loki.transformations.data_offload.field_offload

Functions

add_field_offload_calls(driver, region, ...)

declare_device_ptrs(driver, deviceptrs)

Add a set of data pointer declarations to a given Subroutine

find_offload_variables(driver, region, ...)

Finds the sets of array variable symbols for which we can generate Field API offload code.

replace_kernel_args(driver, offload_map, ...)

Classes

FieldOffloadTransformation([devptr_prefix, ...])

Transformation to offload arrays owned by Field API fields to the device.

class FieldOffloadTransformation(devptr_prefix=None, field_group_types=None, offload_index=None)

Bases: Transformation

Transformation to offload arrays owned by Field API fields to the device.

This transformation is IFS specific.

The transformation assumes that fields are wrapped in derived types specified in field_group_types and will only offload arrays that are members of such derived types. In the process this transformation removes calls to Field API update_view and adds declarations for the device pointers to the driver subroutine.

The transformation acts on !$loki data regions and offloads all Array symbols that satisfy the following conditions:

  1. The array is a member of an object that is of type specified in field_group_types.

  2. The array is passed as a parameter to at least one of the kernel targets passed to transform_subroutine.

Parameters:
  • devptr_prefix (str, optional) – The prefix of device pointers added by this transformation (defaults to 'loki_devptr_').

  • field_group_types (list or tuple of str, optional) – Names of the field group types with members that may be offloaded (defaults to ['']).

  • offload_index (str, optional) – Names of index variable to inject in the outmost dimension of offloaded arrays in the kernel calls (defaults to 'IBL').

transform_subroutine(routine, **kwargs)

Defines the transformation to apply to Subroutine items.

For transformations that modify Subroutine objects, this method should be implemented. It gets called via the dispatch method apply().

Parameters:
  • routine (Subroutine) – The subroutine to be transformed.

  • **kwargs (optional) – Keyword arguments for the transformation.

process_driver(driver)
find_offload_variables(driver, region, field_group_types)

Finds the sets of array variable symbols for which we can generate Field API offload code.

Note

This method requires Loki’s dataflow analysis to be run on the region via dataflow_analysis_attached().

Parameters:
  • region (PragmaRegion) – Code region object for which to determine offload variables

  • field_group_types (list or tuple of str, optional) – Names of the field group types with members that may be offloaded (defaults to ['']).

Returns:

(inargs, inoutargs, outargs) – The sets of array symbols split into three tuples according to access type.

Return type:

(tuple, tuple, tuple)

add_field_offload_calls(driver, region, offload_map)
replace_kernel_args(driver, offload_map, offload_index)