Open
Conversation
…hat the json is closed.)
… and make sure that the datasink gets passed to the bunch for binning config output
aaadelmann
reviewed
Mar 7, 2026
| * Fills @p binCounts and @p binWidths with the current global histogram data and | ||
| * returns the lower bound xMin used when defining the histogram. | ||
| * | ||
| * @note This should be called after initGlobalHistogram()/genAdaptiveHistogram(), |
Contributor
There was a problem hiding this comment.
The IF (rank 0) must be in the body of this function!
Contributor
Author
There was a problem hiding this comment.
The if (rank 0) check is inside DataSink::dumpBinConfig similar to how some of the other dump functions handle it.
But you're right, it's at minimum inconsistent with the doxygen of the function you pointed out. For the moment I removed the rank-0-note from the doxygen, since the function works just fine on any rank (it also doesn't do MPI, the global host histograms exist through the binning routine anyways). But if you think that it would be better, I could of course add the redundant if (ippl::Comm->rank() != 0) { return -1; } inside AdaptBins::getBinConfigHost, just in case?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #242
This PR implements a new writer,
Structure/BinningConfigWriter.h, that prints the binning configuration to a.jsonfile attached to aBinningCmdobject for everyn-thtimestep. The.jsonfile has the following format:[ { "step": 0, "time": 0, "preMerge": true, "xMin": 0.15340109944906014, "binCounts": [ 1, 0, 0, 0, 1, 1, 0, 5, 0, 3, 3, 2, 1, 4, 1, 6, 5, 5, 6, 7, 14, 20, 17, 19, 18, 30, 39, 41, 47, 41, 62, 77, 104, 116, 123, 131, 148, 183, 189, 208, 268, 267, 339, 341, 400, 400, 454, 485, 507, 605, 637, 612, 725, 716, 775, 749, 806, 821, 854, 865, 939, 922, 909, 858, 843, 896, 892, 864, 872, 819, 847, 790, 741, 698, 706, 630, 543, 584, 555, 513, 452, 411, 401, 381, 302, 270, 263, 226, 175, 169, 147, 119, 115, 94, 93, 70, 69, 55, 40, 36, 33, 28, 15, 20, 9, 12, 8, 3, 8, 2, 6, 2, 5, 1, 1, 1, 0, 0, 0, 1 ], "binWidths": [ 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296, 0.00065572253938711296 ] }, { "step": 0, "time": 0, "preMerge": false, "xMin": 0.15340109944906014, "binCounts": [ 32768 ], "binWidths": [ 0.078686704726453741 ] }, ... ]This ensures easy readability, e.g. in Python. For every write action, it saves the pre-merged binning configuration as well as the merged config (
"preMerge": false).Features
AdaptBins) is written to a JSON file configured viaBinningCmd(e.g.DUMPBINSFILE,DUMPBINSFREQ).step,time,preMerge,xMin,binCounts,binWidths. Output is pretty-printed and the file is always a valid, closed JSON array after every write (meaning it is valid, even when the program crashes!).PartBunch::computeSelfFields: once after full rebin (pre-merge histogram) and once after adaptive merge (post-merge), whendumpBinConfig(true)anddumpBinConfig(false)are called.PartBunchat construction (fromTrackRun/ParallelTracker).DataSink::dumpBinConfig(...)delegates to a dedicated writer; no use ofOpalDatainsidecomputeSelfFieldsfor this. In the process I also removedOpalDistribution_mfrom the bunch as it is unused (handled completely byParallelTracker).Changes to the input file, i.e.
BinningCmd:You can now append an (optional) file path and dump frequency. The dump will only be performed if a file path is given (otherwise the variable defaults to
DUMPBINSFILE="NONE", so no dump).Changes:
DataSinkhas a new functiondumpBinConfig(step, time, preMerge, binCounts, binWidths, xMin, fileName)that prints a data row to file on rank 0.PartBunchconstructor takesstd::shared_ptr<DataSink> dataSink;,computeSelfFieldscallsdumpBinConfig(true)anddumpBinConfig(false)instead ofbins->print().TrackRun:initDataSink()builds/gets globalDataSinkand setsds_m;.PartBunchandParallelTrackerare constructed withds_m, now a shared pointer.BinningCmd::update(): when dumping is enabled, ensures dump filename has.jsonsuffix and validatesDUMPBINSFREQ;.BinHistogets a newAdaptBins::getBinConfigHostfunction that writes the global bin configuration into a hoststd::vectorfor theTesting
I have a new test file Drift-4-open-bindump.txt that has the bin configuration logging enabled, if you want to test it. If you just want to look at the new output, have a look at
bin-dump.json(should also look nice in the browser!).Looks good on GPU (Daint, GH200). Output also looks good, including the binning configuration.
Also looks good on CPU:
Also ran all of the regression tests on cpu-serial, all of the ones we would expect it from passed (110/120). Oh and of course we also have some new unit tests.
Additional Information
Here is a small animation that can be created easily with this new output file:
If shows really nice how the flattop distribution propagates in the$\frac{v}{c}$ , where $[v] = \frac{\mathrm{m}}{\mathrm{s}}$ ).
CONSTANTEFIELDCAVITY(note thatxin this plot is normalized velocity