[PATCH] D125256: [OpenMP] Add `__CUDA_ARCH__` definition when offloading with OpenMP

Joseph Huber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 13 11:39:29 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG002a63f937d9: [OpenMP] Add `__CUDA_ARCH__` definition when offloading with OpenMP (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125256

Files:
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/test/OpenMP/driver-openmp-target.c


Index: clang/test/OpenMP/driver-openmp-target.c
===================================================================
--- clang/test/OpenMP/driver-openmp-target.c
+++ clang/test/OpenMP/driver-openmp-target.c
@@ -1,4 +1,8 @@
 // REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
 // REQUIRES: clang-target-64-bits
+
 // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 -fopenmp-targets=x86_64-unknown-unknown -o - | FileCheck --check-prefix=CHECK-45-VERSION %s
 // CHECK-45-VERSION: #define _OPENMP 201511
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -nogpulib --offload-arch=sm_70 --offload-device-only -o - | FileCheck --check-prefix=CHECK-CUDA-ARCH %s
+// CHECK-CUDA-ARCH: #define __CUDA_ARCH__ 700
Index: clang/lib/Basic/Targets/NVPTX.cpp
===================================================================
--- clang/lib/Basic/Targets/NVPTX.cpp
+++ clang/lib/Basic/Targets/NVPTX.cpp
@@ -179,7 +179,7 @@
                                        MacroBuilder &Builder) const {
   Builder.defineMacro("__PTX__");
   Builder.defineMacro("__NVPTX__");
-  if (Opts.CUDAIsDevice) {
+  if (Opts.CUDAIsDevice || Opts.OpenMPIsDevice) {
     // Set __CUDA_ARCH__ for the GPU specified.
     std::string CUDAArchCode = [this] {
       switch (GPU) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125256.429305.patch
Type: text/x-patch
Size: 1270 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220513/9f7728b6/attachment-0001.bin>


More information about the cfe-commits mailing list