pub unsafe extern "C" fn cudaThreadExchangeStreamCaptureMode(
mode: *mut cudaStreamCaptureMode,
) -> cudaError_tExpand description
Swaps the stream capture interaction mode for a thread.
Sets the calling thread’s stream capture interaction mode to the value contained in *mode, and overwrites *mode with the previous mode for the thread. To facilitate deterministic behavior across function or module boundaries, callers are encouraged to use this API in a push-pop fashion:
cudaStreamCaptureMode mode = desiredMode;
cudaThreadExchangeStreamCaptureMode(&mode);
...
cudaThreadExchangeStreamCaptureMode(&mode); // restore previous modeDuring stream capture (see cudaStreamBeginCapture), some actions, such as a call to cudaMalloc, may be unsafe. In the case of cudaMalloc, the operation is not enqueued asynchronously to a stream, and is not observed by stream capture. Therefore, if the sequence of operations captured via cudaStreamBeginCapture depended on the allocation being replayed whenever the graph is launched, the captured graph would be invalid.
Therefore, stream capture places restrictions on API calls that can be made within or concurrently to a cudaStreamBeginCapture-cudaStreamEndCapture sequence. This behavior can be controlled via this API and flags to cudaStreamBeginCapture.
A thread’s mode is one of the following:
cudaStreamCaptureModeGlobal:This is the default mode. If the local thread has an ongoing capture sequence that was not initiated withcudaStreamCaptureMode::CU_STREAM_CAPTURE_MODE_RELAXEDatcuStreamBeginCapture, or if any other thread has a concurrent capture sequence initiated withcudaStreamCaptureMode::CU_STREAM_CAPTURE_MODE_GLOBAL, this thread is prohibited from potentially unsafe API calls.cudaStreamCaptureModeThreadLocal:If the local thread has an ongoing capture sequence not initiated withcudaStreamCaptureMode::CU_STREAM_CAPTURE_MODE_RELAXED, it is prohibited from potentially unsafe API calls. Concurrent capture sequences in other threads are ignored.cudaStreamCaptureModeRelaxed:The local thread is not prohibited from potentially unsafe API calls. Note that the thread is still prohibited from API calls which necessarily conflict with stream capture, for example, attemptingcudaEventQueryon an event that was last recorded inside a capture sequence.
Note that this function may also return error codes from previous, asynchronous launches.
§Parameters
mode: Pointer to mode value to swap with the current mode
§Return value
See also: cudaStreamBeginCapture.