aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/PhysicalParticleContainer.cpp
diff options
context:
space:
mode:
authorGravatar Michael E Rowan <38045958+mrowan137@users.noreply.github.com> 2020-03-27 09:43:04 -0700
committerGravatar GitHub <noreply@github.com> 2020-03-27 09:43:04 -0700
commit035efd914eb3f3c92a126a47030061a1f0a191c6 (patch)
tree3d9286dda9f27fde67f4cdee3d788aefd00e02f1 /Source/Particles/PhysicalParticleContainer.cpp
parent030ef79b6a302e32036bc2f0e355fbdc440cd898 (diff)
downloadWarpX-035efd914eb3f3c92a126a47030061a1f0a191c6.tar.gz
WarpX-035efd914eb3f3c92a126a47030061a1f0a191c6.tar.zst
WarpX-035efd914eb3f3c92a126a47030061a1f0a191c6.zip
Costs vector of (pointer to) vector (#829)
* [WIP] costs mf --> costs vector * [WIP] costs vector * [WIP] vector costs * formatting * makefile * [WIP] costs vector * [WIP] *= costs * wts do not need to divide by num cells * Tiling safety on CPU * Add tests * EOL * Remove unneeded input * Update Source/WarpX.H costs documentation Co-Authored-By: MaxThevenet <mthevenet@lbl.gov> * Update timers with times only if user Timers update * warpx.-->WarpX:: * warpx.-->WarpX:: * warpx.-->WarpX:: * warpx.-->WarpX:: * warpx.-->WarpX:: * add dev synch * Update Regression/WarpX-tests.ini Co-Authored-By: MaxThevenet <mthevenet@lbl.gov> * Delete inputs_loadbalance_costs_heuristic * Update and rename inputs_loadbalancecosts_timers to inputs_loadbalancecosts * Update WarpX-tests.ini Co-authored-by: MaxThevenet <mthevenet@lbl.gov>
Diffstat (limited to 'Source/Particles/PhysicalParticleContainer.cpp')
-rw-r--r--Source/Particles/PhysicalParticleContainer.cpp63
1 files changed, 32 insertions, 31 deletions
diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp
index 188ff4cb4..fe6fe80f2 100644
--- a/Source/Particles/PhysicalParticleContainer.cpp
+++ b/Source/Particles/PhysicalParticleContainer.cpp
@@ -1,8 +1,8 @@
/* Copyright 2019-2020 Andrew Myers, Aurore Blelly, Axel Huebl
* David Grote, Glenn Richardson, Jean-Luc Vay
* Ligia Diana Amorim, Luca Fedeli, Maxence Thevenet
- * Remi Lehe, Revathi Jambunathan, Weiqun Zhang
- * Yinjian Zhao
+ * Michael Rowan, Remi Lehe, Revathi Jambunathan
+ * Weiqun Zhang, Yinjian Zhao
*
* This file is part of WarpX.
*
@@ -406,7 +406,7 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
defineAllParticleTiles();
- MultiFab* cost = WarpX::getCosts(lev);
+ amrex::Vector<amrex::Real>* cost = WarpX::getCosts(lev);
const int nlevs = numLevels();
static bool refine_injection = false;
@@ -449,6 +449,10 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
#endif
for (MFIter mfi = MakeMFIter(lev, info); mfi.isValid(); ++mfi)
{
+ if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers)
+ {
+ amrex::Gpu::synchronize();
+ }
Real wt = amrex::second();
const Box& tile_box = mfi.tilebox();
@@ -789,14 +793,11 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
#endif
});
- if (cost) {
- wt = (amrex::second() - wt) / tile_box.d_numPts();
- Array4<Real> const& costarr = cost->array(mfi);
- amrex::ParallelFor(tile_box,
- [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
- {
- costarr(i,j,k) += wt;
- });
+ if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers)
+ {
+ amrex::Gpu::synchronize();
+ wt = amrex::second() - wt;
+ amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt);
}
}
@@ -878,7 +879,7 @@ PhysicalParticleContainer::FieldGather (int lev,
BL_ASSERT(OnSameGrids(lev,Ex));
- MultiFab* cost = WarpX::getCosts(lev);
+ amrex::Vector<amrex::Real>* cost = WarpX::getCosts(lev);
#ifdef _OPENMP
#pragma omp parallel
@@ -886,6 +887,10 @@ PhysicalParticleContainer::FieldGather (int lev,
{
for (WarpXParIter pti(*this, lev); pti.isValid(); ++pti)
{
+ if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers)
+ {
+ amrex::Gpu::synchronize();
+ }
Real wt = amrex::second();
const Box& box = pti.validbox();
@@ -918,15 +923,11 @@ PhysicalParticleContainer::FieldGather (int lev,
Ex.nGrow(), e_is_nodal,
0, np, lev, lev);
- if (cost) {
- const Box& tbx = pti.tilebox();
- wt = (amrex::second() - wt) / tbx.d_numPts();
- Array4<Real> const& costarr = cost->array(pti);
- amrex::ParallelFor(tbx,
- [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
- {
- costarr(i,j,k) += wt;
- });
+ if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers)
+ {
+ amrex::Gpu::synchronize();
+ wt = amrex::second() - wt;
+ amrex::HostDevice::Atomic::Add( &(*cost)[pti.index()], wt);
}
}
}
@@ -958,7 +959,7 @@ PhysicalParticleContainer::Evolve (int lev,
BL_ASSERT(OnSameGrids(lev,jx));
- MultiFab* cost = WarpX::getCosts(lev);
+ amrex::Vector<amrex::Real>* cost = WarpX::getCosts(lev);
const iMultiFab* current_masks = WarpX::CurrentBufferMasks(lev);
const iMultiFab* gather_masks = WarpX::GatherBufferMasks(lev);
@@ -993,6 +994,10 @@ PhysicalParticleContainer::Evolve (int lev,
for (WarpXParIter pti(*this, lev); pti.isValid(); ++pti)
{
+ if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers)
+ {
+ amrex::Gpu::synchronize();
+ }
Real wt = amrex::second();
const Box& box = pti.validbox();
@@ -1182,15 +1187,11 @@ PhysicalParticleContainer::Evolve (int lev,
}
}
- if (cost) {
- const Box& tbx = pti.tilebox();
- wt = (amrex::second() - wt) / tbx.d_numPts();
- Array4<Real> const& costarr = cost->array(pti);
- amrex::ParallelFor(tbx,
- [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
- {
- costarr(i,j,k) += wt;
- });
+ if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers)
+ {
+ amrex::Gpu::synchronize();
+ wt = amrex::second() - wt;
+ amrex::HostDevice::Atomic::Add( &(*cost)[pti.index()], wt);
}
}
}