Reference Guide  2.5.0
psyclone.dynamo0p3.DynKernelArguments Class Reference
Inheritance diagram for psyclone.dynamo0p3.DynKernelArguments:
Collaboration diagram for psyclone.dynamo0p3.DynKernelArguments:

Public Member Functions

def __init__ (self, call, parent_call, check=True)
 
def get_arg_on_space_name (self, func_space_name)
 
def get_arg_on_space (self, func_space)
 
def has_operator (self, op_type=None)
 
def unique_fss (self)
 
def unique_fs_names (self)
 
def iteration_space_arg (self)
 
def dofs (self)
 
def psyir_expressions (self)
 
def acc_args (self)
 
def scalars (self)
 
- Public Member Functions inherited from psyclone.psyGen.Arguments
def __init__ (self, parent_call)
 
def names (self)
 
def args (self)
 
def append (self, name, argument_type)
 

Detailed Description

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

:param call: the kernel metadata for which to extract argument info.
:type call: :py:class:`psyclone.parse.KernelCall`
:param parent_call: the kernel-call object.
:type parent_call: :py:class:`psyclone.domain.lfric.LFRicKern`
:param bool check: 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.

Definition at line 5035 of file dynamo0p3.py.

Member Function Documentation

◆ acc_args()

def psyclone.dynamo0p3.DynKernelArguments.acc_args (   self)
:returns: the list of quantities that must be available on an \
          OpenACC device before the associated kernel can be launched.
:rtype: list of str

Reimplemented from psyclone.psyGen.Arguments.

Definition at line 5324 of file dynamo0p3.py.

5324  def acc_args(self):
5325  '''
5326  :returns: the list of quantities that must be available on an \
5327  OpenACC device before the associated kernel can be launched.
5328  :rtype: list of str
5329 
5330  '''
5331  create_acc_arg_list = KernCallAccArgList(self._parent_call)
5332  create_acc_arg_list.generate()
5333  return create_acc_arg_list.arglist
5334 

References psyclone.psyGen.Arguments._parent_call.

◆ dofs()

def psyclone.dynamo0p3.DynKernelArguments.dofs (   self)
 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). 

Definition at line 5307 of file dynamo0p3.py.

5307  def dofs(self):
5308  ''' Currently required for Invoke base class although this
5309  makes no sense for Dynamo. Need to refactor the Invoke base class
5310  and remove the need for this property (#279). '''
5311  return self._dofs
5312 

References psyclone.dynamo0p3.DynKernelArguments._dofs, psyclone.gocean1p0.GOKernelArguments._dofs, and psyclone.psyGen.Invoke._dofs.

◆ get_arg_on_space()

