psyclone.domain.lfric.lfric_kern#

This module implements the PSyclone LFRic API by specialising the required base class Kern in psyGen.py

Classes#

  • LFRicKern: Stores information about LFRic Kernels as specified by the

class psyclone.domain.lfric.lfric_kern.LFRicKern[source]#

Stores information about LFRic Kernels as specified by the Kernel metadata and associated algorithm call. Uses this information to generate appropriate PSy layer code for the Kernel instance or to generate a Kernel stub.

Inheritance

Inheritance diagram of LFRicKern
class QRRule(alg_name, psy_name, kernel_args)[source]#

Used to store information on a quadrature rule required by a kernel.

Parameters:
  • alg_name (str) – The actual argument text specifying the QR object in the Alg. layer.

  • psy_name (str) – The PSy-layer variable name for the QR object.

  • kernel_args (List[str]) – Kernel arguments associated with this QR rule.

property all_updates_are_writes: bool#
Returns:

True if all arguments updated by this kernel have ‘GH_WRITE’ access, False otherwise.

property argument_kinds#
Returns:

kinds (precisions) for all arguments in a kernel.

Return type:

set of str

property base_name#
Returns:

a base name for this kernel.

Return type:

str

property cma_operation#
Returns:

the type of CMA operation performed by this kernel (one of ‘assembly’, ‘apply’ or ‘matrix-matrix’) or None if the kernel does not involve CMA operators.

Return type:

str

property colourmap: DataSymbol#
Returns:

the symbol representing the colourmap for this kernel call.

Raises:

InternalError – if this kernel is not coloured or the dictionary of inter-grid kernels and colourmaps has not been constructed.

property eval_shapes#
Returns:

the value(s) of GH_SHAPE for this kernel or an empty list if none are specified.

Return type:

list

property eval_targets#
Returns:

the function spaces upon which basis/diff-basis functions are to be evaluated for this kernel.

Return type:

dict of (psyclone.domain.lfric.FunctionSpace, :py:class`psyclone.lfric.LFRicKernelArgument`), indexed by the names of the target function spaces.

property fs_descriptors#
Returns:

a list of function space descriptor objects of type FSDescriptors which contain information about the function spaces.

Return type:

List[psyclone.FSDescriptors].

property gen_stub: Container#

Create the PSyIR for a kernel stub.

Returns:

the kernel stub root Container.

Raises:

GenerationError – if the supplied kernel stub does not operate on a supported subset of the domain (currently only those that end with “cell_column”).

get_callees()[source]#

Returns the PSyIR Schedule(s) representing the kernel code. The base class creates the PSyIR schedule(s) on first invocation which is then checked for consistency with the kernel metadata here. The Schedule is just generated on first invocation, this allows us to retain transformations that may subsequently be applied to the Schedule(s).

Once issue #935 is implemented, this routine will return the PSyIR Schedule using LFRic-specific PSyIR where possible.

Return type:

List[KernelSchedule]

Returns:

the Schedule(s) representing the kernel implementation.

Raises:

InternalError – if no subroutines matching this kernel can be found in the parse tree of the associated source code.

get_interface_symbol()[source]#
Return type:

Optional[GenericInterfaceSymbol]

Returns:

the interface symbol for this kernel if it is polymorphic, None otherwise.

property halo_depth#

If this is a kernel that has metadata specifying that it operates on halo cells then this property gives the depth of halo that is written.

Returns:

the PSyIR of the depth of halo that is modified.

Return type:

psyclone.psyir.nodes.Literal | psyclone.psyir.nodes.Reference

property is_intergrid#
Returns:

True if it is an inter-grid kernel, False otherwise

Return type:

bool

property last_cell_all_colours_symbol#

Getter for the symbol of the array holding the index of the last cell of each colour.

Returns:

name of the array.

Return type:

str

Raises:

InternalError – if this kernel is not coloured.

load(call, parent=None)[source]#

Sets up kernel information with the call object which is created by the parser. This object includes information about the invoke call and the associated kernel.

Parameters:
load_meta(ktype)[source]#

Sets up kernel information with the kernel type object which is created by the parser. The object includes the metadata describing the kernel code.

Parameters:

ktype (psyclone.domain.lfric.LFRicKernMetadata) – the kernel metadata object produced by the parser

Raises:
property mesh#
Returns:

the mesh properties required by this kernel.

Return type:

:py:class`psyclone.lfric.MeshPropertiesMetaData`

property ncolours_var#

Getter for the name of the variable holding the number of colours associated with this kernel call.

Returns:

name of the variable holding the number of colours

Return type:

Optional[str]

Raises:

InternalError – if this kernel is not coloured.

property ntilecolours_var: str | None#

Getter for the name of the variable holding the number of colours (over tiled cells) associated with this kernel call.

Returns:

name of the variable holding the number of colours

Raises:

InternalError – if this kernel is not coloured or the colour-map information has not been initialised.

property qr_required#
Returns:

True if this kernel requires quadrature, else returns False.

Return type:

bool

property qr_rules#
Returns:

details of each of the quadrature rules required by this kernel.

Return type:

OrderedDict containing psyclone.domain.lfric.LFRicKern.QRRule indexed by quadrature shape.

reference_accesses()[source]#
Return type:

VariablesAccessMap

Returns:

a map of all the symbol accessed inside this node, the keys are Signatures (unique identifiers to a symbol and its structure acccessors) and the values are AccessSequence (a sequence of AccessTypes).

property reference_element#
Returns:

the reference-element properties required by this kernel.

Return type:

psyclone.lfric.RefElementMetaData

property tilecolourmap: DataSymbol#

Getter for the name of the tilecolourmap associated with this kernel call.

Returns:

the symbol representing the tilecolourmap.

Raises:

InternalError – if this kernel is not coloured or the dictionary of inter-grid kernels and colourmaps has not been constructed.

property undf_name#

Dynamically looks up the name of the ‘undf’ variable for the space that this kernel updates.

Returns:

the name of the undf variable.

Return type:

str

validate_global_constraints()[source]#

Perform validation checks for any global constraints (that require the tree to be complete).

Raises:
  • GenerationError – if this kernel does not have a supported operates-on.

  • GenerationError – if the loop goes beyond the level 1 halo and an operator is accessed.

  • GenerationError – if a kernel in the loop has an inc access and the loop is not coloured but is within an OpenMP parallel region.

validate_kernel_code_args(table)[source]#

Check that the arguments in the kernel code match the expected arguments as defined by the kernel metadata and the LFRic API.

Parameters:

table (psyclone.psyir.symbols.SymbolTable) – the symbol table to validate against the metadata.

Raises:

GenerationError – if the number of arguments indicated by the kernel metadata doesn’t match the actual number of arguments in the symbol table.