Repository navigation
GPU: send num_procs and proc_rank to the device after the rank is bound to its GPU - #2371
Conversation
|
Claude Code Review Head SHA: 63649fa Files changed:
Findings: |
Lines of Code
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2371 +/- ##
==========================================
+ Coverage 65.72% 65.77% +0.04%
==========================================
Files 111 111
Lines 30549 30582 +33
Branches 4673 4680 +7
==========================================
+ Hits 20079 20115 +36
+ Misses 6699 6680 -19
- Partials 3771 3787 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Independent NVIDIA verification of current
Check for #2371 (num_procs/proc_rank device update after the GPU binding): every 2-rank IBM test run with the ranks on two different GPUs.
Totals: 118/118 IBM-label tests pass on one GPU and on two GPUs; no failures, no skips beyond the filter. This covers OpenACC only; the OpenMP-offload path was not run in this table. Not run: chemistry tests, OpenMP-offload build, CPU build, any NVHPC other than 25.5, before/after timing of the changes. AI-assisted (Claude Code). |
… binding (#2384) #2371 moved this update after each rank is bound to its GPU, which fixed the bound device's copy under OpenACC. Under NVHPC OpenMP offload, a rank whose first device operation comes after omp_set_default_device moves it to another GPU then fails its first allocation with CUDA_ERROR_INVALID_CONTEXT (two ranks on two GPUs). Keep the update after binding and restore the earlier one.
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.
Summary
In
simulation,s_mpi_initializeends with$:GPU_UPDATE(device='[num_procs, proc_rank]'), but it is called froms_initialize_mpi_domainbefore each rank is bound to its GPU (acc_set_device_num/omp_set_default_device). A rank bound to a device other than the default one never receives the values: its device copy ofnum_procsstays uninitialised. The only device reader,f_local_rank_owns_location(if (num_procs > 1)), then returns.true.on both ranks in the IBM collision kernels, so the contact force is applied by both ranks and summed.Fix: do the update right after the device binding in
s_initialize_mpi_domainand drop it froms_mpi_initialize.pre_processandpost_processalso calls_mpi_initialize, butGPU_UPDATEis a no-op there and nothing else in them reads the values on the device.Evidence (hand test, NVIDIA A100 80GB (Georgia Tech wingtip), NVHPC 25.5, OpenACC, 2 ranks)
-g 0 2maps rank 0 to GPU 0 and rank 1 to GPU 2 (-g 0puts both ranks on GPU 0). Quantities are density (var 1656,D/cons.1.00.000100.dat) and energy (var 220,D/cons.4.01.000100.dat) of a 2-rank IBM collision case (a friction test from #2354). Golden values (Cray CPU build): 0.973596 / 2.50569.-g00 200 22 00 30 1(two GPUs)0(one GPU)examples/1D_sodshocktube, 2 ranks, throwaway kernel printing device vs host at the first step (unpatched)num_procs/proc_rank= 0 / 0, host = 2 / 1; rank 0 fine--gpu mp, tests 09FDDC81 04FB9E91 9C0CAF25 50B98DBF (one GPU per rank, binding is a no-op)The patched mappings agree to about 1e-12. The unpatched
-g 0 2result is reproducible to 1e-12 across repeats;--rdma-mpidid not change it and it persists with friction off, so it is not a halo or friction issue. The unpatched build only passes when both ranks share a GPU.Not verified
gq3_pts/gq3_wtsandnvhpc_omp_state_dependent_eosmatched the host everywhere, sonum_procsandproc_rankare the only stale device values found.omp_set_default_device): checked by reading the code only, not run.--rdma-mpi(the latter made no difference to the unpatched failure on the A100).This PR was made with Claude Code (AI).