Repository navigation
Fix restarts so that they reproduce uninterrupted runs bit-for-bit - #422
Merged
Merged
Conversation
- TimeIntegrator: store the cycle count in restart dumps (as a double, exact up to 2^53) and resume it on restart. The parity of ncycles sets the order of the RKL and hydro steps (Strang splitting); restarting at ncycles=0 from a dump written after an odd cycle flipped that order and made the restarted run diverge from the uninterrupted one. -maxcycles, the final performance figure and the cycle count reported at the end still refer to the cycles performed in the current run, and the log header is now also printed after a restart. - Dump: zero-pad strings (header, field names) up to their fixed size. Uninitialised bytes after the terminating null made otherwise identical dumps differ. - Xdmf: store xdmfFileNumber in restart dumps, as done for vtk, so that xdmf outputs do not start again from 0 after a restart.
By default HDF5 stores access, modification, change and birth times in each object header, so HDF5 files holding identical data differ byte for byte, e.g. between a restart and the uninterrupted run, or between two runs of the same setup. Disable time tracking on the file (root group), group and dataset creation property lists.
Contributor
|
there's an ongoing PR to add new types to dump files, so I suggest we wait for this to be merged before merging this PR, using a dedicated int_64 type for the cycle #. |
HDF5 object timestamps are useful metadata, and h5diff, which compares the content of the files, ignores them. Record them again by default (HDF5's own default), and only disable them when Idefix_DEBUG is on, so that debug builds still produce byte-identical .h5 files for identical data (e.g. a restart vs the uninterrupted run). Document this alongside the other effects of Idefix_DEBUG.
Contributor
|
Waiting for #423 to get through. |
Contributor
|
Rebuilt this branch (213f9db) and reproduced the fix on
Note: Good to merge from my side |
Register ncycles directly as int64_t instead of mirroring it in a double. Simplify TimeIntegrator by removing the ncyclesDump mirror and the associated static_casts.
Contributor
|
Now that #423 has been merged into develop, the cycle count is stored in dumps as native int64 ( Changes on top of the merge:
|
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.
This PR fixes three issues that prevented a restarted simulation from reproducing the uninterrupted one exactly.
Changes
TimeIntegrator):ncycleswas not saved in restart dumps, so a restart always started again atncycles=0. Because the parity ofncyclessets the order of the RKL and hydro steps (Strang splitting), restarting from a dump written after an odd cycle flipped that order, and the restarted run drifted away from the uninterrupted one. The cycle count is now stored in the dump (as adouble, exact up to 2^53, since dumps cannot storeint64_t) and resumed on restart. Dumps written by older versions don't have this field, so the cycle count falls back to 0, which is the old behaviour.-maxcycles, the final performance figure and the cycle count printed at the end still count only the cycles performed in the current run (newGetNCyclesThisRun()).GetNCycles()returns the total.ncycles == 0).Dump::WriteString): the bytes after the terminating null in the fixed-size header and field-name buffers were written as they were, uninitialised, so two otherwise identical dumps could differ byte for byte. Strings are now zero-padded.Xdmf):xdmfFileNumberis now registered in restart dumps, as is already done forvtkFileNumber, so XDMF outputs continue numbering after a restart instead of starting again from 0.Xdmf): by default HDF5 stores access, modification, change and birth times in every object header, so.h5files holding identical data differ byte for byte, even between two uninterrupted runs of the same setup.h5diffcompares the content and ignores these timestamps, so they are kept by default. When compiled with-DIdefix_DEBUG=ON, time tracking is turned off (H5Pset_obj_track_times(..., false)) on the file (root group), group and dataset creation property lists, so that identical data give byte-identical.h5files. Groups are now created withH5Gcreate2so that a group creation property list can be passed; with a size hint of 0,H5Gcreate1already used the default list, and file sizes are unchanged. This is documented with the other effects ofIdefix_DEBUG.Validation
test/HD/thermalDiffusionwithidefix-rkl.ini(HDF5 enabled), dumps and XDMF outputs every 0.01 up to t=0.2. I ran it without interruption, then restarted it from dump 3 (written after cycle 185, odd) and from dump 2 (cycle 178, even):.dmpfiles vs uninterrupted run.xmffiles vs uninterrupted run.h5files vs uninterrupted runh5diff); byte-identical with-DIdefix_DEBUG=ON.vtkfiles vs uninterrupted run.h5files differ (timestamps only)-DIdefix_DEBUG=ONI repeated the VTK and dump checks on
test/MHD/AmbipolarCshock3Dwithidefix-rkl.ini(3D MHD, RKL ambipolar diffusion, outputs every 10 up to t=100), restarting from dump 4 (cycle 913, odd) and dump 2 (cycle 504, even). All later.vtkand.dmpfiles are byte-identical to the uninterrupted run, and two independent uninterrupted runs are byte-identical to each other.Without
Idefix_DEBUG, the.h5files of a restart and of the uninterrupted run differ only by the object timestamps (all 16 objects of each file, checked withh5py), andh5diffreports no difference. As a control,h5diffdoes report a one-ulp change in a single value of a field.A fresh (non-restarted) run gives the same fields and HDF5 content as the current
develop(the only difference is the commit hash in theversionattribute). The build passes with-DIdefix_WERROR=ON, with and without-DIdefix_DEBUG=ON, and pre-commit (including cpplint) passes. The MPI-IO branch ofXdmf::Write()uses the same property lists, but I could only test serial HDF5 locally.