preference probe_array
API Reference Manual  /  7 Simulator-to-Simulator Interfaces  / 

probe

Description
This interface defines a probe in the system. A probe is a mechanism that lets a model expose values of interest to a user. By using this interface, generic tools can extract these values and present them in different forms, like tables and graphs. A probe should always have a meaningful value that can be read at any time during the simulation.

Probes should be used for user observable values and are not intended for model to model communication.

The properties() method is typically called once for each tool or use-case to get information about the probe. It should return a key/value attr_value_t list, i.e., list of lists of two values, with probe specific properties. The first value of the inner list represents the property key as an Sim_Val_Integer using the enum probe_key_t type, and the second value is a key specific data item described below. The probe_key_t is defined as:

typedef enum {
        Probe_Key_Name = 0,                  /* Identifier of the probe */

        Probe_Key_Type = 1,                  /* string, any of: {
                                                "int", "float, "fraction",
                                                "histogram", "int128", "string"
                                                } */
        Probe_Key_Categories = 2,            /* list of strings */
        Probe_Key_Cause_Slowdown = 3,        /* bool */

        Probe_Key_Owner_Object = 4,          /* object: owner object */

        Probe_Key_Display_Name = 5,          /* string: short narrow name */
        Probe_Key_Description = 6,           /* string */

        Probe_Key_Float_Percent = 7,
        Probe_Key_Float_Decimals = 8,
        Probe_Key_Metric_Prefix = 9,
        Probe_Key_Unit = 10,
        Probe_Key_Binary_Prefix = 11,
        Probe_Key_Time_Format = 12,
        Probe_Key_Width = 13,

        Probe_Key_Value_Notifier = 14,
        Probe_Key_Global_Sum = 15,           /* [list of properties] OBSOLETE */
        Probe_Key_Cell_Sum = 16,             /* [list of properties] OBSOLETE */

        Probe_Key_Aggregates = 17,   /* Defines new probes which aggregate
                                        over this probe:
                                        [list of [list properties]]
                                        Invalid for Type: "string"
                                     */
        Probe_Key_Aggregate_Scope = 18, /* Aggregate over all probes in the
                                           cells or all probes in the system.
                                           String and of ["global", "cell"] */
        Probe_Key_Aggregate_Function = 19, /* How the aggregation should be
                                              done:
                                              "sum",
                                              "weighted-arith-mean",
                                              - only fractions
                                           */
        Probe_Key_Definition = 20,         /* string: how the probe is
                                              calculated */
} probe_key_t;

The value() method should return the data for the probe as an attr_value_t in accordance of how the property type has been defined. This method is called each time a tool/user wants to read the latest probe value.

The property keys are describes here as follows:

Probe_Key_Name
Sets the name of the probe as a string (Sim_Val_String). It should be an hierarchical name where each level is separated with a dot. Probes falling into the same domain should have logical names according to this. Currently, there are some defined names on the first level that can be used to build the hierarchy. Among them are: cpu. that collects probes related to a CPU, dev. that collects probes for devices, cell. that collects probes related to cells, host. collects probes related to the host environment, and sim. that collects probes having to do wih the overall simulation environment.

Some examples, include: cpu.cycles, cpu.exec_mode.jit_steps, dev.io_access_count, cell.steps, host.swap.used, and sim.slowdown.

Several objects implementing this interface can use the same probe name, for similar probe values. The global identifier for a probe is a string containing the object name then a colon and then the probe name, e.g., "board.mb.cpu0.cpu[0][0]:cpu.cycles".

Probe_Key_Display_Name
Sets a display name for the probe as a string (Sim_Val_String). This is a more human friendly name than the probe name, and a tool can use this name in table headings or graph legends.
Probe_Key_Type
Sets the type of the probe as a string (Sim_Val_String). The following types are defined: "int", "float", "string", "fraction", "int128" and "histogram". The attr_value_t value that should be returned by the value method for these types are as follows:

For the int type, an attr_value_t of type Sim_Val_Integer should be returned.

For the float type, return a Sim_Val_Floating value.

The string type is returned by a Sim_Val_String value. The string typically represents some momentarily state. Due to nature of a string, a tool cannot do any calculation on the probe value, only show the current string content.

The fraction type should use a attr_value_t list of two Sim_Val_Integer or Sim_Val_Floating values. This represent a mathematical fraction value, where the first one is the numerator and and the second value is the denominator value. Note however that a float value can be used for both of them. To get the proper value for this probe the tool/user should divide the numerator with the denominator. Using fraction makes it possible for the tool to calculate a mean value for this probe between any point in time where the probe was read, e.g., say you have a probe that reads the frequency of a simulated processor that varies over time. Then this probe can be defined as a fraction between the cycle count and the elapsed virtual time (cycles/time = frequency). If the tool saves the cycle difference and the time difference between to points in time, it can calculate the mean frequency between those point by dividing the differences.

For very large numbers the int128 type can be used, the type is represented as a attr_value_t list of two value; the high 64-bit number followed by the low 64-bit number.

The histogram type is represented by a attr_value_t list of lists of two values. Where the inner list is used as a tuple of a named group as a Sim_Val_String, and its corresponding value as a Sim_Val_Integer or Sim_Val_Floating. A tool can then display an histogram of these groups and/or calculate the difference between two histograms over time and display that.

