psyclone.lfric#

This module implements the PSyclone LFRic API by 1) specialising the required base classes in parser.py (KernelType) and adding a new class (LFRicFuncDescriptor) to capture function descriptor metadata and 2) specialising the required base classes in psyGen.py (PSy, Invokes, Invoke, InvokeSchedule, Loop, Kern, Inf, Arguments and Argument).

Classes#

class psyclone.lfric.LFRicFuncDescriptor(func_type)[source]#

The LFRic API includes a function-space descriptor as well as an argument descriptor which is not supported by the base classes. This class captures the information specified in a function-space descriptor.

Inheritance

Inheritance diagram of LFRicFuncDescriptor
property function_space_name#

Returns the name of the descriptors function space

property operator_names#

Returns a list of operators that are associated with this descriptors function space

class psyclone.lfric.LFRicFunctionSpaces(kern_or_invoke)[source]#

Handles the declaration and initialisation of all function-space-related quantities required by an Invoke.

Parameters:

invoke – the Invoke or Kernel object.

Inheritance

Inheritance diagram of LFRicFunctionSpaces
initialise(cursor)[source]#

Create the code that initialises function-space quantities.

Parameters:

cursor (int) – position where to add the next initialisation statements.

Return type:

int

Returns:

Updated cursor value.

invoke_declarations()[source]#

Add function-space-related declarations to a PSy-layer routine.

stub_declarations()[source]#

Add function-space-related declarations to a Kernel stub. Note that argument order is redefined later by ArgOrdering.

class psyclone.lfric.LFRicProxies(node)[source]#

Handles all proxy-related declarations and initialisation. Unlike other sub-classes of LFRicCollection, we do not have to handle Kernel-stub generation since Kernels know nothing about proxies.

An instance of this class is instantiated for each Invoke before the PSy Layer is constructed. For each unique field or operator argument to a kernel in the Invoke it:

  • Creates a DataSymbol for the corresponding proxy;

  • Creates a DataSymbol for the pointer to the data array accessed via the proxy. If the argument is a field vector then a DataSymbol is created for each component of the vector;

  • Tags that DataSymbol so that the correct symbol can always be looked up, irrespective of any name clashes;

Note that since the Fortran standard forbids (Note 12.34 in the Fortran2008 standard) aliasing of effective arguments that are written to, the set of unique kernel arguments must refer to unique memory locations or to those that are read only.

Inheritance

Inheritance diagram of LFRicProxies
initialise(cursor)[source]#

Insert code into the PSy layer to initialise all necessary proxies.

Parameters:

cursor (int) – position where to add the next initialisation statements.

Return type:

int

Returns:

Updated cursor value.

Raises:

InternalError – if a kernel argument of an unrecognised type is encountered.

invoke_declarations()[source]#

Insert declarations of all proxy-related quantities into the PSy layer.

class psyclone.lfric.LFRicLMAOperators(node)[source]#

Handles all entities associated with Local-Matrix-Assembly Operators.

Inheritance

Inheritance diagram of LFRicLMAOperators
invoke_declarations()[source]#

Declare all LMA-related quantities in a PSy-layer routine. Note: PSy layer in LFRic does not modify the LMA operator objects. Hence, their Fortran intents are always “in” (the data updated in the kernels is only pointed to from the LMA operator object and is thus not a part of the object).

stub_declarations()[source]#

Declare all LMA-related quantities in a Kernel stub. Note that argument order will be defined later by ArgOrdering.

class psyclone.lfric.LFRicCMAOperators(node)[source]#

Holds all information on the Column-Matrix-Assembly operators required by an Invoke or Kernel stub.

Parameters:

node (psyclone.lfric.LFRicSchedule or psyclone.domain.lfric.LFRicKern) – either an Invoke schedule or a single Kernel object.

Inheritance

Inheritance diagram of LFRicCMAOperators
initialise(cursor)[source]#

Generates the calls to the LFRic infrastructure that look-up the various components of each CMA operator. Adds these as children of the supplied parent node.

