@@ -351,6 +351,32 @@ class buffer {
351
351
impl, reinterpretRange, OffsetInBytes, IsSubBuffer);
352
352
}
353
353
354
+ template <typename ReinterpretT, int ReinterpretDim = dimensions>
355
+ typename std::enable_if<
356
+ (sizeof (ReinterpretT) == sizeof (T)) && (dimensions == ReinterpretDim),
357
+ buffer<ReinterpretT, ReinterpretDim, AllocatorT>>::type
358
+ reinterpret () const {
359
+ return buffer<ReinterpretT, ReinterpretDim, AllocatorT>(
360
+ impl, get_range (), OffsetInBytes, IsSubBuffer);
361
+ }
362
+
363
+ template <typename ReinterpretT, int ReinterpretDim = dimensions>
364
+ typename std::enable_if<
365
+ (ReinterpretDim == 1 ) && ((dimensions != ReinterpretDim) ||
366
+ (sizeof (ReinterpretT) != sizeof (T))),
367
+ buffer<ReinterpretT, ReinterpretDim, AllocatorT>>::type
368
+ reinterpret () const {
369
+ long sz = get_size (); // TODO: switch to byte_size() once implemented
370
+ if (sz % sizeof (ReinterpretT) != 0 )
371
+ throw cl::sycl::invalid_object_error (
372
+ " Total byte size of buffer is not evenly divisible by the size of "
373
+ " the reinterpreted type" ,
374
+ PI_INVALID_VALUE);
375
+
376
+ return buffer<ReinterpretT, ReinterpretDim, AllocatorT>(
377
+ impl, range<1 >{sz / sizeof (ReinterpretT)}, OffsetInBytes, IsSubBuffer);
378
+ }
379
+
354
380
template <typename propertyT> bool has_property () const {
355
381
return impl->template has_property <propertyT>();
356
382
}
0 commit comments