From 438e210867634f6b494026623c0dc94be055ee23 Mon Sep 17 00:00:00 2001 From: Tom Deakin Date: Mon, 4 Dec 2023 12:42:33 +0000 Subject: [PATCH] Revert "Remove AdaptiveCpp workaround in dpl_shim.h to allow for automatic prefetch optimization (#177)" This reverts commit 06c3d534dd6e0feb2e3d1b6725f1e5b61094e1cd. --- src/dpl_shim.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/dpl_shim.h b/src/dpl_shim.h index e4cba9e..b954019 100644 --- a/src/dpl_shim.h +++ b/src/dpl_shim.h @@ -55,10 +55,22 @@ static constexpr auto exe_policy = std::execution::par_unseq; #endif #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