<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to debug segfault in an OpenCL kernel? in OpenCL* for CPU</title>
    <link>https://community.intel.com/t5/OpenCL-for-CPU/How-to-debug-segfault-in-an-OpenCL-kernel/m-p/1139713#M5843</link>
    <description>&lt;P&gt;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.&lt;/P&gt;

&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;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!&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:;"&gt;simulation run# 1 ...  /usr/bin/oclgrind: line 145:  7204 Killed                  LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH LD_PRELOAD=$LIBDIR/liboclgrind-rt.so "$@"

&lt;/PRE&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;thanks&lt;/P&gt;

&lt;P&gt;PS: if you are interested in testing, here is my code&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;git clone &lt;A href="https://github.com/fangq/mcxcl.git" target="_blank"&gt;https://github.com/fangq/mcxcl.git&lt;/A&gt;
cd mcxcl/src
make
cd ../example/benchmark
../../bin/mcxcl -L
./run_benchmark2.sh -G ???&lt;/PRE&gt;

&lt;P&gt;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.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Oct 2017 18:49:13 GMT</pubDate>
    <dc:creator>QFang1</dc:creator>
    <dc:date>2017-10-11T18:49:13Z</dc:date>
    <item>
      <title>How to debug segfault in an OpenCL kernel?</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/How-to-debug-segfault-in-an-OpenCL-kernel/m-p/1139713#M5843</link>
      <description>&lt;P&gt;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.&lt;/P&gt;

&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;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!&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:;"&gt;simulation run# 1 ...  /usr/bin/oclgrind: line 145:  7204 Killed                  LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH LD_PRELOAD=$LIBDIR/liboclgrind-rt.so "$@"

&lt;/PRE&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;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.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;thanks&lt;/P&gt;

&lt;P&gt;PS: if you are interested in testing, here is my code&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;git clone &lt;A href="https://github.com/fangq/mcxcl.git" target="_blank"&gt;https://github.com/fangq/mcxcl.git&lt;/A&gt;
cd mcxcl/src
make
cd ../example/benchmark
../../bin/mcxcl -L
./run_benchmark2.sh -G ???&lt;/PRE&gt;

&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 18:49:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/How-to-debug-segfault-in-an-OpenCL-kernel/m-p/1139713#M5843</guid>
      <dc:creator>QFang1</dc:creator>
      <dc:date>2017-10-11T18:49:13Z</dc:date>
    </item>
    <item>
      <title>I added the "-g -s /path/to</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/How-to-debug-segfault-in-an-OpenCL-kernel/m-p/1139714#M5844</link>
      <description>&lt;P&gt;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&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;Program received signal SIGSEGV, Segmentation fault.&lt;/SPAN&gt;&lt;BR /&gt;
	&lt;SPAN style="font-size: 1em;"&gt;0x00007fffdf681148 in ?? ()&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;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.&lt;/P&gt;

&lt;P&gt;please let me know how to debug cl code these days? thanks&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 22:19:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/How-to-debug-segfault-in-an-OpenCL-kernel/m-p/1139714#M5844</guid>
      <dc:creator>QFang1</dc:creator>
      <dc:date>2017-10-11T22:19:52Z</dc:date>
    </item>
  </channel>
</rss>

