LIKWID
Classes | Macros | Enumerations | Functions | Variables
Performance monitoring module

Classes

struct  PerfmonCounter
 Structure describing performance monitoring counter data. More...
 
struct  PerfmonEvent
 Structure specifying an performance monitoring event. More...
 
struct  PerfmonEventOption
 Structure specifying event/counter options and their value. More...
 
struct  PerfmonEventSet
 Structure specifying an performance monitoring event group. More...
 
struct  PerfmonEventSetEntry
 Structure specifying an performance monitoring event. More...
 
struct  PerfmonGroupSet
 Structure specifying all performance monitoring event groups. More...
 
struct  PerfmonThread
 Structure specifying thread to CPU relation. More...
 

Macros

#define EVENT_OPTION_NONE_MASK   0x0ULL
 Bitmask with no event/counter option set.
 
#define OPTIONS_TYPE_MASK(type)
 Define for easily creating an bitmask of all configured event/counter options. More...
 

Enumerations

enum  EventOptionType {
  EVENT_OPTION_NONE = 0, EVENT_OPTION_OPCODE, EVENT_OPTION_MATCH0, EVENT_OPTION_MATCH1,
  EVENT_OPTION_MATCH2, EVENT_OPTION_MATCH3, EVENT_OPTION_MASK0, EVENT_OPTION_MASK1,
  EVENT_OPTION_MASK2, EVENT_OPTION_MASK3, EVENT_OPTION_NID, EVENT_OPTION_TID,
  EVENT_OPTION_STATE, EVENT_OPTION_EDGE, EVENT_OPTION_THRESHOLD, EVENT_OPTION_INVERT,
  EVENT_OPTION_COUNT_KERNEL, EVENT_OPTION_ANYTHREAD, EVENT_OPTION_OCCUPANCY, EVENT_OPTION_OCCUPANCY_FILTER,
  EVENT_OPTION_OCCUPANCY_EDGE, EVENT_OPTION_OCCUPANCY_INVERT, EVENT_OPTION_IN_TRANS, EVENT_OPTION_IN_TRANS_ABORT,
  NUM_EVENT_OPTIONS
}
 Enum of possible event and counter options. More...
 
enum  GroupState { STATE_NONE = 0, STATE_SETUP, STATE_START }
 Enum of possible states of an event group. More...
 

Functions

int perfmon_addEventSet (const char *eventCString) __attribute__((visibility("default")))
 Add an event string to LIKWID. More...
 
void perfmon_check_counter_map (int cpu_id) __attribute__((visibility("default")))
 Check the performance monitoring maps whether counters and events are available. More...
 
void perfmon_destroyMarkerResults () __attribute__((visibility("default")))
 Free space for read in Marker API file.
 
void perfmon_finalize (void) __attribute__((visibility("default")))
 Close the perfomance monitoring facility of LIKWID. More...
 
char * perfmon_getCounterName (int groupId, int eventId) __attribute__((visibility("default")))
 Get the counter name of the specified group and event. More...
 
int perfmon_getCountOfRegion (int region, int thread) __attribute__((visibility("default")))
 Get the call count of a region for a thread. More...
 
int perfmon_getCpulistOfRegion (int region, int count, int *cpulist) __attribute__((visibility("default")))
 Get the cpulist of a region. More...
 
char * perfmon_getEventName (int groupId, int eventId) __attribute__((visibility("default")))
 Get the event name of the specified group and event. More...
 
int perfmon_getEventsOfRegion (int region) __attribute__((visibility("default")))
 Get the number of events of a region. More...
 
char * perfmon_getGroupInfoLong (int groupId) __attribute__((visibility("default")))
 Get the long descriptive string of the specified group. More...
 
char * perfmon_getGroupInfoShort (int groupId) __attribute__((visibility("default")))
 Get the short informational string of the specified group. More...
 
char * perfmon_getGroupName (int groupId) __attribute__((visibility("default")))
 Get the name group. More...
 
