From 99b47cb58a3c734ff9292226b952d7a79b351b72 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Fri, 16 Feb 2024 12:32:11 -0800 Subject: [PATCH] getParticleTileData: HostVector must be initialized during resize (#3769) For efficiency reasons, PODVectors are not initialized in the single argument version of the resize function. This fixes a bug in #3760. --- Src/Particle/AMReX_ParticleTile.H | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Src/Particle/AMReX_ParticleTile.H b/Src/Particle/AMReX_ParticleTile.H index 142133c2756..4251de0bea7 100644 --- a/Src/Particle/AMReX_ParticleTile.H +++ b/Src/Particle/AMReX_ParticleTile.H @@ -1113,7 +1113,7 @@ struct ParticleTile m_runtime_i_ptrs.resize(m_soa_tile.NumIntComps() - NArrayInt); #ifdef AMREX_USE_GPU bool copy_real = false; - m_h_runtime_r_ptrs.resize(m_soa_tile.NumRealComps() - NArrayReal); + m_h_runtime_r_ptrs.resize(m_soa_tile.NumRealComps() - NArrayReal, nullptr); for (std::size_t i = 0; i < m_h_runtime_r_ptrs.size(); ++i) { if (m_h_runtime_r_ptrs[i] != m_soa_tile.GetRealData(i + NArrayReal).dataPtr()) { m_h_runtime_r_ptrs[i] = m_soa_tile.GetRealData(i + NArrayReal).dataPtr(); @@ -1126,7 +1126,7 @@ struct ParticleTile } bool copy_int = false; - m_h_runtime_i_ptrs.resize(m_soa_tile.NumIntComps() - NArrayInt); + m_h_runtime_i_ptrs.resize(m_soa_tile.NumIntComps() - NArrayInt, nullptr); for (std::size_t i = 0; i < m_h_runtime_i_ptrs.size(); ++i) { if (m_h_runtime_i_ptrs[i] != m_soa_tile.GetIntData(i + NArrayInt).dataPtr()) { m_h_runtime_i_ptrs[i] = m_soa_tile.GetIntData(i + NArrayInt).dataPtr(); @@ -1189,7 +1189,7 @@ struct ParticleTile m_runtime_i_cptrs.resize(m_soa_tile.NumIntComps() - NArrayInt); #ifdef AMREX_USE_GPU bool copy_real = false; - m_h_runtime_r_cptrs.resize(m_soa_tile.NumRealComps() - NArrayReal); + m_h_runtime_r_cptrs.resize(m_soa_tile.NumRealComps() - NArrayReal, nullptr); for (std::size_t i = 0; i < m_h_runtime_r_cptrs.size(); ++i) { if (m_h_runtime_r_cptrs[i] != m_soa_tile.GetRealData(i + NArrayReal).dataPtr()) { m_h_runtime_r_cptrs[i] = m_soa_tile.GetRealData(i + NArrayReal).dataPtr(); @@ -1202,7 +1202,7 @@ struct ParticleTile } bool copy_int = false; - m_h_runtime_i_cptrs.resize(m_soa_tile.NumIntComps() - NArrayInt); + m_h_runtime_i_cptrs.resize(m_soa_tile.NumIntComps() - NArrayInt, nullptr); for (std::size_t i = 0; i < m_h_runtime_i_cptrs.size(); ++i) { if (m_h_runtime_i_cptrs[i] != m_soa_tile.GetIntData(i + NArrayInt).dataPtr()) { m_h_runtime_i_cptrs[i] = m_soa_tile.GetIntData(i + NArrayInt).dataPtr();