Skip to content

Commit

Permalink
CarpetX: only multi-thread MFIter if AMReX supports it
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaas80 committed Jul 23, 2023
1 parent 9047df5 commit 5eed0f8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CarpetX/src/driver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,9 @@ void CactusAmrCore::ErrorEst(const int level, amrex::TagBoxArray &tags,
[]() { return "ErrorEst"; });
std::size_t npoints_set = 0, npoints_clear = 0, npoints_total = 0;
auto mfitinfo = amrex::MFItInfo().SetDynamic(true).EnableTiling();
#ifdef AMREX_USE_OMP
#pragma omp parallel
#endif
for (amrex::MFIter mfi(*leveldata.fab, mfitinfo); mfi.isValid(); ++mfi) {
GridPtrDesc1 grid(leveldata, groupdata, mfi);

Expand Down
2 changes: 2 additions & 0 deletions CarpetX/src/reduction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ reduction<CCTK_REAL, dim> reduce(int gi, int vi, int tl) {
// TODO: check that multi-threading actually helps (and we are
// not dominated by memory latency)
// TODO: document required version of OpenMP to use custom reductions
#ifdef AMREX_USE_OMP
#pragma omp parallel reduction(reduction : red)
#endif
for (amrex::MFIter mfi(mfab, mfitinfo); mfi.isValid(); ++mfi) {
const amrex::Box &bx = mfi.tilebox(); // current tile (without ghosts)
const vect<int, dim> tmin{bx.smallEnd(0), bx.smallEnd(1),
Expand Down
4 changes: 4 additions & 0 deletions CarpetX/src/valid.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,9 @@ calculate_checksums(const vector<vector<vector<valid_t> > > &will_write) {
assert(active_levels);
active_levels->loop([&](auto &restrict leveldata) {
auto mfitinfo = amrex::MFItInfo().SetDynamic(true).EnableTiling();
#ifdef AMREX_USE_OMP
#pragma omp parallel
#endif
for (amrex::MFIter mfi(*leveldata.fab, mfitinfo); mfi.isValid(); ++mfi) {

for (const auto &groupdataptr : leveldata.groupdata) {
Expand Down Expand Up @@ -563,7 +565,9 @@ void check_checksums(const checksums_t &checksums,
assert(active_levels);
active_levels->loop([&](auto &restrict leveldata) {
auto mfitinfo = amrex::MFItInfo().SetDynamic(true).EnableTiling();
#ifdef AMREX_USE_OMP
#pragma omp parallel
#endif
for (amrex::MFIter mfi(*leveldata.fab, mfitinfo); mfi.isValid(); ++mfi) {

for (const auto &groupdataptr : leveldata.groupdata) {
Expand Down

0 comments on commit 5eed0f8

Please sign in to comment.