-
Notifications
You must be signed in to change notification settings - Fork 38
Change ORB to support arbitrary decomposition axes #560
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
Open
aliemen
wants to merge
5
commits into
master
Choose a base branch
from
559-orb-does-not-allow-arbitrary-decomposition-axis
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2ae70be
Change ORB to support arbitrary decomposition axes and improve domain…
aliemen 9e8162f
Add ORB unit test for Dim>1 that tests arbitrary cut axis
aliemen f812516
Collective clang-format
aliemen eac1088
Merge branch 'master' into 559-orb-does-not-allow-arbitrary-decomposi…
aliemen 8869c39
Merge branch 'master' into 559-orb-does-not-allow-arbitrary-decomposi…
aliemen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,11 @@ | |
| #ifndef IPPL_ORTHOGONAL_RECURSIVE_BISECTION_H | ||
| #define IPPL_ORTHOGONAL_RECURSIVE_BISECTION_H | ||
|
|
||
| #include <algorithm> | ||
| #include <array> | ||
| #include <numeric> | ||
| #include <vector> | ||
|
|
||
| #include "FieldLayout/FieldLayout.h" | ||
| #include "Index/Index.h" | ||
| #include "Index/NDIndex.h" | ||
|
|
@@ -44,7 +49,8 @@ namespace ippl { | |
|
|
||
| /*! | ||
| * Performs scatter operation of particle positions in field (weights) and | ||
| * repartitions FieldLayout's global domain | ||
| * repartitions FieldLayout's global domain. This overload preserves the | ||
| * legacy ORB behavior by allowing cuts along all axes. | ||
| * @tparam Attrib the particle attribute type (memory space must be accessible to field | ||
| * memory) | ||
| * @param R Weights to scatter | ||
|
|
@@ -55,12 +61,48 @@ namespace ippl { | |
| bool binaryRepartition(const Attrib& R, FieldLayout<Dim>& fl, | ||
| const bool& isFirstRepartition); | ||
|
|
||
| /*! | ||
| * Performs scatter operation of particle positions in field (weights) and | ||
| * repartitions FieldLayout's global domain using only the enabled axes. | ||
| * The FieldLayout and the ORB weight field are updated only after the proposed | ||
| * domains pass validation. | ||
| * @tparam Attrib the particle attribute type (memory space must be accessible to field | ||
| * memory) | ||
| * @param R Weights to scatter | ||
| * @param fl FieldLayout | ||
| * @param isFirstRepartition boolean which tells whether to scatter or not | ||
| * @param allowedAxes true for axes ORB is allowed to cut | ||
| */ | ||
| template <typename Attrib> | ||
| bool binaryRepartition(const Attrib& R, FieldLayout<Dim>& fl, | ||
| const bool& isFirstRepartition, | ||
| const std::array<bool, Dim>& allowedAxes); | ||
|
|
||
| /*! | ||
| * Find cutting axis as the longest axis of the field layout. | ||
| * @param dom Domain to reduce | ||
| */ | ||
| int findCutAxis(NDIndex<Dim>& dom); | ||
|
|
||
| /*! | ||
| * Find cutting axis as the longest enabled axis of the field layout. | ||
| * @param dom Domain to reduce | ||
| * @param allowedAxes true for axes ORB is allowed to cut | ||
| */ | ||
| int findCutAxis(const NDIndex<Dim>& dom, const std::array<bool, Dim>& allowedAxes); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar comment as above can't we have only one signature with a default argument? |
||
|
|
||
| /*! | ||
| * Check whether two domains overlap. | ||
| */ | ||
| bool domainsOverlap(const NDIndex<Dim>& lhs, const NDIndex<Dim>& rhs) const; | ||
|
|
||
| /*! | ||
| * Check whether proposed domains tile the global domain without cutting serial axes. | ||
| */ | ||
| bool domainsTileAllowedDecomposition(const std::vector<NDIndex<Dim>>& domains, | ||
| const NDIndex<Dim>& globalDomain, | ||
| const std::array<bool, Dim>& allowedAxes) const; | ||
|
|
||
| /*! | ||
| * Performs reduction on local field in all dimension except that determined | ||
| * by cutAxis, stores result in res | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to have these overloads? Can't we just use this signature alone with a default argument of
allowedAxes=truefor all dimensions to preserve the legacy behaviour? Or is it just to avoid default arguments as it may not be a good practice (although I don't immediately see the disadvantages here)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having a default would be nicer. In 3D one could simply write
std::array<bool, Dim> = {true, true, true}. But since it's dimension independent, we would either need a helper or a lambda invokation. The latter would look like this (for your second example):I'm honestly not sure what's cleaner. But the overload is perhaps easier to read?
If we really want a simple default argument, we could change the semantics to "forbiddenAxes". Then$\equiv$ all axes allowed) and one could write
falsewould be the default (std::array<bool, Dim> allowedAxes = {}. Note that this is now by value, not by reference.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just let me know what you prefer, I'm fine with all three versions.