Proposed HDF5 input format and draft implementation#224
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an HDF5-based format for EXP particle “body” input data, along with a converter utility and initial integration into Component so EXP can initialize from either ASCII or HDF5 while preserving backward compatibility.
Changes:
- Added
hdf5bodsutility to convert EXP ASCII body files to compressed HDF5 (and back), with optional round-trip verification. - Updated
Componentinitialization to detect HDF5 body files and read/distribute particles from HDF5 when applicable (fallback to existing ASCII reader otherwise). - Bumped project/documentation version to 7.11.0.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/PhaseSpace/hdf5bods.cc | New ASCII↔HDF5 body-file converter using HighFive + OpenMP; writes proposed schema attributes/datasets. |
| utils/PhaseSpace/CMakeLists.txt | Builds/installs the new hdf5bods executable. |
| src/Component.H | Adds declarations for HDF5 initialization/read helpers. |
| src/Component.cc | Adds HDF5 detection and HDF5-based body ingest + MPI distribution. |
| include/ScopeTimer.H | New simple scope-based timing helper used by the converter. |
| doc/exp.cfg.breathe | Version bump for generated docs. |
| doc/exp.cfg | Version bump for generated docs. |
| CMakeLists.txt | Project version bump to 7.11.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Thanks for developing this, @The9Cat ! I've tested the compile. I wonder if we can get Copilot to help write the minimal test to read files with attributes / indices? |
|
I've rebased this to |
…stream to make sure that any trailing white space is ignored
|
It would be interesting to see what copilot would do with that request! On indexes and attributes, I realize that we can use I fixed a minor bug in |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
michael-petersen
left a comment
There was a problem hiding this comment.
I haven't as extensive testing as you have, but I have checked that I can do a bods -> hdf5 -> bods, and that I can start a simulation from hdf5. As far as I can tell, this is self-contained and good to go -- and a very welcome addition!
|
Okay, as soon as the CI run from the last merge fixing the version (induced by the previous merge to |
Summary of changes
Component. Also, the PR HDF5 documentation EXP-docs#42 include a full write-up and discussion of the HDF5 initialization and the new HDF5 phase-space file format that we currently recommend instead of the older nativePSPformat.History and intent
This started as a initial body file compressor. Using HDF5 to exploit the intrinsic stuctural similarities in a body file seemed like a good way to go. After completing the standalone routine, I realized that I was more than half way to an implementation of a reader for the
Componentclass.This is low priority and does not fix any bugs. But the ugly and inefficient ASCII tables should probably be replaced by HDF5 now that most of EXP is reading/writing using HDF5.
Implementation details
/
├── Attributes
│ ├── num_particles (int)
│ ├── num_aux_ints (int)
│ └── num_aux_floats (int)
└── particles/ (Group)
├── index (Dataset, unsigned long)
├── m (Dataset, float/double)
├── x, y, z (Datasets, float/double)
├── u, v, w (Datasets, float/double)
├── aux_int_0, aux_int_1, ... (Datasets, int)
└── aux_float_0, aux_float_1, ... (Datasets, float/double)
indexandaux_int_*,aux_float_*fields are optional.posintox, y, z(andvelintou, v, w) to simply thestd::variantcoding to allow bothfloatanddoublearrays. It is possible that consolidating into 2d arrays could be more efficient. But this is easier to code.m, x, y, z, u, v, wif desired.hdf5bodswas initially designed to compress body files and it achieves that goal. It is implemented with OpenMP which gives some modest performance gains (but not MPI). AComponentclass checks whether the specified body file is HDF5 and reverts to the original ascii method if not; so all of the prior behavior is retained for compatibility.indexfield (unsigned long) exists, it will populate the EXPParticle.indxfield. Similarly, the stand-along conversion routine has can read and write theindexfield for consistency with the original ASCII body table format.hdf5bodsconverter has support for multiple HDF5 compression filters for testing. The default GZip has the highest compression ratio but it also takes the most CPU time.Tests so far
hdf5bods, has built in round-trip verification which passesexpcan read the new HDF5 files and produce the same run for a simple case