Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParticleTile: More SoA Updates #3305

Merged
merged 1 commit into from
May 15, 2023
Merged
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
50 changes: 25 additions & 25 deletions Src/Particle/AMReX_ParticleTile.H
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,13 @@ struct ParticleTileData
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
auto* rdata (const int attribute_index)
auto * rdata (const int attribute_index) const
{
return this->m_rdata[attribute_index];
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
auto const * rdata (const int attribute_index) const
{
return this->m_rdata[attribute_index];
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
auto* idata (const int attribute_index)
{
return this->m_idata[attribute_index];
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
auto const * idata (const int attribute_index) const
auto * idata (const int attribute_index) const
{
return this->m_idata[attribute_index];
}
Expand Down Expand Up @@ -746,11 +734,7 @@ struct ParticleTile
SoA& GetStructOfArrays () { return m_soa_tile; }
const SoA& GetStructOfArrays () const { return m_soa_tile; }

template <typename T = ParticleType, typename std::enable_if<!T::is_soa_particle, int>::type = 0>
bool empty () const { return m_aos_tile.empty(); }

template <typename T = ParticleType, typename std::enable_if<T::is_soa_particle, int>::type = 0>
bool empty () const { return m_soa_tile.empty(); }
bool empty () const { return size() == 0; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The development version for empty also works, it was fixed after I made the original PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but removing the SFINAE will improve compile time :)


/**
* \brief Returns the total number of particles (real and neighbor)
Expand Down Expand Up @@ -817,7 +801,9 @@ struct ParticleTile

void resize (std::size_t count)
{
m_aos_tile.resize(count);
if constexpr (!ParticleType::is_soa_particle) {
m_aos_tile.resize(count);
}
m_soa_tile.resize(count);
}

Expand Down Expand Up @@ -969,7 +955,9 @@ struct ParticleTile

void shrink_to_fit ()
{
m_aos_tile().shrink_to_fit();
if constexpr (!ParticleType::is_soa_particle) {
m_aos_tile().shrink_to_fit();
}
for (int j = 0; j < NumRealComps(); ++j)
{
auto& rdata = GetStructOfArrays().GetRealData(j);
Expand All @@ -986,7 +974,9 @@ struct ParticleTile
Long capacity () const
{
Long nbytes = 0;
nbytes += m_aos_tile().capacity() * sizeof(ParticleType);
if constexpr (!ParticleType::is_soa_particle) {
nbytes += m_aos_tile().capacity() * sizeof(ParticleType);
}
for (int j = 0; j < NumRealComps(); ++j)
{
auto& rdata = GetStructOfArrays().GetRealData(j);
Expand All @@ -1003,7 +993,9 @@ struct ParticleTile

void swap (ParticleTile<ParticleType, NArrayReal, NArrayInt, Allocator>& other)
{
m_aos_tile().swap(other.GetArrayOfStructs()());
if constexpr (!ParticleType::is_soa_particle) {
m_aos_tile().swap(other.GetArrayOfStructs()());
}
for (int j = 0; j < NumRealComps(); ++j)
{
auto& rdata = GetStructOfArrays().GetRealData(j);
Expand Down Expand Up @@ -1052,7 +1044,11 @@ struct ParticleTile
#endif

ParticleTileDataType ptd;
ptd.m_aos = m_aos_tile().dataPtr();
if constexpr (!ParticleType::is_soa_particle) {
ptd.m_aos = m_aos_tile().dataPtr();
} else {
ptd.m_aos = nullptr;
}
if constexpr(NArrayReal > 0)
for (int i = 0; i < NArrayReal; ++i)
ptd.m_rdata[i] = m_soa_tile.GetRealData(i).dataPtr();
Expand Down Expand Up @@ -1109,7 +1105,11 @@ struct ParticleTile
#endif

ConstParticleTileDataType ptd;
ptd.m_aos = m_aos_tile().dataPtr();
if constexpr (!ParticleType::is_soa_particle) {
ptd.m_aos = m_aos_tile().dataPtr();
} else {
ptd.m_aos = nullptr;
}
if constexpr(NArrayReal > 0)
for (int i = 0; i < NArrayReal; ++i)
ptd.m_rdata[i] = m_soa_tile.GetRealData(i).dataPtr();
Expand Down