Parameters:

cursor (int) – position where to add the next initialisation statements.

Return type:

int

Returns:

Updated cursor value.

invoke_declarations()[source]#

Generate the necessary PSy-layer declarations for all column-wise operators and their associated parameters. Note: PSy layer in LFRic does not modify the CMA operator objects. Hence, their Fortran intents are always “in” (the data updated in the kernels is only pointed to from the column-wise operator object and is thus not a part of the object).

stub_declarations()[source]#

Generate all necessary declarations for CMA operators being passed to a Kernel stub. Note that argument order is redefined later by ArgOrdering.

class psyclone.lfric.LFRicMeshes(invoke, unique_psy_vars)[source]#

Holds all mesh-related information (including colour maps if required). If there are no inter-grid kernels then there is only one mesh object required (when calling kernels with operates_on==domain, colouring, doing distributed memory or querying the reference element). However, kernels performing inter-grid operations require multiple mesh objects as well as mesh maps and other quantities.

There are two types of inter-grid operation; the first is “prolongation” where a field on a coarse mesh is mapped onto a fine mesh. The second is “restriction” where a field on a fine mesh is mapped onto a coarse mesh.

Parameters:

Inheritance

Inheritance diagram of LFRicMeshes
colourmap_init()[source]#

Sets-up information on any required colourmaps. Since colouring is applied by Transformations, this method is called as the final step of LFRicColourTrans.apply().

initialise(cursor)[source]#

Initialise parameters specific to inter-grid kernels.

Parameters:

cursor (int) – position where to add the next initialisation statements.

Return type:

int

Returns:

Updated cursor value.

property intergrid_kernels#
Returns:

A list of objects describing the intergrid kernels used in this invoke.

Return type:

list[psyclone.lfric.LFRicInterGrid]

invoke_declarations()[source]#

Declare variables specific to mesh objects.

property symtab#
Returns:

associated symbol table.

Return type:

psyclone.psyir.symbols.SymbolTable

class psyclone.lfric.LFRicInterGrid(fine_arg, coarse_arg)[source]#

Holds information on quantities required by an inter-grid kernel.

Parameters:

Inheritance

Inheritance diagram of LFRicInterGrid
property colourmap_symbol: DataSymbol#
Returns:

the colour map symbol.

property last_cell_tile_var_symbol: DataSymbol#
Returns:

the last cell in the tilecolour.

property last_cell_var_symbol: DataSymbol#
Returns:

the last halo/edge cell variable.

property last_tile_var_symbol: DataSymbol#
Returns:

the symbol with the last tile of a given colour.

property ncolours_var_symbol: DataSymbol#
Returns:

the symbol storing the number of colours.

property ntilecolours_var_symbol: DataSymbol#
Returns:

the symbol storing the number of tilecolours.

set_colour_info(colour_map, ncolours, last_cell)[source]#

Sets the colour_map, number of colours, and last cell of a particular colour.

Parameters:
  • colour_map (DataSymbol) – the colour map symbol.

  • ncolours (DataSymbol) – the number of colours.

  • last_cell (DataSymbol) – the last halo cell of a particular colour.

set_tilecolour_info(tilecolour_map, ntilecolours, last_tile, last_cell_tile)[source]#

Sets the tilecolour_map, number of colours of tiles, last tile of a particular colour and last cell of a particular tile and colour.

Parameters:
  • tilecolour_map (DataSymbol) – the tilecolourmap symbol.

  • ntilecolours (DataSymbol) – the number of tilecolours.

  • last_tile (DataSymbol) – the last tile of a particular colour.

  • last_cell_tile (DataSymbol) – the last cell of a particular tilecolour.

property tilecolourmap_symbol: DataSymbol#
Returns:

the tilecolour map symbol.

class psyclone.lfric.LFRicBasisFunctions(node)[source]#

Holds all information on the basis and differential basis functions required by an invoke or kernel call. This covers both those required for quadrature and for evaluators.

Parameters:

node (psyclone.domain.lfric.LFRicInvokeSchedule or psyclone.domain.lfric.LFRicKern) – either the schedule of an Invoke or a single Kernel object for which to extract information on all required basis/diff-basis functions.

Raises:

InternalError – if a call has an unrecognised evaluator shape.

Inheritance

Inheritance diagram of LFRicBasisFunctions
static basis_first_dim_name(function_space)[source]#

Get the name of the variable holding the first dimension of a basis function

Parameters:

function_space (psyclone.domain.lfric.FunctionSpace) – the function space the basis function is for

Returns:

a Fortran variable name

Return type:

str

static basis_first_dim_value(function_space)[source]#

Get the size of the first dimension of a basis function.

Parameters:

function_space (psyclone.domain.lfric.FunctionSpace) – the function space the basis function is for

Returns:

an integer length.

Return type:

string

Raises:

GenerationError – if an unsupported function space is supplied (e.g. ANY_SPACE_*, ANY_DISCONTINUOUS_SPACE_*)

deallocate()[source]#

Add code (at the end of the Invoke Schedule) to deallocate all basis/diff-basis function arrays.

Raises:

InternalError – if an unrecognised type of basis function is encountered.

static diff_basis_first_dim_name(function_space)[source]#

Get the name of the variable holding the first dimension of a differential basis function.

Parameters:

function_space (psyclone.domain.lfric.FunctionSpace) – the function space the diff-basis function is for.

Returns:

a Fortran variable name.

Return type:

str

static diff_basis_first_dim_value(function_space)[source]#

Get the size of the first dimension of an array for a differential basis function.

Parameters:

function_space (psyclone.domain.lfric.FunctionSpace) – the function space the diff-basis function is for.

Returns:

an integer length.

Return type:

str

Raises:

GenerationError – if an unsupported function space is supplied (e.g. ANY_SPACE_*, ANY_DISCONTINUOUS_SPACE_*)

initialise(cursor)[source]#

Create the declarations and assignments required for the basis-functions required by an invoke. These are added as children of the supplied parent node in the AST.

Parameters:

cursor (int) – position where to add the next initialisation statements.

Return type:

int

Returns:

Updated cursor value.

Raises:

InternalError – if an invalid entry is encountered in the self._basis_fns list.

invoke_declarations()[source]#

Add basis-function declarations to the PSy layer.

stub_declarations()[source]#

Insert the variable declarations required by the basis functions into the Kernel stub. Note that argument order is redefined later by ArgOrdering.

Raises:

InternalError – if an unsupported quadrature shape is found.

class psyclone.lfric.LFRicBoundaryConditions(node)[source]#

Manages declarations and initialisation of quantities required by kernels that need boundary condition information.

Parameters:

node (psyclone.domain.lfric.LFRicInvoke or psyclone.domain.lfric.LFRicKern) – the Invoke or Kernel stub for which we are to handle any boundary conditions.

Raises:
  • GenerationError – if a kernel named “enforce_bc_code” is found but does not have an argument on ANY_SPACE_1.

  • GenerationError – if a kernel named “enforce_operator_bc_code” is found but does not have exactly one argument.

Inheritance

Inheritance diagram of LFRicBoundaryConditions
class BoundaryDofs(argument, function_space)#
argument#

Alias for field number 0

function_space#

Alias for field number 1

initialise(cursor)[source]#

Initialise any boundary-dofs arrays required by an Invoke.

Parameters:

cursor (int) – position where to add the next initialisation statements.

Returns:

Updated cursor value.

Return type:

int

invoke_declarations()[source]#

Add declarations for any boundary-dofs arrays required by an Invoke.

stub_declarations()[source]#

Add declarations for any boundary-dofs arrays required by a kernel. Note that argument order is redefined later by ArgOrdering.

class psyclone.lfric.LFRicGlobalSum(scalar, parent=None)[source]#

LFRic specific global sum class which can be added to and manipulated in a schedule.

Parameters:
Raises:

Inheritance

Inheritance diagram of LFRicGlobalSum
lower_to_language_level()[source]#
Returns:

