Skip to content

Commit c60d364

Browse files
Spencer Bryngelsonclaude
andcommitted
Fix CCE 19.0.0 + OpenACC: patch pyrometheus thermochem GPU_ROUTINE macro
Pyrometheus generates !DIR$ INLINEALWAYS for Cray+OpenACC but omits !acc routine seq, so thermochem routines are not registered as OpenACC device routines. Calling them from GPU kernels causes runtime memory access faults at time step 1. Post-process the generated m_thermochem.f90 to replace the broken Cray-specific #ifdef block with a plain #define GPU_ROUTINE(name) !acc routine seq, matching the fix already applied to parallel_macros.fpp in commit 66ad9b2. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f65abdf commit c60d364

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

toolchain/mfc/run/input.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,25 @@ def generate_fpp(self, target) -> None:
9090
directive_str = None
9191

9292
# Write the generated Fortran code to the m_thermochem.f90 file with the chosen precision
93+
thermochem_code = pyro.FortranCodeGenerator().generate(
94+
"m_thermochem",
95+
self.get_cantera_solution(),
96+
pyro.CodeGenerationOptions(scalar_type = real_type, directive_offload = directive_str)
97+
)
98+
99+
# CCE 19.0.0 workaround: pyrometheus generates !DIR$ INLINEALWAYS for Cray+ACC
100+
# but omits !$acc routine seq, so thermochem routines are not registered as
101+
# OpenACC device routines. Replace with plain !$acc routine seq (no INLINEALWAYS).
102+
if directive_str == 'acc':
103+
thermochem_code = thermochem_code.replace(
104+
"#ifdef _CRAYFTN\n#define GPU_ROUTINE(name) !DIR$ INLINEALWAYS name\n"
105+
"#else\n#define GPU_ROUTINE(name) !$acc routine seq\n#endif",
106+
"#define GPU_ROUTINE(name) !$acc routine seq"
107+
)
108+
93109
common.file_write(
94110
os.path.join(modules_dir, "m_thermochem.f90"),
95-
pyro.FortranCodeGenerator().generate(
96-
"m_thermochem",
97-
self.get_cantera_solution(),
98-
pyro.CodeGenerationOptions(scalar_type = real_type, directive_offload = directive_str)
99-
),
111+
thermochem_code,
100112
True
101113
)
102114

0 commit comments

Comments
 (0)