CoopSync for TBB 0.1.0
Cooperative synchronization primitives for TBB resumable tasks
Loading...
Searching...
No Matches
coopsync_tbb::cuda Namespace Reference

CUDA integration. More...

Functions

static COOPSYNC_TBB_CUDA_NODISCARDinline ::cudaError_t wait_for (::cudaStream_t stream, unsigned int sync_mode=0u)
 Suspends the current TBB task until all the work in a CUDA stream completes. Internally a CUDA callback is used to resume the task.
template<typename... StreamTs>
static COOPSYNC_TBB_CUDA_NODISCARD std::array<::cudaError_t, sizeof...(StreamTs)> wait_for_all (unsigned int sync_mode, StreamTs... streams)
 Suspends the current TBB task until all the work in all the provided CUDA streams is completed. A CUDA host callback is enqueued into every stream. The calling task resumes once all callbacks that were successfully enqueued have executed. In case of duplicate streams, the callback is enqueued multiple times, and the task will resume only after all callbacks have executed.
template<typename... StreamTs>
static COOPSYNC_TBB_CUDA_NODISCARD std::array<::cudaError_t, sizeof...(StreamTs)> wait_for_all (StreamTs... streams)
 Suspends the current TBB task until all the work in all the provided CUDA streams is completed. A CUDA host callback is enqueued into every stream. The calling task resumes once all callbacks that were successfully enqueued have executed.
template<typename ForwardIt, typename OutputIt>
static OutputIt wait_for_range (ForwardIt first, ForwardIt last, OutputIt out, unsigned int sync_mode=0u)
 Suspends the current TBB task until all the work in all the provided CUDA streams completes. A CUDA host callback is enqueued into every stream. The calling task resumes once all callbacks that were successfully enqueued have executed. In case of duplicate streams, the callback is enqueued multiple times, and the task will resume only after all callbacks have executed.

Detailed Description

CUDA integration.

Function Documentation

◆ wait_for()

COOPSYNC_TBB_CUDA_NODISCARDinline ::cudaError_t coopsync_tbb::cuda::wait_for ( ::cudaStream_t stream,
unsigned int sync_mode = 0u )
static

Suspends the current TBB task until all the work in a CUDA stream completes. Internally a CUDA callback is used to resume the task.

Parameters
streamCUDA stream.
sync_modeFlag controlling CUDA host callback registration, with semantics corresponding to the syncMode parameter of cudaLaunchHostFunc_v2 function. The sync_mode is only taken into account for CUDA 13.2 and later; for earlier CUDA versions, it has no effect.
Returns
The CUDA error code.
Note
In case of error during callback setup, the task is resumed immediately.

◆ wait_for_all() [1/2]

template<typename... StreamTs>
COOPSYNC_TBB_CUDA_NODISCARD std::array<::cudaError_t, sizeof...(StreamTs)> coopsync_tbb::cuda::wait_for_all ( StreamTs... streams)
inlinestatic

Suspends the current TBB task until all the work in all the provided CUDA streams is completed. A CUDA host callback is enqueued into every stream. The calling task resumes once all callbacks that were successfully enqueued have executed.

Parameters
streamsVariadic list of CUDA streams.
Returns
Array of CUDA error codes. Element i corresponds to stream i.

◆ wait_for_all() [2/2]

template<typename... StreamTs>
COOPSYNC_TBB_CUDA_NODISCARD std::array<::cudaError_t, sizeof...(StreamTs)> coopsync_tbb::cuda::wait_for_all ( unsigned int sync_mode,
StreamTs... streams )
inlinestatic

Suspends the current TBB task until all the work in all the provided CUDA streams is completed. A CUDA host callback is enqueued into every stream. The calling task resumes once all callbacks that were successfully enqueued have executed. In case of duplicate streams, the callback is enqueued multiple times, and the task will resume only after all callbacks have executed.

Parameters
sync_modeFlag controlling CUDA host callback registration, with semantics corresponding to the syncMode parameter of cudaLaunchHostFunc_v2 function. The sync_mode is only taken into account for CUDA 13.2 and later; for earlier CUDA versions, it has no effect.
streamsVariadic list of CUDA streams.
Returns
Array of CUDA error codes. Element i corresponds to stream i.
Note
Note the potentially unintuitive order of arguments: the first argument is the sync_mode, followed by variadic number of streams.

◆ wait_for_range()

template<typename ForwardIt, typename OutputIt>
OutputIt coopsync_tbb::cuda::wait_for_range ( ForwardIt first,
ForwardIt last,
OutputIt out,
unsigned int sync_mode = 0u )
inlinestatic

Suspends the current TBB task until all the work in all the provided CUDA streams completes. A CUDA host callback is enqueued into every stream. The calling task resumes once all callbacks that were successfully enqueued have executed. In case of duplicate streams, the callback is enqueued multiple times, and the task will resume only after all callbacks have executed.

Parameters
firstIterator to first CUDA stream. Must be a LegacyForwardIterator.
lastIterator past the last CUDA stream. Must be a LegacyForwardIterator.
outIterator receiving CUDA error codes in the same order. Must be a LegacyOutputIterator.
sync_modeFlag controlling CUDA host callback registration, with semantics corresponding to the syncMode parameter of cudaLaunchHostFunc_v2 function. The sync_mode is only taken into account for CUDA 13.2 and later; for earlier CUDA versions, it has no effect.
Returns
Iterator past the last written error code.