Class GXFExecutionContext
Defined in File gxf_execution_context.hpp
Base Type
public holoscan::ExecutionContext
(Class ExecutionContext)
-
class GXFExecutionContext : public holoscan::ExecutionContext
Class to hold the execution context for GXF Operator.
This class provides the execution context for the operator using GXF.
Public Functions
-
GXFExecutionContext() = default
-
GXFExecutionContext(gxf_context_t context, Operator *op)
Construct a new GXFExecutionContext object.
- Parameters
context – The pointer to the GXF context.
op – The pointer to the operator.
Construct a new GXFExecutionContext object.
- Parameters
context – The pointer to the GXF context.
gxf_input_context – The shared pointer to the GXFInputContext object.
gxf_output_context – The shared pointer to the GXFOutputContext object.
-
~GXFExecutionContext() override = default
-
inline std::shared_ptr<GXFInputContext> gxf_input()
Get the GXF input context.
- Returns
The pointer to the GXFInputContext object.
-
inline std::shared_ptr<GXFOutputContext> gxf_output()
Get the GXF output context.
- Returns
The pointer to the GXFOutputContext object.
-
virtual expected<cudaStream_t, RuntimeError> allocate_cuda_stream(const std::string &stream_name) override
allocate a new GXF CudaStream object and return the cudaStream_t corresponding to it
-
virtual void synchronize_streams(const std::vector<std::optional<cudaStream_t>> &cuda_streams, cudaStream_t target_cuda_stream) override
synchronize all of the streams in cuda_streams with target_cuda_stream
-
virtual expected<int, RuntimeError> device_from_stream(cudaStream_t stream) override
determine the CUDA device corresponding to the given stream
-
virtual std::shared_ptr<Operator> find_operator(const std::string &op_name) override
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.
-
virtual expected<holoscan::OperatorStatus, RuntimeError> get_operator_status(const std::string &op_name) override
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.
-
expected<gxf::CudaStreamHandle, RuntimeError> stream_handle_from_stream(cudaStream_t stream)
Return the CudaStreamHandle corresponding to a given cudaStream_t.
This will only work with a cudaStream_t that was allocated as a CudaStream object by GXF. The stream should correspond to a CudaStreamId that was received on one of the Operator’s input ports or a stream that was allocated via
allocate_cuda_stream
.- Parameters
stream_handle – A CUDA stream object.
- Returns
The GXF CudaStream handle if found, or unexpected if not found.
-
inline std::shared_ptr<CudaObjectHandler> cuda_object_handler()
-
void init_cuda_object_handler(Operator *op)
initialize the CudaObjectHandler for the Operator
-
void release_internal_cuda_streams()
release any internal stream objects allocated by the operator
-
void clear_received_streams()
clear the handler’s received stream mappings from a prior
Operator::compute
call.
Protected Functions
-
expected<CudaStreamHandle, RuntimeError> allocate_cuda_stream_handle(const std::string &stream_name)
allocate a new GXF CudaStream object and return the GXF Handle to it
-
expected<gxf_uid_t, RuntimeError> get_operator_eid(const std::string &op_name)
get the GXF entity ID of the operator
Protected Attributes
-
Operator *op_ = nullptr
The operator pointer.
-
gxf_uid_t eid_ = kNullUid
The GXF entity ID of the operator.
-
std::shared_ptr<GXFInputContext> gxf_input_context_ = {}
The GXF input context.
-
std::shared_ptr<GXFOutputContext> gxf_output_context_ = {}
The GXF output context.
-
std::shared_ptr<CudaObjectHandler> cuda_object_handler_ = {}
-
std::unordered_map<std::string, gxf_uid_t> operator_eid_cache_ = {}
Cache for operator EIDs.
Friends
- friend class holoscan::gxf::GXFWrapper
- friend class holoscan::gxf::GXFInputContext
- friend class holoscan::gxf::GXFOutputContext
-
GXFExecutionContext() = default