PAPI 7.1.0.0
Loading...
Searching...
No Matches
vendor_profiler_v1.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int vendorp1_init_pre (void)
 
int vendorp1_init (void)
 
int vendorp1_shutdown (void)
 
int vendorp1_ctx_open (unsigned int *events_id, int num_events, vendorp_ctx_t *ctx)
 
int vendorp1_ctx_start (vendorp_ctx_t ctx)
 
int vendorp1_ctx_read (vendorp_ctx_t ctx, long long **counters)
 
int vendorp1_ctx_stop (vendorp_ctx_t ctx)
 
int vendorp1_ctx_reset (vendorp_ctx_t ctx)
 
int vendorp1_ctx_close (vendorp_ctx_t ctx)
 
int vendorp1_evt_enum (unsigned int *event_code, int modifier)
 
int vendorp1_evt_code_to_name (unsigned int event_code, char *name, int len)
 
int vendorp1_evt_code_to_descr (unsigned int event_code, char *descr, int len)
 
int vendorp1_evt_code_to_info (unsigned int event_code, PAPI_event_info_t *info)
 
int vendorp1_evt_name_to_code (const char *name, unsigned int *event_code)
 

Function Documentation

◆ vendorp1_ctx_close()

int vendorp1_ctx_close ( vendorp_ctx_t  ctx)

Definition at line 215 of file vendor_profiler_v1.c.

216{
217 int papi_errno;
218
220
221 papi_errno = close_ctx(ctx);
222 if (papi_errno != PAPI_OK) {
223 goto fn_fail;
224 }
225
226 ctx->state &= ~TEMPL_CTX_OPENED;
227
228 papi_errno = finalize_ctx(ctx);
229 if (papi_errno != PAPI_OK) {
230 goto fn_fail;
231 }
232
233 papi_free(ctx);
234
235 fn_exit:
237 return papi_errno;
238 fn_fail:
239 goto fn_exit;
240
241}
#define PAPI_OK
Definition: f90papi.h:73
#define papi_free(a)
Definition: papi_memory.h:35
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:69
inline_static int _papi_hwi_unlock(int lck)
Definition: threads.h:83
unsigned int _templ_lock
Definition: vendor_common.c:4
static int finalize_ctx(vendorp_ctx_t ctx)
static int close_ctx(vendorp_ctx_t ctx)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vendorp1_ctx_open()

int vendorp1_ctx_open ( unsigned int events_id,
int  num_events,
vendorp_ctx_t *  ctx 
)

Definition at line 132 of file vendor_profiler_v1.c.

133{
134 int papi_errno;
135
136 *ctx = papi_calloc(1, sizeof(struct vendord_ctx));
137 if (NULL == *ctx) {
138 return PAPI_ENOMEM;
139 }
140
142
143 papi_errno = init_ctx(events_id, num_events, *ctx);
144 if (papi_errno != PAPI_OK) {
145 goto fn_fail;
146 }
147
148 papi_errno = open_ctx(*ctx);
149 if (papi_errno != PAPI_OK) {
150 goto fn_fail;
151 }
152
153 (*ctx)->state |= TEMPL_CTX_OPENED;
154
155 fn_exit:
157 return papi_errno;
158 fn_fail:
159 close_ctx(*ctx);
160 finalize_ctx(*ctx);
161 goto fn_exit;
162}
#define PAPI_ENOMEM
Definition: f90papi.h:16
static int num_events
#define papi_calloc(a, b)
Definition: papi_memory.h:37
uint64_t * events_id
#define TEMPL_CTX_OPENED
Definition: vendor_config.h:4
static int init_ctx(unsigned int *events_id, int num_events, vendorp_ctx_t ctx)
static int open_ctx(vendorp_ctx_t ctx)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vendorp1_ctx_read()

int vendorp1_ctx_read ( vendorp_ctx_t  ctx,
long long **  counters 
)

Definition at line 172 of file vendor_profiler_v1.c.