int perfmon_getGroupOfRegion (int region) __attribute__((visibility("default")))
 Get the groupID of a region. More...
 
int perfmon_getGroups (char ***groups, char ***shortinfos, char ***longinfos) __attribute__((visibility("default")))
 Get all groups. More...
 
int perfmon_getIdOfActiveGroup (void) __attribute__((visibility("default")))
 Get the ID of the currently set up event group. More...
 
double perfmon_getLastMetric (int groupId, int metricId, int threadId) __attribute__((visibility("default")))
 Get the last metric result of the specified group, counter and thread. More...
 
double perfmon_getLastResult (int groupId, int eventId, int threadId) __attribute__((visibility("default")))
 Get the last results of the specified group, counter and thread. More...
 
double perfmon_getLastTimeOfGroup (int groupId) __attribute__((visibility("default")))
 Get the last measurement time a group. More...
 
double perfmon_getMetric (int groupId, int metricId, int threadId) __attribute__((visibility("default")))
 Get the metric result of the specified group, counter and thread. More...
 
char * perfmon_getMetricName (int groupId, int metricId) __attribute__((visibility("default")))
 Get the metric name of the specified group and metric. More...
 
double perfmon_getMetricOfRegionThread (int region, int metricId, int threadId) __attribute__((visibility("default")))
 Get the metric result of a region for a metric and thread. More...
 
int perfmon_getMetricsOfRegion (int region) __attribute__((visibility("default")))
 Get the number of metrics of a region. More...
 
int perfmon_getNumberOfEvents (int groupId) __attribute__((visibility("default")))
 Get the number of configured eventSets in group. More...
 
int perfmon_getNumberOfGroups (void) __attribute__((visibility("default")))
 Get the number of configured event groups. More...
 
int perfmon_getNumberOfMetrics (int groupId) __attribute__((visibility("default")))
 Get the number of configured metrics for group. More...
 
int perfmon_getNumberOfRegions () __attribute__((visibility("default")))
 Get the number of regions listed in Marker API result file. More...
 
int perfmon_getNumberOfThreads (void) __attribute__((visibility("default")))
 Get the number of threads specified at perfmon_init() More...
 
double perfmon_getResult (int groupId, int eventId, int threadId) __attribute__((visibility("default")))
 Get the results of the specified group, counter and thread. More...
 
double perfmon_getResultOfRegionThread (int region, int event, int thread) __attribute__((visibility("default")))
 Get the event result of a region for an event and thread. More...
 
char * perfmon_getTagOfRegion (int region) __attribute__((visibility("default")))
 Get the tag of a region. More...
 
int perfmon_getThreadsOfRegion (int region) __attribute__((visibility("default")))
 Get the number of threads of a region. More...
 
double perfmon_getTimeOfGroup (int groupId) __attribute__((visibility("default")))
 Get the accumulated measurement time a group. More...
 
double perfmon_getTimeOfRegion (int region, int thread) __attribute__((visibility("default")))
 Get the accumulated measurement time of a region for a thread. More...
 
int perfmon_init (int nrThreads, const int *threadsToCpu) __attribute__((visibility("default")))
 Initialize performance monitoring facility. More...
 
void perfmon_init_maps (void) __attribute__((visibility("default")))
 Initialize performance monitoring maps. More...
 
int perfmon_readCounters (void) __attribute__((visibility("default")))
 Read the performance monitoring counters on all CPUs. More...
 
int perfmon_readCountersCpu (int cpu_id) __attribute__((visibility("default")))
 Read the performance monitoring counters on one CPU. More...
 
int perfmon_readGroupCounters (int groupId) __attribute__((visibility("default")))
 Read the performance monitoring counters of all threads in a group. More...
 
int perfmon_readGroupThreadCounters (int groupId, int threadId) __attribute__((visibility("default")))
 Read the performance monitoring counters of on thread in a group. More...
 
int perfmon_readMarkerFile (const char *filename) __attribute__((visibility("default")))
 Read the output file of the Marker API. More...
 
