Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 2 additions & 107 deletions clang/include/clang/Basic/Cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#ifndef LLVM_CLANG_BASIC_CUDA_H
#define LLVM_CLANG_BASIC_CUDA_H

#include "clang/Basic/OffloadArch.h"

namespace llvm {
class StringRef;
class Twine;
Expand Down Expand Up @@ -54,98 +56,6 @@ const char *CudaVersionToString(CudaVersion V);
// Input is "Major.Minor"
CudaVersion CudaStringToVersion(const llvm::Twine &S);

enum class OffloadArch {
UNUSED,
UNKNOWN,
// TODO: Deprecate and remove GPU architectures older than sm_52.
SM_20,
SM_21,
SM_30,
// This has a name conflict with sys/mac.h on AIX, rename it as a workaround.
SM_32_,
SM_35,
SM_37,
SM_50,
SM_52,
SM_53,
SM_60,
SM_61,
SM_62,
SM_70,
SM_72,
SM_75,
SM_80,
SM_86,
SM_87,
SM_89,
SM_90,
SM_90a,
SM_100,
SM_100a,
SM_101,
SM_101a,
SM_120,
SM_120a,
GFX600,
GFX601,
GFX602,
GFX700,
GFX701,
GFX702,
GFX703,
GFX704,
GFX705,
GFX801,
GFX802,
GFX803,
GFX805,
GFX810,
GFX9_GENERIC,
GFX900,
GFX902,
GFX904,
GFX906,
GFX908,
GFX909,
GFX90a,
GFX90c,
GFX9_4_GENERIC,
GFX942,
GFX950,
GFX10_1_GENERIC,
GFX1010,
GFX1011,
GFX1012,
GFX1013,
GFX10_3_GENERIC,
GFX1030,
GFX1031,
GFX1032,
GFX1033,
GFX1034,
GFX1035,
GFX1036,
GFX11_GENERIC,
GFX1100,
GFX1101,
GFX1102,
GFX1103,
GFX1150,
GFX1151,
GFX1152,
GFX1153,
GFX12_GENERIC,
GFX1200,
GFX1201,
AMDGCNSPIRV,
Generic, // A processor model named 'generic' if the target backend defines a
// public one.
LAST,

CudaDefault = OffloadArch::SM_52,
HIPDefault = OffloadArch::GFX906,
};

enum class CUDAFunctionTarget {
Device,
Global,
Expand All @@ -154,21 +64,6 @@ enum class CUDAFunctionTarget {
InvalidTarget
};

static inline bool IsNVIDIAOffloadArch(OffloadArch A) {
return A >= OffloadArch::SM_20 && A < OffloadArch::GFX600;
}

static inline bool IsAMDOffloadArch(OffloadArch A) {
// Generic processor model is for testing only.
return A >= OffloadArch::GFX600 && A < OffloadArch::Generic;
}

const char *OffloadArchToString(OffloadArch A);
const char *OffloadArchToVirtualArchString(OffloadArch A);

// The input should have the form "sm_20".
OffloadArch StringToOffloadArch(llvm::StringRef S);

/// Get the earliest CudaVersion that supports the given OffloadArch.
CudaVersion MinVersionForOffloadArch(OffloadArch A);

Expand Down
143 changes: 143 additions & 0 deletions clang/include/clang/Basic/OffloadArch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
//===--- OffloadArch.h - Definition of offloading architectures --- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_BASIC_OFFLOADARCH_H
#define LLVM_CLANG_BASIC_OFFLOADARCH_H

namespace llvm {
class StringRef;
} // namespace llvm

namespace clang {

enum class OffloadArch {
UNUSED,
UNKNOWN,
// TODO: Deprecate and remove GPU architectures older than sm_52.
SM_20,
SM_21,
SM_30,
// This has a name conflict with sys/mac.h on AIX, rename it as a workaround.
SM_32_,
SM_35,
SM_37,
SM_50,
SM_52,
SM_53,
SM_60,
SM_61,
SM_62,
SM_70,
SM_72,
SM_75,
SM_80,
SM_86,
SM_87,
SM_89,
SM_90,
SM_90a,
SM_100,
SM_100a,
SM_101,
SM_101a,
SM_120,
SM_120a,
GFX600,
GFX601,
GFX602,
GFX700,
GFX701,
GFX702,
GFX703,
GFX704,
GFX705,
GFX801,
GFX802,
GFX803,
GFX805,
GFX810,
GFX9_GENERIC,
GFX900,
GFX902,
GFX904,
GFX906,
GFX908,
GFX909,
GFX90a,
GFX90c,
GFX9_4_GENERIC,
GFX942,
GFX950,
GFX10_1_GENERIC,
GFX1010,
GFX1011,
GFX1012,
GFX1013,
GFX10_3_GENERIC,
GFX1030,
GFX1031,
GFX1032,
GFX1033,
GFX1034,
GFX1035,
GFX1036,
GFX11_GENERIC,
GFX1100,
GFX1101,
GFX1102,
GFX1103,
GFX1150,
GFX1151,
GFX1152,
GFX1153,
GFX12_GENERIC,
GFX1200,
GFX1201,
AMDGCNSPIRV,
Generic, // A processor model named 'generic' if the target backend defines a
// public one.
// Intel CPUs
GRANITERAPIDS,
// Intel GPUs
BMG_G21,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these new? If so that should be in a follow-up after an NFC move.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's reasonable. I'll introduce these later.

LAST,

CudaDefault = OffloadArch::SM_52,
HIPDefault = OffloadArch::GFX906,
};

static inline bool IsNVIDIAOffloadArch(OffloadArch A) {
return A >= OffloadArch::SM_20 && A < OffloadArch::GFX600;
}

static inline bool IsAMDOffloadArch(OffloadArch A) {
// Generic processor model is for testing only.
return A >= OffloadArch::GFX600 && A < OffloadArch::Generic;
}

static inline bool IsIntelCPUArch(OffloadArch Arch) {
return Arch >= OffloadArch::GRANITERAPIDS && Arch < OffloadArch::BMG_G21;
}

static inline bool IsIntelGPUArch(OffloadArch Arch) {
return Arch >= OffloadArch::BMG_G21 && Arch < OffloadArch::LAST;
}

static inline bool IsIntelOffloadArch(OffloadArch Arch) {
return IsIntelCPUArch(Arch) || IsIntelGPUArch(Arch);
}

const char *OffloadArchToString(OffloadArch A);
const char *OffloadArchToVirtualArchString(OffloadArch A);

// The input should have the form "sm_20".
OffloadArch StringToOffloadArch(llvm::StringRef S);

} // namespace clang

#endif // LLVM_CLANG_BASIC_OFFLOADARCH_H
1 change: 1 addition & 0 deletions clang/lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ add_clang_library(clangBasic
MakeSupport.cpp
Module.cpp
ObjCRuntime.cpp
OffloadArch.cpp
OpenCLOptions.cpp
OpenMPKinds.cpp
OperatorPrecedence.cpp
Expand Down
Loading