Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
1 change: 0 additions & 1 deletion src/psyclone/domain/lfric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
from psyclone.domain.lfric.lfric_cell_iterators import LFRicCellIterators
from psyclone.domain.lfric.lfric_driver_creator import \
LFRicDriverCreator
from psyclone.domain.lfric.lfric_symbol_table import LFRicSymbolTable
from psyclone.domain.lfric.lfric_types import LFRicTypes
from psyclone.domain.lfric.kern_stub_arg_list import KernStubArgList
from psyclone.domain.lfric.lfric_invoke import LFRicInvoke
Expand Down
14 changes: 5 additions & 9 deletions src/psyclone/domain/lfric/algorithm/lfric_alg.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'''

from psyclone.domain.lfric import (KernCallInvokeArgList, LFRicConstants,
LFRicSymbolTable, LFRicTypes)
LFRicTypes)
from psyclone.domain.lfric.algorithm.psyir import (
LFRicAlgorithmInvokeCall, LFRicBuiltinFunctorFactory, LFRicKernelFunctor)
from psyclone.domain.lfric import LFRicKern
Expand All @@ -52,7 +52,7 @@
from psyclone.parse.utils import ParseError
from psyclone.psyir.frontend.fortran import FortranReader
from psyclone.psyir.nodes import (Assignment, Container, Literal,
Reference, Routine, ScopingNode)
Reference, Routine)
from psyclone.psyir.symbols import (
UnresolvedType, UnsupportedFortranType, DataTypeSymbol, DataSymbol,
ArrayType, ImportInterface, ContainerSymbol, RoutineSymbol,
Expand Down Expand Up @@ -130,7 +130,7 @@ def create_from_kernel(self, name, kernel_path):
# arbitrary value, we use an *integer* literal for this, irrespective
# of the actual type of the scalar argument. The compiler/run-time will
# take care of appropriate type casting.
table.add_lfric_precision_symbol("i_def")
LFRicTypes.add_precision_symbol(table, "i_def")
for sym in kern_args.scalars:
sub.addchild(Assignment.create(
Reference(sym),
Expand All @@ -143,7 +143,7 @@ def create_from_kernel(self, name, kernel_path):
# integer rather than real) we rely on type casting by the
# compiler/run-time.
factory = LFRicBuiltinFunctorFactory.get()
table.add_lfric_precision_symbol("r_def")
LFRicTypes.add_precision_symbol(table, "r_def")
kernel_list = []
for sym, _ in kern_args.fields:
kernel_list.append(
Expand Down Expand Up @@ -188,10 +188,6 @@ def create_alg_routine(name):
if not isinstance(name, str):
raise TypeError(f"Supplied routine name must be a str but got "
f"'{type(name).__name__}'")
# Make sure the scoping node creates LFRicSymbolTables
# pylint: disable=protected-access
# TODO #1954 Remove the protected access using a factory
ScopingNode._symbol_table_class = LFRicSymbolTable
alg_sub = Routine.create(name)
table = alg_sub.symbol_table

Expand Down Expand Up @@ -319,7 +315,7 @@ def initialise_field(prog, sym, space):
'''
reader = FortranReader()

prog.symbol_table.add_lfric_precision_symbol("i_def")
LFRicTypes.add_precision_symbol(prog.symbol_table, "i_def")

if isinstance(sym.datatype, DataTypeSymbol):
# Single field argument.
Expand Down
5 changes: 2 additions & 3 deletions src/psyclone/domain/lfric/arg_ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@
# The next two imports cannot be merged, since this would create
# a circular dependency.
from psyclone.domain.lfric import LFRicConstants
from psyclone.domain.lfric.lfric_symbol_table import LFRicSymbolTable
from psyclone.domain.lfric.metadata_to_arguments_rules import (
MetadataToArgumentsRules)
from psyclone.errors import GenerationError, InternalError
from psyclone.psyir.nodes import ArrayReference, Reference
from psyclone.psyir.symbols import DataSymbol, ArrayType
from psyclone.psyir.symbols import DataSymbol, ArrayType, SymbolTable


