loki.transformations.data_offload.field_offload
Functions
|
Add the variables required for asynchronous blocked offloading over multiple queues to the routine. |
|
Add async pragma content to Loki data and driver-loop pragmas in the section. |
|
Add blocked Field API data transfer calls to a region inside a block loop. |
|
Add Field API device data allocation calls for variables in offload_map. |
|
|
|
Add wait calls to synchronize all queues after a block loop. |
|
Block a driver loop inside a code region. |
|
Add a set of data pointer declarations to a given |
|
Find the sets of array variable symbols for which we can generate Field API offload code. |
|
Replace instances of offload variables with their device pointers inside the region. |
Classes
|
Transformation to perform blocked offload of arrays owned by Field API fields to the device. |
|
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 APIupdate_view
and adds declarations for the device pointers to the driver subroutine.The transformation acts on
!$loki data
regions and offloads allArray
symbols that satisfy the following conditions:The array is a member of an object that is of type specified in
field_group_types
.The array is passed as a parameter to at least one of the kernel targets passed to
transform_subroutine
.
- Parameters:
deviceptr_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 methodapply()
.- Parameters:
routine (
Subroutine
) – The subroutine to be transformed.**kwargs (optional) – Keyword arguments for the transformation.
- process_driver(driver)
- class FieldOffloadBlockedTransformation(block_size, devptr_prefix=None, field_group_types=None, offload_index=None, asynchronous=False, num_queues=1)
Bases:
Transformation
Transformation to perform blocked offload of 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 APIupdate_view
and adds declarations for the device pointers to the driver subroutine.The transformation acts on
!$loki data
regions and offloads allArray
symbols that satisfy the following conditions:The array is a member of an object that is of type specified in
field_group_types
.The array is passed as a parameter to at least one of the kernel targets passed to
transform_subroutine
.
- Parameters:
block_size (int) – Number of blocks per chunk (specified in the final dimension of the field).
deviceptr_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'
).asynchronous (bool, optional) – Perform asynchronous blocked offload (defaults to
False
)num_queues (int, optional) – Number of queues for asynchronous offload should be set to 2 or higher for asynchronous offload (defaults to 1).
- 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 methodapply()
.- 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)
Find 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
viadataflow_analysis_attached()
.- Parameters:
region (
PragmaRegion
) – Code region object for which to determine offload variablesfield_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:
- add_field_offload_calls(driver, region, offload_map)
- replace_offload_args(driver, region, offload_map, offload_index)
Replace instances of offload variables with their device pointers inside the region.
- Parameters:
driver (
Subroutine
) – Subroutine containing the data region.region (
PragmaRegion
) – Data region in which offload variables in the offload map will be replaced.offload_map (
FieldPointerMap
) – FieldPointerMap with variables to be offloaded.offload_index (str) – Name of index variable to inject in the outmost dimension of offloaded pointers.