Reference Guide  2.5.0
psyclone.gocean1p0.GOKernelArguments Class Reference
Inheritance diagram for psyclone.gocean1p0.GOKernelArguments:
Collaboration diagram for psyclone.gocean1p0.GOKernelArguments:

Public Member Functions

def __init__ (self, call, parent_call, check=True)
 
def psyir_expressions (self)
 
def find_grid_access (self)
 
def dofs (self)
 
def acc_args (self)
 
def fields (self)
 
def scalars (self)
 
def append (self, name, argument_type)
 
- Public Member Functions inherited from psyclone.psyGen.Arguments
def __init__ (self, parent_call)
 
def names (self)
 
def args (self)
 
def iteration_space_arg (self)
 

Detailed Description

Provides information about GOcean kernel-call arguments
collectively, as specified by the kernel argument metadata. This
class ensures that initialisation is performed correctly. It also
overrides the iteration_space_arg method to supply a
GOcean-specific dictionary for the mapping of argument-access
types.

:param call: the kernel meta-data 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.gocean1p0.GOKern`
:param bool check: whether to check for consistency between the \
    kernel metadata and the algorithm layer. Defaults to \
    True. Currently does nothing in this API.

Definition at line 1263 of file gocean1p0.py.

Member Function Documentation

◆ acc_args()

def psyclone.gocean1p0.GOKernelArguments.acc_args (   self)
Provide the list of references (both objects and arrays) that must
be present on an OpenACC device before the kernel associated with
this Arguments object may be launched.

:returns: list of (Fortran) quantities
:rtype: list of str

Reimplemented from psyclone.psyGen.Arguments.

Definition at line 1345 of file gocean1p0.py.

1345  def acc_args(self):
1346  '''
1347  Provide the list of references (both objects and arrays) that must
1348  be present on an OpenACC device before the kernel associated with
1349  this Arguments object may be launched.
1350 
1351  :returns: list of (Fortran) quantities
1352  :rtype: list of str
1353  '''
1354  arg_list = []
1355 
1356  # First off, specify the field object which we will de-reference in
1357  # order to get any grid properties (if this kernel requires them).
1358  # We do this as some compilers do less optimisation if we get (read-
1359  # -only) grid properties from a field object that has read-write
1360  # access.
1361  grid_fld = self.find_grid_access()
1362  grid_ptr = grid_fld.name + "%grid"
1363  api_config = Config.get().api_conf("gocean1.0")
1364  # TODO: #676 go_grid_data is actually a field property
1365  data_fmt = api_config.grid_properties["go_grid_data"].fortran
1366  arg_list.extend([grid_fld.name, data_fmt.format(grid_fld.name)])
1367  for arg in self._args:
1368  if arg.argument_type == "scalar":
1369  arg_list.append(arg.name)
1370  elif arg.argument_type == "field" and arg != grid_fld:
1371  # The remote device will need the reference to the field
1372  # object *and* the reference to the array within that object.
1373  arg_list.extend([arg.name, data_fmt.format(arg.name)])
1374  elif arg.argument_type == "grid_property":
1375  if grid_ptr not in arg_list:
1376  # This kernel needs a grid property and therefore the
1377  # pointer to the grid object must be copied to the device.
1378  arg_list.append(grid_ptr)
1379  arg_list.append(grid_ptr+"%"+arg.name)
1380  return arg_list
1381 

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

Here is the call graph for this function:

◆ append()

def psyclone.gocean1p0.GOKernelArguments.append (   self,
  name,
  argument_type 
)
 Create and append a GOKernelArgument to the Argument list.

:param str name: name of the appended argument.
:param str argument_type: type of the appended argument.

:raises TypeError: if the given name is not a string.

Reimplemented from psyclone.psyGen.Arguments.

Definition at line 1407 of file gocean1p0.py.

1407  def append(self, name, argument_type):
1408  ''' Create and append a GOKernelArgument to the Argument list.
1409 
1410  :param str name: name of the appended argument.
1411  :param str argument_type: type of the appended argument.
1412 
1413  :raises TypeError: if the given name is not a string.
1414 
1415  '''
1416  if not isinstance(name, str):
1417  raise TypeError(
1418  f"The name parameter given to GOKernelArguments.append "
1419  f"method should be a string, but found "
1420  f"'{type(name).__name__}' instead.")
1421 
1422  # Create a descriptor with the given type. `len(self.args)` gives the
1423  # position in the argument list of the argument to which this
1424  # descriptor corresponds. (This argument is appended in the code
1425  # below.)
1426  descriptor = Descriptor(None, argument_type, len(self.args))
1427 
1428  # Create the argument and append it to the argument list
1429  arg = Arg("variable", name)
1430  argument = GOKernelArgument(descriptor, arg, self._parent_call)
1431  self.args.append(argument)
1432 
1433 

References psyclone.psyGen.Arguments._parent_call, psyclone.expression.FunctionVar.args, psyclone.f2pygen.SubroutineGen.args(), psyclone.parse.algorithm.ParsedCall.args(), psyclone.psyGen.GlobalSum.args(), psyclone.psyGen.HaloExchange.args(), psyclone.psyGen.Kern.args(), psyclone.psyGen.Arguments.args(), and psyclone.psyir.nodes.node.Node.args().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dofs()

def psyclone.gocean1p0.GOKernelArguments.dofs (   self)
 Currently required for invoke base class although this makes no
    sense for GOcean. Need to refactor the Invoke base class and
    remove the need for this property (#279). 

Definition at line 1338 of file gocean1p0.py.

1338  def dofs(self):
1339  ''' Currently required for invoke base class although this makes no
1340  sense for GOcean. Need to refactor the Invoke base class and
1341  remove the need for this property (#279). '''
1342  return self._dofs
1343 

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

◆ fields()

def psyclone.gocean1p0.GOKernelArguments.fields (   self)
Provides the list of names of field objects that are required by
the kernel associated with this Arguments object.

:returns: List of names of (Fortran) field objects.
:rtype: list of str

Definition at line 1383 of file gocean1p0.py.

1383  def fields(self):
1384  '''
1385  Provides the list of names of field objects that are required by
1386  the kernel associated with this Arguments object.
1387 
1388  :returns: List of names of (Fortran) field objects.
1389  :rtype: list of str
1390  '''
1391  args = args_filter(self._args, arg_types=["field"])
1392  return [arg.name for arg in args]
1393 

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

Here is the caller graph for this function:

◆ find_grid_access()

def psyclone.gocean1p0.GOKernelArguments.find_grid_access (   self)
Determine the best kernel argument from which to get properties of
the grid. For this, an argument must be a field (i.e. not
a scalar) and must be supplied by the algorithm layer
(i.e. not a grid property). If possible it should also be
a field that is read-only as otherwise compilers can get
confused about data dependencies and refuse to SIMD
vectorise.
:returns: the argument object from which to get grid properties.
:rtype: :py:class:`psyclone.gocean1p0.GOKernelArgument` or None

Definition at line 1315 of file gocean1p0.py.

1315  def find_grid_access(self):
1316  '''
1317  Determine the best kernel argument from which to get properties of
1318  the grid. For this, an argument must be a field (i.e. not
1319  a scalar) and must be supplied by the algorithm layer
1320  (i.e. not a grid property). If possible it should also be
1321  a field that is read-only as otherwise compilers can get
1322  confused about data dependencies and refuse to SIMD
1323  vectorise.
1324  :returns: the argument object from which to get grid properties.
1325  :rtype: :py:class:`psyclone.gocean1p0.GOKernelArgument` or None
1326  '''
1327  for access in [AccessType.READ, AccessType.READWRITE,
1328  AccessType.WRITE]:
1329  for arg in self._args:
1330  if arg.argument_type == "field" and arg.access == access:
1331  return arg
1332  # We failed to find any kernel argument which could be used
1333  # to access the grid properties. This will only be a problem
1334  # if the kernel requires a grid-property argument.
1335  return None
1336 

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

Here is the caller graph for this function:

◆ psyir_expressions()

def psyclone.gocean1p0.GOKernelArguments.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 1303 of file gocean1p0.py.

1303  def psyir_expressions(self):
1304  '''
1305  :returns: the PSyIR expressions representing this Argument list.
1306  :rtype: list of :py:class:`psyclone.psyir.nodes.Node`
1307 
1308  '''
1309  symtab = self._parent_call.scope.symbol_table
1310  symbol1 = symtab.lookup_with_tag("contiguous_kidx")
1311  symbol2 = symtab.lookup_with_tag("noncontiguous_kidx")
1312  return ([Reference(symbol1), Reference(symbol2)] +
1313  [arg.psyir_expression() for arg in self.args])
1314 

References psyclone.psyGen.Arguments._parent_call, psyclone.expression.FunctionVar.args, psyclone.f2pygen.SubroutineGen.args(), psyclone.parse.algorithm.ParsedCall.args(), psyclone.psyGen.GlobalSum.args(), psyclone.psyGen.HaloExchange.args(), psyclone.psyGen.Kern.args(), psyclone.psyGen.Arguments.args(), and psyclone.psyir.nodes.node.Node.args().

Here is the call graph for this function:

◆ scalars()

def psyclone.gocean1p0.GOKernelArguments.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 1395 of file gocean1p0.py.

1395  def scalars(self):
1396  '''
1397  Provides the list of names of scalar arguments required by the
1398  kernel associated with this Arguments object. If there are none
1399  then the returned list is empty.
1400 
1401  :returns: A list of the names of scalar arguments in this object.
1402  :rtype: list of str
1403  '''
1404  args = args_filter(self._args, arg_types=["scalar"])
1405  return [arg.name for arg in args]
1406 

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


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