psyclone.dynamo0p3
This module implements the PSyclone Dynamo 0.3 API by 1) specialising the required base classes in parser.py (KernelType) and adding a new class (DynFuncDescriptor03) 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
DynFuncDescriptor03
: The Dynamo 0.3 API includes a function-space descriptor asDynamoPSy
: The LFRic-specific PSy class. This creates an LFRic-specificDynFunctionSpaces
: Handles the declaration and initialisation of all function-space-relatedDynProxies
: Handles all proxy-related declarations and initialisation. Unlike otherDynCellIterators
: Handles all entities required by kernels that operate on cell-columns.DynLMAOperators
: Handles all entities associated with Local-Matrix-Assembly Operators.DynCMAOperators
: Holds all information on the Column-Matrix-Assembly operatorsDynMeshes
: Holds all mesh-related information (including colour maps ifDynInterGrid
: Holds information on quantities required by an inter-grid kernel.DynBasisFunctions
: Holds all information on the basis and differential basisDynBoundaryConditions
: Manages declarations and initialisation of quantities required byDynInvokeSchedule
: The Dynamo specific InvokeSchedule sub-class. This passes the Dynamo-DynGlobalSum
: Dynamo specific global sum class which can be added to andLFRicHaloExchange
: Dynamo specific halo exchange class which can be added to andLFRicHaloExchangeStart
: The start of an asynchronous halo exchange. This is similar to aLFRicHaloExchangeEnd
: The end of an asynchronous halo exchange. This is similar to aHaloDepth
: Determines how much of the halo a read to a field accesses (theHaloWriteAccess
: Determines how much of a field’s halo is written to (the halo depth)HaloReadAccess
: Determines how much of a field’s halo is read (the halo depth) andFSDescriptor
: Provides information about a particular function space used byFSDescriptors
: Contains a collection of FSDescriptor objects and methodsLFRicArgStencil
: Provides stencil information about an LFRic kernel argument.DynKernelArguments
: Provides information about Dynamo kernel call argumentsDynKernelArgument
: This class provides information about individual LFRic kernel callDynACCEnterDataDirective
: Sub-classes ACCEnterDataDirective to provide an API-specific implementation
- class psyclone.dynamo0p3.DynFuncDescriptor03(func_type)
The Dynamo 0.3 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
- 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.dynamo0p3.DynamoPSy(invoke_info)
The LFRic-specific PSy class. This creates an LFRic-specific Invokes object (which controls all the required invocation calls). It also overrides the PSy gen method so that we generate LFRic-specific PSy module code.
- Parameters:
invoke_info (
psyclone.parse.algorithm.FileInfo
) – object containing the required invocation information for code optimisation and generation.
Inheritance
- property gen
Generate PSy code for the LFRic (Dynamo0.3) API.
- Returns:
root node of generated Fortran AST.
- Return type:
psyir.nodes.Node
- property infrastructure_modules
- Returns:
the dictionary that holds the names of the required LFRic infrastructure modules to create “use” statements in the PSy-layer modules.
- Return type:
dict of set
- property name
- Returns:
a name for the PSy layer. This is used as the PSy module name. We override the default value as the Met Office prefer “_psy” to be appended, rather than prepended.
- Return type:
str
- property orig_name
- Returns:
the unmodified PSy-layer name.
- Return type:
str
- class psyclone.dynamo0p3.DynFunctionSpaces(kern_or_invoke)
Handles the declaration and initialisation of all function-space-related quantities required by an Invoke.
- Parameters:
invoke – the Invoke or Kernel object.
Inheritance
- initialise(parent)
Create the code that initialises function-space quantities.
- Parameters:
parent (
psyclone.f2pygen.SubroutineGen
) – the node in the f2pygen AST representing the PSy-layer routine.
- class psyclone.dynamo0p3.DynProxies(node)
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
- initialise(parent)
Insert code into the PSy layer to initialise all necessary proxies.
- Parameters:
parent (
psyclone.f2pygen.SubroutineGen
) – node in the f2pygen AST representing the PSy-layer routine.- Raises:
InternalError – if a kernel argument of an unrecognised type is encountered.
- class psyclone.dynamo0p3.DynCellIterators(kern_or_invoke)
Handles all entities required by kernels that operate on cell-columns.
- Parameters:
kern_or_invoke (
psyclone.domain.lfric.LFRicKern
orpsyclone.dynamo0p3.LFRicInvoke
) – the Kernel or Invoke for which to manage cell iterators.
: raises GenerationError: if an Invoke has no field or operator arguments.
Inheritance
- initialise(parent)
Look-up the number of vertical layers in the mesh in the PSy layer.
- Parameters:
parent (
psyclone.f2pygen.SubroutineGen
) – the f2pygen node representing the PSy-layer routine.
- class psyclone.dynamo0p3.DynLMAOperators(node)
Handles all entities associated with Local-Matrix-Assembly Operators.
Inheritance
- class psyclone.dynamo0p3.DynCMAOperators(node)
Holds all information on the Column-Matrix-Assembly operators required by an Invoke or Kernel stub.
- Parameters:
node (
psyclone.dynamo0p3.DynSchedule
orpsyclone.domain.lfric.LFRicKern
) – either an Invoke schedule or a single Kernel object.
Inheritance
- initialise(parent)
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:
parent (
psyclone.f2pygen.SubroutineGen
) – f2pygen node representing the PSy-layer routine.
- class psyclone.dynamo0p3.DynMeshes(invoke, unique_psy_vars)
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:
invoke (
psyclone.dynamo0p3.LFRicInvoke
) – the Invoke for which to extract information on all required inter-grid operations.unique_psy_vars (list of
psyclone.dynamo0p3.DynKernelArgument
objects.) – list of arguments to the PSy-layer routine.
Inheritance
- declarations(parent)
Declare variables specific to mesh objects.
- Parameters:
parent (
psyclone.f2pygen.BaseGen
) – the parent node to which to add the declarations
- initialise(parent)
Initialise parameters specific to inter-grid kernels.
- Parameters:
parent (
psyclone.f2pygen.BaseGen
) – the parent node to which to add the initialisations.
- property intergrid_kernels
- Returns:
A list of objects describing the intergrid kernels used in this invoke.
- Return type:
list[
psyclone.dynamo3p0.DynInterGrid
]
- class psyclone.dynamo0p3.DynInterGrid(fine_arg, coarse_arg)
Holds information on quantities required by an inter-grid kernel.
- Parameters:
fine_arg (
psyclone.dynamo0p3.DynKernelArgument
) – Kernel argument on the fine mesh.coarse_arg (
psyclone.dynamo0p3.DynKernelArgument
) – Kernel argument on the coarse mesh.
Inheritance
- property colourmap_symbol
- Returns:
the colour map symbol.
- Return type:
- property last_cell_var_symbol
- Returns:
the last halo/edge cell variable.
- Return type:
- property ncolours_var_symbol
- Returns:
the symbol for storing the number of colours.
- Return type:
- set_colour_info(colour_map, ncolours, last_cell)
Sets the colour_map, number of colours, and last cell of a particular colour.
- Parameters:
colour_map – the colour map symbol.
ncolours – the number of colours.
last_cell (
psyclone.psyir.symbols.Symbol
) – the last halo cell of a particular colour.
- Type:
colour_map:py:class:psyclone.psyir.symbols.Symbol
- Type:
ncolours:
psyclone.psyir.symbols.Symbol
- class psyclone.dynamo0p3.DynBasisFunctions(node)
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.dynamo0p3.DynInvokeSchedule
orpsyclone.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
- static basis_first_dim_name(function_space)
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)
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(parent)
Add code to deallocate all basis/diff-basis function arrays
- Parameters:
parent (
psyclone.f2pygen.SubroutineGen
) – node in the f2pygen AST to which the deallocate calls will be added.- Raises:
InternalError – if an unrecognised type of basis function is encountered.
- static diff_basis_first_dim_name(function_space)
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)
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(parent)
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:
parent (
psyclone.f2pygen.SubroutineGen
) – the node in the f2pygen AST that will be the parent of all of the declarations and assignments.- Raises:
InternalError – if an invalid entry is encountered in the self._basis_fns list.
- class psyclone.dynamo0p3.DynBoundaryConditions(node)
Manages declarations and initialisation of quantities required by kernels that need boundary condition information.
- Parameters:
node (
psyclone.dynamo0p3.LFRicInvoke
orpsyclone.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
- class BoundaryDofs(argument, function_space)
- argument
Alias for field number 0
- function_space
Alias for field number 1
- initialise(parent)
Initialise any boundary-dofs arrays required by an Invoke.
- Parameters:
parent (
psyclone.psyir.nodes.Node
) – node in PSyIR to which to add declarations.
- class psyclone.dynamo0p3.DynInvokeSchedule(name, arg, reserved_names=None, parent=None)
The Dynamo specific InvokeSchedule sub-class. This passes the Dynamo- specific factories for creating kernel and infrastructure calls to the base class so it creates the ones we require.
- Parameters:
name (str) – name of the Invoke.
arg (list of
psyclone.parse.algorithm.KernelCall
) – list of KernelCalls parsed from the algorithm layer.reserved_names (list of str) – optional list of names that are not allowed in the new InvokeSchedule SymbolTable.
parent (
psyclone.psyir.nodes.Node
) – the parent of this node in the PSyIR.
Inheritance
- node_str(colour=True)
Creates a text summary of this 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
- class psyclone.dynamo0p3.DynGlobalSum(scalar, parent=None)
Dynamo specific global sum class which can be added to and manipulated in a schedule.
- Parameters:
scalar (
psyclone.dynamo0p3.DynKernelArgument
) – the kernel argument for which to perform a global sum.parent (
psyclone.psyir.nodes.Node
) – the parent node of this node in the PSyIR.
- Raises:
GenerationError – if distributed memory is not enabled.
InternalError – if the supplied argument is not a scalar.
GenerationError – if the scalar is not of “real” intrinsic type.
Inheritance
- gen_code(parent)
Dynamo-specific code generation for this class.
- Parameters:
parent (
psyclone.f2pygen.SubroutineGen
) – f2pygen node to which to add AST nodes.
- class psyclone.dynamo0p3.LFRicHaloExchange(field, check_dirty=True, vector_index=None, parent=None)
Dynamo specific halo exchange class which can be added to and manipulated in a schedule.
- Parameters:
field (
psyclone.dynamo0p3.DynKernelArgument
) – the field that this halo exchange will act oncheck_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 (
psyclone.psyir.nodes.Node
) – optional PSyIRe parent node (default None) of this object
Inheritance
- gen_code(parent)
Dynamo specific code generation for this class.
- Parameters:
parent (
psyclone.f2pygen.BaseGen
) – an f2pygen object that will be the parent of f2pygen objects created in this method
- lower_to_language_level()
- Returns:
this node lowered to language-level PSyIR.
- Return type:
- node_str(colour=True)
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)
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.dynamo0p3.LFRicHaloExchangeStart(field, check_dirty=True, vector_index=None, parent=None)
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.dynamo0p3.DynKernelArgument
) – the field that this halo exchange will act oncheck_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
- required()
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.dynamo0p3.LFRicHaloExchangeEnd(field, check_dirty=True, vector_index=None, parent=None)
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.dynamo0p3.DynKernelArgument
) – the field that this halo exchange will act oncheck_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 (
psyclone.psyir.nodes.Node
) – optional PSyIRe parent node (default None) of this object
Inheritance
- class psyclone.dynamo0p3.HaloDepth(sym_table)
Determines how much of the halo a read to a field accesses (the halo depth).
- Parameters:
sym_table (
psyclone.psyir.symbols.SymbolTable
) – the symbol table of the enclosing InvokeSchedule.
Inheritance
- property annexed_only
- Returns:
True if only annexed dofs are accessed in the halo and False otherwise.
- Return type:
bool
- property literal_depth
Returns the known fixed (literal) depth of halo access. Note, this depth should be added to the var_depth to find the total depth.
- Returns:
the known fixed (literal) halo access depth.
- Return type:
int
- 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()
- Returns:
the PSyIR expression representing this HaloDepth.
- Return type:
- set_by_value(max_depth, var_depth, literal_depth, annexed_only, max_depth_m1)
Set halo depth information directly
- Parameters:
max_depth (bool) – True if the field accesses all of the halo and False otherwise
var_depth (str) – A variable name specifying the halo access depth, if one exists, and None if not
literal_depth (int) – The known fixed (literal) halo access depth
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 and False otherwise
- property var_depth
Returns the name of the variable specifying the depth of halo access if one is provided. Note, a variable will only be provided for stencil accesses. Also note, this depth should be added to the literal_depth to find the total depth.
- Returns:
a variable name specifying the halo access depth if one exists, and None if not.
- Return type:
str
- class psyclone.dynamo0p3.HaloWriteAccess(field, sym_table)
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 (
psyclone.dynamo0p3.DynArgument
) – the field that we are concerned with.sym_table (
psyclone.psyir.symbols.SymbolTable
) – the symbol table associated with the scoping region that contains this halo access.
Inheritance
- 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.dynamo0p3.HaloReadAccess(field, sym_table)
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:
field (
psyclone.dynamo0p3.DynKernelArgument
) – the field for which we want information.sym_table (
psyclone.psyir.symbols.SymbolTable
) – the symbol table associated with the scoping region that contains this halo access.
Inheritance
- 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.dynamo0p3.FSDescriptor(descriptor)
Provides information about a particular function space used by a meta-funcs entry in the kernel metadata.
Inheritance
- 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.dynamo0p3.FSDescriptors(descriptors)
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.DynFuncDescriptor03
.) – list of objects describing the basis/diff-basis functions required by a kernel, as obtained from metadata.
Inheritance
- property descriptors
- Returns:
the list of Descriptors, one for each of the meta-funcs entries in the kernel metadata.
- Return type:
List of
psyclone.dynamo0p3.FSDescriptor
- exists(fspace)
Return True if a descriptor with the specified function space exists, otherwise return False.
- get_descriptor(fspace)
Return the descriptor with the specified function space name. If it does not exist raise an error.
- class psyclone.dynamo0p3.LFRicArgStencil(name: str, extent: str = None, extent_arg: Any = None, direction_arg: Any = None)
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 – the name of the stencil.
extent – the extent of the stencil if it is known. It will be known if it is specified in the metadata.
extent_arg – the algorithm argument associated with the extent value if extent was not found in the metadata.
direction_arg – the direction argument associated with the direction of the stencil if the direction of the stencil is not known.
Inheritance
- class psyclone.dynamo0p3.DynKernelArguments(call, parent_call, check=True)
Provides information about Dynamo 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
- 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 Dynamo. Need to refactor the Invoke base class and remove the need for this property (#279).
- get_arg_on_space(func_space)
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:
- Raises:
FieldNotFoundError if no field or operator argument is found for the specified function space.
- get_arg_on_space_name(func_space_name)
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.dynamo0p3.DynKernelArgument
,psyclone.domain.lfric.FunctionSpace
)- Raises:
FieldNotFoundError if no field or operator argument is found for the named function space.
- has_operator(op_type=None)
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()
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:
- psyir_expressions()
- 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.dynamo0p3.DynKernelArgument(kernel_args, arg_meta_data, arg_info, call, check=True)
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:
kernel_args (
psyclone.dynamo0p3.DynKernelArguments
) – object encapsulating all arguments to the kernel call.arg_meta_data (
psyclone.domain.lfric.LFRicArgDescriptor
) – information obtained from the metadata for this kernel argument.arg_info (
psyclone.parse.algorithm.Arg
) – information on how this argument is specified in the Algorithm layer.call (
psyclone.domain.lfric.LFRicKern
) – the kernel object with which this argument is associated.check (bool) – whether to check for consistency between the kernel metadata and the algorithm layer. Defaults to True.
- Raises:
InternalError – for an unsupported metadata in the argument descriptor data type.
Inheritance
- 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:
- 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:
- 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:
- infer_datatype(proxy=False)
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).
- Returns:
the datatype of this argument.
- Return type:
- 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()
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:
- 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)
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:
- property vector_size
- Returns:
the vector size of this argument as specified in the Kernel metadata.
- Return type:
str
- class psyclone.dynamo0p3.DynACCEnterDataDirective(children=None, parent=None)
Sub-classes ACCEnterDataDirective to provide an API-specific implementation of data_on_device().
Inheritance
- data_on_device(_)
Provide a hook to be able to add information about data being on a device (or not). This is currently not used in dynamo0p3.