Skip to content

Commit 921d7b8

Browse files
committed
Reverse the macro meaning
1 parent f307803 commit 921d7b8

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

sycl/include/CL/sycl/backend.hpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ auto get_native(const SyclObjectT &Obj)
7474
return Obj.template get_native<BackendName>();
7575
}
7676

77-
#ifndef SYCL_GET_NATIVE_BACKEND_OPENCL_RETURN_T_CL_EVENT
77+
// define SYCL_GET_NATIVE_BACKEND_OPENCL_RETURN_T_VEC_CL_EVENT to correspond
78+
// SYCL 2020 spec and return vector<cl_event> from get_native instead of just cl_event
79+
#ifdef SYCL_GET_NATIVE_BACKEND_OPENCL_RETURN_T_VEC_CL_EVENT
7880
template <>
7981
inline backend_return_t<backend::opencl, event>
8082
get_native<backend::opencl, event>(const event &Obj) {
@@ -91,6 +93,23 @@ get_native<backend::opencl, event>(const event &Obj) {
9193
}
9294
return ReturnValue;
9395
}
96+
#else
97+
// Specialization for cl_event with deprecation message
98+
template <>
99+
__SYCL_DEPRECATED("get_native<backend::opencl, event>, which only returns "
100+
"cl_event is deprecated. "
101+
"According to SYCL 2020 spec, please define "
102+
"SYCL_GET_NATIVE_BACKEND_OPENCL_RETURN_T_VEC_CL_EVENT and "
103+
"use vector<cl_event> instead.")
104+
inline backend_return_t<backend::opencl, event> get_native<
105+
backend::opencl, event>(const event &Obj) {
106+
// TODO use SYCL 2020 exception when implemented
107+
if (Obj.get_backend() != backend::opencl) {
108+
throw runtime_error("Backends mismatch", PI_INVALID_OPERATION);
109+
}
110+
return reinterpret_cast<
111+
typename detail::interop<backend::opencl, event>::type>(Obj.getNative());
112+
}
94113
#endif
95114

96115
// Native handle of an accessor should be accessed through interop_handler

sycl/include/CL/sycl/detail/backend_traits_opencl.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,7 @@ template <> struct BackendReturn<backend::opencl, device> {
104104
using type = cl_device_id;
105105
};
106106

107-
#ifdef SYCL_GET_NATIVE_BACKEND_OPENCL_RETURN_T_CL_EVENT
108-
template <> struct interop<backend::opencl, event> { using type = cl_event; };
109-
template <> struct BackendInput<backend::opencl, event> {
110-
using type = cl_event;
111-
};
112-
template <> struct BackendReturn<backend::opencl, event> {
113-
using type = cl_event;
114-
};
115-
#else
107+
#ifdef SYCL_GET_NATIVE_BACKEND_OPENCL_RETURN_T_VEC_CL_EVENT
116108
template <> struct interop<backend::opencl, event> {
117109
using type = std::vector<cl_event>;
118110
using value_type = cl_event;
@@ -125,6 +117,14 @@ template <> struct BackendReturn<backend::opencl, event> {
125117
using type = std::vector<cl_event>;
126118
using value_type = cl_event;
127119
};
120+
#else
121+
template <> struct interop<backend::opencl, event> { using type = cl_event; };
122+
template <> struct BackendInput<backend::opencl, event> {
123+
using type = cl_event;
124+
};
125+
template <> struct BackendReturn<backend::opencl, event> {
126+
using type = cl_event;
127+
};
128128
#endif
129129

130130
template <> struct BackendInput<backend::opencl, queue> {

sycl/test/regression/check_vector_of_opencl_event.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -DSYCL_GET_NATIVE_BACKEND_OPENCL_RETURN_T_VEC_CL_EVENT %s
22
// expected-no-diagnostics
33
//
44
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)