OpenCL in GEGL

Victor Oliveira

Abstract

My proposal is about making possible to write GEGL operations in OpenCL. There are two tasks: - Automatic memory management and migration of tiles from GPU to the CPU and the other way around. - Make some GEGL operations in OpenCL.

Additional Information

OpenCL in GEGL 
 
"OpenCL (Open Computing Language) is a framework for writing programs that execute across heterogeneous platforms consisting of CPUs, GPUs, and other processors. OpenCL includes a language (based on C99) for writing kernels (functions that execute on OpenCL devices), plus APIs that are used to define and then control the platforms. OpenCL provides parallel computing using task-based and data-based parallelism." [wikipedia]

My proposal is about making possible to write GEGL plug-ins in OpenCL. Of course you can always write your plug-in using any technology inside it (nothing forbides you from using OpenMP to parallelize a composition operation, for example). But the main point of the work is extending GeglBuffer to automatically make the memory transferences between the CPU and GPU.


An example:
 
So let's suppose you have defined a graph in GEGL with a path of operations A, B and C. A and C can run at GPU, but we don't have a GPU version for B.

input -> A (GPU) -> B (CPU) -> C (GPU) -> output

So, before entering A, we have to copy the input data to the GPU and do the processing in the GPU plug-in. After that, we copy data back to the main memory in order to B have its data, then we copy B's output to the GPU again and run C, we need to have the output in the CPU of course, so we copy back C's output to the main memory and finish.

Our objective is doing these memory transfers in a transparent way to the end-user of GEGL and implementing some operations in OpenCL.

 

Code samples