Metric Definition File
This topic describes the Metric Definition File.
To add metric libraries that implement the Metric Plugin Template and make calls to the Metric plugin API to compatible
profilers, use a metric definition file.
This is a short xml file that defines the location of a metric plugin library and lists both the metrics that library can provide, and how the profiler must process and display the metric data returned by that library.
A metric definition file uses the format:
<metricdefinition version="1">
<!-- 'metric' element(s) defining the metrics provided by the library -->
<!-- 'metricGroup' element(s) describing how the metrics should be
grouped when displayed by a profiler -->
<!-- 'source' element(s) specifying the location of the metrics library
the profiler should load and, optionally, a list of libraries to
preload into the profiled application -->
</metricdefinition>
See custom1.xml for a complete metric definition file. The elements are described in detail here:
<metric>
<metric id="com.allinea.metrics.myplugin.mymetric1">
<enabled>[always|default_yes|default_no|never]</enabled>
<units>%</units>
<dataType>[uint64_t|double]</dataType>
<domain>time</domain>
<onePerNode>[false|true]</onePerNode>
<source ref="com.allinea.metrics.myplugin_src" functionName="mymetric1" customData="mydata"/>
<display>
<description>Human readable description</description>
<displayName>Human readable display name</displayName>
<type>instructions</type>
<colour>green</colour>
</display>
</metric>
Each <metric> element describes a single metric that is provided by a metric plugin library. The id attribute of the opening <metric> element is the identifier used by this definition file and the profiler to uniquely identify this metric. To avoid confusion, ensure that metric element does not contain any whitespace and that it is chosen to minimize the risk of clashing with an existing metric name.
To avoid metric name clashes, derive your metric ids from your website domain name and the name of the plugin library, for example com.allinea.metrics.myplugin.mymetric1.
enabledSpecifies whether the metric is enabled or not. Options are
always,never,default_yes,default_noenabled. This allows you to explicitly enable or disable the metrics listed asdefault_noordefault_yesenabled using the command line. A metrics source library is not loaded if all metrics which it defines have been disabled.unitsThe units this metric is measured in. The profiler might automatically rescale the units to better display large numbers, for example, convert
BtoKB). Possible values include%(percentage in the range 0..100),B(bytes),B/s(bytes per second),calls/s(calls per second),/s(per second),ns(nanoseconds),J(joule) andW(watts, joules per second). Other units can be specified but the profiler, might not know how to rescale for particularly large or small numbers.dataTypeThe datatype used to represent this metric. Possible values are
uint64_t(exact integer) anddouble(floating point).domainThe domain in which sampling occurs. The only supported domain is
time.onePerNodeIf
false, all processes report this metric. Iftrue, only one process on each node (machine) calculates and returns this metric. Usetruewhen the metric is a machine-level metric that can not be attributed to an individual process. The default value (if this element is omitted) isfalse.If all the metrics of the library have
<onePerNode>set totrue, only the library is enabled in one process of the node, and this process is the only one to call theallinea_plugin_initializeandallinea_plugin_cleanupfunctions.backfillIf
true, the metricgetteris called once for each sample when the user application is ending (for example, inMPI_Finalizeoratexit) or the sampling has stopped after a timeout. Iffalse, or the tag is not present, then the metricgettercollects data at sample time. For more information on backfilling, see the examples backfill1.c and backfill1.xmlsourcerefThe id of the
<source>element detailing the metric plugin library that contains that function. The function infunctionNamemust have the appropriate signature for a metricgetter, see mymetric_getIntValue() as an example.
functionNameThe name of the function to call to obtain a value for this metric.
divideBySampleTime(Not used in example)If
true, the metricgetterfunction returns the difference in the measured value since the last sample. The profiler divides the returned value by the time elapsed since the last sample to get thetruevalue. Iffalse, the value returned by thegetterfunction is left unaltered.As a special case, if
unitsis%(percentage) anddivideBySampleTimeistrue, the result is also multiplied by 100.0 to give a percentage value in the range 0..100.In this situation the function specified by
functionNamereturns a time-in-seconds value.
customDataCustom data string associated with this metric id, which can be extracted in the metric plugin library with a call to allinea_get_custom_data.
displayOptions describing how this metric must display:
descriptionA human-readable description of this metric, suitable for tooltips or short summary text.
displayNameThe human-readable display name for this metric
typeIdentifies the broad category this metric falls under. Currently supported values are
cpu_time,energy,instructions,io,memory,mpi, andother.
colourA color to use when displaying the metric (for example, the color of any graphs generated using this metric). This field is optional. The profiler can choose to use a color based on the
typefield instead of the color code specified here. Color values can be:an RGB hex code of the form #RGB, #RRGGBB, #RRRGGGBBB or #RRRRGGGGBBBB (each of R, G, and B is a single hex digit).
an SVG color keyword, for example,
green.
relSpecifies related metrics. The only supported related metric type is
integral. This type might be used to specify another metric which is an integral of the metric being defined, for examplerapl_energyis an integral ofrapl_power:<rel type="integral" name="rapl_energy"/>
<metricGroup>
<metricGroup id="foo">
<displayName>Foo Metrics</displayName>
<description>All metrics relating to foo.</description>
<metric ref="com.allinea.metrics.myplugin.mymetric1"/>
<metric ref="com.allinea.metrics.myplugin.mymetric2"/>
<metric ref="com.allinea.metrics.myplugin.mymetric3"/>
</metricGroup>
Each metricGroup element describes a collection of metrics to be grouped together. The UI of the profiler might provide actions that apply to all metrics of a group (such as, show or hide all metrics of a group). Metric groups are for display purposes only and do not affect
the gathering of metrics.
displayNameA human readable name for this metric group.
descriptionA human-readable description of this metric group, suitable for tooltips or some short summary text.
metricOne or more elements each referencing a
<metric>element elsewhere in this.xmlfile.
<source>
Each <source> element represents a metric plugin library that is available for loading. The specific metrics in that library are listed as <metric> elements above.
<source id="com.allinea.metrics.myplugin_src">
<sharedLibrary>lib-myplugin.so</sharedLibrary>
<preload>lib-mywrapper1.so</preload>
<preload>lib-mywrapper2.so</preload>
<functions>
<start>user_application_start</start>
<stop>sampling_stop</stop>
</functions>
</source>
idThe id this library is referenced as in this
.xmlfile. This id is used within thesourcefields of<metric>.sharedLibraryThe library implementing the Metric Plugin Template. This must be located in a directory that is checked by the profiler. To resolve this library name, see the documentation of the profiler to determine which directories are searched.
preloadA list of shared libraries to be preloaded into the application to profile. Preloads are optional, and they might be used to wrap function calls from the profiled application into other shared libraries. The
sharedLibrarypreloads have to be located in a directory checked by the profiler.startThe name of the function to call when the Linaro Forge sampler is initialized. This function is optional but must have the same signature as start_profiling().
stopThe name of the function to call when the Linaro Forge sampler has ceased taking samples. This function is optional but must have the same signature as stop_profiling().