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
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
- class QRRule(alg_name, psy_name, kernel_args)
- alg_name
Alias for field number 0
- kernel_args
Alias for field number 2
- psy_name
Alias for field number 1
- property all_updates_are_writes
- Returns:
True if all of the arguments updated by this kernel have ‘GH_WRITE’ access, False otherwise.
- Return type:
bool
- 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
Getter for the name of the colourmap associated with this kernel call.
- Returns:
name of the colourmap (Fortran array).
- Return type:
str
- Raises:
InternalError – if this kernel is not coloured.
- 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.dynamo0p3.DynKernelArgument`), 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
Create the fparser1 AST for a kernel stub.
- Returns:
root of fparser1 AST for the stub routine.
- Return type:
fparser.one.block_statements.Module
- Raises:
GenerationError – if the supplied kernel stub does not operate on a supported subset of the domain (currently only “cell_column”).
- get_kernel_schedule()
Returns a PSyIR Schedule representing the kernel code. The base class creates the PSyIR schedule 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.
Once issue #935 is implemented, this routine will return the PSyIR Schedule using LFRic-specific PSyIR where possible.
- Returns:
Schedule representing the kernel code.
- Return type:
psyclone.psyGen.KernelSchedule
- Raises:
GenerationError – if no subroutine matching this kernel can be found in the parse tree of the associated source code.
- 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)
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:
call (
psyclone.parse.algorithm.KernelCall
) – The KernelCall object from which to extract information about this kernelparent (
psyclone.domain.lfric.LFRicLoop
) – The parent node of the kernel call in the AST we are constructing. This will be a loop.
- load_meta(ktype)
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:
InternalError – for an invalid data type of a scalar argument.
GenerationError – if an invalid argument type is found in the kernel.
- property mesh
- Returns:
the mesh properties required by this kernel.
- Return type:
:py:class`psyclone.dynamo0p3.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 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(var_accesses)
Get all variable access information. All accesses are marked according to the kernel metadata
- Parameters:
var_accesses (
psyclone.core.VariablesAccessInfo
) – VariablesAccessInfo instance that stores the information about variable accesses.
- property reference_element
- Returns:
the reference-element properties required by this kernel.
- Return type:
psyclone.dynamo0p3.RefElementMetaData
- validate_global_constraints()
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 (currently only “cell_column”).
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)
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.