@@ -114,10 +114,8 @@ auto get_native_buffer(const buffer<DataT, Dimensions, AllocatorT, void> &Obj)
114
114
// No check for backend mismatch because buffer can be allocated on different
115
115
// backends
116
116
if (BackendName == backend::ext_oneapi_level_zero)
117
- throw sycl::runtime_error (
118
- errc::feature_not_supported,
119
- " Buffer interop is not supported by level zero yet" ,
120
- PI_ERROR_INVALID_OPERATION);
117
+ throw sycl::exception (make_error_code (errc::feature_not_supported),
118
+ " Buffer interop is not supported by level zero yet" );
121
119
return Obj.template getNative <BackendName>();
122
120
}
123
121
#endif
@@ -126,21 +124,19 @@ auto get_native_buffer(const buffer<DataT, Dimensions, AllocatorT, void> &Obj)
126
124
template <backend BackendName, class SyclObjectT >
127
125
auto get_native (const SyclObjectT &Obj)
128
126
-> backend_return_t <BackendName, SyclObjectT> {
129
- // TODO use SYCL 2020 exception when implemented
130
127
if (Obj.get_backend () != BackendName) {
131
- throw sycl::runtime_error ( errc::backend_mismatch, " Backends mismatch " ,
132
- PI_ERROR_INVALID_OPERATION );
128
+ throw sycl::exception ( make_error_code ( errc::backend_mismatch) ,
129
+ " Backends mismatch " );
133
130
}
134
131
return reinterpret_cast <backend_return_t <BackendName, SyclObjectT>>(
135
132
Obj.getNative ());
136
133
}
137
134
138
135
template <backend BackendName>
139
136
auto get_native (const queue &Obj) -> backend_return_t <BackendName, queue> {
140
- // TODO use SYCL 2020 exception when implemented
141
137
if (Obj.get_backend () != BackendName) {
142
- throw sycl::runtime_error ( errc::backend_mismatch, " Backends mismatch " ,
143
- PI_ERROR_INVALID_OPERATION );
138
+ throw sycl::exception ( make_error_code ( errc::backend_mismatch) ,
139
+ " Backends mismatch " );
144
140
}
145
141
int32_t IsImmCmdList;
146
142
pi_native_handle Handle = Obj.getNative (IsImmCmdList);
@@ -160,10 +156,9 @@ auto get_native(const queue &Obj) -> backend_return_t<BackendName, queue> {
160
156
template <backend BackendName, bundle_state State>
161
157
auto get_native (const kernel_bundle<State> &Obj)
162
158
-> backend_return_t <BackendName, kernel_bundle<State>> {
163
- // TODO use SYCL 2020 exception when implemented
164
159
if (Obj.get_backend () != BackendName) {
165
- throw sycl::runtime_error ( errc::backend_mismatch, " Backends mismatch " ,
166
- PI_ERROR_INVALID_OPERATION );
160
+ throw sycl::exception ( make_error_code ( errc::backend_mismatch) ,
161
+ " Backends mismatch " );
167
162
}
168
163
return Obj.template getNative <BackendName>();
169
164
}
@@ -179,10 +174,9 @@ auto get_native(const buffer<DataT, Dimensions, AllocatorT> &Obj)
179
174
template <>
180
175
inline backend_return_t <backend::opencl, event>
181
176
get_native<backend::opencl, event>(const event &Obj) {
182
- // TODO use SYCL 2020 exception when implemented
183
177
if (Obj.get_backend () != backend::opencl) {
184
- throw sycl::runtime_error ( errc::backend_mismatch, " Backends mismatch " ,
185
- PI_ERROR_INVALID_OPERATION );
178
+ throw sycl::exception ( make_error_code ( errc::backend_mismatch) ,
179
+ " Backends mismatch " );
186
180
}
187
181
backend_return_t <backend::opencl, event> ReturnValue;
188
182
for (auto const &element : Obj.getNativeVector ()) {
@@ -199,10 +193,9 @@ get_native<backend::opencl, event>(const event &Obj) {
199
193
template <>
200
194
inline backend_return_t <backend::ext_oneapi_cuda, device>
201
195
get_native<backend::ext_oneapi_cuda, device>(const device &Obj) {
202
- // TODO use SYCL 2020 exception when implemented
203
196
if (Obj.get_backend () != backend::ext_oneapi_cuda) {
204
- throw sycl::runtime_error ( errc::backend_mismatch, " Backends mismatch " ,
205
- PI_ERROR_INVALID_OPERATION );
197
+ throw sycl::exception ( make_error_code ( errc::backend_mismatch) ,
198
+ " Backends mismatch " );
206
199
}
207
200
// CUDA uses a 32-bit int instead of an opaque pointer like other backends,
208
201
// so we need a specialization with static_cast instead of reinterpret_cast.
0 commit comments