diff --git a/src/dpl_shim.h b/src/dpl_shim.h index e4cba9e0..b9540196 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