LIKWID-PERFCTR(1)
๐ NAME ๐
okay bestie, gather round, because this is the manual page for likwid-perfctr, aka the iconic LIKWID-PERFCTR(1). It configures and reads out hardware performance counters on x86, ARM and POWER CPUs and Nvidia/AMD GPUs. That's the whole mission. ๐
โจ SYNOPSIS โจ
Here's the shape of it, no cap:
likwid-perfctr [-vhHmaiefO] [-c core_list] [-C core_list_for_pinning]
[-g performance_group or performance_event_string] [-t
timeline_frequency] [-S monitoring_time] [-T group_switch_frequency] [-V
verbosity] [-M access_mode] [-o output_file] [-s skip_mask] [-E
search_str] [-G nvidia_gpu_list(*)] [-W nvidia_gpu_performance_group or
nvidia_gpu_performance_event_string(*)] [-I amd_gpu_list(**)] [-R
amd_gpu_performance_group or amd_gpu_performance_event_string(**)]
[--stats]
๐ฆ DESCRIPTION ๐ฆ
likwid-perfctr is a lightweight command line application that configures and reads out hardware performance monitoring data on supported x86, ARM and POWER processors and Nvidia GPUs. It can measure either as a wrapper โ without changing the measured application โ or with marker API functions inside the code, which will turn counters on and off. ๐
There are preconfigured performance groups with useful event sets and derived metrics. And if you're feeling spicy, arbitrary events can be measured with custom event sets. The marker API can measure multiple named regions, and the results are accumulated over multiple region calls. periodt. ๐
(*)OptiononlyavailableifbuiltwithNvidiaGPUsupport
(**)OptiononlyavailableifbuiltwithAMDGPUsupport
๐ OPTIONS ๐
-v,--versionโ prints version information to standard output, then exits. bye bestie โจ-h,--helpโ prints a help message to standard output, then exits.-Hโ prints group help message (use together with-gswitch).-V <level>,--verbose <level>โ verbose output during execution for debugging.0for only errors,1for informational output,2for detailed output and3for developer output. yes, the levels are giving observability. ๐-m,--markerโ run in marker API mode.-aโ print available performance groups for current processor, then exit.-eโ print available counters and performance events of current processor and (if available) Nvidia or AMD GPUs. slay. ๐-o,--output <filename>โ store all output to a file instead of stdout. For the filename the following placeholders are supported:%jforPBS_JOBID,%rfor MPI RANK (only Intel MPI at the moment),%hhost name and%pfor process pid. The placeholders must be separated by underscore as, e.g.,-o test_%h_%p. You must specify a suffix to the filename. Fortxtthe output is printed as is to the file. Other suffixes trigger a filter on the output. Available filters arecsv(comma separated values),xmlandjsonat the moment.-Oโ print output in CSV format (conform to RFC 4180, seehttps://tools.ietf.org/html/rfc4180for details).-i,--infoโ print cpuid information about processor and about Intel Performance Monitoring features, then exit.-c <cpu expression>โ specify a numerical list of processors. The list may contain multiple items, separated by comma, and ranges. For example0,3,9-11.-C <cpu expression>โ specify a numerical list of processors. The list may contain multiple items, separated by comma, and ranges. For example0,3,9-11. This variant will also pin the threads to the cores. Also logical numberings can be used.-g,--group <performance group>or<performance event set string>โ specify which performance group to measure. This can be one of the tags output with the-aflag. Also a custom event set can be specified by a comma separated list of events. Each event has the formateventId:registerwith the register being one of a architecture supported performance counter registers. ๐ซ-t <frequency of measurements>โ timeline mode for time resolved measurements. The time unit must be given on command line, e.g.4s,500msor900us. Not supported for Nvidia and AMD GPUs.-S <waittime between measurements>โ End-to-end measurement usinglikwid-perfctrbut sleep instead of executing an application. The time unit must be given on command line, e.g.4s,500msor900us.-T <time between group switches>โ Frequency to switch groups if multiple are given on commandline, default is2s. Value is ignored for a single event set and default frequency of30sis used to catch overflows. The time unit must be given on command line, e.g.4s,500msor900us.-s,--skip <mask>โ Specify skip mask as HEX number. For each set bit the corresponding thread is skipped.-f,--forceโ Force writing of registers even if they are in use. bold move, but okay. ๐ฅ-E <search_str>โ Print only events and corresponding counters matching<search_str>-G <nvidia_gpu_list>โ specify a numerical list of Nvidia GPU IDs. The list may contain multiple items, separated by comma, and ranges. For example0,3,9-11.-W,--cudagroup <nvidia_gpu_performance_group>or<nvidia_gpu_performance_event_string>โ specify which performance group to measure on the specified Nvidia GPUs. This can be one of the tags output with the-aflag in the GPU section. Also a custom event set can be specified by a comma separated list of events. Each event has the formateventId:GPUx(x=0,1,2,...). You can add as many events to the string until you hit an error.-I <amd_gpu_list>โ specify a numerical list of AMD GPU IDs. The list may contain multiple items, separated by comma, and ranges. For example0,3,9-11.-R,--rocmgroup <amd_gpu_performance_group>or<amd_gpu_performance_event_string>โ specify which performance group to measure on the specified AMD GPUs. This can be one of the tags output with the-aflag in the GPU section. Also a custom event set can be specified by a comma separated list of events. Each event has the formateventId:GPUx(x=0,1,2,...). You can add as many events to the string until you hit an error.--statsโ Always print statistics table
๐ EXAMPLE ๐
Because likwid-perfctr measures on processors and not single applications it is necessary to ensure that processes and threads are pinned to dedicated resources. You can either pin the application yourself or use the builtin pin functionality. let's get into it. ๐ซถ
- As wrapper with performance group:
likwid-perfctr -C 0-2 -g TLB ./cacheBench -n 2 -l 1048576 -i 100 -t
Stream
The parent process is pinned to processor 0, Thread 0 to processor 1 and Thread 1 to processor 2.
- As wrapper with custom event set on AMD:
likwid-perfctr -C 0-4 -g
INSTRUCTIONS_RETIRED_SSE:PMC0,CPU_CLOCKS_UNHALTED:PMC3 ./cacheBench
It is specified that the event INSTRUCTIONS_RETIRED_SSE is measured on counter PMC0 and the event CPU_CLOCKS_UNHALTED on counter PMC3. It is possible calculate the run time of all threads based on the CPU_CLOCKS_UNHALTED event. If you want this you have to include this event in your custom event string as shown above.
- As wrapper with custom event set on Intel:
likwid-perfctr -C 0 -g
INSTR_RETIRED_ANY:FIXC0,CPU_CLK_UNHALTED_CORE:FIXC1 ./stream-icc
On Intel processors fixed events are measured on dedicated counters. These are INSTR_RETIRED_ANY and CPU_CLK_UNHALTED_CORE. If you configure these fixed counters, likwid-perfctr will calculate the run time and CPI metrics for your run.
- Using the marker API to measure only parts of your code (this can be used both with groups or custom event sets):
likwid-perfctr -m -C 0-4 -g
INSTRUCTIONS_RETIRED_SSE:PMC0,CPU_CLOCKS_UNHALTED:PMC3 ./cacheBench
You have to link you code against liblikwid.so and use the marker API calls. Examples can be found in examples folder /usr/share/likwid/examples. The following code snippet shows the necessary calls:
#include <likwid-marker.h>
/* only one thread calls init */
LIKWID_MARKER_INIT;
/* Can be called by each thread the should
* perform measurements. It is only needed
* if the pinning feature of LIKWID failed
* and the threads need to be pinned explicitly.
*
* If you place it in the same parallel
* region as LIKWID_MARKER_START, perform a
* barrier between the statements to avoid
* timing problems.
*/
LIKWID_MARKER_THREADINIT;
/* If you run the code region only once, register
* the region tag previously to reduce the overhead
* of START and STOP calls. Call it once for each
* thread in parallel environment.
* Note: No whitespace characters are allowed in the region tags
* This call is optional but RECOMMENDED, START will do the same operations.
*/
LIKWID_MARKER_REGISTER("name");
/* Start measurement
* Note: No whitespace characters are allowed in the region tags
*/
LIKWID_MARKER_START("name");
/*
* Your code to be measured is here
* You can also nest named regions
* No whitespaces are allowed in the region names!
*/
LIKWID_MARKER_STOP("name");
/* If you want to measure multiple groups/event sets
* Switches through groups in round-robin fashion
*/
LIKWID_MARKER_SWITCH;
/* If you want to get the data of a region inside your application
* nevents in an (int*) and used as input length of the events array. After the
* call, nevents contains the actual amount of events
* events is an array of doubles (double*), time is a pointer to double to
* retrieve the measured runtime of the region and count is a pointer to int
* and is filled with the call count of the region.
*/
LIKWID_MARKER_GET("name", nevents, events, time, count);
/* If you want to reset the counts for a region
*/
LIKWID_MARKER_RESET("name");
/* Finally */
LIKWID_MARKER_CLOSE;
- Using likwid in timeline mode:
likwid-perfctr -c 0-3 -g FLOPS_DP -t 300ms ./cacheBench > out.txt
This will read out the counters every 300ms on physical hardware threads 0-3 and write the results to out.txt. The application is not pinned to the CPUs. The output syntax of the timeline mode is for custom event sets:
<groupID> <numberOfEvents> <numberOfThreads> <Timestamp>
<Event1_Thread1> <Event2_Thread1> ... <Event1_Thread2> ...
<EventN_ThreadM>
For performance groups with metrics: <groupID> <numberOfMetrics> <numberOfThreads> <Timestamp> <Metric1_Thread1> <Metric2_Thread1> ... <Metric1_Thread2> ...<MetricN_ThreadM>
Oh, and for timeline mode there's a whole frontend application out there for you โ likwid-perfscope(1) โ and it enables live plotting of selected events. ๐โจ Just please be aware, bestie: with high frequencies (<100ms), the values differ from the real results. The behaviour of them is valid though, so it's still giving useful. ๐
6. likwid in stethoscope mode ๐ฉบ
likwid-perfctr -c 0-3 -g FLOPS_DP -S 2s
This starts the counters, reads them out after 2s on physical hardware threads 0-3, and writes the results to stdout. Lowkey the easiest way to just vibe-check your counters. ๐
7. likwid with counter options ๐๏ธ
likwid-perfctr -c S0:1@S1:1 -g LLC_LOOKUPS_DATA_READ:CBOX0C0:STATE=0x9 ./cacheBench
This programs the counter CBOX0C0 (that's counter 0 of the LLC cache box 0) to measure the event LLC_LOOKUPS_DATA_READ and filter the increments by the state of a cacheline. For this event, STATE=0x9 means all <invalid> and <modified> cachelines. Which options are allowed for which box is listed in LIKWID's html documentation, and the values for those options can be found in the vendors' performance monitoring documentations. Likwid measures the first CPU of socket 0 and the first CPU of socket 1. Wanna know the deets on cpu expressions? Go see likwid-pin(1). And for more code examples, have a look at the likwid WIKI pages and LIKWID's html documentation. ๐๐
7. likwid with GPU events and Nvmon MarkerAPI for Nvidia GPUs ๐ฎ
The CUDA library and CUPTI library must be reachable (library path in LD_LIBRARY_PATH). Manifesting that for you. ๐ซถ
likwid-perfctr -G 0,1 -W FLOPS_SP -m ./cudaApp
This runs the application in Nvmon MarkerAPI mode on GPUs 0 and 1 and measures the single-precision flops. The Nvmon MarkerAPI is similar to the CPU MarkerAPI (compile with -DLIKWID_NVMON):
#include <likwid-marker.h>
/* Initialize the library and add configured eventset */
NVMON_MARKER_INIT;
/* If you run the code region only once, register
* the region tag previously to reduce the overhead
* of START and STOP calls. Call it before calling START() for
* the region the first time.
*
* Place it around your CUDA kernel call.
*
* Note: No whitespace characters are allowed in the region tags
* This call is optional but RECOMMENDED, START will do the same
operations.
*/ NVMON_MARKER_REGISTER("name");
/* Start measurement on Nvidia GPUs
* Note: No whitespace characters are allowed in the region tags
*/ NVMON_MARKER_START("name"); /*
* Your code to be measured is here
* You can also nest named regions
*/
/* Stop measurment on Nvidia GPUs
* No whitespaces are allowed in the region names!
*/ NVMON_MARKER_STOP("name");
/* If you want to measure multiple groups/event sets
* Switches through groups in round-robin fashion.
*/ NVMON_MARKER_SWITCH;
/* If you want to get the data of a region inside your application
* nevents in an (int*) and used as input length of the events array.
After the
* call, nevents contains the actual amount of events. Same for ngpus.
* events is an array of doubles (double*), time is a pointer to double
to
* retrieve the measured runtime of the region and count is a pointer to
int
* and is filled with the call count of the region.
*/ NVMON_MARKER_GET("name", ngpus, nevents, events, time, count);
/* If you want to reset the counts for a region
*/ NVMON_MARKER_RESET("name");
/* Finally */ NVMON_MARKER_CLOSE;
Bestie, note that no whitespace characters are allowed in the region tags. Not even one. Fr fr. ๐ญ
7. likwid with GPU events in wrapper mode ๐
Measuring given events from the start to the end of the given application. The CUDA library and CUPTI library must be reachable (path in LD_LIBRARY_PATH).
likwid-perfctr -G 0,1 -W FLOPS_DP ./cudaApp
The execution is limited to Nvidia GPUs 0 and 1. It counts the double-precision floating point operations (FLOPS_DP) for the application cudaApp. Slay. ๐ฅ
7. likwid with GPU events and Rocmon MarkerAPI for AMD GPUs ๐
The ROCM library must be reachable (library path in LD_LIBRARY_PATH) and ROCM_HOME should be defined in the environment, pointing to the base directory of the ROCm installation.
likwid-perfctr -I 0,1 -R FLOPS_SP -m ./rocmApp
This runs the application in Rocmon MarkerAPI mode on GPUs 0 and 1 and measures the single-precision flops. The Rocmon MarkerAPI is similar to the CPU MarkerAPI (compile with -DLIKWID_ROCMON):
#include <likwid-marker.h>
/* Initialize the library and add configured eventset */
ROCMON_MARKER_INIT;
/* If you run the code region only once, register
* the region tag previously to reduce the overhead
* of START and STOP calls. Call it before calling START() for
* the region the first time.
*
* Place it around your AMD GPU kernel call.
*
* Note: No whitespace characters are allowed in the region tags
* This call is optional but RECOMMENDED, START will do the same
operations.
*/ ROCMON_MARKER_REGISTER("name");
/* Start measurement on AMD GPUs
* Note: No whitespace characters are allowed in the region tags
*/ ROCMON_MARKER_START("name"); /*
* Your code to be measured is here
* You can also nest named regions
*/
/* Stop measurment on AMD GPUs
* No whitespaces are allowed in the region names!
*/ ROCMON_MARKER_STOP("name");
/* If you want to measure multiple groups/event sets
* Switches through groups in round-robin fashion.
*/ ROCMON_MARKER_SWITCH;
/* If you want to get the data of a region inside your application
* nevents in an (int*) and used as input length of the events array.
After the
* call, nevents contains the actual amount of events. Same for ngpus.
* events is an array of doubles (double*), time is a pointer to double
to
* retrieve the measured runtime of the region and count is a pointer to
int
* and is filled with the call count of the region.
*/ ROCMON_MARKER_GET("name", ngpus, nevents, events, time, count);
/* If you want to reset the counts for a region
*/ ROCMON_MARKER_RESET("name");
/* Finally */ ROCMON_MARKER_CLOSE;
7. likwid with GPU events using the Rocmon for AMD GPUs (wrapper mode) ๐
Measuring given events from the start to the end of the given application. The ROCM library must be reachable (path in LD_LIBRARY_PATH) and ROCM_HOME should be defined in the environment, pointing to the base directory of the ROCm installation.
likwid-perfctr -I 0,1 -R FLOPS_DP ./rocmApp
The execution is limited to AMD GPUs 0 and 1. It counts the double-precision floating point operations (FLOPS_DP) for the application cudaApp. ๐
โจ AUTHOR โจ
Written by Thomas Gruber <thomas.roehl@googlemail.com>. Absolute icon, we stan. ๐
๐ BUGS ๐
Report Bugs on <https://github.com/RRZE-HPC/likwid/issues>. If something is acting up, tell them, don't suffer in silence bestie. ๐ซถ
๐ธ SEE ALSO ๐ธ
And that's the whole page, bestie! ๐ This was likwid-5 from 23.12.2025, filed under LIKWID-PERFCTR(1). Go forth and measure responsibly. ๐
โจ๐ฆ
๐ฆ where this page comes from
- ubuntu stonking: likwid 5.5.1+dfsg-2 ยท GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms