Revert to normal vector without allocators

Prohibit vector type in indices
This commit is contained in:
Tom Lin 2022-07-29 00:17:36 +01:00
parent ed6206b543
commit 72335f320e
7 changed files with 31 additions and 31 deletions

View File

@ -23,11 +23,6 @@ const static auto exe_policy = oneapi::dpl::execution::device_policy<>{
oneapi::dpl::execution::make_device_policy(cl::sycl::default_selector{}) oneapi::dpl::execution::make_device_policy(cl::sycl::default_selector{})
}; };
template<typename T> using Allocator = sycl::usm_allocator<T, sycl::usm::alloc::shared>;
template<class T>
constexpr Allocator<T> alloc_vec() { return {exe_policy.queue()}; };
template<typename T> template<typename T>
T *alloc_raw(size_t size) { return sycl::malloc_shared<T>(size, exe_policy.queue()); } T *alloc_raw(size_t size) { return sycl::malloc_shared<T>(size, exe_policy.queue()); }
@ -61,11 +56,6 @@ static constexpr auto exe_policy = std::execution::par_unseq;
#ifdef USE_STD_PTR_ALLOC_DEALLOC #ifdef USE_STD_PTR_ALLOC_DEALLOC
template<typename T> using Allocator = std::allocator<T>;
template<class T>
constexpr Allocator<T> alloc_vec() { return {}; };
template<typename T> template<typename T>
T *alloc_raw(size_t size) { return (T *) aligned_alloc(ALIGNMENT, sizeof(T) * size); } T *alloc_raw(size_t size) { return (T *) aligned_alloc(ALIGNMENT, sizeof(T) * size); }

View File

@ -18,7 +18,7 @@ template <class T>
STDDataStream<T>::STDDataStream(const int ARRAY_SIZE, int device) STDDataStream<T>::STDDataStream(const int ARRAY_SIZE, int device)
noexcept : array_size{ARRAY_SIZE}, noexcept : array_size{ARRAY_SIZE},
#ifdef USE_VECTOR #ifdef USE_VECTOR
a(ARRAY_SIZE, alloc_vec<T>()), b(ARRAY_SIZE, alloc_vec<T>()), c(ARRAY_SIZE, alloc_vec<T>()) a(ARRAY_SIZE), b(ARRAY_SIZE), c(ARRAY_SIZE)
#else #else
a(alloc_raw<T>(ARRAY_SIZE)), b(alloc_raw<T>(ARRAY_SIZE)), c(alloc_raw<T>(ARRAY_SIZE)) a(alloc_raw<T>(ARRAY_SIZE)), b(alloc_raw<T>(ARRAY_SIZE)), c(alloc_raw<T>(ARRAY_SIZE))
#endif #endif

View File

@ -23,7 +23,7 @@ class STDDataStream : public Stream<T>
// Device side pointers // Device side pointers
#ifdef USE_VECTOR #ifdef USE_VECTOR
std::vector<T, Allocator<T>> a, b, c; std::vector<T> a, b, c;
#else #else
T *a, *b, *c; T *a, *b, *c;
#endif #endif

View File

@ -22,11 +22,21 @@
#define END(x) ((x) + array_size) #define END(x) ((x) + array_size)
#endif #endif
#ifdef USE_VECTOR
#if (defined(__NVCOMPILER) || defined(__NVCOMPILER_LLVM__))
#error "std::vector *is* supported in NVHPC if we capture `this`, however, oneDPL (via SYCL2020) only works correctly with explicit *value* captures."
#endif
#if defined(USE_ONEDPL)
#error "std::vector is unspported: oneDPL (via SYCL2020) only works correctly with explicit *value* captures"
#endif
#endif
template <class T> template <class T>
STDIndicesStream<T>::STDIndicesStream(const int ARRAY_SIZE, int device) STDIndicesStream<T>::STDIndicesStream(const int ARRAY_SIZE, int device)
noexcept : array_size{ARRAY_SIZE}, range(0, array_size), noexcept : array_size{ARRAY_SIZE}, range(0, array_size),
#ifdef USE_VECTOR #ifdef USE_VECTOR
a(ARRAY_SIZE, alloc_vec<T>()), b(ARRAY_SIZE, alloc_vec<T>()), c(ARRAY_SIZE, alloc_vec<T>()) a(ARRAY_SIZE), b(ARRAY_SIZE), c(ARRAY_SIZE)
#else #else
a(alloc_raw<T>(ARRAY_SIZE)), b(alloc_raw<T>(ARRAY_SIZE)), c(alloc_raw<T>(ARRAY_SIZE)) a(alloc_raw<T>(ARRAY_SIZE)), b(alloc_raw<T>(ARRAY_SIZE)), c(alloc_raw<T>(ARRAY_SIZE))
#endif #endif

View File

@ -78,7 +78,7 @@ class STDIndicesStream : public Stream<T>
// Device side pointers // Device side pointers
#ifdef USE_VECTOR #ifdef USE_VECTOR
std::vector<T, Allocator<T>> a, b, c; std::vector<T> a, b, c;
#else #else
T *a, *b, *c; T *a, *b, *c;
#endif #endif

View File

@ -26,7 +26,7 @@ template <class T>
STDRangesStream<T>::STDRangesStream(const int ARRAY_SIZE, int device) STDRangesStream<T>::STDRangesStream(const int ARRAY_SIZE, int device)
noexcept : array_size{ARRAY_SIZE}, noexcept : array_size{ARRAY_SIZE},
#ifdef USE_VECTOR #ifdef USE_VECTOR
a(ARRAY_SIZE, alloc_vec<T>()), b(ARRAY_SIZE, alloc_vec<T>()), c(ARRAY_SIZE, alloc_vec<T>()) a(ARRAY_SIZE), b(ARRAY_SIZE), c(ARRAY_SIZE)
#else #else
a(alloc_raw<T>(ARRAY_SIZE)), b(alloc_raw<T>(ARRAY_SIZE)), c(alloc_raw<T>(ARRAY_SIZE)) a(alloc_raw<T>(ARRAY_SIZE)), b(alloc_raw<T>(ARRAY_SIZE)), c(alloc_raw<T>(ARRAY_SIZE))
#endif #endif

View File

@ -22,7 +22,7 @@ class STDRangesStream : public Stream<T>
// Device side pointers // Device side pointers
#ifdef USE_VECTOR #ifdef USE_VECTOR
std::vector<T, Allocator<T>> a, b, c; std::vector<T> a, b, c;
#else #else
T *a, *b, *c; T *a, *b, *c;
#endif #endif