Skip to content

Commit 21a1e11

Browse files
committed
[SYCL] Only specialize templates with available backend traits
1 parent a822600 commit 21a1e11

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sycl/include/sycl/backend.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ struct BufferInterop<backend::opencl, DataT, Dimensions, AllocatorT> {
101101
}
102102
};
103103

104+
#if SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
104105
template <backend BackendName, typename DataT, int Dimensions,
105106
typename AllocatorT>
106107
auto get_native_buffer(const buffer<DataT, Dimensions, AllocatorT, void> &Obj)
@@ -115,6 +116,7 @@ auto get_native_buffer(const buffer<DataT, Dimensions, AllocatorT, void> &Obj)
115116
PI_ERROR_INVALID_OPERATION);
116117
return Obj.template getNative<BackendName>();
117118
}
119+
#endif
118120
} // namespace detail
119121

120122
template <backend BackendName, class SyclObjectT>
@@ -147,6 +149,7 @@ auto get_native(const buffer<DataT, Dimensions, AllocatorT> &Obj)
147149
return detail::get_native_buffer<BackendName>(Obj);
148150
}
149151

152+
#if SYCL_BACKEND_OPENCL
150153
template <>
151154
inline backend_return_t<backend::opencl, event>
152155
get_native<backend::opencl, event>(const event &Obj) {
@@ -164,7 +167,9 @@ get_native<backend::opencl, event>(const event &Obj) {
164167
}
165168
return ReturnValue;
166169
}
170+
#endif
167171

172+
#if SYCL_EXT_ONEAPI_BACKEND_CUDA
168173
template <>
169174
inline backend_return_t<backend::ext_oneapi_cuda, device>
170175
get_native<backend::ext_oneapi_cuda, device>(const device &Obj) {
@@ -178,6 +183,7 @@ get_native<backend::ext_oneapi_cuda, device>(const device &Obj) {
178183
return static_cast<backend_return_t<backend::ext_oneapi_cuda, device>>(
179184
Obj.getNative());
180185
}
186+
#endif
181187

182188
// Native handle of an accessor should be accessed through interop_handler
183189
template <backend BackendName, typename DataT, int Dimensions,

0 commit comments

Comments
 (0)