Skip to content

Commit

Permalink
compiler: handle plain text header
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Jan 30, 2025
1 parent 3399477 commit 4b2d851
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion devito/ir/iet/visitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,15 @@ def visit_Operator(self, o, mode='all'):
efuncs.extend([self._visit(i), blankline])

# Definitions
headers = [c.Define(*i) for i in o._headers] + [blankline]
headers = []
for h in o._headers:
try:
headers.append(c.Define(*h))
except TypeError:
# Plain string
headers.append(c.Line(h))
headers = headers + [blankline]
# headers = [c.Define(*i) for i in o._headers] + [blankline]

# Header files
includes = self._operator_includes(o) + [blankline]
Expand Down
2 changes: 1 addition & 1 deletion devito/passes/iet/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _complex_includes(iet: Callable, lang: type[LangBB], compiler: Compiler,
return iet, {}

metadata = {}
lib = as_tuple(lang['header-complex'])
lib = as_tuple(lang['includes-complex'])

if lang.get('complex-namespace') is not None:
metadata['namespaces'] = lang['complex-namespace']
Expand Down
2 changes: 1 addition & 1 deletion devito/passes/iet/languages/C.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CBB(LangBB):
'alloc-global-symbol': lambda i, j, k:
Call('memcpy', (i, j, k)),
# Complex and float16
'header-complex': 'complex.h',
'includes-complex': 'complex.h',
}


Expand Down
2 changes: 1 addition & 1 deletion devito/passes/iet/languages/CXX.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CXXBB(LangBB):
'alloc-global-symbol': lambda i, j, k:
Call('memcpy', (i, j, k)),
# Complex and float16
'header-complex': 'complex',
'includes-complex': 'complex',
'complex-namespace': [UsingNamespace('std::complex_literals')],
'def-complex': std_arith,
}
Expand Down

0 comments on commit 4b2d851

Please sign in to comment.