ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

cl_convolution example 'cl::Error'

Open ghost opened this issue 9 years ago • 13 comments

Dears,

I got compiled ARM Compute Library

scons Werror=1 -j8 debug=1 neon=0 opencl=1 os=linux arch=arm64-v8a build=native embed_kernels=1

then build a stub OpenCL library which then can be used to link your application

gcc -o libOpenCL.so -Iinclude -shared opencl-1.2-stubs/opencl_stubs.c -fPIC

and now trying to compile cl_convolution example

root@imx:~/ComputeLibrary# g++ examples/cl_convolution.cpp utils/Utils.cpp -Lbuild -L/home/root/ComputeLibrary -I. -Iinclude -std=c++11 -larm_compute -lOpenCL -o cl_convolution
In file included from ./arm_compute/core/CL/kernels/CLFastCornersKernel.h:27:0,
                 from ./arm_compute/runtime/CL/functions/CLFastCorners.h:28,
                 from ./arm_compute/runtime/CL/CLFunctions.h:51,
                 from examples/cl_convolution.cpp:26:
./arm_compute/core/CL/ICLArray.h:112:51: warning: ignoring attributes on template argument 'cl_ushort {aka short unsigned int}' [-Wignored-attributes]
 using ICLUInt16Array          = ICLArray<cl_ushort>;
                                                   ^
./arm_compute/core/CL/ICLArray.h:113:49: warning: ignoring attributes on template argument 'cl_uint {aka unsigned int}' [-Wignored-attributes]
 using ICLUInt32Array          = ICLArray<cl_uint>;
                                                 ^
./arm_compute/core/CL/ICLArray.h:114:50: warning: ignoring attributes on template argument 'cl_short {aka short int}' [-Wignored-attributes]
 using ICLInt16Array           = ICLArray<cl_short>;
                                                  ^
./arm_compute/core/CL/ICLArray.h:115:48: warning: ignoring attributes on template argument 'cl_int {aka int}' [-Wignored-attributes]
 using ICLInt32Array           = ICLArray<cl_int>;
                                                ^
./arm_compute/core/CL/ICLArray.h:116:50: warning: ignoring attributes on template argument 'cl_float {aka float}' [-Wignored-attributes]
 using ICLFloatArray           = ICLArray<cl_float>;
                                                  ^
In file included from ./arm_compute/runtime/CL/functions/CLFastCorners.h:31:0,
                 from ./arm_compute/runtime/CL/CLFunctions.h:51,
                 from examples/cl_convolution.cpp:26:
./arm_compute/runtime/CL/CLArray.h:102:49: warning: ignoring attributes on template argument 'cl_ushort {aka short unsigned int}' [-Wignored-attributes]
 using CLUInt16Array          = CLArray<cl_ushort>;
                                                 ^
./arm_compute/runtime/CL/CLArray.h:103:47: warning: ignoring attributes on template argument 'cl_uint {aka unsigned int}' [-Wignored-attributes]
 using CLUInt32Array          = CLArray<cl_uint>;
                                               ^
./arm_compute/runtime/CL/CLArray.h:104:48: warning: ignoring attributes on template argument 'cl_short {aka short int}' [-Wignored-attributes]
 using CLInt16Array           = CLArray<cl_short>;
                                                ^
./arm_compute/runtime/CL/CLArray.h:105:46: warning: ignoring attributes on template argument 'cl_int {aka int}' [-Wignored-attributes]
 using CLInt32Array           = CLArray<cl_int>;
                                              ^
./arm_compute/runtime/CL/CLArray.h:106:48: warning: ignoring attributes on template argument 'cl_float {aka float}' [-Wignored-attributes]
 using CLFloatArray           = CLArray<cl_float>;
                                                ^

example is built and try to run

root@imx:~/ComputeLibrary# LD_LIBRARY_PATH=build ./cl_convolution
./cl_convolution
terminate called after throwing an instance of 'cl::Error'
  what():  empty
Aborted (core dumped)

I've read this thread https://github.com/ARM-software/ComputeLibrary/issues/104#issuecomment-301652310 and even though it can't be compiled. On my ARM device there si non ARM GPU but it supports OpenCL1.2, When should I look at to fix this problem?

ghost avatar Sep 13 '17 12:09 ghost

