Skip to content

Fix --debug/--reldebug GPU builds#1527

Merged
sbryngelson merged 1 commit into
masterfrom
fix-gpu-debug-build
Jun 2, 2026
Merged

Fix --debug/--reldebug GPU builds#1527
sbryngelson merged 1 commit into
masterfrom
fix-gpu-debug-build

Conversation

@sbryngelson
Copy link
Copy Markdown
Member

Problem

--debug and --reldebug GPU builds (--gpu acc/--gpu mp) fail to compile with:

NVFORTRAN-S-1061-Procedures called in a compute region must have acc routine
information - s_mpi_abort
  (m_variables_conversion.fpp: 1335)

Root cause

s_compute_fast_magnetosonic_speed is a GPU device routine ($:GPU_ROUTINE(... parallelism='[seq]')), but its #ifdef MFC_DEBUG diagnostic block calls the host routine s_mpi_abort. That call is only legal in Release because IPO/-Minline inlines it away — and --debug/--reldebug disable IPO. With IPO off, the device routine is left calling a host MPI routine, which is illegal in device code.

This is why the failure is debug-only: in Release the entire #ifdef MFC_DEBUG block is compiled out.

Fix

Guard the host s_mpi_abort call with #ifndef MFC_GPU, keeping the device-legal diagnostic print:

#ifdef MFC_DEBUG
        if (disc < 0._wp) then
            print *, 'rho, c, Bx, By, Bz, h, term, disc:', ...
#ifndef MFC_GPU
            call s_mpi_abort('Error: negative discriminant in s_compute_fast_magnetosonic_speed')
#endif
        end if
#endif

A full-tree scan confirms this is the only device-region s_mpi_abort site for NVHPC/Cray (the 6 NaN-check aborts in m_mpi_common.fpp are inside #if defined(__INTEL_COMPILER) and so are not compiled for these backends). CPU and Release builds are byte-for-byte unchanged: off-GPU the guarded call is identical, and in Release the block is compiled out.

Verification

Built on NVHPC 24.5 (Quadro RTX 6000, MFC_CUDA_CC=75):

Build Result
simulation --gpu acc --debug compiles, 0× NVFORTRAN-S-1061
simulation --gpu acc --reldebug compiles, 0× NVFORTRAN-S-1061
./mfc.sh precheck all 7 checks pass
./mfc.sh format clean

Verified on NVHPC only (the GPU compiler available on the test node); the fix is gated on MFC_GPU and is therefore compiler-agnostic (Cray/AMD untested here).

…t of device code)

s_compute_fast_magnetosonic_speed is a GPU routine (acc routine seq) but its
MFC_DEBUG diagnostic block called host s_mpi_abort, which is illegal in device
code without IPO inlining. Debug/reldebug builds disable IPO, so --gpu acc/mp
debug builds failed with NVFORTRAN-S-1061. Guard the abort with #ifndef MFC_GPU,
keeping the device-legal diagnostic print. CPU and Release builds are unchanged.
Copilot AI review requested due to automatic review settings June 2, 2026 00:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes GPU Debug/RelDebug compilation failures by preventing a host-only MPI abort routine (s_mpi_abort) from being referenced inside a GPU device routine (s_compute_fast_magnetosonic_speed) when IPO/inlining is disabled.

Changes:

  • Guarded the s_mpi_abort call in the MFC_DEBUG diagnostic path so it is not compiled for MFC_GPU builds.
  • Added explanatory comments documenting why the guard is required for device compilation.

Comment thread src/common/m_variables_conversion.fpp
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.64%. Comparing base (08d12f8) to head (978ef64).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1527   +/-   ##
=======================================
  Coverage   60.64%   60.64%           
=======================================
  Files          73       73           
  Lines       20213    20213           
  Branches     2936     2936           
=======================================
  Hits        12259    12259           
  Misses       5966     5966           
  Partials     1988     1988           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbryngelson sbryngelson changed the title Fix --debug/--reldebug GPU builds (guard host s_mpi_abort out of device code) Fix --debug/--reldebug GPU builds Jun 2, 2026
@sbryngelson sbryngelson merged commit 9e862e8 into master Jun 2, 2026
93 checks passed
@sbryngelson sbryngelson deleted the fix-gpu-debug-build branch June 2, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants