Skip to content

Commit

Permalink
fix includes for successors for F2C
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSt98 committed Jul 26, 2024
1 parent f55aff0 commit fcfc900
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 2 additions & 8 deletions loki/transformations/transpile/fortran_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from collections import OrderedDict

from loki.backend import cgen, fgen, cudagen
from loki.batch import Transformation, ProcedureItem
from loki.batch import Transformation
from loki.expression import (
symbols as sym, Variable, InlineCall, RangeIndex, Scalar, Array,
ProcedureSymbol, SubstituteExpressions, Dereference, Reference,
Expand Down Expand Up @@ -201,14 +201,8 @@ def transform_subroutine(self, routine, **kwargs):
Sourcefile.to_file(source=fgen(module), path=self.wrapperpath)

# Generate C source file from Loki IR
# TODO: double-check whether this is called in real life and why this is not called by the tests ...
for successor in successors:
if self.language == 'c':
c_kernel.spec.prepend(Import(module=f'{successor.routine.name.lower()}_c.h', c_import=True))
else:
# TODO: should include .h file, however problem compiling/running multiple compilation units ...
if not isinstance(successor, ProcedureItem):
c_kernel.spec.prepend(Import(module=f'{successor.routine.name.lower()}_c.c', c_import=True))
c_kernel.spec.prepend(Import(module=f'{successor.ir.name.lower()}_c.h', c_import=True))

if depth == 1:
if self.language != 'c':
Expand Down
4 changes: 4 additions & 0 deletions loki/transformations/transpile/tests/test_transpile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,8 @@ def test_scc_cuda_parametrise(tmp_path, here, frontend, config, horizontal, vert
assert '#include<cuda_runtime.h>' in c_kernel
assert '#include"kernel_c.h"' in c_kernel
assert '#include"kernel_c_launch.h"' in c_kernel
assert 'include"elemental_device_c.h"' in c_kernel
assert 'include"device_c.h"' in c_kernel
assert '__global__voidkernel_c' in c_kernel
assert 'jl=threadidx.x;' in c_kernel
assert 'b=blockidx.x;' in c_kernel
Expand Down Expand Up @@ -1404,6 +1406,8 @@ def test_scc_cuda_hoist(tmp_path, here, frontend, config, horizontal, vertical,
assert '#include<cuda_runtime.h>' in c_kernel
assert '#include"kernel_c.h"' in c_kernel
assert '#include"kernel_c_launch.h"' in c_kernel
assert '#include"elemental_device_c.h"' in c_kernel
assert '#include"device_c.h"' in c_kernel
assert '__global__voidkernel_c' in c_kernel
assert 'jl=threadidx.x;' in c_kernel
assert 'b=blockidx.x;' in c_kernel
Expand Down

0 comments on commit fcfc900

Please sign in to comment.