Class ExecutionContext
Defined in File execution_context.hpp
Derived Type
public holoscan::gxf::GXFExecutionContext(Class GXFExecutionContext)
-
class ExecutionContext
Class to hold the execution context.
This class provides the execution context for the operator.
Subclassed by holoscan::gxf::GXFExecutionContext
Public Functions
-
ExecutionContext() = default
Construct a new Execution Context object.
-
virtual ~ExecutionContext() = default
-
inline std::shared_ptr<InputContext> input() const
Get the input context.
- Returns
The shared pointer to the input context.
-
inline std::shared_ptr<OutputContext> output() const
Get the output context.
- Returns
The shared pointer to the output context.
-
inline void *context() const
Get the context.
- Returns
The pointer to the context.
-
inline virtual expected<cudaStream_t, RuntimeError> allocate_cuda_stream(const std::string &stream_name = "")
Allocate a CUDA stream from the operator’s CudaStreamPool.
Streams are cached by name — calling with the same name returns the same stream on subsequent calls within the same operator. This is useful for root operators that need to allocate a stream (rather than receiving one from upstream).
Streams allocated this way are not automatically emitted on output ports. Call
OutputContext::set_cuda_stream()beforeemit()if you need to propagate the stream.- Parameters
stream_name – A name for the stream. The same name returns the same stream on subsequent calls. Defaults to an empty string.
- Returns
The allocated cudaStream_t, or an error if no CudaStreamPool is available.
-
inline virtual void synchronize_streams(const std::vector<std::optional<cudaStream_t>> &cuda_streams, cudaStream_t target_cuda_stream)
Synchronize multiple CUDA streams to a target stream (non-blocking).
Uses
cudaEventRecordandcudaStreamWaitEventto create GPU-side dependencies without blocking the CPU. This is the same mechanism used internally byreceive_cuda_stream.When using
receive_cuda_stream, synchronization is handled automatically and this method is not needed. It is provided for advanced manual stream handling use cases.- Parameters
cuda_streams – Vector of streams to synchronize.
std::nulloptelements are skipped.target_cuda_stream – The stream that will wait for all other streams to complete.
-
inline virtual expected<int, RuntimeError> device_from_stream(cudaStream_t stream)
Get the CUDA device ID for a given stream.
Only works with Holoscan-managed streams (those returned by
receive_cuda_stream,receive_cuda_streams, orallocate_cuda_stream).- Parameters
stream – The CUDA stream to query.
- Returns
The device ID, or an error if the stream is not managed by Holoscan.
-
inline virtual bool is_gpu_available() const
check if GPU capability is present on the system
-
inline virtual std::shared_ptr<Operator> find_operator(const std::string &op_name = "")
Find an operator by name.
If the operator name is not provided, the current operator is returned.
- Parameters
op_name – The name of the operator.
- Returns
A shared pointer to the operator or nullptr if the operator is not found.
-
inline virtual expected<holoscan::OperatorStatus, RuntimeError> get_operator_status(const std::string &op_name = "")
Get the status of the operator.
If the operator name is not provided, the status of the current operator is returned.
- Parameters
op_name – The name of the operator.
- Returns
The status of the operator or an error if the operator is not found.
Protected Attributes
-
std::shared_ptr<InputContext> input_context_ = nullptr
The input context.
-
std::shared_ptr<OutputContext> output_context_ = nullptr
The output context.
-
void *context_ = nullptr
The context.
-
ExecutionContext() = default