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

Public Member Functions

def __init__ (self, call, parent=None)
 
def reference_accesses (self, var_accesses)
 
def local_vars (self)
 
def index_offset (self)
 
def get_kernel_schedule (self)
 
- Public Member Functions inherited from psyclone.psyGen.CodedKern
def __init__ (self, KernelArguments, call, parent=None, check=True)
 
def opencl_options (self)
 
def set_opencl_options (self, options)
 
def __str__ (self)
 
def module_name (self)
 
def dag_name (self)
 
def module_inline (self)
 
def module_inline (self, value)
 
def node_str (self, colour=True)
 
def lower_to_language_level (self)
 
def incremented_arg (self)
 
def ast (self)
 
def rename_and_write (self)
 
def modified (self)
 
def modified (self, value)
 
- Public Member Functions inherited from psyclone.psyGen.Kern
def __init__ (self, parent, call, name, ArgumentsClass, check=True)
 
def args (self)
 
def is_reduction (self)
 
def reduction_arg (self)
 
def reprod_reduction (self)
 
def local_reduction_name (self)
 
def zero_reduction_variable (self, parent, position=None)
 
def reduction_sum_loop (self, parent)
 
def arg_descriptors (self)
 
def arg_descriptors (self, obj)
 
def arguments (self)
 
def name (self)
 
def name (self, value)
 
def is_coloured (self)
 
def iterates_over (self)
 
def gen_code (self, parent)
 

Additional Inherited Members

- Public Attributes inherited from psyclone.psyGen.CodedKern
 arg_descriptors
 
 modified
 
 name
 

Detailed Description

Stores information about GOcean Kernels as specified by the Kernel
metadata. Uses this information to generate appropriate PSy layer
code for the Kernel instance. Specialises the gen_code method to
create the appropriate GOcean specific kernel call.

:param call: information on the way in which this kernel is called \
             from the Algorithm layer.
:type call: :py:class:`psyclone.parse.algorithm.KernelCall`
:param parent: optional node where the kernel call will be inserted.
:type parent: :py:class:`psyclone.psyir.nodes.Node`

Definition at line 1071 of file gocean1p0.py.

Member Function Documentation

◆ get_kernel_schedule()

def psyclone.gocean1p0.GOKern.get_kernel_schedule (   self)
:returns: a schedule representing the GOcean kernel code.
:rtype: :py:class:`psyclone.gocean1p0.GOKernelSchedule`

:raises GenerationError: if there is a problem raising the language- \
                         level PSyIR of this kernel to GOcean PSyIR.

Reimplemented from psyclone.psyGen.CodedKern.

Definition at line 1228 of file gocean1p0.py.

1228  def get_kernel_schedule(self):
1229  '''
1230  :returns: a schedule representing the GOcean kernel code.
1231  :rtype: :py:class:`psyclone.gocean1p0.GOKernelSchedule`
1232 
1233  :raises GenerationError: if there is a problem raising the language- \
1234  level PSyIR of this kernel to GOcean PSyIR.
1235  '''
1236  if self._kern_schedule:
1237  return self._kern_schedule
1238 
1239  # Construct the PSyIR of the Fortran parse tree.
1240  astp = Fparser2Reader()
1241  psyir = astp.generate_psyir(self.ast)
1242  # pylint: disable=import-outside-toplevel
1244  RaisePSyIR2GOceanKernTrans)
1245  raise_trans = RaisePSyIR2GOceanKernTrans(self._metadata_name)
1246  try:
1247  raise_trans.apply(psyir)
1248  except Exception as err:
1249  raise GenerationError(
1250  f"Failed to raise the PSyIR for kernel '{self.name}' "
1251  f"to GOcean PSyIR. Error was:\n{err}") from err
1252  for routine in psyir.walk(Routine):
1253  if routine.name == self.name:
1254  break
1255  # We know the above loop will find the named routine because the
1256  # previous raising transformation would have failed otherwise.
1257  # pylint: disable=undefined-loop-variable
1258  self._kern_schedule = routine
1259 
1260  return self._kern_schedule
1261 
1262 

