From 09ad102966d5c244566a5f503c83c7fb01cea6aa Mon Sep 17 00:00:00 2001 From: Tom Lin Date: Sun, 13 Aug 2023 23:41:57 +0100 Subject: [PATCH] Add hipSYCL workaround for std-indices --- src/dpl_shim.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/dpl_shim.h b/src/dpl_shim.h index 226693b..b954019 100644 --- a/src/dpl_shim.h +++ b/src/dpl_shim.h @@ -56,10 +56,21 @@ static constexpr auto exe_policy = std::execution::par_unseq; #ifdef USE_STD_PTR_ALLOC_DEALLOC +#if defined(__HIPSYCL__) || defined(__OPENSYCL__) +#include + +// TODO We temporarily use malloc_shared/free here for hipSYCL stdpar because there's a linking issue if we let it hijack new/delete +// for this to work, we compile with --hipsycl-stdpar-system-usm so that hijacking is disabled +static cl::sycl::queue queue{cl::sycl::default_selector_v}; +template T *alloc_raw(size_t size) { return cl::sycl::malloc_shared(size, queue); } +template void dealloc_raw(T *ptr) { cl::sycl::free(ptr, queue); } + +#else template T *alloc_raw(size_t size) { return (T *) aligned_alloc(ALIGNMENT, sizeof(T) * size); } template void dealloc_raw(T *ptr) { free(ptr); } +#endif #endif