Skip to content

Support writing particles with ADIOS2#400

Merged
JamesMcClung merged 37 commits into
psc-code:mainfrom
JamesMcClung:pr/adios2-particles
May 13, 2026
Merged

Support writing particles with ADIOS2#400
JamesMcClung merged 37 commits into
psc-code:mainfrom
JamesMcClung:pr/adios2-particles

Conversation

@JamesMcClung
Copy link
Copy Markdown
Collaborator

@JamesMcClung JamesMcClung commented Apr 28, 2026

The main thing here is output_particles_adios2_impl.hxx, which provides the OutputParticlesAdios2 particle diagnostic. Some highlights/notes:

  • Writes one bp file per step per species, e.g. prt.i.<step>.bp and prt.e.<step>.bp. Species name, charge, and mass are stored as file-level attributes (in addition to the usual gdims, corner, length, time).
  • Each particle property (e.g. x, py, w, tag) is written to its own 1d variable, and can be independently toggled. By default, q, m, id, and tag are not written. (Assuming the remaining properties are stored as floats, this reduces disk size by 50% compared to the existing h5 implementation, from 56 bytes per particle to 28.)
  • Particles are not sorted by cell index, unlike the h5 writer.
  • Does not use PSC's Adios2 wrappers.

This PR doesn't address the problem of reading the bp data. A prt.bp reader was implemented here in psc-plot: JamesMcClung/psc-plot#33. Also see psc-code/pscpy#41.

Other minor changes:

  • nicell (or rather, the more self-descriptive prts_per_unit_density) was added as a file-level attribute for bp and h5 particle data.
  • Removed output_particles_none_impl.hxx.

not yet implemented
on my macbook, using 1 aggregator per proc outperforms hdf5 writes, but
the default of 1 aggregator per node (i.e., 1 aggregator) underperforms
hdf5. On larger scales, I'd expect this to be reversed. Since prt
output isn't a bottleneck either way, I defer a complete solution.
This fixes a cursed bug wherein e.g. increasing the size of BndFields_
(by adding _hi background constants) caused a segfault in the hdf5
writer. Perhaps it only happened when using H5 prt output with BP
params, which is what I was doing.

On the bright side, I finally know how to use lldb/gdb.
@JamesMcClung
Copy link
Copy Markdown
Collaborator Author

The thing I'm least sure about is not using PSC's ADIOS2 wrappers. @germasch was there a reason for that/did I ADIOS2 wrong? I did notice that prt.bp was slower than prt.h5 on my laptop with default ADIOS2 parameters, with the bulk of the loss coming from the ADIOS2 write itself (not the data processing steps beforehand).

Copy link
Copy Markdown
Contributor

@germasch germasch left a comment

Choose a reason for hiding this comment

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

LGTM 👍

One minor comment: I've been thinking about renaming p[xyz] -> u[xyz] for quite a while -- not sure it's really worth it, but it might make one point of confusion less likely. Doing so internally isn't too big of an issue, but externally (in the output) of course has compatibility issues. Since this is new, and if that renaming is indeed the plan, maybe now is the time to change the naming there?

@JamesMcClung
Copy link
Copy Markdown
Collaborator Author

One minor comment: I've been thinking about renaming p[xyz] -> u[xyz] for quite a while -- not sure it's really worth it, but it might make one point of confusion less likely. Doing so internally isn't too big of an issue, but externally (in the output) of course has compatibility issues. Since this is new, and if that renaming is indeed the plan, maybe now is the time to change the naming there?

Definitely. Should all outputs be changed, or just the ADIOS2 output?

@germasch
Copy link
Copy Markdown
Contributor

Well, I was thinking just the adios2 right now, but if you want to do the other ones, feel free ;) (probably best in a separate PR)

@JamesMcClung JamesMcClung merged commit 57c4a69 into psc-code:main May 13, 2026
2 checks passed
@JamesMcClung JamesMcClung deleted the pr/adios2-particles branch May 13, 2026 15:01
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.

2 participants