Performance-Monitoring Counters Library, for Intel/AMD Processors and Linux
This example introduces
   pmc_lib.h           -- include file, required
   libpmc.a            -- library archive, required
   Compiler options    -- the complete list
   pmc_options         -- as configured
   exit()              -- for a clean exit

Download this example
Next example           -- pmc_control_t
Return to Main Menu

Compile with gcc -o menu0 -O `pmc_options` -I. menu0.c -L. -lpmc Try this example: menu0
#include <pmc_lib.h> int main(int argc, char * argv[]) { exit(0); }
Synopsis #include <pmc_lib.h>
The include file pmc_lib.h is necessary. If it is installed in a directory normally on your search path, you should omit "-I." from the compilation. Similarly, "-L." should be omitted if the library archive libpmc.a is easily located. Usually the directories will be /usr/local/include for pmc_lib.h /usr/local/lib for libpmc.a /usr/local/bin for rabbit, pmc_options, ... The environment variables C_INCLUDE_PATH and LIBRARY_PATH used by gcc can be set for your installation. pmc_lib.h will itself include some other files with definitions of datatypes and various machine-dependent constants. The compiler option -DPMC_P6 (or -DPMC_P5 for a Pentium, or -DPMC_K7 for an Athlon) is necessary. The library should have been compiled for the same processor type. There is an underlying /dev/pmc module which should again have been compiled for the same processor type, and this should agree with the actual processor. All this can be checked with 'rabbit -v' or 'menu2 -v' where pmc_getargs() is used. The command pmc_options should be used to obtain the compiler options set by the installation. For example, on a 450-MHz Pentium II, `pmc_options` would normally be -DPMC_P6 -DPMC_MMX -DPMC_MHZ=450. Use exit(0) instead of return 0. This will ensure that files opened by the library are closed properly, and configuration settings are returned to their original values. As will be seen with pmc_open() in a later example, pmc_close() is invoked through the ANSI C atexit(). Do not use _exit().
The following constants are defined in pmc_lib.h for use as status return values for the rabbit program: RABBIT_SUCCESS 0 no error detected, no program attempted RABBIT_FAILURE 1 error detected, no program attempted RABBIT_NO_STATUS 2 no error detected; program ran with abnormal exit RABBIT_DID_NOT_FORK 126 error detected, could not fork RABBIT_DID_NOT_RUN 126 error detected, child process did not run RABBIT_DID_NOT_FIND 127 error detected, child process not found These are intended to be consistent with the GNU /bin/time program, but might not be useful in other circumstances.
Forward References, Man Pages pmc_getargs(), /dev/pmc, pmc_open(), pmc_close() gcc(1), exit(3), atexit(3), time(1) [if installed]

Performance-Monitoring Counters Library, for Intel/AMD Processors and Linux
Author: Don Heller,
Last revised: 2 August 2000