loki.transformations.transform_region

Collection of utility routines that provide transformations for code regions.

Functions

region_hoist(routine)

Hoist one or multiple code regions annotated by pragma ranges and insert them at a specified target location.

region_to_call(routine)

Convert regions annotated with !$loki region-to-call pragmas to subroutine calls.

region_hoist(routine)

Hoist one or multiple code regions annotated by pragma ranges and insert them at a specified target location.

The pragma syntax for annotating the regions to hoist is !$loki region-hoist [group(group-name)] [collapse(n) [promote(var-name, var-name, ...)]] and !$loki end region-hoist. The optional group(group-name) can be provided when multiple regions are to be hoisted and inserted at different positions. Multiple pragma ranges can be specified for the same group, all of which are then moved to the target location in the same order as the pragma ranges appear. The optional collapse(n) parameter specifies that n enclosing scopes (such as loops, conditionals, etc.) should be re-created at the target location. Optionally, this can be combined with variable promotion using promote(...).

region_to_call(routine)

Convert regions annotated with !$loki region-to-call pragmas to subroutine calls.

The pragma syntax for regions to convert to subroutines is !$loki region-to-call [name(...)] [in(...)] [out(...)] [inout(...)] and !$loki end region-to-call.

A new subroutine is created with the provided name (or an auto-generated default name derived from the current subroutine name) and the content of the pragma region as body.

Variables provided with the in, out and inout options are used as arguments in the routine with the corresponding intent, all other variables used in this region are assumed to be local variables.

The pragma region in the original routine is replaced by a call to the new subroutine.

:param :class:Subroutine routine:

the routine to modify.

Returns:

the list of newly created subroutines.