Chapter 1: An Introduction to OpenCL
Although this chapter at times seems like an extended sales pitch for parallel computation and OpenCL more specifically, it does a good job of mixing high-level concepts with low-level specifics. The highlight in this chapter is the introduction to the parallel programming paradigm, i.e. context-host-kernel as well as work-items/work-groups. As my prior experience has been in sequential (non-parallel) application and database development, these concepts (together) are somewhat unfamiliar and require attention. Initially they can be counter-intuitive, but once the main concepts of context and kernel are grasped, the model begins to take shape and is very straight-forward. I could publish my own primer but that would seem fruitless when there are plenty out there right now.
Chapter 1 is a primer but requires somewhat of a computer engineering background to follow. A less intensive primer is available here or here or here and a basic tutorial is here.
Despite using the “-lOpenCL” flag in the linker options under the “Linker Settings” tab for the OpenCL compiler settings in Code::Blocks, I still receive the following build errors:
obj\Debug\main.o||In function `main’:|
C:\Users\txt103120\Desktop\CodeBlocks\device_check\main.cpp|27|undefined reference to `clGetPlatformIDs@12’|
C:\Users\txt103120\Desktop\CodeBlocks\device_check\main.cpp|29|undefined reference to `clGetDeviceIDs@24’|
C:\Users\txt103120\Desktop\CodeBlocks\device_check\main.cpp|44|undefined reference to `clGetDeviceInfo@20’|
C:\Users\txt103120\Desktop\CodeBlocks\device_check\main.cpp|71|undefined reference to `clGetDeviceInfo@20’|
||=== Build finished: 4 errors, 0 warnings ===|
I found this post on StackOverflow that seems relevant:
Now, I need to determine the course of action to resolve this.
So, I am following this setup process…
So far, it is a useful tutorial but there are a few caveats for someone not yet familiar with C++ and C::B that I thought are worth mentioning.
First: if you are using an NVIDIA GPU you need to DL/install the CUDA toolkit.
Then, when setting the compiler string (under Search Directories in C::B) for Windows it should look something like “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include”. This relates directly to the include statement at the beginning of your code, “#include <CL/cl.h>”. Similarly, your linker string should be something like “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\lib\x64”.
Finally, I still received 4 errors after compiling the tutorial’s example code. I will post a resolution to those errors soon.