aboutsummaryrefslogtreecommitdiff
path: root/Source/Parallelization
diff options
context:
space:
mode:
authorGravatar Axel Huebl <axel.huebl@plasma.ninja> 2022-06-08 14:51:16 -0700
committerGravatar GitHub <noreply@github.com> 2022-06-08 14:51:16 -0700
commitd4a3b6f0de6dc42a7d971680a653b7684afa6e3f (patch)
tree69a94459fe306e3600f67401814de422dcc1cb6f /Source/Parallelization
parent1b812906b333b407b45f5bec015ba06e3faa5abd (diff)
downloadWarpX-d4a3b6f0de6dc42a7d971680a653b7684afa6e3f.tar.gz
WarpX-d4a3b6f0de6dc42a7d971680a653b7684afa6e3f.tar.zst
WarpX-d4a3b6f0de6dc42a7d971680a653b7684afa6e3f.zip
ABLASTR: Move Communication Utilities (#3167)
* Move: WarpXCommUtils to ABLASTR * Update Usage Locations * Refactor: `WarpX::do_single_precision_comms` Do not use a global from WarpX in ABLASTR routines.
Diffstat (limited to 'Source/Parallelization')
-rw-r--r--Source/Parallelization/CMakeLists.txt1
-rw-r--r--Source/Parallelization/Make.package1
-rw-r--r--Source/Parallelization/WarpXComm.cpp180
-rw-r--r--Source/Parallelization/WarpXCommUtil.H95
-rw-r--r--Source/Parallelization/WarpXCommUtil.cpp253
-rw-r--r--Source/Parallelization/WarpXSumGuardCells.H6
6 files changed, 108 insertions, 428 deletions
diff --git a/Source/Parallelization/CMakeLists.txt b/Source/Parallelization/CMakeLists.txt
index 0c75c7542..3588f6f31 100644
--- a/Source/Parallelization/CMakeLists.txt
+++ b/Source/Parallelization/CMakeLists.txt
@@ -3,5 +3,4 @@ target_sources(WarpX
GuardCellManager.cpp
WarpXComm.cpp
WarpXRegrid.cpp
- WarpXCommUtil.cpp
)
diff --git a/Source/Parallelization/Make.package b/Source/Parallelization/Make.package
index 87955f814..629cfafea 100644
--- a/Source/Parallelization/Make.package
+++ b/Source/Parallelization/Make.package
@@ -1,6 +1,5 @@
CEXE_sources += WarpXComm.cpp
CEXE_sources += WarpXRegrid.cpp
CEXE_sources += GuardCellManager.cpp
-CEXE_sources += WarpXCommUtil.cpp
VPATH_LOCATIONS += $(WARPX_HOME)/Source/Parallelization
diff --git a/Source/Parallelization/WarpXComm.cpp b/Source/Parallelization/WarpXComm.cpp
index 539976a0a..c5e83c5bc 100644
--- a/Source/Parallelization/WarpXComm.cpp
+++ b/Source/Parallelization/WarpXComm.cpp
@@ -19,9 +19,10 @@
#include "Utils/WarpXAlgorithmSelection.H"
#include "Utils/WarpXProfilerWrapper.H"
#include "WarpXComm_K.H"
-#include "WarpXCommUtil.H"
#include "WarpXSumGuardCells.H"
+#include <ablastr/utils/Communication.H>
+
#include <AMReX.H>
#include <AMReX_Array.H>
#include <AMReX_Array4.H>
@@ -177,7 +178,8 @@ WarpX::UpdateAuxilaryDataStagToNodal ()
const amrex::IntVect& ng_src = guard_cells.ng_FieldGather;
// Copy Bfield_aux to Btmp, using up to ng_src (=ng_FieldGather) guard cells from
// Bfield_aux and filling up to ng (=nGrow) guard cells in Btmp
- WarpXCommUtil::ParallelCopy(*Btmp[i], *Bfield_aux[lev-1][i], 0, 0, 1, ng_src, ng, cperiod);
+ ablastr::utils::communication::ParallelCopy(*Btmp[i], *Bfield_aux[lev - 1][i], 0, 0, 1,
+ ng_src, ng, WarpX::do_single_precision_comms, cperiod);
}
#ifdef AMREX_USE_OMP
@@ -234,7 +236,8 @@ WarpX::UpdateAuxilaryDataStagToNodal ()
const amrex::IntVect& ng_src = guard_cells.ng_FieldGather;
// Copy Efield_aux to Etmp, using up to ng_src (=ng_FieldGather) guard cells from
// Efield_aux and filling up to ng (=nGrow) guard cells in Etmp
- WarpXCommUtil::ParallelCopy(*Etmp[i], *Efield_aux[lev-1][i], 0, 0, 1, ng_src, ng, cperiod);
+ ablastr::utils::communication::ParallelCopy(*Etmp[i], *Efield_aux[lev - 1][i], 0, 0, 1,
+ ng_src, ng, WarpX::do_single_precision_comms, cperiod);
}
#ifdef AMREX_USE_OMP
@@ -291,9 +294,15 @@ WarpX::UpdateAuxilaryDataSameType ()
// Copy Bfield_aux to the dB MultiFabs, using up to ng_src (=ng_FieldGather) guard
// cells from Bfield_aux and filling up to ng (=nGrow) guard cells in the dB MultiFabs
- WarpXCommUtil::ParallelCopy(dBx, *Bfield_aux[lev-1][0], 0, 0, Bfield_aux[lev-1][0]->nComp(), ng_src, ng, crse_period);
- WarpXCommUtil::ParallelCopy(dBy, *Bfield_aux[lev-1][1], 0, 0, Bfield_aux[lev-1][1]->nComp(), ng_src, ng, crse_period);
- WarpXCommUtil::ParallelCopy(dBz, *Bfield_aux[lev-1][2], 0, 0, Bfield_aux[lev-1][2]->nComp(), ng_src, ng, crse_period);
+ ablastr::utils::communication::ParallelCopy(dBx, *Bfield_aux[lev - 1][0], 0, 0,
+ Bfield_aux[lev - 1][0]->nComp(), ng_src, ng, WarpX::do_single_precision_comms,
+ crse_period);
+ ablastr::utils::communication::ParallelCopy(dBy, *Bfield_aux[lev - 1][1], 0, 0,
+ Bfield_aux[lev - 1][1]->nComp(), ng_src, ng, WarpX::do_single_precision_comms,
+ crse_period);
+ ablastr::utils::communication::ParallelCopy(dBz, *Bfield_aux[lev - 1][2], 0, 0,
+ Bfield_aux[lev - 1][2]->nComp(), ng_src, ng, WarpX::do_single_precision_comms,
+ crse_period);
if (Bfield_cax[lev][0])
{
@@ -355,9 +364,18 @@ WarpX::UpdateAuxilaryDataSameType ()
const amrex::IntVect& ng_src = guard_cells.ng_FieldGather;
// Copy Efield_aux to the dE MultiFabs, using up to ng_src (=ng_FieldGather) guard
// cells from Efield_aux and filling up to ng (=nGrow) guard cells in the dE MultiFabs
- WarpXCommUtil::ParallelCopy(dEx, *Efield_aux[lev-1][0], 0, 0, Efield_aux[lev-1][0]->nComp(), ng_src, ng, crse_period);
- WarpXCommUtil::ParallelCopy(dEy, *Efield_aux[lev-1][1], 0, 0, Efield_aux[lev-1][1]->nComp(), ng_src, ng, crse_period);
- WarpXCommUtil::ParallelCopy(dEz, *Efield_aux[lev-1][2], 0, 0, Efield_aux[lev-1][2]->nComp(), ng_src, ng, crse_period);
+ ablastr::utils::communication::ParallelCopy(dEx, *Efield_aux[lev - 1][0], 0, 0,
+ Efield_aux[lev - 1][0]->nComp(), ng_src, ng,
+ WarpX::do_single_precision_comms,
+ crse_period);
+ ablastr::utils::communication::ParallelCopy(dEy, *Efield_aux[lev - 1][1], 0, 0,
+ Efield_aux[lev - 1][1]->nComp(), ng_src, ng,
+ WarpX::do_single_precision_comms,
+ crse_period);
+ ablastr::utils::communication::ParallelCopy(dEz, *Efield_aux[lev - 1][2], 0, 0,
+ Efield_aux[lev - 1][2]->nComp(), ng_src, ng,
+ WarpX::do_single_precision_comms,
+ crse_period);
if (Efield_cax[lev][0])
{
@@ -563,7 +581,7 @@ WarpX::FillBoundaryE (const int lev, const PatchType patch_type, const amrex::In
"Error: in FillBoundaryE, requested more guard cells than allocated");
const amrex::IntVect nghost = (safe_guard_cells) ? mf[i]->nGrowVect() : ng;
- WarpXCommUtil::FillBoundary(*mf[i], nghost, period, nodal_sync);
+ ablastr::utils::communication::FillBoundary(*mf[i], nghost, WarpX::do_single_precision_comms, period, nodal_sync);
}
}
@@ -620,7 +638,7 @@ WarpX::FillBoundaryB (const int lev, const PatchType patch_type, const amrex::In
"Error: in FillBoundaryB, requested more guard cells than allocated");
const amrex::IntVect nghost = (safe_guard_cells) ? mf[i]->nGrowVect() : ng;
- WarpXCommUtil::FillBoundary(*mf[i], nghost, period, nodal_sync);
+ ablastr::utils::communication::FillBoundary(*mf[i], nghost, WarpX::do_single_precision_comms, period, nodal_sync);
}
}
@@ -644,14 +662,14 @@ WarpX::FillBoundaryE_avg (int lev, PatchType patch_type, IntVect ng)
const amrex::Periodicity& period = Geom(lev).periodicity();
if ( safe_guard_cells ){
Vector<MultiFab*> mf{Efield_avg_fp[lev][0].get(),Efield_avg_fp[lev][1].get(),Efield_avg_fp[lev][2].get()};
- WarpXCommUtil::FillBoundary(mf, period);
+ ablastr::utils::communication::FillBoundary(mf, WarpX::do_single_precision_comms, period);
} else {
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
ng <= Efield_avg_fp[lev][0]->nGrowVect(),
"Error: in FillBoundaryE_avg, requested more guard cells than allocated");
- WarpXCommUtil::FillBoundary(*Efield_avg_fp[lev][0], ng, period);
- WarpXCommUtil::FillBoundary(*Efield_avg_fp[lev][1], ng, period);
- WarpXCommUtil::FillBoundary(*Efield_avg_fp[lev][2], ng, period);
+ ablastr::utils::communication::FillBoundary(*Efield_avg_fp[lev][0], ng, WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::FillBoundary(*Efield_avg_fp[lev][1], ng, WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::FillBoundary(*Efield_avg_fp[lev][2], ng, WarpX::do_single_precision_comms, period);
}
}
else if (patch_type == PatchType::coarse)
@@ -664,15 +682,15 @@ WarpX::FillBoundaryE_avg (int lev, PatchType patch_type, IntVect ng)
const amrex::Periodicity& cperiod = Geom(lev-1).periodicity();
if ( safe_guard_cells ) {
Vector<MultiFab*> mf{Efield_avg_cp[lev][0].get(),Efield_avg_cp[lev][1].get(),Efield_avg_cp[lev][2].get()};
- WarpXCommUtil::FillBoundary(mf, cperiod);
+ ablastr::utils::communication::FillBoundary(mf, WarpX::do_single_precision_comms, cperiod);
} else {
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
ng <= Efield_avg_cp[lev][0]->nGrowVect(),
"Error: in FillBoundaryE, requested more guard cells than allocated");
- WarpXCommUtil::FillBoundary(*Efield_avg_cp[lev][0], ng, cperiod);
- WarpXCommUtil::FillBoundary(*Efield_avg_cp[lev][1], ng, cperiod);
- WarpXCommUtil::FillBoundary(*Efield_avg_cp[lev][2], ng, cperiod);
+ ablastr::utils::communication::FillBoundary(*Efield_avg_cp[lev][0], ng, WarpX::do_single_precision_comms, cperiod);
+ ablastr::utils::communication::FillBoundary(*Efield_avg_cp[lev][1], ng, WarpX::do_single_precision_comms, cperiod);
+ ablastr::utils::communication::FillBoundary(*Efield_avg_cp[lev][2], ng, WarpX::do_single_precision_comms, cperiod);
}
}
}
@@ -697,14 +715,14 @@ WarpX::FillBoundaryB_avg (int lev, PatchType patch_type, IntVect ng)
const amrex::Periodicity& period = Geom(lev).periodicity();
if ( safe_guard_cells ) {
Vector<MultiFab*> mf{Bfield_avg_fp[lev][0].get(),Bfield_avg_fp[lev][1].get(),Bfield_avg_fp[lev][2].get()};
- WarpXCommUtil::FillBoundary(mf, period);
+ ablastr::utils::communication::FillBoundary(mf, WarpX::do_single_precision_comms, period);
} else {
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
ng <= Bfield_fp[lev][0]->nGrowVect(),
"Error: in FillBoundaryB, requested more guard cells than allocated");
- WarpXCommUtil::FillBoundary(*Bfield_avg_fp[lev][0], ng, period);
- WarpXCommUtil::FillBoundary(*Bfield_avg_fp[lev][1], ng, period);
- WarpXCommUtil::FillBoundary(*Bfield_avg_fp[lev][2], ng, period);
+ ablastr::utils::communication::FillBoundary(*Bfield_avg_fp[lev][0], ng, WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::FillBoundary(*Bfield_avg_fp[lev][1], ng, WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::FillBoundary(*Bfield_avg_fp[lev][2], ng, WarpX::do_single_precision_comms, period);
}
}
else if (patch_type == PatchType::coarse)
@@ -717,14 +735,14 @@ WarpX::FillBoundaryB_avg (int lev, PatchType patch_type, IntVect ng)
const amrex::Periodicity& cperiod = Geom(lev-1).periodicity();
if ( safe_guard_cells ){
Vector<MultiFab*> mf{Bfield_avg_cp[lev][0].get(),Bfield_avg_cp[lev][1].get(),Bfield_avg_cp[lev][2].get()};
- WarpXCommUtil::FillBoundary(mf, cperiod);
+ ablastr::utils::communication::FillBoundary(mf, WarpX::do_single_precision_comms, cperiod);
} else {
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
ng <= Bfield_avg_cp[lev][0]->nGrowVect(),
"Error: in FillBoundaryB_avg, requested more guard cells than allocated");
- WarpXCommUtil::FillBoundary(*Bfield_avg_cp[lev][0], ng, cperiod);
- WarpXCommUtil::FillBoundary(*Bfield_avg_cp[lev][1], ng, cperiod);
- WarpXCommUtil::FillBoundary(*Bfield_avg_cp[lev][2], ng, cperiod);
+ ablastr::utils::communication::FillBoundary(*Bfield_avg_cp[lev][0], ng, WarpX::do_single_precision_comms, cperiod);
+ ablastr::utils::communication::FillBoundary(*Bfield_avg_cp[lev][1], ng, WarpX::do_single_precision_comms, cperiod);
+ ablastr::utils::communication::FillBoundary(*Bfield_avg_cp[lev][2], ng, WarpX::do_single_precision_comms, cperiod);
}
}
}
@@ -751,7 +769,7 @@ WarpX::FillBoundaryF (int lev, PatchType patch_type, IntVect ng, const bool noda
{
const amrex::Periodicity& period = Geom(lev).periodicity();
const amrex::IntVect& nghost = (safe_guard_cells) ? F_fp[lev]->nGrowVect() : ng;
- WarpXCommUtil::FillBoundary(*F_fp[lev], nghost, period, nodal_sync);
+ ablastr::utils::communication::FillBoundary(*F_fp[lev], nghost, WarpX::do_single_precision_comms, period, nodal_sync);
}
}
else if (patch_type == PatchType::coarse)
@@ -766,7 +784,7 @@ WarpX::FillBoundaryF (int lev, PatchType patch_type, IntVect ng, const bool noda
{
const amrex::Periodicity& period = Geom(lev-1).periodicity();
const amrex::IntVect& nghost = (safe_guard_cells) ? F_cp[lev]->nGrowVect() : ng;
- WarpXCommUtil::FillBoundary(*F_cp[lev], nghost, period, nodal_sync);
+ ablastr::utils::communication::FillBoundary(*F_cp[lev], nghost, WarpX::do_single_precision_comms, period, nodal_sync);
}
}
}
@@ -795,7 +813,7 @@ void WarpX::FillBoundaryG (int lev, PatchType patch_type, IntVect ng, const bool
{
const amrex::Periodicity& period = Geom(lev).periodicity();
const amrex::IntVect& nghost = (safe_guard_cells) ? G_fp[lev]->nGrowVect() : ng;
- WarpXCommUtil::FillBoundary(*G_fp[lev], nghost, period, nodal_sync);
+ ablastr::utils::communication::FillBoundary(*G_fp[lev], nghost, WarpX::do_single_precision_comms, period, nodal_sync);
}
}
else if (patch_type == PatchType::coarse)
@@ -810,7 +828,7 @@ void WarpX::FillBoundaryG (int lev, PatchType patch_type, IntVect ng, const bool
{
const amrex::Periodicity& period = Geom(lev-1).periodicity();
const amrex::IntVect& nghost = (safe_guard_cells) ? G_cp[lev]->nGrowVect() : ng;
- WarpXCommUtil::FillBoundary(*G_cp[lev], nghost, period, nodal_sync);
+ ablastr::utils::communication::FillBoundary(*G_cp[lev], nghost, WarpX::do_single_precision_comms, period, nodal_sync);
}
}
}
@@ -828,12 +846,12 @@ void
WarpX::FillBoundaryAux (int lev, IntVect ng)
{
const amrex::Periodicity& period = Geom(lev).periodicity();
- WarpXCommUtil::FillBoundary(*Efield_aux[lev][0], ng, period);
- WarpXCommUtil::FillBoundary(*Efield_aux[lev][1], ng, period);
- WarpXCommUtil::FillBoundary(*Efield_aux[lev][2], ng, period);
- WarpXCommUtil::FillBoundary(*Bfield_aux[lev][0], ng, period);
- WarpXCommUtil::FillBoundary(*Bfield_aux[lev][1], ng, period);
- WarpXCommUtil::FillBoundary(*Bfield_aux[lev][2], ng, period);
+ ablastr::utils::communication::FillBoundary(*Efield_aux[lev][0], ng, WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::FillBoundary(*Efield_aux[lev][1], ng, WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::FillBoundary(*Efield_aux[lev][2], ng, WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::FillBoundary(*Bfield_aux[lev][0], ng, WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::FillBoundary(*Bfield_aux[lev][1], ng, WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::FillBoundary(*Bfield_aux[lev][2], ng, WarpX::do_single_precision_comms, period);
}
void
@@ -1034,7 +1052,8 @@ void WarpX::AddCurrentFromFineLevelandSumBoundary (
bilinear_filter.ApplyStencil(jfb, *current_buf[lev+1][idim], lev+1);
MultiFab::Add(jfb, jfc, 0, 0, current_buf[lev+1][idim]->nComp(), ng);
- WarpXCommUtil::ParallelAdd(mf, jfb, 0, 0, current_buf[lev+1][idim]->nComp(), ng, IntVect::TheZeroVector(), period);
+ ablastr::utils::communication::ParallelAdd(mf, jfb, 0, 0, current_buf[lev + 1][idim]->nComp(),
+ ng, IntVect::TheZeroVector(), WarpX::do_single_precision_comms, period);
WarpXSumGuardCells(*J_cp[lev+1][idim], jfc, period, ng_depos_J, 0, J_cp[lev+1][idim]->nComp());
}
@@ -1048,7 +1067,8 @@ void WarpX::AddCurrentFromFineLevelandSumBoundary (
J_cp[lev+1][idim]->DistributionMap(), J_cp[lev+1][idim]->nComp(), ng);
bilinear_filter.ApplyStencil(jf, *J_cp[lev+1][idim], lev+1);
- WarpXCommUtil::ParallelAdd(mf, jf, 0, 0, J_cp[lev+1][idim]->nComp(), ng, IntVect::TheZeroVector(), period);
+ ablastr::utils::communication::ParallelAdd(mf, jf, 0, 0, J_cp[lev + 1][idim]->nComp(), ng,
+ IntVect::TheZeroVector(), WarpX::do_single_precision_comms, period);
WarpXSumGuardCells(*J_cp[lev+1][idim], jf, period, ng_depos_J, 0, J_cp[lev+1][idim]->nComp());
}
else if (current_buf[lev+1][idim]) // but no filter
@@ -1057,17 +1077,21 @@ void WarpX::AddCurrentFromFineLevelandSumBoundary (
MultiFab::Add(*current_buf[lev+1][idim],
*J_cp [lev+1][idim], 0, 0, current_buf[lev+1][idim]->nComp(),
J_cp[lev+1][idim]->nGrowVect());
- WarpXCommUtil::ParallelAdd(mf, *current_buf[lev+1][idim], 0, 0, current_buf[lev+1][idim]->nComp(),
- current_buf[lev+1][idim]->nGrowVect(), IntVect::TheZeroVector(),
- period);
+ ablastr::utils::communication::ParallelAdd(mf, *current_buf[lev + 1][idim], 0, 0,
+ current_buf[lev + 1][idim]->nComp(),
+ current_buf[lev + 1][idim]->nGrowVect(),
+ IntVect::TheZeroVector(), WarpX::do_single_precision_comms,
+ period);
WarpXSumGuardCells(*(J_cp[lev+1][idim]), period, ng_depos_J, 0, J_cp[lev+1][idim]->nComp());
}
else // no filter, no buffer
{
ng_depos_J.min(ng);
- WarpXCommUtil::ParallelAdd(mf, *J_cp[lev+1][idim], 0, 0, J_cp[lev+1][idim]->nComp(),
- J_cp[lev+1][idim]->nGrowVect(), IntVect::TheZeroVector(),
- period);
+ ablastr::utils::communication::ParallelAdd(mf, *J_cp[lev + 1][idim], 0, 0,
+ J_cp[lev + 1][idim]->nComp(),
+ J_cp[lev + 1][idim]->nGrowVect(),
+ IntVect::TheZeroVector(), WarpX::do_single_precision_comms,
+ period);
WarpXSumGuardCells(*(J_cp[lev+1][idim]), period, ng_depos_J, 0, J_cp[lev+1][idim]->nComp());
}
MultiFab::Add(*J_fp[lev][idim], mf, 0, 0, J_fp[lev+1][idim]->nComp(), 0);
@@ -1170,7 +1194,8 @@ void WarpX::AddRhoFromFineLevelandSumBoundary (
MultiFab::Add(rhofb, rhofc, 0, 0, ncomp, ng);
- WarpXCommUtil::ParallelAdd(mf, rhofb, 0, 0, ncomp, ng, IntVect::TheZeroVector(), period);
+ ablastr::utils::communication::ParallelAdd(mf, rhofb, 0, 0, ncomp, ng, IntVect::TheZeroVector(),
+ WarpX::do_single_precision_comms, period);
WarpXSumGuardCells( *charge_cp[lev+1], rhofc, period, ng_depos_rho, icomp, ncomp );
}
else if (use_filter) // but no buffer
@@ -1181,7 +1206,8 @@ void WarpX::AddRhoFromFineLevelandSumBoundary (
MultiFab rf(charge_cp[lev+1]->boxArray(), charge_cp[lev+1]->DistributionMap(), ncomp, ng);
bilinear_filter.ApplyStencil(rf, *charge_cp[lev+1], lev+1, icomp, 0, ncomp);
- WarpXCommUtil::ParallelAdd(mf, rf, 0, 0, ncomp, ng, IntVect::TheZeroVector(), period);
+ ablastr::utils::communication::ParallelAdd(mf, rf, 0, 0, ncomp, ng, IntVect::TheZeroVector(),
+ WarpX::do_single_precision_comms, period);
WarpXSumGuardCells( *charge_cp[lev+1], rf, period, ng_depos_rho, icomp, ncomp );
}
else if (charge_buf[lev+1]) // but no filter
@@ -1191,18 +1217,20 @@ void WarpX::AddRhoFromFineLevelandSumBoundary (
*charge_cp[lev+1], icomp, icomp, ncomp,
charge_cp[lev+1]->nGrowVect());
- WarpXCommUtil::ParallelAdd(mf, *charge_buf[lev+1], icomp, 0,
- ncomp,
- charge_buf[lev+1]->nGrowVect(), IntVect::TheZeroVector(),
- period);
+ ablastr::utils::communication::ParallelAdd(mf, *charge_buf[lev + 1], icomp, 0,
+ ncomp,
+ charge_buf[lev + 1]->nGrowVect(),
+ IntVect::TheZeroVector(), WarpX::do_single_precision_comms,
+ period);
WarpXSumGuardCells(*(charge_cp[lev+1]), period, ng_depos_rho, icomp, ncomp);
}
else // no filter, no buffer
{
ng_depos_rho.min(ng);
- WarpXCommUtil::ParallelAdd(mf, *charge_cp[lev+1], icomp, 0, ncomp,
- charge_cp[lev+1]->nGrowVect(), IntVect::TheZeroVector(),
- period);
+ ablastr::utils::communication::ParallelAdd(mf, *charge_cp[lev + 1], icomp, 0, ncomp,
+ charge_cp[lev + 1]->nGrowVect(),
+ IntVect::TheZeroVector(), WarpX::do_single_precision_comms,
+ period);
WarpXSumGuardCells(*(charge_cp[lev+1]), period, ng_depos_rho, icomp, ncomp);
}
MultiFab::Add(*charge_fp[lev], mf, 0, icomp, ncomp, 0);
@@ -1220,16 +1248,16 @@ void WarpX::NodalSyncJ (
if (patch_type == PatchType::fine)
{
const amrex::Periodicity& period = Geom(lev).periodicity();
- WarpXCommUtil::OverrideSync(*J_fp[lev][0], period);
- WarpXCommUtil::OverrideSync(*J_fp[lev][1], period);
- WarpXCommUtil::OverrideSync(*J_fp[lev][2], period);
+ ablastr::utils::communication::OverrideSync(*J_fp[lev][0], WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::OverrideSync(*J_fp[lev][1], WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::OverrideSync(*J_fp[lev][2], WarpX::do_single_precision_comms, period);
}
else if (patch_type == PatchType::coarse)
{
const amrex::Periodicity& cperiod = Geom(lev-1).periodicity();
- WarpXCommUtil::OverrideSync(*J_cp[lev][0], cperiod);
- WarpXCommUtil::OverrideSync(*J_cp[lev][1], cperiod);
- WarpXCommUtil::OverrideSync(*J_cp[lev][2], cperiod);
+ ablastr::utils::communication::OverrideSync(*J_cp[lev][0], WarpX::do_single_precision_comms, cperiod);
+ ablastr::utils::communication::OverrideSync(*J_cp[lev][1], WarpX::do_single_precision_comms, cperiod);
+ ablastr::utils::communication::OverrideSync(*J_cp[lev][2], WarpX::do_single_precision_comms, cperiod);
}
}
@@ -1247,13 +1275,13 @@ void WarpX::NodalSyncRho (
{
const amrex::Periodicity& period = Geom(lev).periodicity();
MultiFab rhof(*charge_fp[lev], amrex::make_alias, icomp, ncomp);
- WarpXCommUtil::OverrideSync(rhof, period);
+ ablastr::utils::communication::OverrideSync(rhof, WarpX::do_single_precision_comms, period);
}
else if (patch_type == PatchType::coarse && charge_cp[lev])
{
const amrex::Periodicity& cperiod = Geom(lev-1).periodicity();
MultiFab rhoc(*charge_cp[lev], amrex::make_alias, icomp, ncomp);
- WarpXCommUtil::OverrideSync(rhoc, cperiod);
+ ablastr::utils::communication::OverrideSync(rhoc, WarpX::do_single_precision_comms, cperiod);
}
}
@@ -1283,17 +1311,17 @@ void WarpX::NodalSyncPML (int lev, PatchType patch_type)
// Always synchronize nodal points
const amrex::Periodicity& period = Geom(lev).periodicity();
- WarpXCommUtil::OverrideSync(*pml_E[0], period);
- WarpXCommUtil::OverrideSync(*pml_E[1], period);
- WarpXCommUtil::OverrideSync(*pml_E[2], period);
- WarpXCommUtil::OverrideSync(*pml_B[0], period);
- WarpXCommUtil::OverrideSync(*pml_B[1], period);
- WarpXCommUtil::OverrideSync(*pml_B[2], period);
+ ablastr::utils::communication::OverrideSync(*pml_E[0], WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::OverrideSync(*pml_E[1], WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::OverrideSync(*pml_E[2], WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::OverrideSync(*pml_B[0], WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::OverrideSync(*pml_B[1], WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::OverrideSync(*pml_B[2], WarpX::do_single_precision_comms, period);
if (pml_F) {
- WarpXCommUtil::OverrideSync(*pml_F, period);
+ ablastr::utils::communication::OverrideSync(*pml_F, WarpX::do_single_precision_comms, period);
}
if (pml_G) {
- WarpXCommUtil::OverrideSync(*pml_G, period);
+ ablastr::utils::communication::OverrideSync(*pml_G, WarpX::do_single_precision_comms, period);
}
}
@@ -1324,16 +1352,16 @@ void WarpX::NodalSync (amrex::Vector<std::array<std::unique_ptr<amrex::MultiFab>
for (int lev = 0; lev <= WarpX::finest_level; lev++)
{
const amrex::Periodicity& period = Geom(lev).periodicity();
- WarpXCommUtil::OverrideSync(*mf_fp[lev][0], period);
- WarpXCommUtil::OverrideSync(*mf_fp[lev][1], period);
- WarpXCommUtil::OverrideSync(*mf_fp[lev][2], period);
+ ablastr::utils::communication::OverrideSync(*mf_fp[lev][0], WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::OverrideSync(*mf_fp[lev][1], WarpX::do_single_precision_comms, period);
+ ablastr::utils::communication::OverrideSync(*mf_fp[lev][2], WarpX::do_single_precision_comms, period);
if (lev > 0)
{
const amrex::Periodicity& cperiod = Geom(lev-1).periodicity();
- WarpXCommUtil::OverrideSync(*mf_cp[lev][0], cperiod);
- WarpXCommUtil::OverrideSync(*mf_cp[lev][1], cperiod);
- WarpXCommUtil::OverrideSync(*mf_cp[lev][2], cperiod);
+ ablastr::utils::communication::OverrideSync(*mf_cp[lev][0], WarpX::do_single_precision_comms, cperiod);
+ ablastr::utils::communication::OverrideSync(*mf_cp[lev][1], WarpX::do_single_precision_comms, cperiod);
+ ablastr::utils::communication::OverrideSync(*mf_cp[lev][2], WarpX::do_single_precision_comms, cperiod);
}
}
}
diff --git a/Source/Parallelization/WarpXCommUtil.H b/Source/Parallelization/WarpXCommUtil.H
deleted file mode 100644
index 09d102a56..000000000
--- a/Source/Parallelization/WarpXCommUtil.H
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Copyright 2019 Andrew Myers
- *
- * This file is part of WarpX.
- *
- * License: BSD-3-Clause-LBNL
- */
-#ifndef WARPX_COMMUTIL_H_
-#define WARPX_COMMUTIL_H_
-
-#include <AMReX_FabArray.H>
-#include <AMReX_Gpu.H>
-#include <AMReX_iMultiFab.H>
-#include <AMReX_MultiFab.H>
-#include <AMReX_Periodicity.H>
-#include <AMReX_TypeTraits.H>
-
-#include "WarpX.H"
-
-namespace WarpXCommUtil
-{
-
-using comm_float_type = float;
-
-template <class FAB1, class FAB2>
-void
-mixedCopy (amrex::FabArray<FAB1>& dst, amrex::FabArray<FAB2> const& src, int srccomp, int dstcomp, int numcomp, const amrex::IntVect& nghost)
-{
- auto const& srcma = src.const_arrays();
- auto const& dstma = dst.arrays();
- ParallelFor(dst, nghost, numcomp,
- [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k, int n) noexcept
- {
- dstma[box_no](i,j,k,dstcomp+n) = (typename FAB1::value_type) srcma[box_no](i,j,k,srccomp+n);
- });
- amrex::Gpu::synchronize();
-}
-
-void ParallelCopy (amrex::MultiFab& dst,
- const amrex::MultiFab& src,
- int src_comp,
- int dst_comp,
- int num_comp,
- const amrex::IntVect& src_nghost,
- const amrex::IntVect& dst_nghost,
- const amrex::Periodicity& period = amrex::Periodicity::NonPeriodic(),
- amrex::FabArrayBase::CpOp op = amrex::FabArrayBase::COPY);
-
-void ParallelAdd (amrex::MultiFab& dst,
- const amrex::MultiFab& src,
- int src_comp,
- int dst_comp,
- int num_comp,
- const amrex::IntVect& src_nghost,
- const amrex::IntVect& dst_nghost,
- const amrex::Periodicity& period = amrex::Periodicity::NonPeriodic());
-
-void FillBoundary (amrex::MultiFab& mf,
- const amrex::Periodicity& period = amrex::Periodicity::NonPeriodic());
-
-void FillBoundary (amrex::MultiFab& mf,
- amrex::IntVect ng,
- const amrex::Periodicity& period = amrex::Periodicity::NonPeriodic(),
- const bool nodal_sync = false);
-
-void FillBoundary (amrex::iMultiFab& mf,
- const amrex::Periodicity& period = amrex::Periodicity::NonPeriodic());
-
-void FillBoundary (amrex::iMultiFab& mf,
- amrex::IntVect ng,
- const amrex::Periodicity& period = amrex::Periodicity::NonPeriodic());
-
-void
-FillBoundary (amrex::Vector<amrex::MultiFab*> const& mf, const amrex::Periodicity& period);
-
-void SumBoundary (amrex::MultiFab& mf,
- const amrex::Periodicity& period = amrex::Periodicity::NonPeriodic());
-
-void SumBoundary (amrex::MultiFab& mf,
- int start_comp,
- int num_comps,
- amrex::IntVect ng,
- const amrex::Periodicity& period = amrex::Periodicity::NonPeriodic());
-
-void SumBoundary (amrex::MultiFab& mf,
- int start_comp,
- int num_comps,
- amrex::IntVect src_ng,
- amrex::IntVect dst_ng,
- const amrex::Periodicity& period = amrex::Periodicity::NonPeriodic());
-
-void OverrideSync (amrex::MultiFab& mf,
- const amrex::Periodicity& period = amrex::Periodicity::NonPeriodic());
-}
-
-#endif
diff --git a/Source/Parallelization/WarpXCommUtil.cpp b/Source/Parallelization/WarpXCommUtil.cpp
deleted file mode 100644
index 104aa5aae..000000000
--- a/Source/Parallelization/WarpXCommUtil.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/* Copyright 2021 Andrew Myers
- *
- * This file is part of WarpX.
- *
- * License: BSD-3-Clause-LBNL
- */
-#include "WarpXCommUtil.H"
-
-#include <AMReX.H>
-#include <AMReX_BaseFab.H>
-#include <AMReX_IntVect.H>
-#include <AMReX_FabArray.H>
-#include <AMReX_MultiFab.H>
-#include <AMReX_iMultiFab.H>
-
-namespace WarpXCommUtil {
-
-void ParallelCopy (amrex::MultiFab& dst,
- const amrex::MultiFab& src,
- int src_comp,
- int dst_comp,
- int num_comp,
- const amrex::IntVect& src_nghost,
- const amrex::IntVect& dst_nghost,
- const amrex::Periodicity& period,
- amrex::FabArrayBase::CpOp op)
-{
- BL_PROFILE("WarpXCommUtil::ParallelCopy");
-
- using WarpXCommUtil::comm_float_type;
-
- if (WarpX::do_single_precision_comms)
- {
- amrex::FabArray<amrex::BaseFab<comm_float_type> > src_tmp(src.boxArray(),
- src.DistributionMap(),
- num_comp,
- src_nghost);
- mixedCopy(src_tmp, src, src_comp, 0, num_comp, src_nghost);
-
- amrex::FabArray<amrex::BaseFab<comm_float_type> > dst_tmp(dst.boxArray(),
- dst.DistributionMap(),
- num_comp,
- dst_nghost);
-
- mixedCopy(dst_tmp, dst, dst_comp, 0, num_comp, dst_nghost);
-
- dst_tmp.ParallelCopy(src_tmp, 0, 0, num_comp,
- src_nghost, dst_nghost, period, op);
-
- mixedCopy(dst, dst_tmp, 0, dst_comp, num_comp, dst_nghost);
- }
- else
- {
- dst.ParallelCopy(src, src_comp, dst_comp, num_comp, src_nghost, dst_nghost, period, op);
- }
-}
-
-void ParallelAdd (amrex::MultiFab& dst,
- const amrex::MultiFab& src,
- int src_comp,
- int dst_comp,
- int num_comp,
- const amrex::IntVect& src_nghost,
- const amrex::IntVect& dst_nghost,
- const amrex::Periodicity& period)
-{
- WarpXCommUtil::ParallelCopy(dst, src, src_comp, dst_comp, num_comp, src_nghost, dst_nghost, period,
- amrex::FabArrayBase::ADD);
-}
-
-void FillBoundary (amrex::MultiFab& mf, const amrex::Periodicity& period)
-{
- BL_PROFILE("WarpXCommUtil::FillBoundary");
-
- if (WarpX::do_single_precision_comms)
- {
- amrex::FabArray<amrex::BaseFab<comm_float_type> > mf_tmp(mf.boxArray(),
- mf.DistributionMap(),
- mf.nComp(),
- mf.nGrowVect());
-
- mixedCopy(mf_tmp, mf, 0, 0, mf.nComp(), mf.nGrowVect());
-
- mf_tmp.FillBoundary(period);
-
- mixedCopy(mf, mf_tmp, 0, 0, mf.nComp(), mf.nGrowVect());
- }
- else
- {
- mf.FillBoundary(period);
- }
-}
-
-void FillBoundary (amrex::MultiFab& mf,
- amrex::IntVect ng,
- const amrex::Periodicity& period,
- const bool nodal_sync)
-{
- BL_PROFILE("WarpXCommUtil::FillBoundary");
-
- if (WarpX::do_single_precision_comms)
- {
- amrex::FabArray<amrex::BaseFab<comm_float_type> > mf_tmp(mf.boxArray(),
- mf.DistributionMap(),
- mf.nComp(),
- mf.nGrowVect());
-
- mixedCopy(mf_tmp, mf, 0, 0, mf.nComp(), mf.nGrowVect());
-
- if (nodal_sync) {
- mf_tmp.FillBoundaryAndSync(0, mf.nComp(), ng, period);
- } else {
- mf_tmp.FillBoundary(ng, period);
- }
-
- mixedCopy(mf, mf_tmp, 0, 0, mf.nComp(), mf.nGrowVect());
- }
- else
- {
-
- if (nodal_sync) {
- mf.FillBoundaryAndSync(0, mf.nComp(), ng, period);
- } else {
- mf.FillBoundary(ng, period);
- }
- }
-}
-
-void FillBoundary (amrex::iMultiFab& imf, const amrex::Periodicity& period)
-{
- BL_PROFILE("WarpXCommUtil::FillBoundary");
-
- imf.FillBoundary(period);
-}
-
-void FillBoundary (amrex::iMultiFab& imf,
- amrex::IntVect ng,
- const amrex::Periodicity& period)
-{
- BL_PROFILE("WarpXCommUtil::FillBoundary");
- imf.FillBoundary(ng, period);
-}
-
-void
-FillBoundary (amrex::Vector<amrex::MultiFab*> const& mf, const amrex::Periodicity& period)
-{
- for (auto x : mf) {
- WarpXCommUtil::FillBoundary(*x, period);
- }
-}
-
-void SumBoundary (amrex::MultiFab& mf, const amrex::Periodicity& period)
-{
- BL_PROFILE("WarpXCommUtil::SumBoundary");
-
- if (WarpX::do_single_precision_comms)
- {
- amrex::FabArray<amrex::BaseFab<comm_float_type> > mf_tmp(mf.boxArray(),
- mf.DistributionMap(),
- mf.nComp(),
- mf.nGrowVect());
-
- mixedCopy(mf_tmp, mf, 0, 0, mf.nComp(), mf.nGrowVect());
-
- mf_tmp.SumBoundary(period);
-
- mixedCopy(mf, mf_tmp, 0, 0, mf.nComp(), mf.nGrowVect());
- }
- else
- {
- mf.SumBoundary(period);
- }
-}
-
-void SumBoundary (amrex::MultiFab& mf,
- int start_comp,
- int num_comps,
- amrex::IntVect ng,
- const amrex::Periodicity& period)
-{
- BL_PROFILE("WarpXCommUtil::SumBoundary");
-
- if (WarpX::do_single_precision_comms)
- {
- amrex::FabArray<amrex::BaseFab<comm_float_type> > mf_tmp(mf.boxArray(),
- mf.DistributionMap(),
- num_comps,
- ng);
- mixedCopy(mf_tmp, mf, start_comp, 0, num_comps, ng);
-
- mf_tmp.SumBoundary(0, num_comps, ng, period);
-
- mixedCopy(mf, mf_tmp, 0, start_comp, num_comps, ng);
- }
- else
- {
- mf.SumBoundary(start_comp, num_comps, ng, period);
- }
-}
-
-void SumBoundary (amrex::MultiFab& mf,
- int start_comp,
- int num_comps,
- amrex::IntVect src_ng,
- amrex::IntVect dst_ng,
- const amrex::Periodicity& period)
-{
- BL_PROFILE("WarpXCommUtil::SumBoundary");
-
- if (WarpX::do_single_precision_comms)
- {
- amrex::FabArray<amrex::BaseFab<comm_float_type> > mf_tmp(mf.boxArray(),
- mf.DistributionMap(),
- num_comps,
- mf.nGrowVect());
- mixedCopy(mf_tmp, mf, start_comp, 0, num_comps, mf.nGrowVect());
-
- mf_tmp.SumBoundary(0, num_comps, src_ng, dst_ng, period);
-
- mixedCopy(mf, mf_tmp, 0, start_comp, num_comps, dst_ng);
- }
- else
- {
- mf.SumBoundary(start_comp, num_comps, src_ng, dst_ng, period);
- }
-}
-
-void OverrideSync (amrex::MultiFab& mf,
- const amrex::Periodicity& period)
-{
- if (mf.ixType().cellCentered()) return;
-
- if (WarpX::do_single_precision_comms)
- {
- amrex::FabArray<amrex::BaseFab<comm_float_type> > mf_tmp(mf.boxArray(),
- mf.DistributionMap(),
- mf.nComp(),
- mf.nGrowVect());
-
- mixedCopy(mf_tmp, mf, 0, 0, mf.nComp(), mf.nGrowVect());
-
- auto msk = mf.OwnerMask(period);
- amrex::OverrideSync(mf_tmp, *msk, period);
-
- mixedCopy(mf, mf_tmp, 0, 0, mf.nComp(), mf.nGrowVect());
- }
- else
- {
- mf.OverrideSync(period);
- }
-}
-
-}
diff --git a/Source/Parallelization/WarpXSumGuardCells.H b/Source/Parallelization/WarpXSumGuardCells.H
index c94e8a0fb..1bfbf5162 100644
--- a/Source/Parallelization/WarpXSumGuardCells.H
+++ b/Source/Parallelization/WarpXSumGuardCells.H
@@ -10,6 +10,8 @@
#include "Utils/WarpXAlgorithmSelection.H"
+#include <ablastr/utils/Communication.H>
+
#include <AMReX_MultiFab.H>
/** \brief Sum the values of `mf`, where the different boxes overlap
@@ -36,7 +38,7 @@ WarpXSumGuardCells(amrex::MultiFab& mf, const amrex::Periodicity& period,
n_updated_guards = mf.nGrowVect();
else // Update only the valid cells
n_updated_guards = amrex::IntVect::TheZeroVector();
- WarpXCommUtil::SumBoundary(mf, icomp, ncomp, src_ngrow, n_updated_guards, period);
+ ablastr::utils::communication::SumBoundary(mf, icomp, ncomp, src_ngrow, n_updated_guards, WarpX::do_single_precision_comms, period);
}
/** \brief Sum the values of `src` where the different boxes overlap
@@ -69,7 +71,7 @@ WarpXSumGuardCells(amrex::MultiFab& dst, amrex::MultiFab& src,
n_updated_guards = amrex::IntVect::TheZeroVector();
dst.setVal(0., icomp, ncomp, n_updated_guards);
-// WarpXCommUtil::ParallelAdd(dst, src, 0, icomp, ncomp, src_ngrow, n_updated_guards, period);
+// ablastr::utils::communication::ParallelAdd(dst, src, 0, icomp, ncomp, src_ngrow, n_updated_guards, period);
dst.ParallelAdd(src, 0, icomp, ncomp, src_ngrow, n_updated_guards, period);
}