From 84ab5c350102dfa5a31a00c9c371035a6acfcdef Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Mon, 26 Jun 2023 11:20:46 +0100 Subject: [PATCH 01/15] #2189 add initial, failing test showing bug --- .../tests/dynamo0p3_multigrid_test.py | 50 +++++++++++++++---- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/src/psyclone/tests/dynamo0p3_multigrid_test.py b/src/psyclone/tests/dynamo0p3_multigrid_test.py index 89de91e031..9c54833f4b 100644 --- a/src/psyclone/tests/dynamo0p3_multigrid_test.py +++ b/src/psyclone/tests/dynamo0p3_multigrid_test.py @@ -1,7 +1,7 @@ # ----------------------------------------------------------------------------- # BSD 3-Clause License # -# Copyright (c) 2017-2022, Science and Technology Facilities Council +# Copyright (c) 2017-2023, Science and Technology Facilities Council # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -35,14 +35,9 @@ # Modified I. Kavcic, Met Office # Modified by J. Henrichs, Bureau of Meteorology -''' This module contains tests for the multi-grid part of the Dynamo 0.3 API +''' This module contains tests for the multi-grid part of the LFRic API using pytest. ''' -from __future__ import absolute_import, print_function -# Since this is a file containing tests which often have to get in and -# change the internal state of objects we disable pylint's warning -# about such accesses - import os import pytest import fparser @@ -56,11 +51,12 @@ from psyclone.parse.algorithm import parse from psyclone.parse.utils import ParseError from psyclone.psyGen import PSyFactory -from psyclone.psyir.nodes import Node +from psyclone.psyir.nodes import Node, Loop from psyclone.psyir.symbols import Symbol from psyclone.tests.lfric_build import LFRicBuild -from psyclone.transformations import check_intergrid, Dynamo0p3ColourTrans, \ - DynamoOMPParallelLoopTrans, TransformationError +from psyclone.transformations import ( + ACCEnterDataTrans, ACCKernelsTrans, check_intergrid, Dynamo0p3ColourTrans, + DynamoOMPParallelLoopTrans, TransformationError) # constants BASE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), @@ -832,3 +828,37 @@ def test_restrict_prolong_chain_anyd(tmpdir): ctrans.apply(schedule.children[1]) assert ("Loops iterating over a discontinuous function space " "are not currently supported." in str(excinfo.value)) + + +def test_restrict_prolong_chain_acc(tmpdir): + ''' Test that we generate correct OpenACC code for an invoke containing + a chain of discontinuous restrictions and continuous prolongations. + + ''' + _, invoke_info = parse(os.path.join(BASE_PATH, + "22.2.1_intergrid_3levels_anyd.f90"), + api=API) + psy = PSyFactory(API, distributed_memory=True).create(invoke_info) + schedule = psy.invokes.invoke_list[0].schedule + enter_data_trans = ACCEnterDataTrans() + kernel_trans = ACCKernelsTrans() + ctrans = Dynamo0p3ColourTrans() + const = LFRicConstants() + + for loop in schedule.walk(Loop): + if (loop.iteration_space == "cell_column" and + loop.field_space.orig_name not in + const.VALID_DISCONTINUOUS_NAMES): + ctrans.apply(loop) + for loop in schedule.walk(Loop): + if loop.loop_type not in ["colours", "null"]: + kernel_trans.apply(loop) + + enter_data_trans.apply(schedule) + output = str(psy.gen) + for line in output.split("\n"): + # There should be no indexing into arrays within the enter-data + # directive. + if line.lstrip().startswith("!$acc enter data"): + assert "(:,:,cell)" not in line + break From 8a31752145a249a9270b16b7521824875ff5acf1 Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Mon, 26 Jun 2023 11:56:28 +0100 Subject: [PATCH 02/15] #2189 update KernCallACCAargList to explicitly handle inter-grid kernels. --- .../domain/lfric/kern_call_acc_arg_list.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py index 8f989589f5..094067966d 100644 --- a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py +++ b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py @@ -43,6 +43,7 @@ ''' from psyclone.domain.lfric import KernCallArgList +from psyclone import psyGen class KernCallAccArgList(KernCallArgList): @@ -55,6 +56,18 @@ class KernCallAccArgList(KernCallArgList): to keep them in. ''' + def cell_map(self, var_accesses=None): + '''Add cell-map to the list of required arrays. + + :param var_accesses: unused. + :type var_accesses: :py:class:`psyclone.core.VariablesAccessInfo` + + ''' + cargs = psyGen.args_filter(self._kern.args, arg_meshes=["gh_coarse"]) + carg = cargs[0] + base_name = "cell_map_" + carg.name + self.append(base_name) + def field_vector(self, argvect, var_accesses=None): '''Add the field vector associated with the argument 'argvect' to the argument list. OpenACC requires the field and the @@ -213,6 +226,22 @@ def fs_compulsory_field(self, function_space, var_accesses=None): # needs the whole field, so we cannot call the base class. self.append(function_space.map_name, var_accesses) + def fs_intergrid(self, function_space, var_accesses=None): + ''' + ''' + # Is this FS associated with the coarse or fine mesh? (All fields + # on a given mesh must be on the same FS.) + arg = self._kern.arguments.get_arg_on_space(function_space) + if arg.mesh == "gh_fine": + # For the fine mesh, we need the *whole* dofmap + map_name = function_space.map_name + self.append(map_name, var_accesses) + else: + # For the coarse mesh we only need undf and the dofmap for + # the current column + self.fs_compulsory_field(function_space, + var_accesses=var_accesses) + def scalar(self, scalar_arg, var_accesses=None): ''' Override the default implementation as there's no need to specify From 592e28cfe07f93d0e98196e22dffe4a974b071bc Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Mon, 26 Jun 2023 16:22:07 +0100 Subject: [PATCH 03/15] #2189 update creation of colour map symbol and use consistently --- .../domain/lfric/kern_call_acc_arg_list.py | 16 ++++++++++++ .../domain/lfric/kern_call_arg_list.py | 2 +- src/psyclone/dynamo0p3.py | 26 ++++++++++++------- .../tests/dynamo0p3_multigrid_test.py | 4 ++- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py index 094067966d..62203e3a4c 100644 --- a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py +++ b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py @@ -67,6 +67,22 @@ def cell_map(self, var_accesses=None): carg = cargs[0] base_name = "cell_map_" + carg.name self.append(base_name) + # Add the cell map to our argument list + _, cell_ref = self.cell_ref_name(var_accesses) + self.append(cell_ref.symbol.name) + + def cell_position(self, var_accesses=None): + '''Adds a cell argument to the argument list and if supplied stores + this access in var_accesses. + + :param var_accesses: optional VariablesAccessInfo instance to store \ + the information about variable accesses. + :type var_accesses: \ + :py:class:`psyclone.core.VariablesAccessInfo` + + ''' + cell_ref_name, ref = self.cell_ref_name(var_accesses) + self.append(ref.symbol.name) def field_vector(self, argvect, var_accesses=None): '''Add the field vector associated with the argument 'argvect' to the diff --git a/src/psyclone/domain/lfric/kern_call_arg_list.py b/src/psyclone/domain/lfric/kern_call_arg_list.py index a64f533cc1..6ab0c390a5 100644 --- a/src/psyclone/domain/lfric/kern_call_arg_list.py +++ b/src/psyclone/domain/lfric/kern_call_arg_list.py @@ -993,7 +993,7 @@ def cell_ref_name(self, var_accesses=None): if self._kern.is_coloured(): colour_sym = self._symtab.find_or_create_integer_symbol( "colour", tag="colours_loop_idx") - array_ref = self.get_array_reference("cmap", + array_ref = self.get_array_reference(self._kern.colourmap, [Reference(colour_sym), Reference(cell_sym)], ScalarType.Intrinsic.INTEGER) diff --git a/src/psyclone/dynamo0p3.py b/src/psyclone/dynamo0p3.py index ea111598f0..53a2523938 100644 --- a/src/psyclone/dynamo0p3.py +++ b/src/psyclone/dynamo0p3.py @@ -4007,12 +4007,13 @@ def _colourmap_init(self): ''' Sets-up information on any required colourmaps. This cannot be done in the constructor since colouring is applied by Transformations - and happens after the Schedule has already been constructed. + and happens after the Schedule has already been constructed. Therefore, + this method is called at code-generation time. ''' # pylint: disable=too-many-locals const = LFRicConstants() - have_non_intergrid = False + non_intergrid_kern = None sym_tab = self._schedule.symbol_table for call in [call for call in self._schedule.coded_kernels() if @@ -4027,7 +4028,7 @@ def _colourmap_init(self): self._needs_colourmap = True if not call.is_intergrid: - have_non_intergrid = True + non_intergrid_kern = call continue # This is an inter-grid kernel so look-up the names of @@ -4060,13 +4061,12 @@ def _colourmap_init(self): self._ig_kernels[id(call)].set_colour_info(colour_map, ncolours, last_cell) - if have_non_intergrid and (self._needs_colourmap or + if non_intergrid_kern and (self._needs_colourmap or self._needs_colourmap_halo): # There aren't any inter-grid kernels but we do need colourmap # information and that means we'll need a mesh object self._add_mesh_symbols(["mesh"]) - colour_map = sym_tab.find_or_create_array( - "cmap", 2, ScalarType.Intrinsic.INTEGER, tag="cmap").name + colour_map = non_intergrid_kern.colourmap # No. of colours ncolours = sym_tab.find_or_create_integer_symbol( "ncolour", tag="ncolour").name @@ -4168,7 +4168,7 @@ def declarations(self, parent): # colourmap information base_name = "cmap" colour_map = \ - self._schedule.symbol_table.find_or_create_tag(base_name).name + self._schedule.symbol_table.lookup_with_tag(base_name).name # No. of colours base_name = "ncolour" ncolours = \ @@ -4234,6 +4234,7 @@ def initialise(self, parent): parent.add(CommentGen(parent, " Get the colourmap")) parent.add(CommentGen(parent, "")) # Look-up variable names for colourmap and number of colours + self._colourmap_init() colour_map = self._schedule.symbol_table.find_or_create_tag( "cmap").name ncolour = \ @@ -7909,8 +7910,9 @@ def colourmap(self): if not self.is_coloured(): raise InternalError(f"Kernel '{self.name}' is not inside a " f"coloured loop.") + sched = self.ancestor(InvokeSchedule) if self._is_intergrid: - invoke = self.ancestor(InvokeSchedule).invoke + invoke = sched.invoke if id(self) not in invoke.meshes.intergrid_kernels: raise InternalError( f"Colourmap information for kernel '{self.name}' has " @@ -7918,7 +7920,13 @@ def colourmap(self): cmap = invoke.meshes.intergrid_kernels[id(self)].\ colourmap_symbol.name else: - cmap = self.scope.symbol_table.lookup_with_tag("cmap").name + try: + cmap = sched.symbol_table.lookup_with_tag("cmap").name + except KeyError: + # We have to do this here as _init_colourmap is only called + # at code-generation time. + cmap = sched.symbol_table.find_or_create_array( + "cmap", 2, ScalarType.Intrinsic.INTEGER, tag="cmap").name return cmap diff --git a/src/psyclone/tests/dynamo0p3_multigrid_test.py b/src/psyclone/tests/dynamo0p3_multigrid_test.py index 9c54833f4b..73e20a6f65 100644 --- a/src/psyclone/tests/dynamo0p3_multigrid_test.py +++ b/src/psyclone/tests/dynamo0p3_multigrid_test.py @@ -836,7 +836,7 @@ def test_restrict_prolong_chain_acc(tmpdir): ''' _, invoke_info = parse(os.path.join(BASE_PATH, - "22.2.1_intergrid_3levels_anyd.f90"), + "22.2_intergrid_3levels.f90"), api=API) psy = PSyFactory(API, distributed_memory=True).create(invoke_info) schedule = psy.invokes.invoke_list[0].schedule @@ -861,4 +861,6 @@ def test_restrict_prolong_chain_acc(tmpdir): # directive. if line.lstrip().startswith("!$acc enter data"): assert "(:,:,cell)" not in line + assert "cmap(colour,cell)" not in line + assert "cmap_fld_c,cmap_fld_m," in line break From 704151484035cacc8f9d9eeabeac757f0441342f Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Thu, 29 Jun 2023 15:37:56 +0100 Subject: [PATCH 04/15] #2189 add compilation to new test --- src/psyclone/tests/dynamo0p3_multigrid_test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/psyclone/tests/dynamo0p3_multigrid_test.py b/src/psyclone/tests/dynamo0p3_multigrid_test.py index 73e20a6f65..2c3004daee 100644 --- a/src/psyclone/tests/dynamo0p3_multigrid_test.py +++ b/src/psyclone/tests/dynamo0p3_multigrid_test.py @@ -864,3 +864,5 @@ def test_restrict_prolong_chain_acc(tmpdir): assert "cmap(colour,cell)" not in line assert "cmap_fld_c,cmap_fld_m," in line break + # Check compilation + assert LFRicBuild(tmpdir).code_compiles(psy) From 5c3bb356e8b66c81096599fdfafe9b0fc12e1fc6 Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Thu, 29 Jun 2023 16:01:48 +0100 Subject: [PATCH 05/15] #2189 update docstring --- src/psyclone/domain/lfric/kern_call_acc_arg_list.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py index 62203e3a4c..b2119785aa 100644 --- a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py +++ b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py @@ -243,7 +243,16 @@ def fs_compulsory_field(self, function_space, var_accesses=None): self.append(function_space.map_name, var_accesses) def fs_intergrid(self, function_space, var_accesses=None): - ''' + '''Add arrays that need to be uploaded for inter-grid kernels. + These arrays contain the mapping between fine and coarse meshes. + + :param function_space: the function space associated with the mesh. + :type function_space: :py:class:`psyclone.domain.lfric.FunctionSpace` + :param var_accesses: optional VariablesAccessInfo instance to store + the information about variable accesses. + :type var_accesses: Optional[ + :py:class:`psyclone.core.VariablesAccessInfo`] + ''' # Is this FS associated with the coarse or fine mesh? (All fields # on a given mesh must be on the same FS.) From a31f3a3f2a8c189a702e3f176ec68bb0d6e06bbb Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Fri, 30 Jun 2023 09:42:32 +0100 Subject: [PATCH 06/15] #2199 final tidying --- .../domain/lfric/kern_call_acc_arg_list.py | 23 +++++++++++-------- .../tests/dynamo0p3_multigrid_test.py | 1 + 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py index b2119785aa..77ab9499fe 100644 --- a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py +++ b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py @@ -59,8 +59,10 @@ class KernCallAccArgList(KernCallArgList): def cell_map(self, var_accesses=None): '''Add cell-map to the list of required arrays. - :param var_accesses: unused. - :type var_accesses: :py:class:`psyclone.core.VariablesAccessInfo` + :param var_accesses: optional VariablesAccessInfo instance to store + the information about variable accesses. + :type var_accesses: Optional[ + :py:class:`psyclone.core.VariablesAccessInfo`] ''' cargs = psyGen.args_filter(self._kern.args, arg_meshes=["gh_coarse"]) @@ -73,15 +75,16 @@ def cell_map(self, var_accesses=None): def cell_position(self, var_accesses=None): '''Adds a cell argument to the argument list and if supplied stores - this access in var_accesses. + this access in var_accesses. The cell argument may actually require + a lookup from a colour map array. - :param var_accesses: optional VariablesAccessInfo instance to store \ + :param var_accesses: optional VariablesAccessInfo instance to store the information about variable accesses. - :type var_accesses: \ - :py:class:`psyclone.core.VariablesAccessInfo` + :type var_accesses: Optional[ + :py:class:`psyclone.core.VariablesAccessInfo`] ''' - cell_ref_name, ref = self.cell_ref_name(var_accesses) + _, ref = self.cell_ref_name(var_accesses) self.append(ref.symbol.name) def field_vector(self, argvect, var_accesses=None): @@ -92,10 +95,10 @@ def field_vector(self, argvect, var_accesses=None): :param argvect: the field vector to add. :type argvect: :py:class:`psyclone.dynamo0p3.DynKernelArgument` - :param var_accesses: optional VariablesAccessInfo instance to store \ + :param var_accesses: optional VariablesAccessInfo instance to store the information about variable accesses. - :type var_accesses: \ - :py:class:`psyclone.core.VariablesAccessInfo` + :type var_accesses: Optional[ + :py:class:`psyclone.core.VariablesAccessInfo`] ''' # First provide the derived-type object diff --git a/src/psyclone/tests/dynamo0p3_multigrid_test.py b/src/psyclone/tests/dynamo0p3_multigrid_test.py index 2c3004daee..1273078239 100644 --- a/src/psyclone/tests/dynamo0p3_multigrid_test.py +++ b/src/psyclone/tests/dynamo0p3_multigrid_test.py @@ -856,6 +856,7 @@ def test_restrict_prolong_chain_acc(tmpdir): enter_data_trans.apply(schedule) output = str(psy.gen) + assert "acc enter data" in output for line in output.split("\n"): # There should be no indexing into arrays within the enter-data # directive. From e4b287da0a9d5a0b282622c455c02180d5db1d3c Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Thu, 6 Jul 2023 17:21:35 +0100 Subject: [PATCH 07/15] #2189 rm unnecessary _colourmap_init() call and add check for expected metadata --- src/psyclone/domain/lfric/kern_call_acc_arg_list.py | 7 ++++++- src/psyclone/dynamo0p3.py | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py index 77ab9499fe..a0497445d5 100644 --- a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py +++ b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py @@ -42,8 +42,9 @@ first before any members. ''' -from psyclone.domain.lfric import KernCallArgList from psyclone import psyGen +from psyclone.domain.lfric import KernCallArgList +from psyclone.errors import InternalError class KernCallAccArgList(KernCallArgList): @@ -66,6 +67,10 @@ def cell_map(self, var_accesses=None): ''' cargs = psyGen.args_filter(self._kern.args, arg_meshes=["gh_coarse"]) + if len(cargs) > 1: + raise InternalError( + f"An LFRic intergrid kernel should have only one coarse mesh " + f"but {self._kern.name} has {len(cargs)}") carg = cargs[0] base_name = "cell_map_" + carg.name self.append(base_name) diff --git a/src/psyclone/dynamo0p3.py b/src/psyclone/dynamo0p3.py index 53a2523938..749bc59ad3 100644 --- a/src/psyclone/dynamo0p3.py +++ b/src/psyclone/dynamo0p3.py @@ -4234,7 +4234,6 @@ def initialise(self, parent): parent.add(CommentGen(parent, " Get the colourmap")) parent.add(CommentGen(parent, "")) # Look-up variable names for colourmap and number of colours - self._colourmap_init() colour_map = self._schedule.symbol_table.find_or_create_tag( "cmap").name ncolour = \ From c0a43bc2f58d0d3aab2b597a1efa2ff6515339ed Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Fri, 7 Jul 2023 08:32:19 +0100 Subject: [PATCH 08/15] #2189 mv existing tests into new file --- .../domain/lfric/kern_call_acc_arg_list.py | 2 +- src/psyclone/tests/dependency_test.py | 91 +--------- .../lfric/kern_call_acc_arg_list_test.py | 166 ++++++++++++++++++ 3 files changed, 170 insertions(+), 89 deletions(-) create mode 100644 src/psyclone/tests/domain/lfric/kern_call_acc_arg_list_test.py diff --git a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py index a0497445d5..fbc22e3793 100644 --- a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py +++ b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py @@ -70,7 +70,7 @@ def cell_map(self, var_accesses=None): if len(cargs) > 1: raise InternalError( f"An LFRic intergrid kernel should have only one coarse mesh " - f"but {self._kern.name} has {len(cargs)}") + f"but '{self._kern.name}' has {len(cargs)}") carg = cargs[0] base_name = "cell_map_" + carg.name self.append(base_name) diff --git a/src/psyclone/tests/dependency_test.py b/src/psyclone/tests/dependency_test.py index 9fdcd836a7..35e539ba2a 100644 --- a/src/psyclone/tests/dependency_test.py +++ b/src/psyclone/tests/dependency_test.py @@ -1,7 +1,7 @@ # ----------------------------------------------------------------------------- # BSD 3-Clause License # -# Copyright (c) 2019-2022, Science and Technology Facilities Council. +# Copyright (c) 2019-2023, Science and Technology Facilities Council. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -38,20 +38,18 @@ ''' Module containing py.test tests for dependency analysis.''' -from __future__ import print_function, absolute_import import os import pytest from fparser.common.readfortran import FortranStringReader from psyclone import nemo from psyclone.core import AccessType, Signature, VariablesAccessInfo -from psyclone.domain.lfric import KernCallAccArgList, KernStubArgList +from psyclone.domain.lfric import KernStubArgList from psyclone.dynamo0p3 import DynKernMetadata, DynKern from psyclone.parse.algorithm import parse -from psyclone.psyGen import CodedKern, PSyFactory +from psyclone.psyGen import PSyFactory from psyclone.psyir.nodes import Assignment, IfBlock, Loop from psyclone.tests.utilities import get_invoke, get_ast -from psyclone.transformations import ACCParallelTrans, ACCEnterDataTrans # Constants API = "nemo" @@ -849,86 +847,3 @@ def test_lfric_stub_boundary_dofmap(): create_arg_list = KernStubArgList(kernel) create_arg_list.generate(var_accesses=var_accesses) assert "boundary_dofs_op_1: READ" in str(var_accesses) - - -def test_lfric_acc(): - '''Check variable usage detection when OpenACC is used. - - ''' - # Use the OpenACC transforms to enclose the kernels - # with OpenACC directives. - acc_par_trans = ACCParallelTrans() - acc_enter_trans = ACCEnterDataTrans() - _, invoke = get_invoke("1_single_invoke.f90", "dynamo0.3", - name="invoke_0_testkern_type", dist_mem=False) - sched = invoke.schedule - acc_par_trans.apply(sched.children) - acc_enter_trans.apply(sched) - - # Find the first kernel: - kern = invoke.schedule.walk(CodedKern)[0] - create_acc_arg_list = KernCallAccArgList(kern) - var_accesses = VariablesAccessInfo() - create_acc_arg_list.generate(var_accesses=var_accesses) - var_info = str(var_accesses) - assert "f1: READ+WRITE" in var_info - assert "f2: READ" in var_info - assert "m1: READ" in var_info - assert "m2: READ" in var_info - assert "undf_w1: READ" in var_info - assert "map_w1: READ" in var_info - assert "undf_w2: READ" in var_info - assert "map_w2: READ" in var_info - assert "undf_w3: READ" in var_info - assert "map_w3: READ" in var_info - - -def test_lfric_acc_operator(): - '''Check variable usage detection when OpenACC is used with - a kernel that uses an operator. - - ''' - # Use the OpenACC transforms to enclose the kernels - # with OpenACC directives. - acc_par_trans = ACCParallelTrans() - acc_enter_trans = ACCEnterDataTrans() - _, invoke = get_invoke("20.0_cma_assembly.f90", "dynamo0.3", - idx=0, dist_mem=False) - sched = invoke.schedule - acc_par_trans.apply(sched.children) - acc_enter_trans.apply(sched) - - # Find the first kernel: - kern = invoke.schedule.walk(CodedKern)[0] - create_acc_arg_list = KernCallAccArgList(kern) - var_accesses = VariablesAccessInfo() - create_acc_arg_list.generate(var_accesses=var_accesses) - var_info = str(var_accesses) - assert "lma_op1_proxy%ncell_3d: READ" in var_info - assert "lma_op1_proxy%local_stencil: READ" in var_info - assert "cma_op1_matrix: WRITE" in var_info - - -def test_lfric_stencil(): - '''Check variable usage detection when OpenACC is used with a - kernel that uses a stencil. - - ''' - # Use the OpenACC transforms to create the required kernels - acc_par_trans = ACCParallelTrans() - acc_enter_trans = ACCEnterDataTrans() - _, invoke = get_invoke("14.4_halo_vector.f90", "dynamo0.3", - idx=0, dist_mem=False) - sched = invoke.schedule - acc_par_trans.apply(sched.children) - acc_enter_trans.apply(sched) - - # Find the first kernel: - kern = invoke.schedule.walk(CodedKern)[0] - create_acc_arg_list = KernCallAccArgList(kern) - var_accesses = VariablesAccessInfo() - create_acc_arg_list.generate(var_accesses=var_accesses) - var_info = str(var_accesses) - assert "f1: READ+WRITE" in var_info - assert "f2: READ" in var_info - assert "f2_stencil_dofmap: READ" in var_info diff --git a/src/psyclone/tests/domain/lfric/kern_call_acc_arg_list_test.py b/src/psyclone/tests/domain/lfric/kern_call_acc_arg_list_test.py new file mode 100644 index 0000000000..d09ff54eee --- /dev/null +++ b/src/psyclone/tests/domain/lfric/kern_call_acc_arg_list_test.py @@ -0,0 +1,166 @@ +# ----------------------------------------------------------------------------- +# BSD 3-Clause License +# +# Copyright (c) 2023, 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: J. Henrichs, Bureau of Meteorology +# R. W. Ford and A. R. Porter, STFC Daresbury Lab +# I. Kavcic, Met Office + +''' This module tests the LFric KernCallAccArgList class.''' + +import os + +import pytest + +from psyclone.core import VariablesAccessInfo +from psyclone.domain.lfric import (KernCallAccArgList, LFRicConstants, + LFRicSymbolTable, LFRicTypes) +from psyclone.errors import GenerationError, InternalError +from psyclone.dynamo0p3 import DynKern +from psyclone.parse.algorithm import parse +from psyclone import psyGen +from psyclone.psyir.nodes import Literal, Loop, Reference, UnaryOperation +from psyclone.psyir.symbols import ArrayType, ScalarType +from psyclone.tests.utilities import get_base_path, get_invoke +from psyclone.transformations import ACCParallelTrans, ACCEnterDataTrans + +# constants +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_acc_arg_list_single_coarse_mesh(dist_mem, monkeypatch): + '''Tests that an exception is raised as expected if a kernel has more than + one coarse mesh. + ''' + # We need a DynKern in order to construct an instance of KernCallAccArgList + _, invoke_info = parse(os.path.join(BASE_PATH, + "22.0_intergrid_prolong.f90"), + api=TEST_API) + psy = psyGen.PSyFactory(TEST_API, + distributed_memory=dist_mem).create(invoke_info) + schedule = psy.invokes.invoke_list[0].schedule + kern = schedule.walk(DynKern)[0] + arg_list = KernCallAccArgList(kern) + # Rather than attempt to break the kernel itself, we monkeypatch the + # args_filter routine so that it returns all args rather than just the + # one requested. + monkeypatch.setattr(psyGen, "args_filter", lambda args, arg_meshes: args) + with pytest.raises(InternalError) as err: + arg_list.cell_map() + assert ("An LFRic intergrid kernel should have only one coarse mesh but " + "'prolong_test_kernel_code' has 2" in str(err.value)) + + +def test_lfric_acc(): + '''Check variable usage detection when OpenACC is used. + + ''' + # Use the OpenACC transforms to enclose the kernels + # with OpenACC directives. + acc_par_trans = ACCParallelTrans() + acc_enter_trans = ACCEnterDataTrans() + _, invoke = get_invoke("1_single_invoke.f90", "dynamo0.3", + name="invoke_0_testkern_type", dist_mem=False) + sched = invoke.schedule + acc_par_trans.apply(sched.children) + acc_enter_trans.apply(sched) + + # Find the first kernel: + kern = invoke.schedule.walk(psyGen.CodedKern)[0] + create_acc_arg_list = KernCallAccArgList(kern) + var_accesses = VariablesAccessInfo() + create_acc_arg_list.generate(var_accesses=var_accesses) + var_info = str(var_accesses) + assert "f1: READ+WRITE" in var_info + assert "f2: READ" in var_info + assert "m1: READ" in var_info + assert "m2: READ" in var_info + assert "undf_w1: READ" in var_info + assert "map_w1: READ" in var_info + assert "undf_w2: READ" in var_info + assert "map_w2: READ" in var_info + assert "undf_w3: READ" in var_info + assert "map_w3: READ" in var_info + + +def test_lfric_acc_operator(): + '''Check variable usage detection when OpenACC is used with + a kernel that uses an operator. + + ''' + # Use the OpenACC transforms to enclose the kernels + # with OpenACC directives. + acc_par_trans = ACCParallelTrans() + acc_enter_trans = ACCEnterDataTrans() + _, invoke = get_invoke("20.0_cma_assembly.f90", "dynamo0.3", + idx=0, dist_mem=False) + sched = invoke.schedule + acc_par_trans.apply(sched.children) + acc_enter_trans.apply(sched) + + # Find the first kernel: + kern = invoke.schedule.walk(psyGen.CodedKern)[0] + create_acc_arg_list = KernCallAccArgList(kern) + var_accesses = VariablesAccessInfo() + create_acc_arg_list.generate(var_accesses=var_accesses) + var_info = str(var_accesses) + assert "lma_op1_proxy%ncell_3d: READ" in var_info + assert "lma_op1_proxy%local_stencil: READ" in var_info + assert "cma_op1_matrix: WRITE" in var_info + + +def test_lfric_stencil(): + '''Check variable usage detection when OpenACC is used with a + kernel that uses a stencil. + + ''' + # Use the OpenACC transforms to create the required kernels + acc_par_trans = ACCParallelTrans() + acc_enter_trans = ACCEnterDataTrans() + _, invoke = get_invoke("14.4_halo_vector.f90", "dynamo0.3", + idx=0, dist_mem=False) + sched = invoke.schedule + acc_par_trans.apply(sched.children) + acc_enter_trans.apply(sched) + + # Find the first kernel: + kern = invoke.schedule.walk(psyGen.CodedKern)[0] + create_acc_arg_list = KernCallAccArgList(kern) + var_accesses = VariablesAccessInfo() + create_acc_arg_list.generate(var_accesses=var_accesses) + var_info = str(var_accesses) + assert "f1: READ+WRITE" in var_info + assert "f2: READ" in var_info + assert "f2_stencil_dofmap: READ" in var_info From 69224d5dc54d932af2c8379ca9bde78493d38f1c Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Fri, 7 Jul 2023 09:43:06 +0100 Subject: [PATCH 09/15] #2189 extend tests to get coverage --- .../lfric/kern_call_acc_arg_list_test.py | 70 +++++++++++++++---- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git a/src/psyclone/tests/domain/lfric/kern_call_acc_arg_list_test.py b/src/psyclone/tests/domain/lfric/kern_call_acc_arg_list_test.py index d09ff54eee..0e366b0a8a 100644 --- a/src/psyclone/tests/domain/lfric/kern_call_acc_arg_list_test.py +++ b/src/psyclone/tests/domain/lfric/kern_call_acc_arg_list_test.py @@ -42,28 +42,21 @@ import pytest from psyclone.core import VariablesAccessInfo -from psyclone.domain.lfric import (KernCallAccArgList, LFRicConstants, - LFRicSymbolTable, LFRicTypes) -from psyclone.errors import GenerationError, InternalError +from psyclone.domain.lfric import FunctionSpace, KernCallAccArgList +from psyclone.errors import InternalError from psyclone.dynamo0p3 import DynKern from psyclone.parse.algorithm import parse from psyclone import psyGen -from psyclone.psyir.nodes import Literal, Loop, Reference, UnaryOperation -from psyclone.psyir.symbols import ArrayType, ScalarType from psyclone.tests.utilities import get_base_path, get_invoke from psyclone.transformations import ACCParallelTrans, ACCEnterDataTrans # constants -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" +BASE_PATH = get_base_path(TEST_API) -def test_acc_arg_list_single_coarse_mesh(dist_mem, monkeypatch): - '''Tests that an exception is raised as expected if a kernel has more than - one coarse mesh. - ''' +def test_acc_arg_list_cell_map(dist_mem, monkeypatch): + '''Test the cell_map() method.''' # We need a DynKern in order to construct an instance of KernCallAccArgList _, invoke_info = parse(os.path.join(BASE_PATH, "22.0_intergrid_prolong.f90"), @@ -73,6 +66,9 @@ def test_acc_arg_list_single_coarse_mesh(dist_mem, monkeypatch): schedule = psy.invokes.invoke_list[0].schedule kern = schedule.walk(DynKern)[0] arg_list = KernCallAccArgList(kern) + # Check that the cell_map method works as expected. + arg_list.cell_map() + assert "cell_map_field2" in arg_list._arglist # Rather than attempt to break the kernel itself, we monkeypatch the # args_filter routine so that it returns all args rather than just the # one requested. @@ -83,6 +79,56 @@ def test_acc_arg_list_single_coarse_mesh(dist_mem, monkeypatch): "'prolong_test_kernel_code' has 2" in str(err.value)) +def test_stencil_2d(): + '''Test for the stencil_2d() and stencil_2d_unknown_extent methods.''' + _, invoke = get_invoke("19.7_multiple_stencils.f90", TEST_API, + name="invoke_0_testkern_stencil_multi_type", + dist_mem=False) + sched = invoke.schedule + kern = sched.walk(DynKern)[0] + arg_list = KernCallAccArgList(kern) + arg_list.stencil_2d(kern.arguments._args[1]) + # This should result in the whole stencil dofmap being added as an arg. + assert arg_list._arglist == ['f2_stencil_dofmap'] + arg_list.stencil_2d_unknown_extent(kern.arguments._args[1]) + # This should result in the stencil extent being added as an arg. + assert arg_list._arglist == ['f2_stencil_dofmap', 'f2_stencil_size'] + + +def test_fs_compulsory_field_no_cell_column(): + '''Check that the fs_compulsory_field method does nothing if the kernel + does not iterate over cell columns.''' + _, invoke = get_invoke("25.0_domain.f90", TEST_API, + name="invoke_0_testkern_domain_type", + dist_mem=False) + sched = invoke.schedule + kern = sched.walk(DynKern)[0] + arg_list = KernCallAccArgList(kern) + fspace = FunctionSpace("w3", kern.arguments) + arg_list.fs_compulsory_field(fspace) + assert arg_list._arglist == [] + + +def test_fs_intergrid(): + '''Test the fs_intergrid() method.''' + _, invoke = get_invoke("22.2_intergrid_3levels.f90", TEST_API, + name="invoke_0", dist_mem=False) + sched = invoke.schedule + kernels = sched.walk(DynKern) + prolong_kern = kernels[0] + restrict_kern = kernels[2] + fspace = FunctionSpace("any_space_1", restrict_kern.arguments) + arg_list = KernCallAccArgList(restrict_kern) + arg_list.fs_intergrid(fspace) + # For the coarse mesh we need undf and the dofmap for the column. + assert arg_list._arglist == ['undf_aspc1_fld_m', 'map_aspc1_fld_m'] + fspace = FunctionSpace("w1", prolong_kern.arguments) + arg_list = KernCallAccArgList(prolong_kern) + arg_list.fs_intergrid(fspace) + # For the fine mesh we just need the whole dofmap. + assert arg_list._arglist == ['map_w1'] + + def test_lfric_acc(): '''Check variable usage detection when OpenACC is used. From 54d391387e851fb7539d647b485055fe2960f482 Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Fri, 7 Jul 2023 14:09:10 +0100 Subject: [PATCH 10/15] #2189 tidying for review and work towards fixing cmap name clashes [skip ci] --- .../domain/lfric/kern_call_acc_arg_list.py | 67 ++++++++++--------- src/psyclone/dynamo0p3.py | 17 +++-- .../domain/lfric/kern_call_arg_list_test.py | 6 +- src/psyclone/tests/dynamo0p3_basis_test.py | 23 +++---- .../test_files/dynamo0p3/6.1_eval_invoke.f90 | 4 +- 5 files changed, 61 insertions(+), 56 deletions(-) diff --git a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py index fbc22e3793..f303b5f917 100644 --- a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py +++ b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py @@ -72,16 +72,17 @@ def cell_map(self, var_accesses=None): f"An LFRic intergrid kernel should have only one coarse mesh " f"but '{self._kern.name}' has {len(cargs)}") carg = cargs[0] + # Add the cell map to our argument list base_name = "cell_map_" + carg.name self.append(base_name) - # Add the cell map to our argument list - _, cell_ref = self.cell_ref_name(var_accesses) - self.append(cell_ref.symbol.name) + # We'll need the current cell to index into this cell map. + self.cell_position(var_accesses) def cell_position(self, var_accesses=None): '''Adds a cell argument to the argument list and if supplied stores - this access in var_accesses. The cell argument may actually require - a lookup from a colour map array. + this access in var_accesses. Although normally just a scalar, the cell + argument may actually require a lookup from a colour map array. Either + way, this method adds the name of the variable to the argument list. :param var_accesses: optional VariablesAccessInfo instance to store the information about variable accesses. @@ -120,10 +121,10 @@ def field(self, arg, var_accesses=None): :param arg: the field to be added. :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument` - :param var_accesses: optional VariablesAccessInfo instance to store \ + :param var_accesses: optional VariablesAccessInfo instance to store the information about variable accesses. - :type var_accesses: \ - :py:class:`psyclone.core.VariablesAccessInfo` + :type var_accesses: Optional[ + :py:class:`psyclone.core.VariablesAccessInfo`] ''' text1 = arg.proxy_name @@ -137,13 +138,13 @@ def stencil(self, arg, var_accesses=None): to the argument list. OpenACC requires the full dofmap to be specified. If supplied it also stores this access in var_accesses. - :param arg: the meta-data description of the kernel \ - argument with which the stencil is associated. + :param arg: the meta-data description of the kernel argument with + which the stencil is associated. :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument` - :param var_accesses: optional VariablesAccessInfo instance to store \ + :param var_accesses: optional VariablesAccessInfo instance to store the information about variable accesses. - :type var_accesses: \ - :py:class:`psyclone.core.VariablesAccessInfo` + :type var_accesses: [ + :py:class:`psyclone.core.VariablesAccessInfo`] ''' # Import here to avoid circular dependency @@ -159,13 +160,13 @@ def stencil_2d(self, arg, var_accesses=None): specified. If supplied it also stores this access in var_accesses.This method passes through to the stencil method. - :param arg: the meta-data description of the kernel \ + :param arg: the meta-data description of the kernel argument with which the stencil is associated. :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument` - :param var_accesses: optional VariablesAccessInfo instance to store \ + :param var_accesses: optional VariablesAccessInfo instance to store the information about variable accesses. - :type var_accesses: \ - :py:class:`psyclone.core.VariablesAccessInfo` + :type var_accesses: Optional[ + :py:class:`psyclone.core.VariablesAccessInfo`] ''' self.stencil(arg, var_accesses) @@ -177,10 +178,10 @@ def stencil_unknown_extent(self, arg, var_accesses=None): :param arg: the kernel argument with which the stencil is associated. :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument` - :param var_accesses: optional VariablesAccessInfo instance to store \ + :param var_accesses: optional VariablesAccessInfo instance to store the information about variable accesses. - :type var_accesses: \ - :py:class:`psyclone.core.VariablesAccessInfo` + :type var_accesses: Optional[ + :py:class:`psyclone.core.VariablesAccessInfo`] ''' # The extent is not specified in the metadata so pass the value in @@ -199,10 +200,10 @@ def stencil_2d_unknown_extent(self, arg, var_accesses=None): :param arg: the kernel argument with which the stencil is associated. :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument` - :param var_accesses: optional VariablesAccessInfo instance to store \ + :param var_accesses: optional VariablesAccessInfo instance to store the information about variable accesses. - :type var_accesses: \ - :py:class:`psyclone.core.VariablesAccessInfo` + :type var_accesses: Optional[ + :py:class:`psyclone.core.VariablesAccessInfo`] ''' self.stencil_unknown_extent(arg, var_accesses) @@ -215,10 +216,10 @@ def operator(self, arg, var_accesses=None): :param arg: the meta-data description of the operator. :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument` - :param var_accesses: optional VariablesAccessInfo instance to store \ + :param var_accesses: optional VariablesAccessInfo instance to store the information about variable accesses. - :type var_accesses: \ - :py:class:`psyclone.core.VariablesAccessInfo` + :type var_accesses: Optional[ + :py:class:`psyclone.core.VariablesAccessInfo`] ''' # In case of OpenACC we do not want to transfer the same @@ -234,13 +235,13 @@ def fs_compulsory_field(self, function_space, var_accesses=None): to be specified. If supplied it also stores this access in var_accesses. - :param function_space: the function space for which the compulsory \ + :param function_space: the function space for which the compulsory arguments are added. :type function_space: :py:class:`psyclone.domain.lfric.FunctionSpace` - :param var_accesses: optional VariablesAccessInfo instance to store \ + :param var_accesses: optional VariablesAccessInfo instance to store the information about variable accesses. - :type var_accesses: \ - :py:class:`psyclone.core.VariablesAccessInfo` + :type var_accesses: Optional[ + :py:class:`psyclone.core.VariablesAccessInfo`] ''' if self._kern.iterates_over != "cell_column": @@ -282,10 +283,10 @@ def scalar(self, scalar_arg, var_accesses=None): :param scalar_arg: the kernel argument. :type scalar_arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument` - :param var_accesses: optional VariablesAccessInfo instance that \ + :param var_accesses: optional VariablesAccessInfo instance that stores information about variable accesses. - :type var_accesses: \ - :py:class:`psyclone.core.VariablesAccessInfo` + :type var_accesses: Optional[ + :py:class:`psyclone.core.VariablesAccessInfo`] ''' diff --git a/src/psyclone/dynamo0p3.py b/src/psyclone/dynamo0p3.py index 749bc59ad3..1bfbfc5200 100644 --- a/src/psyclone/dynamo0p3.py +++ b/src/psyclone/dynamo0p3.py @@ -1860,7 +1860,9 @@ def kern_args(self, stub=False, var_accesses=None, cell_name = "cell" if self._kernel.is_coloured(): colour_name = "colour" - cmap_name = "cmap" + #cmap_name = "cmap" + cmap_name = self._symbol_table.find_or_create_tag( + "cmap", root_name="cmap").name adj_face += (f"(:,{cmap_name}({colour_name}," f"{cell_name}))") else: @@ -4066,6 +4068,8 @@ def _colourmap_init(self): # There aren't any inter-grid kernels but we do need colourmap # information and that means we'll need a mesh object self._add_mesh_symbols(["mesh"]) + # This creates the colourmap information for this invoke if we + # don't already have one. colour_map = non_intergrid_kern.colourmap # No. of colours ncolours = sym_tab.find_or_create_integer_symbol( @@ -4167,8 +4171,8 @@ def declarations(self, parent): # There aren't any inter-grid kernels but we do need # colourmap information base_name = "cmap" - colour_map = \ - self._schedule.symbol_table.lookup_with_tag(base_name).name + csym = self._schedule.symbol_table.lookup_with_tag("cmap") + colour_map = csym.name # No. of colours base_name = "ncolour" ncolours = \ @@ -7922,10 +7926,11 @@ def colourmap(self): try: cmap = sched.symbol_table.lookup_with_tag("cmap").name except KeyError: - # We have to do this here as _init_colourmap is only called - # at code-generation time. + # We have to do this here as _init_colourmap (which calls this + # method) is only called at code-generation time. cmap = sched.symbol_table.find_or_create_array( - "cmap", 2, ScalarType.Intrinsic.INTEGER, tag="cmap").name + "cmap", 2, ScalarType.Intrinsic.INTEGER, + tag="cmap").name return cmap diff --git a/src/psyclone/tests/domain/lfric/kern_call_arg_list_test.py b/src/psyclone/tests/domain/lfric/kern_call_arg_list_test.py index 06bcc87323..0ab5ab207b 100644 --- a/src/psyclone/tests/domain/lfric/kern_call_arg_list_test.py +++ b/src/psyclone/tests/domain/lfric/kern_call_arg_list_test.py @@ -274,9 +274,9 @@ def test_kerncallarglist_evaluator(fortran_writer): create_arg_list = KernCallArgList(schedule.kernels()[0]) create_arg_list.generate() assert create_arg_list._arglist == [ - 'nlayers', 'f0_proxy%data', 'f1_proxy%data', 'ndf_w0', 'undf_w0', - 'map_w0(:,cmap(colour,cell))', 'basis_w0_on_w0', 'ndf_w1', 'undf_w1', - 'map_w1(:,cmap(colour,cell))', 'diff_basis_w1_on_w0'] + 'nlayers', 'f0_proxy%data', 'cmap_proxy%data', 'ndf_w0', 'undf_w0', + 'map_w0(:,cmap_1(colour,cell))', 'basis_w0_on_w0', 'ndf_w1', 'undf_w1', + 'map_w1(:,cmap_1(colour,cell))', 'diff_basis_w1_on_w0'] check_psyir_results(create_arg_list, fortran_writer) diff --git a/src/psyclone/tests/dynamo0p3_basis_test.py b/src/psyclone/tests/dynamo0p3_basis_test.py index dd40e0f9e2..35cd94b87c 100644 --- a/src/psyclone/tests/dynamo0p3_basis_test.py +++ b/src/psyclone/tests/dynamo0p3_basis_test.py @@ -1,7 +1,7 @@ # ----------------------------------------------------------------------------- # BSD 3-Clause License # -# Copyright (c) 2017-2022, Science and Technology Facilities Council. +# Copyright (c) 2017-2023, Science and Technology Facilities Council. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -38,7 +38,6 @@ ''' Module containing py.test tests for functionality related to evaluators in the LFRic API ''' -from __future__ import absolute_import, print_function import os import pytest import fparser @@ -204,10 +203,10 @@ def test_single_kern_eval(tmpdir): # Check subroutine declarations expected_decl = ( - " SUBROUTINE invoke_0_testkern_eval_type(f0, f1)\n" + " SUBROUTINE invoke_0_testkern_eval_type(f0, cmap)\n" " USE testkern_eval_mod, ONLY: testkern_eval_code\n" " USE function_space_mod, ONLY: BASIS, DIFF_BASIS\n" - " TYPE(field_type), intent(in) :: f0, f1\n" + " TYPE(field_type), intent(in) :: f0, cmap\n" " INTEGER(KIND=i_def) cell\n" " INTEGER(KIND=i_def) loop0_start, loop0_stop\n" " INTEGER(KIND=i_def) df_nodal, df_w0, df_w1\n" @@ -216,7 +215,7 @@ def test_single_kern_eval(tmpdir): " INTEGER(KIND=i_def) dim_w0, diff_dim_w1\n" " REAL(KIND=r_def), pointer :: nodes_w0(:,:) => null()\n" " INTEGER(KIND=i_def) nlayers\n" - " TYPE(field_proxy_type) f0_proxy, f1_proxy\n" + " TYPE(field_proxy_type) f0_proxy, cmap_proxy\n" " INTEGER(KIND=i_def), pointer :: map_w0(:,:) => null(), " "map_w1(:,:) => null()\n" " INTEGER(KIND=i_def) ndf_w0, undf_w0, ndf_w1, undf_w1\n") @@ -227,7 +226,7 @@ def test_single_kern_eval(tmpdir): " ! Initialise field and/or operator proxies\n" " !\n" " f0_proxy = f0%get_proxy()\n" - " f1_proxy = f1%get_proxy()\n" + " cmap_proxy = cmap%get_proxy()\n" " !\n" " ! Initialise number of layers\n" " !\n" @@ -236,7 +235,7 @@ def test_single_kern_eval(tmpdir): " ! Look-up dofmaps for each function space\n" " !\n" " map_w0 => f0_proxy%vspace%get_whole_dofmap()\n" - " map_w1 => f1_proxy%vspace%get_whole_dofmap()\n" + " map_w1 => cmap_proxy%vspace%get_whole_dofmap()\n" " !\n" " ! Initialise number of DoFs for w0\n" " !\n" @@ -245,8 +244,8 @@ def test_single_kern_eval(tmpdir): " !\n" " ! Initialise number of DoFs for w1\n" " !\n" - " ndf_w1 = f1_proxy%vspace%get_ndf()\n" - " undf_w1 = f1_proxy%vspace%get_undf()\n" + " ndf_w1 = cmap_proxy%vspace%get_ndf()\n" + " undf_w1 = cmap_proxy%vspace%get_undf()\n" " !\n" " ! Initialise evaluator-related quantities for the target " "function spaces\n" @@ -256,7 +255,7 @@ def test_single_kern_eval(tmpdir): " ! Allocate basis/diff-basis arrays\n" " !\n" " dim_w0 = f0_proxy%vspace%get_dim_space()\n" - " diff_dim_w1 = f1_proxy%vspace%get_dim_space_diff()\n" + " diff_dim_w1 = cmap_proxy%vspace%get_dim_space_diff()\n" " ALLOCATE (basis_w0_on_w0(dim_w0, ndf_w0, ndf_w0))\n" " ALLOCATE (diff_basis_w1_on_w0(diff_dim_w1, ndf_w1, ndf_w0))\n" " !\n" @@ -270,7 +269,7 @@ def test_single_kern_eval(tmpdir): " END DO\n" " DO df_nodal=1,ndf_w0\n" " DO df_w1=1,ndf_w1\n" - " diff_basis_w1_on_w0(:,df_w1,df_nodal) = f1_proxy%vspace%" + " diff_basis_w1_on_w0(:,df_w1,df_nodal) = cmap_proxy%vspace%" "call_function(DIFF_BASIS,df_w1,nodes_w0(:,df_nodal))\n" " END DO\n" " END DO\n" @@ -285,7 +284,7 @@ def test_single_kern_eval(tmpdir): " DO cell=loop0_start,loop0_stop\n" " !\n" " CALL testkern_eval_code(nlayers, f0_proxy%data, " - "f1_proxy%data, ndf_w0, undf_w0, map_w0(:,cell), basis_w0_on_w0, " + "cmap_proxy%data, ndf_w0, undf_w0, map_w0(:,cell), basis_w0_on_w0, " "ndf_w1, undf_w1, map_w1(:,cell), diff_basis_w1_on_w0)\n" " END DO\n" " !\n" diff --git a/src/psyclone/tests/test_files/dynamo0p3/6.1_eval_invoke.f90 b/src/psyclone/tests/test_files/dynamo0p3/6.1_eval_invoke.f90 index 3e81e1776f..f8c2dc0f3e 100644 --- a/src/psyclone/tests/test_files/dynamo0p3/6.1_eval_invoke.f90 +++ b/src/psyclone/tests/test_files/dynamo0p3/6.1_eval_invoke.f90 @@ -38,8 +38,8 @@ program eval_invoke implicit none - type(field_type) :: f0, f1 + type(field_type) :: f0, cmap - call invoke( testkern_eval_type(f0, f1) ) + call invoke( testkern_eval_type(f0, cmap) ) end program eval_invoke From ca3ebb84b31a1bb8a7660744833046697053e79e Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Fri, 7 Jul 2023 15:54:26 +0100 Subject: [PATCH 11/15] #2189 fix all tests after renaming a field arg in a test --- .../domain/lfric/kern_call_arg_list.py | 9 +++- .../dynamo0p3_transformations_test.py | 44 ++++++++-------- .../tests/dynamo0p3_multigrid_test.py | 52 ++++++++++--------- .../dynamo0p3/22.2_intergrid_3levels.f90 | 18 ++++--- 4 files changed, 67 insertions(+), 56 deletions(-) diff --git a/src/psyclone/domain/lfric/kern_call_arg_list.py b/src/psyclone/domain/lfric/kern_call_arg_list.py index 6ab0c390a5..12a03ac410 100644 --- a/src/psyclone/domain/lfric/kern_call_arg_list.py +++ b/src/psyclone/domain/lfric/kern_call_arg_list.py @@ -993,10 +993,17 @@ def cell_ref_name(self, var_accesses=None): if self._kern.is_coloured(): colour_sym = self._symtab.find_or_create_integer_symbol( "colour", tag="colours_loop_idx") + if self._kern.is_intergrid: + tag = None + else: + # If there is only one colourmap we need to specify the tag + # to make sure we get the right symbol. + tag = "cmap" array_ref = self.get_array_reference(self._kern.colourmap, [Reference(colour_sym), Reference(cell_sym)], - ScalarType.Intrinsic.INTEGER) + ScalarType.Intrinsic.INTEGER, + tag=tag) if var_accesses is not None: var_accesses.add_access(Signature(colour_sym.name), AccessType.READ, self._kern) 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 8e8927ef0d..96b469edc0 100644 --- a/src/psyclone/tests/domain/lfric/transformations/dynamo0p3_transformations_test.py +++ b/src/psyclone/tests/domain/lfric/transformations/dynamo0p3_transformations_test.py @@ -6170,8 +6170,8 @@ def test_intergrid_colour(dist_mem): cmap_fld_m => mesh_fld_m%get_colour_map()''' assert expected in gen expected = '''\ - ncolour_fld_c = mesh_fld_c%get_ncolours() - cmap_fld_c => mesh_fld_c%get_colour_map()''' + ncolour_cmap_fld_c = mesh_cmap_fld_c%get_ncolours() + cmap_cmap_fld_c => mesh_cmap_fld_c%get_colour_map()''' assert expected in gen assert "loop1_stop = ncolour_fld_m" in gen assert "loop2_stop" not in gen @@ -6259,20 +6259,20 @@ def test_intergrid_omp_parado(dist_mem, tmpdir): otrans.apply(loops[2]) otrans.apply(loops[5]) gen = str(psy.gen) - assert "loop4_stop = ncolour_fld_c" in gen + assert "loop4_stop = ncolour_cmap_fld_c" in gen assert (" DO colour=loop4_start,loop4_stop\n" " !$omp parallel do default(shared), private(cell), " "schedule(static)\n" in gen) if dist_mem: - assert ("last_halo_cell_all_colours_fld_c = " - "mesh_fld_c%get_last_halo_cell_all_colours()" in gen) - assert ("DO cell=loop5_start,last_halo_cell_all_colours_fld_c" + assert ("last_halo_cell_all_colours_cmap_fld_c = " + "mesh_cmap_fld_c%get_last_halo_cell_all_colours()" in gen) + assert ("DO cell=loop5_start,last_halo_cell_all_colours_cmap_fld_c" "(colour,1)\n" in gen) else: - assert ("last_edge_cell_all_colours_fld_c = mesh_fld_c%get_last_edge_" - "cell_all_colours()" in gen) - assert ("DO cell=loop5_start,last_edge_cell_all_colours_fld_c" + assert ("last_edge_cell_all_colours_cmap_fld_c = mesh_cmap_fld_c%" + "get_last_edge_cell_all_colours()" in gen) + assert ("DO cell=loop5_start,last_edge_cell_all_colours_cmap_fld_c" "(colour)\n" in gen) assert LFRicBuild(tmpdir).code_compiles(psy) @@ -6287,7 +6287,7 @@ def test_intergrid_omp_para_region1(dist_mem, tmpdir): ctrans = Dynamo0p3ColourTrans() ptrans = OMPParallelTrans() otrans = Dynamo0p3OMPLoopTrans() - # Colour the first loop (where 'fld_c' is the field on the coarse mesh) + # Colour the first loop (where 'cmap_fld_c' is the field on the coarse mesh) loops = schedule.walk(Loop) ctrans.apply(loops[0]) # Parallelise the loop over cells of a given colour @@ -6298,24 +6298,24 @@ def test_intergrid_omp_para_region1(dist_mem, tmpdir): ptrans.apply(dirs[0]) gen = str(psy.gen) if dist_mem: - assert ("last_halo_cell_all_colours_fld_c = mesh_fld_c%get_last_halo_" - "cell_all_colours()" in gen) - upper_bound = "last_halo_cell_all_colours_fld_c(colour,1)" + assert ("last_halo_cell_all_colours_cmap_fld_c = mesh_cmap_fld_c%" + "get_last_halo_cell_all_colours()" in gen) + upper_bound = "last_halo_cell_all_colours_cmap_fld_c(colour,1)" else: - assert ("last_edge_cell_all_colours_fld_c = mesh_fld_c%get_last_edge_" - "cell_all_colours()\n" in gen) - upper_bound = "last_edge_cell_all_colours_fld_c(colour)" - assert "loop0_stop = ncolour_fld_c\n" in gen + assert ("last_edge_cell_all_colours_cmap_fld_c = mesh_cmap_fld_c%" + "get_last_edge_cell_all_colours()\n" in gen) + upper_bound = "last_edge_cell_all_colours_cmap_fld_c(colour)" + assert "loop0_stop = ncolour_cmap_fld_c\n" in gen assert (f" DO colour=loop0_start,loop0_stop\n" f" !$omp parallel default(shared), private(cell)\n" f" !$omp do schedule(static)\n" f" DO cell=loop1_start,{upper_bound}\n" f" !\n" - f" CALL prolong_test_kernel_code(nlayers, cell_map_fld_c" - f"(:,:,cmap_fld_c(colour,cell)), ncpc_fld_m_fld_c_x, " - f"ncpc_fld_m_fld_c_y, ncell_fld_m, " - f"fld_m_proxy%data, fld_c_proxy%data, ndf_w1, undf_w1, map_w1, " - f"undf_w2, map_w2(:,cmap_fld_c(colour,cell)))\n" + f" CALL prolong_test_kernel_code(nlayers, " + f"cell_map_cmap_fld_c(:,:,cmap_cmap_fld_c(colour,cell)), " + f"ncpc_fld_m_cmap_fld_c_x, ncpc_fld_m_cmap_fld_c_y, ncell_fld_m, " + f"fld_m_proxy%data, cmap_fld_c_proxy%data, ndf_w1, undf_w1, " + f"map_w1, undf_w2, map_w2(:,cmap_cmap_fld_c(colour,cell)))\n" f" END DO\n" f" !$omp end do\n" f" !$omp end parallel\n" diff --git a/src/psyclone/tests/dynamo0p3_multigrid_test.py b/src/psyclone/tests/dynamo0p3_multigrid_test.py index 1273078239..7d84c194d8 100644 --- a/src/psyclone/tests/dynamo0p3_multigrid_test.py +++ b/src/psyclone/tests/dynamo0p3_multigrid_test.py @@ -522,23 +522,23 @@ def test_restrict_prolong_chain(tmpdir, dist_mem): if dist_mem: expected += ( " max_halo_depth_mesh_fld_m = mesh_fld_m%get_halo_depth()\n" - " mesh_fld_c => fld_c_proxy%vspace%get_mesh()\n" - " max_halo_depth_mesh_fld_c = mesh_fld_c%get_halo_depth()\n" + " mesh_cmap_fld_c => cmap_fld_c_proxy%vspace%get_mesh()\n" + " max_halo_depth_mesh_cmap_fld_c = mesh_cmap_fld_c%get_halo_depth()\n" ) else: - expected += " mesh_fld_c => fld_c_proxy%vspace%get_mesh()\n" + expected += " mesh_cmap_fld_c => cmap_fld_c_proxy%vspace%get_mesh()\n" expected += ( - " mmap_fld_m_fld_c => mesh_fld_c%get_mesh_map(mesh_fld_m)\n" - " cell_map_fld_c => mmap_fld_m_fld_c%get_whole_cell_map()\n") + " mmap_fld_m_cmap_fld_c => mesh_cmap_fld_c%get_mesh_map(mesh_fld_m)\n" + " cell_map_cmap_fld_c => mmap_fld_m_cmap_fld_c%get_whole_cell_map()\n") assert expected in output if dist_mem: expected = ( " ncell_fld_m = mesh_fld_m%get_last_halo_cell(depth=2)\n" - " ncpc_fld_m_fld_c_x = mmap_fld_m_fld_c%" + " ncpc_fld_m_cmap_fld_c_x = mmap_fld_m_cmap_fld_c%" "get_ntarget_cells_per_source_x()\n" - " ncpc_fld_m_fld_c_y = mmap_fld_m_fld_c%" + " ncpc_fld_m_cmap_fld_c_y = mmap_fld_m_cmap_fld_c%" "get_ntarget_cells_per_source_y()\n" " mesh_fld_f => fld_f_proxy%vspace%get_mesh()\n" " max_halo_depth_mesh_fld_f = mesh_fld_f%get_halo_depth()\n" @@ -552,9 +552,9 @@ def test_restrict_prolong_chain(tmpdir, dist_mem): else: expected = ( " ncell_fld_m = fld_m_proxy%vspace%get_ncell()\n" - " ncpc_fld_m_fld_c_x = mmap_fld_m_fld_c%get_ntarget_cells_" + " ncpc_fld_m_cmap_fld_c_x = mmap_fld_m_cmap_fld_c%get_ntarget_cells_" "per_source_x()\n" - " ncpc_fld_m_fld_c_y = mmap_fld_m_fld_c%get_ntarget_cells_" + " ncpc_fld_m_cmap_fld_c_y = mmap_fld_m_cmap_fld_c%get_ntarget_cells_" "per_source_y()\n" " mesh_fld_f => fld_f_proxy%vspace%get_mesh()\n" " mmap_fld_f_fld_m => mesh_fld_m%get_mesh_map(mesh_fld_f)\n" @@ -579,13 +579,13 @@ def test_restrict_prolong_chain(tmpdir, dist_mem): " CALL fld_m_proxy%halo_exchange(depth=1)\n" " END IF\n" " !\n" - " IF (fld_c_proxy%is_dirty(depth=1)) THEN\n" - " CALL fld_c_proxy%halo_exchange(depth=1)\n" + " IF (cmap_fld_c_proxy%is_dirty(depth=1)) THEN\n" + " CALL cmap_fld_c_proxy%halo_exchange(depth=1)\n" " END IF\n" " !\n" " DO cell=loop0_start,loop0_stop") assert expected in output - assert "loop0_stop = mesh_fld_c%get_last_halo_cell(1)\n" in output + assert "loop0_stop = mesh_cmap_fld_c%get_last_halo_cell(1)\n" in output # Since we loop into L1 halo of the coarse mesh, the L1 halo # of the fine(r) mesh will now be clean. Therefore, no halo # swap before the next prolongation required for fld_m @@ -631,19 +631,20 @@ def test_restrict_prolong_chain(tmpdir, dist_mem): " !\n" " CALL restrict_test_kernel_code") assert expected in output - assert "loop3_stop = mesh_fld_c%get_last_halo_cell(1)\n" in output + assert "loop3_stop = mesh_cmap_fld_c%get_last_halo_cell(1)\n" in output else: - assert "loop0_stop = fld_c_proxy%vspace%get_ncell()\n" in output + assert "loop0_stop = cmap_fld_c_proxy%vspace%get_ncell()\n" in output assert "loop1_stop = fld_m_proxy%vspace%get_ncell()\n" in output assert "loop2_stop = fld_m_proxy%vspace%get_ncell()\n" in output - assert "loop3_stop = fld_c_proxy%vspace%get_ncell()\n" in output + assert "loop3_stop = cmap_fld_c_proxy%vspace%get_ncell()\n" in output expected = ( " DO cell=loop0_start,loop0_stop\n" " !\n" - " CALL prolong_test_kernel_code(nlayers, cell_map_fld_c" - "(:,:,cell), ncpc_fld_m_fld_c_x, ncpc_fld_m_fld_c_y, ncell_fld_m, " - "fld_m_proxy%data, fld_c_proxy%data, ndf_w1, undf_w1, map_w1, " - "undf_w2, map_w2(:,cell))\n" + " CALL prolong_test_kernel_code(nlayers, " + "cell_map_cmap_fld_c(:,:,cell), ncpc_fld_m_cmap_fld_c_x, " + "ncpc_fld_m_cmap_fld_c_y, ncell_fld_m, fld_m_proxy%data, " + "cmap_fld_c_proxy%data, ndf_w1, undf_w1, map_w1, undf_w2, " + "map_w2(:,cell))\n" " END DO\n" " DO cell=loop1_start,loop1_stop\n" " !\n" @@ -662,11 +663,11 @@ def test_restrict_prolong_chain(tmpdir, dist_mem): " END DO\n" " DO cell=loop3_start,loop3_stop\n" " !\n" - " CALL restrict_test_kernel_code(nlayers, cell_map_fld_c" - "(:,:,cell), ncpc_fld_m_fld_c_x, ncpc_fld_m_fld_c_y, ncell_fld_m, " - "fld_c_proxy%data, fld_m_proxy%data, undf_aspc1_fld_c, " - "map_aspc1_fld_c(:,cell), ndf_aspc2_fld_m, undf_aspc2_fld_m, " - "map_aspc2_fld_m)\n") + " CALL restrict_test_kernel_code(nlayers, " + "cell_map_cmap_fld_c(:,:,cell), ncpc_fld_m_cmap_fld_c_x, " + "ncpc_fld_m_cmap_fld_c_y, ncell_fld_m, cmap_fld_c_proxy%data, " + "fld_m_proxy%data, undf_aspc1_cmap_fld_c, map_aspc1_cmap_fld_c" + "(:,cell), ndf_aspc2_fld_m, undf_aspc2_fld_m, map_aspc2_fld_m)\n") assert expected in output @@ -863,7 +864,8 @@ def test_restrict_prolong_chain_acc(tmpdir): if line.lstrip().startswith("!$acc enter data"): assert "(:,:,cell)" not in line assert "cmap(colour,cell)" not in line - assert "cmap_fld_c,cmap_fld_m," in line + assert ",cmap_cmap_fld_c," in line + assert ",cmap_fld_m," in line break # Check compilation assert LFRicBuild(tmpdir).code_compiles(psy) diff --git a/src/psyclone/tests/test_files/dynamo0p3/22.2_intergrid_3levels.f90 b/src/psyclone/tests/test_files/dynamo0p3/22.2_intergrid_3levels.f90 index c89802eb6e..3472fbcfb3 100644 --- a/src/psyclone/tests/test_files/dynamo0p3/22.2_intergrid_3levels.f90 +++ b/src/psyclone/tests/test_files/dynamo0p3/22.2_intergrid_3levels.f90 @@ -1,7 +1,7 @@ ! ----------------------------------------------------------------------------- ! BSD 3-Clause License ! -! Copyright (c) 2017-2020, Science and Technology Facilities Council +! Copyright (c) 2017-2023, Science and Technology Facilities Council ! All rights reserved. ! ! Redistribution and use in source and binary forms, with or without @@ -37,19 +37,21 @@ program restrict_prolong ! Description: invoke containing restrictions/prolongations where - ! fields swap roles (what was 'fine' becomes 'coarse') + ! fields swap roles (what was 'fine' becomes 'coarse'). Once of the fields is + ! also named so as to provoke a name clash with the standard name that + ! PSyclone would generate for a colour map. use field_mod, only: field_type use restrict_test_kernel_mod, only: restrict_test_kernel_type use prolong_test_kernel_mod, only: prolong_test_kernel_type implicit none - type(field_type) :: fld_f, fld_m, fld_c + type(field_type) :: fld_f, fld_m, cmap_fld_c - call invoke( & - prolong_test_kernel_type(fld_m, fld_c), & ! coarse -> medium - prolong_test_kernel_type(fld_f, fld_m), & ! medium -> fine - restrict_test_kernel_type(fld_m, fld_f), & ! fine -> medium - restrict_test_kernel_type(fld_c, fld_m) ) ! medium -> coarse + call invoke( & + prolong_test_kernel_type(fld_m, cmap_fld_c), & ! coarse -> medium + prolong_test_kernel_type(fld_f, fld_m), & ! medium -> fine + restrict_test_kernel_type(fld_m, fld_f), & ! fine -> medium + restrict_test_kernel_type(cmap_fld_c, fld_m) ) ! medium -> coarse end program restrict_prolong From fef0bccbe91c7d4b640b818069fc06cffb95ccfc Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Fri, 7 Jul 2023 16:17:37 +0100 Subject: [PATCH 12/15] #2189 fix failing test due to fld rename --- src/psyclone/tests/dependency_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psyclone/tests/dependency_test.py b/src/psyclone/tests/dependency_test.py index 35e539ba2a..2bc3c668f9 100644 --- a/src/psyclone/tests/dependency_test.py +++ b/src/psyclone/tests/dependency_test.py @@ -507,7 +507,7 @@ def test_lfric_operator(): psy.gen var_info = str(VariablesAccessInfo(invoke_info.schedule)) assert "f0: READ+WRITE" in var_info - assert "f1: READ" in var_info + assert "cmap: READ" in var_info assert "basis_w0_on_w0: READ" in var_info assert "diff_basis_w1_on_w0: READ" in var_info From 28d7ea80e14b181e909c28df3627f39cf25a0a43 Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Thu, 13 Jul 2023 14:06:50 +0100 Subject: [PATCH 13/15] #2189 rm unnecessary colour map init call --- src/psyclone/dynamo0p3.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/psyclone/dynamo0p3.py b/src/psyclone/dynamo0p3.py index 53a2523938..749bc59ad3 100644 --- a/src/psyclone/dynamo0p3.py +++ b/src/psyclone/dynamo0p3.py @@ -4234,7 +4234,6 @@ def initialise(self, parent): parent.add(CommentGen(parent, " Get the colourmap")) parent.add(CommentGen(parent, "")) # Look-up variable names for colourmap and number of colours - self._colourmap_init() colour_map = self._schedule.symbol_table.find_or_create_tag( "cmap").name ncolour = \ From 0432fa737474dfbf4cb0de95a2f0ec3ad18f75fe Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Wed, 16 Aug 2023 10:01:15 +0100 Subject: [PATCH 14/15] #2199 tidying for review --- src/psyclone/domain/lfric/kern_call_acc_arg_list.py | 2 +- src/psyclone/dynamo0p3.py | 1 - src/psyclone/tests/domain/lfric/kern_call_acc_arg_list_test.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py index f303b5f917..5759378c24 100644 --- a/src/psyclone/domain/lfric/kern_call_acc_arg_list.py +++ b/src/psyclone/domain/lfric/kern_call_acc_arg_list.py @@ -143,7 +143,7 @@ def stencil(self, arg, var_accesses=None): :type arg: :py:class:`psyclone.dynamo0p3.DynKernelArgument` :param var_accesses: optional VariablesAccessInfo instance to store the information about variable accesses. - :type var_accesses: [ + :type var_accesses: Optional[ :py:class:`psyclone.core.VariablesAccessInfo`] ''' diff --git a/src/psyclone/dynamo0p3.py b/src/psyclone/dynamo0p3.py index 1bfbfc5200..a89c969a58 100644 --- a/src/psyclone/dynamo0p3.py +++ b/src/psyclone/dynamo0p3.py @@ -1860,7 +1860,6 @@ def kern_args(self, stub=False, var_accesses=None, cell_name = "cell" if self._kernel.is_coloured(): colour_name = "colour" - #cmap_name = "cmap" cmap_name = self._symbol_table.find_or_create_tag( "cmap", root_name="cmap").name adj_face += (f"(:,{cmap_name}({colour_name}," diff --git a/src/psyclone/tests/domain/lfric/kern_call_acc_arg_list_test.py b/src/psyclone/tests/domain/lfric/kern_call_acc_arg_list_test.py index 0e366b0a8a..21892158f1 100644 --- a/src/psyclone/tests/domain/lfric/kern_call_acc_arg_list_test.py +++ b/src/psyclone/tests/domain/lfric/kern_call_acc_arg_list_test.py @@ -43,8 +43,8 @@ from psyclone.core import VariablesAccessInfo from psyclone.domain.lfric import FunctionSpace, KernCallAccArgList -from psyclone.errors import InternalError from psyclone.dynamo0p3 import DynKern +from psyclone.errors import InternalError from psyclone.parse.algorithm import parse from psyclone import psyGen from psyclone.tests.utilities import get_base_path, get_invoke From 56ad08344cbe243c1cb9609884cbe89194bca1c8 Mon Sep 17 00:00:00 2001 From: rupertford Date: Fri, 29 Sep 2023 15:29:27 +0100 Subject: [PATCH 15/15] pr #2199. Updated changelong ready for merge to master. --- changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog b/changelog index 45fff9fd58..0b7d34967c 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,7 @@ + 1) PR #2199 for #2189. fix bugs with missing maps in enter data + directive. + release 2.4.0 29th of September 2023 1) PR #1758 for #1741. Splits the PSyData read functionality into a