holoscan::CudaObjectHandler
holoscan::CudaObjectHandler
Pure virtual base class for handling CUDA streams in operators.
This class defines the interface for managing CUDA streams in Holoscan operators. It provides methods for stream synchronization, allocation, and management.
Constructors
Destructor
~CudaObjectHandler
Methods
init_from_operator
Initialize the handler from an operator.
Parameters
The operator this instance is attached to.
add_stream
Add a CUDA stream to an output port.
Returns: 0 if successful, otherwise an error code
Parameters
The stream to add
The name of the output port
get_cuda_stream
Get the CUDA stream for a given input port.
Returns: The CUDA stream to use
Parameters
Context object (e.g. gxf_context_t for the GXF backend)
The name of the input port
If true, allocate a new stream if none exists
If true, synchronize to default stream
get_cuda_streams
Get all CUDA streams for a given input port.
Returns: Vector of optional CUDA streams (one per message)
Parameters
Context object (e.g. gxf_context_t for the GXF backend)
The name of the input port
synchronize_streams
Synchronize streams with a target stream.
Returns: 0 if successful, error code otherwise
Parameters
The streams to synchronize
The stream to synchronize to
If true, also sync to default stream
release_internal_streams
Release all internally allocated CUDA streams.
Returns: 0 if successful, error code otherwise
Parameters
Context object (e.g. gxf_context_t for the GXF backend)
clear_received_streams
Clear all received streams.
This is used to refresh the state before each compute call.
is_gpu_available
Check if GPU capability is present on the system.
Returns: true if GPU(s) are available, false if no GPU is present