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

Use mfem::Workspace for temporary Vector allocations #194

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

sebastiangrimberg
Copy link
Contributor

@sebastiangrimberg sebastiangrimberg commented Feb 9, 2024

NOTE: Builds on #184 (and #194, and now #204)

See mfem/mfem#4065

TODO: Add patch on MFEM for mfem/mfem#4065 to enable this functionality -> Done as part of #184

@sebastiangrimberg sebastiangrimberg added enhancement New feature or request performance Related to performance labels Feb 9, 2024
@sebastiangrimberg sebastiangrimberg force-pushed the sjg/mfem-vector-workspace branch 3 times, most recently from 8cb0852 to dcdd063 Compare February 16, 2024 21:47
@sebastiangrimberg sebastiangrimberg force-pushed the sjg/hypre-interface-dev branch 5 times, most recently from d70f023 to 6c7d418 Compare February 19, 2024 16:41
@sebastiangrimberg sebastiangrimberg marked this pull request as ready for review February 19, 2024 16:44
@sebastiangrimberg sebastiangrimberg force-pushed the sjg/mfem-vector-workspace branch 2 times, most recently from 272a6b1 to eaa4af8 Compare February 22, 2024 01:27
@sebastiangrimberg sebastiangrimberg force-pushed the sjg/hypre-interface-dev branch 2 times, most recently from 74e35d9 to 83f60dd Compare February 22, 2024 02:13
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.

Only important thing is the ComplexWorkspaceVector I think has some very minor issues on the interface/usage of method casting. Otherwise, this is a great change.

palace/linalg/arpack.cpp Outdated Show resolved Hide resolved
Comment on lines 33 to 39
ComplexWorkspaceVector &operator=(ComplexWorkspaceVector &other)
{
ComplexVector::operator=(other);
return *this;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The copy ctor and assignment I think should have const on the arguments: the =delete above doesn't refer to an existing special member function, and given it dispatches to the underlying copy ctor with a const argument, nothing should be lost. Looking at the mfem workspace, I see that's where the lack of const is being copied from, so I asked Will a question there why he dropped it.

Additionally, looking in chebyshev.cpp, I'm slightly confused by the corresponding need for .VecType::operator=(x) which I would think of being for finding a shadowed method. However, I think the type system should be deducing this ok, as the overload resolution for operator= should find the most specialized method. In the case the rhs is a ComplexVector, it's operator=(const ComplexVector &) if it's a ComplexWorkspaceVector it would be operator=(const ComplexWorkspaceVector &). If that isn't working, do you have an idea why?

I was trying to trigger a dispatch error that would require this here but can't get the kind of dispatch error I think this must be addressing, hence the confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, indeed this error was copied from the original PR. Fixed in 8e4148a.

Comment on lines 62 to 65
auto ly = workspace::NewVector<Vector>(test_fespace.GetVSize());
A->Mult(lx, ly);

auto &ty = test_fespace.GetTVector<Vector>();
RestrictionMatrixMult(ly, ty);
b.Add(-1.0, ty);
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

ly can be moved into the limited scope too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This scope block is actually not necessary I think since ly and ty must always be present in the same scope. So I've removed in f3ef607 to be more similar to the rest of the ParOperator functions.

palace/linalg/iterative.cpp Outdated Show resolved Hide resolved
@sebastiangrimberg sebastiangrimberg changed the base branch from sjg/hypre-interface-dev to sjg/complex-gridfunction-dev March 1, 2024 23:15
@sebastiangrimberg sebastiangrimberg force-pushed the sjg/complex-gridfunction-dev branch 2 times, most recently from 702eb30 to ffaeafd Compare March 4, 2024 21:51
Base automatically changed from sjg/complex-gridfunction-dev to main March 4, 2024 22:37
@sebastiangrimberg
Copy link
Contributor Author

sebastiangrimberg commented Mar 4, 2024

Commit 3e5a42b introduces a patch for MFEM to fix the issues discussed here: mfem/mfem#4065 (comment).

@sebastiangrimberg sebastiangrimberg force-pushed the sjg/mfem-vector-workspace branch 2 times, most recently from 1e79930 to 9072819 Compare March 5, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Related to performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants