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 d83308b commit cd3f430
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/std-indices/dpl_shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ static constexpr auto exec_policy = dpl::execution::par_unseq;

#endif

#elif defined(USE_LLVM_OMPT)

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

inline auto &&exec_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
13 changes: 13 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 @@ -47,6 +51,15 @@ macro(setup)
register_link_library(oneDPL)
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 (NVHPC_OFFLOAD)
set(NVHPC_FLAGS
-stdpar
Expand Down

0 comments on commit cd3f430

Please sign in to comment.