Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper function for setting id and cpu simultaneously. #3733

Merged
merged 7 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Src/Particle/AMReX_Particle.H
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ struct ConstParticleCPUWrapper
operator int () const noexcept { return static_cast<int>(m_idata & 0x00FFFFFF); }
};

/** Set the idcpu value at once, based on a particle id and cpuid
*
* This can be used in initialization and assignments,
* to avoid writing twice into the same memory bank.
*/
std::uint64_t SetParticleIDandCPU (Long id, int cpu) {
ax3l marked this conversation as resolved.
Show resolved Hide resolved
std:uint64_t idcpu = 0;
atmyers marked this conversation as resolved.
Show resolved Hide resolved
ParticleIDWrapper{idcpu} = id;
``
ax3l marked this conversation as resolved.
Show resolved Hide resolved
ParticleCPUWrapper{idcpu} = cpu;
return idcpu;
}

template <typename T, int NReal, int NInt>
struct ParticleBase
Expand Down
1 change: 1 addition & 0 deletions Src/Particle/AMReX_ParticleIO.H
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
{
new_size += src_tile.size();
} else {
amrex::ignore_unused(src_tile);
new_size += host_real_attribs[host_lev][std::make_pair(grid,tile)][0].size();
}
dst_tile.resize(new_size);
Expand Down
Loading