|
20 | 20 | #include <CL/sycl/stl.hpp>
|
21 | 21 |
|
22 | 22 | #include <cstring>
|
| 23 | +#include <memory> |
23 | 24 | #include <type_traits>
|
24 | 25 |
|
25 | 26 | __SYCL_INLINE_NAMESPACE(cl) {
|
@@ -51,7 +52,13 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI {
|
51 | 52 |
|
52 | 53 | template <typename T>
|
53 | 54 | using EnableIfOutputIteratorT = enable_if_t<
|
54 |
| - /*is_output_iterator<T>::value &&*/ !std::is_pointer<T>::value>; |
| 55 | + /*is_output_iterator<T>::value &&*/ !std::is_pointer<T>::value && |
| 56 | + !std::is_same<typename T::value_type, bool>::value>; |
| 57 | + |
| 58 | + template <typename T> |
| 59 | + using EnableIfOutputIteratorBool = |
| 60 | + enable_if_t<!std::is_pointer<T>::value && |
| 61 | + std::is_same<typename T::value_type, bool>::value>; |
55 | 62 |
|
56 | 63 | template <typename T>
|
57 | 64 | using EnableIfDefaultAllocator =
|
@@ -184,6 +191,22 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI {
|
184 | 191 | };
|
185 | 192 | }
|
186 | 193 |
|
| 194 | + template <typename Destination> |
| 195 | + __SYCL_DLL_LOCAL EnableIfOutputIteratorBool<Destination> |
| 196 | + set_final_data(Destination FinalData) { |
| 197 | + MUploadDataFunctor = [this, FinalData]() { |
| 198 | + using DestinationValueT = iterator_value_type_t<Destination>; |
| 199 | + // TODO if Destination is ContiguousIterator then don't create |
| 200 | + // ContiguousStorage. updateHostMemory works only with pointer to |
| 201 | + // continuous data. |
| 202 | + const size_t Size = MSizeInBytes / sizeof(DestinationValueT); |
| 203 | + std::unique_ptr<bool[]> ContiguousStorage(new bool[Size]); |
| 204 | + updateHostMemory(ContiguousStorage.get()); |
| 205 | + std::copy(ContiguousStorage.get(), ContiguousStorage.get() + Size, |
| 206 | + FinalData); |
| 207 | + }; |
| 208 | + } |
| 209 | + |
187 | 210 | protected:
|
188 | 211 | void updateHostMemory(void *const Ptr);
|
189 | 212 |
|
|
0 commit comments