this node lowered to language-level PSyIR.

Return type:

psyclone.psyir.nodes.Node

class psyclone.lfric.LFRicHaloExchange(field, check_dirty=True, vector_index=None, parent=None)[source]#

LFRic-specific halo exchange class which can be added to and manipulated in a schedule.

Parameters:
  • field (psyclone.lfric.LFRicKernelArgument) – the field that this halo exchange will act on

  • check_dirty (bool) – optional argument default True indicating whether this halo exchange should be subject to a run-time check for clean/dirty halos.

  • vector_index (int) – optional vector index (default None) to identify identify which index of a vector field this halo exchange is responsible for.

  • parent (Optional[psyclone.psyir.nodes.Node]) – PSyIR parent node of this object.

Inheritance

Inheritance diagram of LFRicHaloExchange
lower_to_language_level()[source]#
Returns:

this node lowered to language-level PSyIR.

Return type:

psyclone.psyir.nodes.Node

node_str(colour=True)[source]#

Creates a text summary of this HaloExchange node.

Parameters:

colour (bool) – whether or not to include control codes for colour.

Returns:

text summary of this node, optionally with control codes for colour highlighting.

Return type:

str

required(ignore_hex_dep=False)[source]#

Determines whether this halo exchange is definitely required (True, True), might be required (True, False) or is definitely not required (False, *).

If the optional ignore_hex_dep argument is set to True then any read accesses contained in halo exchange nodes are ignored. This option can therefore be used to filter out any halo exchange dependencies and only consider non-halo exchange dependencies if and when required.

Whilst a halo exchange is generally only ever added if it is required, or if it may be required, this situation can change if redundant computation transformations are applied. The first argument can be used to remove such halo exchanges if required.

When the first return value is True, the second return value can be used to see if we need to rely on the runtime (set_dirty and set_clean calls) and therefore add a check_dirty() call around the halo exchange or whether we definitely know that this halo exchange is required.

This routine assumes that a stencil size provided via a variable may take the value 0. If a variables value is constrained to be 1, or more, then the logic for deciding whether a halo exchange is definitely required should be updated. Note, the routine would still be correct as is, it would just return more unknown results than it should).

Parameters:

ignore_hex_dep (bool) – if True then ignore any read accesses contained in halo exchanges. This is an optional argument that defaults to False.

Returns:

(x, y) where x specifies whether this halo exchange is (or might be) required - True, or is not required - False. If the first tuple item is True then the second argument specifies whether we definitely know that we need the HaloExchange - True, or are not sure - False.

Return type:

(bool, bool)

class psyclone.lfric.LFRicHaloExchangeStart(field, check_dirty=True, vector_index=None, parent=None)[source]#

The start of an asynchronous halo exchange. This is similar to a regular halo exchange except that the Fortran name of the call is different and the routine only reads the data being transferred (the associated field is specified as having a read access). As a result this class is not able to determine some important properties (such as whether the halo exchange is known to be required or not). This is solved by finding the corresponding asynchronous halo exchange end (a halo exchange start always has a corresponding halo exchange end and vice versa) and calling its methods (a halo exchange end is specified as having readwrite access to its associated field and therefore is able to determine the required properties).

Parameters:
  • field (psyclone.lfric.LFRicKernelArgument) – the field that this halo exchange will act on

  • check_dirty (bool) – optional argument (default True) indicating whether this halo exchange should be subject to a run-time check for clean/dirty halos.

  • vector_index (int) – optional vector index (default None) to identify which component of a vector field this halo exchange is responsible for

  • parent (psyclone.psyir.nodes.Node) – optional PSyIRe parent node (default None) of this object

Inheritance

Inheritance diagram of LFRicHaloExchangeStart
required()[source]#

Call the required method in the corresponding halo exchange end object. This is done as the field in halo exchange start is only read and the dependence analysis beneath this call requires the field to be modified.

Returns:

