Hello everyone, I`m going to use my personal blog to register my steps in the wonderful world of my GSoC project. I`m going to implement OpenCL support in the Generic Graphics Library.
For those who doesn`t know, OpenCL is a language which allows parallel and high-performance code to run in different platforms, like GPUs and Multi-Core CPUs. By the end of the project, I want GEGL`s (and GIMP) plugins/operations to be able to use OpenCL.
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.
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.