void perfmon_returnGroups (int nrgroups, char **groups, char **shortinfos, char **longinfos) __attribute__((visibility("default")))
 Free all group information. More...
 
int perfmon_setupCounters (int groupId) __attribute__((visibility("default")))
 Setup all performance monitoring counters of an eventSet. More...
 
void perfmon_setVerbosity (int verbose) __attribute__((visibility("default")))
 Set verbosity of LIKWID library. More...
 
int perfmon_startCounters (void) __attribute__((visibility("default")))
 Start performance monitoring counters. More...
 
int perfmon_stopCounters (void) __attribute__((visibility("default")))
 Stop performance monitoring counters. More...
 
int perfmon_switchActiveGroup (int new_group) __attribute__((visibility("default")))
 Switch the active eventSet to a new one. More...
 

Variables

BoxMap * box_map
 List of boxes with name, config register, counter registers and if needed PCI device. Mainly used in Uncore handling but also core-local counters are defined as a box.
 
RegisterMap * counter_map
 List of counter with name, config register, counter registers and if needed PCI device.
 
PerfmonEventeventHash
 List of events available for the current architecture.
 
char * eventOptionTypeName [NUM_EVENT_OPTIONS]
 List of option names. More...
 
PciDevice * pci_devices
 List of PCI devices available for the current architecture.
 

Detailed Description

Macro Definition Documentation

#define OPTIONS_TYPE_MASK (   type)
Value:
(((type == EVENT_OPTION_NONE)||(type >= NUM_EVENT_OPTIONS)) ? \
(1ULL<<type))
#define EVENT_OPTION_NONE_MASK
Bitmask with no event/counter option set.
Definition: perfmon_types.h:106
No option, used as False value.
Definition: perfmon_types.h:58
Amount of defined options.
Definition: perfmon_types.h:86

Define for easily creating an bitmask of all configured event/counter options.

Enumeration Type Documentation

Enum of possible event and counter options.

List of internally used IDs for all event and counter options that are supported by LIKWID.

Enumerator
EVENT_OPTION_NONE 

No option, used as False value.

EVENT_OPTION_OPCODE 

Match opcode.

EVENT_OPTION_MATCH0 

Match0 register.

EVENT_OPTION_MATCH1 

Match1 register.

EVENT_OPTION_MATCH2 

Match2 register.

EVENT_OPTION_MATCH3 

Match3 register.

EVENT_OPTION_MASK0 

Mask0 register.

EVENT_OPTION_MASK1 

Mask1 register.

EVENT_OPTION_MASK2 

Mask2 register.

EVENT_OPTION_MASK3 

Mask3 register.

EVENT_OPTION_NID 

Set NUMA node ID.

EVENT_OPTION_TID 

Set Thread ID.

EVENT_OPTION_STATE 

Match for state.

EVENT_OPTION_EDGE 

Increment counter at each edge.

EVENT_OPTION_THRESHOLD 

Increment only if exceeding threshold.

EVENT_OPTION_INVERT 

Invert behavior of EVENT_OPTION_THRESHOLD, hence increment only below threshold.

EVENT_OPTION_COUNT_KERNEL 

Also count events when in kernel space.

EVENT_OPTION_ANYTHREAD 

Increment counter at events of all HW threads in the core.

EVENT_OPTION_OCCUPANCY 

Count occupancy not occurrences.

EVENT_OPTION_OCCUPANCY_FILTER 

Filter for occupancy counting.

EVENT_OPTION_OCCUPANCY_EDGE 

Increment occupancy counter at detection of an edge.

EVENT_OPTION_OCCUPANCY_INVERT 

Invert filter for occupancy counting.

EVENT_OPTION_IN_TRANS 

Count events during transactions.

EVENT_OPTION_IN_TRANS_ABORT 

Count events that aborted during transactions.

NUM_EVENT_OPTIONS 

Amount of defined options.

enum GroupState

Enum of possible states of an event group.