I'd recommend rebuilding the example in debug mode (-g -O0) and catching the exception in GDB in order to see where the problem comes from.

AnthonyBarbier avatar Sep 13 '17 13:09 AnthonyBarbier

I'm running it as

root@imx:~/ComputeLibrary# LD_LIBRARY_PATH=build ./cl_convolution with gdb can I set 'LD_LIBRARY_PATH' somehow afterwards for cl_convolution?

root@imx:~/ComputeLibrary# gdb LD_LIBRARY_PATH=build ./cl_convolution
LD_LIBRARY_PATH=build: No such file or directory.
"/home/root/ComputeLibrary/./cl_convolution" is not a core dump: File format not recognized
(gdb) run
Starting program:
No executable file specified.
Use the "file" or "exec-file" command.
(gdb) quit

or

root@imx:~/ComputeLibrary# gdb ./cl_convolution
Reading symbols from ./cl_convolution...done.
(gdb) run
Starting program: /home/root/ComputeLibrary/cl_convolution
/home/root/ComputeLibrary/cl_convolution: error while loading shared libraries: libarm_compute.so: cannot open shared object file: No such file or directory
[Inferior 1 (process 8965) exited with code 0177]
(gdb)

ghost avatar Sep 13 '17 13:09 ghost

You can do an "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:build" before running in gdb. If this doesn't work try with gdb --args LD_LIBRARY_PATH=build ./cl_convolution.

mpekatsoula avatar Sep 13 '17 14:09 mpekatsoula

(gdb) run
Starting program: /home/root/ComputeLibrary/cl_convolution
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

/home/root/ComputeLibrary/cl_convolution


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: clGetPlatformIDs from stub libOpenCL.so library called! This library can be used to resolve OpenCL symbols at compile time but must *not* be in your runtime path (You need to use a real OpenCL implementation, this one is empty)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
terminate called after throwing an instance of 'cl::Error'
  what():  empty

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at /usr/src/debug/glibc/2.24-r0/git/sysdeps/unix/sysv/linux/raise.c:58
58      }
(gdb)

ghost avatar Sep 13 '17 14:09 ghost

Can you please follow the suggestions from here? It looks like you are trying to run the example using the stub library.

mpekatsoula avatar Sep 13 '17 14:09 mpekatsoula

when build against system OpenCL

(gdb) run
Starting program: /home/root/ComputeLibrary/cl_convolution
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

/home/root/ComputeLibrary/cl_convolution

warning: the debug information found in "/usr/lib/libxshmfence.so.1.0.0" does not match "/usr/lib/libxshmfence.so.1" (CRC mismatch).

terminate called after throwing an instance of 'cl::Error'
  what():  empty

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at /usr/src/debug/glibc/2.24-r0/git/sysdeps/unix/sysv/linux/raise.c:58
58      }
(gdb)

ghost avatar Sep 13 '17 14:09 ghost

before you do run please do catch throw Then when the execution stops backtrace to see where it comes from in the code

AnthonyBarbier avatar Sep 13 '17 19:09 AnthonyBarbier

(gdb) catch throw
Catchpoint 1 (throw)
(gdb) run
Starting program: /home/root/ComputeLibrary/cl_convolution
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

/home/root/ComputeLibrary/cl_convolution

warning: the debug information found in "/usr/lib/libxshmfence.so.1.0.0" does not match "/usr/lib/libxshmfence.so.1" (CRC mismatch).


Catchpoint 1 (exception thrown), 0x0000007fb7a38f68 in __cxa_throw () from /usr/lib/libstdc++.so.6
(gdb) backtrace
#0  0x0000007fb7a38f68 in __cxa_throw () from /usr/lib/libstdc++.so.6
#1  0x000000000040abec in cl::detail::errHandler(int, char const*) ()
#2  0x000000000040c654 in cl::Context::Context(unsigned long, long*, void (*)(char const*, void const*, unsigned long, void*), void*, int*) ()
#3  0x000000000040c354 in cl::Context::makeDefault() ()
#4  0x0000000000411348 in void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) ()
#5  0x000000000041070c in std::_Bind_simple<void (*())()>::operator()() ()
#6  0x000000000040f620 in void std::__once_call_impl<std::_Bind_simple<void (*())()> >() ()
#7  0x0000007fb7774a54 in __pthread_once_slow (once_control=0x42bbf8 <cl::Context::default_initialized_>, init_routine=0x40a890 <__once_proxy@plt>) at /usr/src/debug/glibc/2.24-r0/git/nptl/pthread_once.c:116
#8  0x000000000040ab78 in __gthread_once(int*, void (*)()) ()
#9  0x000000000040dda4 in void std::call_once<void (&)()>(std::once_flag&, void (&)()) ()
#10 0x000000000040c798 in cl::Context::getDefault(int*) ()
#11 0x000000000040d4f0 in arm_compute::CLScheduler::default_init() ()
#12 0x000000000040ad88 in main_cl_convolution(int, char const**) ()
#13 0x00000000004139a0 in arm_compute::utils::run_example(int, char const**, void (&)(int, char const**)) ()
#14 0x000000000040b124 in main ()
(gdb)

