14{
15 int ret;
17 int cid;
19 int event_counter = 0;
20 int subctr = 0;
21 int tmp_event_count;
22 int event_qual_i, event_i;
23
24 if (!stock) return 1;
25
27
28
29 event_counter = 0;
30 for(cid = 0; cid < ncomps; ++cid)
31 {
34 continue;
35
39 }
40
42
43
44 if (NULL == (stock->
evtsizes = (
int*)calloc( (tmp_event_count),
sizeof(
int) ))) {
45 fprintf(
stderr,
"Failed allocation of stock->evtsizes.\n");
46 goto gracious_error;
47 }
48
49 if (NULL == (stock->
base_evts = (
char**)malloc( (tmp_event_count)*
sizeof(
char*) ))) {
50 fprintf(
stderr,
"Failed allocation of stock->base_evts.\n");
51 goto gracious_error;
52 }
53
54 if (NULL == (stock->
evts = (
char***)malloc((tmp_event_count)*
sizeof(
char**)))) {
55 fprintf(
stderr,
"Failed allocation of stock->evts.\n");
56 goto gracious_error;
57 }
58
59 if (NULL == (stock->
maxqualsize = (
size_t *)calloc( tmp_event_count,
sizeof(
size_t) ))) {
60 fprintf(
stderr,
"Failed allocation of stock->maxqualsize.\n");
61 goto gracious_error;
62 }
63
64 break;
65 }
66
67 if( 0 == tmp_event_count ){
69 goto gracious_error;
70 }
71
72
73
76 fprintf(
stderr,
"ERROR: CPU component does not contain any events. Exiting");
77 goto gracious_error;
78 }
79
80 do{
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;
85
86
87 if( event_counter >= tmp_event_count ){
88 tmp_event_count *= 2;
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 *) );
93 }
94
95 if (NULL == (stock->
evts[event_counter] = (
char**)malloc( max_qual_count*
sizeof(
char*) )) ) {
96 fprintf(
stderr,
"Failed allocation of stock->evts[i].\n");
97 goto gracious_error;
98 }
99
100 max_qual_len = 0;
101 subctr = 0;
103
104 do
105 {
106 char *col_pos;
109 continue;
110
112
113
116 continue;
117 }
118
119
120
121
122 if( NULL != strstr(info.
symbol,
"=") )
123 continue;
124
125 col_pos = rindex(info.
symbol,
':');
126 if ( NULL == col_pos ){
127 continue;
128 }
129
130
131 if( subctr >= max_qual_count ){
132 max_qual_count *= 2;
133 stock->
evts[event_counter] = (
char **)realloc( stock->
evts[event_counter], max_qual_count*
sizeof(
char *) );
134 }
135
136
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;
141 subctr++;
142
144 stock->
evtsizes[event_counter] = subctr;
146 event_counter++;
148
149 stock->
size = event_counter;
150 return 0;
151
152gracious_error:
153
155 return 1;
156}
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.
#define _PAPI_CPU_COMPONENT_NAME
void remove_stock(evstock *stock)
#define PAPI_NTV_ENUM_UMASKS
char name[PAPI_MAX_STR_LEN]
char symbol[PAPI_HUGE_STR_LEN]