Skip to content

Commit 7bbd0f2

Browse files
committed
Support Many (Many) Particles
Support more than 2 billion particles per rank (process or device). This gives us a small performance hit (~5%, to double-check), but makes sure one never has to worry. This is useful for nodes or GPUs with very large memory (e.g. >80 GB) when doing very large (>2B particle) runs on them.
1 parent 71c229c commit 7bbd0f2

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/elements/mixin/beamoptic.H

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ namespace detail
8686
*/
8787
AMREX_GPU_DEVICE AMREX_FORCE_INLINE
8888
void
89-
operator() (int i) const
89+
operator() (amrex::Long i) const
9090
{
9191
// access SoA Real data
9292
// note: an optimizing compiler will eliminate loads of unused parameters
@@ -110,11 +110,11 @@ namespace detail
110110
template<int SIMD_WIDTH>
111111
AMREX_GPU_DEVICE AMREX_FORCE_INLINE
112112
void
113-
operator() (amrex::SIMDindex<SIMD_WIDTH, int> idx) const
113+
operator() (amrex::SIMDindex<SIMD_WIDTH, amrex::Long> idx) const
114114
{
115115
using namespace amrex::simd;
116116

117-
int const i = idx.index;
117+
amrex::Long const i = idx.index;
118118

119119
// uninitialized memory
120120
SIMDParticleReal<SIMD_WIDTH> part_x;
@@ -181,7 +181,7 @@ namespace detail
181181
RefPart & AMREX_RESTRICT ref_part,
182182
T_Element & element
183183
) {
184-
const int np = pti.numParticles();
184+
amrex::Long const np = pti.numParticles();
185185

186186
// preparing access to particle data: SoA of Reals
187187
auto& soa_real = pti.GetStructOfArrays().GetRealData();

src/particles/spacecharge/GatherAndPush.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace impactx::particles::spacecharge
7676
amrex::ParticleReal const push_consts = dt * charge * inv_gamma2 / pz_ref_SI;
7777

7878
// gather to each particle and push momentum
79-
amrex::ParallelFor(np, [=] AMREX_GPU_DEVICE (int i) {
79+
amrex::ParallelFor(np, [=] AMREX_GPU_DEVICE (amrex::Long i) {
8080
// access SoA Real data
8181
amrex::ParticleReal & AMREX_RESTRICT x = part_x[i];
8282
amrex::ParticleReal & AMREX_RESTRICT y = part_y[i];

src/particles/wakefields/ChargeBinning.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace impactx::particles::wakefields
5151
amrex::ParticleReal* const AMREX_RESTRICT pos_z = soa.GetRealData(impactx::RealSoA::z).dataPtr();
5252

5353
// Parallel loop over particles
54-
amrex::ParallelFor(np, [=] AMREX_GPU_DEVICE(int i)
54+
amrex::ParallelFor(np, [=] AMREX_GPU_DEVICE(amrex::Long i)
5555
{
5656
// Access particle z-position directly
5757
amrex::ParticleReal const z = pos_z[i]; // (Macro)Particle longitudinal position at i
@@ -155,7 +155,7 @@ namespace impactx::particles::wakefields
155155
amrex::Real* const AMREX_RESTRICT pos_z = soa.GetRealData(impactx::RealSoA::z).dataPtr();
156156
amrex::Real* const AMREX_RESTRICT d_w = soa.GetRealData(impactx::RealSoA::w).dataPtr();
157157

158-
amrex::ParallelFor(np, [=] AMREX_GPU_DEVICE(int i)
158+
amrex::ParallelFor(np, [=] AMREX_GPU_DEVICE(amrex::Long i)
159159
{
160160
amrex::Real const w = d_w[i];
161161
amrex::Real const x = pos_x[i];

src/particles/wakefields/WakePush.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace impactx::particles::wakefields
6363

6464
// Gather particles and push momentum
6565
const amrex::Real* wakefield_ptr = convolved_wakefield.data();
66-
amrex::ParallelFor(np, [=] AMREX_GPU_DEVICE (int i)
66+
amrex::ParallelFor(np, [=] AMREX_GPU_DEVICE (amrex::Long i)
6767
{
6868
// Access SoA Real data
6969
amrex::ParticleReal const & AMREX_RESTRICT t = part_t[i];

0 commit comments

Comments
 (0)