2-4 July 2020
University of Zurich
Europe/Zurich timezone

Interfacing with OpenCL from Modern Fortran for Highly Parallel Workloads

3 Jul 2020, 17:20
ZOOM (University of Zurich)


University of Zurich

Junior Presentations Session F


Laurence Kedward (University of Bristol, UK)


OpenCL is a well-established and widely-supported standard for executing parallel workloads
on accelerator devices such as conventional multicore CPUs as well as GPUs and FPGAs.

In this presentation, detail is given on a modern Fortran library which wraps calls to the OpenCL API with a higher abstraction level aimed at scientists and engineers looking to execute highly-parallel OpenCL kernels from Fortran. Modern Fortran features, including derived types, generics, operator-overloading and the iso c binding, are exploited to bring the Fortran style to OpenCL by: abstracting away pointers; providing a level of type-safety for device memory; detecting and handling program errors in a user-friendly manner; and providing a concise but feature-rich interface.

Device kernels are written in the OpenCL C dialect and the Fortran library provides routines to: initialize the accelerator, allocate device memory, enqueue kernels for execution, perform memory transfers and manage device synchronisation.

Code extracts and results are presented for two fluid dynamics codes implementing a lattice Boltzmann method and a multigrid finite volume Euler solver. Background is given on the challenges and design choices for programming GPU hardware from a Fortran perspective, followed by discussion on the future of accelerator offloading from the Fortran language.

Primary author

Laurence Kedward (University of Bristol, UK)

Presentation Materials