forked from AMReX-Codes/amrex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding bittree interface to improve regridding performance in octree …
…mode (AMReX-Codes#3555) ## Summary This PR introduces dependency on [Bittree library](https://github.com/Flash-X/Bittree) to improve regridding performance in octree mode. ## Additional background Testing and development of this feature is done in sync with Flash-X and is recorded in this [reproducibility capsule](https://github.com/Lab-Notebooks/AMReX-Bittree-Performance). This PR is primarily created to consolidate development work and avoid creating multiple branches. At present using AMReX+Bittree improves regridding performance [by a factor of 2](https://github.com/Lab-Notebooks/AMReX-Bittree-Performance/blob/14faa2212c4e5dba7fd99a6526c6937414f9c109/analysis/Performance.ipynb) at > 20000 ranks. We hope to improve performance further using a bittree-based distribution mapping and therefore adding a new function `AmrMesh::MakeDistributionMap` as a place-holder. Continuation of AMReX-Codes#2893 and AMReX-Codes#3547 ## Checklist The proposed changes: - [ ] fix a bug or incorrect behavior in AMReX - [x] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate --------- Co-authored-by: Weiqun Zhang <[email protected]> Co-authored-by: Tom Klosterman <https://github.com/tklos96>
- Loading branch information
1 parent
703a204
commit 8515ea8
Showing
14 changed files
with
737 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#ifndef BL_BITTREE_H_ | ||
#define BL_BITTREE_H_ | ||
|
||
#include <AMReX_IntVect.H> | ||
#include <AMReX_BoxArray.H> | ||
#include <AMReX_DistributionMapping.H> | ||
#include <Bittree_BittreeAmr.h> | ||
|
||
namespace amrex { | ||
|
||
/* | ||
Include in Make.local: | ||
BITTREE_PATH = /path/to/bittree/installation | ||
INCLUDE_LOCATIONS += $(BITTREE_PATH)/include | ||
LIBRARY_LOCATIONS += $(BITTREE_PATH)/lib | ||
LIBRARIES += -lbittree | ||
Include in inputs: | ||
amr.use_bittree = true | ||
*/ | ||
|
||
class btUnit { | ||
// Functions used in AmrMesh | ||
public: | ||
static int btRefine(bittree::BittreeAmr* const mesh, | ||
std::vector<int>& btTags, | ||
int max_crse, int lbase, | ||
Vector<BoxArray>& grids, Vector<DistributionMapping>& dmap, | ||
MPI_Comm comm); | ||
static void btCalculateGrids(bittree::BittreeAmr* const mesh, | ||
int lbase, | ||
int& new_finest, | ||
Vector<BoxArray>& new_grids, | ||
Vector<IntVect> const& max_grid_size); | ||
static void btCalculateLevel(bittree::BittreeAmr* const mesh, | ||
int lev, | ||
BoxArray& ba, | ||
IntVect const& max_grid_size); | ||
// Utils | ||
public: | ||
static int getBitid(bittree::BittreeAmr* const mesh, bool updated, | ||
int lev, int idx_on_lev); | ||
static int getIndex(bittree::BittreeAmr* const mesh, bool updated, | ||
int lev, int bitid); | ||
|
||
// Functions to implement strict octree logic | ||
private: | ||
static void btCheckRefine(bittree::BittreeAmr* const mesh, | ||
std::vector<int>& btTags, | ||
int max_crse, int lbase, | ||
Vector<BoxArray>& grids, Vector<DistributionMapping>& dmap, | ||
MPI_Comm comm); | ||
|
||
static void btCheckDerefine(bittree::BittreeAmr* const mesh, | ||
std::vector<int>& btTags, | ||
int max_crse, int lbase, | ||
Vector<BoxArray>& grids, Vector<DistributionMapping>& dmap, | ||
MPI_Comm comm); | ||
|
||
// Utility Functions | ||
static bool checkNeighborsRefine(bittree::BittreeAmr* const mesh, | ||
bittree::MortonTree::Block b); | ||
static std::vector<int> neighIntCoords(bittree::BittreeAmr* const mesh, | ||
unsigned lev, unsigned* lcoord, | ||
int* gCell); | ||
|
||
public: | ||
// Represents whether domain has periodic BC in each direction | ||
// true = Periodic, false = Non-Periodic | ||
static bool bcPeriodic[AMREX_SPACEDIM]; | ||
}; | ||
|
||
|
||
} | ||
#endif |
Oops, something went wrong.