Skip to content

Commit

Permalink
[SYCL] Use SYCL 2020 exception in ext/oneapi/experimental/cuda/* (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aelovikov-intel authored Jul 11, 2024
1 parent 7b79cc9 commit 49a1c42
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
47 changes: 23 additions & 24 deletions sycl/include/sycl/ext/oneapi/experimental/cuda/barrier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#pragma once

#include <CL/__spirv/spirv_ops.hpp> // for __clc_BarrierInitialize
#include <sycl/detail/pi.h> // for PI_ERROR_INVALID_DEVICE
#include <sycl/exception.hpp> // for runtime_error
#include <sycl/exception.hpp>

#include <stdint.h> // for int32_t, int64_t, uint32_t, uint64_t

Expand Down Expand Up @@ -41,35 +40,35 @@ class barrier {
#else
(void)state;
(void)expected_count;
throw runtime_error("Barrier is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"Barrier is not supported on host.");
#endif
}

void invalidate() {
#ifdef __SYCL_DEVICE_ONLY__
__clc_BarrierInvalidate(&state);
#else
throw runtime_error("Barrier is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"Barrier is not supported on host.");
#endif
}

arrival_token arrive() {
#ifdef __SYCL_DEVICE_ONLY__
return __clc_BarrierArrive(&state);
#else
throw runtime_error("Barrier is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"Barrier is not supported on host.");
#endif
}

arrival_token arrive_and_drop() {
#ifdef __SYCL_DEVICE_ONLY__
return __clc_BarrierArriveAndDrop(&state);
#else
throw runtime_error("Barrier is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"Barrier is not supported on host.");
#endif
}

Expand All @@ -78,8 +77,8 @@ class barrier {
return __clc_BarrierArriveNoComplete(&state, count);
#else
(void)count;
throw runtime_error("Barrier is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"Barrier is not supported on host.");
#endif
}

Expand All @@ -88,26 +87,26 @@ class barrier {
return __clc_BarrierArriveAndDropNoComplete(&state, count);
#else
(void)count;
throw runtime_error("Barrier is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"Barrier is not supported on host.");
#endif
}

void arrive_copy_async() {
#ifdef __SYCL_DEVICE_ONLY__
__clc_BarrierCopyAsyncArrive(&state);
#else
throw runtime_error("Barrier is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"Barrier is not supported on host.");
#endif
}

void arrive_copy_async_no_inc() {
#ifdef __SYCL_DEVICE_ONLY__
__clc_BarrierCopyAsyncArriveNoInc(&state);
#else
throw runtime_error("Barrier is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"Barrier is not supported on host.");
#endif
}

Expand All @@ -116,8 +115,8 @@ class barrier {
__clc_BarrierWait(&state, arrival);
#else
(void)arrival;
throw runtime_error("Barrier is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"Barrier is not supported on host.");
#endif
}

Expand All @@ -126,17 +125,17 @@ class barrier {
return __clc_BarrierTestWait(&state, arrival);
#else
(void)arrival;
throw runtime_error("Barrier is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"Barrier is not supported on host.");
#endif
}

void arrive_and_wait() {
#ifdef __SYCL_DEVICE_ONLY__
__clc_BarrierArriveAndWait(&state);
#else
throw runtime_error("Barrier is not supported on host device.",
PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"Barrier is not supported on host.");
#endif
}

Expand Down
3 changes: 2 additions & 1 deletion sycl/include/sycl/ext/oneapi/experimental/cuda/builtins.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ ldg(const T *ptr) {
return *ptr;
#endif
#else
throw runtime_error("ldg is not supported on host.", PI_ERROR_INVALID_DEVICE);
throw exception(make_error_code(errc::runtime),
"ldg is not supported on host.");
#endif
}

Expand Down

0 comments on commit 49a1c42

Please sign in to comment.