diff --git a/changelog b/changelog index 681db929ee..3279d980b7 100644 --- a/changelog +++ b/changelog @@ -88,6 +88,9 @@ 32) PR #2590 fpr #2589. Moves to the latest LFRic (split repo) and fixes the LFRic integration tests. + 33) PR #2452 for #2451. Move and rename DynInvokeSchedule to + LFRicInvokeSchedule. + release 2.5.0 14th of February 2024 1) PR #2199 for #2189. Fix bugs with missing maps in enter data diff --git a/doc/user_guide/dynamo0p3_topclasses.dot b/doc/user_guide/dynamo0p3_topclasses.dot index 67700919c4..9d7c5057d5 100644 --- a/doc/user_guide/dynamo0p3_topclasses.dot +++ b/doc/user_guide/dynamo0p3_topclasses.dot @@ -3,7 +3,7 @@ charset="utf-8" rankdir=BT "20" [label="{LFRicInvoke|\l|arg_for_funcspace()\lfield_on_space()\lgen_code()\lis_coloured()\lunique_fss()\lunique_proxy_declarations()\l}", shape="record"]; -"21" [label="{DynInvokeSchedule|\l|view()\l}", shape="record"]; +"21" [label="{LFRicInvokeSchedule|\l|view()\l}", shape="record"]; "35" [label="{DynamoInvokes|\l|}", shape="record"]; "36" [label="{DynamoPSy|\l|}", shape="record"]; "45" [label="{Invoke|\l|first_access()\lgen()\lgen_code()\lunique_declarations()\lunique_declns_by_intent()\l}", shape="record", style=filled, fillcolor="antiquewhite"]; diff --git a/doc/user_guide/dynamo0p3_topclasses.svg b/doc/user_guide/dynamo0p3_topclasses.svg index dfa07f7cbe..5dbc989db4 100644 --- a/doc/user_guide/dynamo0p3_topclasses.svg +++ b/doc/user_guide/dynamo0p3_topclasses.svg @@ -62,7 +62,7 @@ 21 -DynInvokeSchedule +LFRicInvokeSchedule view() diff --git a/psyclone.pdf b/psyclone.pdf index c57270ff02..b653e370ba 100644 Binary files a/psyclone.pdf and b/psyclone.pdf differ diff --git a/src/psyclone/domain/lfric/__init__.py b/src/psyclone/domain/lfric/__init__.py index 1a3fe3220f..bdea534228 100644 --- a/src/psyclone/domain/lfric/__init__.py +++ b/src/psyclone/domain/lfric/__init__.py @@ -71,6 +71,7 @@ from psyclone.domain.lfric.lfric_scalar_args import LFRicScalarArgs from psyclone.domain.lfric.lfric_loop_bounds import LFRicLoopBounds from psyclone.domain.lfric.lfric_kern_metadata import LFRicKernMetadata +from psyclone.domain.lfric.lfric_invoke_schedule import LFRicInvokeSchedule from psyclone.domain.lfric.lfric_dofmaps import LFRicDofmaps from psyclone.domain.lfric.lfric_stencils import LFRicStencils @@ -90,6 +91,7 @@ 'LFRicFields', 'LFRicInvoke', 'LFRicInvokes', + 'LFRicInvokeSchedule', 'LFRicKern', 'LFRicKernCallFactory', 'LFRicKernMetadata', diff --git a/src/psyclone/domain/lfric/lfric_builtins.py b/src/psyclone/domain/lfric/lfric_builtins.py index d8ce2c068b..d43643c2c4 100644 --- a/src/psyclone/domain/lfric/lfric_builtins.py +++ b/src/psyclone/domain/lfric/lfric_builtins.py @@ -107,7 +107,7 @@ def create(call, parent=None): :type call: :py:class:`psyclone.parse.algorithm.BuiltInCall` :param parent: the schedule instance to which the built-in call \ belongs. - :type parent: :py:class:`psyclone.dynamo0p3.DynInvokeSchedule` + :type parent: :py:class:`psyclone.domain.lfric.LFRicInvokeSchedule` :raises ParseError: if the name of the function being called is \ not a recognised built-in. diff --git a/src/psyclone/domain/lfric/lfric_invoke.py b/src/psyclone/domain/lfric/lfric_invoke.py index 6fe8ded05d..fde9a512f0 100644 --- a/src/psyclone/domain/lfric/lfric_invoke.py +++ b/src/psyclone/domain/lfric/lfric_invoke.py @@ -76,14 +76,14 @@ def __init__(self, alg_invocation, idx, invokes): return # Import here to avoid circular dependency # pylint: disable=import-outside-toplevel - from psyclone.dynamo0p3 import DynInvokeSchedule - self._schedule = DynInvokeSchedule('name', None) # for pyreverse + from psyclone.domain.lfric import LFRicInvokeSchedule + self._schedule = LFRicInvokeSchedule('name', None) # for pyreverse reserved_names_list = [] const = LFRicConstants() reserved_names_list.extend(const.STENCIL_MAPPING.values()) reserved_names_list.extend(["omp_get_thread_num", "omp_get_max_threads"]) - Invoke.__init__(self, alg_invocation, idx, DynInvokeSchedule, + Invoke.__init__(self, alg_invocation, idx, LFRicInvokeSchedule, invokes, reserved_names=reserved_names_list) # The base class works out the algorithm code's unique argument diff --git a/src/psyclone/domain/lfric/lfric_invoke_schedule.py b/src/psyclone/domain/lfric/lfric_invoke_schedule.py new file mode 100644 index 0000000000..34db34e0d8 --- /dev/null +++ b/src/psyclone/domain/lfric/lfric_invoke_schedule.py @@ -0,0 +1,91 @@ +# ----------------------------------------------------------------------------- +# BSD 3-Clause License +# +# Copyright (c) 2017-2024, Science and Technology Facilities Council. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# ----------------------------------------------------------------------------- +# Authors R. W. Ford, A. R. Porter and S. Siso, STFC Daresbury Lab +# Modified I. Kavcic, A. Coughtrie, L. Turner and O. Brunt, Met Office +# Modified J. Henrichs, Bureau of Meteorology +# Modified A. B. G. Chalk and N. Nobre, STFC Daresbury Lab + +''' This module contains the LFRic-specific InvokeSchedule sub-class which +inherits from the InvokeSchedule class. LFRicInvokeSchedule takes an +Invoke name and a list of parsed KernelCalls as required parameters +which it passes to the base class to create a new SymbolTable for +the new InvokeSchedule. + +''' + +from psyclone.configuration import Config +from psyclone.domain.lfric.lfric_builtins import LFRicBuiltInCallFactory +from psyclone.domain.lfric import LFRicSymbolTable, LFRicKernCallFactory +from psyclone.psyGen import InvokeSchedule + + +class LFRicInvokeSchedule(InvokeSchedule): + ''' The LFRic-specific InvokeSchedule sub-class. This passes the LFRic- + specific factories for creating kernel and infrastructure calls + to the base class so it creates the ones we require. + + :param str name: name of the Invoke. + :param arg: list of KernelCalls parsed from the algorithm layer. + :type arg: list of :py:class:`psyclone.parse.algorithm.KernelCall` + :param reserved_names: optional list of names that are not allowed in the + new InvokeSchedule SymbolTable. + :type reserved_names: list[str] + :param parent: the parent of this node in the PSyIR. + :type parent: :py:class:`psyclone.psyir.nodes.Node` + + ''' + + def __init__(self, name, arg, reserved_names=None, parent=None): + super().__init__(name, LFRicKernCallFactory, + LFRicBuiltInCallFactory, arg, reserved_names, + parent=parent, symbol_table=LFRicSymbolTable()) + + def node_str(self, colour=True): + ''' Creates a text summary of this node. + + :param bool colour: whether or not to include control codes for colour. + + :returns: text summary of this node, optionally with control codes + for colour highlighting. + :rtype: str + + ''' + return (self.coloured_name(colour) + "[invoke='" + self.invoke.name + + "', dm=" + str(Config.get().distributed_memory)+"]") + + +# ---------- Documentation utils -------------------------------------------- # +# The list of module members that we wish AutoAPI to generate +# documentation for. (See https://psyclone-ref.readthedocs.io) +__all__ = ['LFRicInvokeSchedule'] diff --git a/src/psyclone/domain/lfric/lfric_loop.py b/src/psyclone/domain/lfric/lfric_loop.py index 9ce4fb57a3..7150737ff4 100644 --- a/src/psyclone/domain/lfric/lfric_loop.py +++ b/src/psyclone/domain/lfric/lfric_loop.py @@ -804,7 +804,7 @@ def stop_expr(self): if self.upper_bound_name in const.HALO_ACCESS_LOOP_BOUNDS: if self._upper_bound_halo_depth: # TODO: #696 Add kind (precision) once the - # DynInvokeSchedule constructor has been extended to + # LFRicInvokeSchedule constructor has been extended to # create the necessary symbols. halo_depth = Literal(str(self._upper_bound_halo_depth), INTEGER_TYPE) diff --git a/src/psyclone/dynamo0p3.py b/src/psyclone/dynamo0p3.py index c20834611a..f291b0d0c2 100644 --- a/src/psyclone/dynamo0p3.py +++ b/src/psyclone/dynamo0p3.py @@ -52,14 +52,11 @@ from psyclone import psyGen from psyclone.configuration import Config from psyclone.core import AccessType, Signature -from psyclone.domain.lfric.lfric_builtins import (LFRicBuiltInCallFactory, - LFRicBuiltIn) +from psyclone.domain.lfric.lfric_builtins import LFRicBuiltIn from psyclone.domain.lfric import (FunctionSpace, KernCallAccArgList, - KernCallArgList, - LFRicCollection, LFRicConstants, - LFRicSymbolTable, LFRicKernCallFactory, - LFRicKern, LFRicInvokes, LFRicTypes, - LFRicLoop) + KernCallArgList, LFRicCollection, + LFRicConstants, LFRicSymbolTable, LFRicKern, + LFRicInvokes, LFRicTypes, LFRicLoop) from psyclone.errors import GenerationError, InternalError, FieldNotFoundError from psyclone.f2pygen import (AllocateGen, AssignGen, CallGen, CommentGen, DeallocateGen, DeclGen, DoGen, @@ -2632,10 +2629,10 @@ class DynBasisFunctions(LFRicCollection): functions required by an invoke or kernel call. This covers both those required for quadrature and for evaluators. - :param node: either the schedule of an Invoke or a single Kernel object \ - for which to extract information on all required \ + :param node: either the schedule of an Invoke or a single Kernel object + for which to extract information on all required basis/diff-basis functions. - :type node: :py:class:`psyclone.dynamo0p3.DynInvokeSchedule` or \ + :type node: :py:class:`psyclone.domain.lfric.LFRicInvokeSchedule` or :py:class:`psyclone.domain.lfric.LFRicKern` :raises InternalError: if a call has an unrecognised evaluator shape. @@ -3632,41 +3629,6 @@ def initialise(self, parent): "get_boundary_dofs()"]))) -class DynInvokeSchedule(InvokeSchedule): - ''' The Dynamo specific InvokeSchedule sub-class. This passes the Dynamo- - specific factories for creating kernel and infrastructure calls - to the base class so it creates the ones we require. - - :param str name: name of the Invoke. - :param arg: list of KernelCalls parsed from the algorithm layer. - :type arg: list of :py:class:`psyclone.parse.algorithm.KernelCall` - :param reserved_names: optional list of names that are not allowed in the \ - new InvokeSchedule SymbolTable. - :type reserved_names: list of str - :param parent: the parent of this node in the PSyIR. - :type parent: :py:class:`psyclone.psyir.nodes.Node` - - ''' - - def __init__(self, name, arg, reserved_names=None, parent=None): - super().__init__(name, LFRicKernCallFactory, - LFRicBuiltInCallFactory, arg, reserved_names, - parent=parent, symbol_table=LFRicSymbolTable()) - - def node_str(self, colour=True): - ''' Creates a text summary of this node. - - :param bool colour: whether or not to include control codes for colour. - - :returns: text summary of this node, optionally with control codes \ - for colour highlighting. - :rtype: str - - ''' - return (self.coloured_name(colour) + "[invoke='" + self.invoke.name + - "', dm=" + str(Config.get().distributed_memory)+"]") - - class DynGlobalSum(GlobalSum): ''' Dynamo specific global sum class which can be added to and @@ -6260,7 +6222,6 @@ def data_on_device(self, _): 'DynInterGrid', 'DynBasisFunctions', 'DynBoundaryConditions', - 'DynInvokeSchedule', 'DynGlobalSum', 'LFRicHaloExchange', 'LFRicHaloExchangeStart', diff --git a/src/psyclone/psyir/nodes/acc_directives.py b/src/psyclone/psyir/nodes/acc_directives.py index 8e30ae1596..0271564d81 100644 --- a/src/psyclone/psyir/nodes/acc_directives.py +++ b/src/psyclone/psyir/nodes/acc_directives.py @@ -121,11 +121,11 @@ def signatures(self): ''' # pylint: disable=import-outside-toplevel - from psyclone.dynamo0p3 import DynInvokeSchedule + from psyclone.domain.lfric import LFRicInvokeSchedule from psyclone.gocean1p0 import GOInvokeSchedule from psyclone.psyir.tools.call_tree_utils import CallTreeUtils - if self.ancestor((DynInvokeSchedule, GOInvokeSchedule)): + if self.ancestor((LFRicInvokeSchedule, GOInvokeSchedule)): # Look-up the kernels that are children of this node sig_set = set() for call in self.kernels(): diff --git a/src/psyclone/tests/domain/lfric/dyn_invoke_schedule_test.py b/src/psyclone/tests/domain/lfric/dyn_invoke_schedule_test.py deleted file mode 100644 index f957851b70..0000000000 --- a/src/psyclone/tests/domain/lfric/dyn_invoke_schedule_test.py +++ /dev/null @@ -1,63 +0,0 @@ -# ----------------------------------------------------------------------------- -# BSD 3-Clause License -# -# Copyright (c) 2021-2024, Science and Technology Facilities Council. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# * Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# ----------------------------------------------------------------------------- -# Author: A. R. Porter, STFC Daresbury Lab - -''' This module contains pytest tests for the DynInvokeSchedule class. ''' - -import os -from psyclone.domain.lfric import LFRicSymbolTable -from psyclone.dynamo0p3 import DynInvokeSchedule -from psyclone.parse.algorithm import parse -from psyclone.psyir.nodes import Container - - -BASE_PATH = os.path.join( - os.path.dirname(os.path.dirname(os.path.dirname( - os.path.abspath(__file__)))), "test_files", "dynamo0p3") -TEST_API = "dynamo0.3" - - -def test_dyninvsched_parent(): - ''' Check the setting of the parent of a DynInvokeSchedule. ''' - _, invoke_info = parse(os.path.join(BASE_PATH, - "1.0.1_single_named_invoke.f90"), - api=TEST_API) - kcalls = invoke_info.calls[0].kcalls - # With no parent specified - dsched = DynInvokeSchedule("my_sched", kcalls) - assert dsched.parent is None - # With a parent - fake_parent = Container("my_mod", symbol_table=LFRicSymbolTable()) - dsched2 = DynInvokeSchedule("my_sched", kcalls, parent=fake_parent) - assert dsched2.parent is fake_parent diff --git a/src/psyclone/tests/domain/lfric/lfric_invoke_schedule_test.py b/src/psyclone/tests/domain/lfric/lfric_invoke_schedule_test.py new file mode 100644 index 0000000000..d2c4dafab7 --- /dev/null +++ b/src/psyclone/tests/domain/lfric/lfric_invoke_schedule_test.py @@ -0,0 +1,118 @@ +# ----------------------------------------------------------------------------- +# BSD 3-Clause License +# +# Copyright (c) 2021-2024, Science and Technology Facilities Council. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# ----------------------------------------------------------------------------- +# Author: A. R. Porter, STFC Daresbury Lab + +''' This module contains pytest tests for the LFRicInvokeSchedule class. ''' + +import os +from psyclone.domain.lfric import LFRicSymbolTable, LFRicInvokeSchedule +from psyclone.parse.algorithm import parse +from psyclone.psyir.nodes import Container, colored +from psyclone.psyGen import PSyFactory + + +BASE_PATH = os.path.join( + os.path.dirname(os.path.dirname(os.path.dirname( + os.path.abspath(__file__)))), "test_files", "dynamo0p3") +TEST_API = "dynamo0.3" + + +def test_lfricinvsched_parent(): + ''' Check the setting of the parent of a LFRicInvokeSchedule. ''' + _, invoke_info = parse(os.path.join(BASE_PATH, + "1.0.1_single_named_invoke.f90"), + api=TEST_API) + kcalls = invoke_info.calls[0].kcalls + # With no parent specified + dsched = LFRicInvokeSchedule("my_sched", kcalls) + assert dsched.parent is None + # With a parent + fake_parent = Container("my_mod", symbol_table=LFRicSymbolTable()) + dsched2 = LFRicInvokeSchedule("my_sched", kcalls, parent=fake_parent) + assert dsched2.parent is fake_parent + + +def test_lfricinvsched_node_str_coloured(): + ''' + Check the node_str method of the LFRicInvokeSchedule class. We need an + Invoke object for this which we get using the dynamo0.3 API. + + This test checks that `dm` is printed equal to `True` when dist_mem is + `True` in the config and that `InvokeSchedule` is coloured when requested + by the `node_str` method. + + ''' + _, invoke_info = parse(os.path.join(BASE_PATH, + "1.0.1_single_named_invoke.f90"), + api="dynamo0.3") + + # distributed_memory set to True + psy = PSyFactory("dynamo0.3", distributed_memory=True).create(invoke_info) + # Create a plain LFRicInvokeSchedule + sched = LFRicInvokeSchedule('name', None, None) + # Manually supply it with an Invoke object created with the LFRic API. + sched.invoke = psy.invokes.invoke_list[0] + output = sched.node_str() + + assert colored("InvokeSchedule", LFRicInvokeSchedule._colour) in output + assert str("[invoke='" + sched.invoke.name + "', dm=True]") in output + + +def test_lfricinvsched_node_str_colourless(): + ''' + Check the node_str method of the LFRicInvokeSchedule class. We need an + Invoke object for this which we get using the dynamo0.3 API. + + This test checks that `dm` is printed equal to `False` when dist_mem is + `False` in the config and that `InvokeSchedule` is uncoloured when + requested by the `node_str` method. + + ''' + _, invoke_info = parse(os.path.join(BASE_PATH, + "1.0.1_single_named_invoke.f90"), + api="dynamo0.3") + psy = PSyFactory("dynamo0.3", distributed_memory=False).create(invoke_info) + # Create a plain LFRicInvokeSchedule + sched = LFRicInvokeSchedule('name', None, None) + # Manually supply it with an Invoke object created with the LFRic API. + sched.invoke = psy.invokes.invoke_list[0] + + # colour set to False + output = sched.node_str(colour=False) + + # expected output + expected = str("InvokeSchedule[invoke='" + sched.invoke.name + + "', dm=False]") + + assert expected in output diff --git a/src/psyclone/tests/domain/lfric/transformations/dynamo0p3_transformations_test.py b/src/psyclone/tests/domain/lfric/transformations/dynamo0p3_transformations_test.py index c455874ee0..1d3f77442b 100644 --- a/src/psyclone/tests/domain/lfric/transformations/dynamo0p3_transformations_test.py +++ b/src/psyclone/tests/domain/lfric/transformations/dynamo0p3_transformations_test.py @@ -459,7 +459,7 @@ def test_colouring_not_a_loop(dist_mem): with pytest.raises(TransformationError) as excinfo: ctrans.apply(schedule) assert ("Target of Dynamo0p3ColourTrans transformation must be a " - "sub-class of Loop but got 'DynInvokeSchedule'" in + "sub-class of Loop but got 'LFRicInvokeSchedule'" in str(excinfo.value)) @@ -501,7 +501,8 @@ def test_omp_not_a_loop(dist_mem): otrans.apply(schedule) assert ("Target of Dynamo0p3OMPLoopTrans transformation must be a sub-" - "class of Loop but got 'DynInvokeSchedule'" in str(excinfo.value)) + "class of Loop but got 'LFRicInvokeSchedule'" in + str(excinfo.value)) def test_omp_parallel_not_a_loop(dist_mem): @@ -518,7 +519,7 @@ def test_omp_parallel_not_a_loop(dist_mem): with pytest.raises(TransformationError) as excinfo: otrans.apply(schedule) assert ("Error in DynamoOMPParallelLoopTrans transformation. The " - "supplied node must be a LFRicLoop but got 'DynInvokeSchedule'" + "supplied node must be a LFRicLoop but got 'LFRicInvokeSchedule'" in str(excinfo.value)) @@ -5452,7 +5453,7 @@ def test_rc_wrong_parent(monkeypatch): # Apply redundant computation to the loop with pytest.raises(TransformationError) as excinfo: rc_trans.apply(schedule.children[4], {"depth": 1}) - assert ("the parent of the supplied loop must be the DynInvokeSchedule, " + assert ("the parent of the supplied loop must be the LFRicInvokeSchedule, " "or a Loop") in str(excinfo.value) @@ -5492,7 +5493,7 @@ def test_rc_parent_loop_colour(monkeypatch): with pytest.raises(TransformationError) as excinfo: rc_trans.apply(schedule.children[4].loop_body[0], {"depth": 1}) assert ("if the parent of the supplied Loop is also a Loop then the " - "parent's parent must be the DynInvokeSchedule" + "parent's parent must be the LFRicInvokeSchedule" in str(excinfo.value)) # Make the outermost loop iterate over cells (it should be diff --git a/src/psyclone/tests/domain/lfric/transformations/lfric_haloex_test.py b/src/psyclone/tests/domain/lfric/transformations/lfric_haloex_test.py index 67723dbb63..ed659e0e45 100644 --- a/src/psyclone/tests/domain/lfric/transformations/lfric_haloex_test.py +++ b/src/psyclone/tests/domain/lfric/transformations/lfric_haloex_test.py @@ -93,7 +93,7 @@ def check_schedule(schedule): write-to-gh_inc dependence. :param schedule: a dynamo0.3 API schedule object - :type schedule: :py:class:`psyclone.dynamo0p3.DynInvokeSchedule`. + :type schedule: :py:class:`psyclone.domain.lfric.LFRicInvokeSchedule`. ''' assert len(schedule.children) == 3 @@ -250,7 +250,7 @@ def check(schedule, f1depth, f2depth): field 'f1' is what we are expecting :param schedule: a dynamo0.3 API schedule object - :type schedule: :py:class:`psyclone.dynamo0p3.DynInvokeSchedule`. + :type schedule: :py:class:`psyclone.domain.lfric.LFRicInvokeSchedule`. :param int f1depth: The expected depth of the halo exchange \ associated with field f1 :param int f2depth: The expected depth of the halo exchange \ @@ -316,7 +316,7 @@ def check(schedule, f1depth, f2depth): field 'f1' is what we are expecting :param schedule: a dynamo0.3 API schedule object - :type schedule: :py:class:`psyclone.dynamo0p3.DynInvokeSchedule`. + :type schedule: :py:class:`psyclone.domain.lfric.LFRicInvokeSchedule`. :param int f1depth: The expected depth of the halo exchange \ associated with field f1 :param int f2depth: The expected depth of the halo exchange \ diff --git a/src/psyclone/tests/psyGen_test.py b/src/psyclone/tests/psyGen_test.py index e423601869..b99147749a 100644 --- a/src/psyclone/tests/psyGen_test.py +++ b/src/psyclone/tests/psyGen_test.py @@ -52,10 +52,10 @@ from psyclone.configuration import Config from psyclone.core.access_type import AccessType from psyclone.domain.common.psylayer import PSyLoop -from psyclone.domain.lfric import lfric_builtins, LFRicKern, LFRicKernMetadata +from psyclone.domain.lfric import (lfric_builtins, LFRicInvokeSchedule, + LFRicKern, LFRicKernMetadata) from psyclone.domain.lfric.transformations import LFRicLoopFuseTrans -from psyclone.dynamo0p3 import (DynInvokeSchedule, DynGlobalSum, - DynKernelArguments) +from psyclone.dynamo0p3 import DynGlobalSum, DynKernelArguments from psyclone.errors import FieldNotFoundError, GenerationError, InternalError from psyclone.generator import generate from psyclone.gocean1p0 import GOKern @@ -295,12 +295,12 @@ def test_invokes_can_always_be_printed(): assert inv.__str__() == "invoke()" invoke_call = InvokeCall([], "TestName") - inv = Invoke(invoke_call, 12, DynInvokeSchedule, None) + inv = Invoke(invoke_call, 12, LFRicInvokeSchedule, None) # Name is converted to lower case if set in constructor of InvokeCall: assert inv.__str__() == "invoke_testname()" invoke_call._name = None - inv = Invoke(invoke_call, 12, DynInvokeSchedule, None) + inv = Invoke(invoke_call, 12, LFRicInvokeSchedule, None) assert inv.__str__() == "invoke_12()" # Last test case: one kernel call - to avoid constructing @@ -311,7 +311,7 @@ def test_invokes_can_always_be_printed(): api="dynamo0.3") alg_invocation = invoke.calls[0] - inv = Invoke(alg_invocation, 0, DynInvokeSchedule, None) + inv = Invoke(alg_invocation, 0, LFRicInvokeSchedule, None) assert inv.__str__() == \ "invoke_0_testkern_type(a, f1_my_field, f1 % my_field, m1, m2)" @@ -323,7 +323,7 @@ def test_invoke_container(): api="dynamo0.3") alg_invocation = invoke.calls[0] # An isolated Invoke object has no associated Container - inv = Invoke(alg_invocation, 0, DynInvokeSchedule, None) + inv = Invoke(alg_invocation, 0, LFRicInvokeSchedule, None) assert inv._schedule.parent is None # Creating an Invokes object requires a PSy object but the construction of # the latter also creates the former. Therefore, we just create a PSy diff --git a/src/psyclone/tests/psyir/tools/call_tree_utils_test.py b/src/psyclone/tests/psyir/tools/call_tree_utils_test.py index ee47d69072..b13f7d7b75 100644 --- a/src/psyclone/tests/psyir/tools/call_tree_utils_test.py +++ b/src/psyclone/tests/psyir/tools/call_tree_utils_test.py @@ -143,7 +143,7 @@ def test_call_tree_compute_all_non_locals_kernel(): mod_psyir, _ = get_invoke(test_file, "dynamo0.3", 0, dist_mem=False) psyir = mod_psyir.invokes.invoke_list[0].schedule - # This will return three schedule - the DynInvokeSchedule, and two + # This will return three schedule - the LFRicInvokeSchedule, and two # schedules for the kernel and builtin. Just make sure we have # the right parts before doing the actual test: schedules = psyir.walk(Schedule) diff --git a/src/psyclone/transformations.py b/src/psyclone/transformations.py index fbab93ad73..4a534f5044 100644 --- a/src/psyclone/transformations.py +++ b/src/psyclone/transformations.py @@ -48,10 +48,9 @@ from psyclone import psyGen from psyclone.configuration import Config from psyclone.core import Signature, VariablesAccessInfo -from psyclone.domain.lfric import (KernCallArgList, LFRicConstants, LFRicKern, - LFRicLoop) -from psyclone.dynamo0p3 import (LFRicHaloExchangeEnd, LFRicHaloExchangeStart, - DynInvokeSchedule) +from psyclone.domain.lfric import (KernCallArgList, LFRicConstants, + LFRicInvokeSchedule, LFRicKern, LFRicLoop) +from psyclone.dynamo0p3 import LFRicHaloExchangeEnd, LFRicHaloExchangeStart from psyclone.errors import InternalError from psyclone.gocean1p0 import GOInvokeSchedule from psyclone.nemo import NemoInvokeSchedule @@ -1806,7 +1805,7 @@ def validate(self, node, options=None): :py:class:`psyclone.psyir.nodes.Directive`. :raises TransformationError: if the parent of the loop is not a\ :py:class:`psyclone.psyir.nodes.Loop` or a\ - :py:class:`psyclone.psyGen.DynInvokeSchedule`. + :py:class:`psyclone.psyGen.LFRicInvokeSchedule`. :raises TransformationError: if the parent of the loop is a\ :py:class:`psyclone.psyir.nodes.Loop` but the original loop does\ not iterate over 'colour'. @@ -1815,7 +1814,7 @@ def validate(self, node, options=None): iterate over 'colours'. :raises TransformationError: if the parent of the loop is a\ :py:class:`psyclone.psyir.nodes.Loop` but the parent's parent is\ - not a :py:class:`psyclone.psyGen.DynInvokeSchedule`. + not a :py:class:`psyclone.psyGen.LFRicInvokeSchedule`. :raises TransformationError: if this transformation is applied\ when distributed memory is not switched on. :raises TransformationError: if the loop does not iterate over\ @@ -1860,12 +1859,13 @@ def validate(self, node, options=None): f"method the supplied loop is sits beneath a directive of " f"type {type(dir_node)}. Redundant computation must be applied" f" before directives are added.") - if not (isinstance(node.parent, DynInvokeSchedule) or + if not (isinstance(node.parent, LFRicInvokeSchedule) or isinstance(node.parent.parent, Loop)): raise TransformationError( f"In the Dynamo0p3RedundantComputation transformation " f"apply method the parent of the supplied loop must be the " - f"DynInvokeSchedule, or a Loop, but found {type(node.parent)}") + f"LFRicInvokeSchedule, or a Loop, but found " + f"{type(node.parent)}") if isinstance(node.parent.parent, Loop): if node.loop_type != "colour": raise TransformationError( @@ -1879,12 +1879,12 @@ def validate(self, node, options=None): f"apply method, if the parent of the supplied Loop is " f"also a Loop then the parent must iterate over " f"'colours', but found '{node.parent.parent.loop_type}'") - if not isinstance(node.parent.parent.parent, DynInvokeSchedule): + if not isinstance(node.parent.parent.parent, LFRicInvokeSchedule): raise TransformationError( f"In the Dynamo0p3RedundantComputation transformation " f"apply method, if the parent of the supplied Loop is " f"also a Loop then the parent's parent must be the " - f"DynInvokeSchedule, but found {type(node.parent)}") + f"LFRicInvokeSchedule, but found {type(node.parent)}") if not Config.get().distributed_memory: raise TransformationError( "In the Dynamo0p3RedundantComputation transformation apply " @@ -2449,7 +2449,7 @@ def apply(self, sched, options=None): self.validate(sched, options) # pylint: disable=import-outside-toplevel - if isinstance(sched, DynInvokeSchedule): + if isinstance(sched, LFRicInvokeSchedule): from psyclone.dynamo0p3 import DynACCEnterDataDirective as \ AccEnterDataDir elif isinstance(sched, GOInvokeSchedule): @@ -2686,7 +2686,8 @@ def validate(self, nodes, options): node_list = self.get_node_list(nodes) # Check that the front-end is valid - sched = node_list[0].ancestor((NemoInvokeSchedule, DynInvokeSchedule)) + sched = node_list[0].ancestor((NemoInvokeSchedule, + LFRicInvokeSchedule)) if not sched: raise NotImplementedError( "OpenACC kernels regions are currently only supported for the "