NvRulesAPI: NV::Rules::IFrontend Class Reference

# NV::Rules::IFrontend Class Reference
[NvRules Tool lifetime-managed classes.]

Frontend interface. More...

## Public Types
enum | MarkerKind
| Marker Kind. More...
enum | MsgType
| Message type. More...
enum | Severity
| Focus metric severity. More...
enum | SpeedupType
| Speedup estimation type. More...
## Public Member Functions
virtual bool | focus_metric (int message_id, const char *metric_name, double metric_value, Severity severity, const char *info)=0
| Rule focus metric message.
virtual void | load_chart_from_file (const char *filename)=0
virtual int | message (MsgType type, const char *str, const char *name=nullptr)=0
| Rule result message.
virtual int | message (const char *str, const char *name=nullptr)=0
| Rule result message.
virtual Dict | receive_dict_from_parent (const RuleId &parent_id)=0
| Receive a dictionary from parent rule `parent_id`.
virtual void | send_dict_to_children (const Dict &dict)=0
| Send a dictionary `dict` to all child rules.
virtual void | source_marker (const char *str, uint64_t address_or_line, MarkerKind kind, const char *file_name, MsgType type=MsgType::MSG_NONE)=0
| Rule source marker.
virtual void | source_marker (const char *str, uint64_t address_or_line, MarkerKind kind, MsgType type=MsgType::MSG_NONE)=0
| Rule source marker.
virtual bool | speedup (int message_id, SpeedupType type, double estimated_speedup)=0
| Rule estimated speedup message.

## Detailed Description

The frontend is responsible for relaying messages and results to the caller via user interfaces, logs or output files.

## Member Enumeration Documentation

enum NV::Rules::IFrontend::MarkerKind

The kind of marker that is created in the Source Page with source_marker. `SASS` The marker will be associated with a SASS instruction. `SOURCE` The marker will be associated with a Source line.

enum NV::Rules::IFrontend::MsgType

The type a message to the frontend represents when calling message. `MSG_NONE` No specific type for this message. `MSG_OK` The message is informative. `MSG_OPTIMIZATION` The message represents a suggestion for performance optimization. `MSG_WARNING` The message represents a warning or fixable issue. `MSG_ERROR` The message represents an error, potentially in executing the rule.

enum NV::Rules::IFrontend::Severity

The severity a focus metric represents when calling focus_metric. The severity can be used by the rule system client when processing the focus metric. `SEVERITY_DEFAULT` The default severity. `SEVERITY_LOW` Severity if low. `SEVERITY_HIGH` Severity if high.

enum NV::Rules::IFrontend::SpeedupType

The type of speedup estimation used when calling speedup. `LOCAL` The proportional increase in efficiency of the hardware usage when viewing the performance problem in isolation. `GLOBAL` The proportional reduction in runtime of the entire workload.

## Member Function Documentation

virtual bool NV::Rules::IFrontend::focus_metric | ( | int | message_id,
|  | const char * | metric_name,
|  | double | metric_value,
|  | Severity | severity,
|  | const char * | info |
| ) |  |  | `[pure virtual]`

Issues a focus metric message to the frontend, e.g. to indicate a key metric that triggered the rule output. Can be associated with a prior message using its `message_id` . The `severity` can be used to indicate this metric's impact/severity on the result. The `info` field can be set to a descriptive string for further information, e.g. the calculation leading to this metric being focused. Returns whether the focus_metric could be set successfully for the `message_id` .

virtual void NV::Rules::IFrontend::load_chart_from_file | ( | const char * | filename | ) | `[pure virtual]`

Load a ProfilerSection google protcol buffer chart from `filename`

virtual int NV::Rules::IFrontend::message | ( | MsgType | type,
|  | const char * | str,
|  | const char * | name = `nullptr` |
| ) |  |  | `[pure virtual]`

Issues a message `str` with a specific message `type` and optional name `name` to the frontend. Returns a message ID that is unique in this rule invocation.

virtual int NV::Rules::IFrontend::message | ( | const char * | str,
|  | const char * | name = `nullptr` |
| ) |  |  | `[pure virtual]`

Issues a message `str` to the frontend with the default MsgType and optional name `name` . Returns a message ID that is unique in this rule invocation.

virtual Dict NV::Rules::IFrontend::receive_dict_from_parent | ( | const RuleId & | parent_id | ) | `[pure virtual]`

Receive a dictionary of type dict[str,float] sent using `send_dict_to_children` . In case `parent_id` does not represent a pre-specified parent rule of this rule, or in case the parent rule has not been executed, an empty dict will be returned.

virtual void NV::Rules::IFrontend::send_dict_to_children | ( | const Dict & | dict | ) | `[pure virtual]`

Sends a Python dictionary of type dict[str,float] to all rules that specify this rule as a parent rule. Child rules can retrieve the message using `receive_dict_from_parent` . In case this function is called repeatedly, the dict is updated accordingly, thereby adding new key-value pairs, and overwriting values of pre-existing keys.

virtual void NV::Rules::IFrontend::source_marker | ( | const char * | str,
|  | uint64_t | address_or_line,
|  | MarkerKind | kind,
|  | const char * | file_name,
|  | MsgType | type = `MsgType::MSG_NONE` |
| ) |  |  | `[pure virtual]`

Creates a source marker with a message `str` at the source location `address_or_line` in the appropriate `kind` of source. This function supports multi-file programs, which means a `file_name` has to be specified. The `type` denotes the urgency associated with this marker and is optional.

virtual void NV::Rules::IFrontend::source_marker | ( | const char * | str,
|  | uint64_t | address_or_line,
|  | MarkerKind | kind,
|  | MsgType | type = `MsgType::MSG_NONE` |
| ) |  |  | `[pure virtual]`

Creates a source marker with a message `str` at the source location `address_or_line` in the appropriate `kind` of source. The `type` denotes the urgency associated with this marker and is optional.

virtual bool NV::Rules::IFrontend::speedup | ( | int | message_id,
|  | SpeedupType | type,
|  | double | estimated_speedup |
| ) |  |  | `[pure virtual]`

Issues an estimated speedup to the frontend associated to the message with ID `message_id` . When `type` is `SpeedupType::GLOBAL`, it indicates what proportional decrease in workload runtime could potentially be achieved, when following the guidelines of the rule. When `type` is `SpeedupType::LOCAL`, it indicates what increase in the efficiency of the hardware usage within the context of the performance problem could be achieved. Returns whether the speedup could be set successfully for the `message_id` .