Skip to content

Commit

Permalink
Initial support for PSTL's OpenMP target backend
Browse files Browse the repository at this point in the history
  • Loading branch information
tom91136 committed Oct 1, 2023
1 parent 2e3ebee commit f7ec5ea
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/dpl_shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ static constexpr auto exe_policy = dpl::execution::par_unseq;

#endif

#elif defined(USE_LLVM_OMPT)

#include <algorithm>
#include <execution>
#include <numeric>
#include <omp.h>

inline auto && exe_policy = std::execution::par_unseq;

template<typename T>
T *alloc_raw(size_t size) { return (T *) omp_alloc(size * sizeof(T), llvm_omp_target_shared_mem_alloc); }

template<typename T>
void dealloc_raw(T *ptr) { omp_free(ptr, llvm_omp_target_shared_mem_alloc); }

#else

// Normal C++17 PSTL
Expand Down
12 changes: 12 additions & 0 deletions src/std-data/model.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ register_flag_optional(USE_TBB
"No-op if ONE_TBB_DIR is set. Link against an in-tree oneTBB via FetchContent_Declare, see top level CMakeLists.txt for details."
"OFF")

register_flag_optional(USE_LLVM_OMPT
"Use LLVM's PTSL offload"
"OFF")

register_flag_optional(USE_ONEDPL
"Link oneDPL which implements C++17 executor policies (via execution_policy_tag) for different backends.
Expand All @@ -46,6 +50,14 @@ macro(setup)
if (USE_TBB)
register_link_library(TBB::tbb)
endif ()

if(USE_LLVM_OMPT)
register_definitions(USE_LLVM_OMPT)
# find_package(OpenMP REQUIRED)
# register_link_library(OpenMP::OpenMP_CXX)
# TODO target flags
endif ()

if (USE_ONEDPL)
register_definitions(USE_ONEDPL)
register_link_library(oneDPL)
Expand Down
12 changes: 12 additions & 0 deletions src/std-indices/model.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ register_flag_optional(USE_TBB
"Link against an in-tree oneTBB via FetchContent_Declare, see top level CMakeLists.txt for details."
"OFF")

register_flag_optional(USE_LLVM_OMPT
"Use LLVM's PTSL offload"
"OFF")

register_flag_optional(USE_ONEDPL
"Link oneDPL which implements C++17 executor policies (via execution_policy_tag) for different backends.
Expand All @@ -43,6 +47,14 @@ macro(setup)
register_append_cxx_flags(ANY ${NVHPC_FLAGS})
register_append_link_flags(${NVHPC_FLAGS})
endif ()

if(USE_LLVM_OMPT)
register_definitions(USE_LLVM_OMPT)
# find_package(OpenMP REQUIRED)
# register_link_library(OpenMP::OpenMP_CXX)
# TODO target flags
endif ()

if (USE_TBB)
register_link_library(TBB::tbb)
endif ()
Expand Down

0 comments on commit f7ec5ea

Please sign in to comment.