Skip to content

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Jan 11, 2023

Implement a new diagnostics element that writes out openPMD data.

Close #98

Checklist

  • build logic
  • openPMD element:
    • C++
    • Python
    • docs
  • configure options:
    • file format / backend
    • iteration encoding
  • GPU pinned memory support instead of managed/GPU pointers
  • CI: w/ HDF5 CI: Clean Up & HDF5 #324 and/or ADIOS2
  • remove ASCII draft diagnostics that wrote the full beam
  • update examples to use openPMD, esp. in analysis & plot scripts
  • update Python examples requirements.txt and other script & deploy logic to request openPMD-api
  • update cluster docs to load HDF5 and/or ADIOS2 modules
  • match to MAD-X monitor: https://mad.web.cern.ch/mad/webguide/manual.html#Ch11.S19
    • technically, this is meta-data w/o particles

Performance Measurement

Measured on my laptop, 12th Gen Intel(R) Core(TM) i9-12900H processor & PM9A1 Samsung 2TB SSD drive.
Software: GCC 11.3.0, MPICH 4.0.3, ADIOS2 2.8.3.

Running all ImpactX tests.

# for PR only: patch example I/O backend to ADIOS2 BP (our first CI version uses HDF5)
git grep h5 examples/ | awk -F: '{print $1}' | xargs -I{} sed -i 's/h5/bp/g' {}
sed -i 's/h5/bp/g' src/python/impactx/madx_to_impactx.py

# build
cmake -S . -B build -DImpactX_PYTHON=ON
cmake --build build -j 12

# run
ctest --output-on-failure --test-dir build/ -E AMReX -j 6

Ran 90 test targets each (incl. analysis & plotting):

  • prior to this PR: 59.14 sec
  • now, with ADIOS2 openPMD: 26.03 sec
  • now, with HDF5 openPMD: 27.33 sec

Follow-Up

@ax3l ax3l added the component: diagnostics all types of outputs label Jan 11, 2023
@ax3l ax3l added this to the Advanced Methods milestone Jan 11, 2023
@ax3l ax3l force-pushed the topic-openpmd-output branch from 3186609 to 53c8f65 Compare January 11, 2023 20:17
@ax3l ax3l force-pushed the topic-openpmd-output branch 3 times, most recently from d017253 to 9820ba7 Compare January 13, 2023 04:03
Comment on lines 196 to 373
std::shared_ptr<amrex::ParticleReal> curr(
new amrex::ParticleReal[numParticleOnTile],
[](amrex::ParticleReal const *p) { delete[] p; }
);
for (auto i = 0; i < numParticleOnTile; i++) {
curr.get()[i] = aos[i].pos(currDim);
}
std::string const positionComponent = positionComponents[currDim];
beam["position"][positionComponent].storeChunk(curr, {offset},
Copy link
Member Author

Choose a reason for hiding this comment

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

@ax3l ax3l force-pushed the topic-openpmd-output branch from d1aba37 to f2140a7 Compare February 25, 2023 21:08
Comment on lines 308 to 415
/*
// comment this in once IntSoA::nattribs is > 0
std::vector<std::string> int_soa_names(IntSoA::names_s.size);
std::copy(IntSoA::names_s.begin(), IntSoA::names_s.end(), int_soa_names.begin());
for (auto int_idx=0; int_idx < RealSoA::nattribs; int_idx++) {
auto const component_name = int_soa_names.at(int_idx);
getComponentRecord(component_name).storeChunk(
io::shareRaw(soa.GetIntData(int_idx)), {offset}, {numParticleOnTile64});
}
*/

Check notice

Code scanning / CodeQL

Commented-out code

This comment appears to contain commented-out code.
Comment on lines +232 to +298
/*
using SrcData = WarpXParticleContainer::ParticleTileType::ConstParticleTileDataType;
tmp.copyParticles(*pc,
[=] AMREX_GPU_HOST_DEVICE (const SrcData& src, int ip, const amrex::RandomEngine& engine)
{
const SuperParticleType& p = src.getSuperParticle(ip);
return random_filter(p, engine) * uniform_filter(p, engine)
* parser_filter(p, engine) * geometry_filter(p, engine);
}, true);
*/

Check notice

Code scanning / CodeQL

Commented-out code

This comment appears to contain commented-out code.
@ax3l ax3l force-pushed the topic-openpmd-output branch 4 times, most recently from b7a17d8 to 6b59888 Compare March 2, 2023 00:43
@ax3l ax3l force-pushed the topic-openpmd-output branch 6 times, most recently from 22d7fb3 to 6cc3f40 Compare March 14, 2023 23:00
@ax3l ax3l force-pushed the topic-openpmd-output branch from a8db1d6 to 904fada Compare March 15, 2023 08:34
@ax3l ax3l mentioned this pull request Mar 23, 2023
@ax3l ax3l force-pushed the topic-openpmd-output branch from d3a0eea to 12b5640 Compare March 23, 2023 05:28
@ax3l ax3l force-pushed the topic-openpmd-output branch from 3042e42 to 6a905e2 Compare March 29, 2023 20:20
pp_element.queryAdd("backend", openpmd_backend);
std::string openpmd_encoding {"g"};
pp_element.queryAdd("encoding", openpmd_encoding);
m_lattice.emplace_back( diagnostics::BeamMonitor(element_name, openpmd_backend, openpmd_encoding) );
Copy link
Member

Choose a reason for hiding this comment

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

I have two questions about this element. First, is it useful to include an ascii option for backward-compatibility? (Some users are simply more comfortable with plain ascii text.) Second, should we include the option of specifying a filename for output?

Copy link
Member Author

@ax3l ax3l Mar 30, 2023

Choose a reason for hiding this comment

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

I think no and yes :-) No to the first part for heavy particle data, because it's not scalable and what counts for users is mainly an API to read the data in their scripting language of choice. Also lacks a ton of meta-data that we want to preserve.

We can document an easily usable export to ascii table nonetheless - but in post.
It's a one liner via .to_csv() in Python:
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_csv.html

Let's discuss tomorrow :)

Copy link
Member

@cemitch99 cemitch99 left a comment

Choose a reason for hiding this comment

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

Looks good to me. I made some comments to follow-up on later.

@ax3l ax3l force-pushed the topic-openpmd-output branch 3 times, most recently from d87fb39 to f86e5bb Compare March 30, 2023 04:19
@ax3l ax3l force-pushed the topic-openpmd-output branch from f86e5bb to ddb2727 Compare March 30, 2023 05:28
- New Binary Names
- HDF5 dependency
@ax3l ax3l force-pushed the topic-openpmd-output branch from ddb2727 to 1246aae Compare March 30, 2023 05:55
@ax3l ax3l merged commit 8e55e93 into BLAST-ImpactX:development Mar 30, 2023
@ax3l ax3l deleted the topic-openpmd-output branch March 30, 2023 07:01
@ax3l ax3l added the changes input scripts / defaults Changes the syntax or meaning of input scripts and/or defaults label Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes input scripts / defaults Changes the syntax or meaning of input scripts and/or defaults component: diagnostics all types of outputs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add openPMD Beam Output

2 participants