Skip to content

Commit 62a5051

Browse files
committed
Add support for AdaptiveCpp to C++ Standard Parallelism
1 parent b3786f6 commit 62a5051

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Diff for: src/std/STDStream.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ template <class T>
149149
void STDStream<T>::nstream()
150150
{
151151
// a[i] += b[i] + scalar * c[i];
152-
#if defined(DATA17) || defined(DATA23) // Until we can require GCC 14.1
152+
#if defined(DATA17)
153153
// Need to do in two round-trips with C++17 STL.
154154
// 1: a[i] += b[i]
155155
// 2: a[i] += scalar * c[i];
@@ -160,6 +160,7 @@ void STDStream<T>::nstream()
160160
auto as = std::ranges::subrange(a, a + array_size);
161161
auto bs = std::ranges::subrange(b, b + array_size);
162162
auto cs = std::ranges::subrange(c, c + array_size);
163+
auto r = std::views::zip(as, bs, cs);
163164
std::transform(exe_policy, r.begin(), r.end(), a, [](auto vs) {
164165
auto [a, b, c] = vs;
165166
return a + b + startScalar * c;

Diff for: src/std/model.cmake

+14-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ register_flag_optional(NVHPC_OFFLOAD
2020
ccnative - Compiles for compute capability of current device"
2121
"")
2222

23+
register_flag_optional(ACPP_OFFLOAD
24+
"Enable offloading support (via the non-standard `-acpp-stdpar`) for AdaptiveCpp."
25+
"OFF")
26+
2327
register_flag_optional(USE_TBB
2428
"No-op if ONE_TBB_DIR is set. Link against an in-tree oneTBB via FetchContent_Declare, see top level CMakeLists.txt for details."
2529
"OFF")
@@ -59,8 +63,17 @@ macro(setup)
5963
register_append_cxx_flags(ANY ${NVHPC_FLAGS})
6064
register_append_link_flags(${NVHPC_FLAGS})
6165
endif ()
66+
if (ACPP_OFFLOAD)
67+
set(ACPP_FLAGS --acpp-stdpar)
68+
register_append_cxx_flags(ANY ${ACPP_FLAGS})
69+
register_append_link_flags(${ACPP_FLAGS})
70+
endif ()
6271
if (USE_TBB)
63-
register_link_library(TBB::tbb)
72+
if (FETCH_TBB)
73+
register_link_library(TBB::tbb)
74+
else ()
75+
register_link_library(tbb)
76+
endif ()
6477
endif ()
6578
if (USE_ONEDPL)
6679
register_definitions(USE_ONEDPL)

0 commit comments

Comments
 (0)