@@ -71,10 +71,46 @@ auto get_native(const SyclObjectT &Obj)
71
71
if (Obj.get_backend () != BackendName) {
72
72
throw runtime_error (" Backends mismatch" , PI_INVALID_OPERATION);
73
73
}
74
-
75
74
return Obj.template get_native <BackendName>();
76
75
}
77
76
77
+ // define SYCL2020_CONFORMANT_APIS to correspond SYCL 2020 spec and return
78
+ // vector<cl_event> from get_native instead of just cl_event
79
+ #ifdef SYCL2020_CONFORMANT_APIS
80
+ template <>
81
+ inline backend_return_t <backend::opencl, event>
82
+ get_native<backend::opencl, event>(const event &Obj) {
83
+ // TODO use SYCL 2020 exception when implemented
84
+ if (Obj.get_backend () != backend::opencl) {
85
+ throw runtime_error (" Backends mismatch" , PI_INVALID_OPERATION);
86
+ }
87
+ backend_return_t <backend::opencl, event> ReturnValue;
88
+ for (auto const &element : Obj.getNativeVector ()) {
89
+ ReturnValue.push_back (
90
+ reinterpret_cast <
91
+ typename detail::interop<backend::opencl, event>::value_type>(
92
+ element));
93
+ }
94
+ return ReturnValue;
95
+ }
96
+ #else
97
+ // Specialization for cl_event with deprecation message
98
+ template <>
99
+ __SYCL_DEPRECATED (
100
+ " get_native<backend::opencl, event>, which return type is "
101
+ " cl_event is deprecated. According to SYCL 2020 spec, please define "
102
+ " SYCL2020_CONFORMANT_APIS and use vector<cl_event> instead." )
103
+ inline backend_return_t<backend::opencl, event> get_native<
104
+ backend::opencl, event>(const event &Obj) {
105
+ // TODO use SYCL 2020 exception when implemented
106
+ if (Obj.get_backend () != backend::opencl) {
107
+ throw runtime_error (" Backends mismatch" , PI_INVALID_OPERATION);
108
+ }
109
+ return reinterpret_cast <
110
+ typename detail::interop<backend::opencl, event>::type>(Obj.getNative ());
111
+ }
112
+ #endif
113
+
78
114
// Native handle of an accessor should be accessed through interop_handler
79
115
template <backend BackendName, typename DataT, int Dimensions,
80
116
access::mode AccessMode, access::target AccessTarget,
0 commit comments