Skip to content

Commit daecec4

Browse files
FabioLuporinimloubout
authored andcommitted
arch: Add Compiler.save_header
1 parent 570605c commit daecec4

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

devito/arch/compiler.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,22 @@ def load(self, soname):
291291
"""
292292
return npct.load_library(str(self.get_jit_dir().joinpath(soname)), '.')
293293

294+
def save_header(self, filename, code):
295+
"""
296+
Store some source code into a header file within the same temporary directory
297+
used for JIT compilation.
298+
299+
Parameters
300+
----------
301+
filename : str
302+
The name of the header file (w/o the suffix).
303+
code : str
304+
The source code to be stored.
305+
"""
306+
hfile = self.get_jit_dir().joinpath(filename).with_suffix('.h')
307+
with open(str(hfile), 'w') as f:
308+
f.write(code)
309+
294310
def save(self, soname, binary):
295311
"""
296312
Store a binary into a file within a temporary directory.

0 commit comments

Comments
 (0)