Skip to content

Commit

Permalink
Merge pull request #282 from ecmwf-ifs/nabr-revert-251
Browse files Browse the repository at this point in the history
Revert "DEPENDENCY TRAFO: statement functions included via c-style imports preserved" (#251)
  • Loading branch information
reuterbal authored Apr 10, 2024
2 parents dd7ec90 + b268942 commit 6216cca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 2 additions & 2 deletions loki/transform/dependency_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def rename_imports(self, source, imports, targets=None):
for im in imports:
if im.c_import:
target_symbol = im.module.split('.')[0].lower()
if targets and target_symbol.lower() in targets and 'intfb' in im.module.lower():
if targets and target_symbol.lower() in targets:
# Modify the the basename of the C-style header import
s = '.'.join(im.module.split('.')[1:])
im._update(module=f'{target_symbol}{self.suffix}.{s}')
Expand Down Expand Up @@ -490,7 +490,7 @@ def _update_item(proc_name, module_name):
for im in imports:
if im.c_import:
target_symbol = im.module.split('.')[0].lower()
if targets and target_symbol.lower() in targets and 'intfb' in im.module.lower():
if targets and target_symbol.lower() in targets:
# Create a new module import with explicitly qualified symbol
modname = f'{target_symbol}{self.module_suffix}'
_update_item(target_symbol.lower(), modname)
Expand Down
10 changes: 2 additions & 8 deletions tests/test_transform_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ def test_dependency_transformation_header_includes(here, frontend):
INTEGER, INTENT(INOUT) :: a, b, c
#include "kernel.intfb.h"
#include "kernel.func.h"
CALL kernel(a, b ,c)
END SUBROUTINE driver
Expand Down Expand Up @@ -246,9 +245,6 @@ def test_dependency_transformation_header_includes(here, frontend):
assert '#include "kernel.intfb.h"' not in driver.to_fortran()
assert '#include "kernel_test.intfb.h"' in driver.to_fortran()

# Check that imported function was not modified
assert '#include "kernel.func.h"' in driver.to_fortran()

# Check that header file was generated and clean up
assert header_file.exists()
header_file.unlink()
Expand All @@ -266,7 +262,6 @@ def test_dependency_transformation_module_wrap(frontend, use_scheduler, tempdir,
SUBROUTINE driver(a, b, c)
INTEGER, INTENT(INOUT) :: a, b, c
#include "kernel.func.h"
#include "kernel.intfb.h"
CALL kernel(a, b ,c)
Expand Down Expand Up @@ -325,11 +320,10 @@ def test_dependency_transformation_module_wrap(frontend, use_scheduler, tempdir,
calls = FindNodes(CallStatement).visit(driver['driver'].body)
assert len(calls) == 1
assert calls[0].name == 'kernel_test'
imports = FindNodes(Import).visit(driver['driver'].ir)
assert len(imports) == 2
imports = FindNodes(Import).visit(driver['driver'].spec)
assert len(imports) == 1
assert imports[0].module == 'kernel_test_mod'
assert 'kernel_test' in [str(s) for s in imports[0].symbols]
assert imports[1].module == 'kernel.func.h'


@pytest.mark.parametrize('frontend', available_frontends())
Expand Down

0 comments on commit 6216cca

Please sign in to comment.