Basic Concepts: online kernel compiling

Typos are a programmers worst nightmare, as they are bad for concentration. The code in your head is not the same as the code on the screen and therefore doesn’t have much to do with the actual problem solving. Code highlighting in the IDE helps, but better is to use the actual OpenCL compiler without running your whole software: an Online OpenCL Compiler. In short is just an OpenCL-program with a variable kernel as input, and thus uses the compilers of Intel, AMD, NVidia or whatever you have installed to try to compile the source. I have found two solutions, which both have to be built from source – so a C-compiler is needed.

  • CLCC. It needs the boost-libraries, cmake and make to build. Works on Windows, OSX and Linux (needs possibly some fixes, see below).
  • OnlineCLC. Needs waf to build. Seems to be Linux-only.

For both you can just give the source-file of the kernel, optionally which driver/device to use. With OnlineCLC it is not very clear what is meant with the “device” option and I am trying to find that out and hope to update this article soon. CLCC has an extra option to specify the device-type (GPU, CPU, etc) to use. It is for instance possible to have these commands as an external command in your IDE, so you can check your kernel when needed. And don’t forget to write your test-cases with this – assuming the test-machine has all the devices.

Watch out! It is using the hardware for compiling too, so it can crash your machine as hard as you can do with your own GPGPU-software.

Getting CLCC working on Linux

The downloaded version 0.1 of CLCC does not work out-of-the-box on a recent Linux-distribution with the latest boost-libraries. You can check out of SVN, wait for the upcoming version 0.2 or enter the below fixes.

The file src/CMakeLists.txt needs “cmake_minimum_required(VERSION 2.8)” at the top and

if (UNIX)
target_link_libraries(clcc ${CMAKE_DL_LIBS})
endif()

to make the linking working. In options.cpp replace “ifdef __LINUX__” with “ifdef __linux__“. In main.cpp en clpp.cpp replace “#include <boost/exception.hpp>” with “#include <boost/exception/all.hpp>“. That’s all.

Now run

cmake -G "Unix Makefiles" .
make

in the root of the project. Now you are ready to run CLCC. Any feedback can go to george at organicvectory dot com.

Related Posts

One thought on “Basic Concepts: online kernel compiling

Comments are closed.