class ArgOrdering:
Expand Down Expand Up @@ -106,7 +105,7 @@ def _symtab(self):
# _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()
return SymbolTable()

def psyir_append(self, node):
'''Appends a PSyIR node to the PSyIR argument list.
Expand Down
27 changes: 16 additions & 11 deletions src/psyclone/domain/lfric/kern_call_arg_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def get_user_type(self, module_name: str,
mod_sym_tab = self._symtab

# The user-defined type must be declared in the same symbol
# table as the container (otherwise errors will happen later):
# table as the container.
user_type_symbol = mod_sym_tab.find_or_create(
user_type,
symbol_type=DataTypeSymbol,
Expand Down Expand Up @@ -380,8 +380,9 @@ def field_vector(self, argvect,
f"{argvect.name}_{idx}:{suffix}")
if self._kern.iterates_over == "dof":
# If dof kernel, add access to the field by dof ref
dof_sym = self._symtab.find_or_create_integer_symbol(
"df", tag="dof_loop_idx")
dof_sym = self._symtab.find_or_create(
"df", tag="dof_loop_idx", symbol_type=DataSymbol,
datatype=LFRicTypes("LFRicIntegerScalarDataType")())
# TODO #1010 removes the need to declare type and
# allows this to be fixed
self.append_array_reference(cmpt_sym.name,
Expand Down Expand Up @@ -418,8 +419,9 @@ def field(self, arg, var_accesses: Optional[VariablesAccessMap] = None):

if self._kern.iterates_over == "dof":
# If dof kernel, add access to the field by dof ref
dof_sym = self._symtab.find_or_create_integer_symbol(
"df", tag="dof_loop_idx")
dof_sym = self._symtab.find_or_create(
"df", tag="dof_loop_idx", symbol_type=DataSymbol,
datatype=LFRicTypes("LFRicIntegerScalarDataType")())
# TODO #1010 removes the need to declare type and
# allows this to be fixed
self.append_array_reference(sym.name, [Reference(dof_sym)],
Expand Down Expand Up @@ -977,15 +979,17 @@ def cell_ref_name(
and similar methods should be refactored.

'''
cell_sym = self._symtab.find_or_create_integer_symbol(
"cell", tag="cell_loop_idx")
cell_sym = self._symtab.find_or_create(
"cell", tag="cell_loop_idx", symbol_type=DataSymbol,
datatype=LFRicTypes("LFRicIntegerScalarDataType")())
if var_accesses is not None:
var_accesses.add_access(Signature(cell_sym.name), AccessType.READ,
self._kern)

