Skip to content

Conversation

@frasercrmck
Copy link
Contributor

As best as I can see, all NVPTX architectures support the generic address space.

I note there's a FIXME in the target's address space map about 'generic' still having to be added to the target but we haven't observed any issues with it downstream. The generic address space is mapped to the same target address space as default/private (0), but this isn't necessarily a problem for users.

As best as I can see, all NVPTX architectures support the generic
address space.

I note there's a FIXME in the target's address space map about 'generic'
still having to be added to the target but we haven't observed any
issues with it downstream. The generic address space is mapped to the
same target address space as default/private (0), but this isn't
necessarily a problem for users.
@frasercrmck frasercrmck requested a review from AlexMaclean April 30, 2025 09:16
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Apr 30, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 30, 2025

@llvm/pr-subscribers-clang

Author: Fraser Cormack (frasercrmck)

Changes

As best as I can see, all NVPTX architectures support the generic address space.

I note there's a FIXME in the target's address space map about 'generic' still having to be added to the target but we haven't observed any issues with it downstream. The generic address space is mapped to the same target address space as default/private (0), but this isn't necessarily a problem for users.


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

2 Files Affected:

  • (modified) clang/lib/Basic/Targets/NVPTX.h (+2)
  • (modified) clang/test/Misc/nvptx.languageOptsOpenCL.cl (+8)
diff --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h
index dc1ecc30980b7..fbb46001b0f90 100644
--- a/clang/lib/Basic/Targets/NVPTX.h
+++ b/clang/lib/Basic/Targets/NVPTX.h
@@ -170,6 +170,8 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo {
     Opts["cl_khr_global_int32_extended_atomics"] = true;
     Opts["cl_khr_local_int32_base_atomics"] = true;
     Opts["cl_khr_local_int32_extended_atomics"] = true;
+
+    Opts["__opencl_c_generic_address_space"] = true;
   }
 
   const llvm::omp::GV &getGridValue() const override {
diff --git a/clang/test/Misc/nvptx.languageOptsOpenCL.cl b/clang/test/Misc/nvptx.languageOptsOpenCL.cl
index f479dddffb3ab..2610cfafc257b 100644
--- a/clang/test/Misc/nvptx.languageOptsOpenCL.cl
+++ b/clang/test/Misc/nvptx.languageOptsOpenCL.cl
@@ -132,3 +132,11 @@
 #pragma OPENCL EXTENSION cl_khr_subgroups: enable
 // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 300)
+#ifndef __opencl_c_generic_address_space
+#error "Missing __opencl_c_generic_address_space define"
+#else
+#error "Incorrect __opencl_c_generic_address_space define"
+#endif
+#pragma OPENCL EXTENSION __opencl_c_generic_address_space: enable
+#endif

@frasercrmck frasercrmck requested a review from Artem-B May 12, 2025 13:47
@frasercrmck
Copy link
Contributor Author

ping, thanks

@arsenm arsenm requested a review from svenvh May 20, 2025 19:52
@arsenm arsenm added the OpenCL label May 20, 2025
@frasercrmck frasercrmck merged commit 6553dc3 into llvm:main May 21, 2025
15 checks passed
@frasercrmck frasercrmck deleted the nvptx-opencl-generic-addrspace branch May 21, 2025 08:55
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 OpenCL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants