OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1718 Discussions

How to debug segfault in an OpenCL kernel?

QFang1
Novice
1,015 Views

My kernel works on AMD and NVIDIA OpenCL, but for some specific test, it fails on Intel ocl with i7-7700k. it threw a segfault and crashed.

I want to find out where in my code had caused the issue. I wish there are some debugging tools, like valgrind, to print out the offending lines. 

I installed oclgrind on my Ubuntu 16.04 box, for a small workload, it worked without any issue, no error was captured. but for large enough workload, oclgrind crashed too without printing anything useful related to my kernel! 

simulation run# 1 ...  /usr/bin/oclgrind: line 145:  7204 Killed                  LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH LD_PRELOAD=$LIBDIR/liboclgrind-rt.so "$@"

does Intel OCL sdk have any tool for this purpose? I don't have a windows machine installed with intel ocl, so a command line tool is preferred.

thanks

PS: if you are interested in testing, here is my code

git clone https://github.com/fangq/mcxcl.git
cd mcxcl/src
make
cd ../example/benchmark
../../bin/mcxcl -L
./run_benchmark2.sh -G ???

where ??? is an 01 string to select the CPU. for example, if the mcxcl -L command above lists 3 devices, the CPU is the 1st, you should use -G 1; if it is the 2nd, you should give -G 01, if it is the 3rd, use -G 001 and so on. You should see a segfault when running the last command.

0 Kudos
1 Reply
QFang1
Novice
1,015 Views

I added the "-g -s /path/to/kernel.cl" in the clbuildprogram options, and tried to run this in gdb, but every time gdb gives me a crash before the kernel is compiled

Program received signal SIGSEGV, Segmentation fault.
0x00007fffdf681148 in ?? ()

is this method obsolete? I tried both Ubuntu's default gdb and the gdb inside the sdk .../gt_debugger_2016.0/bin/gdb, same error.

please let me know how to debug cl code these days? thanks

 

0 Kudos
Reply