psyclone.domain.gocean.transformations.gocean_loop_fuse_trans#

This module contains the GOcean-specific loop-fusion transformation.

Classes#

class psyclone.domain.gocean.transformations.gocean_loop_fuse_trans.GOceanLoopFuseTrans[source]#

GOcean API specialisation of the base class in order to fuse two GOcean loops after performing validity checks (e.g. that the loops are over the same grid-point type). For example:

>>> from psyclone.parse.algorithm import parse
>>> from psyclone.psyGen import PSyFactory
>>> ast, invokeInfo = parse("shallow_alg.f90")
>>> psy = PSyFactory("gocean").create(invokeInfo)
>>> schedule = psy.invokes.get('invoke_0').schedule
>>> print(schedule.view())
>>>
>>> from psyclone.transformations import GOceanLoopFuseTrans
>>> ftrans = GOceanLoopFuseTrans()
>>> ftrans.apply(schedule[0], schedule[1])
>>> print(schedule.view())

Inheritance

Inheritance diagram of GOceanLoopFuseTrans
apply(node1, node2, options=None, **kwargs)[source]#

Applies the GoceanLoopFuseTrans to the provided nodes.

Parameters:
  • node1 (GOLoop) – the first Node representing a GOLoop.

  • node2 (GOLoop) – the second Node representing a GOLoop.

  • force (bool) – whether to force fusion of the target loop (i.e. ignore any dependence analysis). This only skips a limited number of the checks, and does not fully force merging.

  • node_type_check (bool) – If the type of nodes enclosed in the loop should be tested to avoid including unsupported nodes in the transformation.

  • verbose (bool) – whether to log the reason the validation failed, at the moment with a comment in the provided PSyIR node.

validate(node1, node2, options=None, **kwargs)[source]#

Checks if it is valid to apply the GOceanLoopFuseTrans transform. It ensures that the fused loops are over the same grid-point types, before calling the normal LoopFuseTrans validation function.

Parameters:
  • node1 (GOLoop) – the first Node representing a GOLoop.

  • node2 (GOLoop) – the second Node representing a GOLoop.

  • options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.

  • force (bool) – whether to force fusion of the target loop (i.e. ignore any dependence analysis). This only skips a limited number of the checks, and does not fully force merging.

  • node_type_check (bool) – If the type of nodes enclosed in the loop should be tested to avoid including unsupported nodes in the transformation.

  • verbose (bool) – whether to log the reason the validation failed, at the moment with a comment in the provided PSyIR node.

Raises: