psyclone.psyir.transformations.arrayrange2loop_trans

Module providing a transformation from a PSyIR Array Range to a PSyIR Loop. This could be useful for e.g. performance reasons, to allow further transformations e.g. loop fusion or if the back-end does not support array ranges.

Classes

class psyclone.psyir.transformations.arrayrange2loop_trans.ArrayRange2LoopTrans

Provides a transformation from a PSyIR Array Range to a PSyIR Loop. For example:

>>> from psyclone.parse.algorithm import parse
>>> from psyclone.psyGen import PSyFactory
>>> api = "nemo"
>>> filename = "tra_adv_compute.F90"
>>> 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.psyir.transformations import ArrayRange2LoopTrans,     >>>     TransformationError
>>>
>>> print(schedule.view())
>>> trans = ArrayRange2LoopTrans()
>>> for assignment in schedule.walk(Assignment):
>>>     while True:
>>>         try:
>>>             trans.apply(assignment)
>>>         except TransformationError:
>>>             break
>>> print(schedule.view())

Inheritance

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

Apply the ArrayRange2Loop transformation to the specified node. The node must be an assignment. The rightmost range node in each array within the assignment is replaced with a loop index and the assignment is placed within a loop iterating over that index. The bounds of the loop are determined from the bounds of the array range on the left hand side of the assignment.

Parameters:

node (psyclone.psyir.nodes.Assignment) – an Assignment node.

property name
Returns:

the name of the transformation as a string.

Return type:

str

validate(node, options=None)

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

Parameters:

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

Raises:
  • TransformationError – if the node argument is not an Assignment.

  • TransformationError – if the node argument is an Assignment whose left hand side is not an ArrayReference.

  • TransformationError – if the node argument is an Assignment whose left hand side is an ArrayReference that does not have Range specifying the access to at least one of its dimensions.

  • TransformationError – if two or more of the loop ranges in the assignment are different or are not known to be the same.