Moisés Viñas Buceta


Hi, I am Moisés Viñas Buceta and I am a Phd student in the Computer Architecture Group (GAC) of University of A Coruña.

My reseaching is focused mainly in the GPGPU computation using CUDA and OpenCL. My thesis is based on the development of HPL, a library that helps to the programmer to parallelize its code easily on heterogeneus systems that uses OpenCL as backend.

Well, let's go with an example...

We are going to show you the differences between a program written in OpenCL and HPL. In our case, we have chosen a program that takes an image as input, applies a sepia filter to it and returns the same filtered image.

Imagen a filtrar Imagen filtrada
Figura 1. Input image Figura 2. Output image

The structure of an OpenCL program has basically the following 6 blocks of code:

  1. OpenCL setup: This block usually goes at the beginning of the program and probably, it is the more tedious and error prone task of the whole program. In this block, the user must communicate with the OpenCL devices in the system to allow the later execution of kernels in them. In this stage, we will also work with a huge amount of OpenCL terms.
  2. Buffers creation : When the OpenCL environment is ready, we need to tell it what data will use the device.
  3. Loading data in the device: Our data will be allocated in the memory space of the main thread of our program. In this block, we fill the buffers of the device with these data.
  4. Kernel creation: We implement the kernel that will be executed in the device previously selected.
  5. Kernel execution: With the buffers updated with the correct data, we can run the kernel that we have chosen.
  6. Unload the data of the device: When the excution has finished, we have to bring the data of the device to the main program to continue the execution in the host that surely will use these data.
Notice that these are the blocks of a typical program where a kernel is launched only once. This scheme would become more complex if we had conditional sentences. HPL removes these complexities such as we will see in the table. This table contains the lines of code of the 6 stages of the sepia filter program for the two implementations, OpenCL and HPL.


If you are still interested to know more about HPL, we invite you to try this test and other ones that you can found here .