Skip to content

Commit

Permalink
SCC: Fix SCC + sequence-assoc + internal-inlining test
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange05 committed Jan 16, 2024
1 parent 67b54a9 commit 7ace31a
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions transformations/tests/test_single_column_coalesced.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
CallStatement, Conditional, Scalar, Array, Pragma, pragmas_attached,
fgen, Sourcefile, Section, SubroutineItem, pragma_regions_attached, PragmaRegion,
is_loki_pragma, IntLiteral, RangeIndex, Comment, HoistTemporaryArraysAnalysis,
gettempdir, Scheduler, SchedulerConfig
gettempdir, Scheduler, SchedulerConfig, SanitiseTransformation, InlineTransformation
)
from conftest import available_frontends
from transformations import (
Expand Down Expand Up @@ -1723,10 +1723,11 @@ def test_single_column_coalesced_vector_section_trim_complex(frontend, horizonta


@pytest.mark.parametrize('frontend', available_frontends())
@pytest.mark.parametrize('inline_members', [False, True])
@pytest.mark.parametrize('inline_internals', [False, True])
@pytest.mark.parametrize('resolve_sequence_association', [False, True])
def test_single_column_coalesced_inline_and_sequence_association(frontend, horizontal,
inline_members, resolve_sequence_association):
def test_single_column_coalesced_inline_and_sequence_association(
frontend, horizontal, inline_internals, resolve_sequence_association
):
"""
Test the combinations of routine inlining and sequence association
"""
Expand Down Expand Up @@ -1758,26 +1759,36 @@ def test_single_column_coalesced_inline_and_sequence_association(frontend, horiz

routine = Subroutine.from_source(fcode_kernel, frontend=frontend)

scc_transform = SCCBaseTransformation(horizontal=horizontal,
inline_members=inline_members,
resolve_sequence_association=resolve_sequence_association)
# Remove sequence association via SanitiseTransform
sanitise_transform = SanitiseTransformation(
resolve_sequence_association=resolve_sequence_association
)
sanitise_transform.apply(routine, role='kernel')

# Create member inlining transformation to go along SCC
inline_transform = InlineTransformation(inline_internals=inline_internals)

scc_transform = SCCBaseTransformation(horizontal=horizontal)

#Not really doing anything for contained routines
if (not inline_members and not resolve_sequence_association):
if (not inline_internals and not resolve_sequence_association):
inline_transform.apply(routine, role='kernel')
scc_transform.apply(routine, role='kernel')

assert len(routine.members) == 1
assert not FindNodes(Loop).visit(routine.body)

#Should fail because it can't resolve sequence association
elif (inline_members and not resolve_sequence_association):
elif (inline_internals and not resolve_sequence_association):
with pytest.raises(RuntimeError) as e_info:
inline_transform.apply(routine, role='kernel')
scc_transform.apply(routine, role='kernel')
assert(e_info.exconly() ==
'RuntimeError: [Loki::TransformInline] Cannot resolve procedure call to contained_kernel')

#Check that the call is properly modified
elif (not inline_members and resolve_sequence_association):
elif (not inline_internals and resolve_sequence_association):
inline_transform.apply(routine, role='kernel')
scc_transform.apply(routine, role='kernel')

assert len(routine.members) == 1
Expand All @@ -1786,6 +1797,7 @@ def test_single_column_coalesced_inline_and_sequence_association(frontend, horiz

#Check that the contained subroutine has been inlined
else:
inline_transform.apply(routine, role='kernel')
scc_transform.apply(routine, role='kernel')

assert len(routine.members) == 0
Expand Down

0 comments on commit 7ace31a

Please sign in to comment.