Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9184acd
#2846 WIP adding support for renaming routines upon module inlining […
arporter Jan 16, 2026
4d91244
#2846 WIP supporting interfaces [skip ci]
arporter Jan 19, 2026
d3d0d7b
Merge branch 'master' into 2846_rename_inlined_routines
arporter Jan 19, 2026
1ae3225
#2846 first cut with passing tests
arporter Jan 19, 2026
4712a83
#2846 rm unused utilities
arporter Jan 19, 2026
b7e79e3
#2846 fix linting
arporter Jan 19, 2026
19be2f7
Merge branch 'master' into 2846_rename_inlined_routines
arporter Jan 20, 2026
2a78b97
#2846 WIP fixing tests after removing naming checks [skip ci]
arporter Jan 20, 2026
8cf153c
#2846 linting
arporter Jan 20, 2026
515c4b6
Merge branch 'master' into 2846_rename_inlined_routines
arporter Mar 25, 2026
a76f206
#2846 linting
arporter Mar 25, 2026
e8f9069
#2846 fix error msg in test
arporter Mar 25, 2026
39a5f7d
Merge branch 'master' into 2846_rename_inlined_routines
arporter Mar 31, 2026
efb0b6e
Merge branch '2846_rename_inlined_routines' of github.com:stfc/PSyclo…
arporter Apr 28, 2026
37f5517
Merge branch 'master' into 2846_rename_inlined_routines
arporter Apr 29, 2026
fdeb1ea
#2846 linting [skip ci]
arporter Apr 29, 2026
9027034
#2846 WIP fixing tests now kernels are renamed [skip ci]
arporter May 1, 2026
4b47003
#2846 add (unused) update_all argument to transformation
arporter May 5, 2026
bb77a46
Merge branch 'master' into 2846_rename_inlined_routines
arporter May 5, 2026
626b11f
Merge branch 'master' into 2846_rename_inlined_routines
arporter Jun 23, 2026
f86623b
#2846 WIP supporting update_all [skip ci]
arporter Jun 23, 2026
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
384 changes: 102 additions & 282 deletions src/psyclone/domain/common/transformations/kernel_module_inline_trans.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/psyclone/domain/lfric/lfric_kern.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def __init__(self):
api_config = Config.get().api_conf("lfric")
self._argument_kinds = {api_config.default_kind["real"],
api_config.default_kind["integer"]}
# TODO #2054 - this 'routine' property can be replaced once this
# class sub-classes Call.
self.routine: Optional[Reference] = None

def reference_accesses(self) -> VariablesAccessMap:
'''
Expand Down
17 changes: 14 additions & 3 deletions src/psyclone/psyGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,11 +1172,12 @@ def __init__(self,
self._opencl_options = {'local_size': 64, 'queue_number': 1}
self.arg_descriptors = call.ktype.arg_descriptors

# If we have an ancestor InvokeSchedule then add the necessary
# symbols.
# TODO #2054 - this 'routine' property can be replaced once this
# class sub-classes Call.
self.routine: Optional[Reference] = None

# If we have an ancestor InvokeSchedule then add the necessary
# symbols.
container = self.ancestor(Container)
if container:
symtab = container.symbol_table
Expand Down Expand Up @@ -1213,6 +1214,16 @@ def get_callees(self):
raise NotImplementedError(
f"get_callees() must be overridden in class {self.__class__}")

@property
def name(self) -> str:
'''
Override Kern.name to use the RoutineSymbol name if one is available.

'''
if self.routine:
return self.routine.symbol.name
return super().name

@property
def opencl_options(self):
'''
Expand Down Expand Up @@ -1309,7 +1320,7 @@ def lower_to_language_level(self) -> Node:
'''
symtab = self.ancestor(InvokeSchedule).symbol_table

rsymbol = symtab.lookup(self._name)
rsymbol = symtab.lookup(self.name)

# Create Call to the rsymbol with the argument expressions as children
# of the new node
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/psyclone/tests/domain/gocean/goloop_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ def __init__(self):
PSyIR node'''
# pylint: disable=super-init-not-called, non-parent-init-called
Node.__init__(self) # Ignore hierarchy constructors
self.routine = None

# Test Loop containing kernels with different offsets
gokern1 = GOKernMock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def test_kernelimportstoargumentstrans_no_wildcard_import():
trans = KernelImportsToArguments()
with pytest.raises(TransformationError) as err:
trans.apply(kernel)
assert ("'kernel_with_use_code' contains accesses to 'rdt' which is "
"unresolved" in str(err.value))
assert ("'kernel_with_use_code_inlined_' contains accesses to 'rdt' which "
"is unresolved" in str(err.value))


def test_kernelimportstoargumentstrans(fortran_writer):
Expand Down Expand Up @@ -165,16 +165,16 @@ def test_kernelimportstoargumentstrans(fortran_writer):

