Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion Docs/sphinx_documentation/source/RuntimeParameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ Memory

.. py:data:: amrex.vector_growth_factor
:type: amrex::Real
:value: 1.5
:value: 1.25

This controls the growth factor of :cpp:`amrex::PODVector` and its
derived classes such as :cpp:`amrex::Gpu::DeviceVector`,
Expand Down
15 changes: 15 additions & 0 deletions Src/Base/AMReX_PODVector.H
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,21 @@ namespace amrex
}
}


void resize_geometric_grow (size_type a_new_size)
{
auto old_size = m_size;
if (m_capacity < a_new_size) {
size_type new_capacity = std::max(a_new_size, GetNewCapacityForPush());
reserve(new_capacity);
}
m_size = a_new_size;
if (old_size < a_new_size) {
detail::maybe_init_snan(m_data + old_size,
m_size - old_size, (Allocator const&)(*this));
}
}

void reserve (size_type a_capacity)
{
if (m_capacity < a_capacity) {
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_PODVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace amrex::VectorGrowthStrategy
{
Real growth_factor = 1.5_rt;
Real growth_factor = 1.25_rt;

// clamp user input to reasonable values
constexpr Real min_factor = 1.001_rt;
Expand Down
2 changes: 1 addition & 1 deletion Src/Particle/AMReX_ParticleCommunication.H
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct RedistributeUnpackPolicy
}

for (auto& kv : tile_sizes) {
kv.first->resize(kv.second);
kv.first->resize_geometric_grow(kv.second);
}
}
};
Expand Down
20 changes: 20 additions & 0 deletions Src/Particle/AMReX_ParticleTile.H
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,26 @@ struct ParticleTile
m_soa_tile.resize(count);
}

void resize_geometric_grow (std::size_t count)
{
if constexpr (ParticleType::is_soa_particle) {
GetStructOfArrays().GetIdCPUData().resize_geometric_grow(count);
} else {
m_aos_tile().resize_geometric_grow(count);
}
for (int j = 0; j < NumRealComps(); ++j)
{
auto& rdata = GetStructOfArrays().GetRealData(j);
rdata.resize_geometric_grow(count);
}

for (int j = 0; j < NumIntComps(); ++j)
{
auto& idata = GetStructOfArrays().GetIntData(j);
idata.resize_geometric_grow(count);
}
}

///
/// Add one particle to this tile.
///
Expand Down
Loading