Skip to content

[SYCL][CUDA] Make plugin specific error return an error #10626

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

Merged
merged 5 commits into from
Aug 2, 2023
Merged
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
8 changes: 5 additions & 3 deletions sycl/plugins/unified_runtime/pi2ur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,12 +928,14 @@ inline pi_result piPluginGetLastError(char **Message) {
// reference for the urAdapterGetLastError call, then release it.
ur_adapter_handle_t Adapter;
urAdapterGet(1, &Adapter, nullptr);
// FIXME: ErrorCode should store a native error, but these are not being used
// in CUDA adapter at the moment
int32_t ErrorCode;
urAdapterGetLastError(Adapter, const_cast<const char **>(Message),
&ErrorCode);
ur_result_t Res = urAdapterGetLastError(
Adapter, const_cast<const char **>(Message), &ErrorCode);
urAdapterRelease(Adapter);

return PI_SUCCESS;
return ur2piResult(Res);
}

inline pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
Expand Down
4 changes: 2 additions & 2 deletions sycl/plugins/unified_runtime/ur/adapters/cuda/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterRelease(ur_adapter_handle_t) {

UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetLastError(
ur_adapter_handle_t, const char **ppMessage, int32_t *pError) {
std::ignore = pError;
*ppMessage = ErrorMessage;
*pError = ErrorMessageCode;
return UR_RESULT_SUCCESS;
return ErrorMessageCode;
}

UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t,
Expand Down
30 changes: 30 additions & 0 deletions sycl/test-e2e/Plugin/cuda-max-local-mem-size.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// REQUIRES: cuda

// RUN: %{build} -o %t.out
// RUN: not %{run} SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE=0 %t.out 2>&1 | FileCheck --check-prefixes=CHECK-ZERO %s
// RUN: not %{run} SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE=100000000 %t.out 2>&1 | FileCheck --check-prefixes=CHECK-OVERALLOCATE %s

//==---------------------- cuda-max-local-mem-size.cpp --------------------===//
//==--- SYCL test to test SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE env var----------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include <sycl/sycl.hpp>

int main() {
sycl::queue Q{};
auto LocalSize =
Q.get_device().get_info<sycl::info::device::local_mem_size>();
Q.submit([&](sycl::handler &cgh) {
auto LocalAcc = sycl::local_accessor<float>(LocalSize + 1, cgh);
cgh.parallel_for(sycl::nd_range<1>{32, 32}, [=](sycl::nd_item<1> idx) {
LocalAcc[idx.get_global_linear_id()] *= 2;
});
}).wait();
// CHECK-ZERO: Local memory for kernel exceeds the amount requested using SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE
// CHECK-OVERALLOCATE: Too much local memory allocated for device
}