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

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.parse.algorithm import parse
>>> from psyclone.psyGen import PSyFactory
>>> API = "gocean1.0"
>>> FILENAME = "shallow_alg.f90" # examples/gocean/eg1
>>> ast, invoke_info = parse(FILENAME, api=API)
>>> psy = PSyFactory(API, distributed_memory=False).create(invoke_info)
>>> schedule = psy.invokes.get('invoke_0').schedule
>>> ocl_trans = GOOpenCLTrans()
>>> ocl_trans.apply(schedule)
>>> print(schedule.view())

Inheritance

Inheritance diagram of GOOpenCLTrans
apply(node, options=None)

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 (https://github.com/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)

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: