PAPI3:PAPI encode events.3
#include <papi.h> int PAPI_encode_events(char * event_file, int replace);
NOTE: This API has been deprecated in PAPI 3.5 pending a data structure redesign. This function reads event descriptions from a file where they are stored in comma separated value format and modifies or adds events to the PAPI preset event table. The file format is described below. This function presently works only to define or modify PAPI preset events.
event_file -- string containing the name of the csv event file to be read
replace -- 1 to replace existing events, or 0 to prevent accidental replacement
PAPI_EPERM You are trying to modify an existing event without specifying replace.
PAPI_EISRUN You are trying to modify an event that has been added to an EventSet.
PAPI_EINVAL One or more of the arguments or fields of the info structure is invalid.
PAPI_ENOTPRESET The PAPI preset table is full and there is no room for a new event.
PAPI_ENOEVNT The event specified is not a PAPI preset. Usually because the PAPI_PRESET_MASK bit is not set.
This function has no known bugs.
FILE FORMATThe comma separated value file format is one that can be easily edited in a standard text editor or a csv-aware spreadsheet application, and can be easily parsed. Text strings can contain commas, but only if the strings are enclosed in quotes. Each entry in the file is a separate line, and each field, including empty fields, is separated by a comma from its neighbor. The specific format used in this case consists of a title line for readability, a blank line, and a series of lines containing event definitions. A portion of such a file (for Pentium 4) is shown below:
name,derived,postfix,short_descr,long_descr,note,[native,...] PAPI_L1_ICM,NOT_DERIVED,,"L1I cache misses","Level 1 instruction cache misses",,BPU_fetch_request_TCMISS PAPI_L2_TCM,NOT_DERIVED,,"L2 cache misses","Level 2 cache misses",,BSQ_cache_reference_RD_2ndL_MISS_WR_2ndL_MISS PAPI_TLB_DM,NOT_DERIVED,,"Data TLB misses","Data translation lookaside buffer misses",,page_walk_type_DTMISS MY_PAPI_TLB_DM,NOT_DERIVED,,"Data TLB misses","Data translation lookaside buffer misses","This is a note for my event",page_walk_type_DTMISS
/* Use the command line utility to create a csv copy of the currently defined events */ > /papi/utils/decode -a -> current.csv /* View and modify the events in an editor */ > vi current.csv ... /* Load the modified events into the preset table */ if (PAPI_encode_events("./current.csv", 1) != PAPI_OK) handle_error(1);