Skip to content

Commit 7e3c146

Browse files
author
Deepak Raj H R
authored
[SYCLomatic] Support migration for cuGetErrorName API (#2618)
1 parent 44fac3d commit 7e3c146

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

clang/lib/DPCT/RulesLang/APINamesDriver.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ WARNING_FACTORY_ENTRY(
1515
CALL(MapNames::getDpctNamespace() + "get_error_string_dummy", ARG_WC(0)))),
1616
Diagnostics::ERROR_HANDLING_API_REPLACED_BY_DUMMY)
1717

18+
WARNING_FACTORY_ENTRY(
19+
"cuGetErrorName",
20+
ASSIGNABLE_FACTORY(
21+
ASSIGN_FACTORY_ENTRY("cuGetErrorName", DEREF(1),
22+
CALL(MapNames::getDpctNamespace() + "get_error_string_dummy", ARG_WC(0)))),
23+
Diagnostics::ERROR_HANDLING_API_REPLACED_BY_DUMMY)
24+
1825
FEATURE_REQUEST_FACTORY(
1926
HelperFeatureEnum::device_ext,
2027
ASSIGNABLE_FACTORY(ASSIGN_FACTORY_ENTRY(

clang/lib/DPCT/RulesLang/RulesLang.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8199,10 +8199,11 @@ void DriverModuleAPIRule::runRule(
81998199
void DriverDeviceAPIRule::registerMatcher(ast_matchers::MatchFinder &MF) {
82008200

82018201
auto DriverDeviceAPI = [&]() {
8202-
return hasAnyName(
8203-
"cuDeviceGet", "cuDeviceComputeCapability", "cuDriverGetVersion",
8204-
"cuDeviceGetCount", "cuDeviceGetAttribute", "cuDeviceGetName",
8205-
"cuDeviceGetUuid", "cuDeviceGetUuid_v2", "cuGetErrorString");
8202+
return hasAnyName("cuDeviceGet", "cuDeviceComputeCapability",
8203+
"cuDriverGetVersion", "cuDeviceGetCount",
8204+
"cuDeviceGetAttribute", "cuDeviceGetName",
8205+
"cuDeviceGetUuid", "cuDeviceGetUuid_v2",
8206+
"cuGetErrorString", "cuGetErrorName");
82068207
};
82078208

82088209
MF.addMatcher(

clang/lib/DPCT/SrcAPI/APINames.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ ENTRY(__match_any_sync, __match_any_sync, true, NO_FLAG, P4, "comment")
15361536
ENTRY(__match_all_sync, __match_all_sync, true, NO_FLAG, P4, "comment")
15371537

15381538
// Error Handling
1539-
ENTRY(cuGetErrorName, cuGetErrorName, false, NO_FLAG, P4, "comment")
1539+
ENTRY(cuGetErrorName, cuGetErrorName, true, NO_FLAG, P4, "Successful")
15401540
ENTRY(cuGetErrorString, cuGetErrorString, true, NO_FLAG, P4, "comment")
15411541

15421542
// Initialization

clang/test/dpct/cuda-get-error-string.cu

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ const char *test_function() {
137137
//CHECK-NEXT: err_s = dpct::get_error_string_dummy(e);
138138
cuGetErrorString(e, &err_s);
139139

140+
//CHECK: /*
141+
//CHECK-NEXT: DPCT1009:{{[0-9]+}}: SYCL reports errors using exceptions and does not use error codes. Please replace the "get_error_string_dummy(...)" with a real error-handling function.
142+
//CHECK-NEXT: */
143+
//CHECK-NEXT: err_s = dpct::get_error_string_dummy(e);
144+
cuGetErrorName(e, &err_s);
145+
146+
//CHECK: /*
147+
//CHECK-NEXT: DPCT1009:{{[0-9]+}}: SYCL reports errors using exceptions and does not use error codes. Please replace the "get_error_string_dummy(...)" with a real error-handling function.
148+
//CHECK-NEXT: */
149+
//CHECK-NEXT: err_s = dpct::get_error_string_dummy({{[0-9]+}});
150+
cuGetErrorName(CUDA_ERROR_OUT_OF_MEMORY, &err_s);
151+
140152
//CHECK:/*
141153
//CHECK-NEXT:DPCT1009:{{[0-9]+}}: SYCL reports errors using exceptions and does not use error codes. Please replace the "get_error_string_dummy(...)" with a real error-handling function.
142154
//CHECK-NEXT:*/

0 commit comments

Comments
 (0)