psyclone.domain.gocean.transformations.gocean_opencl_trans#

This module contains the GOcean-specific OpenCL transformation.

Classes#

  • GOOpenCLTrans: Switches on/off the generation of an OpenCL PSy layer for a given

class psyclone.domain.gocean.transformations.gocean_opencl_trans.GOOpenCLTrans[source]#

Switches on/off the generation of an OpenCL PSy layer for a given InvokeSchedule. Additionally, it will generate OpenCL kernels for each of the kernels referenced by the Invoke. For example:

>>> from psyclone.tests.utilities import get_psylayer_schedule
>>> filename = "eg1/shallow_alg.f90"
>>> schedule = get_psylayer_schedule(filename, "gocean-examples")
>>>
>>> from psyclone.domain.gocean.transformations import (
...     GOMoveIterationBoundariesInsideKernelTrans,
...     GOOpenCLTrans)
>>> from psyclone.domain.common.transformations import (
...     KernelModuleInlineTrans)
>>> move_trans = GOMoveIterationBoundariesInsideKernelTrans()
>>> mod_inline_trans = KernelModuleInlineTrans()
>>> ocl_trans = GOOpenCLTrans()
>>> for kern in schedule.kernels():
...    # Put kernels in same container and iterate the whole space
...    mod_inline_trans.apply(kern)
...    move_trans.apply(kern)
>>> # Commented to prevent generating doctest output .cl files
>>> # ocl_trans.apply(schedule)

Inheritance

Inheritance diagram of GOOpenCLTrans
apply(node, options=None)[source]#

Apply the OpenCL transformation to the supplied GOInvokeSchedule. This causes PSyclone to generate an OpenCL version of the corresponding PSy-layer routine. The generated code makes use of the FortCL library (stfc/FortCL) in order to manage the OpenCL device directly from Fortran.

Parameters:
  • node (psyclone.psyGen.GOInvokeSchedule) – the InvokeSchedule to transform.

  • options (dict of str:value or None) – set of option to tune the OpenCL generation.

  • options["enable_profiling"] (bool) – whether or not to set up the OpenCL environment with the profiling option enabled.

  • options["out_of_order"] (bool) – whether or not to set up the OpenCL environment with the out_of_order option enabled.

  • options["end_barrier"] (bool) – whether or not to add an OpenCL barrier at the end of the transformed invoke.

property name#
Returns:

the name of this transformation.

Return type:

str

validate(node, options=None)[source]#

Checks that the supplied InvokeSchedule is valid and that an OpenCL version of it can be generated.

Parameters:
  • node (psyclone.psyGen.InvokeSchedule) – the Schedule to check.

  • options (dict of str:value or None) – a dictionary with options for transformations.

  • options["enable_profiling"] (bool) – whether or not to set up the OpenCL environment with the profiling option enabled.

  • options["out_of_order"] (bool) – whether or not to set up the OpenCL environment with the out_of_order option enabled.

  • options["end_barrier"] (bool) – whether or not to add an OpenCL barrier at the end of the transformed invoke.

Raises: