Skip to content

Commit

Permalink
#2716 fixes for the transformation in LFRic
Browse files Browse the repository at this point in the history
  • Loading branch information
arporter committed Oct 8, 2024
1 parent a00f367 commit 2b82201
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def apply(self, node, options=None):
# validation that it's a Routine. Now check if they are
# exactly the same.
for routine in container.walk(Routine, stop_type=Routine):
if routine.name == caller_name:
if routine.name == existing_symbol.name:
# This TransformationError happens here and not in
# the validation because it needs the
# symbols_to_bring_in applied to effectively
Expand Down
18 changes: 13 additions & 5 deletions src/psyclone/dynamo0p3.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
from psyclone.domain.lfric.lfric_invoke_schedule import LFRicInvokeSchedule
from psyclone.errors import GenerationError, InternalError, FieldNotFoundError
from psyclone.f2pygen import (AllocateGen, AssignGen, CallGen, CommentGen,
DeallocateGen, DeclGen, DoGen,
DeallocateGen, DeclGen, DoGen, InterfaceDeclGen,
ModuleGen, TypeDeclGen, UseGen, PSyIRGen)
from psyclone.parse.kernel import getkerneldescriptors
from psyclone.parse.utils import ParseError
Expand All @@ -71,10 +71,10 @@
from psyclone.psyir.nodes import (
Reference, ACCEnterDataDirective, ScopingNode, ArrayOfStructuresReference,
StructureReference, Literal, IfBlock, Call, BinaryOperation, IntrinsicCall)
from psyclone.psyir.symbols import (INTEGER_TYPE, DataSymbol, ScalarType,
UnresolvedType, DataTypeSymbol,
ContainerSymbol, ImportInterface,
ArrayType, UnsupportedFortranType)
from psyclone.psyir.symbols import (ArrayType, ContainerSymbol, DataSymbol,
DataTypeSymbol, GenericInterfaceSymbol,
INTEGER_TYPE, ScalarType, ImportInterface,
UnresolvedType, UnsupportedFortranType)


# pylint: disable=too-many-lines
Expand Down Expand Up @@ -473,6 +473,14 @@ def gen(self):
if not isinstance(routine, InvokeSchedule):
psy_module.add(PSyIRGen(psy_module, routine))

# Similarly, we have to take care of any Interface symbols (which
# we may have if we've inlined a polymorphic Kernel).
for sym in self.container.symbol_table.symbols:
if isinstance(sym, GenericInterfaceSymbol):
names = [rt.symbol.name for rt in sym.routines]
psy_module.add(
InterfaceDeclGen(psy_module, sym.name, names))

# Add all invoke-specific information
self.invokes.gen_code(psy_module)

Expand Down
8 changes: 0 additions & 8 deletions src/psyclone/psyGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,14 +710,6 @@ def __init__(self, symbol, KernFactory, BuiltInFactory, alg_calls=None,
else:
self.addchild(KernFactory.create(call, parent=self))

@property
def symbol_table(self):
'''
:returns: Table containing symbol information for the schedule.
:rtype: :py:class:`psyclone.psyir.symbols.SymbolTable`
'''
return self._symbol_table

@property
def invoke(self):
return self._invoke
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,13 +766,17 @@ def test_module_inline_with_interfaces(tmpdir):
'''
psy, invoke = get_invoke("26.8_mixed_precision_args.f90", "lfric",
name="invoke_0", dist_mem=False)
kern_call = invoke.schedule.walk(CodedKern)[0]
kern_calls = invoke.schedule.walk(CodedKern)
inline_trans = KernelModuleInlineTrans()
inline_trans.apply(kern_call)
inline_trans.apply(kern_calls[0])
# Check that module-inlining the second kernel call (which is to the
# same interface) doesn't break anything.
inline_trans.apply(kern_calls[1])
gen = str(psy.gen).lower()
# Both the caller and the callee are in the file and use the interface
# name.
assert "call mixed_code(" in gen
assert "interface mixed_code" in gen
assert "subroutine mixed_code_64(" in gen
assert "subroutine mixed_code_32(" in gen

Expand Down

0 comments on commit 2b82201

Please sign in to comment.