OpenCL Error in examples
I build the library with OpenCL support using the stub library, and tested the example cl_convolution on a Samsung Galaxy S4.
At the line:
CLScheduler::get().default_init();
The app crashed with the following error:
terminate called after throwing an instance of 'cl::Error'
what(): empty
Further testing: If I comment out the CLScheduler, the program runs until
CLConvolution3x3 conv3x3;
I where it gives the error:
ERROR in const arm_compute::Program &arm_compute::CLKernelLibrary::load_program(const std::string &) const src/core/CL/CLKernelLibrary.cpp:553: Kernel file .convolution3x3.cl does not exist. No such file or directory
The path to libopencl.so is included in the phone&s LD_LIBRARY_PATH. Is there anything else that I have missed?
Samsung Galaxy S4 has a Qualcomm GPU so not sure what the OpenCL situation is for this platform.
default_init() just creates an OpenCL Context and Command Queue and the cl::Error get thrown by the OpenCL C++11 wrapper (cl2.hpp), which means it's an error returned by the OpenCL runtime at initialisation time. Not sure what it could be I'm afraid, we haven't seen it on any of the devices we've tested the library on
Thanks, I started testing on a HTC_M9pw and the first error went away. So I assume that was a device problem.
However, I still get an error at:
conv3x3.configure(&src, &tmp, gaussian3x3, 0, BorderMode::UNDEFINED);
The error message reads:
ERROR in const arm_compute::Program &arm_compute::CLKernelLibrary::load_program(const std::string &) const src/core/CL/CLKernelLibrary.cpp:553: Kernel file ./cl_kernels/convolution3x3.cl does not exist. No such file or directory
My build statement is:
CXX=clang++ CC=clang scons Werror=1 -j8 debug=1 neon=0 opencl=1 os=android arch=armv7a
You either need to upload the CL kernels from src/core/CL/cl_kernels to your platform or to recompile the library with embed_kernels=1 (then the OpenCL kernels will directly be embedded inside the library's binary)
Thanks, I added embed_kernels=1 and rebuilt the library, and the missing kernel file error disappeared. However, the same line
conv3x3.configure(&src, &tmp, gaussian3x3, 0, BorderMode::UNDEFINED);
gives me the error
error: unknown argument: '-cl-arm-non-uniform-work-group-size'
terminate called after throwing an instance of 'cl::Error'
what(): clCreateKernel
While searching for a way to fix this, I found the following statement in a Khronos web page.
Enabling non-uniform work-groups requires a kernel to be compiled with the -cl-std=CL2.0 flag and without the -cl-uniform-work-group-size flag.
Is this relevant to the error? I used the OpenCL 1.2 stub for building the library. Is it necessary to build the kernels for CL2.0?
That's because the OpenCL driver you are using doesn't support the -cl-arm-non-uniform-work-group-size flag (Which means your GPU is probably not an ARM GPU), if your GPU supports CL 2.0 you can try to replace -cl-arm-non-uniform-work-group-size by -cl-std=CL2.0 here
Many thanks, that fixed the problem. In my case, it was -cl-std=CL1.1.
@mo-morikawa , hi, when you face the problem "default_init()" and "conv3x3.configure(&src, &tmp, gaussian3x3, 0, BorderMode::UNDEFINED);" is the executable program or the apk in the Andriod ? When use the demo of "cl_convolution" executable program is successful on mate9. But when change the code to the Shared Library for apk ,I face the same problem to yours. thank you.
I got the error when it was running in the device as an executable. So far, I haven't tried making an apk. Will try that some time, since I am going to need it later.