r329584 - [CUDA] Revert defining __CUDA_ARCH__ for amdgcn targets
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 9 08:43:01 PDT 2018
Author: yaxunl
Date: Mon Apr 9 08:43:01 2018
New Revision: 329584
URL: http://llvm.org/viewvc/llvm-project?rev=329584&view=rev
Log:
[CUDA] Revert defining __CUDA_ARCH__ for amdgcn targets
amdgcn targets only support HIP, which does not define __CUDA_ARCH__.
this is a partial unroll of r329232 / D45277.
Differential Revision: https://reviews.llvm.org/D45387
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Basic/Targets.h
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/lib/Basic/Targets/AMDGPU.h
cfe/trunk/lib/Basic/Targets/NVPTX.cpp
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=329584&r1=329583&r2=329584&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Apr 9 08:43:01 2018
@@ -112,61 +112,6 @@ void addMinGWDefines(const llvm::Triple
addCygMingDefines(Opts, Builder);
}
-void defineCudaArchMacro(CudaArch GPU, clang::MacroBuilder &Builder) {
- std::string CUDAArchCode = [GPU] {
- switch (GPU) {
- case CudaArch::LAST:
- break;
- case CudaArch::SM_20:
- return "200";
- case CudaArch::SM_21:
- return "210";
- case CudaArch::SM_30:
- return "300";
- case CudaArch::SM_32:
- return "320";
- case CudaArch::SM_35:
- return "350";
- case CudaArch::SM_37:
- return "370";
- case CudaArch::SM_50:
- return "500";
- case CudaArch::SM_52:
- return "520";
- case CudaArch::SM_53:
- return "530";
- case CudaArch::SM_60:
- return "600";
- case CudaArch::SM_61:
- return "610";
- case CudaArch::SM_62:
- return "620";
- case CudaArch::SM_70:
- return "700";
- case CudaArch::SM_72:
- return "720";
- case CudaArch::GFX600:
- case CudaArch::GFX601:
- case CudaArch::GFX700:
- case CudaArch::GFX701:
- case CudaArch::GFX702:
- case CudaArch::GFX703:
- case CudaArch::GFX704:
- case CudaArch::GFX801:
- case CudaArch::GFX802:
- case CudaArch::GFX803:
- case CudaArch::GFX810:
- case CudaArch::GFX900:
- case CudaArch::GFX902:
- return "1";
- case CudaArch::UNKNOWN:
- llvm_unreachable("unhandled Cuda/HIP Arch");
- }
- llvm_unreachable("unhandled Cuda/HIP Arch");
- }();
- Builder.defineMacro("__CUDA_ARCH__", CUDAArchCode);
-}
-
//===----------------------------------------------------------------------===//
// Driver code
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Basic/Targets.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.h?rev=329584&r1=329583&r2=329584&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.h (original)
+++ cfe/trunk/lib/Basic/Targets.h Mon Apr 9 08:43:01 2018
@@ -16,7 +16,6 @@
#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_H
#define LLVM_CLANG_LIB_BASIC_TARGETS_H
-#include "clang/Basic/Cuda.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/MacroBuilder.h"
#include "clang/Basic/TargetInfo.h"
@@ -47,9 +46,6 @@ void addMinGWDefines(const llvm::Triple
LLVM_LIBRARY_VISIBILITY
void addCygMingDefines(const clang::LangOptions &Opts,
clang::MacroBuilder &Builder);
-
-LLVM_LIBRARY_VISIBILITY
-void defineCudaArchMacro(CudaArch GPU, clang::MacroBuilder &Builder);
} // namespace targets
} // namespace clang
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_H
Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=329584&r1=329583&r2=329584&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Mon Apr 9 08:43:01 2018
@@ -12,7 +12,6 @@
//===----------------------------------------------------------------------===//
#include "AMDGPU.h"
-#include "Targets.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/MacroBuilder.h"
@@ -264,7 +263,6 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const
resetDataLayout(isAMDGCN(getTriple()) ? DataLayoutStringAMDGCN
: DataLayoutStringR600);
assert(DataLayout->getAllocaAddrSpace() == Private);
- GCN_Subarch = CudaArch::GFX803; // Default to fiji
setAddressSpaceMap(Triple.getOS() == llvm::Triple::Mesa3D ||
!isAMDGCN(Triple));
@@ -309,9 +307,6 @@ void AMDGPUTargetInfo::getTargetDefines(
if (GPU.Kind != GK_NONE)
Builder.defineMacro(Twine("__") + Twine(GPU.CanonicalName) + Twine("__"));
- if (Opts.CUDAIsDevice)
- defineCudaArchMacro(GCN_Subarch, Builder);
-
// TODO: __HAS_FMAF__, __HAS_LDEXPF__, __HAS_FP64__ are deprecated and will be
// removed in the near future.
if (GPU.HasFMAF)
Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.h?rev=329584&r1=329583&r2=329584&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/AMDGPU.h (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.h Mon Apr 9 08:43:01 2018
@@ -14,7 +14,6 @@
#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H
#define LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H
-#include "clang/Basic/Cuda.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TargetOptions.h"
#include "llvm/ADT/StringSet.h"
@@ -175,7 +174,6 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTarg
static bool isAMDGCN(const llvm::Triple &TT) {
return TT.getArch() == llvm::Triple::amdgcn;
}
- CudaArch GCN_Subarch;
public:
AMDGPUTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
@@ -332,7 +330,6 @@ public:
else
GPU = parseR600Name(Name);
- GCN_Subarch = StringToCudaArch(Name);
return GK_NONE != GPU.Kind;
}
Modified: cfe/trunk/lib/Basic/Targets/NVPTX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/NVPTX.cpp?rev=329584&r1=329583&r2=329584&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/NVPTX.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/NVPTX.cpp Mon Apr 9 08:43:01 2018
@@ -153,8 +153,61 @@ void NVPTXTargetInfo::getTargetDefines(c
MacroBuilder &Builder) const {
Builder.defineMacro("__PTX__");
Builder.defineMacro("__NVPTX__");
- if (Opts.CUDAIsDevice)
- defineCudaArchMacro(GPU, Builder);
+ if (Opts.CUDAIsDevice) {
+ // Set __CUDA_ARCH__ for the GPU specified.
+ std::string CUDAArchCode = [this] {
+ switch (GPU) {
+ case CudaArch::GFX600:
+ case CudaArch::GFX601:
+ case CudaArch::GFX700:
+ case CudaArch::GFX701:
+ case CudaArch::GFX702:
+ case CudaArch::GFX703:
+ case CudaArch::GFX704:
+ case CudaArch::GFX801:
+ case CudaArch::GFX802:
+ case CudaArch::GFX803:
+ case CudaArch::GFX810:
+ case CudaArch::GFX900:
+ case CudaArch::GFX902:
+ case CudaArch::LAST:
+ break;
+ case CudaArch::UNKNOWN:
+ assert(false && "No GPU arch when compiling CUDA device code.");
+ return "";
+ case CudaArch::SM_20:
+ return "200";
+ case CudaArch::SM_21:
+ return "210";
+ case CudaArch::SM_30:
+ return "300";
+ case CudaArch::SM_32:
+ return "320";
+ case CudaArch::SM_35:
+ return "350";
+ case CudaArch::SM_37:
+ return "370";
+ case CudaArch::SM_50:
+ return "500";
+ case CudaArch::SM_52:
+ return "520";
+ case CudaArch::SM_53:
+ return "530";
+ case CudaArch::SM_60:
+ return "600";
+ case CudaArch::SM_61:
+ return "610";
+ case CudaArch::SM_62:
+ return "620";
+ case CudaArch::SM_70:
+ return "700";
+ case CudaArch::SM_72:
+ return "720";
+ }
+ llvm_unreachable("unhandled CudaArch");
+ }();
+ Builder.defineMacro("__CUDA_ARCH__", CUDAArchCode);
+ }
}
ArrayRef<Builtin::Info> NVPTXTargetInfo::getTargetBuiltins() const {
More information about the cfe-commits
mailing list