The basic usage of pocl should be as easy as any other OpenCL implementation.
While it is possible to link against pocl directly, the recommended way is to use the ICD interface.
Android applications can use pocl using jni. App has to dlopen “/data/data/org.pocl.libs/files/lib/libpocl.so” and dlsym OpenCL function symbols from it.
pocl is built with the ICD extensions of OpenCL by default. This allows you to have several OpenCL implementations concurrently on your computer, and select the one to use at runtime by selecting the corresponding cl_platform. ICD support can be disabled by adding the flag:
to the ./configure script.
In case you also give the –prefix=$INSTALL option to ./configure, you need to copy the icd file to where your ICD loader finds it, e.g.:
cp $INSTALL/etc/OpenCL/vendors/pocl.icd /etc/OpenCL/vendors/pocl.icd
The ocl-icd ICD loader allows to use the OCL_ICD_VENDORS environment variable to specify a (non-standard) replacement for the /etc/OpenCL/vendors directory.
An ICD loader is an OpenCL library acting as a “proxy” to one of the various OpenCL implementations installed in the system. pocl does not provide an ICD loader itself, but NVidia, AMD, Intel, Khronos, and the free ocl-icd project each provides one.
Since pocl is installed in a non-standard path, dynamic linking is not possible. App has to dlopen “/data/data/org.pocl.libs/files/lib/libpocl.so” and dlsym OpenCL function symbols from it.
Refer examples/pocl-android-sample/ for hello-world android app that uses pocl. This app uses a third-party stub OpenCL library that does dlopen/dlsym on its behalf
Vecmathlib (aka VML) https://bitbucket.org/eschnett/vecmathlib/wiki/Home provides optimized implementations for math builtins such as sqrt, sin, cos, etc. These are highly recommended as they can be inlined to the call site and lead to better optimized kernels. A copy of Vecmathlib is distributed with pocl for convenience in the directory lib/kernel/vecmathlib.
To use VML, you need to have a functional clang++ installed. Currently, VML is enabled only for x86_64.