psyclone.domain.lfric.transformations.lfric_loop_fuse_trans

This module provides the LFRic-specific loop fusion transformation.

Classes

class psyclone.domain.lfric.transformations.lfric_loop_fuse_trans.LFRicLoopFuseTrans

Dynamo0.3 API specialisation of the base class in order to fuse two Dynamo loops after performing validity checks. For example:

>>> from psyclone.parse.algorithm import parse
>>> from psyclone.psyGen import PSyFactory
>>>
>>> API = "dynamo0.3"
>>> FILENAME = "alg.x90"
>>> ast, invokeInfo = parse(FILENAME, api=API)
>>> psy = PSyFactory(API, distributed_memory=False).create(invoke_info)
>>> schedule = psy.invokes.get('invoke_0').schedule
>>>
>>> from psyclone.domain.lfric.transformations import LFRicLoopFuseTrans
>>> ftrans =  LFRicLoopFuseTrans()
>>>
>>> ftrans.apply(schedule[0], schedule[1])
>>> print(schedule.view())

The optional argument same_space can be set as

>>> ftrans.apply(schedule[0], schedule[1], {"same_space": True})

when applying the transformation.

Inheritance

Inheritance diagram of LFRicLoopFuseTrans
validate(node1, node2, options=None)

Performs various checks to ensure that it is valid to apply the LFRicLoopFuseTrans transformation to the supplied loops.

Parameters:
  • node1 (psyclone.domain.lfric.LFRicLoop) – the first Loop to fuse.

  • node2 (psyclone.domain.lfric.LFRicLoop) – the second Loop to fuse.

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

  • options["same_space"] (bool) – this optional flag, set to True, asserts that an unknown iteration space (i.e. ANY_SPACE) matches the other iteration space. This is set at the user’s own risk. If both iteration spaces are discontinuous the loops can be fused without having to use the same_space flag.

Raises:
  • TransformationError – if either of the supplied loops contains an inter-grid kernel.

  • TransformationError – if one or both function spaces have invalid names.

  • TransformationError – if the same_space flag was set, but does not apply because neither field is on ANY_SPACE or the spaces are not the same.

  • TransformationError – if one or more of the iteration spaces is unknown (ANY_SPACE) and the same_space flag is not set to True.

  • TransformationError – if the loops are over different spaces that are not both discontinuous and the loops both iterate over cells.

  • TransformationError – if the loops’ upper bound names are not the same.

  • TransformationError – if the halo-depth indices of two loops are not the same.

  • TransformationError – if each loop already contains a reduction.

  • TransformationError – if the first loop has a reduction and the second loop reads the result of the reduction.