173{
174 int papi_errno;
175
176 int i;
177 for (i = 0; i < ctx->num_events; ++i) {
178 event_info_t info;
179 papi_errno = evt_id_to_info(ctx->events_id[i], &info);
180 if (papi_errno != PAPI_OK) {
181 return papi_errno;
182 }
183
184 if (0 == strcmp(ntv_table_p->events[info.nameid].name, "TEMPLATE_ZERO")) {
185 ctx->counters[i] = (long long) 0;
186 } else if (0 == strcmp(ntv_table_p->events[info.nameid].name, "TEMPLATE_CONSTANT")) {
187 ctx->counters[i] = (long long) 42;
188 } else if (0 == strcmp(ntv_table_p->events[info.nameid].name, "TEMPLATE_FUNCTION")) {
189 if (info.opcode == OPCODE_EXP) {
190 ctx->counters[i] = (ctx->counters[i]) ? ctx->counters[i] * 2 : 2;
191 } else {
192 ctx->counters[i] = (ctx->counters[i]) ? ctx->counters[i] + 1 : 1;
193 }
194 }
195 }
196 *counters = ctx->counters;
197 return PAPI_OK;
198}
int i
long long int long long
Definition: sde_internal.h:85
char * name
Definition: roc_profiler.c:43
ntv_event_t * events
Definition: roc_profiler.c:50
static int evt_id_to_info(uint32_t event_id, event_info_t *info)
#define OPCODE_EXP
static ntv_event_table_t * ntv_table_p
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vendorp1_ctx_reset()

int vendorp1_ctx_reset ( vendorp_ctx_t  ctx)

Definition at line 208 of file vendor_profiler_v1.c.

209{
210 memset(ctx->counters, 0, sizeof(ctx->counters) * ctx->num_events);
211 return PAPI_OK;
212}
Here is the caller graph for this function:

◆ vendorp1_ctx_start()

int vendorp1_ctx_start ( vendorp_ctx_t  ctx)

Definition at line 165 of file vendor_profiler_v1.c.

166{
167 ctx->state |= TEMPL_CTX_RUNNING;
168 return PAPI_OK;
169}
#define TEMPL_CTX_RUNNING
Definition: vendor_config.h:5
Here is the caller graph for this function:

◆ vendorp1_ctx_stop()

int vendorp1_ctx_stop ( vendorp_ctx_t  ctx)

Definition at line 201 of file vendor_profiler_v1.c.

202{
203 ctx->state &= ~TEMPL_CTX_RUNNING;
204 return PAPI_OK;
205}
Here is the caller graph for this function:

◆ vendorp1_evt_code_to_descr()

int vendorp1_evt_code_to_descr ( unsigned int  event_code,
char *  descr,
int  len 
)

Definition at line 329 of file vendor_profiler_v1.c.

330{
331 int papi_errno;
332
333 event_info_t info;
334 papi_errno = evt_id_to_info(event_code, &info);
335 if (papi_errno != PAPI_OK) {
336 return papi_errno;
337 }
338
339 snprintf(descr, len, "%s", ntv_table_p->events[info.nameid].descr);
340 return PAPI_OK;
341}
char * descr
Definition: roc_profiler.c:44
char * descr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vendorp1_evt_code_to_info()

int vendorp1_evt_code_to_info ( unsigned int  event_code,
PAPI_event_info_t info 
)

Definition at line 344 of file vendor_profiler_v1.c.

345{
346 int papi_errno;
347
348 event_info_t code_info;
349 papi_errno = evt_id_to_info(event_code, &code_info);
350 if (papi_errno != PAPI_OK) {
351 return papi_errno;
352 }
353
354 switch (code_info.flags) {
355 case 0:
356 sprintf(info->symbol, "%s", ntv_table_p->events[code_info.nameid].name);
357 sprintf(info->long_descr, "%s", ntv_table_p->events[code_info.nameid].descr);
358 break;
360 sprintf(info->symbol, "%s:device=%i:function=%s",
361 ntv_table_p->events[code_info.nameid].name,
362 code_info.device,
363 (code_info.opcode == OPCODE_EXP) ? "exp" : "sum");
364 sprintf(info->long_descr, "%s", ntv_table_p->events[code_info.nameid].descr);
365 break;
366 case DEVICE_FLAG:
367 {
368 int i;
369 char devices[PAPI_MAX_STR_LEN] = { 0 };
370 for (i = 0; i < device_table_p->num_devices; ++i) {
371 sprintf(devices + strlen(devices), "%i,", i);
372 }
373 *(devices + strlen(devices) - 1) = 0;
374 sprintf(info->symbol, "%s:device=%i", ntv_table_p->events[code_info.nameid].name, code_info.device);
375 sprintf(info->long_descr, "%s masks:Device qualifier [%s]",
376 ntv_table_p->events[code_info.nameid].descr, devices);
377 break;
378 }
379 case OPCODE_FLAG:
380 sprintf(info->symbol, "%s:function=%s",
381 ntv_table_p->events[code_info.nameid].name,
382 (code_info.opcode == OPCODE_EXP) ? "exp" : "sum");
383 sprintf(info->long_descr, "%s masks:Mandatory function qualifier (exp,sum)",
384 ntv_table_p->events[code_info.nameid].descr);
385 break;
386 default:
387 papi_errno = PAPI_EINVAL;
388 }
389
390 return papi_errno;
391}
#define PAPI_EINVAL
Definition: f90papi.h:115
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
static nvmlDevice_t * devices
Definition: linux-nvml.c:146
device_table_t * device_table_p
Definition: roc_common.c:19
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:960
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
#define OPCODE_FLAG
#define DEVICE_FLAG
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vendorp1_evt_code_to_name()

int vendorp1_evt_code_to_name ( unsigned int  event_code,
char *  name,
int  len 
)

Definition at line 294 of file vendor_profiler_v1.c.

295{
296 int papi_errno;
297
298 event_info_t info;
299 papi_errno = evt_id_to_info(event_code, &info);
300 if (papi_errno != PAPI_OK) {
301 return papi_errno;
302 }
303
304 switch (info.flags) {
306 snprintf(name, len, "%s:device=%i:function=%s",
308 info.device, (info.opcode == OPCODE_EXP) ? "exp" : "sum");
309 break;
310 case DEVICE_FLAG:
311 snprintf(name, len, "%s:device=%i",
313 info.device);
314 break;
315 case OPCODE_FLAG:
316 snprintf(name, len, "%s:function=%s",
318 (info.opcode == OPCODE_EXP) ? "exp" : "sum");
319 break;
320 default:
321 papi_errno = PAPI_ENOEVNT;
322 }
323
324 snprintf(name, len, "%s", ntv_table_p->events[info.nameid].name);
325 return papi_errno;
326}
#define PAPI_ENOEVNT
Definition: f90papi.h:139
char * name
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vendorp1_evt_enum()

int vendorp1_evt_enum ( unsigned int event_code,
int  modifier 
)

Definition at line 244 of file vendor_profiler_v1.c.

245{
246 int papi_errno;
247
248 event_info_t info;
249 papi_errno = evt_id_to_info(*event_code, &info);
250 if (papi_errno != PAPI_OK) {
251 return papi_errno;
252 }
253
254 switch(modifier) {
255 case PAPI_ENUM_FIRST:
256 if (ntv_table_p->num_events == 0) {
257 papi_errno = PAPI_ENOEVNT;
258 }
259 info.device = 0;
260 info.opcode = 0;
261 info.flags = 0;
262 info.nameid = 0;
263 papi_errno = evt_id_create(&info, event_code);
264 break;
265 case PAPI_ENUM_EVENTS:
266 if (info.nameid + 1 >= ntv_table_p->num_events) {
267 papi_errno = PAPI_ENOEVNT;
268 break;
269 }
270 ++info.nameid;
271 papi_errno = evt_id_create(&info, event_code);
272 break;
274 if (info.flags == 0) {
275 info.flags = DEVICE_FLAG;
276 papi_errno = evt_id_create(&info, event_code);
277 break;
278 }
279 if (info.flags & DEVICE_FLAG && info.nameid == 2) {
280 info.flags = OPCODE_FLAG;
281 papi_errno = evt_id_create(&info, event_code);
282 break;
283 }
284 papi_errno = PAPI_END;
285 break;
286 default:
287 papi_errno = PAPI_EINVAL;
288 }
289
290 return papi_errno;
291}
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_END
Definition: f90papi.h:303
#define PAPI_NTV_ENUM_UMASKS
Definition: f90papi.h:66
static int evt_id_create(event_info_t *info, uint32_t *event_id)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vendorp1_evt_name_to_code()

