When I implemented the function based on OpenCL, the segmentation fault occurred within the kernel function.
The background is that I just made the static lib (.a file) including the OpenCL code, and integrate such lib in my project and call the public interface from the lib.
When I gdb the program, the callstack is as follows:
#0 0x000ce780 in ?? ()
#1 0xb6d1d3ec in Coal::BufferEvent::isSubBufferAligned(Coal::MemObject const*, Coal::DeviceInterface const*) () from /usr/lib/libOpenCL.so.1
#2 0xb6d1f768 in Coal::KernelEvent::KernelEvent(Coal::CommandQueue*, Coal::Kernel*, unsigned int, unsigned int const*, unsigned int const*, unsigned int const*, unsigned int, _cl_event* const*, int*) () from /usr/lib/libOpenCL.so.1
#3 0xb6d17664 in clEnqueueNDRangeKernel () from /usr/lib/libOpenCL.so.1
#4 0x0008efee in cl::CommandQueue::enqueueNDRangeKernel (this=0xc7dcc <kernelFunc+4>, kernel=..., offset=..., global=..., local=..., events=0x0,
event=0xbeffed94)
at /opt/ti-processor-sdk-linux-k2hk-evm-03.00.00.04/linux-devkit/sysroots/cortexa15hf-neon-linux-gnueabi/usr/include/CL/cl.hpp:2955
#5 0x0008fc70 in cl::KernelFunctor::operator()<int, int, int, float, cl::Buffer*, int, cl::Buffer*, int, float, cl::Buffer*, int, int, int, cl::LocalSpaceArg, cl::Buffer> (this=0xc7dc8 <kernelFunc>, a1=@0xbeffed14: 16, a2=@0xbeffed10: 200704, a3=@0xbeffedb8: 27, a4=@0xbeffed0c: 1,
a5=@0xbeffed34: 0x122ea0, a6=@0xbeffed14: 16, a7=@0xbeffed30: 0x117ba8, a8=@0xbeffedb8: 27, a9=@0xbeffed08: 1, a10=@0xbeffed2c: 0x10a4b8,
a11=@0xbeffed14: 16, a12=@0xc7da0: 32, a13=@0xc7da4: 8, a14=..., a15=..., events=0x0)
at /opt/ti-processor-sdk-linux-k2hk-evm-03.00.00.04/linux-devkit/sysroots/cortexa15hf-neon-linux-gnueabi/usr/include/CL/cl.hpp:3936
...
(PS: a13 means constant value 8, not the memory address)
And the error information is:
Cannot access memory at address 0x8
Program received signal SIGSEGV, Segmentation fault.
Cannot access memory at address 0x8
I see that the program visited the illegal address 0x8 in the "KernelEvent". But I've checked all the parameters of kernel function, they are either allocated at the normal address or the fixed values. Since the last function is "isSubBufferAligned" that exists in OpenCL lib. I didn't know how to go further on this issue.
Could anyone give some idea on how to debug such OpenCL run-time error?
Thanks so much!!