CoopSync for TBB 0.1.0
Cooperative synchronization primitives for TBB resumable tasks
Loading...
Searching...
No Matches
wait_for.hpp
1// SPDX-FileCopyrightText: 2026 CERN
2//
3// SPDX-License-Identifier: Apache-2.0
4
5#pragma once
6
7#include <oneapi/tbb/task.h>
8
9#include <alpaka/alpaka.hpp>
10
11namespace coopsync_tbb {
13namespace alpaka {
14
22#if ALPAKA_VERSION >= 300000000
24template <typename Device>
25inline static void wait_for(::alpaka::onHost::Queue<Device>& queue) {
26 ::tbb::task::suspend([&queue](::tbb::task::suspend_point suspend_point) {
27 queue.enqueueHostFnDeferred(
28 [suspend_point]() { ::tbb::task::resume(suspend_point); });
29 });
30}
31#else
33template <typename Queue>
34#if ALPAKA_VERSION >= 200200000
35 requires ::alpaka::concepts::Queue<Queue>
36#else
37 requires ::alpaka::isQueue<Queue>
38#endif
39inline static void wait_for(Queue& queue) {
40 ::tbb::task::suspend([&queue](::tbb::task::suspend_point suspend_point) {
41 ::alpaka::enqueue(
42 queue, [suspend_point]() { ::tbb::task::resume(suspend_point); });
43 });
44}
45#endif
46} // namespace alpaka
47} // namespace coopsync_tbb
alpaka integration.
Definition wait_for.hpp:13
static requires ::alpaka::isQueue< Queue > void wait_for(Queue &queue)
Suspends the current TBB task until all the work in a given alpaka queue is complete.
Definition wait_for.hpp:39
Main namespace of the library, containing all public APIs.
Definition wait_for.hpp:11