Reference Guide  2.5.0
psyclone.psyGen.PSyFactory Class Reference

Public Member Functions

def __init__ (self, api="", distributed_memory=None)
 
def create (self, invoke_info)
 

Detailed Description

Creates a specific version of the PSy. If a particular api is not
provided then the default api, as specified in the psyclone.cfg
file, is chosen.

:param str api: name of the PSyclone API (domain) for which to create \
    a factory.
:param bool distributed_memory: whether or not the PSy object created \
    will include support for distributed-memory parallelism.

:raises TypeError: if the distributed_memory argument is not a bool.

Definition at line 152 of file psyGen.py.

Member Function Documentation

◆ create()

def psyclone.psyGen.PSyFactory.create (   self,
  invoke_info 
)
Create the API-specific PSy instance.

:param invoke_info: information on the invoke()s found by parsing \
                    the Algorithm layer or (for NEMO) the fparser2 \
                    parse tree of the source file.
:type invoke_info: :py:class:`psyclone.parse.algorithm.FileInfo` or \
                   :py:class:`fparser.two.Fortran2003.Program`

:returns: an instance of the API-specific sub-class of PSy.
:rtype: subclass of :py:class:`psyclone.psyGen.PSy`

:raises InternalError: if this factory is found to have an \
                       unsupported type (API).

Definition at line 183 of file psyGen.py.

183  def create(self, invoke_info):
184  '''
185  Create the API-specific PSy instance.
186 
187  :param invoke_info: information on the invoke()s found by parsing \
188  the Algorithm layer or (for NEMO) the fparser2 \
189  parse tree of the source file.
190  :type invoke_info: :py:class:`psyclone.parse.algorithm.FileInfo` or \
191  :py:class:`fparser.two.Fortran2003.Program`
192 
193  :returns: an instance of the API-specific sub-class of PSy.
194  :rtype: subclass of :py:class:`psyclone.psyGen.PSy`
195 
196  :raises InternalError: if this factory is found to have an \
197  unsupported type (API).
198  '''
199  # Conditional run-time importing is a part of this factory
200  # implementation.
201  # pylint: disable=import-outside-toplevel
202  if self._type == "dynamo0.3":
203  from psyclone.dynamo0p3 import DynamoPSy as PSyClass
204  elif self._type == "gocean1.0":
205  from psyclone.gocean1p0 import GOPSy as PSyClass
206  elif self._type == "nemo":
207  from psyclone.nemo import NemoPSy as PSyClass
208  # For this API, the 'invoke_info' is actually the fparser2 AST
209  # of the Fortran file being processed
210  else:
211  raise InternalError(
212  f"PSyFactory: Unsupported API type '{self._type}' found. "
213  f"Expected one of {Config.get().supported_apis}.")
214  return PSyClass(invoke_info)
215 
216 

References psyclone.parse.kernel.KernelTypeFactory._type, and psyclone.psyGen.PSyFactory._type.

Here is the caller graph for this function:

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