Skip to content

Commit

Permalink
Pure SoA: NextID as Long
Browse files Browse the repository at this point in the history
This is a leftover from an earlier implementation of pure SoA.
Our 39bit particle ids must be stored in an `amrex::Long`. An `int`
will crop them to 32bit range, which we quickly run out from.
  • Loading branch information
ax3l committed Feb 20, 2024
1 parent 296ed40 commit 8aa5389
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Src/Particle/AMReX_ParticleTile.H
Original file line number Diff line number Diff line change
Expand Up @@ -423,19 +423,19 @@ struct SoAParticle : SoAParticleBase
return this->m_particle_tile_data.m_rdata[position_index][m_index];
}

static int NextID ();
static Long NextID ();

/**
* \brief This version can only be used inside omp critical.
*/
static int UnprotectedNextID ();
static Long UnprotectedNextID ();

/**
* \brief Reset on restart.
*
* \param nextid
*/
static void NextID (int nextid);
static void NextID (Long nextid);

private :

Expand All @@ -449,7 +449,7 @@ private :
template <int NArrayReal, int NArrayInt> int SoAParticle<NArrayReal, NArrayInt>::the_next_id = 1;

template <int NArrayReal, int NArrayInt>
int
Long
SoAParticle<NArrayReal, NArrayInt>::NextID ()
{
Long next;
Expand All @@ -466,14 +466,14 @@ SoAParticle<NArrayReal, NArrayInt>::NextID ()
amrex::Abort("SoAParticle<NArrayReal, NArrayInt>::NextID() -- too many particles");
}

return int(next);
return next;
}

template <int NArrayReal, int NArrayInt>
int
Long
SoAParticle<NArrayReal, NArrayInt>::UnprotectedNextID ()
{
int next = the_next_id++;
Long next = the_next_id++;
if (next > LongParticleIds::LastParticleID) {
amrex::Abort("SoAParticle<NArrayReal, NArrayInt>::NextID() -- too many particles");
}
Expand All @@ -482,7 +482,7 @@ SoAParticle<NArrayReal, NArrayInt>::UnprotectedNextID ()

template <int NArrayReal, int NArrayInt>
void
SoAParticle<NArrayReal, NArrayInt>::NextID (int nextid)
SoAParticle<NArrayReal, NArrayInt>::NextID (Long nextid)
{
the_next_id = nextid;
}
Expand Down

0 comments on commit 8aa5389

Please sign in to comment.