Skip to content

Commit b7a43a4

Browse files
hdelanHugh Delaney
andauthored
[SYCL][CUDA] Make plugin specific error return an error (#10626)
The `UR_RESULT_ADAPTER_SPECIFIC_ERROR` was not returning an error to the SYCL RT which meant all errors were treated as warnings and ignored unless `SYCL_RT_WARNING_LEVEL` is set to geq 2. This changes things so the adapter specific error is now reported as such, meaning all uses `UR_RESULT_ADAPTER_SPECIFIC_ERROR` meant as warnings are now caught as errors. --------- Co-authored-by: Hugh Delaney <[email protected]>
1 parent 5d28c93 commit b7a43a4

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

sycl/plugins/unified_runtime/pi2ur.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,12 +932,14 @@ inline pi_result piPluginGetLastError(char **Message) {
932932
// reference for the urAdapterGetLastError call, then release it.
933933
ur_adapter_handle_t Adapter;
934934
urAdapterGet(1, &Adapter, nullptr);
935+
// FIXME: ErrorCode should store a native error, but these are not being used
936+
// in CUDA adapter at the moment
935937
int32_t ErrorCode;
936-
urAdapterGetLastError(Adapter, const_cast<const char **>(Message),
937-
&ErrorCode);
938+
ur_result_t Res = urAdapterGetLastError(
939+
Adapter, const_cast<const char **>(Message), &ErrorCode);
938940
urAdapterRelease(Adapter);
939941

940-
return PI_SUCCESS;
942+
return ur2piResult(Res);
941943
}
942944

943945
inline pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,

sycl/plugins/unified_runtime/ur/adapters/cuda/adapter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterRelease(ur_adapter_handle_t) {
6464

6565
UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetLastError(
6666
ur_adapter_handle_t, const char **ppMessage, int32_t *pError) {
67+
std::ignore = pError;
6768
*ppMessage = ErrorMessage;
68-
*pError = ErrorMessageCode;
69-
return UR_RESULT_SUCCESS;
69+
return ErrorMessageCode;
7070
}
7171

7272
UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// REQUIRES: cuda
2+
3+
// RUN: %{build} -o %t.out
4+
// RUN: not %{run} SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE=0 %t.out 2>&1 | FileCheck --check-prefixes=CHECK-ZERO %s
5+
// RUN: not %{run} SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE=100000000 %t.out 2>&1 | FileCheck --check-prefixes=CHECK-OVERALLOCATE %s
6+
7+
//==---------------------- cuda-max-local-mem-size.cpp --------------------===//
8+
//==--- SYCL test to test SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE env var----------===//
9+
//
10+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
11+
// See https://llvm.org/LICENSE.txt for license information.
12+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
13+
//
14+
//===----------------------------------------------------------------------===//
15+
16+
#include <sycl/sycl.hpp>
17+
18+
int main() {
19+
sycl::queue Q{};
20+
auto LocalSize =
21+
Q.get_device().get_info<sycl::info::device::local_mem_size>();
22+
Q.submit([&](sycl::handler &cgh) {
23+
auto LocalAcc = sycl::local_accessor<float>(LocalSize + 1, cgh);
24+
cgh.parallel_for(sycl::nd_range<1>{32, 32}, [=](sycl::nd_item<1> idx) {
25+
LocalAcc[idx.get_global_linear_id()] *= 2;
26+
});
27+
}).wait();
28+
// CHECK-ZERO: Local memory for kernel exceeds the amount requested using SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE
29+
// CHECK-OVERALLOCATE: Too much local memory allocated for device
30+
}

0 commit comments

Comments
 (0)