diff --git a/sycl/doc/EnvironmentVariables.md b/sycl/doc/EnvironmentVariables.md index 13d98fa6be51e..a5eb55b8a12e1 100755 --- a/sycl/doc/EnvironmentVariables.md +++ b/sycl/doc/EnvironmentVariables.md @@ -111,6 +111,7 @@ variables in production code. | `SYCL_HOST_UNIFIED_MEMORY` | Integer | Enforce host unified memory support or lack of it for the execution graph builder. If set to 0, it is enforced as not supported by all devices. If set to 1, it is enforced as supported by all devices. | | `SYCL_CACHE_TRACE` | Any(\*) | If the variable is set, messages are sent to std::cerr when caching events or non-blocking failures happen (e.g. unable to access cache item file). | | `SYCL_PARALLEL_FOR_RANGE_ROUNDING_TRACE` | Any(\*) | Enables tracing of `parallel_for` invocations with rounded-up ranges. | +| `SYCL_PI_SUPPRESS_ERROR_MESSAGE` | Any(\*) | Suppress printing of error message, only used for CI in order not to interrupt errors generated by underlying toolchains; note that the variable only modifies the printing of the error message (error value, name, description and location), the handling of error return code and aborting/throwing behaviour remains unchanged. | `(*) Note: Any means this environment variable is effective when set to any non-null value.` diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index 90f703477705a..c522a24ff0281 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -133,17 +133,21 @@ pi_result check_error(CUresult result, const char *function, int line, return PI_SUCCESS; } - const char *errorString = nullptr; - const char *errorName = nullptr; - cuGetErrorName(result, &errorName); - cuGetErrorString(result, &errorString); - std::cerr << "\nPI CUDA ERROR:" - << "\n\tValue: " << result - << "\n\tName: " << errorName - << "\n\tDescription: " << errorString - << "\n\tFunction: " << function - << "\n\tSource Location: " << file << ":" << line << "\n" - << std::endl; + if (std::getenv("SYCL_PI_SUPPRESS_ERROR_MESSAGE") == nullptr) { + const char *errorString = nullptr; + const char *errorName = nullptr; + cuGetErrorName(result, &errorName); + cuGetErrorString(result, &errorString); + std::stringstream ss; + ss << "\nPI CUDA ERROR:" + << "\n\tValue: " << result + << "\n\tName: " << errorName + << "\n\tDescription: " << errorString + << "\n\tFunction: " << function << "\n\tSource Location: " << file + << ":" << line << "\n" + << std::endl; + std::cerr << ss.str(); + } if (std::getenv("PI_CUDA_ABORT") != nullptr) { std::abort(); diff --git a/sycl/plugins/hip/pi_hip.cpp b/sycl/plugins/hip/pi_hip.cpp index 01d76ac0702e3..4262f21f3eb22 100644 --- a/sycl/plugins/hip/pi_hip.cpp +++ b/sycl/plugins/hip/pi_hip.cpp @@ -189,17 +189,21 @@ pi_result check_error(hipError_t result, const char *function, int line, return PI_SUCCESS; } - const char *errorString = nullptr; - const char *errorName = nullptr; - errorName = hipGetErrorName(result); - errorString = hipGetErrorString(result); - std::cerr << "\nPI HIP ERROR:" - << "\n\tValue: " << result - << "\n\tName: " << errorName - << "\n\tDescription: " << errorString - << "\n\tFunction: " << function - << "\n\tSource Location: " << file << ":" << line << "\n" - << std::endl; + if (std::getenv("SYCL_PI_SUPPRESS_ERROR_MESSAGE") == nullptr) { + const char *errorString = nullptr; + const char *errorName = nullptr; + errorName = hipGetErrorName(result); + errorString = hipGetErrorString(result); + std::stringstream ss; + ss << "\nPI HIP ERROR:" + << "\n\tValue: " << result + << "\n\tName: " << errorName + << "\n\tDescription: " << errorString + << "\n\tFunction: " << function << "\n\tSource Location: " << file + << ":" << line << "\n" + << std::endl; + std::cerr << ss.str(); + } if (std::getenv("PI_HIP_ABORT") != nullptr) { std::abort();