Reference Guide  2.5.0
psyclone.psyGen.Invokes Class Reference
Inheritance diagram for psyclone.psyGen.Invokes:

Public Member Functions

def __init__ (self, alg_calls, invoke_cls, psy)
 
def __str__ (self)
 
def psy (self)
 
def names (self)
 
def get (self, invoke_name)
 
def gen_code (self, parent)
 

Public Attributes

 invoke_map
 
 invoke_list
 

Detailed Description

Manage the invoke calls.

:param alg_calls: a list of invoke metadata extracted by the \
    parser.
:type alg_calls: list of \
:py:class:`psyclone.parse.algorithm.InvokeCall`
:param invoke_cls: an api-specific Invoke class.
:type invoke_cls: subclass of :py:class:`psyclone.psyGen.Invoke`
:param psy: the PSy instance containing this Invokes instance.
:type psy: subclass of :py:class`psyclone.psyGen.PSy`

Definition at line 282 of file psyGen.py.

Constructor & Destructor Documentation

◆ __init__()

def psyclone.psyGen.Invokes.__init__ (   self,
  alg_calls,
  invoke_cls,
  psy 
)
Manage the invoke calls.

:param alg_calls: a list of invoke metadata extracted by the \
    parser.
:type alg_calls: list of \
:py:class:`psyclone.parse.algorithm.InvokeCall`
:param invoke_cls: an api-specific Invoke class.
:type invoke_cls: subclass of :py:class:`psyclone.psyGen.Invoke`
:param psy: the PSy instance containing this Invokes instance.
:type psy: subclass of :py:class`psyclone.psyGen.PSy`

Definition at line 295 of file psyGen.py.

295  def __init__(self, alg_calls, invoke_cls, psy):
296  self._psy = psy
297  self.invoke_map = {}
298  self.invoke_list = []
299  for idx, alg_invocation in enumerate(alg_calls):
300  my_invoke = invoke_cls(alg_invocation, idx, self)
301  self.invoke_map[my_invoke.name] = my_invoke
302  self.invoke_list.append(my_invoke)
303 

References psyclone.alg_gen.Alg._psy, psyclone.nemo.NemoInvokes._psy, psyclone.psyGen.Invokes._psy, psyclone.nemo.NemoInvokes.invoke_list, psyclone.psyGen.Invokes.invoke_list, psyclone.nemo.NemoInvokes.invoke_map, psyclone.psyGen.Invokes.invoke_map, psyclone.expression.ExpressionNode.names, psyclone.f2pygen.BaseDeclGen.names(), psyclone.psyGen.Invokes.names(), and psyclone.psyGen.Arguments.names().

Here is the call graph for this function:

Member Function Documentation

◆ gen_code()

def psyclone.psyGen.Invokes.gen_code (   self,
  parent 
)
Create the f2pygen AST for each Invoke in the PSy layer.

:param parent: the parent node in the AST to which to add content.
:type parent: `psyclone.f2pygen.ModuleGen`

:raises GenerationError: if an invoke_list schedule is not an \
    InvokeSchedule.

Reimplemented in psyclone.gocean1p0.GOInvokes.

Definition at line 348 of file psyGen.py.

348  def gen_code(self, parent):
349  '''
350  Create the f2pygen AST for each Invoke in the PSy layer.
351 
352  :param parent: the parent node in the AST to which to add content.
353  :type parent: `psyclone.f2pygen.ModuleGen`
354 
355  :raises GenerationError: if an invoke_list schedule is not an \
356  InvokeSchedule.
357  '''
358  for invoke in self.invoke_list:
359  if not isinstance(invoke.schedule, InvokeSchedule):
360  raise GenerationError(
361  f"An invoke.schedule element of the invoke_list is a "
362  f"'{type(invoke.schedule).__name__}', but it should be an "
363  f"'InvokeSchedule'.")
364  invoke.gen_code(parent)
365 
366 

References psyclone.nemo.NemoInvokes.invoke_list, and psyclone.psyGen.Invokes.invoke_list.

Here is the caller graph for this function:

◆ get()

def psyclone.psyGen.Invokes.get (   self,
  invoke_name 
)
Gets the Invoke with the supplied name. If the name does not already
begin with ``invoke_`` then a new name with this prepended is included
in the search if no exact match is found initially.

:param str invoke_name: the name of the Invoke to get (not case-
                        sensitive).

:returns: the invoke with the specified name.
:rtype: :py:class:`psyclone.psyGen.Invoke`

:raises RuntimeError: if no Invoke with the supplied name (with or
                      without ``invoke_`` prepended) exists.

Definition at line 320 of file psyGen.py.

320  def get(self, invoke_name):
321  '''
322  Gets the Invoke with the supplied name. If the name does not already
323  begin with ``invoke_`` then a new name with this prepended is included
324  in the search if no exact match is found initially.
325 
326  :param str invoke_name: the name of the Invoke to get (not case-
327  sensitive).
328 
329  :returns: the invoke with the specified name.
330  :rtype: :py:class:`psyclone.psyGen.Invoke`
331 
332  :raises RuntimeError: if no Invoke with the supplied name (with or
333  without ``invoke_`` prepended) exists.
334  '''
335  search_names = [invoke_name.lower()]
336  if not search_names[0].startswith("invoke_"):
337  search_names.append("invoke_"+search_names[0])
338  for name in search_names:
339  try:
340  return self.invoke_map[name]
341  except KeyError:
342  pass
343 
344  search_list = " or ".join(f"'{name}'" for name in search_names)
345  raise RuntimeError(f"Cannot find an invoke named {search_list} "
346  f"in {list(self.names)}")
347 

References psyclone.nemo.NemoInvokes.invoke_map, and psyclone.psyGen.Invokes.invoke_map.

◆ psy()

def psyclone.psyGen.Invokes.psy (   self)
:returns: the PSy instance that contains this instance.
:rtype: subclass of :py:class:`psyclone.psyGen.PSy`

Definition at line 308 of file psyGen.py.

308  def psy(self):
309  '''
310  :returns: the PSy instance that contains this instance.
311  :rtype: subclass of :py:class:`psyclone.psyGen.PSy`
312 
313  '''
314  return self._psy
315 

References psyclone.alg_gen.Alg._psy, psyclone.nemo.NemoInvokes._psy, psyclone.psyGen.Invokes._psy, psyclone.nemo.NemoInvokes.invoke_map, and psyclone.psyGen.Invokes.invoke_map.


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