.
Probe_Key_Categories
The key is a list of string that defines some categories for the probe. This information can be used to search for probes of a specific use case.
Probe_Key_Cause_Slowdown
The value for this key is a Sim_Val_Boolean. True means that using the probe can cause a significant slowdown of the simulation. False means it does not cause any particular slowdown.
Probe_Key_Owner_Object
The value for this key is a Sim_Val_Object that should be regarded as the owner of the probe instead of the object that implements this interface (which is default). This can be useful if some other objects implements functionality for the main object.
Probe_Key_Description
The value for this key is a Sim_Val_String that documents this probe in details.
Probe_Key_Definition
"Function" definition string, explaining how the probe is being calculated out from other probes. This is automatically created for probe aggregates and derivatives. Default is an empty string.
Probe_Key_Float_Decimals
The value for this key is a Sim_Val_Integer that sets the preferred number of decimals of this is float probe when a value is displayed.
Probe_Key_Float_Percent
The value for this key is a Sim_Val_Boolean that sets the preferred representation of a float probe as a percent representation, e.g., a value of 0.176 will be displayed as 17.6% if the number of decimals are one.
Probe_Key_Metric_Prefix
The value for this key is a Sim_Val_String describing a unit name. This sets the preferred representation of a float probe to be displayed with a metric prefix for the unit given. Supported metric prefixes are: k, M, G, T, P, E, Z, Y, for values > 1 and m, µ, n, p, f, a, z, y for values < 1. For example if the unit is set to "s" (seconds) and the float value is 0.0000347, then the displayed representation should be "34.7 µs". To omit the unit in the output use the empty string, "", as the unit. If the value is outside the prefix ranges, an scientific E notation will be used.
Probe_Key_Binary_Prefix
The value for this key is a Sim_Val_String describing a unit name. This sets the preferred representation of an integer probe to be displayed with a binary prefix for the unit given. Supported prefixes are: ki, Mi, Gi, Ti, Pi, Ei, Zi, and Yi. For example if the unit is set to "B" (representing bytes), and the integer value is 10485760 (10*1024*1024), then the displayed representation should be "10 MiB". .
Probe_Key_Unit
The value for this key is a Sim_Val_String that sets the unit for the value. A tool can use this to display the unit for the value.
Probe_Key_Time_Format
The value for this key is a Sim_Val_Boolean that sets the preferred representation for a float value to a time format, hh:mm:ss.d, where h is hours, m minutes, s seconds, and d is fractions of a seconds. The raw value returned by the value method is the number of seconds. The Probe_Key_Float_Decimals key/value pair controls the number of digits in the fraction. If the number of seconds represents more than 99 hours, it should continue adding digits for the hours, e.g., 100:44:10.123
Probe_Key_Width
The value for this key is a Sim_Val_Integer that sets the preferred width of a probe value in characters. This can be used to determine the best width of columns in a table tool, for instance.
Probe_Key_Value_Notifier
The value for this key is a Sim_Val_String that describes a notifier that is triggered when the value changes. This can be used by a tool to track all changes of the value. For performance reasons the value should be changes infrequently.
Probe_Key_Global_Sum
Deprecated, use Probe_Key_Aggregates instead.
Probe_Key_Cell_Sum
Deprecated, use Probe_Key_Aggregates instead.
Probe_Key_Aggregates
Defines lists of new probes which are aggregates of the probe defined. Each list-element defines a new probe, specified as a list of the key-value properties for the aggregate probe. All properties are inherited from the probe being aggregated, except the new name of the aggregate probe which must be defined. Probe keys can be redefined if they appear in the aggregate scope. For example, it is advisable to change the description making it clear what value that is being returned by the aggregate.

Only in the aggregate scope, the Probe_Key_Aggregate_Scope and Probe_Key_Aggregate_Function key-value pairs are used to further define how the aggregation is done. Note that aggregates depend on the the type of the underlying probe. Some probe types can only be aggregated with certain functions.

Probe_Key_Aggregate_Scope
Defines the scope for the aggregate probe. That is, which objects that implements the probe, should be part of the aggregation. Valid values are "cell" or "global". Default is "global", which means that all objects which implements the probe will be part of the aggregate. Cell-aggregates are put under the available cell objects and will aggregate the probe which belongs to the respective cell object.
Probe_Key_Aggregate_Function
Defines how the aggregate should be generated. Valid values are "sum", "min", "max", "arith-mean", "weighted-arith-mean" and "median". Default is "sum".
sum
All probe values are summed together. Not supported on "string" probes.
min
The lowest value among the probe values is returned. Not supported on "string" and "histogram" probes.
max
The highest value among probe values is returned. Not supported on "string" and "histogram" probes.
arith-mean
The arithmetic mean is calculated for all the probe values. Not supported on "string" and "histogram" probes.
weighted-arith-mean
Only supported in fraction type probes. The denominators are used as weights.

Using these weights implies that the weighted arithmetic mean can be calculated by adding all numerators and denominators, producing a new fraction of these sums.

For example, when calculating the mean instruction per cycles (IPC) on all processors (where the IPC per processor is represented as a fraction: instructions / cycles). With two processors having [20/30] and [40/50], the total IPC becomes [(20+40)/(30+50)] or [60/80] and the IPC value of 0.75.

median
The median among the probe values is returned. Not supported on "fraction", "string" and "histogram" probes.
object-histogram
A histogram probe is created using the probe-owner-objects as key and their probe-values value. The type of this aggregate probe must be set to "histogram". Only supported on "int" and "float" probes types.
class-histogram
Similar to the object-histogram, but here the histogram uses the the classname of the owner-object as key, and the value is the sum of the probe-values with the same class. The type of this aggregate probe must be set to "histogram". Only supported on "int" and "float" probes types.

All key/value pairs except the Probe_Key_Name and Probe_Key_Type are optional.

SIM_INTERFACE(probe) {
        attr_value_t (*value)(conf_object_t *obj);
        attr_value_t (*properties)(conf_object_t *obj);
};
#define PROBE_INTERFACE "probe"

Execution Context
Global Context for all methods.

preference probe_array