<?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 SPIR-V from clang/llvm-spirv fails or crashes with OpenCL runtime on Windows in GPU Compute Software</title>
    <link>https://community.intel.com/t5/GPU-Compute-Software/SPIR-V-from-clang-llvm-spirv-fails-or-crashes-with-OpenCL/m-p/1508820#M969</link>
    <description>&lt;H5&gt;&lt;STRONG&gt;Overview&lt;/STRONG&gt;&lt;/H5&gt;&lt;P&gt;I'm seeing a range of failures when attempting to execute SPIR-V from clang/llvm-spirv with the Intel OpenCL runtime on Windows. Depending on the driver version and kernel source, the failures include CL_INVALID_KERNEL_NAME when retrieving a kernel, CL_INVALID_KERNEL_ARGS when launching a kernel, or a crash in clBuildProgram.&lt;/P&gt;&lt;P&gt;When kernels are compiled to SPIR-V with the ocloc offline compiler from oneAPI, everything works fine. However, ocloc only compiles C kernels. Support for C++ kernels is rapidly becoming a gating requirement for device support for the project (a consumer desktop application). The Metal, Cuda (driver API), and CPU backends for the project all support C++ kernels, and this is turning out to be indispensible for managing the kernel-side combinatorics of types, dimensions, memory spaces, function blocks, and so on.&lt;/P&gt;&lt;H5&gt;&lt;STRONG&gt;Environment&lt;/STRONG&gt;&lt;/H5&gt;&lt;P&gt;&lt;EM&gt;Device&lt;/EM&gt;:&amp;nbsp; Intel UHD Graphics 630, i7-10700K processor&lt;BR /&gt;&lt;EM&gt;Driver&lt;/EM&gt;:&amp;nbsp; Intel graphics driver 31.0.101.2125, 30.0.101.1273&lt;BR /&gt;&lt;EM&gt;OS&lt;/EM&gt;:&amp;nbsp; Windows 11 Pro 10.0.22621&lt;BR /&gt;&lt;EM&gt;LLVM&lt;/EM&gt;:&amp;nbsp; 17.0.0 from main on July 9, 2023&lt;BR /&gt;&lt;EM&gt;ocloc&lt;/EM&gt;:&amp;nbsp; 2023.1.0, from oneAPI installation&lt;/P&gt;&lt;H5&gt;&lt;STRONG&gt;Code to reproduce&lt;/STRONG&gt;&lt;/H5&gt;&lt;P&gt;See attached .zip file. Contents:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;main.cpp -- Host code&lt;BR /&gt;kernel.cl -- C kernel that results in execution errors&lt;BR /&gt;kernel.clcpp -- C++ kernel that results in execution errors&lt;BR /&gt;crash_kernel.cl -- C kernel that results in execution crash&lt;BR /&gt;build.bat -- Build script for host app &amp;amp; kernels&lt;BR /&gt;test.exe -- prebuilt host app binary&lt;BR /&gt;*.spv -- prebuilt SPIR-V bitcode&lt;BR /&gt;*.spirv-dis -- disassembly of *.spv using spirv-dis&lt;/P&gt;&lt;H5&gt;&lt;STRONG&gt;Build instructions&lt;/STRONG&gt;&lt;/H5&gt;&lt;OL&gt;&lt;LI&gt;Edit paths at top of build.bat for your system&lt;/LI&gt;&lt;LI&gt;Start a Visual Studio command prompt (i.e. with vcvars64.bat loaded)&lt;/LI&gt;&lt;LI&gt;Run build.bat&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This should produce the following:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;test.exe -&amp;gt; host application&lt;BR /&gt;kernel_cl_ocloc.spv -&amp;gt; kernel.cl compiled with ocloc&lt;BR /&gt;kernel_cl_clang.spv -&amp;gt; kernel.cl compiled with clang/llvm-spirv&lt;BR /&gt;kernel_clcpp_clang.spv -&amp;gt; kernel.clcpp compiled with clang/llvm-spirv&lt;BR /&gt;crash_kernel_cl_ocloc.spv -&amp;gt; crash_kernel.cl compiled with ocloc&lt;BR /&gt;crash_kernel_cl_clang.spv -&amp;gt; crash_kernel.cl compiled with clang/llvm-spirv&lt;/P&gt;&lt;H5&gt;&lt;STRONG&gt;Results&lt;/STRONG&gt;&lt;/H5&gt;&lt;P class="lia-indent-padding-left-30px"&gt;With driver 31.0.101.2125:&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;test kernel_cl_ocloc.spv -&amp;gt; succeeds&lt;BR /&gt;test kernel_cl_clang.spv -&amp;gt; fails with&amp;nbsp; CL_INVALID_KERNEL_ARGS&lt;BR /&gt;test kernel_clcpp_clang.spv -&amp;gt; fails with&amp;nbsp; CL_INVALID_KERNEL_ARGS&amp;nbsp;&lt;BR /&gt;test crash_kernel_cl_ocloc.spv -&amp;gt; succeeds&lt;BR /&gt;test crash_kernel_cl_clang.spv -&amp;gt; clBuildProgram crashes&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;With driver 30.0.101.1273:&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;test kernel_cl_ocloc.spv -&amp;gt; succeeds&lt;BR /&gt;test kernel_cl_clang.spv -&amp;gt; fails with CL_INVALID_KERNEL_NAME&lt;BR /&gt;test kernel_clcpp_clang.spv -&amp;gt; fails with CL_INVALID_KERNEL_NAME&lt;BR /&gt;test crash_kernel_cl_ocloc.spv -&amp;gt; succeeds&lt;BR /&gt;test crash_kernel_cl_clang.spv -&amp;gt; fails with CL_INVALID_KERNEL_NAME&lt;/P&gt;&lt;P&gt;Success with ocloc and various C kernels establishes that the basic SPIR-V -&amp;gt; device execution chain is sane at least for C kernels, both with the sample code here and with the (much more elaborate) cross-API framework that I mentioned above.&amp;nbsp; So the problem seems to be either in the Intel OpenCL runtime on Windows, or in the SPIR-V produced by clang/llvm-spirv (but even then it shouldn't crash the driver).&amp;nbsp; Documentation and slideware from Khronos and Intel imply that the SPIR-V from clang/llvm-spirv should be viable with Intel drivers for both C and C++ kernels, and comments elsewhere indicate some success on Linux.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Level Zero:&lt;/STRONG&gt; I could implement a Level Zero backend if that would make a difference, and it would probably be a better long-term solution. However, if Level Zero relies on the same SPIR-V-to-device path that the OpenCL runtime is using, then I'll just end up in the same spot.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jul 2023 16:36:36 GMT</pubDate>
    <dc:creator>pxcc</dc:creator>
    <dc:date>2023-07-27T16:36:36Z</dc:date>
    <item>
      <title>SPIR-V from clang/llvm-spirv fails or crashes with OpenCL runtime on Windows</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/SPIR-V-from-clang-llvm-spirv-fails-or-crashes-with-OpenCL/m-p/1508820#M969</link>
      <description>&lt;H5&gt;&lt;STRONG&gt;Overview&lt;/STRONG&gt;&lt;/H5&gt;&lt;P&gt;I'm seeing a range of failures when attempting to execute SPIR-V from clang/llvm-spirv with the Intel OpenCL runtime on Windows. Depending on the driver version and kernel source, the failures include CL_INVALID_KERNEL_NAME when retrieving a kernel, CL_INVALID_KERNEL_ARGS when launching a kernel, or a crash in clBuildProgram.&lt;/P&gt;&lt;P&gt;When kernels are compiled to SPIR-V with the ocloc offline compiler from oneAPI, everything works fine. However, ocloc only compiles C kernels. Support for C++ kernels is rapidly becoming a gating requirement for device support for the project (a consumer desktop application). The Metal, Cuda (driver API), and CPU backends for the project all support C++ kernels, and this is turning out to be indispensible for managing the kernel-side combinatorics of types, dimensions, memory spaces, function blocks, and so on.&lt;/P&gt;&lt;H5&gt;&lt;STRONG&gt;Environment&lt;/STRONG&gt;&lt;/H5&gt;&lt;P&gt;&lt;EM&gt;Device&lt;/EM&gt;:&amp;nbsp; Intel UHD Graphics 630, i7-10700K processor&lt;BR /&gt;&lt;EM&gt;Driver&lt;/EM&gt;:&amp;nbsp; Intel graphics driver 31.0.101.2125, 30.0.101.1273&lt;BR /&gt;&lt;EM&gt;OS&lt;/EM&gt;:&amp;nbsp; Windows 11 Pro 10.0.22621&lt;BR /&gt;&lt;EM&gt;LLVM&lt;/EM&gt;:&amp;nbsp; 17.0.0 from main on July 9, 2023&lt;BR /&gt;&lt;EM&gt;ocloc&lt;/EM&gt;:&amp;nbsp; 2023.1.0, from oneAPI installation&lt;/P&gt;&lt;H5&gt;&lt;STRONG&gt;Code to reproduce&lt;/STRONG&gt;&lt;/H5&gt;&lt;P&gt;See attached .zip file. Contents:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;main.cpp -- Host code&lt;BR /&gt;kernel.cl -- C kernel that results in execution errors&lt;BR /&gt;kernel.clcpp -- C++ kernel that results in execution errors&lt;BR /&gt;crash_kernel.cl -- C kernel that results in execution crash&lt;BR /&gt;build.bat -- Build script for host app &amp;amp; kernels&lt;BR /&gt;test.exe -- prebuilt host app binary&lt;BR /&gt;*.spv -- prebuilt SPIR-V bitcode&lt;BR /&gt;*.spirv-dis -- disassembly of *.spv using spirv-dis&lt;/P&gt;&lt;H5&gt;&lt;STRONG&gt;Build instructions&lt;/STRONG&gt;&lt;/H5&gt;&lt;OL&gt;&lt;LI&gt;Edit paths at top of build.bat for your system&lt;/LI&gt;&lt;LI&gt;Start a Visual Studio command prompt (i.e. with vcvars64.bat loaded)&lt;/LI&gt;&lt;LI&gt;Run build.bat&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This should produce the following:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;test.exe -&amp;gt; host application&lt;BR /&gt;kernel_cl_ocloc.spv -&amp;gt; kernel.cl compiled with ocloc&lt;BR /&gt;kernel_cl_clang.spv -&amp;gt; kernel.cl compiled with clang/llvm-spirv&lt;BR /&gt;kernel_clcpp_clang.spv -&amp;gt; kernel.clcpp compiled with clang/llvm-spirv&lt;BR /&gt;crash_kernel_cl_ocloc.spv -&amp;gt; crash_kernel.cl compiled with ocloc&lt;BR /&gt;crash_kernel_cl_clang.spv -&amp;gt; crash_kernel.cl compiled with clang/llvm-spirv&lt;/P&gt;&lt;H5&gt;&lt;STRONG&gt;Results&lt;/STRONG&gt;&lt;/H5&gt;&lt;P class="lia-indent-padding-left-30px"&gt;With driver 31.0.101.2125:&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;test kernel_cl_ocloc.spv -&amp;gt; succeeds&lt;BR /&gt;test kernel_cl_clang.spv -&amp;gt; fails with&amp;nbsp; CL_INVALID_KERNEL_ARGS&lt;BR /&gt;test kernel_clcpp_clang.spv -&amp;gt; fails with&amp;nbsp; CL_INVALID_KERNEL_ARGS&amp;nbsp;&lt;BR /&gt;test crash_kernel_cl_ocloc.spv -&amp;gt; succeeds&lt;BR /&gt;test crash_kernel_cl_clang.spv -&amp;gt; clBuildProgram crashes&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;With driver 30.0.101.1273:&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;test kernel_cl_ocloc.spv -&amp;gt; succeeds&lt;BR /&gt;test kernel_cl_clang.spv -&amp;gt; fails with CL_INVALID_KERNEL_NAME&lt;BR /&gt;test kernel_clcpp_clang.spv -&amp;gt; fails with CL_INVALID_KERNEL_NAME&lt;BR /&gt;test crash_kernel_cl_ocloc.spv -&amp;gt; succeeds&lt;BR /&gt;test crash_kernel_cl_clang.spv -&amp;gt; fails with CL_INVALID_KERNEL_NAME&lt;/P&gt;&lt;P&gt;Success with ocloc and various C kernels establishes that the basic SPIR-V -&amp;gt; device execution chain is sane at least for C kernels, both with the sample code here and with the (much more elaborate) cross-API framework that I mentioned above.&amp;nbsp; So the problem seems to be either in the Intel OpenCL runtime on Windows, or in the SPIR-V produced by clang/llvm-spirv (but even then it shouldn't crash the driver).&amp;nbsp; Documentation and slideware from Khronos and Intel imply that the SPIR-V from clang/llvm-spirv should be viable with Intel drivers for both C and C++ kernels, and comments elsewhere indicate some success on Linux.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Level Zero:&lt;/STRONG&gt; I could implement a Level Zero backend if that would make a difference, and it would probably be a better long-term solution. However, if Level Zero relies on the same SPIR-V-to-device path that the OpenCL runtime is using, then I'll just end up in the same spot.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 16:36:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/SPIR-V-from-clang-llvm-spirv-fails-or-crashes-with-OpenCL/m-p/1508820#M969</guid>
      <dc:creator>pxcc</dc:creator>
      <dc:date>2023-07-27T16:36:36Z</dc:date>
    </item>
    <item>
      <title>Re:SPIR-V from clang/llvm-spirv fails or crashes with OpenCL runtime on Windows</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/SPIR-V-from-clang-llvm-spirv-fails-or-crashes-with-OpenCL/m-p/1509047#M970</link>
      <description>&lt;P&gt;Dear User, &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thank you for reaching out to us. We are reproducing your issue and get back to you shortly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Jul 2023 07:34:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/SPIR-V-from-clang-llvm-spirv-fails-or-crashes-with-OpenCL/m-p/1509047#M970</guid>
      <dc:creator>Anita_Intel</dc:creator>
      <dc:date>2023-07-28T07:34:51Z</dc:date>
    </item>
    <item>
      <title>Re:SPIR-V from clang/llvm-spirv fails or crashes with OpenCL runtime on Windows</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/SPIR-V-from-clang-llvm-spirv-fails-or-crashes-with-OpenCL/m-p/1509947#M975</link>
      <description>&lt;P&gt;Dear User,&lt;/P&gt;&lt;P&gt;We used below steps to reproduce this issue,&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;set below paths in build.bat&lt;OL&gt;&lt;LI&gt;set opencl_hdr_dir="C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL\sdk\include"&lt;/LI&gt;&lt;LI&gt;set opencl_lib_dir="C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL\sdk\lib\x64"&lt;/LI&gt;&lt;LI&gt;set ocloc="C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\lib\ocloc\gen9-11\ocloc.exe"&lt;/LI&gt;&lt;LI&gt;set clang="C:\Program Files (x86)\Intel\oneAPI\compiler\2023.2.0\windows\bin-llvm\clang.exe"&lt;/LI&gt;&lt;LI&gt;set llvm_spirv="C:\Program Files (x86)\Intel\oneAPI\compiler\2023.2.0\windows\bin-llvm\llvm-spirv.exe"&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;downloaded OpenCL API C++ bindings from the Khronos link: &lt;A href="https://codeload.github.com/KhronosGroup/OpenCL-CLHPP/zip/refs/heads/main" target="_blank"&gt;https://codeload.github.com/KhronosGroup/OpenCL-CLHPP/zip/refs/heads/main&lt;/A&gt;&lt;OL&gt;&lt;LI&gt;copy both header files "cl2.hpp and opencl.hpp" from location OpenCL-CLHPP-main\include\CL to opencl sdk header "C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL\sdk\include\CL"&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Loaded "c:\Program Files (x86)\Intel\oneAPI\setvars.bat"&lt;/LI&gt;&lt;LI&gt;Run build.bat&lt;/LI&gt;&lt;LI&gt;All opencl kernels compile successfully and test.exe gets created and run on GPU.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;​&lt;/P&gt;&lt;P&gt;Could you please follow same steps and let us know issues? &lt;/P&gt;&lt;P&gt;If you are having some other concerns, please write specifically and send us logs; we can investigate further if any incompatibility in the SPIR-V generated.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Aug 2023 05:36:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/SPIR-V-from-clang-llvm-spirv-fails-or-crashes-with-OpenCL/m-p/1509947#M975</guid>
      <dc:creator>Anita_Intel</dc:creator>
      <dc:date>2023-08-01T05:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Re:SPIR-V from clang/llvm-spirv fails or crashes with OpenCL runtime on Windows</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/SPIR-V-from-clang-llvm-spirv-fails-or-crashes-with-OpenCL/m-p/1510175#M976</link>
      <description>&lt;P&gt;Hi Anita,&lt;/P&gt;&lt;P&gt;I did a quick test using the 2023.1 clang/llvm-spirv from my current oneAPI installation, and that was sufficient to make the test cases work.&amp;nbsp; I didn't need to update the OpenCl headers.&lt;/P&gt;&lt;P&gt;However, my actual application code is still crashing with that change, and I'm in the middle of another task right now. As soon as I get to a stopping point, I'll install the July 20 oneAPI release, update OpenCL headers from Khronos, and go through my code to see if I can resolve any discrepancies with the test code.&amp;nbsp;It might be a couple of days before I can dig into it. I'll report back when I know more.&lt;/P&gt;&lt;P&gt;Thanks for your help with this, I appreciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2023 18:49:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/SPIR-V-from-clang-llvm-spirv-fails-or-crashes-with-OpenCL/m-p/1510175#M976</guid>
      <dc:creator>pxcc</dc:creator>
      <dc:date>2023-08-01T18:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Re:SPIR-V from clang/llvm-spirv fails or crashes with OpenCL runtime on Windows</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/SPIR-V-from-clang-llvm-spirv-fails-or-crashes-with-OpenCL/m-p/1511001#M978</link>
      <description>&lt;P&gt;Success!&amp;nbsp; It's working now.&amp;nbsp; I had forgotten to tickle part of my CMake superbuild and it wasn't picking up the new compiler path.&lt;/P&gt;&lt;P&gt;I switched on cl-std=CLC++2021&amp;nbsp; for the kernel language and so far templates and lambdas and whatnot are compiling and executing without issue.&lt;/P&gt;&lt;P&gt;This pleases me greatly.&lt;/P&gt;&lt;P&gt;Thanks again for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 21:44:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/SPIR-V-from-clang-llvm-spirv-fails-or-crashes-with-OpenCL/m-p/1511001#M978</guid>
      <dc:creator>pxcc</dc:creator>
      <dc:date>2023-08-03T21:44:47Z</dc:date>
    </item>
  </channel>
</rss>

