Skip OpenCL 3.1 PCM generation when prebuilt clang lacks CL3.1 support - #814
Conversation
The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM), which doesn't have the CL3.1 clang patches from patches/clang applied (those only apply when building clang from source in-tree). This made opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in '-cl-std=CL3.1'". Probe the resolved clang for -cl-std=CL3.1 support and skip generating/ packaging the CL3.1 PCM variants when unsupported, gating the runtime resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so GetHeaders() doesn't fail looking for a PCM that was never built. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ks CL3.1 support (intel#814) The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM), which doesn't have the CL3.1 clang patches from patches/clang applied (those only apply when building clang from source in-tree). This made opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in '-cl-std=CL3.1'". Probe the resolved clang for -cl-std=CL3.1 support and skip generating/ packaging the CL3.1 PCM variants when unsupported, gating the runtime resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so GetHeaders() doesn't fail looking for a PCM that was never built. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 9363ff5) This fixes out-of-tree build.
…ks CL3.1 support (intel#814) The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM), which doesn't have the CL3.1 clang patches from patches/clang applied (those only apply when building clang from source in-tree). This made opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in '-cl-std=CL3.1'". Probe the resolved clang for -cl-std=CL3.1 support and skip generating/ packaging the CL3.1 PCM variants when unsupported, gating the runtime resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so GetHeaders() doesn't fail looking for a PCM that was never built. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 9363ff5) This fixes out-of-tree build.
…ks CL3.1 support (#814) (#820) The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM), which doesn't have the CL3.1 clang patches from patches/clang applied (those only apply when building clang from source in-tree). This made opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in '-cl-std=CL3.1'". Probe the resolved clang for -cl-std=CL3.1 support and skip generating/ packaging the CL3.1 PCM variants when unsupported, gating the runtime resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so GetHeaders() doesn't fail looking for a PCM that was never built. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 9363ff5) This fixes out-of-tree build.
…ks CL3.1 support (#814) (#819) The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM), which doesn't have the CL3.1 clang patches from patches/clang applied (those only apply when building clang from source in-tree). This made opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in '-cl-std=CL3.1'". Probe the resolved clang for -cl-std=CL3.1 support and skip generating/ packaging the CL3.1 PCM variants when unsupported, gating the runtime resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so GetHeaders() doesn't fail looking for a PCM that was never built. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 9363ff5) This fixes out-of-tree build.
…ks CL3.1 support (#814) (#818) The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM), which doesn't have the CL3.1 clang patches from patches/clang applied (those only apply when building clang from source in-tree). This made opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in '-cl-std=CL3.1'". Probe the resolved clang for -cl-std=CL3.1 support and skip generating/ packaging the CL3.1 PCM variants when unsupported, gating the runtime resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so GetHeaders() doesn't fail looking for a PCM that was never built. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 9363ff5) This fixes out-of-tree build.
…ks CL3.1 support (#814) (#823) The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM), which doesn't have the CL3.1 clang patches from patches/clang applied (those only apply when building clang from source in-tree). This made opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in '-cl-std=CL3.1'". Probe the resolved clang for -cl-std=CL3.1 support and skip generating/ packaging the CL3.1 PCM variants when unsupported, gating the runtime resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so GetHeaders() doesn't fail looking for a PCM that was never built. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 9363ff5) This fixes out-of-tree build.
…ks CL3.1 support (#814) (#826) The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM), which doesn't have the CL3.1 clang patches from patches/clang applied (those only apply when building clang from source in-tree). This made opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in '-cl-std=CL3.1'". Probe the resolved clang for -cl-std=CL3.1 support and skip generating/ packaging the CL3.1 PCM variants when unsupported, gating the runtime resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so GetHeaders() doesn't fail looking for a PCM that was never built. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 9363ff5) This fixes out-of-tree build.
…ks CL3.1 support (#814) (#825) The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM), which doesn't have the CL3.1 clang patches from patches/clang applied (those only apply when building clang from source in-tree). This made opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in '-cl-std=CL3.1'". Probe the resolved clang for -cl-std=CL3.1 support and skip generating/ packaging the CL3.1 PCM variants when unsupported, gating the runtime resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so GetHeaders() doesn't fail looking for a PCM that was never built. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 9363ff5) This fixes out-of-tree build.
…ks CL3.1 support (#814) (#824) The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM), which doesn't have the CL3.1 clang patches from patches/clang applied (those only apply when building clang from source in-tree). This made opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in '-cl-std=CL3.1'". Probe the resolved clang for -cl-std=CL3.1 support and skip generating/ packaging the CL3.1 PCM variants when unsupported, gating the runtime resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so GetHeaders() doesn't fail looking for a PCM that was never built. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 9363ff5) This fixes out-of-tree build.
…ks CL3.1 support (#814) (#822) The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM), which doesn't have the CL3.1 clang patches from patches/clang applied (those only apply when building clang from source in-tree). This made opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in '-cl-std=CL3.1'". Probe the resolved clang for -cl-std=CL3.1 support and skip generating/ packaging the CL3.1 PCM variants when unsupported, gating the runtime resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so GetHeaders() doesn't fail looking for a PCM that was never built. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 9363ff5) This fixes out-of-tree build.
| @@ -80,20 +80,32 @@ set(OPTS -cl-ext=+all,-cl_khr_fp64,-__opencl_c_fp64) | |||
| create_pcm(opencl-c-12-spir.pcm cl12spir opencl-c-base.h "${SPIR_TRIPLE};${CL12};${OPTS}" "${DEPS}") | |||
There was a problem hiding this comment.
Was a condition in line 65 missed? I am having currently some trouble with CL3.1 in NixOS.
There was a problem hiding this comment.
line 65 is set(CL31 "-cl-std=CL3.1") and CL31 isn't used if CLANG_SUPPORTS_CL31 is false.
Could you paste the error? Is CLANG_SUPPORTS_CL31 true or false?
There was a problem hiding this comment.
#880 will fix out-of-tree build in opencl-clang main branch
There was a problem hiding this comment.
Oh yeah, that just sets the var 🤦🏼
I figured the issue out in NixOS. Since we have no full git tree, the patching would not work as the exit code of git for rev-prase would be 128. That is handled in newer versions of opencl-clang and logged, but for the time being I just turned one condition to always true. We only consume opencl-clang throuch intel-graphics-compierl.
That's the PR if you are interested NixOS/nixpkgs#555838
And igc still uses the 170 branch, so we are stuck to that.
There was a problem hiding this comment.
Is it right that NixOS extract llvm-project release from a tarball file and there is not .git folder in llvm-project folder?
There was a problem hiding this comment.
Could you please check if #881 works for you? After the PR, opencl-clang can apply patch without requiring .git folder being existing.
There was a problem hiding this comment.
Is it right that NixOS extract llvm-project release from a tarball file and there is not .git folder in llvm-project folder?
Yep. I tried fetching the git tree, but I could not get a stable hash of that download, so it failed CI, obviously.
I try to look at the patch in the next days.
There was a problem hiding this comment.
I try to look at the patch in the next days.
great. My local testing shows opencl-clang applied its clang/llvm patch successfully in llvm-project-17.0.6.src folder (no .git subfolder) extracted from llvm-project-17.0.6.src.tar.xz
The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM), which doesn't have the CL3.1 clang patches from patches/clang applied (those only apply when building clang from source in-tree). This made opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in '-cl-std=CL3.1'".
Probe the resolved clang for -cl-std=CL3.1 support and skip generating/ packaging the CL3.1 PCM variants when unsupported, gating the runtime resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so GetHeaders() doesn't fail looking for a PCM that was never built.