References psyclone.domain.lfric.lfric_kern.LFRicKern._kern_schedule, psyclone.gocean1p0.GOKern._kern_schedule, psyclone.psyGen.CodedKern._kern_schedule, psyclone.domain.gocean.transformations.raise_psyir_2_gocean_kern_trans.RaisePSyIR2GOceanKernTrans._metadata_name, psyclone.gocean1p0.GOKern._metadata_name, psyclone.parse.kernel.KernelProcedure.ast(), psyclone.psyGen.CodedKern.ast(), psyclone.psyir.nodes.codeblock.CodeBlock.ast, psyclone.psyir.nodes.node.Node.ast(), psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.name, psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.GridArg.name, psyclone.domain.gocean.transformations.gocean_const_loop_bounds_trans.GOConstLoopBoundsTrans.name(), psyclone.domain.gocean.transformations.gocean_move_iteration_boundaries_inside_kernel_trans.GOMoveIterationBoundariesInsideKernelTrans.name(), psyclone.domain.gocean.transformations.gocean_opencl_trans.GOOpenCLTrans.name(), psyclone.domain.lfric.kernel.lfric_kernel_metadata.LFRicKernelMetadata.name, psyclone.domain.nemo.transformations.create_nemo_invoke_schedule_trans.CreateNemoInvokeScheduleTrans.name(), psyclone.domain.nemo.transformations.create_nemo_psy_trans.CreateNemoPSyTrans.name(), psyclone.domain.nemo.transformations.nemo_allarrayrange2loop_trans.NemoAllArrayRange2LoopTrans.name(), psyclone.domain.nemo.transformations.nemo_arrayrange2loop_trans.NemoArrayRange2LoopTrans.name(), psyclone.domain.nemo.transformations.nemo_outerarrayrange2loop_trans.NemoOuterArrayRange2LoopTrans.name(), psyclone.dynamo0p3.DynamoPSy.name(), psyclone.expression.FunctionVar.name, psyclone.expression.NamedArg.name(), psyclone.gocean1p0.GOKernelGridArgument.name(), psyclone.gocean1p0.GOStencil.name(), psyclone.parse.algorithm.FileInfo.name(), psyclone.parse.algorithm.InvokeCall.name(), psyclone.parse.kernel.KernelProcedure.name(), psyclone.parse.kernel.KernelType.name(), psyclone.parse.module_info.ModuleInfo.name(), psyclone.psyad.transformations.assignment_trans.AssignmentTrans.name(), psyclone.psyGen.PSy.name(), psyclone.psyGen.Invoke.name(), psyclone.psyGen.Kern.name(), psyclone.psyGen.CodedKern.name, psyclone.psyGen.Argument.name(), psyclone.psyGen.Transformation.name(), psyclone.psyGen.DummyTransformation.name(), psyclone.psyir.nodes.container.Container.name, psyclone.psyir.nodes.member.Member.name, psyclone.psyir.nodes.reference.Reference.name(), psyclone.psyir.nodes.routine.Routine.name, psyclone.psyir.symbols.symbol.Symbol.name(), psyclone.psyir.transformations.allarrayaccess2loop_trans.AllArrayAccess2LoopTrans.name(), psyclone.psyir.transformations.arrayrange2loop_trans.ArrayRange2LoopTrans.name(), psyclone.psyir.transformations.fold_conditional_return_expressions_trans.FoldConditionalReturnExpressionsTrans.name(), psyclone.psyir.transformations.loop_trans.LoopTrans.name(), psyclone.psyir.transformations.omp_task_trans.OMPTaskTrans.name(), psyclone.psyir.transformations.psy_data_trans.PSyDataTrans.name(), psyclone.transformations.OMPSingleTrans.name(), psyclone.transformations.OMPMasterTrans.name(), psyclone.transformations.OMPParallelTrans.name(), psyclone.transformations.MoveTrans.name(), psyclone.transformations.Dynamo0p3AsyncHaloExchangeTrans.name(), psyclone.transformations.Dynamo0p3KernelConstTrans.name(), psyclone.transformations.ACCEnterDataTrans.name(), psyclone.transformations.ACCRoutineTrans.name(), psyclone.transformations.ACCKernelsTrans.name(), psyclone.transformations.ACCDataTrans.name(), and psyclone.transformations.KernelImportsToArguments.name().

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

