OpenCL
From NaplesPU Documentation
The OpenCL support for the nu+ architecture is made through pocl.
How to install vanilla pocl
- Download following the link.
- In order to build pocl, you need the following support libraries and tools:
- Latest released version of LLVM & Clang
- GNU make
- libtool dlopen wrapper files (e.g. libltdl3-dev in Debian)
- pthread (should be installed by default)
- hwloc v1.0 or newer (e.g. libhwloc-dev)
- pkg-config
- cmake
- libclang-3.8-dev if you are using Ubuntu 16.04 LTS
- On Ubuntu 16.04 LTS you can run the following code on a terminal
-
sudo apt-get install llvm & clang & libltdl3-dev & libhwloc-dev & libhwloc-dev & libclang-3.8-dev & make & cmake
- Build and install
-
cd <directory-with-pocl-sources> mkdir build cd build cmake [-D<option>=<value> ...] .. make && make install
-
Using pocl
To compile with pocl you have to execute:
gcc example1.c -o example `pkg-config --libs --cflags pocl`
See [1] and [2] for further informations.
Adding a new device class in pocl
- Create a directory for the new device class in "lib/CL/devices". In this case the "nuplus" folder is created.
- Create at least the files newdevice.c and newdevice.h. In this case "nuplus.c" and "nuplus.h"
- Create the CMakeList.txt file in the device folder, specifying the files created before and the device name.
if(MSVC)
set_source_files_properties( nuplus.h nuplus.c PROPERTIES LANGUAGE CXX )
endif(MSVC)
add_library("pocl-devices-nuplus" OBJECT nuplus.h nuplus.c)
- Modify the "lib/CL/devices.c" file including the new header file for the device and adding the init fucntion in the vector pocl_devices_init_ops
#include "nuplus/nuplus.h"
...
static init_device_ops pocl_devices_init_ops[] = {
pocl_pthread_init_device_ops,
pocl_basic_init_device_ops,
pocl_nuplus_init_device_ops,
#if defined(TCE_AVAILABLE)
pocl_ttasim_init_device_ops,
#endif
#if defined(BUILD_HSA)
pocl_hsa_init_device_ops,
#endif
};
...
- Modify the "lib/CL/devices/CMakeLists.txt" adding the new device subdirectory name.
...
add_subdirectory("nuplus")
...
- Modify the "CMakeLists.txt" in the pocl root directory adding the new device name to the "OCL_DRIVERS".
...
set(OCL_DRIVERS "basic pthreads nuplus")
...