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

Named SoA Support #4163

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Sep 23, 2024

Summary

Add support to optionally name SoA Real and Int components, both for compile-time and runtime components.

  • define and defaults
  • single tile Get*Data(std::string)
  • multi-component GetData() with named indices
  • refactor out default name generation for reuse, finalize defaults in AddReal/IntComp
  • test

Additional background

Close #3614

Checklist

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • changes answers in the test suite to more than roundoff level
  • are likely to significantly affect the results of downstream AMReX users
  • include documentation in the code and/or rst files, if appropriate

{
m_defined = true;
m_runtime_rdata.resize(a_num_runtime_real);
m_runtime_idata.resize(a_num_runtime_int );
m_rdata_names = soa_rdata_names;

Check warning

Code scanning / CodeQL

Local variable address stored in non-local memory Warning

A stack address which arrived via a
parameter
may be assigned to a non-local variable.
{
m_defined = true;
m_runtime_rdata.resize(a_num_runtime_real);
m_runtime_idata.resize(a_num_runtime_int );
m_rdata_names = soa_rdata_names;
m_idata_names = soa_idata_names;

Check warning

Code scanning / CodeQL

Local variable address stored in non-local memory Warning

A stack address which arrived via a
parameter
may be assigned to a non-local variable.
Add support to optionally name SoA Real and Int components, both
for compile-time and runtime components.
Comment on lines +68 to +87
int first_r_name = 0;
// push back x,y,z
if constexpr (ParticleType::is_soa_particle) {
constexpr int x_in_ascii = 120;
for (int i=0; i<AMREX_SPACEDIM; ++i)
{
std::string const name{char(x_in_ascii+i)};
m_soa_rdata_names.push_back(name);
}
first_r_name = AMREX_SPACEDIM;
}
for (int i=first_r_name; i<NArrayReal; ++i)
{
m_soa_rdata_names.push_back("real_comp" + std::to_string(i-first_r_name));
}
for (int i=0; i<NArrayInt; ++i)
{
m_soa_idata_names.push_back("int_comp" + std::to_string(i));
}

Copy link
Member Author

Choose a reason for hiding this comment

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

We discussed that we want to make this two functions (one for real, one for int) that take the ParticleType and index to return a default name on the current index.

This way, we can reuse this in the:

  • current I/O logic (existing naming scheme we took over here)
  • here
  • in AddRealComp/AddIntComp without name argument

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Named Particle SoA Components
2 participants