Download the lab files from GPGPU_OpenCL_lab.tar.gz.
All files you'll need are bundled in one archive this time.
In the folder /tools you will find an image viewer which can be used to view the output images from task 2 and 3, as well as a small program which can convert any jpg images to the rbm format used as input / output in this lab, in case you want to use an own image for task 3. Note that you have to run make first if you want to use them.
In this lab you will work with the files task1.cpp and task1.cl. You need to hand-in only the answer to the questions.
1. Take a look at lab1-1.cpp, and how the open CL is initiated and how the kernel is called.
2. Make the lab with make task1, and run it. You will notice that it produces an error. Open the file task1.cl
andtask1.cpp, and fix the problem. You can use the image_viewer to look at the output files.
Note that you don't need to recompile everytime, saving the kernel will suffice (since it is compiled at runtime).
Unfortunately, the gpu is quite slow compared to the cpu. Can you make it faster?
In this lab you will work with the files task2.cpp and task2.cl. You need to hand in the kernels from task 1 and 2 and the answer to the questions.
You received an image of a contact person in an allied intelligence agency. Naturally, it is encrypted.
The decrypt function can be found in the file cpu_decrypt.It will be your mission to implement it as two different openCL kernels.
Like most crypto algorithms, this one works on a block (in this case 4*4 chars), and in several rounds (in this case 11). Each round consists of a one-way function (a modulo multiplication with the key), and a permutation (a bytewise shift by data_shift). In the end of each round, the permutation is alterad and the key is shuffled (via key_shift) for the next round. Note that athough typical operations of a block cipher are used the security of this algorithm is doubtful.
1. Implement the decrypt algorithm in a kernel. Each work item should take care of a block. You can use the image_viewer in tools/ to take a look at its output image, and compare it to the one produced by the decryption on the cpu.
2. Rewrite the same kernel, so that each work item is now working on a single input character. Note that you will need to hand in both kernels, so save your kernel from task 2.1. .
In this lab you will work with the files task3.cpp and task3.cl. You need to hand in these both files and the answer to the questions.
Now it's time to get creative. You have to implement an image filter of your own choice. You can for example implement a blur (e.g. gauss), edge detection (laplace) or denoising (median).
Also, this time you will have to do everything yourself, including the initialization and the kernel call.
You can either use the provided test_image.rbm or an image of your own.
1. Implement a cpu version of the filter in the function cpu_filter. This will give you something to compare with your kernel, and also help with the debugging which can be quite tedious if done in OpenCL.
2. Write the functions for initializing OpenCL and for calling your kernel. Implement a small kernel which just passes the input data to the output data to make sure everything is working correctly.
3. Finally write the filter as an OpenCL kernel.