From e0fbdd6d2ba82b8c21ad5cce1a40415f5490209b Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 21 Nov 2026 07:42:24 -0800 Subject: [PATCH 1/3] Docs: GPU silent-failure traps for conditional private scalars, pre-binding device updates, harness-vs-code CI --- docs/documentation/gpuParallelization.md | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/documentation/gpuParallelization.md b/docs/documentation/gpuParallelization.md index 07c93cda61..4db106366c 100644 --- a/docs/documentation/gpuParallelization.md +++ b/docs/documentation/gpuParallelization.md @@ -978,6 +978,36 @@ answer is wrong, or one backend diverges from all the others. the rest overwrites neighbouring cells, with no error. A leading section (`arr(1:n)`, or a fixed trailing index such as `freg(d)%%lo(:,:,:,k)`) is contiguous and safe. Move a sub-box with a pack/unpack device kernel instead (`s_amr_pack_unpack_block_st`). +- **Assign every GPU-private scalar unconditionally before any conditional use.** A private + copy is not initialised from the host value (only `firstprivate` is), so a scalar written + only under an `if` is undefined on the threads that skip the write. PR #2330 had + `if (ib_id > 0) g = ib_id` inside the `GPU_PARALLEL_LOOP` of `s_ib_shell_mass` + (`src/simulation/m_ibm.fpp`). On NVHPC 25.5 (A100 and H200, OpenACC and OpenMP) `g` was + undefined for cells with `ib_id <= 0`, the shell gas mass sum stayed 0, the `ib_mass_relax` + correction was silently inert, and 13 moving-body tests failed on NVIDIA. CPU, Cray and + amdflang happened to behave. It was found with debug prints on an A100 and fixed by + `g = max(ib_id, 0)`. The same pattern (`i`, `g`, `sh` set only under + `if (wc_on(c) == 1)`) turned up in the heat-booking loop of `s_accumulate_ib_face_fluxes` + in review of PR #2329 and was hardened. Give each private scalar a safe default, and clamp + or guard any array index taken from a marker id that can be `<= 0`. To find candidates, run + ``grep -nE 'if \(.*\) [a-z_]+ = ' src/simulation/*.fpp``; each hit inside a GPU loop needs a + human check of its context. +- **Run `GPU_UPDATE(device=...)` and `GPU_ENTER_DATA` of static module data only after the + rank is bound to its GPU.** `s_mpi_initialize` (`src/common/m_mpi_common.fpp`) updated + `num_procs` and `proc_rank` on the device before `s_initialize_mpi_domain` + (`src/simulation/m_start_up.fpp`) called `acc_set_device_num` / `omp_set_default_device`. + The update went to the default device, so a rank bound to another device kept an + uninitialised copy and `f_local_rank_owns_location` returned `.true.` on both ranks: a + collision force was applied twice and summed. Reproduced on an NVIDIA A100 as a + deterministic difference between `-g 0` and `-g 0 2`. AMD CI hides it because each rank sees + one GPU and the binding is a no-op. Test a 2-rank GPU change with both ranks on one GPU and + on two GPUs. The fix is #2371. +- **A CI result that looks like a code failure can be the harness.** The Phoenix NVHPC lanes + timed out, rather than failed, for months: the suite needs about 7.5 h against a 3.5 h + limit. A Phoenix timeout or `Submitting batch file for Interactive failed` is no result for + the PR. An NVHPC version difference (25.5 vs 25.11) makes chemistry test `124D7972` differ + by 1.8% (issue #2181), so a new-compiler lane that disagrees with a golden file is not yet + evidence of a regression. - `@:ACC_SETUP_VFs` and `@:ACC_SETUP_SFs` compile only under Cray. Around MPI, use `GPU_UPDATE(host=...)` before a send and `GPU_UPDATE(device=...)` after a receive. From d894710cf058277d431051280e3de5286b2b0c13 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 21 Nov 2026 07:46:43 -0800 Subject: [PATCH 2/3] Docs: make the CI-harness trap time-independent; note grep over-matches --- docs/documentation/gpuParallelization.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/documentation/gpuParallelization.md b/docs/documentation/gpuParallelization.md index 4db106366c..30b353ca3e 100644 --- a/docs/documentation/gpuParallelization.md +++ b/docs/documentation/gpuParallelization.md @@ -990,7 +990,8 @@ answer is wrong, or one backend diverges from all the others. `if (wc_on(c) == 1)`) turned up in the heat-booking loop of `s_accumulate_ib_face_fluxes` in review of PR #2329 and was hardened. Give each private scalar a safe default, and clamp or guard any array index taken from a marker id that can be `<= 0`. To find candidates, run - ``grep -nE 'if \(.*\) [a-z_]+ = ' src/simulation/*.fpp``; each hit inside a GPU loop needs a + ``grep -nE 'if \(.*\) [a-z_]+ = ' src/simulation/*.fpp``; it over-matches (about 260 hits on + the tree at the time of writing, mostly host code), so each hit inside a GPU loop needs a human check of its context. - **Run `GPU_UPDATE(device=...)` and `GPU_ENTER_DATA` of static module data only after the rank is bound to its GPU.** `s_mpi_initialize` (`src/common/m_mpi_common.fpp`) updated @@ -1002,12 +1003,12 @@ answer is wrong, or one backend diverges from all the others. deterministic difference between `-g 0` and `-g 0 2`. AMD CI hides it because each rank sees one GPU and the binding is a no-op. Test a 2-rank GPU change with both ranks on one GPU and on two GPUs. The fix is #2371. -- **A CI result that looks like a code failure can be the harness.** The Phoenix NVHPC lanes - timed out, rather than failed, for months: the suite needs about 7.5 h against a 3.5 h - limit. A Phoenix timeout or `Submitting batch file for Interactive failed` is no result for - the PR. An NVHPC version difference (25.5 vs 25.11) makes chemistry test `124D7972` differ - by 1.8% (issue #2181), so a new-compiler lane that disagrees with a golden file is not yet - evidence of a regression. +- **A CI result that looks like a code failure can be the harness.** A Phoenix lane that hits + its Slurm time limit, or a launch failure such as `Submitting batch file for Interactive + failed`, is no result for the PR: check the job log for `TIMEOUT` before reading it as a code + failure. At the time of writing, NVHPC 25.5 and 25.11 differ by 1.8% on chemistry test + `124D7972` (issue #2181), so a lane on another compiler version that disagrees with a golden + file is not yet evidence of a regression. - `@:ACC_SETUP_VFs` and `@:ACC_SETUP_SFs` compile only under Cray. Around MPI, use `GPU_UPDATE(host=...)` before a send and `GPU_UPDATE(device=...)` after a receive. From afdf0068a951acf281e4c3064d5f2120637267e5 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 21 Nov 2026 07:48:22 -0800 Subject: [PATCH 3/3] Docs: drop unverified 'mostly host code' remark --- docs/documentation/gpuParallelization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/documentation/gpuParallelization.md b/docs/documentation/gpuParallelization.md index 30b353ca3e..7814315725 100644 --- a/docs/documentation/gpuParallelization.md +++ b/docs/documentation/gpuParallelization.md @@ -991,7 +991,7 @@ answer is wrong, or one backend diverges from all the others. in review of PR #2329 and was hardened. Give each private scalar a safe default, and clamp or guard any array index taken from a marker id that can be `<= 0`. To find candidates, run ``grep -nE 'if \(.*\) [a-z_]+ = ' src/simulation/*.fpp``; it over-matches (about 260 hits on - the tree at the time of writing, mostly host code), so each hit inside a GPU loop needs a + the tree at the time of writing), so each hit inside a GPU loop needs a human check of its context. - **Run `GPU_UPDATE(device=...)` and `GPU_ENTER_DATA` of static module data only after the rank is bound to its GPU.** `s_mpi_initialize` (`src/common/m_mpi_common.fpp`) updated