(x, y) where x specifies whether this halo exchange is (or might be) required - True, or is not required - False. If the first tuple item is True then the second argument specifies whether we definitely know that we need the HaloExchange - True, or are not sure - False.

Return type:

(bool, bool)

class psyclone.lfric.LFRicHaloExchangeEnd(field, check_dirty=True, vector_index=None, parent=None)[source]#

The end of an asynchronous halo exchange. This is similar to a regular halo exchange except that the Fortran name of the call is different and the routine only writes to the data being transferred.

Parameters:
  • field (psyclone.lfric.LFRicKernelArgument) – the field that this halo exchange will act on

  • check_dirty (bool) – optional argument (default True) indicating whether this halo exchange should be subject to a run-time check for clean/dirty halos.

  • vector_index (int) – optional vector index (default None) to identify which index of a vector field this halo exchange is responsible for.

  • parent (Optional[psyclone.psyir.nodes.Node]) – PSyIR parent node (default None) of this object.

Inheritance

Inheritance diagram of LFRicHaloExchangeEnd
class psyclone.lfric.HaloDepth(parent)[source]#

Determines how much of the halo a read to a field accesses (the halo depth).

Parameters:

parent (psyclone.psyir.nodes.Node) – the parent PSyIR node of the region containing the field access that is represented.

Raises:

TypeError – if the parent argument is not a Node.

Inheritance

Inheritance diagram of HaloDepth
property annexed_only#
Returns:

True if only annexed dofs are accessed in the halo and False otherwise.

Return type:

bool

property max_depth#
Returns:

True if the read to the field is known to access all of the halo and False otherwise.

Return type:

bool

property max_depth_m1#

Returns whether the read to the field is known to access all of the halo except the outermost level or not.

Returns:

True if the read to the field is known to access all of the halo except the outermost and False otherwise.

Return type:

bool

psyir_expression()[source]#
Returns:

the PSyIR expression representing this HaloDepth.

Return type:

psyclone.psyir.nodes.Node

set_by_value(max_depth, var_depth, annexed_only, max_depth_m1)[source]#

Set halo depth information directly.

Parameters:
  • max_depth (bool) – True if the field accesses all of the halo and False otherwise

  • var_depth (Optional[DataNode]) – PSyIR expression specifying the halo access depth, if one exists, and None if not

  • annexed_only (bool) – True if only the halo’s annexed dofs are accessed and False otherwise

  • max_depth_m1 (bool) – True if the field accesses all of the halo but does not require the outermost halo to be correct, False otherwise

property var_depth#

Returns the PSyIR of the expression specifying the depth of halo access if one is provided.

Returns:

PSyIR specifying the halo access depth if one exists, and None if not.

Return type:

psyclone.psyir.nodes.Statement

class psyclone.lfric.HaloWriteAccess(field, parent)[source]#

Determines how much of a field’s halo is written to (the halo depth) when a field is accessed in a particular kernel within a particular loop nest.

Parameters:
  • field (LFRicKernelArgument) – the field that we are concerned with.

  • parent (Node) – the parent PSyIR node associated with the scoping region that contains this halo access.

Inheritance

Inheritance diagram of HaloWriteAccess
property clean_depth#

Returns the depth to which this halo is clean following the write.

Returns:

PSyIR for the expression for the clean halo depth or None.

Return type:

psyclone.psyir.nodes.Node | NoneType

property dirty_outer#

Returns True if the writer is continuous and accesses the halo and False otherwise. It indicates that the outer level of halo that has been written to is actually dirty (well to be precise it is a partial sum).

Returns:

True if the outer layer of halo that is written to remains dirty and False otherwise.

Return type:

bool

class psyclone.lfric.HaloReadAccess(field, parent=None)[source]#

Determines how much of a field’s halo is read (the halo depth) and additionally the access pattern (the stencil) when a field is accessed in a particular kernel within a particular loop nest.

Parameters:

Inheritance

Inheritance diagram of HaloReadAccess
property needs_clean_outer#

Returns False if the reader has a gh_inc access and accesses the halo. Otherwise returns True. Indicates that the outer level of halo that has been read does not need to be clean (although any annexed dofs do).