int vendorp1_evt_name_to_code ( const char *  name,
unsigned int event_code 
)

Definition at line 394 of file vendor_profiler_v1.c.

395{
396 int papi_errno;
397
398 char basename[PAPI_MAX_STR_LEN] = { 0 };
399 papi_errno = evt_name_to_basename(name, basename, PAPI_MAX_STR_LEN);
400 if (papi_errno != PAPI_OK) {
401 return papi_errno;
402 }
403
404 int device;
405 papi_errno = evt_name_to_device(name, &device);
406 if (papi_errno != PAPI_OK) {
407 return papi_errno;
408 }
409
410 int opcode = 0;
411 papi_errno = evt_name_to_opcode(name, &opcode);
412 if (papi_errno != PAPI_OK) {
413 return papi_errno;
414 }
415
416 int i, nameid = 0;
417 for (i = 0; i < ntv_table_p->num_events; ++i) {
418 if (0 == strcmp(ntv_table_p->events[i].name, basename)) {
419 nameid = i;
420 break;
421 }
422 }
423
424 event_info_t info = { 0, 0, 0, 0 };
425 if (0 == strcmp(ntv_table_p->events[nameid].name, "TEMPLATE_FUNCTION")) {
426 info.device = device;
427 info.opcode = opcode;
428 info.flags = (DEVICE_FLAG | OPCODE_FLAG);
429 info.nameid = nameid;
430 papi_errno = evt_id_create(&info, event_code);
431 if (papi_errno != PAPI_OK) {
432 return papi_errno;
433 }
434 } else {
435 info.device = device;
436 info.opcode = 0;
437 info.flags = DEVICE_FLAG;
438 info.nameid = nameid;
439 papi_errno = evt_id_create(&info, event_code);
440 if (papi_errno != PAPI_OK) {
441 return papi_errno;
442 }
443 }
444
445 papi_errno = evt_id_to_info(*event_code, &info);
446
447 return papi_errno;
448}
static int evt_name_to_basename(const char *name, char *base, int len)
static int evt_name_to_opcode(const char *name, int *opcode)
static int evt_name_to_device(const char *name, int *device)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vendorp1_init()

int vendorp1_init ( void  )

Definition at line 93 of file vendor_profiler_v1.c.

94{
95 int papi_errno;
96
97 papi_errno = load_profiler_v1_symbols();
98 if (papi_errno != PAPI_OK) {
99 return papi_errno;
100 }
101
102 papi_errno = initialize_event_table();
103 if (papi_errno != PAPI_OK) {
104 goto fn_fail;
105 }
106
108
109 fn_exit:
110 return papi_errno;
111 fn_fail:
114 goto fn_exit;
115}
static int unload_profiler_v1_symbols(void)
static ntv_event_table_t ntv_table
static int finalize_event_table(void)
static int initialize_event_table(void)
static int load_profiler_v1_symbols(void)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vendorp1_init_pre()

int vendorp1_init_pre ( void  )

Definition at line 69 of file vendor_profiler_v1.c.

70{
71 return PAPI_OK;
72}
Here is the caller graph for this function:

◆ vendorp1_shutdown()

int vendorp1_shutdown ( void  )

Definition at line 118 of file vendor_profiler_v1.c.

119{
121 ntv_table_p = NULL;
123 return PAPI_OK;
124}
Here is the call graph for this function:
Here is the caller graph for this function: