holoscan::Executor

Beta
View as Markdown

Base class for all executors.

An Executor that manages the execution of a Fragment on a physical node. The framework provides a default Executor that uses a GXF Scheduler to execute an Application.

#include <holoscan/executor.hpp>

Constructors

Executor

holoscan::Executor::Executor(
Fragment *fragment
)

Construct a new Executor object.

Parameters

fragment
Fragment *

The pointer to the fragment of the executor.

Destructor

~Executor

virtual holoscan::Executor::~Executor() = default

Assignment operators

operator=

Executor & holoscan::Executor::operator=(
const Executor &
) = delete

Methods

run

virtual void holoscan::Executor::run(
OperatorFlowGraph &graph
)

Run the graph.

Parameters

graph
OperatorFlowGraph &

The reference to the graph.

run_async

virtual std::future<void> holoscan::Executor::run_async(
OperatorFlowGraph &graph
)

Run the graph asynchronously.

Returns: The future object.

Parameters

graph
OperatorFlowGraph &

The reference to the graph.

interrupt

virtual bool holoscan::Executor::interrupt()

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

virtual void holoscan::Executor::wait()

Wait for the execution to complete.

This method blocks until the graph execution (started by run_async or interrupted by interrupt()) completes. Should be called after interrupt() to ensure the scheduler has fully stopped before performing cleanup operations.

Only call this if interrupt() returned true. Calling wait() when the graph is not running can cause issues with concurrent cleanup.

fragment

void holoscan::Executor::fragment(
Fragment *fragment
)

Set the pointer to the fragment of the executor.

Parameters

fragment
Fragment *

The pointer to the fragment of the executor.

context

virtual
virtual void holoscan::Executor::context(
void *context
)

Set the context.

Parameters

context
void *

The context.

owns_context

bool holoscan::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

void holoscan::Executor::context_uint64(
uint64_t context
)

extension_manager

virtual std::shared_ptr<ExtensionManager> holoscan::Executor::extension_manager()

Get the extension manager.

Returns: The shared pointer of the extension manager.

exception

void holoscan::Executor::exception(
const std::exception_ptr &e
)

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

e
const std::exception_ptr &

The exception to store.

initialize_fragment

virtual bool holoscan::Executor::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

virtual bool holoscan::Executor::initialize_operator(
Operator *op
)

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

op
Operator *

The pointer to the operator.

initialize_scheduler

virtual bool holoscan::Executor::initialize_scheduler(
Scheduler *sch
)

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

sch
Scheduler *

The pointer to the scheduler.

initialize_network_context

virtual bool holoscan::Executor::initialize_network_context(
NetworkContext *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

network_context
NetworkContext *

The pointer to the network context.

initialize_fragment_services

virtual bool holoscan::Executor::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

virtual bool holoscan::Executor::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
)

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

op
const std::shared_ptr<Operator> &

The reference to the shared pointer of the operator.

receivers_name
const std::string &

The name of the receivers whose parameter type is ‘std::vector<holoscan::IOSpec*>’.

new_input_labels
std::vector<std::string> &

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’).

iospec_vector
std::vector<holoscan::IOSpec *> &

The reference to the vector of IOSpec pointers.

add_control_flow

virtual bool holoscan::Executor::add_control_flow(
const std::shared_ptr<Operator> &upstream_op,
const std::shared_ptr<Operator> &downstream_op
)

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

upstream_op
const std::shared_ptr<Operator> &

The shared pointer to the upstream operator.

downstream_op
const std::shared_ptr<Operator> &

The shared pointer to the downstream operator.


Member variables

NameTypeDescription
fragment_Fragment *The fragment of the executor.
context_void *The context.
owns_context_boolWhether the context is owned by the executor.
extension_manager_std::shared_ptr< ExtensionManager >The extension manager.
exception_std::exception_ptrThe stored exception.