def psyclone.dynamo0p3.DynKernelArguments.get_arg_on_space (   self,
  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.

:param func_space: The function space for which to find an argument.
:type func_space: :py:class:`psyclone.domain.lfric.FunctionSpace`
:return: the first kernel argument that is on the supplied function
         space
:rtype: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
:raises: FieldNotFoundError if no field or operator argument is found
         for the specified function space.

Definition at line 5178 of file dynamo0p3.py.

5178  def get_arg_on_space(self, func_space):
5179  '''
5180  Returns the first argument (field or operator) found that is on
5181  the specified function space. The mangled name of the supplied
5182  function space is used for comparison.
5183 
5184  :param func_space: The function space for which to find an argument.
5185  :type func_space: :py:class:`psyclone.domain.lfric.FunctionSpace`
5186  :return: the first kernel argument that is on the supplied function
5187  space
5188  :rtype: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
5189  :raises: FieldNotFoundError if no field or operator argument is found
5190  for the specified function space.
5191  '''
5192  for arg in self._args:
5193  for function_space in arg.function_spaces:
5194  if function_space:
5195  if func_space.mangled_name == function_space.mangled_name:
5196  return arg
5197 
5198  raise FieldNotFoundError(f"DynKernelArguments:get_arg_on_space: there "
5199  f"is no field or operator with function space"
5200  f" {func_space.orig_name} (mangled name = "
5201  f"'{func_space.mangled_name}')")
5202 

References psyclone.dynamo0p3.DynKernelArguments._args, psyclone.gocean1p0.GOKernelArguments._args, psyclone.parse.algorithm.ParsedCall._args, and psyclone.psyGen.Arguments._args.

◆ get_arg_on_space_name()

def psyclone.dynamo0p3.DynKernelArguments.get_arg_on_space_name (   self,
  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.

:param str func_space_name: Name of the function space (as specified \
                            in kernel metadata) for which to \
                            find an argument.
:return: the first kernel argument that is on the named function \
         space and the associated FunctionSpace object.
:rtype: (:py:class:`psyclone.dynamo0p3.DynKernelArgument`,
         :py:class:`psyclone.domain.lfric.FunctionSpace`)
:raises: FieldNotFoundError if no field or operator argument is found \
         for the named function space.

Definition at line 5153 of file dynamo0p3.py.

5153  def get_arg_on_space_name(self, func_space_name):
5154  '''
5155  Returns the first argument (field or operator) found that is on
5156  the named function space, as specified in the kernel metadata. Also
5157  returns the associated FunctionSpace object.
5158 
5159  :param str func_space_name: Name of the function space (as specified \
5160  in kernel metadata) for which to \
5161  find an argument.
5162  :return: the first kernel argument that is on the named function \
5163  space and the associated FunctionSpace object.
5164  :rtype: (:py:class:`psyclone.dynamo0p3.DynKernelArgument`,
5165  :py:class:`psyclone.domain.lfric.FunctionSpace`)
5166  :raises: FieldNotFoundError if no field or operator argument is found \
5167  for the named function space.
5168  '''
5169  for arg in self._args:
5170  for function_space in arg.function_spaces:
5171  if function_space:
5172  if func_space_name == function_space.orig_name:
5173  return arg, function_space
5174  raise FieldNotFoundError(f"DynKernelArguments:get_arg_on_space_name: "
5175  f"there is no field or operator with "
5176  f"function space {func_space_name}")
5177 

References psyclone.dynamo0p3.DynKernelArguments._args, psyclone.gocean1p0.GOKernelArguments._args, psyclone.parse.algorithm.ParsedCall._args, and psyclone.psyGen.Arguments._args.

◆ has_operator()

def psyclone.dynamo0p3.DynKernelArguments.has_operator (   self,
  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. 

Definition at line 5203 of file dynamo0p3.py.

5203  def has_operator(self, op_type=None):
5204  ''' Returns true if at least one of the arguments is an operator
5205  of type op_type (either gh_operator [LMA] or gh_columnwise_operator
5206  [CMA]). If op_type is None then searches for *any* valid operator
5207  type. '''
5208  const = LFRicConstants()
5209  if op_type and op_type not in const.VALID_OPERATOR_NAMES:
5210  raise GenerationError(
5211  f"If supplied, 'op_type' must be a valid operator type (one "
5212  f"of {const.VALID_OPERATOR_NAMES}) but got '{op_type}'")
5213  if not op_type:
5214  # If no operator type is specified then we match any type
5215  op_list = const.VALID_OPERATOR_NAMES
5216  else:
5217  op_list = [op_type]
5218  for arg in self._args:
5219  if arg.argument_type in op_list:
5220  return True
5221  return False
5222 

References psyclone.dynamo0p3.DynKernelArguments._args, psyclone.gocean1p0.GOKernelArguments._args, psyclone.parse.algorithm.ParsedCall._args, and psyclone.psyGen.Arguments._args.

◆ iteration_space_arg()

def psyclone.dynamo0p3.DynKernelArguments.iteration_space_arg (   self)
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.

:return: Kernel argument from which to obtain iteration space
:rtype: :py:class:`psyclone.dynamo0p3.DynKernelArgument`

Reimplemented from psyclone.psyGen.Arguments.

Definition at line 5236 of file dynamo0p3.py.

5236  def iteration_space_arg(self):
5237  '''
5238  Returns an argument we can use to dereference the iteration
5239  space. This can be a field or operator that is modified or
5240  alternatively a field that is read if one or more scalars
5241  are modified. If a kernel writes to more than one argument then
5242  that requiring the largest iteration space is selected.
5243 
5244  :return: Kernel argument from which to obtain iteration space
5245  :rtype: :py:class:`psyclone.dynamo0p3.DynKernelArgument`
5246  '''
5247 
5248  # Since we always compute operators out to the L1 halo we first
5249  # check whether this kernel writes to an operator
5250  write_accesses = AccessType.all_write_accesses()
5251  const = LFRicConstants()
5252  op_args = psyGen.args_filter(
5253  self._args,
5254  arg_types=const.VALID_OPERATOR_NAMES,
5255  arg_accesses=write_accesses)
5256  if op_args:
5257  return op_args[0]
5258 
5259  # Is this an inter-grid kernel? If so, then the iteration space
5260  # is determined by the coarse mesh, irrespective of whether
5261  # we are prolonging (and thus writing to a field on the fine mesh)
5262  # or restricting.
5263  if self._parent_call.is_intergrid:
5264  fld_args = psyGen.args_filter(
5265  self._args,
5266  arg_types=const.VALID_FIELD_NAMES,
5267  arg_meshes=["gh_coarse"])
5268  return fld_args[0]
5269 
5270  # This is not an inter-grid kernel and it does not write to an
5271  # operator. We now check for fields that are written to. We
5272  # check first for any modified field on a continuous function
5273  # space, failing that we try any_space function spaces
5274  # (because we must assume such a space is continuous) and
5275  # finally we try all discontinuous function spaces including
5276  # any_discontinuous_space. We do this because if a quantity on
5277  # a continuous FS is modified then our iteration space must be
5278  # larger (include L1-halo cells)
5279  const = LFRicConstants()
5280  write_accesses = AccessType.all_write_accesses()
5281  fld_args = psyGen.args_filter(
5282  self._args,
5283  arg_types=const.VALID_FIELD_NAMES,
5284  arg_accesses=write_accesses)
5285  if fld_args:
5286  for spaces in [const.CONTINUOUS_FUNCTION_SPACES,
5287  const.VALID_ANY_SPACE_NAMES,
5288  const.VALID_DISCONTINUOUS_NAMES]:
5289  for arg in fld_args:
5290  if arg.function_space.orig_name in spaces:
5291  return arg
5292 
5293  # No modified fields or operators. Check for unmodified fields...
5294  fld_args = psyGen.args_filter(
5295  self._args,
5296  arg_types=const.VALID_FIELD_NAMES)
5297  if fld_args:
5298  return fld_args[0]
5299 
5300  # it is an error if we get to here
5301  raise GenerationError(
5302  "iteration_space_arg(). The dynamo0.3 api must have a modified "
5303  "field, a modified operator, or an unmodified field (in the case "
5304  "of a modified scalar). None of these were found.")
5305 

References psyclone.dynamo0p3.DynKernelArguments._args, psyclone.gocean1p0.GOKernelArguments._args, psyclone.parse.algorithm.ParsedCall._args, psyclone.psyGen.Arguments._args, and psyclone.psyGen.Arguments._parent_call.

◆ psyir_expressions()

def psyclone.dynamo0p3.DynKernelArguments.psyir_expressions (   self)
:returns: the PSyIR expressions representing this Argument list.
:rtype: list of :py:class:`psyclone.psyir.nodes.Node`

Reimplemented from psyclone.psyGen.Arguments.

Definition at line 5313 of file dynamo0p3.py.

5313  def psyir_expressions(self):
5314  '''
5315  :returns: the PSyIR expressions representing this Argument list.
5316  :rtype: list of :py:class:`psyclone.psyir.nodes.Node`
5317 
5318  '''
5319  create_arg_list = KernCallArgList(self._parent_call)
5320  create_arg_list.generate()
5321  return create_arg_list.psyir_arglist
5322 

References psyclone.psyGen.Arguments._parent_call.

◆ scalars()

def psyclone.dynamo0p3.DynKernelArguments.scalars (   self)
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.
:rtype: list of str

Reimplemented from psyclone.psyGen.Arguments.

Definition at line 5336 of file dynamo0p3.py.

5336  def scalars(self):
5337  '''
5338  Provides the list of names of scalar arguments required by the
5339  kernel associated with this Arguments object. If there are none
5340  then the returned list is empty.
5341 
5342  :returns: A list of the names of scalar arguments in this object.
5343  :rtype: list of str
5344  '''
5345  # Return nothing for the moment as it is unclear whether
5346  # scalars need to be explicitly dealt with (for OpenACC) in
5347  # the dynamo api.
5348  return []
5349 
5350 

◆ unique_fs_names()

def psyclone.dynamo0p3.DynKernelArguments.unique_fs_names (   self)
 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) 

Definition at line 5230 of file dynamo0p3.py.

5230  def unique_fs_names(self):
5231  ''' Return the list of unique function space names used by the
5232  arguments of this kernel. The names are unmangled (i.e. as
5233  specified in the kernel metadata) '''
5234  return self._unique_fs_names
5235 

References psyclone.dynamo0p3.DynKernelArguments._unique_fs_names.

◆ unique_fss()

def psyclone.dynamo0p3.DynKernelArguments.unique_fss (   self)
 Returns a unique list of function space objects used by the
arguments of this kernel 

Definition at line 5224 of file dynamo0p3.py.

5224  def unique_fss(self):
5225  ''' Returns a unique list of function space objects used by the
5226  arguments of this kernel '''
5227  return self._unique_fss
5228 

References psyclone.dynamo0p3.DynKernelArguments._unique_fss.


The documentation for this class was generated from the following file: