Skip to content

Commit

Permalink
getParticleTileData: HostVector must be initialized during resize (AM…
Browse files Browse the repository at this point in the history
…ReX-Codes#3769)

For efficiency reasons, PODVectors are not initialized in the single
argument version of the resize function. This fixes a bug in AMReX-Codes#3760.
  • Loading branch information
WeiqunZhang authored Feb 16, 2024
1 parent 6117841 commit 99b47cb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Src/Particle/AMReX_ParticleTile.H
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 99b47cb

Please sign in to comment.