List of states for event groups

Enumerator
STATE_NONE 

Not configured, not started and not stopped.

STATE_SETUP 

The event set hold by group is configured.

STATE_START 

The event set hold by group is current running.

Function Documentation

int perfmon_addEventSet ( const char *  eventCString)

Add an event string to LIKWID.

A event string looks like Eventname:Countername(:Option1:Option2:...),... The eventname, countername and options are checked if they are available.

Parameters
[in]eventCStringEvent string
Returns
Returns the ID of the new eventSet
void perfmon_check_counter_map ( int  cpu_id)

Check the performance monitoring maps whether counters and events are available.

Checks each counter and event in the performance monitoring maps for their availibility on the current system. topology_init(), numa_init() and perfmon_init_maps() must be called before calling perfmon_check_counter_map().

See also
RegisterMap list, PerfmonEvent list and BoxMap list
void perfmon_finalize ( void  )

Close the perfomance monitoring facility of LIKWID.

Deallocates all internal data that is used during performance monitoring. Also the counter values are not accessible after this function.

char* perfmon_getCounterName ( int  groupId,
int  eventId 
)

Get the counter name of the specified group and event.

Get the counter name as defined in the performance group file

Parameters
[in]groupIdID of the group that should be read
[in]eventIdID of the event of which the counter should be returned
Returns
The counter name or NULL in case of failure
int perfmon_getCountOfRegion ( int  region,
int  thread 
)

Get the call count of a region for a thread.

Parameters
[in]regionID of region
[in]threadID of thread
Returns
Call count of a region for a thread
int perfmon_getCpulistOfRegion ( int  region,
int  count,
int *  cpulist 
)

Get the cpulist of a region.

Parameters
[in]regionID of region
[in]countLength of cpulist array
[in,out]cpulistcpulist array
Returns
Number of threads of region or count, whatever is lower
char* perfmon_getEventName ( int  groupId,
int  eventId 
)

Get the event name of the specified group and event.

Get the metric name as defined in the performance group file

Parameters
[in]groupIdID of the group that should be read
[in]eventIdID of the event that should be returned
Returns
The event name or NULL in case of failure
int perfmon_getEventsOfRegion ( int  region)

Get the number of events of a region.

Parameters
[in]regionID of region
Returns
Number of events of region
char* perfmon_getGroupInfoLong ( int  groupId)

Get the long descriptive string of the specified group.

Returns the long descriptive string as defined by performance groups or NULL in case of custom event sets

Parameters
[in]groupIdID of the group that should be read
Returns
The long description or NULL in case of failure
char* perfmon_getGroupInfoShort ( int  groupId)

Get the short informational string of the specified group.

Returns the short information string as defined by performance groups or "Custom" in case of custom event sets

Parameters
[in]groupIdID of the group that should be read
Returns
The short information or NULL in case of failure
char* perfmon_getGroupName ( int  groupId)

Get the name group.

Get the name of group. Either it is the name of the performance group or "Custom"

Parameters
[in]groupIdID of the group that should be read
Returns
The group name or NULL in case of failure
int perfmon_getGroupOfRegion ( int  region)

Get the groupID of a region.

Parameters
[in]regionID of region
Returns
Group ID of region
int perfmon_getGroups ( char ***  groups,
char ***  shortinfos,
char ***  longinfos 
)

Get all groups.

Checks the configured performance group path for the current architecture and returns all found group names

Returns
Amount of found performance groups
int perfmon_getIdOfActiveGroup ( void  )

Get the ID of the currently set up event group.

Returns
Number of active group
double perfmon_getLastMetric ( int  groupId,
int  metricId,
int  threadId 
)

Get the last metric result of the specified group, counter and thread.

Get the metric result of the last measurement cycle. It reads all raw results for the given groupId and threadId.

Parameters
[in]groupIdID of the group that should be read
[in]metricIdID of the metric that should be calculated
[in]threadIdID of the thread/cpu that should be read
Returns
The metric result
double perfmon_getLastResult ( int  groupId,
int  eventId,
int  threadId 
)

Get the last results of the specified group, counter and thread.

Get the result of the last measurement cycle. The function takes care of happened overflows and if the counter values need to be calculated with multipliers.

Parameters
[in]groupIdID of the group that should be read
[in]eventIdID of the event that should be read
[in]threadIdID of the thread/cpu that should be read
Returns
The counter result
double perfmon_getLastTimeOfGroup ( int  groupId)

Get the last measurement time a group.

Parameters
[in]groupIdID of group
Returns
Time in seconds the event group was measured the last time
double perfmon_getMetric ( int  groupId,
int  metricId,
int  threadId 
)

Get the metric result of the specified group, counter and thread.

Get the metric result of all measurement cycles. It reads all raw results for the given groupId and threadId.

Parameters
[in]groupIdID of the group that should be read
[in]metricIdID of the metric that should be calculated
[in]threadIdID of the thread/cpu that should be read
Returns
The metric result
char* perfmon_getMetricName ( int  groupId,
int  metricId 
)

Get the metric name of the specified group and metric.

Get the metric name as defined in the performance group file

Parameters
[in]groupIdID of the group that should be read
[in]metricIdID of the metric that should be calculated
Returns
The metric name or NULL in case of failure
double perfmon_getMetricOfRegionThread ( int  region,
int  metricId,
int  threadId 
)

Get the metric result of a region for a metric and thread.

Parameters
[in]regionID of region
[in]metricIdID of metric
[in]threadIdID of thread
Returns
Metric result of a region for a thread
int perfmon_getMetricsOfRegion ( int  region)

Get the number of metrics of a region.

Parameters
[in]regionID of region
Returns
Number of metrics of region
int perfmon_getNumberOfEvents ( int  groupId)

Get the number of configured eventSets in group.

Parameters
[in]groupIdID of group
Returns
Number of eventSets
int perfmon_getNumberOfGroups ( void  )

Get the number of configured event groups.

Returns
Number of groups
int perfmon_getNumberOfMetrics ( int  groupId)

Get the number of configured metrics for group.

Parameters
[in]groupIdID of group
Returns
Number of metrics
int perfmon_getNumberOfRegions ( )

Get the number of regions listed in Marker API result file.

Returns
Number of regions
int perfmon_getNumberOfThreads ( void  )

Get the number of threads specified at perfmon_init()

Returns
Number of threads
double perfmon_getResult ( int  groupId,
int  eventId,
int  threadId 
)

Get the results of the specified group, counter and thread.

Get the result of all measurement cycles. The function takes care of happened overflows and if the counter values need to be calculated with multipliers.

Parameters
[in]groupIdID of the group that should be read
[in]eventIdID of the event that should be read
[in]threadIdID of the thread/cpu that should be read
Returns
The counter result
double perfmon_getResultOfRegionThread ( int  region,
int  event,
int  thread 
)

Get the event result of a region for an event and thread.

Parameters
[in]regionID of region
[in]eventID of event
[in]threadID of thread
Returns
Result of a region for an event and thread
char* perfmon_getTagOfRegion ( int  region)

Get the tag of a region.

Parameters
[in]regionID of region
Returns
tag of region
int perfmon_getThreadsOfRegion ( int  region)

Get the number of threads of a region.

Parameters
[in]regionID of region
Returns
Number of threads of region
double perfmon_getTimeOfGroup ( int  groupId)

Get the accumulated measurement time a group.

Parameters
[in]groupIdID of group
Returns
Time in seconds the event group was measured
double perfmon_getTimeOfRegion ( int  region,
int  thread 
)

Get the accumulated measurement time of a region for a thread.

Parameters
[in]regionID of region
[in]threadID of thread
Returns
Measurement time of a region for a thread
int perfmon_init ( int  nrThreads,
const int *  threadsToCpu 
)

Initialize performance monitoring facility.

Initialize the performance monitoring feature by creating basic data structures. The access mode must already be set when calling perfmon_init()

