psyclone.domain.nemo.transformations.nemo_outerarrayrange2loop_trans

Module providing a transformation from an Assignment node containing an Array Reference node in its left-hand-side which in turn has at least one PSyIR Range node specifying an access to an array index (equivalent to an array assignment statement in Fortran) to the equivalent loop representation using a NemoLoop node. The outermost Range is chosen to be replaced as replacing any other Range node would result in a reordering of the array accesses.

Classes

class psyclone.domain.nemo.transformations.nemo_outerarrayrange2loop_trans.NemoOuterArrayRange2LoopTrans

Provides a transformation from the outermost PSyIR ArrayReference Range to a PSyIR NemoLoop. For example:

>>> from psyclone.parse.algorithm import parse
>>> from psyclone.psyGen import PSyFactory
>>> api = "nemo"
>>> filename = "tra_adv.F90" # examples/nemo/code
>>> ast, invoke_info = parse(filename, api=api)
>>> psy = PSyFactory(api).create(invoke_info)
>>> schedule = psy.invokes.invoke_list[0].schedule
>>>
>>> from psyclone.psyir.nodes import Assignment
>>> from psyclone.domain.nemo.transformations import             NemoOuterArrayRange2LoopTrans
>>> from psyclone.transformations import TransformationError
>>>
>>> print(schedule.view())
>>> trans = NemoOuterArrayRange2LoopTrans()
>>> for assignment in schedule.walk(Assignment):
>>>     while True:
>>>         try:
>>>             trans.apply(assignment)
>>>         except TransformationError:
>>>             break
>>> print(schedule.view())

Inheritance

Inheritance diagram of NemoOuterArrayRange2LoopTrans
apply(node, options=None)

Apply the NemoOuterArrayRange2Loop transformation to the specified node if the node is an Assignment and the left-hand-side of the assignment is an Array Reference containing at least one Range node specifying an access to an array index. If this is the case then the outermost Range nodes within array references within the assignment are replaced with references to a loop index. A NemoLoop loop (with the same loop index) is also placed around the modified assignment statement.

The name of the loop index is taken from the PSyclone configuration file if a name exists for the particular array index, otherwise a new name is generated. The bounds of the loop are taken from the Range node if they are provided. If not, the loop bounds are taken from the PSyclone configuration file if bounds values are supplied. If not, the LBOUND or UBOUND intrinsics are used as appropriate. The type of the NemoLoop is also taken from the configuration file if it is supplied for that index, otherwise it is specified as being “unknown”.

Parameters:
  • node (psyclone.psyir.nodes.Assignment) – an Assignment node.

  • options (Optional[Dict[str, Any]]) – a dictionary with options for transformations. No options are used in this transformation. This is an optional argument that defaults to None.

  • options["allow_string"] (bool) – whether to allow the transformation on a character type array range. Defaults to False.

property name
Returns:

the name of the transformation.

Return type:

str

validate(node, options=None)

Perform various checks to ensure that it is valid to apply the NemoOuterArrayRange2LoopTrans transformation to the supplied PSyIR Node.

Parameters:
  • node (psyclone.psyir.nodes.Assignment) – the node that is being checked.

  • options (Optional[Dict[str, Any]]) – a dictionary with options for transformations. No options are used in this transformation. This is an optional argument that defaults to None.

Raises:

TransformationError – if the supplied node is not an Assignment node, if the Assignment node does not have an Array-type Reference node on its left hand side or if the Array-type node does not contain at least one Range node.