Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor linear algebra functionality for complex-valued problems #47

Merged
merged 41 commits into from
Aug 22, 2023

Conversation

sebastiangrimberg
Copy link
Contributor

@sebastiangrimberg sebastiangrimberg commented Jun 1, 2023

Previously, Palace leveraged PETSc configured with complex-valued scalars to provide support for solving complex-valued linear systems, using wrapper classes like PetscParMatrix and PetscParVector. With this PR, complex-valued linear algebra functionality is built directly on the underlying MFEM data structures, removing the need for PETSc as a direct dependency (only for the SLEPc eigenvalue solver). For small (sequential) complex-valued linear algebra like for PROM construction, we use Eigen.

This will make features like operator partial-assembly much easier to implement, as well as simplifying eventual GPU support by avoiding many interfaces between PETSc and MFEM objects.

This PR is a prerequisite for #64. Since #64 contains some follow-up changes to changes also made in this PR, I propose we review both simultaneously and only merge #47 quickly followed by #64 once comments with both have been addressed and they are both approved.

TODO

  • Documentation updates for configuration file keywords
  • Update config file schema
  • Changelog

Closes #42

@sebastiangrimberg sebastiangrimberg force-pushed the sjg/driven-port-debug branch 3 times, most recently from 97a68f8 to ff10b89 Compare June 5, 2023 15:23
@sebastiangrimberg sebastiangrimberg changed the base branch from sjg/source-reorg-dev to sjg/arpack-ci-tests June 5, 2023 15:24
@sebastiangrimberg sebastiangrimberg changed the title Draft: Partial-assembly development branch, part 3 Draft: Partial-assembly development branch, part 5 Jun 5, 2023
Base automatically changed from sjg/arpack-ci-tests to sjg/mfem-patches-pa-support June 5, 2023 15:44
@sebastiangrimberg sebastiangrimberg force-pushed the sjg/mfem-patches-pa-support branch 3 times, most recently from dfb66ca to ea571b5 Compare June 5, 2023 16:32
@sebastiangrimberg sebastiangrimberg changed the title Draft: Partial-assembly development branch, part 5 Draft: Partial-assembly development branch, part 3 Jun 13, 2023
@sebastiangrimberg sebastiangrimberg force-pushed the sjg/driven-port-debug branch 2 times, most recently from bb79f42 to 9bbfe39 Compare June 14, 2023 15:41
@sebastiangrimberg sebastiangrimberg changed the title Draft: Partial-assembly development branch, part 3 Draft: Partial-assembly development branch, part 2 Jun 14, 2023
@sebastiangrimberg sebastiangrimberg force-pushed the sjg/mfem-patches-pa-support branch 3 times, most recently from cba2779 to af4a5e5 Compare June 27, 2023 19:03
@sebastiangrimberg sebastiangrimberg force-pushed the sjg/driven-port-debug branch 2 times, most recently from 10c87a4 to 6317e8e Compare June 27, 2023 19:13
Base automatically changed from sjg/mfem-patches-pa-support to main June 30, 2023 15:23
Copy link
Collaborator

@hughcars hughcars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I have definitely missed some things as this was a pretty big read, but hopefully I've caught a good chunk.
  • For derived virtual classes, consider use of final for the class or for overrides if there is no intention of a child in future. Same for choosing between protected and private for member variables and methods.
  • I have a branch hughcars/driven-port-debug-comments where I tried out a few of my suggested changes to check they worked, feel free to take as appropriate. Particularly the ComplexVector value semantics I thiiink are complete on there.

palace/drivers/drivensolver.cpp Outdated Show resolved Hide resolved
palace/linalg/vector.hpp Outdated Show resolved Hide resolved
palace/linalg/vector.hpp Show resolved Hide resolved
palace/linalg/vector.cpp Outdated Show resolved Hide resolved
ComplexVector(int n = 0);

// Copy constructor.
ComplexVector(const ComplexVector &y);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tl;dr: this class needs to match the general c++ value semantics, so I proposed a few changes. For details, see the cpp and hughcars/driven-port-debug-comments for an implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, I've added some subset of the functionality suggested in hughcars/driven-port-debug-comments. For now I've skipped the move constructor since we haven't had a need for it.

palace/models/waveportoperator.cpp Outdated Show resolved Hide resolved
palace/utils/iodata.cpp Show resolved Hide resolved
palace/models/spaceoperator.cpp Show resolved Hide resolved
palace/models/spaceoperator.cpp Show resolved Hide resolved
scripts/schema/config/solver.json Show resolved Hide resolved
Copy link
Collaborator

@hughcars hughcars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I have definitely missed some things as this was a pretty big read, but hopefully I've caught a good chunk.
  • For derived virtual classes, consider use of final for the class or for overrides if there is no intention of a child in future. Same for choosing between protected and private for member variables and methods.
  • I have a branch hughcars/driven-port-debug-comments where I tried out a few of my suggested changes to check they worked, feel free to take as appropriate. Particularly the ComplexVector value semantics I thiiink are complete on there.

…nSolver -> Arpack/SlepcEigenvalueSolver, using instead of typedef, fix some typos in comments
…with a mutable RAP member to avoid some const_cast, clarify some comments, use initializer lists where possible for constructors
sebastiangrimberg added a commit that referenced this pull request Aug 16, 2023
Initial testing shows the expected 2x improvement in number of iterations, where each iteration now doubles in cost at the fine levels due to complex-valued MVP instead of real-valued. However, for expensive coarse solves, this is a substantial improvement and speedups look to be 25% on cavity example. Also adds back Chebyshev smoothing based on the standard 1st-kind polynomials, with runtime options for configuring which variant and the associated tolerances."
Copy link
Collaborator

@hughcars hughcars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still disagree on Arpack and the buffers, but not a hill to die on.

palace/drivers/eigensolver.cpp Show resolved Hide resolved
palace/linalg/ams.cpp Show resolved Hide resolved
palace/linalg/arpack.cpp Show resolved Hide resolved
palace/linalg/arpack.cpp Show resolved Hide resolved
palace/linalg/arpack.cpp Show resolved Hide resolved
@sebastiangrimberg sebastiangrimberg merged commit cdc8e20 into main Aug 22, 2023
17 checks passed
@sebastiangrimberg sebastiangrimberg deleted the sjg/driven-port-debug branch August 22, 2023 17:10
sebastiangrimberg added a commit that referenced this pull request Aug 23, 2023
Initial testing shows the expected 2x improvement in number of iterations, where each iteration now doubles in cost at the fine levels due to complex-valued MVP instead of real-valued. However, for expensive coarse solves, this is a substantial improvement and speedups look to be 25% on cavity example. Also adds back Chebyshev smoothing based on the standard 1st-kind polynomials, with runtime options for configuring which variant and the associated tolerances."
sebastiangrimberg added a commit that referenced this pull request Aug 23, 2023
Initial testing shows the expected 2x improvement in number of iterations, where each iteration now doubles in cost at the fine levels due to complex-valued MVP instead of real-valued. However, for expensive coarse solves, this is a substantial improvement and speedups look to be 25% on cavity example. Also adds back Chebyshev smoothing based on the standard 1st-kind polynomials, with runtime options for configuring which variant and the associated tolerances."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants