Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "DEPENDENCY TRAFO: statement functions included via c-style imports preserved" (#251) #282

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading