holoscan::gxf::GXFExecutor
holoscan::gxf::GXFExecutor
Executor for GXF.
Inherits from: holoscan::Executor (public)
Constructors
GXFExecutor
Overload 2
Deleted overload 1
Destructor
~GXFExecutor
Methods
run
Initialize the graph and run the graph.
This method calls compose() to compose the graph, and runs the graph.
Parameters
The reference to the graph.
run_async
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.
Returns: The future object.
Parameters
The reference to the graph.
interrupt
Interrupt the execution.
This method calls GxfGraphInterrupt() to interrupt the execution.
Returns: true if the interrupt was successful (graph was running), false if the graph was not running (already stopped or not started).
wait
Wait for the execution to complete.
This method calls GxfGraphWait() to wait for the graph execution to complete. Should be called after interrupt() to ensure the scheduler has fully stopped.
Only call this if interrupt() returned true. Calling wait() when the graph is not running can cause issues with concurrent cleanup.
reset_execution_state
Reset execution state to allow for multiple runs.
Resets internal flags related to graph initialization and activation to allow for multiple consecutive executions.
destroy_context
Destroy the GXF context.
Releases resources associated with the GXF context if it exists. No operation is performed if the context is null or the context is not owned by this.
context
Set the context
Get the context
Set the context.
For GXF, GXFExtensionManager(extension_manager_) is initialized with the context.
Parameters
The context.
extension_manager
Get GXF extension manager.
Returns: The GXF extension manager.
See also: GXFExtensionManager
op_eid
Overload 1
Overload 2
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 within an existing entity, e.g., when initializing an operator from the holoscan::gxf::OperatorWrapper class.
Parameters
The GXF entity ID.
op_cid
Overload 1
Overload 2
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 an existing component within an existing entity, e.g., when initializing an operator from the holoscan::gxf::OperatorWrapper class.
Parameters
The GXF component ID.
entity_prefix
Get the entity prefix string.
Returns: The entity prefix string.
setup_signal_handlers
Set up signal handlers for graceful shutdown.
fragment
Set the pointer to the fragment of the executor
Overload 2
Set the pointer to the fragment of the executor.
Parameters
The pointer to the fragment of the executor.
owns_context
Get whether the context is owned by the executor.
Returns: true if the context is owned by the executor. Otherwise, false.
context_uint64
Overload 1
Overload 2
exception
Set the exception
Get the stored exception
Set the exception.
This method is called by the framework to store the exception that occurred during the execution of the fragment. If the exception is set, this exception is rethrown by the framework after the execution of the fragment.
Parameters
The exception to store.
initialize_fragment
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: true if fragment initialization is successful. Otherwise, false.
initialize_operator
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.
Returns: true if the operator is initialized successfully. Otherwise, false.
Parameters
The pointer to the operator.
initialize_scheduler
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.
Returns: true if the scheduler is initialized successfully. Otherwise, false.
Parameters
The pointer to the scheduler.
initialize_network_context
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.
Returns: true if the network context is initialized successfully. Otherwise, false.
Parameters
The pointer to the network context.
initialize_fragment_services
Initialize the fragment services for the executor.
This method is called during executor initialization to set up any required fragment services.
Depending on the type of executor, this method may be overridden to initialize specific fragment services. For example, the default executor (GXFExecutor) may initialize fragment services using the GXF API.
Returns: true if the fragment services are initialized successfully. Otherwise, false.
add_receivers
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’).
Returns: true if the receivers are added successfully. Otherwise, false.
Parameters
The reference to the shared pointer of the operator.
The name of the receivers whose parameter type is ‘std::vector<holoscan::IOSpec*>’.
The reference to the vector of input port labels to which the input port labels are added. In the case of multiple receivers, the input port label is updated to ‘parameter name:index’ (e.g. ‘receivers’ => ‘receivers:0’).
The reference to the vector of IOSpec pointers.
add_control_flow
Add a control flow between two operators.
This method is called by Fragment::add_flow() to add a control flow between two operators.
Returns: true if the control flow is added successfully. Otherwise, false.
Parameters
The shared pointer to the upstream operator.
The shared pointer to the downstream operator.
initialize_gxf_graph
activate_gxf_graph
run_gxf_graph
connection_items
add_operator_to_entity_group
register_extensions
initialize_gxf_resources
Initialize all GXF Resources in the map and assign them to graph_entity.
Utility function grouping common code across initialize_network_context and intialize_scheduler.
Parameters
Unordered map of GXF resources.
The entity to which the resources will be assigned.
Nvidia::gxf::GraphEntity pointer for the resources.
add_connection
Create a GXF Connection component between a transmitter and receiver.
The Connection object created will belong to connections_entity_.
Returns: The GXF status code.
Parameters
The GXF Transmitter component ID.
The GXF Receiver component ID.
create_broadcast_components
Create Broadcast components and add their nvidia::gxf::GraphEntity to broadcast_entites.
This is a helper method that gets called by initialize_fragment.
Creates broadcast components for any output ports of op that connect to more than one input port.
Does not add any transmitter to the Broadcast entity. The transmitters will be added later when the incoming edges to the respective operators are processed.
Any connected ports of the operator are removed from port_map_val.
Parameters
The operator to create broadcast components for.
The mapping of broadcast graph entities.
TODO
connect_broadcast_to_previous_op
Add connection between the prior Broadcast component and the current operator’s input port(s).
Creates a transmitter on the broadcast component and connects it to the input port of op.
Any connected ports of the operator are removed from port_map_val.
Parameters
The mapping of broadcast graph entities.
The broadcast entity’s output will connect to the input port of this operator.
The operator connected to the input of the broadcast entity. The capacity and policy of the transmitter added to the broadcast entity will be copied from the transmitter on the broadcasted output port of this operator.
The port mapping between prev_op and op.
add_condition_to_graph_entity
Helper function that adds a GXF Condition to the specified graph entity.
add_resource_to_graph_entity
Helper function that adds a GXF Resource to the specified graph entity.
add_iospec_to_graph_entity
add_component_args_to_graph_entity
connect_ucx_transmitters_to_virtual_ops
add_gpu_device_to_graph_entity
get_operator_port_iospec
get_operator_port_cid
Static methods
create_input_port
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
The fragment that this operator belongs to.
The input port specification.
The operator to which this port is being added. create a new GXF Receiver component.
create_output_port
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
The fragment that this operator belongs to.
The output port specification.
The operator to which this port is being added. create a new GXF Transmitter component.
reset_interrupt_flags
Reset the static interrupt flags and cancel any active force-exit countdown threads.
This method is needed for unit testing of interrupt handling to ensure clean state between test cases. It cancels any lingering countdown threads from previous tests and resets all static interrupt-related flags.
register_codec
Register the codec for serialization/deserialization of a custom type.
If any operator has an argument with a custom type, the codec must be registered using this method.
For example, suppose we want to emit using the following custom struct type:
Then, we can define codec<Coordinate> as follows where the serialize and deserialize methods would be used for serialization and deserialization of this type, respectively.
In this case, since this is a simple struct with a static size, we can use the existing serialize_trivial_type and deserialize_trivial_type implementations.
Finally, to register this custom codec at runtime, we need to make the following call within the setup method of our Operator.
Template parameters
The type of the argument to register.
Parameters
The name of the codec (must be unique unless overwrite is true).
If true and codec_name already exists, the codec will be overwritten.
Example
Example
Example