Summary
GPU_ROUTINE(..., cray_inline=True) and GPU_ROUTINE(..., cray_noinline=True) never emit their !DIR$ directive on a Cray GPU build. The directives are emitted only on Cray CPU builds, where a device-inlining hint has no purpose. Every current use of these options is in device code, so in practice both options are no-ops.
Where
src/common/include/parallel_macros.fpp:66-100. The cray_noinline branch expands to:
#ifdef _CRAYFTN
#if MFC_OpenACC
$:acc_directive ! acc routine only
#elif MFC_OpenMP
$:omp_directive ! omp declare target only
#else
$:cray_noinline_directive ! !DIR$ NOINLINE -- Cray CPU only
#endif
#elif MFC_OpenACC
$:acc_directive
#elif MFC_OpenMP
$:omp_directive
#endif
Under _CRAYFTN, the !DIR$ line sits in the #else arm, so it is selected only when neither MFC_OpenACC nor MFC_OpenMP is defined. The cray_inline branch immediately below has the same shape and the same problem.
Reproduction
$ printf "#:include 'parallel_macros.fpp'\nsubroutine s_t\n \$:GPU_ROUTINE(function_name='s_t', parallelism='[seq]', cray_noinline=True)\nend subroutine\n" > /tmp/mt.fpp
$ ./build/venv/bin/fypp -I src/common/include -DMFC_COMPILER='"Cray"' -DMFC_CASE_OPTIMIZATION=False /tmp/mt.fpp
subroutine s_t
#ifdef _CRAYFTN
#if MFC_OpenACC
!$acc routine seq
#elif MFC_OpenMP
!$omp declare target device_type(any)
#else
!DIR$ NOINLINE s_t
#endif
#elif MFC_OpenACC
!$acc routine seq
#elif MFC_OpenMP
Substituting cray_inline=True produces the same structure with !DIR$ INLINEALWAYS s_t in the same unreachable arm.
Impact
- 8 call sites use
cray_noinline=True, 43 use cray_inline=True, across m_variables_conversion, m_boundary_primitives, m_riemann_state, m_qbmm, m_bubbles, m_bubbles_EL, m_bubbles_EL_kernels, m_compute_cbc, m_chemistry, m_phase_change, and m_sim_helpers.
- All of them are device routines, so on Cray GPU builds the inlining behaviour is whatever the compiler's heuristics choose. Whatever these options were added to guarantee is not in effect there.
- If any of them was added to work around a Cray codegen issue, that workaround has been silently inactive on Cray GPU builds.
Both !DIR$ INLINEALWAYS and !DIR$ NOINLINE are accepted by Cray ftn alongside !$acc routine / !$omp declare target, so the fix should be to emit the !DIR$ line in addition to the offload directive rather than as an alternative to it:
#ifdef _CRAYFTN
$:cray_noinline_directive
#if MFC_OpenACC
$:acc_directive
#elif MFC_OpenMP
$:omp_directive
#endif
#elif MFC_OpenACC
...
Worth confirming the directive ordering Cray expects relative to !$acc routine before settling on a form.
Notes
Pre-existing; parallel_macros.fpp is unchanged on the current master and by any open PR. Found while investigating a Cray-only NaN regression on Frontier in #1679, where the inlining status of s_convert_species_to_mixture_variables_kernel (declared cray_noinline=True) mattered to the diagnosis. Whether the two are related is not established — filing separately because the macro defect stands on its own.
Summary
GPU_ROUTINE(..., cray_inline=True)andGPU_ROUTINE(..., cray_noinline=True)never emit their!DIR$directive on a Cray GPU build. The directives are emitted only on Cray CPU builds, where a device-inlining hint has no purpose. Every current use of these options is in device code, so in practice both options are no-ops.Where
src/common/include/parallel_macros.fpp:66-100. Thecray_noinlinebranch expands to:Under
_CRAYFTN, the!DIR$line sits in the#elsearm, so it is selected only when neitherMFC_OpenACCnorMFC_OpenMPis defined. Thecray_inlinebranch immediately below has the same shape and the same problem.Reproduction
Substituting
cray_inline=Trueproduces the same structure with!DIR$ INLINEALWAYS s_tin the same unreachable arm.Impact
cray_noinline=True, 43 usecray_inline=True, acrossm_variables_conversion,m_boundary_primitives,m_riemann_state,m_qbmm,m_bubbles,m_bubbles_EL,m_bubbles_EL_kernels,m_compute_cbc,m_chemistry,m_phase_change, andm_sim_helpers.Both
!DIR$ INLINEALWAYSand!DIR$ NOINLINEare accepted by Cray ftn alongside!$acc routine/!$omp declare target, so the fix should be to emit the!DIR$line in addition to the offload directive rather than as an alternative to it:Worth confirming the directive ordering Cray expects relative to
!$acc routinebefore settling on a form.Notes
Pre-existing;
parallel_macros.fppis unchanged on the currentmasterand by any open PR. Found while investigating a Cray-only NaN regression on Frontier in #1679, where the inlining status ofs_convert_species_to_mixture_variables_kernel(declaredcray_noinline=True) mattered to the diagnosis. Whether the two are related is not established — filing separately because the macro defect stands on its own.