Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCLomatic] Add support for cuGetErrorName #2618

Open
wants to merge 4 commits into
base: SYCLomatic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions clang/lib/DPCT/RulesLang/APINamesDriver.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ WARNING_FACTORY_ENTRY(
CALL(MapNames::getDpctNamespace() + "get_error_string_dummy", ARG_WC(0)))),
Diagnostics::ERROR_HANDLING_API_REPLACED_BY_DUMMY)

WARNING_FACTORY_ENTRY(
"cuGetErrorName",
ASSIGNABLE_FACTORY(
ASSIGN_FACTORY_ENTRY("cuGetErrorName", DEREF(1),
CALL(MapNames::getDpctNamespace() + "get_error_string_dummy", ARG_WC(0)))),
Diagnostics::ERROR_HANDLING_API_REPLACED_BY_DUMMY)

FEATURE_REQUEST_FACTORY(
HelperFeatureEnum::device_ext,
ASSIGNABLE_FACTORY(ASSIGN_FACTORY_ENTRY(
Expand Down
9 changes: 5 additions & 4 deletions clang/lib/DPCT/RulesLang/RulesLang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8198,10 +8198,11 @@ void DriverModuleAPIRule::runRule(
void DriverDeviceAPIRule::registerMatcher(ast_matchers::MatchFinder &MF) {

auto DriverDeviceAPI = [&]() {
return hasAnyName(
"cuDeviceGet", "cuDeviceComputeCapability", "cuDriverGetVersion",
"cuDeviceGetCount", "cuDeviceGetAttribute", "cuDeviceGetName",
"cuDeviceGetUuid", "cuDeviceGetUuid_v2", "cuGetErrorString");
return hasAnyName("cuDeviceGet", "cuDeviceComputeCapability",
"cuDriverGetVersion", "cuDeviceGetCount",
"cuDeviceGetAttribute", "cuDeviceGetName",
"cuDeviceGetUuid", "cuDeviceGetUuid_v2",
"cuGetErrorString", "cuGetErrorName");
};

MF.addMatcher(
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/DPCT/SrcAPI/APINames.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ ENTRY(__match_any_sync, __match_any_sync, true, NO_FLAG, P4, "comment")
ENTRY(__match_all_sync, __match_all_sync, true, NO_FLAG, P4, "comment")

// Error Handling
ENTRY(cuGetErrorName, cuGetErrorName, false, NO_FLAG, P4, "comment")
ENTRY(cuGetErrorName, cuGetErrorName, true, NO_FLAG, P4, "Successful")
ENTRY(cuGetErrorString, cuGetErrorString, true, NO_FLAG, P4, "comment")

// Initialization
Expand Down
12 changes: 12 additions & 0 deletions clang/test/dpct/cuda-get-error-string.cu
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ const char *test_function() {
//CHECK-NEXT: err_s = dpct::get_error_string_dummy(e);
cuGetErrorString(e, &err_s);

//CHECK: /*
//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.
//CHECK-NEXT: */
//CHECK-NEXT: err_s = dpct::get_error_string_dummy(e);
cuGetErrorName(e, &err_s);

//CHECK: /*
//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.
//CHECK-NEXT: */
//CHECK-NEXT: err_s = dpct::get_error_string_dummy({{[0-9]+}});
cuGetErrorName(CUDA_ERROR_OUT_OF_MEMORY, &err_s);

//CHECK:/*
//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.
//CHECK-NEXT:*/
Expand Down