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

Public Member Functions

def __init__ (self, node)
 
def initialise (self, parent)
 
- Public Member Functions inherited from psyclone.domain.lfric.lfric_collection.LFRicCollection
def declarations (self, parent)
 

Detailed Description

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.

Definition at line 1303 of file dynamo0p3.py.

Member Function Documentation

◆ initialise()

def psyclone.dynamo0p3.DynProxies.initialise (   self,
  parent 
)
Insert code into the PSy layer to initialise all necessary proxies.

:param parent: node in the f2pygen AST representing the PSy-layer
               routine.
:type parent: :py:class:`psyclone.f2pygen.SubroutineGen`

:raises InternalError: if a kernel argument of an unrecognised type
    is encountered.

Reimplemented from psyclone.domain.lfric.lfric_collection.LFRicCollection.

Definition at line 1547 of file dynamo0p3.py.

1547  def initialise(self, parent):
1548  '''
1549  Insert code into the PSy layer to initialise all necessary proxies.
1550 
1551  :param parent: node in the f2pygen AST representing the PSy-layer
1552  routine.
1553  :type parent: :py:class:`psyclone.f2pygen.SubroutineGen`
1554 
1555  :raises InternalError: if a kernel argument of an unrecognised type
1556  is encountered.
1557 
1558  '''
1559  parent.add(CommentGen(parent, ""))
1560  parent.add(CommentGen(parent,
1561  " Initialise field and/or operator proxies"))
1562  parent.add(CommentGen(parent, ""))
1563  for arg in self._invoke.psy_unique_vars:
1564  # We don't have proxies for scalars
1565  if arg.is_scalar:
1566  continue
1567 
1568  const = LFRicConstants()
1569  suffix = const.ARG_TYPE_SUFFIX_MAPPING[arg.argument_type]
1570 
1571  if arg.vector_size > 1:
1572  # the range function below returns values from
1573  # 1 to the vector size which is what we
1574  # require in our Fortran code
1575  for idx in range(1, arg.vector_size+1):
1576  parent.add(
1577  AssignGen(parent,
1578  lhs=arg.proxy_name+"("+str(idx)+")",
1579  rhs=arg.name+"("+str(idx)+")%get_proxy()"))
1580  name = self._symbol_table.lookup_with_tag(
1581  f"{arg.name}_{idx}:{suffix}").name
1582  parent.add(
1583  AssignGen(parent,
1584  lhs=name,
1585  rhs=f"{arg.proxy_name}({idx})%data",
1586  pointer=True))
1587  else:
1588  parent.add(AssignGen(parent, lhs=arg.proxy_name,
1589  rhs=arg.name+"%get_proxy()"))
1590  if arg.is_field:
1591  name = self._symbol_table.lookup_with_tag(
1592  f"{arg.name}:{suffix}").name
1593  parent.add(
1594  AssignGen(parent,
1595  lhs=name,
1596  rhs=f"{arg.proxy_name}%data",
1597  pointer=True))
1598  elif arg.is_operator:
1599  if arg.argument_type == "gh_columnwise_operator":
1600  # CMA operator arguments are handled in DynCMAOperators
1601  pass
1602  elif arg.argument_type == "gh_operator":
1603  name = self._symbol_table.lookup_with_tag(
1604  f"{arg.name}:{suffix}").name
1605  parent.add(
1606  AssignGen(parent,
1607  lhs=name,
1608  rhs=f"{arg.proxy_name}%local_stencil",
1609  pointer=True))
1610  else:
1611  raise InternalError(
1612  f"Kernel argument '{arg.name}' is a recognised "
1613  f"operator but its type ('{arg.argument_type}') is"
1614  f" not supported by DynProxies.initialise()")
1615  else:
1616  raise InternalError(
1617  f"Kernel argument '{arg.name}' of type "
1618  f"'{arg.argument_type}' not "
1619  f"handled in DynProxies.initialise()")
1620 
1621 

References psyclone.domain.lfric.lfric_collection.LFRicCollection._invoke, psyclone.nemo.NemoInvokeSchedule._invoke, psyclone.psyGen.InvokeSchedule._invoke, psyclone.domain.lfric.lfric_collection.LFRicCollection._symbol_table, psyclone.dynamo0p3.DynMeshes._symbol_table, psyclone.dynamo0p3.HaloDepth._symbol_table, psyclone.psyGen.HaloExchange._symbol_table, psyclone.psyir.backend.sympy_writer.SymPyWriter._symbol_table, and psyclone.psyir.nodes.scoping_node.ScopingNode._symbol_table.


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