if self._kern.is_coloured():
colour_sym = self._symtab.find_or_create_integer_symbol(
"colour", tag="colours_loop_idx")
colour_sym = self._symtab.find_or_create(
"colour", tag="colours_loop_idx", symbol_type=DataSymbol,
datatype=LFRicTypes("LFRicIntegerScalarDataType")())
if var_accesses is not None:
var_accesses.add_access(Signature(colour_sym.name),
AccessType.READ, self._kern)
Expand All @@ -995,8 +999,9 @@ def cell_ref_name(
loop_type = self._kern.ancestor(LFRicLoop).loop_type

if loop_type == "cells_in_tile":
tile_sym = self._symtab.find_or_create_integer_symbol(
"tile", tag="tile_loop_idx")
tile_sym = self._symtab.find_or_create(
"tile", tag="tile_loop_idx", symbol_type=DataSymbol,
datatype=LFRicTypes("LFRicIntegerScalarDataType")())
map_sym = self._symtab.lookup(self._kern.tilecolourmap)
array_ref = ArrayReference.create(
map_sym, [Reference(colour_sym), Reference(tile_sym),
Expand Down
2 changes: 1 addition & 1 deletion src/psyclone/domain/lfric/kern_call_invoke_arg_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def scalar(self, scalar_arg, var_accesses=None):

consts = LFRicConstants()
precision_name = consts.SCALAR_PRECISION_MAP[scalar_arg.intrinsic_type]
self._symtab.add_lfric_precision_symbol(precision_name)
LFRicTypes.add_precision_symbol(self._symtab, precision_name)

sym = self._symtab.new_symbol(scalar_arg.name,
symbol_type=DataSymbol,
Expand Down
5 changes: 2 additions & 3 deletions src/psyclone/domain/lfric/kernel_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@
from psyclone.core import AccessType
from psyclone.domain.lfric.arg_ordering import ArgOrdering
from psyclone.domain.lfric.lfric_constants import LFRicConstants
from psyclone.domain.lfric.lfric_symbol_table import LFRicSymbolTable
from psyclone.domain.lfric.lfric_types import LFRicTypes
from psyclone.errors import InternalError
from psyclone.psyir.frontend.fparser2 import INTENT_MAPPING
from psyclone.psyir.nodes import Reference
from psyclone.psyir.symbols import ArgumentInterface
from psyclone.psyir.symbols import ArgumentInterface, SymbolTable


# pylint: disable=too-many-public-methods, no-member
Expand Down Expand Up @@ -108,7 +107,7 @@ def __init__(self, kern):
# ArgOrdering constructor defaults to). This is so that we can
# specify the correct interface for those symbols passed
# as arguments.
self._forced_symtab = LFRicSymbolTable()
self._forced_symtab = SymbolTable()

def generate(self, var_accesses=None):
'''Call the generate base class then add the argument list as it can't
Expand Down
8 changes: 5 additions & 3 deletions src/psyclone/domain/lfric/lfric_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@
from psyclone.domain.lfric.kernel import (
LFRicKernelMetadata, FieldArgMetadata, ScalarArgMetadata,
FieldVectorArgMetadata)
from psyclone.domain.lfric.lfric_types import LFRicTypes
from psyclone.errors import GenerationError, InternalError
from psyclone.parse.utils import ParseError
from psyclone.psyGen import BuiltIn
from psyclone.psyir.nodes import (ArrayReference, Assignment, BinaryOperation,
Reference, IntrinsicCall)
from psyclone.psyir.nodes.node import Node
from psyclone.psyir.symbols import UnsupportedFortranType
from psyclone.psyir.symbols import DataSymbol, UnsupportedFortranType
from psyclone.utils import a_or_an

#: The name of the file containing the meta-data describing the
Expand Down Expand Up @@ -487,8 +488,9 @@ def get_dof_loop_index_symbol(self):
table = self.scope.symbol_table
# The symbol representing the loop index is created in the LFRicLoop
# constructor.
return table.find_or_create_integer_symbol(
"df", tag="dof_loop_idx")
return table.find_or_create(
"df", tag="dof_loop_idx", symbol_type=DataSymbol,
datatype=LFRicTypes("LFRicIntegerScalarDataType")())
Comment thread
LonelyCat124 marked this conversation as resolved.

def get_indexed_field_argument_references(self):
'''
Expand Down
5 changes: 0 additions & 5 deletions src/psyclone/domain/lfric/lfric_invoke_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
from psyclone.configuration import Config
from psyclone.domain.lfric.lfric_builtins import LFRicBuiltInCallFactory
from psyclone.domain.lfric.lfric_kern_call_factory import LFRicKernCallFactory
from psyclone.domain.lfric.lfric_symbol_table import LFRicSymbolTable
from psyclone.psyGen import InvokeSchedule


Expand All @@ -66,10 +65,6 @@ class LFRicInvokeSchedule(InvokeSchedule):
:type parent: :py:class:`psyclone.psyir.nodes.Node`

'''
# LFRicInvokeSchedule always uses an LFRicSymbolTable for its inner scope
# symbol table.
_symbol_table_class = LFRicSymbolTable

def __init__(self, symbol, alg_calls=None, parent=None, **kwargs):
if not alg_calls:
alg_calls = []
Expand Down
28 changes: 14 additions & 14 deletions src/psyclone/domain/lfric/lfric_kern.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
from psyclone.core import AccessType, VariablesAccessMap
from psyclone.domain.lfric.kern_call_arg_list import KernCallArgList
from psyclone.domain.lfric.lfric_constants import LFRicConstants
from psyclone.domain.lfric.lfric_symbol_table import LFRicSymbolTable
from psyclone.domain.lfric.kern_stub_arg_list import KernStubArgList
from psyclone.domain.lfric.kernel_interface import KernelInterface
from psyclone.domain.lfric.lfric_types import LFRicTypes
Expand All @@ -61,7 +60,7 @@
Loop, Literal, Reference, KernelSchedule, Container, Routine)
from psyclone.psyir.symbols import (
ArgumentInterface, ArrayType, ContainerSymbol, DataSymbol, DataTypeSymbol,
GenericInterfaceSymbol, ImportInterface, ScalarType, SymbolTable,
GenericInterfaceSymbol, ImportInterface, SymbolTable,
UnresolvedType, INTEGER_TYPE, UnsupportedFortranType)


Expand Down Expand Up @@ -95,7 +94,7 @@ def __init__(self):
# is called from load().
# pylint: disable=super-init-not-called
self._parent = None
self._stub_symbol_table = LFRicSymbolTable()
self._stub_symbol_table = SymbolTable()
self._base_name = ""
self._func_descriptors = None
self._fs_descriptors = None
Expand Down Expand Up @@ -577,15 +576,17 @@ def last_cell_all_colours_symbol(self):
const = LFRicConstants()

if ubnd_name in const.HALO_ACCESS_LOOP_BOUNDS:
return self.scope.symbol_table.find_or_create_array(
"last_halo_cell_all_colours", 2,
ScalarType.Intrinsic.INTEGER,
tag="last_halo_cell_all_colours")

return self.scope.symbol_table.find_or_create_array(
"last_edge_cell_all_colours", 1,
ScalarType.Intrinsic.INTEGER,
tag="last_edge_cell_all_colours")
return self.scope.symbol_table.find_or_create(
"last_halo_cell_all_colours", tag="last_halo_cell_all_colours",
symbol_type=DataSymbol, datatype=ArrayType(
LFRicTypes("LFRicIntegerScalarDataType")(),
2*[ArrayType.Extent.DEFERRED]))

return self.scope.symbol_table.find_or_create(
"last_edge_cell_all_colours", tag="last_edge_cell_all_colours",
symbol_type=DataSymbol, datatype=ArrayType(
LFRicTypes("LFRicIntegerScalarDataType")(),
[ArrayType.Extent.DEFERRED]))

@property
def ncolours_var(self):
Expand Down Expand Up @@ -765,8 +766,7 @@ def gen_stub(self) -> Container:
stub_module = Container(self._base_name+"_mod")

# Create the subroutine
stub_routine = Routine.create(self._base_name+"_code",
symbol_table=LFRicSymbolTable())
stub_routine = Routine.create(self._base_name+"_code")
stub_module.addchild(stub_routine)
self._stub_symbol_table = stub_routine.symbol_table

Expand Down
6 changes: 1 addition & 5 deletions src/psyclone/domain/lfric/lfric_psy.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@


from psyclone.configuration import Config
from psyclone.domain.lfric import LFRicSymbolTable, LFRicInvokes
from psyclone.domain.lfric import LFRicInvokes
from psyclone.psyGen import PSy
from psyclone.psyir.nodes import ScopingNode


class LFRicPSy(PSy):
Expand All @@ -61,9 +60,6 @@ class LFRicPSy(PSy):

'''
def __init__(self, invoke_info):
# Make sure the scoping node creates LFRicSymbolTables
# TODO #1954: Remove the protected access using a factory
ScopingNode._symbol_table_class = LFRicSymbolTable
Config.get().api = "lfric"
super().__init__(invoke_info)

Expand Down
Loading
Loading