[PATCH] D146975: [NVPTX] Add __CUDA_ARCH__ macro to standalone NVPTX compilations

Joseph Huber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 27 10:24:00 PDT 2023


jhuber6 marked an inline comment as done.
jhuber6 added inline comments.


================
Comment at: clang/lib/Basic/Targets/NVPTX.cpp:171
   Builder.defineMacro("__NVPTX__");
-  if (Opts.CUDAIsDevice || Opts.OpenMPIsDevice) {
+  if (Opts.CUDAIsDevice || Opts.OpenMPIsDevice || !HostTarget) {
     // Set __CUDA_ARCH__ for the GPU specified.
----------------
tra wrote:
> Wouldn't just `if(!HostTarget)` be sufficient here?
> 
`HostTarget` is the host toolchain, provided via `-aux-triple`. So it's set for OpenMP and CUDA but not for a standalone.


================
Comment at: clang/test/Frontend/nvptx-macros.c:1
+// REQUIRES: nvptx-registered-target
+
----------------
tra wrote:
> I'd rename the file to make it more obvious that it deals with a standalone compilation.
> 
> `standalone-nvptx-macros.c` ?
I can do that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146975/new/

https://reviews.llvm.org/D146975



More information about the cfe-commits mailing list