ghost avatar Sep 14 '17 09:09 ghost

Looks like your OpenCL driver doesn't work: seems to fail in the OpenCL Context Creation, not in the library.

AnthonyBarbier avatar Sep 14 '17 09:09 AnthonyBarbier

I have OpenCL 1.2 per cl_info

  *** Platform #0 ***
  CL_PLATFORM_PROFILE: FULL_PROFILE
  CL_PLATFORM_VERSION: OpenCL 1.2 V6.2.3.129602

Does the example need to be instructed to use OpenCL 1.2 explicitly or you assume already there is OpenCL library problem of context creation?

ghost avatar Sep 14 '17 11:09 ghost

There seems to be a library problem at context creation. Have you tried to run some stock OpenCL code before ? In GDB you could try to move to frame 1 and print what the error number is and check with the errors listed in the Khronos documentation

AnthonyBarbier avatar Sep 14 '17 12:09 AnthonyBarbier

BTW how to get the error number out of clCreateContext? is it err variable?

(gdb) backtrace
#0  0x0000007fb7a38f68 in __cxa_throw () from /usr/lib/libstdc++.so.6
#1  0x000000000040abec in cl::detail::errHandler(int, char const*) ()
#2  0x000000000040c654 in cl::Context::Context(unsigned long, long*, void (*)(char const*, void const*, unsigned long, void*), void*, int*) ()
#3  0x000000000040c354 in cl::Context::makeDefault() ()
#4  0x0000000000411348 in void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) ()
#5  0x000000000041070c in std::_Bind_simple<void (*())()>::operator()() ()
#6  0x000000000040f620 in void std::__once_call_impl<std::_Bind_simple<void (*())()> >() ()
#7  0x0000007fb7774a54 in __pthread_once_slow (once_control=0x42bbf8 <cl::Context::default_initialized_>, init_routine=0x40a890 <__once_proxy@plt>)
    at /usr/src/debug/glibc/2.24-r0/git/nptl/pthread_once.c:116
#8  0x000000000040ab78 in __gthread_once(int*, void (*)()) ()
#9  0x000000000040dda4 in void std::call_once<void (&)()>(std::once_flag&, void (&)()) ()
#10 0x000000000040c798 in cl::Context::getDefault(int*) ()
#11 0x000000000040d4f0 in arm_compute::CLScheduler::default_init() ()
#12 0x000000000040ad88 in main_cl_convolution(int, char const**) ()
#13 0x00000000004139a0 in arm_compute::utils::run_example(int, char const**, void (&)(int, char const**)) ()
#14 0x000000000040b124 in main ()
(gdb) frame 1
#1  0x000000000040abec in cl::detail::errHandler(int, char const*) ()
(gdb) info frame
Stack level 1, frame at 0x7fffffebb0:
 pc = 0x40abec in cl::detail::errHandler(int, char const*); saved pc = 0x40c654
 called by frame at 0x7fffffec80, caller of frame at 0x7fffffeb80
 Arglist at 0x7fffffeb80, args:
 Locals at 0x7fffffeb80, Previous frame's sp is 0x7fffffebb0
 Saved registers:
  x19 at 0x7fffffeb90, x29 at 0x7fffffeb80, x30 at 0x7fffffeb88
(gdb) print err
$2 = {void (int, const char *, ...)} 0x7fb78587a0 <err>

ghost avatar Sep 22 '17 20:09 ghost

Closing as duplicate of #228

GeorgeARM avatar Sep 29 '17 10:09 GeorgeARM