Skip to content

[NVPTX] Enable OpenCL 3d_image_writes support #143331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wenju-he
Copy link
Contributor

@wenju-he wenju-he commented Jun 9, 2025

NV supports opencl_3d_image_writes according
https://developer.nvidia.com/blog/nvidia-is-now-opencl-3-0-conformant/

This PR allows removing explicit enabling of image extensions via -cl-ext command line option, e.g. at
https://github.com/intel/llvm/blob/43b3d42e2b2060e9e9e3a96469a1982dc4c10ddd/libclc/CMakeLists.txt#L503

NV supports opencl_3d_image_writes according
https://developer.nvidia.com/blog/nvidia-is-now-opencl-3-0-conformant/

This PR allows removing explicit enabling of image extensions via
-cl-ext command line option, e.g. at
https://github.com/intel/llvm/blob/43b3d42e2b2060e9e9e3a96469a1982dc4c10ddd/libclc/CMakeLists.txt#L503
@wenju-he wenju-he requested a review from frasercrmck June 9, 2025 01:45
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jun 9, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 9, 2025

@llvm/pr-subscribers-clang

Author: Wenju He (wenju-he)

Changes

NV supports opencl_3d_image_writes according
https://developer.nvidia.com/blog/nvidia-is-now-opencl-3-0-conformant/

This PR allows removing explicit enabling of image extensions via -cl-ext command line option, e.g. at
https://github.com/intel/llvm/blob/43b3d42e2b2060e9e9e3a96469a1982dc4c10ddd/libclc/CMakeLists.txt#L503


Full diff: https://github.com/llvm/llvm-project/pull/143331.diff

3 Files Affected:

  • (modified) clang/lib/Basic/Targets/NVPTX.h (+4)
  • (modified) clang/test/Misc/nvptx.languageOptsOpenCL.cl (+2-3)
  • (removed) clang/test/Misc/nvptx.unsupported_core.cl (-7)
diff --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h
index 33c29586359be..ae36252601229 100644
--- a/clang/lib/Basic/Targets/NVPTX.h
+++ b/clang/lib/Basic/Targets/NVPTX.h
@@ -172,6 +172,10 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo {
     Opts["cl_khr_local_int32_base_atomics"] = true;
     Opts["cl_khr_local_int32_extended_atomics"] = true;
 
+    Opts["__opencl_c_images"] = true;
+    Opts["__opencl_c_3d_image_writes"] = true;
+    Opts["cl_khr_3d_image_writes"] = true;
+
     Opts["__opencl_c_generic_address_space"] = true;
   }
 
diff --git a/clang/test/Misc/nvptx.languageOptsOpenCL.cl b/clang/test/Misc/nvptx.languageOptsOpenCL.cl
index 2610cfafc257b..186f22782d010 100644
--- a/clang/test/Misc/nvptx.languageOptsOpenCL.cl
+++ b/clang/test/Misc/nvptx.languageOptsOpenCL.cl
@@ -108,11 +108,10 @@
 #endif
 
 // Core feature in CL 2.0, but not supported on nvptx
-#ifdef cl_khr_3d_image_writes
-#error "Incorrect cl_khr_3d_image_writes define"
+#ifndef cl_khr_3d_image_writes
+#error "Missing cl_khr_3d_image_writes define"
 #endif
 #pragma OPENCL EXTENSION cl_khr_3d_image_writes: enable
-// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_3d_image_writes' - ignoring}}
 
 #ifdef cl_khr_gl_msaa_sharing
 #error "Incorrect cl_khr_gl_msaa_sharing define"
diff --git a/clang/test/Misc/nvptx.unsupported_core.cl b/clang/test/Misc/nvptx.unsupported_core.cl
deleted file mode 100644
index b56a4828914ee..0000000000000
--- a/clang/test/Misc/nvptx.unsupported_core.cl
+++ /dev/null
@@ -1,7 +0,0 @@
-// RUN: %clang_cc1 -cl-std=CL2.0 -triple nvptx-unknown-unknown -Wpedantic-core-features %s 2> %t
-// RUN: FileCheck --check-prefixes=CHECK-C < %t %s
-// RUN: %clang_cc1 -cl-std=CLC++ -triple nvptx-unknown-unknown -Wpedantic-core-features %s 2> %t
-// RUN: FileCheck --check-prefixes=CHECK-CPP < %t %s
-
-// CHECK-C: cl_khr_3d_image_writes is a core feature in OpenCL C version 2.0 but not supported on this target
-// CHECK-CPP: cl_khr_3d_image_writes is a core feature in C++ for OpenCL version 1.0 but not supported on this target

Copy link
Contributor

@frasercrmck frasercrmck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I'm never sure who owns this aspect of NVPTX. @Artem-B, @jhuber6 ?

@jhuber6
Copy link
Contributor

jhuber6 commented Jun 9, 2025

LGTM but I'm never sure who owns this aspect of NVPTX. @Artem-B, @jhuber6 ?

I work at AMD and don't really know much about OpenCL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants