Skip to content

Commit

Permalink
Add support for AdaptiveCpp to C++ Standard Parallelism
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalobg committed Jun 5, 2024
1 parent b3786f6 commit 62a5051
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/std/STDStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ template <class T>
void STDStream<T>::nstream()
{
// a[i] += b[i] + scalar * c[i];
#if defined(DATA17) || defined(DATA23) // Until we can require GCC 14.1
#if defined(DATA17)
// Need to do in two round-trips with C++17 STL.
// 1: a[i] += b[i]
// 2: a[i] += scalar * c[i];
Expand All @@ -160,6 +160,7 @@ void STDStream<T>::nstream()
auto as = std::ranges::subrange(a, a + array_size);
auto bs = std::ranges::subrange(b, b + array_size);
auto cs = std::ranges::subrange(c, c + array_size);
auto r = std::views::zip(as, bs, cs);
std::transform(exe_policy, r.begin(), r.end(), a, [](auto vs) {
auto [a, b, c] = vs;
return a + b + startScalar * c;
Expand Down
15 changes: 14 additions & 1 deletion src/std/model.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ register_flag_optional(NVHPC_OFFLOAD
ccnative - Compiles for compute capability of current device"
"")

register_flag_optional(ACPP_OFFLOAD
"Enable offloading support (via the non-standard `-acpp-stdpar`) for AdaptiveCpp."
"OFF")

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")
Expand Down Expand Up @@ -59,8 +63,17 @@ macro(setup)
register_append_cxx_flags(ANY ${NVHPC_FLAGS})
register_append_link_flags(${NVHPC_FLAGS})
endif ()
if (ACPP_OFFLOAD)
set(ACPP_FLAGS --acpp-stdpar)
register_append_cxx_flags(ANY ${ACPP_FLAGS})
register_append_link_flags(${ACPP_FLAGS})
endif ()
if (USE_TBB)
register_link_library(TBB::tbb)
if (FETCH_TBB)
register_link_library(TBB::tbb)
else ()
register_link_library(tbb)
endif ()
endif ()
if (USE_ONEDPL)
register_definitions(USE_ONEDPL)
Expand Down

0 comments on commit 62a5051

Please sign in to comment.