Skip to content

Commit

Permalink
Bump oneDPL version
Browse files Browse the repository at this point in the history
Add hipSYCL support in dpl shim
  • Loading branch information
tom91136 committed Sep 1, 2023
1 parent f0acef9 commit 5ce76b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ if (USE_ONEDPL)
FetchContent_Declare(
oneDPL
GIT_REPOSITORY https://github.com/oneapi-src/oneDPL.git
GIT_TAG oneDPL-2021.7.0-release
GIT_TAG oneDPL-2022.2.0-rc1
)
string(TOLOWER ${USE_ONEDPL} ONEDPL_BACKEND)
# XXX oneDPL looks for omp instead of openmp, which mismatches(!) with ONEDPL_PAR_BACKEND if using find_package
Expand Down
22 changes: 14 additions & 8 deletions src/std-indices/dpl_shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
#include <cstdlib>
#include <cstddef>

#ifndef ALIGNMENT
#define ALIGNMENT (2*1024*1024) // 2MB
#endif

#ifdef USE_ONEDPL

// oneDPL C++17 PSTL
Expand Down Expand Up @@ -56,10 +52,20 @@ static constexpr auto exec_policy = std::execution::par_unseq;

#ifdef USE_STD_PTR_ALLOC_DEALLOC

template<typename T>
T *alloc_raw(size_t size) { return (T *) aligned_alloc(ALIGNMENT, sizeof(T) * size); }
#if defined(__HIPSYCL__) || defined(__OPENSYCL__)
#include <CL/sycl.hpp>

template<typename T>
void dealloc_raw(T *ptr) { free(ptr); }
// 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 static_cast<T *>(std::malloc(size * sizeof(T))); }
template <typename T> void dealloc_raw(T *ptr) { std::free(ptr); }

#endif

#endif

0 comments on commit 5ce76b5

Please sign in to comment.