9#if !defined(_PAPI_CPU_COMPONENT_NAME)
10#define _PAPI_CPU_COMPONENT_NAME "perf_event"
19 int event_counter = 0;
22 int event_qual_i, event_i;
30 for(cid = 0; cid < ncomps; ++cid)
44 if (NULL == (stock->
evtsizes = (
int*)calloc( (tmp_event_count),
sizeof(
int) ))) {
45 fprintf(
stderr,
"Failed allocation of stock->evtsizes.\n");
49 if (NULL == (stock->
base_evts = (
char**)malloc( (tmp_event_count)*
sizeof(
char*) ))) {
50 fprintf(
stderr,
"Failed allocation of stock->base_evts.\n");
54 if (NULL == (stock->
evts = (
char***)malloc((tmp_event_count)*
sizeof(
char**)))) {
55 fprintf(
stderr,
"Failed allocation of stock->evts.\n");
59 if (NULL == (stock->
maxqualsize = (
size_t *)calloc( tmp_event_count,
sizeof(
size_t) ))) {
60 fprintf(
stderr,
"Failed allocation of stock->maxqualsize.\n");
67 if( 0 == tmp_event_count ){
76 fprintf(
stderr,
"ERROR: CPU component does not contain any events. Exiting");
81 int i, max_qual_count = 32;
82 size_t max_qual_len, tmp_qual_len;
83 memset(&info,0,
sizeof(info));
84 event_qual_i = event_i;
87 if( event_counter >= tmp_event_count ){
89 stock->
evts = (
char ***)realloc( stock->
evts, tmp_event_count*
sizeof(
char **) );
90 stock->
evtsizes = (
int *)realloc( stock->
evtsizes, tmp_event_count*
sizeof(
int) );
91 stock->
base_evts = (
char **)realloc( stock->
base_evts, tmp_event_count*
sizeof(
char *) );
95 if (NULL == (stock->
evts[event_counter] = (
char**)malloc( max_qual_count*
sizeof(
char*) )) ) {
96 fprintf(
stderr,
"Failed allocation of stock->evts[i].\n");
122 if( NULL != strstr(info.
symbol,
"=") )
125 col_pos = rindex(info.
symbol,
':');
126 if ( NULL == col_pos ){
131 if( subctr >= max_qual_count ){
133 stock->
evts[event_counter] = (
char **)realloc( stock->
evts[event_counter], max_qual_count*
sizeof(
char *) );
137 stock->
evts[event_counter][subctr] = strdup(col_pos+1);
138 tmp_qual_len = strlen( stock->
evts[event_counter][subctr] ) + 1;
139 if( tmp_qual_len > max_qual_len )
140 max_qual_len = tmp_qual_len;
144 stock->
evtsizes[event_counter] = subctr;
149 stock->
size = event_counter;
161 for(
i = 0;
i < stock->
size; ++
i)
190 return stock->
evts[base_evt][tag];
203 for(
i = 0;
i < stock->
size; ++
i)
208 if (stock->
evts[
i][j])
209 free(stock->
evts[
i][j]);
212 free(stock->
evts[
i]);
Enumerate PAPI preset or native events for a given component.
get information about a specific software component
Get the event's name and description info.
Get the number of components available on the system.
int num_evts(evstock *stock)
#define _PAPI_CPU_COMPONENT_NAME
void remove_stock(evstock *stock)
int build_stock(evstock *stock)
size_t max_qual_size(evstock *stock, int base_evt)
int num_quals(evstock *stock, int base_evt)
char * evt_name(evstock *stock, int index)
void print_stock(evstock *stock)
char * evt_qual(evstock *stock, int base_evt, int tag)
#define PAPI_NTV_ENUM_UMASKS
Return codes and api definitions.
char name[PAPI_MAX_STR_LEN]
char symbol[PAPI_HUGE_STR_LEN]