◆ index_offset()

def psyclone.gocean1p0.GOKern.index_offset (   self)
 The grid index-offset convention that this kernel expects 

Definition at line 1224 of file gocean1p0.py.

1224  def index_offset(self):
1225  ''' The grid index-offset convention that this kernel expects '''
1226  return self._index_offset
1227 

References psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata._index_offset, psyclone.gocean1p0.GOKern._index_offset, and psyclone.gocean1p0.GOKernelType1p0._index_offset.

Here is the caller graph for this function:

◆ local_vars()

def psyclone.gocean1p0.GOKern.local_vars (   self)
Return a list of the variable (names) that are local to this loop
(and must therefore be e.g. threadprivate if doing OpenMP)

Reimplemented from psyclone.psyGen.Kern.

Definition at line 1216 of file gocean1p0.py.

1216  def local_vars(self):
1217  '''Return a list of the variable (names) that are local to this loop
1218  (and must therefore be e.g. threadprivate if doing OpenMP)
1219 
1220  '''
1221  return []
1222 

◆ reference_accesses()

def psyclone.gocean1p0.GOKern.reference_accesses (   self,
  var_accesses 
)
Get all variable access information. All accesses are marked
according to the kernel metadata.

:param var_accesses: VariablesAccessInfo instance that stores the\
    information about variable accesses.
:type var_accesses: \
    :py:class:`psyclone.core.VariablesAccessInfo`

Reimplemented from psyclone.psyGen.Kern.

Definition at line 1170 of file gocean1p0.py.

1170  def reference_accesses(self, var_accesses):
1171  '''Get all variable access information. All accesses are marked
1172  according to the kernel metadata.
1173 
1174  :param var_accesses: VariablesAccessInfo instance that stores the\
1175  information about variable accesses.
1176  :type var_accesses: \
1177  :py:class:`psyclone.core.VariablesAccessInfo`
1178 
1179  '''
1180  # Grid properties are accessed using one of the fields. This stores
1181  # the field used to avoid repeatedly determining the best field:
1182  field_for_grid_property = None
1183  for arg in self.arguments.args:
1184  if arg.argument_type == "grid_property":
1185  if not field_for_grid_property:
1186  field_for_grid_property = \
1187  self._arguments.find_grid_access()
1188  var_name = arg.dereference(field_for_grid_property.name)
1189  else:
1190  var_name = arg.name
1191 
1192  signature = Signature(var_name.split("%"))
1193  if arg.is_scalar:
1194  # The argument is only a variable if it is not a constant:
1195  if not arg.is_literal:
1196  var_accesses.add_access(signature, arg.access, self)
1197  else:
1198  if arg.argument_type == "field":
1199  # Now add 'artificial' accesses to this field depending
1200  # on meta-data (access-mode and stencil information):
1201  self._record_stencil_accesses(signature, arg,
1202  var_accesses)
1203  else:
1204  # In case of an array for now add an arbitrary array
1205  # reference to (i,j) so it is properly recognised as
1206  # an array access.
1207  sym_tab = self.ancestor(GOInvokeSchedule).symbol_table
1208  symbol_i = sym_tab.lookup_with_tag("contiguous_kidx")
1209  symbol_j = sym_tab.lookup_with_tag("noncontiguous_kidx")
1210  var_accesses.add_access(signature, arg.access,
1211  self, [Reference(symbol_i),
1212  Reference(symbol_j)])
1213  super().reference_accesses(var_accesses)
1214  var_accesses.next_location()
1215 

References psyclone.domain.lfric.lfric_kern.LFRicKern._arguments, psyclone.psyGen.Kern._arguments, psyclone.psyGen.InlinedKern._arguments, psyclone.gocean1p0.GOKern._record_stencil_accesses(), psyclone.psyir.nodes.node.Node.ancestor(), psyclone.psyGen.Kern.arguments(), and psyclone.psyir.nodes.call.Call.arguments().

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

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