Class GXFExecutor

class GXFExecutor : public holoscan::Executor

Executor for GXF.

Public Functions

GXFExecutor() = delete
explicit GXFExecutor(holoscan::Fragment *app, bool create_gxf_context = true)
~GXFExecutor() override
virtual void run(OperatorGraph &graph) override

Initialize the graph and run the graph.

This method calls compose() to compose the graph, and runs the graph.

Parameters
virtual std::future<void> run_async(OperatorGraph &graph) override

Initialize the graph and run the graph asynchronously.

This method calls compose() to compose the graph, and runs the graph asynchronously. The graph is executed in a separate thread and returns a future object.

Parameters
Returns
virtual void interrupt() override
virtual void context(void *context) override

Set the context.

For GXF, GXFExtensionManager(gxf_extension_manager_) is initialized with the context.

Parameters
virtual std::shared_ptr<ExtensionManager> extension_manager() override

Get GXF extension manager.

Returns
inline void op_eid(gxf_uid_t eid)

Set the GXF entity ID of the operator initialized by this executor.

If this is 0, a new entity is created for the operator. Otherwise, the operator as a codelet will be added to the existing entity specified by this ID. This is useful when initializing operators inside the existing entity. (e.g., when initializing an operator from holoscan::gxf::OperatorWrapper class)

Parameters
inline void op_cid(gxf_uid_t cid)

Set the GXF component ID of the operator initialized by this executor.

If this is 0, a new component is created for the operator. This is useful when initializing operators using the existing component inside the existing entity. (e.g., when initializing an operator from holoscan::gxf::OperatorWrapper class)

Parameters
inline bool own_gxf_context()

Returns whether the GXF context is created by this executor.

Returns
inline const std::string &entity_prefix()

Get the entity prefix string.

Returns
inline virtual void context(void *context)

Set the context.

Parameters
inline void *context()

Get the context.

Returns

Public Static Functions

static void create_input_port(Fragment *fragment, gxf_context_t gxf_context, gxf_uid_t eid, IOSpec *io_spec, bool bind_port = false, Operator *op = nullptr)

Create and setup GXF components for input port.

For a given input port specification, create a GXF Receiver component for the port and create a GXF SchedulingTerm component that is corresponding to the Condition of the port.

If there is no condition specified for the port, a default condition (MessageAvailableCondition) is created. It currently supports ConditionType::kMessageAvailable and ConditionType::kNone condition types.

This function is a static function so that it can be called from other classes without dependency on this class.

Parameters
static void create_output_port(Fragment *fragment, gxf_context_t gxf_context, gxf_uid_t eid, IOSpec *io_spec, bool bind_port = false, Operator *op = nullptr)

Create and setup GXF components for output port.

For a given output port specification, create a GXF Receiver component for the port and create a GXF SchedulingTerm component that is corresponding to the Condition of the port.

If there is no condition specified for the port, a default condition (DownstreamMessageAffordableCondition) is created. It currently supports ConditionType::kDownstreamMessageAffordable and ConditionType::kNone condition types.

This function is a static function so that it can be called from other classes without dependency on on this class.

Parameters

Protected Functions

virtual bool initialize_fragment() override

Initialize the fragment_ in this Executor.

This method is called by run() to initialize the fragment and the graph of operators in the fragment before execution.

Returns
virtual bool initialize_operator(Operator *op) override

Initialize the given operator.

This method is called by Operator::initialize() to initialize the operator.

Depending on the type of the operator, this method may be overridden to initialize the operator. For example, the default executor (GXFExecutor) initializes the operator using the GXF API and sets the operator’s ID to the ID of the GXF codelet.

Parameters
Returns
virtual bool initialize_scheduler(Scheduler *sch) override

Initialize the given scheduler.

This method is called by Scheduler::initialize() to initialize the operator.

Depending on the type of the scheduler, this method may be overridden to initialize the scheduler. For example, the default executor (GXFExecutor) initializes the scheduler using the GXF API and sets the operator’s ID to the ID of the GXF scheduler.

Parameters
Returns
virtual bool initialize_network_context(NetworkContext *network_context) override

Initialize the given network context.

This method is called by NetworkContext::initialize() to initialize the operator.

Depending on the type of the network context, this method may be overridden to initialize the network context. For example, the default executor (GXFExecutor) initializes the network context using the GXF API and sets the operator’s ID to the ID of the GXF network context.

Parameters
Returns
virtual bool add_receivers(const std::shared_ptr<Operator> &op, const std::string &receivers_name, std::vector<std::string> &new_input_labels, std::vector<holoscan::IOSpec*> &iospec_vector) override

Add the receivers as input ports of the given operator.

This method is to be called by the Fragment::add_flow() method to support for the case where the destination input port label points to the parameter name of the downstream operator, and the parameter type is ‘std::vector<holoscan::IOSpec*>’. This finds a parameter with with ‘std::vector<holoscan::IOSpec*>’ type and create a new input port with a specific label (‘<parameter name>:<index>’. e.g, ‘receivers:0’).

Parameters
Returns
bool initialize_gxf_graph(OperatorGraph &graph)
void activate_gxf_graph()
bool run_gxf_graph()
bool connection_items(std::vector<std::shared_ptr<holoscan::ConnectionItem>> &connection_items)
void add_operator_to_entity_group(gxf_context_t context, gxf_uid_t entity_group_gid, std::shared_ptr<Operator> op)
void register_extensions()

Protected Attributes

bool own_gxf_context_ = false
gxf_uid_t op_eid_ = 0
gxf_uid_t op_cid_ = 0
std::shared_ptr<GXFExtensionManager> gxf_extension_manager_
nvidia::gxf::Extension *gxf_holoscan_extension_ = nullptr
bool is_extensions_loaded_ = false
bool is_gxf_graph_initialized_ = false
bool is_gxf_graph_activated_ = false
std::string entity_prefix_
std::vector<std::shared_ptr<holoscan::ConnectionItem>> connection_items_

Friends

friend class holoscan::AppDriver
friend class holoscan::AppWorker

© Copyright 2022-2023, NVIDIA. Last updated on Sep 13, 2023.