Skip to content

Commit 5768f50

Browse files
committed
Update
Signed-off-by: Jiang, Zhiwei <zhiwei.jiang@intel.com>
1 parent 5a74ef3 commit 5768f50

3 files changed

Lines changed: 43 additions & 157 deletions

File tree

clang/lib/DPCT/RulesLang/RulesLang.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,10 @@ void TypeInDeclRule::registerMatcher(MatchFinder &MF) {
328328
"curandRngType_t", "curandOrdering_t", "cufftHandle", "cufftReal",
329329
"cufftDoubleReal", "cufftComplex", "cufftDoubleComplex",
330330
"cufftResult_t", "cufftResult", "cufftType_t", "cufftType",
331-
thrustNamespace() + "pair", "CUdeviceptr", "cudaDeviceAttr", "CUmodule",
332-
"CUjit_option", "CUfunction", "cudaMemcpyKind", "cudaComputeMode",
333-
"__nv_bfloat16", "cooperative_groups::__v1::thread_group",
331+
thrustNamespace() + "pair", "CUdeviceptr", "cudaDeviceAttr",
332+
"CUmodule", "CUjit_option", "CUfunction", "cudaMemcpyKind",
333+
"cudaComputeMode", "__nv_bfloat16",
334+
"cooperative_groups::__v1::thread_group",
334335
"cooperative_groups::__v1::thread_block", "libraryPropertyType_t",
335336
"libraryPropertyType", "cudaDataType_t", "cudaDataType",
336337
"cublasComputeType_t", "cublasAtomicsMode_t", "cublasMath_t",

clang/lib/DPCT/RulesLangLib/ThrustAPIMigration.cpp

Lines changed: 35 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -22,136 +22,44 @@ void ThrustAPIRule::registerMatcher(ast_matchers::MatchFinder &MF) {
2222
// API register
2323
auto functionName = [&]() { return hasAnyName("on"); };
2424

25-
// THRUST_200302___CUDA_ARCH_LIST___NS is newly imported inline
26-
// namespace by thrust library in CUDA header file 12.4.
27-
auto thrustFuncNameCuda124 = [&]() {
28-
return hasAnyName("THRUST_200302___CUDA_ARCH_LIST___NS",
29-
"THRUST_200302___CUDA_ARCH_LIST___NS::detail",
30-
"THRUST_200302___CUDA_ARCH_LIST___NS::system");
31-
};
32-
33-
// THRUST_200400___CUDA_ARCH_LIST___NS is newly imported inline
34-
// namespace by thrust library in CUDA header file 12.5.
35-
auto thrustFuncNameCuda125 = [&]() {
36-
return hasAnyName("THRUST_200400___CUDA_ARCH_LIST___NS",
37-
"THRUST_200400___CUDA_ARCH_LIST___NS::detail",
38-
"THRUST_200400___CUDA_ARCH_LIST___NS::system");
39-
};
40-
41-
// THRUST_200500___CUDA_ARCH_LIST___NS is newly imported inline
42-
// namespace by thrust library in CUDA header file 12.6.
43-
auto thrustFuncNameCuda126 = [&]() {
44-
return hasAnyName("THRUST_200500___CUDA_ARCH_LIST___NS",
45-
"THRUST_200500___CUDA_ARCH_LIST___NS::detail",
46-
"THRUST_200500___CUDA_ARCH_LIST___NS::system");
47-
};
48-
49-
// THRUST_200700___CUDA_ARCH_LIST___NS is newly imported inline
50-
// namespace by thrust library in CUDA header file 12.6.
51-
auto thrustFuncNameCuda128 = [&]() {
52-
return hasAnyName("THRUST_200700___CUDA_ARCH_LIST___NS",
53-
"THRUST_200700___CUDA_ARCH_LIST___NS::detail",
54-
"THRUST_200700___CUDA_ARCH_LIST___NS::system");
55-
};
56-
57-
auto thrustFuncNameCuda129 = [&]() {
58-
return hasAnyName("THRUST_200802_SM___CUDA_ARCH_LIST___NS",
59-
"THRUST_200802_SM___CUDA_ARCH_LIST___NS::detail",
60-
"THRUST_200802_SM___CUDA_ARCH_LIST___NS::system");
61-
};
62-
63-
auto thrustFuncNameCudaCommon = [&]() {
64-
return hasAnyName("thrust", "thrust::detail", "thrust::system", "__4");
65-
};
66-
6725
int ThrustMajorVersion = ThrustVersion / 100000;
6826
int ThrustMinorVersion = ThrustVersion / 100 % 1000;
6927

70-
if (ThrustMajorVersion == 2 && ThrustMinorVersion == 3) {
71-
// For CUDA-12.4
72-
MF.addMatcher(
73-
callExpr(
74-
anyOf(callee(functionDecl(anyOf(
75-
hasDeclContext(namespaceDecl(thrustFuncNameCuda124())),
76-
hasDeclContext(namespaceDecl(thrustFuncNameCudaCommon())),
77-
functionName()))),
78-
callee(unresolvedLookupExpr(
79-
hasAnyDeclaration(namedDecl(hasDeclContext(namespaceDecl(
80-
anyOf(thrustFuncNameCuda124(),
81-
thrustFuncNameCudaCommon())))))))))
82-
.bind("thrustFuncCall"),
83-
this);
84-
85-
} else if (ThrustMajorVersion == 2 && ThrustMinorVersion == 4) {
86-
// For CUDA-12.5
87-
MF.addMatcher(
88-
callExpr(
89-
anyOf(callee(functionDecl(anyOf(
90-
hasDeclContext(namespaceDecl(thrustFuncNameCuda125())),
91-
hasDeclContext(namespaceDecl(thrustFuncNameCudaCommon())),
92-
functionName()))),
93-
callee(unresolvedLookupExpr(
94-
hasAnyDeclaration(namedDecl(hasDeclContext(namespaceDecl(
95-
anyOf(thrustFuncNameCuda125(),
96-
thrustFuncNameCudaCommon())))))))))
97-
.bind("thrustFuncCall"),
98-
this);
99-
} else if (ThrustMajorVersion == 2 && ThrustMinorVersion == 5) {
100-
// For CUDA-12.6
101-
MF.addMatcher(
102-
callExpr(
103-
anyOf(callee(functionDecl(anyOf(
104-
hasDeclContext(namespaceDecl(thrustFuncNameCuda126())),
105-
hasDeclContext(namespaceDecl(thrustFuncNameCudaCommon())),
106-
functionName()))),
107-
callee(unresolvedLookupExpr(
108-
hasAnyDeclaration(namedDecl(hasDeclContext(namespaceDecl(
109-
anyOf(thrustFuncNameCuda126(),
110-
thrustFuncNameCudaCommon())))))))))
111-
.bind("thrustFuncCall"),
112-
this);
113-
} else if (ThrustMajorVersion == 2 && ThrustMinorVersion == 7) {
114-
// For CUDA-12.8
115-
MF.addMatcher(
116-
callExpr(
117-
anyOf(callee(functionDecl(anyOf(
118-
hasDeclContext(namespaceDecl(thrustFuncNameCuda128())),
119-
hasDeclContext(namespaceDecl(thrustFuncNameCudaCommon())),
120-
functionName()))),
121-
callee(unresolvedLookupExpr(
122-
hasAnyDeclaration(namedDecl(hasDeclContext(namespaceDecl(
123-
anyOf(thrustFuncNameCuda128(),
124-
thrustFuncNameCudaCommon())))))))))
125-
.bind("thrustFuncCall"),
126-
this);
127-
} else if (ThrustMajorVersion == 2 && ThrustMinorVersion == 8) {
128-
// For CUDA-12.9
129-
MF.addMatcher(
130-
callExpr(
131-
anyOf(callee(functionDecl(anyOf(
132-
hasDeclContext(namespaceDecl(thrustFuncNameCuda129())),
133-
hasDeclContext(namespaceDecl(thrustFuncNameCudaCommon())),
134-
functionName()))),
135-
callee(unresolvedLookupExpr(
136-
hasAnyDeclaration(namedDecl(hasDeclContext(namespaceDecl(
137-
anyOf(thrustFuncNameCuda129(),
138-
thrustFuncNameCudaCommon())))))))))
139-
.bind("thrustFuncCall"),
140-
this);
141-
} else {
142-
// For CUDA SDK versions before CUDA-12.4
143-
MF.addMatcher(
144-
callExpr(
145-
anyOf(callee(functionDecl(anyOf(
146-
hasDeclContext(namespaceDecl(thrustFuncNameCudaCommon())),
147-
148-
functionName()))),
149-
callee(unresolvedLookupExpr(
150-
hasAnyDeclaration(namedDecl(hasDeclContext(
151-
namespaceDecl(thrustFuncNameCudaCommon()))))))))
152-
.bind("thrustFuncCall"),
153-
this);
154-
}
28+
auto thrustFuncName = [&]() {
29+
#define COMMON "thrust", "thrust::detail", "thrust::system", "__4"
30+
if (ThrustMajorVersion == 2 && ThrustMinorVersion == 3)
31+
return hasAnyName("THRUST_200302___CUDA_ARCH_LIST___NS",
32+
"THRUST_200302___CUDA_ARCH_LIST___NS::detail",
33+
"THRUST_200302___CUDA_ARCH_LIST___NS::system", COMMON);
34+
if (ThrustMajorVersion == 2 && ThrustMinorVersion == 4)
35+
return hasAnyName("THRUST_200400___CUDA_ARCH_LIST___NS",
36+
"THRUST_200400___CUDA_ARCH_LIST___NS::detail",
37+
"THRUST_200400___CUDA_ARCH_LIST___NS::system", COMMON);
38+
if (ThrustMajorVersion == 2 && ThrustMinorVersion == 5)
39+
return hasAnyName("THRUST_200500___CUDA_ARCH_LIST___NS",
40+
"THRUST_200500___CUDA_ARCH_LIST___NS::detail",
41+
"THRUST_200500___CUDA_ARCH_LIST___NS::system", COMMON);
42+
if (ThrustMajorVersion == 2 && ThrustMinorVersion == 7)
43+
return hasAnyName("THRUST_200700___CUDA_ARCH_LIST___NS",
44+
"THRUST_200700___CUDA_ARCH_LIST___NS::detail",
45+
"THRUST_200700___CUDA_ARCH_LIST___NS::system", COMMON);
46+
if (ThrustMajorVersion == 2 && ThrustMinorVersion == 8)
47+
return hasAnyName("THRUST_200802_SM___CUDA_ARCH_LIST___NS",
48+
"THRUST_200802_SM___CUDA_ARCH_LIST___NS::detail",
49+
"THRUST_200802_SM___CUDA_ARCH_LIST___NS::system",
50+
COMMON);
51+
return hasAnyName(COMMON);
52+
#undef COMMON
53+
};
54+
55+
MF.addMatcher(
56+
callExpr(anyOf(callee(functionDecl(
57+
anyOf(hasDeclContext(namespaceDecl(thrustFuncName())),
58+
functionName()))),
59+
callee(unresolvedLookupExpr(hasAnyDeclaration(namedDecl(
60+
hasDeclContext(namespaceDecl(thrustFuncName()))))))))
61+
.bind("thrustFuncCall"),
62+
this);
15563

15664
// THRUST_STATIC_ASSERT macro register
15765
MF.addMatcher(staticAssertDecl(isExpandedFromMacro("THRUST_STATIC_ASSERT"))

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ bool CudaInstallationDetector::ParseCudaVersionFile(const std::string &FilePath)
203203
Version = CudaVersion::CUDA_129;
204204
}
205205

206-
207206
if (Version != CudaVersion::UNKNOWN) {
208207
IsVersionSupported = true;
209208
return true;
@@ -352,32 +351,10 @@ CudaInstallationDetector::CudaInstallationDetector(
352351

353352
// In decreasing order so we prefer newer versions to older versions.
354353
#ifdef SYCLomatic_CUSTOMIZATION
355-
std::initializer_list<const char *> Versions = {"12.9",
356-
"12.8",
357-
"12.6",
358-
"12.5",
359-
"12.4",
360-
"12.3",
361-
"12.2",
362-
"12.1",
363-
"12.0",
364-
"11.8",
365-
"11.7",
366-
"11.6",
367-
"11.5",
368-
"11.4",
369-
"11.3",
370-
"11.2",
371-
"11.1",
372-
"10.2",
373-
"10.1",
374-
"10.0",
375-
"9.2",
376-
"9.1",
377-
"9.0",
378-
"8.0",
379-
"7.5",
380-
"7.0"};
354+
std::initializer_list<const char *> Versions = {
355+
"12.9", "12.8", "12.6", "12.5", "12.4", "12.3", "12.2", "12.1", "12.0",
356+
"11.8", "11.7", "11.6", "11.5", "11.4", "11.3", "11.2", "11.1", "10.2",
357+
"10.1", "10.0", "9.2", "9.1", "9.0", "8.0", "7.5", "7.0"};
381358
#else
382359
std::initializer_list<const char *> Versions = {
383360
"11.4", "11.3", "11.2", "11.1", "10.2", "10.1", "10.0",

0 commit comments

Comments
 (0)