Skip to content

Commit

Permalink
Fix new bug in pure soa communication (#4337)
Browse files Browse the repository at this point in the history
This fixes an issue introduced in PR #4333.

The proposed changes:
- [x] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
  • Loading branch information
atmyers authored Feb 18, 2025
1 parent f8d7483 commit b364bec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
6 changes: 5 additions & 1 deletion Src/Particle/AMReX_ParticleCommunication.H
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@ struct ParticleCopyPlan
int NStructInt = PC::ParticleContainerType::NStructInt;

int num_real_comm_comp = 0;
for (int i = AMREX_SPACEDIM + NStructReal; i < real_comp_mask.size(); ++i) {
int comm_comps_start = 0;
if constexpr (!PC::ParticleType::is_soa_particle) {
comm_comps_start += AMREX_SPACEDIM + NStructReal;
}
for (int i = comm_comps_start; i < real_comp_mask.size(); ++i) {
if (real_comp_mask[i]) {++num_real_comm_comp;}
}

Expand Down
21 changes: 15 additions & 6 deletions Src/Particle/AMReX_ParticleTile.H
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ struct ParticleTileData
memcpy(dst, m_idcpu + src_index, sizeof(uint64_t));
dst += sizeof(uint64_t);
}
int array_start_index = AMREX_SPACEDIM + NStructReal;
int array_start_index = 0;
if constexpr (!ParticleType::is_soa_particle) {
array_start_index = AMREX_SPACEDIM + NStructReal;
}
for (int i = 0; i < NAR; ++i)
{
if (comm_real[array_start_index + i])
Expand All @@ -143,7 +146,7 @@ struct ParticleTileData
dst += sizeof(ParticleReal);
}
}
int runtime_start_index = AMREX_SPACEDIM + NStructReal + NAR;
int runtime_start_index = array_start_index + NAR;
for (int i = 0; i < m_num_runtime_real; ++i)
{
if (comm_real[runtime_start_index + i])
Expand Down Expand Up @@ -185,7 +188,10 @@ struct ParticleTileData
memcpy(m_idcpu + dst_index, src, sizeof(uint64_t));
src += sizeof(uint64_t);
}
int array_start_index = AMREX_SPACEDIM + NStructReal;
int array_start_index = 0;
if constexpr (!ParticleType::is_soa_particle) {
array_start_index = AMREX_SPACEDIM + NStructReal;
}
for (int i = 0; i < NAR; ++i)
{
if (comm_real[array_start_index + i])
Expand All @@ -194,7 +200,7 @@ struct ParticleTileData
src += sizeof(ParticleReal);
}
}
int runtime_start_index = AMREX_SPACEDIM + NStructReal + NAR;
int runtime_start_index = array_start_index + NAR;
for (int i = 0; i < m_num_runtime_real; ++i)
{
if (comm_real[runtime_start_index + i])
Expand Down Expand Up @@ -595,7 +601,10 @@ struct ConstParticleTileData
memcpy(dst, m_idcpu + src_index, sizeof(uint64_t));
dst += sizeof(uint64_t);
}
int array_start_index = AMREX_SPACEDIM + NStructReal;
int array_start_index = 0;
if constexpr (!ParticleType::is_soa_particle) {
array_start_index = AMREX_SPACEDIM + NStructReal;
}
for (int i = 0; i < NArrayReal; ++i)
{
if (comm_real[array_start_index + i])
Expand All @@ -604,7 +613,7 @@ struct ConstParticleTileData
dst += sizeof(ParticleReal);
}
}
int runtime_start_index = AMREX_SPACEDIM + NStructReal + NArrayReal;
int runtime_start_index = array_start_index + NArrayReal;
for (int i = 0; i < m_num_runtime_real; ++i)
{
if (comm_real[runtime_start_index + i])
Expand Down

0 comments on commit b364bec

Please sign in to comment.