# Check the kernel code is generated as expected
kernel_code = fortran_writer(kernel.get_callees()[0])
assert ("subroutine kernel_with_use_code(ji, jj, istep, ssha, tmask, "
"rdt, magic)" in kernel_code)
assert ("subroutine kernel_with_use_code_inlined_(ji, jj, istep, ssha, "
"tmask, rdt, magic)" in kernel_code)
assert "real(kind=go_wp), intent(in) :: rdt" in kernel_code
assert "real(kind=go_wp), intent(inout) :: magic" in kernel_code

# Check that the PSy-layer generated code now contains the use statement
# and argument call
generated_code = str(psy.gen)
assert "use model_mod, only : magic, rdt" in generated_code
assert ("call kernel_with_use_code(i, j, oldu_fld, cu_fld%data, "
assert ("call kernel_with_use_code_inlined_(i, j, oldu_fld, cu_fld%data, "
"cu_fld%grid%tmask, rdt, magic)" in generated_code)
assert invoke.schedule.symbol_table.lookup("model_mod")
assert invoke.schedule.symbol_table.lookup("rdt")
Expand Down Expand Up @@ -210,8 +210,8 @@ def create_data_symbol(arg):
kernels = kernel.get_callees()
kernel_code = fortran_writer(kernels[0])

assert ("subroutine kernel_with_use_code(ji, jj, istep, ssha, tmask, rdt, "
"magic)" in kernel_code)
assert ("subroutine kernel_with_use_code_inlined_(ji, jj, istep, ssha, "
"tmask, rdt, magic)" in kernel_code)
assert "integer, intent(in) :: rdt" in kernel_code


Expand Down Expand Up @@ -261,15 +261,15 @@ def test_kernelimportstoarguments_multiple_kernels(fortran_writer):
# The kernels are checked before the psy.gen, so they don't include the
# modified suffix.
expected = [
["subroutine kernel_with_use_code(ji, jj, istep, ssha, tmask, rdt, "
"magic)",
["subroutine kernel_with_use_code_inlined_(ji, jj, istep, ssha, "
"tmask, rdt, magic)",
"real(kind=go_wp), intent(in) :: rdt"],
["subroutine kernel_with_use2_code(ji, jj, istep, ssha, tmask, cbfr,"
" rdt)",
["subroutine kernel_with_use2_code_inlined_(ji, jj, istep, ssha, "
"tmask, cbfr, rdt)",
"real(kind=go_wp), intent(inout) :: cbfr\n real(kind=go_wp), "
"intent(in) :: rdt"],
["subroutine kernel_with_use_code(ji, jj, istep, ssha, tmask, rdt, "
"magic)",
["subroutine kernel_with_use_code_inlined_(ji, jj, istep, ssha, "
"tmask, rdt, magic)",
"real(kind=go_wp), intent(in) :: rdt\n real(kind=go_wp), "
"intent(inout) :: magic"]]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1530,8 +1530,8 @@ def raise_gen_error():
monkeypatch.setattr(kern, "get_callees", raise_gen_error)
with pytest.raises(TransformationError) as err:
rtrans.apply(kern)
assert ("Failed to create PSyIR for kernel 'continuity_code'. Cannot "
"transform such a kernel." in str(err.value))
assert ("Failed to create PSyIR for kernel 'continuity_code_inlined_'. "
"Cannot transform such a kernel." in str(err.value))


def test_accroutinetrans_with_routine(fortran_writer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ def test_go_move_iteration_boundaries_inside_kernel_two_kernels_apply_twice(
ystop = cu_fld%internal%ystop
do j = 1, SIZE(cu_fld%data, dim=2), 1
do i = 1, SIZE(cu_fld%data, dim=1), 1
call compute_cu_code(i, j, cu_fld%data, p_fld%data, u_fld%data, xstart, \
xstop, ystart, ystop)
call compute_cu_code_inlined_(i, j, cu_fld%data, p_fld%data, u_fld%data,\
xstart, xstop, ystart, ystop)
enddo
enddo
xstart_1 = 1
Expand All @@ -219,8 +219,8 @@ def test_go_move_iteration_boundaries_inside_kernel_two_kernels_apply_twice(
ystop_1 = SIZE(uold_fld%data, dim=2)
do j = 1, SIZE(uold_fld%data, dim=2), 1
do i = 1, SIZE(uold_fld%data, dim=1), 1
call time_smooth_code(i, j, cu_fld%data, unew_fld%data, uold_fld%data, \
xstart_1, xstop_1, ystart_1, ystop_1)
call time_smooth_code_inlined_(i, j, cu_fld%data, unew_fld%data, \
uold_fld%data, xstart_1, xstop_1, ystart_1, ystop_1)
enddo
enddo

Expand Down
Loading