Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2451 DynInvokeSchedule split & rename #2452

Merged
merged 24 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9c0591f
#2451 Renamed to LFRicInvokeSchedule
oakleybrunt Jan 3, 2024
3384a80
#2451 Moved LFRicInvokeSchedule to lfric domain
oakleybrunt Jan 3, 2024
ca9fc7e
#2451 Updated docstring
oakleybrunt Jan 8, 2024
16c1f7a
Merge branch 'master' into 2451_split_rename_DynInvokeSchedule
oakleybrunt Jan 8, 2024
e0f5c80
Issue #2451 Merge branch 'master' into 2451_split_rename_DynInvokeSch…
oakleybrunt Jan 24, 2024
cc37325
Merge branch 'master' into 2451_split_rename_DynInvokeSchedule
oakleybrunt Jan 24, 2024
6e241c3
Merge branch 'master' into 2451_split_rename_DynInvokeSchedule
oakleybrunt Feb 15, 2024
83c1c2b
#2451 replaced accidentally deleted 's' from LFRicStencils
oakleybrunt Feb 15, 2024
4164336
Merge branch 'master' into 2451_split_rename_DynInvokeSchedule
oakleybrunt Mar 1, 2024
cb73756
Merge branch 'master' into 2451_split_rename_DynInvokeSchedule
oakleybrunt Mar 27, 2024
4b47ec1
Merge branch 'master' into 2451_split_rename_DynInvokeSchedule
oakleybrunt May 9, 2024
1ed5c4c
#2451 Fixed linting notes
oakleybrunt May 10, 2024
a7a8a0d
Merge branch '2451_split_rename_DynInvokeSchedule' of github.com:stfc…
oakleybrunt May 10, 2024
071bd1b
Merge branch 'master' into 2451_split_rename_DynInvokeSchedule
oakleybrunt May 10, 2024
e83df85
Merge branch 'master' into 2451_split_rename_DynInvokeSchedule
arporter May 13, 2024
cfecd68
Merge branch 'master' into 2451_split_rename_DynInvokeSchedule
oakleybrunt May 13, 2024
91d945a
#2451 tests for node_str
oakleybrunt May 14, 2024
2e3d336
Merge branch '2451_split_rename_DynInvokeSchedule' of github.com:stfc…
oakleybrunt May 14, 2024
acfcf63
Merge branch 'master' into 2451_split_rename_DynInvokeSchedule
oakleybrunt May 14, 2024
cd6e779
#1351 lint fix
oakleybrunt May 14, 2024
04ad525
Merge branch '2451_split_rename_DynInvokeSchedule' of github.com:stfc…
oakleybrunt May 14, 2024
9362dbe
Merge branch 'master' into 2451_split_rename_DynInvokeSchedule
oakleybrunt May 15, 2024
2a811ae
Merge branch 'master' into 2451_split_rename_DynInvokeSchedule
arporter May 16, 2024
bf9d495
#2452 update changelog and UG
arporter May 16, 2024
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
2 changes: 1 addition & 1 deletion doc/user_guide/dynamo0p3_topclasses.dot
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down
2 changes: 1 addition & 1 deletion doc/user_guide/dynamo0p3_topclasses.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/psyclone/domain/lfric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -90,6 +91,7 @@
'LFRicFields',
'LFRicInvoke',
'LFRicInvokes',
'LFRicInvokeSchedule',
'LFRicKern',
'LFRicKernCallFactory',
'LFRicKernMetadata',
Expand Down
2 changes: 1 addition & 1 deletion src/psyclone/domain/lfric/lfric_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/psyclone/domain/lfric/lfric_invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
91 changes: 91 additions & 0 deletions src/psyclone/domain/lfric/lfric_invoke_schedule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# -----------------------------------------------------------------------------
# BSD 3-Clause License
#
# Copyright (c) 2017-2023, Science and Technology Facilities Council.
arporter marked this conversation as resolved.
Show resolved Hide resolved
# 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 \
arporter marked this conversation as resolved.
Show resolved Hide resolved
new InvokeSchedule SymbolTable.
:type reserved_names: list of str
arporter marked this conversation as resolved.
Show resolved Hide resolved
: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 +
arporter marked this conversation as resolved.
Show resolved Hide resolved
"', 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']
2 changes: 1 addition & 1 deletion src/psyclone/domain/lfric/lfric_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
49 changes: 5 additions & 44 deletions src/psyclone/dynamo0p3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -2635,7 +2632,7 @@ class DynBasisFunctions(LFRicCollection):
: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 \
arporter marked this conversation as resolved.
Show resolved Hide resolved
:py:class:`psyclone.domain.lfric.LFRicKern`

:raises InternalError: if a call has an unrecognised evaluator shape.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -6260,7 +6222,6 @@ def data_on_device(self, _):
'DynInterGrid',
'DynBasisFunctions',
'DynBoundaryConditions',
'DynInvokeSchedule',
'DynGlobalSum',
'LFRicHaloExchange',
'LFRicHaloExchangeStart',
Expand Down
4 changes: 2 additions & 2 deletions src/psyclone/psyir/nodes/acc_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@
# -----------------------------------------------------------------------------
# Author: A. R. Porter, STFC Daresbury Lab

''' This module contains pytest tests for the DynInvokeSchedule class. '''
''' This module contains pytest tests for the LFRicInvokeSchedule class. '''

import os
from psyclone.domain.lfric import LFRicSymbolTable
from psyclone.dynamo0p3 import DynInvokeSchedule
from psyclone.domain.lfric import LFRicSymbolTable, LFRicInvokeSchedule
from psyclone.parse.algorithm import parse
from psyclone.psyir.nodes import Container

Expand All @@ -49,15 +48,15 @@


def test_dyninvsched_parent():
''' Check the setting of the parent of a DynInvokeSchedule. '''
''' 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 = DynInvokeSchedule("my_sched", kcalls)
dsched = LFRicInvokeSchedule("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)
dsched2 = LFRicInvokeSchedule("my_sched", kcalls, parent=fake_parent)
assert dsched2.parent is fake_parent
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down Expand Up @@ -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):
Expand All @@ -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))


Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
Loading
Loading