Skip to content

Commit

Permalink
Merge pull request #178 from UoB-HPC/revert-177-patch-5
Browse files Browse the repository at this point in the history
Revert "Remove AdaptiveCpp workaround in dpl_shim.h to allow for automatic prefetch optimization"
  • Loading branch information
tomdeakin authored Dec 4, 2023
2 parents 06c3d53 + 438e210 commit ad61a0d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/dpl_shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <CL/sycl.hpp>

// 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 <typename T> T *alloc_raw(size_t size) { return cl::sycl::malloc_shared<T>(size, queue); }
template <typename T> void dealloc_raw(T *ptr) { cl::sycl::free(ptr, queue); }

#else
template<typename T>
T *alloc_raw(size_t size) { return (T *) aligned_alloc(ALIGNMENT, sizeof(T) * size); }

template<typename T>
void dealloc_raw(T *ptr) { free(ptr); }
#endif

#endif

0 comments on commit ad61a0d

Please sign in to comment.