Returns:

Returns False if the outer layer of halo that is read does not need to be clean and True otherwise.

Return type:

bool

property stencil_type#

Returns the type of stencil access used by the field(s) in the halo if one exists. If redundant computation (accessing the full halo) is combined with a stencil access (potentially accessing a subset of the halo) then the access is assumed to be full access (region) for all depths.

Returns:

the type of stencil access used or None if there is no stencil.

Return type:

str

class psyclone.lfric.FSDescriptor(descriptor)[source]#

Provides information about a particular function space used by a meta-funcs entry in the kernel metadata.

Inheritance

Inheritance diagram of FSDescriptor
property fs_name#

Returns the raw metadata value of this function space.

property requires_basis#

Returns True if a basis function is associated with this function space, otherwise it returns False.

property requires_diff_basis#

Returns True if a differential basis function is associated with this function space, otherwise it returns False.

class psyclone.lfric.FSDescriptors(descriptors)[source]#

Contains a collection of FSDescriptor objects and methods that provide information across these objects. We have one FSDescriptor for each meta-funcs entry in the kernel metadata. # TODO #274 this should actually be named something like BasisFuncDescriptors as it holds information describing the basis/diff-basis functions required by a kernel.

Parameters:

descriptors (list of psyclone.LFRicFuncDescriptor.) – list of objects describing the basis/diff-basis functions required by a kernel, as obtained from metadata.

Inheritance

Inheritance diagram of FSDescriptors
property descriptors#
Returns:

the list of Descriptors, one for each of the meta-funcs entries in the kernel metadata.

Return type:

List of psyclone.lfric.FSDescriptor

exists(fspace)[source]#

Return True if a descriptor with the specified function space exists, otherwise return False.

get_descriptor(fspace)[source]#

Return the descriptor with the specified function space name. If it does not exist raise an error.

class psyclone.lfric.LFRicArgStencil(name, extent=None, extent_arg=None, direction_arg=None)[source]#

Provides stencil information about an LFRic kernel argument. LFRicArgStencil can provide the extent, algorithm argument for the extent, and the direction argument of a stencil or set any of these properties.

Parameters:
  • name (str) – the name of the stencil.

  • extent (str) – the extent of the stencil if it is known. It will be known if it is specified in the metadata.

  • extent_arg (Any) – the algorithm argument associated with the extent value if extent was not found in the metadata.

  • direction_arg (Any) – the direction argument associated with the direction of the stencil if the direction of the stencil is not known.

Inheritance

Inheritance diagram of LFRicArgStencil
class psyclone.lfric.LFRicKernelArguments(call, parent_call, check=True)[source]#

Provides information about LFRic kernel call arguments collectively, as specified by the kernel argument metadata.

Parameters:
  • call (psyclone.parse.KernelCall) – the kernel metadata for which to extract argument info.

  • parent_call (psyclone.domain.lfric.LFRicKern) – the kernel-call object.

  • check (bool) – whether to check for consistency between the kernel metadata and the algorithm layer. Defaults to True.

Raises:

GenerationError – if the kernel metadata specifies stencil extent.

Inheritance

Inheritance diagram of LFRicKernelArguments
property acc_args#
Returns:

the list of quantities that must be available on an OpenACC device before the associated kernel can be launched.

Return type:

list of str

property dofs#

