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

(closes #1010) Generate PSy-layers and Kernel Subs using PSyIR lowering (instead of gen_code/f2pygen) #2834

Open
wants to merge 113 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
bc49de6
#1010 Start converting LFRic PSy-layer declarations and initialisatio…
sergisiso Apr 9, 2024
a3e1b35
Merge remote-tracking branch 'origin/1495_type_bound_methods' into 10…
sergisiso Apr 14, 2024
e864bc2
#1010 Continue porting LFRic declarations and initialisations to PSyIR
sergisiso Apr 22, 2024
df68488
#1010 Pass one more test using backend declarations instead of f2pygen
sergisiso Apr 30, 2024
cd515be
#1010 Bring to master
sergisiso Apr 30, 2024
0b90f7b
#1010 More tests use backend declarations instead of f2pygen
sergisiso Apr 30, 2024
96c1aa6
#1010 More tests use backend declarations instead of f2pygen
sergisiso Apr 30, 2024
5c74c42
#1010 More tests use backend declarations instead of f2pygen, pass cu…
sergisiso May 3, 2024
e661950
#1010 More tests use backend declarations instead of f2pygen, and add…
sergisiso May 6, 2024
64a6bfd
#1010 More tests use backend declarations instead of f2pygen
sergisiso May 7, 2024
6c55316
#1010 Update dynamo0p3_basis test to the fortran backend syntax
sergisiso May 13, 2024
93f88f3
#1010 Start updating stub generation tests for new backend
sergisiso May 21, 2024
77fe7ff
#1010 Bring to master
sergisiso Jun 11, 2024
99ffbbe
Merge remote-tracking branch 'origin/1010_remaining_lfric_lowering' i…
sergisiso Jun 11, 2024
99422e6
#1010 Fix tests in psyir
sergisiso Jun 18, 2024
9be02af
Merge remote-tracking branch 'origin/master' into 1010_remaining_lfri…
sergisiso Jun 18, 2024
2481022
#1010 Fix tests in psyir introduced by lastest update to master
sergisiso Jun 18, 2024
decd073
#1010 Merge master and refactored builtin tests
sergisiso Jul 2, 2024
0e05a0b
#1010 Fix output syntax in gocean opencl trans tests
sergisiso Jul 2, 2024
ef34fa1
#1010 Start updating dynamo0p3_transformations_test to check output w…
sergisiso Jul 2, 2024
62e41e5
#1010 Update more dynamo0p3_transformations_test test to use the psyi…
sergisiso Jul 4, 2024
8908239
#1010 Update more dynamo0p3_transformations_test test to use the psyi…
sergisiso Jul 10, 2024
930ddb9
#1010 Bring to master
sergisiso Jul 18, 2024
a2942f1
#1010 Fix some issues introduced due to previous merge with master
sergisiso Jul 19, 2024
cf63302
#1010 Fix issues with reference_element
sergisiso Jul 19, 2024
3d8969c
#1010 Start porting reductions to generic PSyIR
sergisiso Jul 19, 2024
98a899c
#1010 Remove file mistakenly introduced when brining the branch to ma…
sergisiso Jul 19, 2024
ddef4de
#1010 Move LFRic reductions to OpenMP classes
sergisiso Jul 24, 2024
b697236
#1010 Bring to master
sergisiso Jul 25, 2024
6ab2c8c
#1010 Modifications to pass more LFRic OpenMP reduction tests
sergisiso Jul 25, 2024
bbb31da
#1010 Modify the starting kernels comment in the invoke schedule
sergisiso Jul 25, 2024
6bf1383
#1010 Fix more LFRic OpenMP tests
sergisiso Jul 25, 2024
6787c5e
#1010 Fix a few more LFRic tests using the PSyIR backend
sergisiso Jul 25, 2024
960855f
#1010 Update more lfric transformations tests
sergisiso Aug 2, 2024
0d0d8e3
#1010 Continue fixing lfric tests after switching to PSyIR backend
sergisiso Aug 2, 2024
0cdb879
#1010 Fix more LFRic test syntax to match Fortran backend
sergisiso Aug 5, 2024
4c74023
Merge remote-tracking branch 'origin/master' into 1010_remaining_lfri…
sergisiso Aug 5, 2024
5c08043
#1010 Continue porting LFRic to PSyIR backend
sergisiso Aug 9, 2024
35180f8
Merge remote-tracking branch 'origin/master' into 1010_remaining_lfri…
sergisiso Aug 9, 2024
2a556b2
#1010 Fix more LFRic tests
sergisiso Aug 13, 2024
990afa5
#1010 Fix LFRic stencil tests for PSyIR backend
sergisiso Aug 14, 2024
46eee5c
Merge remote-tracking branch 'origin/master' into 1010_remaining_lfri…
sergisiso Aug 14, 2024
d3dab2d
#1010 Fix LFRic stencil stubs tests for PSyIR backend
sergisiso Aug 15, 2024
3ac82c5
#1010 LFRic uses wildcard import for constants_mod
sergisiso Aug 15, 2024
e8bfe66
#1010 Fix more LFRic tests for PSyIR backend
sergisiso Aug 15, 2024
d83f380
Merge remote-tracking branch 'origin/master' into 1010_remaining_lfri…
sergisiso Sep 12, 2024
8183b8a
1010 Fix test after moving LFRic to use the new backend
sergisiso Sep 12, 2024
55a4eaa
1010 Set LFRic loop bounds during lowering bounds initialisation
sergisiso Sep 16, 2024
225d346
1010 Fix some LFRic stub tests
sergisiso Sep 16, 2024
17f6749
1010 Fix more tests after switching to new PSyIR backend
sergisiso Sep 16, 2024
84f96e3
1010 Fix tests after moving LFRic to use the new backend
sergisiso Sep 16, 2024
c9938f3
1010 Fix psydata tests (except loop bounds and a few driver creator t…
sergisiso Sep 18, 2024
50ad16c
1010 Fix more LFRic tests
sergisiso Sep 18, 2024
3cc4589
1010 Fix LFRic quadrature tests
sergisiso Sep 19, 2024
c719f11
1010 Use generic symbol table in LFRic and fix more tests
sergisiso Sep 24, 2024
f0c87d2
1010 Fix more LFRic tests
sergisiso Sep 24, 2024
d398ed2
1010 Fix more LFRic tests and start updating mesh map code
sergisiso Sep 25, 2024
2a3fe85
#1010 Bring to master
sergisiso Oct 4, 2024
b0d5e98
#1010 Update more LFRic test to new backend
sergisiso Oct 4, 2024
009006f
#1010 Fix more LFRic test for the new backend
sergisiso Oct 5, 2024
14e0b23
#1010 Fix more LFRic test for the new backend
sergisiso Oct 5, 2024
eee5c9c
#1010 Do not store InvokeSchedules and SymbolTables inside other classes
sergisiso Oct 9, 2024
e3d2f2e
#1010 Fix issues with compilation tests
sergisiso Oct 12, 2024
501655a
#1010 Start cleaning up PR
sergisiso Oct 12, 2024
82d8706
#1010 Bring the failing tests down to 0 again (but some with xfails/e…
sergisiso Oct 14, 2024
a5c50fd
#1010 Bring the failing tests down to 0 again (but some with xfails/e…
sergisiso Oct 14, 2024
b134171
#2730 Generalise acc_parallel lfric script to also accept openmp dire…
sergisiso Oct 2, 2024
300afee
#2730 Add gen_code support for OpenMP target directives
sergisiso Oct 2, 2024
08e9221
#2730 Fix issues with LFRic OMP offloading and add it to the integrat…
sergisiso Oct 3, 2024
a0d5e2f
#2730 Fix CI failures
sergisiso Oct 3, 2024
0fb3098
#2730 Add tests for missing code coverage
sergisiso Oct 3, 2024
1f97c15
#2730 Update LFRic offloading envvar and fix comments and docstrings
sergisiso Oct 7, 2024
cfcc44d
#2730 Fix lfric nvfortran.mk syntax
sergisiso Oct 7, 2024
39c3037
#2733 update UG and changelog
arporter Oct 8, 2024
9edd419
Sorted the fspaces in the LFRic algorithm generation
DrTVockerodtMO Oct 10, 2024
298fa90
Added my name to modified by list
DrTVockerodtMO Oct 10, 2024
ea78b6f
Modified test to check for correct function space ordering
DrTVockerodtMO Oct 10, 2024
cf32395
Made the test use a shuffled input
DrTVockerodtMO Oct 10, 2024
9558dc4
#2743 update changelog and UG
arporter Oct 11, 2024
43a0e83
#1010 Restore missing set halo dirty comment
sergisiso Oct 14, 2024
d1ab352
#1010 Bring to master
sergisiso Oct 14, 2024
7cae96a
#1010 Start cleaning up PR
sergisiso Oct 14, 2024
ecd20d3
#1010 Cleaning up PR
sergisiso Oct 14, 2024
b81e2ed
#1010 Cleaning up PR
sergisiso Oct 14, 2024
b3a3d82
#1010 Bring to master
sergisiso Nov 1, 2024
dbac36c
#1010 Bring to master
sergisiso Nov 12, 2024
5a7b0a6
1010 Bring to master (with issues)
sergisiso Nov 17, 2024
36af0bf
#1010 Bring to master
sergisiso Dec 20, 2024
abc2feb
#1010 Fix flake8 errors
sergisiso Dec 20, 2024
0ffbb70
#1010 Fix some issues with the LFRic HaloEx tests
sergisiso Dec 29, 2024
65afad9
#1010 Fix remaining issues with LFRic lowering backend
sergisiso Dec 29, 2024
c754874
#1010 Clean up old comments and improve docstrings
sergisiso Dec 29, 2024
713a758
#1010 Fix compilation errors
sergisiso Dec 29, 2024
bbf58ab
#1010 Fix example and resolve some fixmes
sergisiso Dec 29, 2024
f3d3574
#1010 Temporary disable lfric psydata compilation
sergisiso Dec 30, 2024
b7cb593
#1010 Revert skipped example/tutorial and remove some unused code
sergisiso Dec 30, 2024
7d3ab2a
#1010 Remove unused code
sergisiso Dec 30, 2024
b9a64c1
#1010 Fix test
sergisiso Dec 30, 2024
9ff9eae
Merge remote-tracking branch 'origin/master' into 1010_remaining_lfri…
sergisiso Dec 30, 2024
dc1c142
#1010 Fix merge issue
sergisiso Dec 30, 2024
3ab9c4d
#1010 Fix flake8 issues
sergisiso Dec 30, 2024
852a826
#1010 Improve test coverage and fix integration test issue
sergisiso Dec 31, 2024
1dd394e
#1010 Remove some more old code and fix tests
sergisiso Jan 6, 2025
5d7d712
#1010 Do not generate th_idx and nthreads variables when not needed
sergisiso Jan 6, 2025
5dc9ec0
#1010 Fix some xfail tests
sergisiso Jan 9, 2025
e90cbcf
Merge remote-tracking branch 'origin/master' into 1010_remaining_lfri…
sergisiso Jan 12, 2025
3a4b983
#1010 Resolve some issues with psy_data
sergisiso Jan 22, 2025
3a18bb3
#1010 Move LFRic loop_start/stop symbols at the beginning
sergisiso Jan 22, 2025
cd18e86
#1010 Remove NOT_INITIALISED integer literals
sergisiso Jan 22, 2025
6ddb65e
Merge remote-tracking branch 'origin/master' into 1010_remaining_lfri…
sergisiso Jan 23, 2025
c345f0a
#1010 Clean up psy_data_node
sergisiso Jan 23, 2025
9ec3f54
#1010 Convert some array types to pointers
sergisiso Jan 23, 2025
57db171
#1010 Clean up PR
sergisiso Jan 23, 2025
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
4 changes: 2 additions & 2 deletions doc/user_guide/psyke.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ PSyclone modifies the Schedule of the selected ``invoke_0``:
Schedule[invoke='invoke_0' dm=False]
0: Loop[type='dofs',field_space='any_space_1',it_space='dofs',
upper_bound='ndofs']
Literal[value:'NOT_INITIALISED']
Literal[value:'NOT_INITIALISED']
Reference[name:'loop0_start']
Reference[name:'loop0_stop']
Literal[value:'1']
Schedule[]
0: BuiltIn setval_c(f5,0.0)
Expand Down
8 changes: 4 additions & 4 deletions examples/lfric/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,14 @@ Kernel call 'matrix_vector_code' was found in
InvokeSchedule[invoke='invoke_0', dm=False]
...
Loop[type='', field_space='any_space_1', it_space='cells', upper_bound='ncells']
Literal[value:'NOT_INITIALISED']
Literal[value:'NOT_INITIALISED']
Reference[name:'loop0_start']
Reference[name:'loop0_stop']
Literal[value:'1']
Schedule[]
CodedKern matrix_vector_kernel_code(m_lumped,ones,mb) [module_inline=False]
Loop[type='dofs', field_space='any_space_1', it_space='dofs', upper_bound='ndofs']
Literal[value:'NOT_INITIALISED']
Literal[value:'NOT_INITIALISED']
Reference[name:'loop1_start']
Reference[name:'loop1_stop']
Literal[value:'1']
Schedule[]
BuiltIn x_divideby_y(self_mb_lumped_inv,ones,m_lumped)
Expand Down
1 change: 0 additions & 1 deletion src/psyclone/core/access_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

'''This module implements the AccessType used throughout PSyclone.'''

from __future__ import print_function, absolute_import
from enum import Enum
from psyclone.configuration import Config

Expand Down
2 changes: 0 additions & 2 deletions src/psyclone/core/component_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@

'''This module provides a class to manage indices in variable accesses.'''

from __future__ import print_function, absolute_import


from psyclone.errors import InternalError

Expand Down
48 changes: 29 additions & 19 deletions src/psyclone/domain/lfric/arg_ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
MetadataToArgumentsRules)
from psyclone.errors import GenerationError, InternalError
from psyclone.psyir.nodes import ArrayReference, Reference
from psyclone.psyir.symbols import ScalarType
from psyclone.psyir.symbols import DataSymbol, ArrayType


class ArgOrdering:
Expand Down Expand Up @@ -102,10 +102,11 @@ def _symtab(self):
'''
if self._forced_symtab:
return self._forced_symtab
elif self._kern and self._kern.ancestor(psyGen.InvokeSchedule):
return self._kern.ancestor(psyGen.InvokeSchedule).symbol_table
else:
return LFRicSymbolTable()
if self._kern and self._kern.ancestor(psyGen.InvokeSchedule):
# _kern may be outdated, so go back up to the invoke first
current_invoke = self._kern.ancestor(psyGen.InvokeSchedule).invoke
return current_invoke.schedule.symbol_table
return LFRicSymbolTable()

def psyir_append(self, node):
'''Appends a PSyIR node to the PSyIR argument list.
Expand Down Expand Up @@ -197,13 +198,17 @@ def append_integer_reference(self, name, tag=None):
:rtype: :py:class:`psyclone.psyir.symbols.Symbol`

'''
# pylint: disable=import-outside-toplevel
from psyclone.domain.lfric import LFRicTypes
if tag is None:
tag = name
sym = self._symtab.find_or_create_integer_symbol(name, tag)
sym = self._symtab.find_or_create(
name, tag=tag, symbol_type=DataSymbol,
datatype=LFRicTypes("LFRicIntegerScalarDataType")())
self.psyir_append(Reference(sym))
return sym

def get_array_reference(self, array_name, indices, intrinsic_type,
def get_array_reference(self, array_name, indices, intrinsic_type=None,
tag=None, symbol=None):
# pylint: disable=too-many-arguments
'''This function creates an array reference. If there is no symbol
Expand All @@ -215,9 +220,10 @@ def get_array_reference(self, array_name, indices, intrinsic_type,
:param indices: the indices to be used in the PSyIR reference. It \
must either be ":", or a PSyIR node.
:type indices: List[Union[str, py:class:`psyclone.psyir.nodes.Node`]]
:param intrinsic_type: the intrinsic type of the array.
:param intrinsic_type: the intrinsic type of the array. Defaults to
LFRicIntegerScalarDataType.
:type intrinsic_type: \
:py:class:`psyclone.psyir.symbols.datatypes.ScalarType.Intrinsic`
Optional[:py:class:`psyclone.psyir.symbols.datatypes.ScalarType`]
:param tag: optional tag for the symbol.
:type tag: Optional[str]
:param symbol: optional the symbol to use.
Expand All @@ -229,11 +235,17 @@ def get_array_reference(self, array_name, indices, intrinsic_type,
'''
if not tag:
tag = array_name
if intrinsic_type is None:
# pylint: disable=import-outside-toplevel
from psyclone.domain.lfric import LFRicTypes
intrinsic_type = LFRicTypes("LFRicIntegerScalarDataType")()

if not symbol:
symbol = self._symtab.find_or_create_array(array_name,
len(indices),
intrinsic_type,
tag)
symbol = self._symtab.find_or_create(
array_name, tag=tag, symbol_type=DataSymbol,
datatype=ArrayType(
intrinsic_type,
[ArrayType.Extent.DEFERRED for _ in indices]))
else:
if symbol.name != array_name:
raise InternalError(f"Specified symbol '{symbol.name}' has a "
Expand All @@ -248,7 +260,7 @@ def get_array_reference(self, array_name, indices, intrinsic_type,
ref = ArrayReference.create(symbol, indices)
return ref

def append_array_reference(self, array_name, indices, intrinsic_type,
def append_array_reference(self, array_name, indices, intrinsic_type=None,
tag=None, symbol=None):
# pylint: disable=too-many-arguments
'''This function adds an array reference. If there is no symbol with
Expand All @@ -263,7 +275,7 @@ def append_array_reference(self, array_name, indices, intrinsic_type,
:type indices: List[Union[str, py:class:`psyclone.psyir.nodes.Node`]]
:param intrinsic_type: the intrinsic type of the array.
:type intrinsic_type: \
:py:class:`psyclone.psyir.symbols.datatypes.ScalarType.Intrinsic`
Optional[:py:class:`psyclone.psyir.symbols.datatypes.ScalarType`]
:param tag: optional tag for the symbol.
:type tag: Optional[str]
:param symbol: optional the symbol to use.
Expand Down Expand Up @@ -912,8 +924,7 @@ def banded_dofmap(self, function_space, var_accesses=None):
# to the argument list as they are mandatory for every function
# space that appears in the meta-data.
sym = self.append_array_reference(
function_space.cbanded_map_name, indices=[":", ":"],
intrinsic_type=ScalarType.Intrinsic.INTEGER)
function_space.cbanded_map_name, indices=[":", ":"])
self.append(sym.name, var_accesses)

def indirection_dofmap(self, function_space, operator=None,
Expand All @@ -934,8 +945,7 @@ def indirection_dofmap(self, function_space, operator=None,
'''
# pylint: disable=unused-argument
map_name = function_space.cma_indirection_map_name
self.append_array_reference(map_name, [":"],
ScalarType.Intrinsic.INTEGER, tag=map_name)
self.append_array_reference(map_name, [":"], tag=map_name)
self.append(map_name, var_accesses)

def ref_element_properties(self, var_accesses=None):
Expand Down
93 changes: 51 additions & 42 deletions src/psyclone/domain/lfric/kern_call_arg_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
ArrayReference, Reference, StructureReference)
from psyclone.psyir.symbols import (
DataSymbol, DataTypeSymbol, UnresolvedType, ContainerSymbol,
ImportInterface, ScalarType)
ImportInterface, ScalarType, ArrayType, UnsupportedFortranType)

# psyir has classes created at runtime
# pylint: disable=no-member
Expand Down Expand Up @@ -138,9 +138,9 @@ def get_user_type(self, module_name, user_type, name, tag=None):
interface=ImportInterface(module))
# Declare the actual user symbol in the local symbol table, using
# the datatype from the root table:
sym = self._symtab.new_symbol(name, tag=tag,
symbol_type=DataSymbol,
datatype=user_type_symbol)
sym = self._symtab.find_or_create(name, tag=tag,
symbol_type=DataSymbol,
datatype=user_type_symbol)
return sym

def append_structure_reference(self, module_name, user_type, member_list,
Expand Down Expand Up @@ -207,8 +207,7 @@ def cell_map(self, var_accesses=None):

# Add the cell map to our argument list
cell_ref_name, cell_ref = self.cell_ref_name(var_accesses)
sym = self.append_array_reference(base_name, [":", ":", cell_ref],
ScalarType.Intrinsic.INTEGER)
sym = self.append_array_reference(base_name, [":", ":", cell_ref])
self.append(f"{sym.name}(:,:,{cell_ref_name})",
var_accesses=var_accesses, var_access_name=sym.name)

Expand Down Expand Up @@ -426,7 +425,6 @@ def stencil_unknown_extent(self, arg, var_accesses=None):
var_sym = LFRicStencils.dofmap_size_symbol(self._symtab, arg)
cell_name, cell_ref = self.cell_ref_name(var_accesses)
self.append_array_reference(var_sym.name, [cell_ref],
ScalarType.Intrinsic.INTEGER,
symbol=var_sym)
self.append(f"{var_sym.name}({cell_name})", var_accesses,
var_access_name=var_sym.name)
Expand All @@ -451,7 +449,6 @@ def stencil_2d_unknown_extent(self, arg, var_accesses=None):
var_sym = LFRicStencils.dofmap_size_symbol(self._symtab, arg)
cell_name, cell_ref = self.cell_ref_name(var_accesses)
self.append_array_reference(var_sym.name, [":", cell_ref],
ScalarType.Intrinsic.INTEGER,
symbol=var_sym)
name = f"{var_sym.name}(:,{cell_name})"
self.append(name, var_accesses, var_access_name=var_sym.name)
Expand Down Expand Up @@ -523,7 +520,6 @@ def stencil(self, arg, var_accesses=None):
var_sym = LFRicStencils.dofmap_symbol(self._symtab, arg)
cell_name, cell_ref = self.cell_ref_name(var_accesses)
self.append_array_reference(var_sym.name, [":", ":", cell_ref],
ScalarType.Intrinsic.INTEGER,
symbol=var_sym)
self.append(f"{var_sym.name}(:,:,{cell_name})", var_accesses,
var_access_name=var_sym.name)
Expand Down Expand Up @@ -556,7 +552,6 @@ def stencil_2d(self, arg, var_accesses=None):
cell_name, cell_ref = self.cell_ref_name(var_accesses)
self.append_array_reference(var_sym.name,
[":", ":", ":", cell_ref],
ScalarType.Intrinsic.INTEGER,
symbol=var_sym)
name = f"{var_sym.name}(:,:,:,{cell_name})"
self.append(name, var_accesses, var_access_name=var_sym.name)
Expand Down Expand Up @@ -639,17 +634,26 @@ def fs_compulsory_field(self, function_space, var_accesses=None):
self.append(sym.name, var_accesses)

map_name = function_space.map_name
intrinsic_type = LFRicTypes("LFRicIntegerScalarDataType")()
dtype = UnsupportedFortranType(
f"{intrinsic_type.intrinsic.name}("
f"kind={intrinsic_type.precision.name}), pointer, "
f"dimension(:,:) :: {map_name} => null()",
partial_datatype=ArrayType(
intrinsic_type,
[ArrayType.Extent.DEFERRED, ArrayType.Extent.DEFERRED]))
sym = self._symtab.find_or_create_tag(
map_name, symbol_type=DataSymbol, datatype=dtype)

if self._kern.iterates_over == 'domain':
# This kernel takes responsibility for iterating over cells so
# pass the whole dofmap.
sym = self.append_array_reference(map_name, [":", ":"],
ScalarType.Intrinsic.INTEGER)
self.append_array_reference(map_name, [":", ":"], symbol=sym)
self.append(sym.name, var_accesses, var_access_name=sym.name)
else:
# Pass the dofmap for the cell column
cell_name, cell_ref = self.cell_ref_name(var_accesses)
sym = self.append_array_reference(map_name, [":", cell_ref],
ScalarType.Intrinsic.INTEGER)
self.append_array_reference(map_name, [":", cell_ref], symbol=sym)
self.append(f"{sym.name}(:,{cell_name})",
var_accesses, var_access_name=sym.name)

Expand All @@ -675,8 +679,7 @@ def fs_intergrid(self, function_space, var_accesses=None):
sym = self.append_integer_reference(function_space.undf_name)
self.append(sym.name, var_accesses)
map_name = function_space.map_name
sym = self.append_array_reference(map_name, [":", ":"],
ScalarType.Intrinsic.INTEGER)
sym = self.append_array_reference(map_name, [":", ":"])
self.append(sym.name, var_accesses)
else:
# For the coarse mesh we only need undf and the dofmap for
Expand All @@ -699,8 +702,10 @@ def basis(self, function_space, var_accesses=None):
'''
for rule in self._kern.qr_rules.values():
basis_name = function_space.get_basis_name(qr_var=rule.psy_name)
sym = self.append_array_reference(basis_name, [":", ":", ":", ":"],
ScalarType.Intrinsic.REAL)
sym = self.append_array_reference(
basis_name, [":", ":", ":", ":"],
LFRicTypes("LFRicRealScalarDataType")()
)
self.append(sym.name, var_accesses)

if "gh_evaluator" in self._kern.eval_shapes:
Expand All @@ -712,8 +717,7 @@ def basis(self, function_space, var_accesses=None):
# function space
fspace = self._kern.eval_targets[fs_name][0]
basis_name = function_space.get_basis_name(on_space=fspace)
sym = self.append_array_reference(basis_name, [":", ":", ":"],
ScalarType.Intrinsic.REAL)
sym = self.append_array_reference(basis_name, [":", ":", ":"])
self.append(sym.name, var_accesses)

def diff_basis(self, function_space, var_accesses=None):
Expand All @@ -733,9 +737,11 @@ def diff_basis(self, function_space, var_accesses=None):
for rule in self._kern.qr_rules.values():
diff_basis_name = function_space.get_diff_basis_name(
qr_var=rule.psy_name)
sym = self.append_array_reference(diff_basis_name,
[":", ":", ":", ":"],
ScalarType.Intrinsic.REAL)
sym = self.append_array_reference(
diff_basis_name,
[":", ":", ":", ":"],
LFRicTypes("LFRicRealScalarDataType")()
)
self.append(sym.name, var_accesses)

if "gh_evaluator" in self._kern.eval_shapes:
Expand All @@ -748,9 +754,10 @@ def diff_basis(self, function_space, var_accesses=None):
fspace = self._kern.eval_targets[fs_name][0]
diff_basis_name = function_space.get_diff_basis_name(
on_space=fspace)
sym = self.append_array_reference(diff_basis_name,
[":", ":", ":"],
ScalarType.Intrinsic.REAL)
sym = self.append_array_reference(
diff_basis_name,
[":", ":", ":"],
LFRicTypes("LFRicRealScalarDataType")())
self.append(sym.name, var_accesses)

def field_bcs_kernel(self, function_space, var_accesses=None):
Expand Down Expand Up @@ -784,8 +791,7 @@ def field_bcs_kernel(self, function_space, var_accesses=None):
f"{self._kern.name} but got '{farg.argument_type}'")

base_name = "boundary_dofs_" + farg.name
sym = self.append_array_reference(base_name, [":", ":"],
ScalarType.Intrinsic.INTEGER)
sym = self.append_array_reference(base_name, [":", ":"])
self.append(sym.name, var_accesses)

def operator_bcs_kernel(self, function_space, var_accesses=None):
Expand All @@ -805,8 +811,7 @@ def operator_bcs_kernel(self, function_space, var_accesses=None):
# Checks for this are performed in ArgOrdering.generate()
op_arg = self._kern.arguments.args[0]
base_name = "boundary_dofs_" + op_arg.name
sym = self.append_array_reference(base_name, [":", ":"],
ScalarType.Intrinsic.INTEGER)
sym = self.append_array_reference(base_name, [":", ":"])
self.append(sym.name, var_accesses)

def mesh_properties(self, var_accesses=None):
Expand Down Expand Up @@ -877,14 +882,14 @@ def quad_rule(self, var_accesses=None):
self.append_integer_reference(arg)
elif generic_name in ["weights_xy", "weights_z"]:
# 1d arrays:
# TODO # 1910: These should be pointers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this TODO incorrect - i.e. it's fine that they aren't pointers? Can #1910 be closed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, as this is the kernel-call argument list I suppose we don't care whether or not they are pointers as we just need References?

self.append_array_reference(arg, [":"],
ScalarType.Intrinsic.REAL)
self.append_array_reference(
arg, [":"],
LFRicTypes("LFRicRealScalarDataType")())
elif generic_name in ["weights_xyz"]:
# 2d arrays:
# TODO #1910: These should be pointers
self.append_array_reference(arg, [":", ":"],
ScalarType.Intrinsic.REAL)
self.append_array_reference(
arg, [":", ":"],
LFRicTypes("LFRicRealScalarDataType")())
else:
raise InternalError(f"Found invalid kernel argument "
f"'{arg}'.")
Expand Down Expand Up @@ -970,11 +975,15 @@ def cell_ref_name(self, var_accesses=None):
# 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,
tag=tag)
symbol = self._symtab.find_or_create(
self._kern.colourmap.name, symbol_type=DataSymbol,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused here. self._kern.colourmap is a call to LFRicKern.colourmap and that returns a Symbol. Perhaps it's not in the right table or perhaps symbol ends up being that same symbol? While I'm here, the docstring for LFRicKern.colourmap says it returns a str but it in fact it returns a Symbol. It's not the fault of this PR but would you mind fixing it?

datatype=ArrayType(
LFRicTypes("LFRicIntegerScalarDataType")(),
[ArrayType.Extent.DEFERRED, ArrayType.Extent.DEFERRED]),
tag=tag)
array_ref = ArrayReference.create(
symbol,
[Reference(colour_sym), Reference(cell_sym)])
if var_accesses is not None:
var_accesses.add_access(Signature(colour_sym.name),
AccessType.READ, self._kern)
Expand All @@ -984,7 +993,7 @@ def cell_ref_name(self, var_accesses=None):
AccessType.READ,
self._kern, ["colour", "cell"])

return (self._kern.colourmap + "(colour,cell)",
return (self._kern.colourmap.name + "(colour,cell)",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this now be array_ref.debug_string() or (better) use the FortranWriter?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it should also have a TODO as this will need cleaning up somehow.

array_ref)

if var_accesses is not None:
Expand Down
Loading
Loading