Skip to content

Commit ad82940

Browse files
callumfarefabiomestre
authored andcommitted
[SYCL][UR][CUDA] Mirror SYCL_PI env vars with UR prefix (#10045)
1 parent 2d5a79b commit ad82940

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

common.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ ur_result_t checkErrorUR(CUresult Result, const char *Function, int Line,
3939
return UR_RESULT_SUCCESS;
4040
}
4141

42-
if (std::getenv("SYCL_PI_SUPPRESS_ERROR_MESSAGE") == nullptr) {
42+
if (std::getenv("SYCL_PI_SUPPRESS_ERROR_MESSAGE") == nullptr &&
43+
std::getenv("UR_SUPPRESS_ERROR_MESSAGE") == nullptr) {
4344
const char *ErrorString = nullptr;
4445
const char *ErrorName = nullptr;
4546
cuGetErrorName(Result, &ErrorName);
@@ -55,7 +56,8 @@ ur_result_t checkErrorUR(CUresult Result, const char *Function, int Line,
5556
std::cerr << SS.str();
5657
}
5758

58-
if (std::getenv("PI_CUDA_ABORT") != nullptr) {
59+
if (std::getenv("PI_CUDA_ABORT") != nullptr ||
60+
std::getenv("UR_CUDA_ABORT") != nullptr) {
5961
std::abort();
6062
}
6163

@@ -68,7 +70,8 @@ ur_result_t checkErrorUR(ur_result_t Result, const char *Function, int Line,
6870
return UR_RESULT_SUCCESS;
6971
}
7072

71-
if (std::getenv("SYCL_PI_SUPPRESS_ERROR_MESSAGE") == nullptr) {
73+
if (std::getenv("SYCL_PI_SUPPRESS_ERROR_MESSAGE") == nullptr &&
74+
std::getenv("UR_SUPPRESS_ERROR_MESSAGE") == nullptr) {
7275
std::stringstream SS;
7376
SS << "\nUR ERROR:"
7477
<< "\n\tValue: " << Result

device.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
272272
case UR_DEVICE_INFO_IMAGE_SUPPORTED: {
273273
bool Enabled = false;
274274

275-
if (std::getenv("SYCL_PI_CUDA_ENABLE_IMAGE_SUPPORT") != nullptr) {
275+
if (std::getenv("SYCL_PI_CUDA_ENABLE_IMAGE_SUPPORT") != nullptr ||
276+
std::getenv("UR_CUDA_ENABLE_IMAGE_SUPPORT") != nullptr) {
276277
Enabled = true;
277278
} else {
278279
detail::ur::cuPrint(

device.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ struct ur_device_handle_t_ {
4545
cuDevice));
4646

4747
// Set local mem max size if env var is present
48-
static const char *LocalMemSizePtr =
48+
static const char *LocalMemSizePtrUR =
49+
std::getenv("UR_CUDA_MAX_LOCAL_MEM_SIZE");
50+
static const char *LocalMemSizePtrPI =
4951
std::getenv("SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE");
52+
static const char *LocalMemSizePtr =
53+
LocalMemSizePtrUR ? LocalMemSizePtrUR
54+
: (LocalMemSizePtrPI ? LocalMemSizePtrPI : nullptr);
5055

5156
if (LocalMemSizePtr) {
5257
cuDeviceGetAttribute(

enqueue.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
397397
// Set up local memory requirements for kernel.
398398
auto Device = hQueue->getContext()->getDevice();
399399
if (Device->getMaxChosenLocalMem() < 0) {
400-
setErrorMessage("Invalid value specified for "
401-
"SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE",
400+
bool EnvVarHasURPrefix =
401+
(std::getenv("UR_CUDA_MAX_LOCAL_MEM_SIZE") != nullptr);
402+
setErrorMessage(EnvVarHasURPrefix ? "Invalid value specified for "
403+
"UR_CUDA_MAX_LOCAL_MEM_SIZE"
404+
: "Invalid value specified for "
405+
"SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE",
402406
UR_RESULT_ERROR_ADAPTER_SPECIFIC);
403407
return UR_RESULT_ERROR_ADAPTER_SPECIFIC;
404408
}
@@ -408,10 +412,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
408412
return UR_RESULT_ERROR_ADAPTER_SPECIFIC;
409413
}
410414
if (LocalSize > static_cast<uint32_t>(Device->getMaxChosenLocalMem())) {
415+
bool EnvVarHasURPrefix =
416+
(std::getenv("UR_CUDA_MAX_LOCAL_MEM_SIZE") != nullptr);
411417
setErrorMessage(
412-
"Local memory for kernel exceeds the amount requested using "
413-
"SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE. Try increasing the value for "
414-
"SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE.",
418+
EnvVarHasURPrefix
419+
? "Local memory for kernel exceeds the amount requested using "
420+
"UR_CUDA_MAX_LOCAL_MEM_SIZE. Try increasing the value of "
421+
"UR_CUDA_MAX_LOCAL_MEM_SIZE."
422+
: "Local memory for kernel exceeds the amount requested using "
423+
"SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE. Try increasing the the "
424+
"value of SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE.",
415425
UR_RESULT_ERROR_ADAPTER_SPECIFIC);
416426
return UR_RESULT_ERROR_ADAPTER_SPECIFIC;
417427
}

0 commit comments

Comments
 (0)