Parameters
[in]nrThreadsAmount of threads
[in]threadsToCpuList of CPUs
Returns
error code (0 on success, -ERRORCODE on failure)
void perfmon_init_maps ( void  )

Initialize performance monitoring maps.

Initialize the performance monitoring maps for counters, events and Uncore boxes# for the current architecture. topology_init() and numa_init() must be called before calling perfmon_init_maps()

See also
RegisterMap list, PerfmonEvent list and BoxMap list
int perfmon_readCounters ( void  )

Read the performance monitoring counters on all CPUs.

Read the counters that have been previously started by perfmon_startCounters(). The counters are stopped directly to avoid interference of LIKWID with the measured code. Before returning, the counters are started again.

Returns
0 on success and -(thread_id+1) for error
int perfmon_readCountersCpu ( int  cpu_id)

Read the performance monitoring counters on one CPU.

Read the counters that have been previously started by perfmon_startCounters(). The counters are stopped directly to avoid interference of LIKWID with the measured code. Before returning, the counters are started again. Only one CPU is read.

Parameters
[in]cpu_idCPU ID of the CPU that should be read
Returns
0 on success and -(thread_id+1) for error
int perfmon_readGroupCounters ( int  groupId)

Read the performance monitoring counters of all threads in a group.

Read the counters that have been previously started by perfmon_startCounters(). The counters are stopped directly to avoid interference of LIKWID with the measured code. Before returning, the counters are started again.

Parameters
[in]groupIdRead the counters for all threads taking part in group
Returns
0 on success and -(thread_id+1) for error
int perfmon_readGroupThreadCounters ( int  groupId,
int  threadId 
)

Read the performance monitoring counters of on thread in a group.

Read the counters that have been previously started by perfmon_startCounters(). The counters are stopped directly to avoid interference of LIKWID with the measured code. Before returning, the counters are started again. Only one thread's CPU is read.

Parameters
[in]groupIdRead the counters defined in group identified with groupId
[in]threadIdRead the counters for the thread
Returns
0 on success and -(thread_id+1) for error
int perfmon_readMarkerFile ( const char *  filename)

Read the output file of the Marker API.

Parameters
[in]filenameFilename with Marker API results
Returns
0 or negative error number
void perfmon_returnGroups ( int  nrgroups,
char **  groups,
char **  shortinfos,
char **  longinfos 
)

Free all group information.

Parameters
[in]nrgroupsNumber of groups
[in]groupsList of group names
[in]shortinfosList of short information string about group
[in]longinfosList of long information string about group
int perfmon_setupCounters ( int  groupId)

Setup all performance monitoring counters of an eventSet.

A event string looks like Eventname:Countername(:Option1:Option2:...),... The eventname, countername and options are checked if they are available.

Parameters
[in]groupId(returned from perfmon_addEventSet()
Returns
error code (-ENOENT if groupId is invalid and -1 if the counters of one CPU cannot be set up)
void perfmon_setVerbosity ( int  verbose)

Set verbosity of LIKWID library.

int perfmon_startCounters ( void  )

Start performance monitoring counters.

Start the counters that have been previously set up by perfmon_setupCounters(). The counter registered are zeroed before enabling the counters

Returns
0 on success and -(thread_id+1) for error
int perfmon_stopCounters ( void  )

Stop performance monitoring counters.

Stop the counters that have been previously started by perfmon_startCounters(). All config registers get zeroed before reading the counter register.

Returns
0 on success and -(thread_id+1) for error
int perfmon_switchActiveGroup ( int  new_group)

Switch the active eventSet to a new one.

Stops the currently running counters, switches the eventSet by setting up the counters and start the counters.

Parameters
[in]new_groupID of group that should be switched to.
Returns
0 on success and -(thread_id+1) for error

Variable Documentation

char* eventOptionTypeName[NUM_EVENT_OPTIONS]

List of option names.

List of strings for all event and counter options used for matching and output