Repository navigation
Conversation
Motivation Mixed-precision builds have incompatible storage and working types, and parallel field views use the wrong cell size. Expectation Make the affected interfaces and MPI I/O agree with storage precision while preserving non-mixed behavior. Change A --mixed build (stp = half, wp = single) did not compile with nvfortran, and once it did, runs on two or more ranks with parallel_io wrote corrupted initial-condition and restart files. Build: - m_viscous, m_bubbles_EE, m_acoustic_src and post_process m_start_up passed real(stp) field values to real(wp) dummies. Convert them at the call site, converting each operand before any sum or quotient so the arithmetic does not run in half precision. - m_igr exposes jac through a scalar_field pointer, which is real(stp), while jac was declared real(wp). Every write to jac already converts to stp, so declare it real(stp). - integer_field dropped to integer(kind=1) under --mixed, but s_decode_patch_periodicity, the MPI_INTEGER marker I/O and the GPU_ATOMIC max expect default integers, and encoded periodic IB ids exceed 127. Keep it a default integer. Parallel I/O: a stored cell is 2 bytes under --mixed (mpi_io_p = MPI_BYTE, mpi_io_type = 2), but the field subarrays were built from mpi_p and several file views used mpi_p as their etype, so each rank's block landed at the wrong offset. Build the subarrays from a 2-byte cell type (s_create_mpi_field_subarray), use mpi_io_p as the etype wherever the transfer uses it, and read data_size*mpi_io_type elements in pre_process. test_mixed_mpi_views.py checks the production views from 2 ranks against a serially written file. Non-mixed builds are unchanged: stp == wp, mpi_io_p == mpi_p and mpi_io_type == 1 there, so every change is a no-op. Result The type conversions, integer metadata and file-view fixes are retained. The precheck passes and regression reference files are unchanged. Compiler tests are skipped by the standard precheck; the documented numerical and compiler verification is not rerun by this preparation. Co-authored-by: ruru25254649 <ruru.2525.4649@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WPhkY8p1EHhGY7jScizJmC
Lines of Code
|
|
Claude Code Review Head SHA: 910f07b Files changed:
Findings: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2110 +/- ##
=======================================
Coverage 61.95% 61.96%
=======================================
Files 86 86
Lines 22906 22908 +2
Branches 3378 3378
=======================================
+ Hits 14192 14195 +3
+ Misses 6206 6205 -1
Partials 2508 2508 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
./mfc.sh build --mixed(half-precision storagestp, single-precision workingwp) does not compile on master with NVHPC. Once it does, runs on two or more ranks withparallel_io = 'T'write corrupted initial-condition and restart files. This PR fixes both.Non-mixed builds are unaffected. There
stp == wp,mpi_io_p == mpi_pandmpi_io_type == 1, so every change below is a no-op. The Cray--mixedfailure in #1965 happens earlier, inm_derived_types, and is not addressed here.1. The build
On master,
./mfc.sh build --mixed --no-gpuwith NVHPC 26.3 fails insimulation:--gpu accalso fails onf_bulk_modulusandf_advance_step. The fixes:real(stp)field values passed toreal(wp)dummies.m_viscous,m_bubbles_EE,m_acoustic_src, andpost_process/m_start_up(s_phase_temperature).real(..., kind=wp)at the call site. The dummies areintent(in), so nothing is written back.alpha_rho/max(alpha, sgm_eps)), each operand is converted first. Otherwise the sum, quotient andmaxwould run in half precision, andmaxwould mixstpwith thewpconstantsgm_eps.jacinm_igris declaredreal(wp), but it is exposed through ascalar_fieldpointer, which isreal(stp). Every assignment tojacalready converts tostp, so it is now declaredreal(stp).jac_rhsandjac_oldstaywp.integer_fieldstays a default integer. It used to drop tointeger(kind=1)under--mixed(since d290396), but its users need a default integer:s_decode_patch_periodicitytakes a default integer. This is the error left inm_ibm.fpponce the real-kind fixes are in.MPI_INTEGER.ib_markersis updated with aGPU_ATOMICmax.gbl_id + (num_gbl_ibs+1)*(xp + 3*yp + 9*zp), exceeds 127 with only a few bodies.2. Parallel I/O
Under
--mixeda stored cell is 2 bytes (mpi_io_p = MPI_BYTE,mpi_io_type = 2). The field file views did not follow that:s_initialize_mpi_dataands_initialize_mpi_data_dsbuilt each field's subarray frommpi_p, which is 4 bytes.MPI_FILE_SET_VIEWcalls inpre_process/m_start_up,simulation/m_data_outputandpost_process/m_data_inputusedmpi_pas the etype, while the transfer right after usesmpi_io_p. This breaks the Common Pitfalls rule incontributing.md: "mpi_io_pmust matchstp".pre_process/m_start_upreaddata_sizeelements ofmpi_pinto a buffer ofdata_size2-byte cells.On one rank the layout still comes out right by accident. On two or more, each rank's block lands at the wrong offset.
The fix:
s_create_mpi_field_subarray, a private helper inm_mpi_common.mpi_io_pas its etype.pre_processreader readsdata_size*mpi_io_typeelements ofmpi_io_p.The remaining
mpi_pviews (Lagrange bubbles and thepost_processoutput) describereal(wp)buffers and are correct as they are.toolchain/mfc/test_mixed_mpi_views.py:s_initialize_mpi_dataand every production fieldSET_VIEW/transfer pair against 2-byte opaque cells, so it needs noREAL(2)support. It writes from 2 ranks and compares the result with a serially written file.MFC_SKIP_COMPILER_TESTS=1, like the other compiler tests.Side effects
--mixedbuilds:ib_markersandbc_typetake 4 bytes per cell instead of 1.--mixedbuild cannot be read back. NVHPC could not produce such a build on master.jac(IGR) is stored instp, which is what every assignment to it already produced.%sf→%sf(:,:,:)in the same MPI-IO calls), inpre_process/m_start_up,simulation/m_data_outputandpost_process/m_data_input:private ::line inm_mpi_common, keep both.Verification
Hardware: Intel Core i7-14700F, RTX 4060 Ti (sm_89). Compiler: NVHPC 26.3 with its bundled HPC-X MPI, built in clean build directories.
Build:
--mixed --no-gpu, pre/sim/postsimulationfails (above)--mixed --gpu acc, pre/sim/postsimulationfails (alsof_bulk_modulus,f_advance_step)Parallel I/O:
examples/2D_riemann_testat 64², 20 steps,parallel_io = 'T',--mixed.restart_data/lustre_<step>.datfiles, byte for byte. Each is 40,960 bytes (64·64·5 fields·2 bytes).lustre_0(initial condition)lustre_10lustre_20--gpu acc): 1 rank vs 2 ranksDensity at step 20, 2 ranks, against a double-precision run of the same case:
--mixedThe final code writes restart files byte-identical to the runs above, on CPU and GPU. This inviscid case does not reach the operand-first conversions, which were added after those runs.
The operand-first conversions:
post_processtemperature (T_wrt = 'T'on the case above),--mixed, CPU and GPU, against doubleexamples/2D_poiseuille_nn(non-Newtonian),--mixed, CPU, 2,730 stepssimulation,--mixed --gpu acc --unified(the UVMjac_hostpath)Tests:
test_mixed_mpi_views.py: fails on master. Passes with this PR on Open MPI 4.1.6 + gfortran 13.3 and on HPC-X + nvfortran 26.3. Also passes merged with SCC 26: bug: fix parallel I/O failures and performance overhead #2085.ee99151b, GNU 13.3 + Open MPI 4.1.6, CPU: 725 passed, 0 failed (39 convergence cases skipped by default). No golden changes../mfc.sh lint, including the compiler tests, passes.Contribution Policy
All contributions are expected to demonstrate:
If these expectations are not met, we would prefer to implement the changes ourselves rather than spend time reviewing low-effort submissions.
Acknowledgement
This PR is from Diablo (Tsinghua University) participating in the SC26 Student Cluster Competition.