From 96f6d669d1bb2622346663a2b7cb58624866fcc3 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Tue, 16 Apr 2024 19:11:12 -0700 Subject: [PATCH] Fix offset in recv buffer of single precision particle communication (#3896) A similar bug was fixed in #3758 for the particle send buffer. But we did not notice the issue in the receive buffer at the time. The offset for the `i`th buffer might be aligned for the `i`th buffer's communication data type, not the previous buffer. The reason the bug only appears for large single precision runs is because for double precision the particle size is aligned with the size of unsigned long long used in communication, whereas for single precision this is not the case. --- Src/Particle/AMReX_ParticleCommunication.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Particle/AMReX_ParticleCommunication.H b/Src/Particle/AMReX_ParticleCommunication.H index 5a5dfeb54e1..f78d5fd1fb2 100644 --- a/Src/Particle/AMReX_ParticleCommunication.H +++ b/Src/Particle/AMReX_ParticleCommunication.H @@ -481,10 +481,10 @@ void communicateParticlesStart (const PC& pc, ParticleCopyPlan& plan, const SndB for (int i = 0; i < NProcs; ++i) { if (plan.m_rcv_num_particles[i] > 0) { RcvProc.push_back(i); - rOffset.push_back(TotRcvBytes); Long nbytes = plan.m_rcv_num_particles[i]*psize; std::size_t acd = ParallelDescriptor::sizeof_selected_comm_data_type(nbytes); TotRcvBytes = Long(amrex::aligned_size(acd, TotRcvBytes)); + rOffset.push_back(TotRcvBytes); TotRcvBytes += Long(amrex::aligned_size(acd, nbytes)); plan.m_rcv_pad_correction_h.push_back(plan.m_rcv_pad_correction_h.back() + nbytes); }