Currently required for Invoke base class although this makes no sense for LFRic. Need to refactor the Invoke base class and remove the need for this property (#279).

property first_field_or_operator#
Returns:

the first field or operator argument in the list.

Return type:

psyclone.lfric.LFRicKernelArgument

Raises:

InternalError – if no field or operator argument is found.

get_arg_on_space(func_space)[source]#

Returns the first argument (field or operator) found that is on the specified function space. The mangled name of the supplied function space is used for comparison.

Parameters:

func_space (psyclone.domain.lfric.FunctionSpace) – The function space for which to find an argument.

Returns:

the first kernel argument that is on the supplied function space

Return type:

psyclone.lfric.LFRicKernelArgument

Raises:

FieldNotFoundError if no field or operator argument is found for the specified function space.

get_arg_on_space_name(func_space_name)[source]#

Returns the first argument (field or operator) found that is on the named function space, as specified in the kernel metadata. Also returns the associated FunctionSpace object.

Parameters:

func_space_name (str) – Name of the function space (as specified in kernel metadata) for which to find an argument.

Returns:

the first kernel argument that is on the named function space and the associated FunctionSpace object.

Return type:

(psyclone.lfric.LFRicKernelArgument, psyclone.domain.lfric.FunctionSpace)

Raises:

FieldNotFoundError if no field or operator argument is found for the named function space.

has_operator(op_type=None)[source]#

Returns true if at least one of the arguments is an operator of type op_type (either gh_operator [LMA] or gh_columnwise_operator [CMA]). If op_type is None then searches for any valid operator type.

iteration_space_arg()[source]#

Returns an argument we can use to dereference the iteration space. This can be a field or operator that is modified or alternatively a field that is read if one or more scalars are modified. If a kernel writes to more than one argument then that requiring the largest iteration space is selected.

Returns:

Kernel argument from which to obtain iteration space

Return type:

psyclone.lfric.LFRicKernelArgument

psyir_expressions()[source]#
Returns:

the PSyIR expressions representing this Argument list.

Return type:

list of psyclone.psyir.nodes.Node

property scalars#

Provides the list of names of scalar arguments required by the kernel associated with this Arguments object. If there are none then the returned list is empty.

Returns:

A list of the names of scalar arguments in this object.

Return type:

list of str

property unique_fs_names#

Return the list of unique function space names used by the arguments of this kernel. The names are unmangled (i.e. as specified in the kernel metadata)

property unique_fss#

Returns a unique list of function space objects used by the arguments of this kernel

class psyclone.lfric.LFRicKernelArgument(kernel_args, arg_meta_data, arg_info, call, check=True)[source]#

This class provides information about individual LFRic kernel call arguments as specified by the kernel argument metadata and the kernel invocation in the Algorithm layer.

Parameters:
Raises:

InternalError – for an unsupported metadata in the argument descriptor data type.

Inheritance

Inheritance diagram of LFRicKernelArgument
property argument_type#
Returns:

the API type of this argument, as specified in the metadata.

Return type:

str

property declaration_name#
Returns:

the name for this argument with the array dimensions added if required.

Return type:

str

property descriptor#
Returns:

a descriptor object which contains Kernel metadata about this argument.

Return type:

psyclone.domain.lfric.LFRicArgDescriptor

property discontinuous#

Returns True if this argument is known to be on a discontinuous function space including any_discontinuous_space, otherwise returns False.

Returns:

whether the argument is discontinuous.

Return type:

bool

property function_space#

Returns the expected finite element function space for a kernel argument as specified by the kernel argument metadata: a single function space for a field and function_space_from for an operator.

Returns:

function space for this argument.

Return type:

psyclone.domain.lfric.FunctionSpace

property function_space_from#
Returns:

the ‘from’ function space of an operator.

Return type:

str

property function_space_names#

Returns a list of the names of the function spaces associated with this argument. We have more than one function space when dealing with operators.

Returns:

list of function space names for this argument.

Return type:

list of str

property function_space_to#
Returns:

the ‘to’ function space of an operator.

Return type:

str

property function_spaces#

Returns the expected finite element function space for a kernel argument as specified by the kernel argument metadata: a single function space for a field and a list containing function_space_to and function_space_from for an operator.

Returns:

function space(s) for this argument.

Return type:

list of psyclone.domain.lfric.FunctionSpace

generate_accessor(function_space=None)[source]#

Generate a Reference accessing this object’s data.

Parameters:

function_space (Optional[str]) – name of the function space.

Returns:

the generated Reference.

Return type:

psyclone.psyir.nodes.Reference

generate_method_call(method, function_space=None)[source]#

Generate a PSyIR call to the given method of this object.

Parameters:
  • method (str) – name of the method to generate a call to.

  • function_space (Optional[str]) – name of the function space.

Returns:

the generated call.

Return type:

psyclone.psyir.nodes.Call

infer_datatype(proxy=False)[source]#

Infer the datatype of this kernel argument in the PSy layer using the LFRic API rules. If any LFRic infrastructure modules are required but are not already present then suitable ContainerSymbols are added to the outermost symbol table. Similarly, DataTypeSymbols are added for any required LFRic derived types that are not already in the symbol table.

TODO #1258 - ultimately this routine should not have to create any DataTypeSymbols as that should already have been done.

Parameters:

proxy (bool) – whether or not we want the type of the proxy object for this kernel argument. Defaults to False (i.e. return the type rather than the proxy type).

Return type:

DataType

Returns:

the datatype of this argument.

Raises:

NotImplementedError – if an unsupported argument type is found.

property intent#

Returns the Fortran intent of this argument as defined by the valid access types for this API

Returns:

the expected Fortran intent for this argument as specified by the kernel argument metadata

Return type:

str

property intrinsic_type#
Returns:

the intrinsic Fortran type of this argument for scalars or of the argument’s data for fields and operators.

Return type:

str

property is_field#
Returns:

True if this kernel argument represents a field, False otherwise.

Return type:

bool

property is_operator#
Returns:

True if this kernel argument represents an operator, False otherwise.

Return type:

bool

property is_scalar#
Returns:

True if this kernel argument represents a scalar, False otherwise.

Return type:

bool

property mesh#
Returns:

mesh associated with argument (‘GH_FINE’ or ‘GH_COARSE’).

Return type:

str

property name_indexed#
Returns:

the name for this argument with an additional index which accesses the first element for a vector argument.

Return type:

str

property proxy_data_type#
Returns:

the type of this argument’s proxy (if it exists) as defined in LFRic infrastructure.

Return type:

str or NoneType

property proxy_declaration_name#
Returns:

the proxy name for this argument with the array dimensions added if required.

Return type:

str

property proxy_name#
Returns:

the proxy name for this argument.

Return type:

str

property proxy_name_indexed#
Returns:

the proxy name for this argument with an additional index which accesses the first element for a vector argument.

Return type:

str

psyir_expression()[source]#

Looks up or creates a reference to a suitable Symbol for this kernel argument. If the argument is a scalar that has been provided as a literal (in the Algorithm layer) then the PSyIR of the expression is returned.

Returns:

the PSyIR for this kernel argument.

Return type:

psyclone.psyir.nodes.Node

Raises:
  • InternalError – if this argument is a literal but we fail to construct PSyIR that is consistent with this.

  • NotImplementedError – if this argument is not a literal, scalar or field.

ref_name(function_space=None)[source]#

Returns the name used to dereference this type of argument (depends on whether it is a field or operator and, if the latter, whether it is the to- or from-space that is specified).

Parameters:

function_space (psyclone.domain.lfric.FunctionSpace) – the function space of this argument

Returns:

the name used to dereference this argument.

Return type:

str

Raises:
  • GenerationError – if the supplied function space is not one of the function spaces associated with this argument.

  • GenerationError – if the supplied function space is not being returned by either ‘function_space_from’ or ‘function_space_to’.

  • GenerationError – if the argument type is not supported.

property stencil#
Returns:

stencil information for this argument if it exists.

Return type:

psyclone.lfric.LFRicArgStencil

property vector_size#
Returns:

the vector size of this argument as specified in the Kernel metadata.

Return type:

str

class psyclone.lfric.LFRicACCEnterDataDirective(children=None, parent=None, async_queue=False)[source]#

Sub-classes ACCEnterDataDirective to provide an API-specific implementation of data_on_device().

Inheritance

Inheritance diagram of LFRicACCEnterDataDirective
data_on_device(_)[source]#

Provide a hook to be able to add information about data being on a device (or not). This is currently not used in LFRic.