Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: RZ_A2M_Mbed_samples
Stream Class Reference
[Data Structures]
This class encapsulates a queue of asynchronous calls. More...
#include <cuda.hpp>
Public Member Functions | |
Stream () | |
creates a new asynchronous stream | |
bool | queryIfComplete () const |
Returns true if the current stream queue is finished. | |
void | waitForCompletion () |
Blocks the current CPU thread until all operations in the stream are complete. | |
void | waitEvent (const Event &event) |
Makes a compute stream wait on an event. | |
void | enqueueHostCallback (StreamCallback callback, void *userData) |
Adds a callback to be called on the host after all currently enqueued items in the stream have completed. | |
operator bool_type () const | |
returns true if stream object is not default (!= 0) | |
Static Public Member Functions | |
static Stream & | Null () |
return Stream object for default CUDA stream |
Detailed Description
This class encapsulates a queue of asynchronous calls.
- Note:
- Currently, you may face problems if an operation is enqueued twice with different data. Some functions use the constant GPU memory, and next call may update the memory before the previous one has been finished. But calling different operations asynchronously is safe because each operation has its own constant buffer. Memory copy/upload/download/set operations to the buffers you hold are also safe.
- The Stream class is not thread-safe. Please use different Stream objects for different CPU threads.
void thread1() { cv::cuda::Stream stream1; cv::cuda::func1(..., stream1); } void thread2() { cv::cuda::Stream stream2; cv::cuda::func2(..., stream2); }
- Note:
- By default all CUDA routines are launched in Stream::Null() object, if the stream is not specified by user. In multi-threading environment the stream objects must be passed explicitly (see previous note).
Definition at line 471 of file core/cuda.hpp.
Constructor & Destructor Documentation
Stream | ( | ) |
creates a new asynchronous stream
Member Function Documentation
void enqueueHostCallback | ( | StreamCallback | callback, |
void * | userData | ||
) |
Adds a callback to be called on the host after all currently enqueued items in the stream have completed.
- Note:
- Callbacks must not make any CUDA API calls. Callbacks must not perform any synchronization that may depend on outstanding device work or other callbacks that are not mandated to run earlier. Callbacks without a mandated order (in independent streams) execute in undefined order and may be serialized.
operator bool_type | ( | ) | const |
returns true if stream object is not default (!= 0)
bool queryIfComplete | ( | ) | const |
Returns true if the current stream queue is finished.
Otherwise, it returns false.
void waitEvent | ( | const Event & | event ) |
Makes a compute stream wait on an event.
void waitForCompletion | ( | ) |
Blocks the current CPU thread until all operations in the stream are complete.
Generated on Tue Jul 12 2022 18:20:24 by
