Skip to content

Commit

Permalink
#2716 add initial fix and test [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
arporter committed Sep 17, 2024
1 parent aa7f2e3 commit 3bbdef5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/psyclone/psyGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1714,14 +1714,16 @@ def _rename_psyir(self, suffix):
:param str suffix: the string to insert into the quantity names.
'''
# We need to get the kernel schedule before modifying self.name
# We need to get the kernel schedule before modifying self.name.
# If the kernel corresponds to an interface, this will get the
# implementation that is actually being called.
kern_schedule = self.get_kernel_schedule()
container = kern_schedule.ancestor(Container)

# Use the suffix to create a new kernel name. This will
# conform to the PSyclone convention of ending in "_code"
orig_mod_name = self.module_name[:]
orig_kern_name = self.name[:]
orig_kern_name = kern_schedule.name[:] # self.name[:]

new_kern_name = self._new_name(orig_kern_name, suffix, "_code")
new_mod_name = self._new_name(orig_mod_name, suffix, "_mod")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,26 @@ def test_new_same_kern_single(kernel_outputdir, monkeypatch):
assert out_files == [new_kernels[1].module_name+".f90"]


def test_transform_kern_with_interface(kernel_outputdir):
'''
'''
rtrans = ACCRoutineTrans()
_, invoke = get_invoke("26.8_mixed_precision_args.f90",
api="lfric", idx=0)
sched = invoke.schedule
kern = sched.coded_kernels()[0]
rtrans.apply(kern)
kern.rename_and_write()
out_files = os.listdir(str(kernel_outputdir))
import pdb; pdb.set_trace()
filename = os.path.join(str(kernel_outputdir), out_files[0])
assert os.path.isfile(filename)
with open(filename,
"r", encoding="utf-8") as ffile:
contents = ffile.read()
assert "happy days" in contents


# The following tests test the MarkRoutineForGPUMixin validation, for this
# it uses the ACCRoutineTrans as instance of this Mixin.

Expand Down

0 comments on commit 3bbdef5

Please sign in to comment.