diff --git a/Source/Diagnostics/ReducedDiags/FieldMomentum.cpp b/Source/Diagnostics/ReducedDiags/FieldMomentum.cpp index b9a90b67ec5..bde692a8eb4 100644 --- a/Source/Diagnostics/ReducedDiags/FieldMomentum.cpp +++ b/Source/Diagnostics/ReducedDiags/FieldMomentum.cpp @@ -182,9 +182,7 @@ void FieldMomentum::ComputeDiags (int step) amrex::Real ExB_x = amrex::get<0>(r); amrex::Real ExB_y = amrex::get<1>(r); amrex::Real ExB_z = amrex::get<2>(r); - amrex::ParallelDescriptor::ReduceRealSum(ExB_x); - amrex::ParallelDescriptor::ReduceRealSum(ExB_y); - amrex::ParallelDescriptor::ReduceRealSum(ExB_z); + amrex::ParallelDescriptor::ReduceRealSum({ExB_x,ExB_y,ExB_z}); // Get cell size amrex::Geometry const & geom = warpx.Geom(lev); diff --git a/Source/Diagnostics/ReducedDiags/ParticleEnergy.cpp b/Source/Diagnostics/ReducedDiags/ParticleEnergy.cpp index f6b23d3ec27..47b90e09978 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleEnergy.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleEnergy.cpp @@ -159,8 +159,7 @@ void ParticleEnergy::ComputeDiags (int step) } // Reduced sum over MPI ranks - ParallelDescriptor::ReduceRealSum(Etot, ParallelDescriptor::IOProcessorNumber()); - ParallelDescriptor::ReduceRealSum(Ws , ParallelDescriptor::IOProcessorNumber()); + ParallelDescriptor::ReduceRealSum({Etot,Ws}, ParallelDescriptor::IOProcessorNumber()); // Accumulate sum of weights over all species (must come after MPI reduction of Ws) Wtot += Ws; diff --git a/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp b/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp index faba5238f4a..e125f44e08f 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp @@ -197,114 +197,92 @@ void ParticleExtrema::ComputeDiags (int step) Real xmin = ReduceMin( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.pos(0)*std::cos(p.rdata(PIdx::theta)); }); - ParallelDescriptor::ReduceRealMin(xmin); #elif (defined WARPX_DIM_1D_Z) - const Real xmin = 0.0_rt; + Real xmin = 0.0_rt; #else Real xmin = ReduceMin( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.pos(0); }); - ParallelDescriptor::ReduceRealMin(xmin); #endif // xmax #if (defined WARPX_DIM_RZ) - Real t_xmax = ReduceMax( myspc, + Real xmax = ReduceMax( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.pos(0)*std::cos(p.rdata(PIdx::theta)); }); - ParallelDescriptor::ReduceRealMax(t_xmax); - const Real xmax = t_xmax; #elif (defined WARPX_DIM_1D_Z) - const Real xmax = 0.0_rt; + Real xmax = 0.0_rt; #else - Real t_xmax = ReduceMax( myspc, + Real xmax = ReduceMax( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.pos(0); }); - ParallelDescriptor::ReduceRealMax(t_xmax); - const Real xmax = t_xmax; #endif // ymin #if (defined WARPX_DIM_RZ) - Real t_ymin = ReduceMin( myspc, + Real ymin = ReduceMin( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.pos(0)*std::sin(p.rdata(PIdx::theta)); }); - ParallelDescriptor::ReduceRealMin(t_ymin); - const Real ymin = t_ymin; #elif (defined WARPX_DIM_XZ || WARPX_DIM_1D_Z) - const Real ymin = 0.0_rt; + Real ymin = 0.0_rt; #else - Real t_ymin = ReduceMin( myspc, + Real ymin = ReduceMin( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.pos(1); }); - ParallelDescriptor::ReduceRealMin(t_ymin); - const Real ymin = t_ymin; #endif // ymax #if (defined WARPX_DIM_RZ) - Real t_ymax = ReduceMax( myspc, + Real ymax = ReduceMax( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.pos(0)*std::sin(p.rdata(PIdx::theta)); }); - ParallelDescriptor::ReduceRealMax(t_ymax); - const Real ymax = t_ymax; #elif (defined WARPX_DIM_XZ || WARPX_DIM_1D_Z) - const Real ymax = 0.0_rt; + Real ymax = 0.0_rt; #else - Real t_ymax = ReduceMax( myspc, + Real ymax = ReduceMax( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.pos(1); }); - ParallelDescriptor::ReduceRealMax(t_ymax); - const Real ymax = t_ymax; #endif // zmin Real zmin = ReduceMin( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.pos(index_z); }); - ParallelDescriptor::ReduceRealMin(zmin); // zmax Real zmax = ReduceMax( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.pos(index_z); }); - ParallelDescriptor::ReduceRealMax(zmax); // uxmin Real uxmin = ReduceMin( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.rdata(PIdx::ux); }); - ParallelDescriptor::ReduceRealMin(uxmin); // uxmax Real uxmax = ReduceMax( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.rdata(PIdx::ux); }); - ParallelDescriptor::ReduceRealMax(uxmax); // uymin Real uymin = ReduceMin( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.rdata(PIdx::uy); }); - ParallelDescriptor::ReduceRealMin(uymin); // uymax Real uymax = ReduceMax( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.rdata(PIdx::uy); }); - ParallelDescriptor::ReduceRealMax(uymax); // uzmin Real uzmin = ReduceMin( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.rdata(PIdx::uz); }); - ParallelDescriptor::ReduceRealMin(uzmin); // uzmax Real uzmax = ReduceMax( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.rdata(PIdx::uz); }); - ParallelDescriptor::ReduceRealMax(uzmax); // gmin Real gmin = 0.0_rt; @@ -329,7 +307,6 @@ void ParticleExtrema::ComputeDiags (int step) return std::sqrt(1.0_rt + us*inv_c2); }); } - ParallelDescriptor::ReduceRealMin(gmin); // gmax Real gmax = 0.0_rt; @@ -354,19 +331,19 @@ void ParticleExtrema::ComputeDiags (int step) return std::sqrt(1.0_rt + us*inv_c2); }); } - ParallelDescriptor::ReduceRealMax(gmax); // wmin Real wmin = ReduceMin( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.rdata(PIdx::w); }); - ParallelDescriptor::ReduceRealMin(wmin); // wmax Real wmax = ReduceMax( myspc, [=] AMREX_GPU_HOST_DEVICE (const PType& p) { return p.rdata(PIdx::w); }); - ParallelDescriptor::ReduceRealMax(wmax); + + ParallelDescriptor::ReduceRealMin({xmin,ymin,zmin,uxmin,uymin,uzmin,gmin,wmin}); + ParallelDescriptor::ReduceRealMax({xmax,ymax,zmax,uxmax,uymax,uzmax,gmax,wmax}); #if (defined WARPX_QED) // get number of level (int) diff --git a/Source/Diagnostics/ReducedDiags/ParticleMomentum.cpp b/Source/Diagnostics/ReducedDiags/ParticleMomentum.cpp index 0adfc1ba90f..b3f0f142e87 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleMomentum.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleMomentum.cpp @@ -167,10 +167,7 @@ void ParticleMomentum::ComputeDiags (int step) amrex::Real Ws = amrex::get<3>(r); // Reduced sum over MPI ranks - ParallelDescriptor::ReduceRealSum(Px, ParallelDescriptor::IOProcessorNumber()); - ParallelDescriptor::ReduceRealSum(Py, ParallelDescriptor::IOProcessorNumber()); - ParallelDescriptor::ReduceRealSum(Pz, ParallelDescriptor::IOProcessorNumber()); - ParallelDescriptor::ReduceRealSum(Ws, ParallelDescriptor::IOProcessorNumber()); + ParallelDescriptor::ReduceRealSum({Px,Py,Pz,Ws}, ParallelDescriptor::IOProcessorNumber()); // Accumulate sum of weights over all species (must come after MPI reduction of Ws) Wtot += Ws; diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index 7775702e4b9..cabe05c6ea3 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -1223,9 +1223,7 @@ std::array WarpXParticleContainer::meanParticleVelocity(bool lo } if (local == false) { - ParallelDescriptor::ReduceRealSum(vx_total); - ParallelDescriptor::ReduceRealSum(vy_total); - ParallelDescriptor::ReduceRealSum(vz_total); + ParallelDescriptor::ReduceRealSum({vx_total,vy_total,vz_total}); ParallelDescriptor::ReduceLongSum(np_total); }