psyclone.alg_gen

This module provides the Alg class and supporting exception-handling to translate the original algorithm file into one that can be compiled and linked with the generated PSy code.

Classes

  • Alg: Generate a modified algorithm code for a single algorithm

class psyclone.alg_gen.Alg(parse_tree, psy, invoke_name='invoke')

Generate a modified algorithm code for a single algorithm specification. Takes the parse tree of the algorithm specification output from the function psyclone.parse.algorithm.parse() and an instance of the psyGen.PSy class as input. The latter allows consistent names to be generated between the algorithm (callng) and psy (callee) layers.

For example:

>>> from psyclone.algorithm.parse import parse
>>> parse_tree, info = parse("argspec.F90")
>>> from psyclone.psyGen import PSy
>>> psy = PSy(info)
>>> from psyclone.alg_gen import Alg
>>> alg = Alg(parse_tree, psy)
>>> print(alg.gen)
Parameters:
  • parse_tree (fparser.two.utils.Base) – an object containing a parse tree of the algorithm specification which was produced by the function psyclone.parse.algorithm.parse(). Assumes the algorithm will be parsed by fparser2 and expects a valid program unit, program, module, subroutine or function.

  • psy (psyclone.psyGen.PSy) – an object containing information about the PSy layer.

  • invoke_name (str) – the name that the algorithm layer uses to indicate an invoke call. This is an optional argument that defaults to the name “invoke”.

Inheritance

Inheritance diagram of Alg
property gen

Modifies and returns the algorithm code. ‘invoke’ calls are replaced with calls to the corresponding PSy-layer routines and the USE statements for the kernels that were referenced by each ‘invoke’ are removed.

Returns:

the modified algorithm specification as an fparser2 parse tree.

Return type:

fparser.two.utils.Base

Raises:

NoInvokesError – if no ‘invoke()’ calls are found.

Exceptions

  • NoInvokesError: Provides a PSyclone-specific error class for the situation when an

exception psyclone.alg_gen.NoInvokesError(value)

Provides a PSyclone-specific error class for the situation when an algorithm code contains no invoke calls.

Parameters:

value (str) – the message associated with the error.

Inheritance

Inheritance diagram of NoInvokesError