holoscan::MessageLabel

Beta
View as Markdown

Class to define a MessageLabel that is attached to every GXF Entity being communicated as a message between Operators in Holoscan, for Data Frame Flow Tracking.

A MessageLabel has a vector of paths, where each path is a vector of Operator references and their publish and receive timestamps. It also stores frame numbers for root operators.

#include <holoscan/messagelabel.hpp>

Constructors

MessageLabel


Assignment operators

operator=

MessageLabel & holoscan::MessageLabel::operator=(
const MessageLabel &m
)

Methods

num_paths

int holoscan::MessageLabel::num_paths() const

Get the number of paths in a MessageLabel.

Returns: The number of paths in a MessageLabel.

get_all_path_names

std::vector<std::string> holoscan::MessageLabel::get_all_path_names()

Get all the names of the path in formatted string, which is comma-separated values of the Operator names.

Returns: std::vector<std::string> The vector of strings, where each string is a path name.

paths

std::vector<TimestampedPath> & holoscan::MessageLabel::paths()

get_e2e_latency

int64_t holoscan::MessageLabel::get_e2e_latency(
int index
)

Get the current end-to-end latency of a path in microseconds.

MessageLabel and the whole Data Flow Tracking component tracks the latency in microseconds, which is sufficient for our use-cases.

Returns: int64_t The current end-to-end latency of the index path in microseconds

Parameters

index
int

The index of the path for which to get the latency

get_e2e_latency_ms

double holoscan::MessageLabel::get_e2e_latency_ms(
int index
)

Get the current end-to-end latency of a path in milliseconds.

Returns: double The current end-to-end latency of the index path in milliseconds.

Parameters

index
int

The index of the path for which to get the latency.

get_path

TimestampedPath holoscan::MessageLabel::get_path(
int index
)

Get the Timestamped path at the given index.

Returns: TimestampedPath& The timestamped path at the given index

Parameters

index
int

The index of the path to get

get_path_name

std::string holoscan::MessageLabel::get_path_name(
int index
)

Get the path name string which is comma-separated values of the operator names.

Returns: The path name string

Parameters

index
int

The index of the path to get

get_operator

OperatorTimestampLabel & holoscan::MessageLabel::get_operator(
int path_index,
int op_index
)

Get the OperatorTimestampLabel at the given path and operator index.

Returns: OperatorTimestampLabel& The Operator reference at the given path and operator index

Parameters

path_index
int

The path index of the OperatorTimestampLabel to get

op_index
int

The Operator index of the OperatorTimestampLabel to get

set_operator_pub_timestamp

void holoscan::MessageLabel::set_operator_pub_timestamp(
int path_index,
int op_index,
int64_t pub_timestamp
)

Set an Operator’s pub_timestamp.

Parameters

path_index
int

The path index of the Operator

op_index
int

The index of the Operator in the path

pub_timestamp
int64_t

The new pub_timestamp to set

set_operator_rec_timestamp

void holoscan::MessageLabel::set_operator_rec_timestamp(
int path_index,
int op_index,
int64_t rec_timestamp
)

Set an Operator’s pub_timestamp.

Parameters

path_index
int

The path index of the Operator

op_index
int

The index of the Operator in the path

rec_timestamp
int64_t

The new rec_timestamp to set

has_operator

std::vector<int> holoscan::MessageLabel::has_operator(
const std::string &op_name
) const

Check if an operator is present in the MessageLabel.

Returns an empty vector if the operator is not present in any path.

Returns: List of path indexes where the operator is present

Parameters

op_name
const std::string &

The name of the operator to check

set_frame_number

void holoscan::MessageLabel::set_frame_number(
const std::string &operator_name,
const std::string &port_name,
uint64_t frame_number
)

Set frame number for a specific root operator and port.

Parameters

operator_name
const std::string &

The name of the root operator

port_name
const std::string &

The name of the output port

frame_number
uint64_t

The frame number to set

get_frame_numbers

FrameNumberMap holoscan::MessageLabel::get_frame_numbers() const

Get all frame numbers as a map.

Returns: Copy of the frame number map (thread-safe)

add_new_op_timestamp

void holoscan::MessageLabel::add_new_op_timestamp(
const holoscan::OperatorTimestampLabel &o_timestamp
)

Add a new Operator timestamp to all the paths in a message label.

Parameters

o_timestamp
const holoscan::OperatorTimestampLabel &

The new operator timestamp to be added

update_last_op_publish

void holoscan::MessageLabel::update_last_op_publish()

Update the publish timestamp of the last operator in all the paths in a message label.

add_new_path

void holoscan::MessageLabel::add_new_path(
const TimestampedPath &path
)

Add a new path to the MessageLabel.

Parameters

path
const TimestampedPath &

The path to be added.

to_string

std::string holoscan::MessageLabel::to_string() const

Convert the MessageLabel to a string.

Returns: std::string The formatted string representing the MessageLabel with all the paths and the Operators with their publish and receive timestamps.

print_all

void holoscan::MessageLabel::print_all()

Print the to_string() in the standard output with a heading for the MessageLabel.


Static methods

get_path_e2e_latency_ms

static double holoscan::MessageLabel::get_path_e2e_latency_ms(
const TimestampedPath &path
)

Get the end-to-end latency of a TimestampedPath in microseconds.

It is a utility function in the class and not dependent on the object of this class. Therefore, it’s a static function.

Returns: The end-to-end latency of the path in ms

Parameters

path
const TimestampedPath &

The path for which to get the latency

to_string

static std::string holoscan::MessageLabel::to_string(
const TimestampedPath &path
)

Types

Typedefs

NameDefinition
TimestampedPathstd::vector< OperatorTimestampLabel >
PathOperatorsstd::unordered_set< std::string >
FrameNumberMapstd::map< std::string, uint64_t >

Member variables

NameTypeDescription
message_pathsstd::vector< TimestampedPath >
message_path_operatorsstd::vector< PathOperators >List of paths where each path is a set of name of the operators This variable is used to quickly check whether an operator is in a path.
frame_numbers_FrameNumberMapMap of root operator-port combinations to their frame numbers Keys are in format “operatorname-portname” to track frame numbers per output port.
frame_numbers_mutex_std::mutexMutex to protect concurrent access to frame_numbers_.