PAPI 7.1.0.0
Loading...
Searching...
No Matches
vendor_profiler_v1.c File Reference
Include dependency graph for vendor_profiler_v1.c:

Go to the source code of this file.

Data Structures

struct  ntv_event_t
 
struct  ntv_event_table_t
 
struct  vendorp_ctx_t
 
struct  event_info_t
 

Macros

#define EVENTS_WIDTH   (sizeof(uint32_t) * 8)
 
#define DEVICE_WIDTH   (7)
 
#define OPCODE_WIDTH   (1)
 
#define QLMASK_WIDTH   (2)
 
#define NAMEID_WIDTH   (2)
 
#define UNUSED_WIDTH   (EVENTS_WIDTH - DEVICE_WIDTH - OPCODE_WIDTH - QLMASK_WIDTH - NAMEID_WIDTH)
 
#define DEVICE_SHIFT   (EVENTS_WIDTH - UNUSED_WIDTH - DEVICE_WIDTH)
 
#define OPCODE_SHIFT   (DEVICE_SHIFT - OPCODE_WIDTH)
 
#define QLMASK_SHIFT   (OPCODE_SHIFT - QLMASK_WIDTH)
 
#define NAMEID_SHIFT   (QLMASK_SHIFT - NAMEID_WIDTH)
 
#define DEVICE_MASK   ((0xFFFFFFFF >> (EVENTS_WIDTH - DEVICE_WIDTH)) << DEVICE_SHIFT)
 
#define OPCODE_MASK   ((0xFFFFFFFF >> (EVENTS_WIDTH - OPCODE_WIDTH)) << OPCODE_SHIFT)
 
#define QLMASK_MASK   ((0xFFFFFFFF >> (EVENTS_WIDTH - QLMASK_WIDTH)) << QLMASK_SHIFT)
 
#define NAMEID_MASK   ((0xFFFFFFFF >> (EVENTS_WIDTH - NAMEID_WIDTH)) << NAMEID_SHIFT)
 
#define DEVICE_FLAG   (0x2)
 
#define OPCODE_FLAG   (0x1)
 
#define OPCODE_EXP   (0x0)
 
#define OPCODE_SUM   (0x1)
 

Functions

int vendorp1_init_pre (void)
 
static int load_profiler_v1_symbols (void)
 
static int unload_profiler_v1_symbols (void)
 
static int initialize_event_table (void)
 
static int finalize_event_table (void)
 
static int evt_id_create (event_info_t *info, uint32_t *event_id)
 
static int evt_id_to_info (uint32_t event_id, event_info_t *info)
 
static int evt_name_to_device (const char *name, int *device)
 
static int evt_name_to_opcode (const char *name, int *opcode)
 
static int evt_name_to_basename (const char *name, char *base, int len)
 
int vendorp1_init (void)
 
int vendorp1_shutdown (void)
 
static int init_ctx (unsigned int *events_id, int num_events, vendorp_ctx_t ctx)
 
static int open_ctx (vendorp_ctx_t ctx)
 
static int close_ctx (vendorp_ctx_t ctx)
 
static int finalize_ctx (vendorp_ctx_t ctx)
 
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)
 
static int get_events_count (int *num_events)
 
static int get_events (ntv_event_t *events, int num_events)
 
int open_ctx (vendorp_ctx_t ctx __attribute__((unused)))
 
int close_ctx (vendorp_ctx_t ctx __attribute__((unused)))
 

Variables

struct {
   char *   name
 
   char *   descr
 
vendor_events []
 
static ntv_event_table_t ntv_table
 
static ntv_event_table_tntv_table_p
 

Macro Definition Documentation

◆ DEVICE_FLAG

#define DEVICE_FLAG   (0x2)

Definition at line 33 of file vendor_profiler_v1.c.

◆ DEVICE_MASK

#define DEVICE_MASK   ((0xFFFFFFFF >> (EVENTS_WIDTH - DEVICE_WIDTH)) << DEVICE_SHIFT)

Definition at line 29 of file vendor_profiler_v1.c.

◆ DEVICE_SHIFT

#define DEVICE_SHIFT   (EVENTS_WIDTH - UNUSED_WIDTH - DEVICE_WIDTH)

Definition at line 25 of file vendor_profiler_v1.c.

◆ DEVICE_WIDTH

#define DEVICE_WIDTH   (7)

Definition at line 20 of file vendor_profiler_v1.c.

◆ EVENTS_WIDTH

#define EVENTS_WIDTH   (sizeof(uint32_t) * 8)

Event identifier encoding format: +-----------------—+----—+-+–+–+ | unused | dev | | |id| +-----------------—+----—+-+–+–+

unused : 18 bits device : 7 bits ([0 - 127] devices) function : 1 bits (exponential or sum) qlmask : 2 bits (qualifier mask) nameid : 2 bits ([0 - 3] event names)

Definition at line 19 of file vendor_profiler_v1.c.

◆ NAMEID_MASK

#define NAMEID_MASK   ((0xFFFFFFFF >> (EVENTS_WIDTH - NAMEID_WIDTH)) << NAMEID_SHIFT)

Definition at line 32 of file vendor_profiler_v1.c.

◆ NAMEID_SHIFT

#define NAMEID_SHIFT   (QLMASK_SHIFT - NAMEID_WIDTH)

Definition at line 28 of file vendor_profiler_v1.c.

◆ NAMEID_WIDTH

#define NAMEID_WIDTH   (2)

Definition at line 23 of file vendor_profiler_v1.c.

◆ OPCODE_EXP

#define OPCODE_EXP   (0x0)

Definition at line 35 of file vendor_profiler_v1.c.

◆ OPCODE_FLAG

#define OPCODE_FLAG   (0x1)

Definition at line 34 of file vendor_profiler_v1.c.

◆ OPCODE_MASK

#define OPCODE_MASK   ((0xFFFFFFFF >> (EVENTS_WIDTH - OPCODE_WIDTH)) << OPCODE_SHIFT)

Definition at line 30 of file vendor_profiler_v1.c.

◆ OPCODE_SHIFT

#define OPCODE_SHIFT   (DEVICE_SHIFT - OPCODE_WIDTH)

Definition at line 26 of file vendor_profiler_v1.c.

◆ OPCODE_SUM

#define OPCODE_SUM   (0x1)

Definition at line 36 of file vendor_profiler_v1.c.

◆ OPCODE_WIDTH

#define OPCODE_WIDTH   (1)

Definition at line 21 of file vendor_profiler_v1.c.

◆ QLMASK_MASK

#define QLMASK_MASK   ((0xFFFFFFFF >> (EVENTS_WIDTH - QLMASK_WIDTH)) << QLMASK_SHIFT)

Definition at line 31 of file vendor_profiler_v1.c.

◆ QLMASK_SHIFT

#define QLMASK_SHIFT   (OPCODE_SHIFT - QLMASK_WIDTH)

Definition at line 27 of file vendor_profiler_v1.c.

◆ QLMASK_WIDTH

#define QLMASK_WIDTH   (2)

Definition at line 22 of file vendor_profiler_v1.c.

◆ UNUSED_WIDTH

#define UNUSED_WIDTH   (EVENTS_WIDTH - DEVICE_WIDTH - OPCODE_WIDTH - QLMASK_WIDTH - NAMEID_WIDTH)

Definition at line 24 of file vendor_profiler_v1.c.

Function Documentation

◆ close_ctx() [1/2]

int close_ctx ( vendorp_ctx_t ctx   __attribute__(unused))

Definition at line 523 of file vendor_profiler_v1.c.

524{
525 return PAPI_OK;
526}
#define PAPI_OK
Definition: f90papi.h:73

◆ close_ctx() [2/2]

static int close_ctx ( vendorp_ctx_t  ctx)
static
Here is the caller graph for this function:

◆ evt_id_create()

int evt_id_create ( event_info_t info,
uint32_t *  event_id 
)
static

Definition at line 559 of file vendor_profiler_v1.c.

560{
561 *event_id = (uint32_t)(info->device << DEVICE_SHIFT);
562 *event_id |= (uint32_t)(info->opcode << OPCODE_SHIFT);
563 *event_id |= (uint32_t)(info->flags << QLMASK_SHIFT);
564 *event_id |= (uint32_t)(info->nameid << NAMEID_SHIFT);
565 return PAPI_OK;
566}
#define NAMEID_SHIFT
#define DEVICE_SHIFT
#define OPCODE_SHIFT
#define QLMASK_SHIFT
Here is the caller graph for this function:

◆ evt_id_to_info()

int evt_id_to_info ( uint32_t  event_id,
event_info_t info 
)
static

Definition at line 569 of file vendor_profiler_v1.c.

570{
571 info->device = (int)((event_id & DEVICE_MASK) >> DEVICE_SHIFT);
572 info->opcode = (int)((event_id & OPCODE_MASK) >> OPCODE_SHIFT);
573 info->flags = (int)((event_id & QLMASK_MASK) >> QLMASK_SHIFT);
574 info->nameid = (int)((event_id & NAMEID_MASK) >> NAMEID_SHIFT);
575
576 if (info->device >= device_table_p->num_devices) {
577 return PAPI_ENOEVNT;
578 }
579
580 if (info->nameid >= ntv_table_p->num_events) {
581 return PAPI_ENOEVNT;
582 }
583
584 if (0 == strcmp(ntv_table_p->events[info->nameid].name, "TEMPLATE_FUNCTION") && 0 == info->flags) {
585 return PAPI_ENOEVNT;
586 }
587
588 return PAPI_OK;
589}
#define PAPI_ENOEVNT
Definition: f90papi.h:139
device_table_t * device_table_p
Definition: roc_common.c:19
int
Definition: sde_internal.h:89
char * name
Definition: roc_profiler.c:43
ntv_event_t * events
Definition: roc_profiler.c:50
#define QLMASK_MASK
static ntv_event_table_t * ntv_table_p
#define NAMEID_MASK
#define DEVICE_MASK
#define OPCODE_MASK
Here is the caller graph for this function:

◆ evt_name_to_basename()

int evt_name_to_basename ( const char *  name,
char *  base,
int  len 
)
static

Definition at line 625 of file vendor_profiler_v1.c.

626{
627 char *p = strstr(name, ":");
628 if (p) {
629 if (len < (int)(p - name)) {
630 return PAPI_EBUF;
631 }
632 strncpy(base, name, (size_t)(p - name));
633 } else {
634 if (len < (int) strlen(name)) {
635 return PAPI_EBUF;
636 }
637 strncpy(base, name, (size_t) len);
638 }
639 return PAPI_OK;
640}
#define PAPI_EBUF
Definition: f90papi.h:253
char * name
Here is the caller graph for this function:

◆ evt_name_to_device()

int evt_name_to_device ( const char *  name,
int device 
)
static

Definition at line 592 of file vendor_profiler_v1.c.

593{
594 *device = 0;
595 char *p = strstr(name, ":device=");
596 if (p) {
597 *device = (int) strtol(p + strlen(":device="), NULL, 10);
598 }
599 return PAPI_OK;
600}
Here is the caller graph for this function:

◆ evt_name_to_opcode()

int evt_name_to_opcode ( const char *  name,
int opcode 
)
static

Definition at line 603 of file vendor_profiler_v1.c.

604{
605 char basename[PAPI_MAX_STR_LEN] = { 0 };
607 if (0 == strcmp(basename, "TEMPLATE_FUNCTION")) {
608 char *p = strstr(name, ":function=");
609 if (p) {
610 if (strncmp(p + strlen(":function="), "exp", strlen("exp")) == 0) {
611 *opcode = OPCODE_EXP;
612 } else if (strncmp(p + strlen(":function="), "sum", strlen("sum")) == 0) {
613 *opcode = OPCODE_SUM;
614 } else {
615 return PAPI_ENOEVNT;
616 }
617 } else {
618 return PAPI_ENOEVNT;
619 }
620 }
621 return PAPI_OK;
622}
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define OPCODE_SUM
static int evt_name_to_basename(const char *name, char *base, int len)
#define OPCODE_EXP
Here is the call graph for this function:
Here is the caller graph for this function:

◆ finalize_ctx()

int finalize_ctx ( vendorp_ctx_t  ctx)
static

Definition at line 529 of file vendor_profiler_v1.c.

530{
531 ctx->events_id = NULL;
532 ctx->num_events = 0;
533 papi_free(ctx->counters);
534 return PAPI_OK;
535}
#define papi_free(a)
Definition: papi_memory.h:35
Here is the caller graph for this function:

◆ finalize_event_table()

int finalize_event_table ( void  )
static

Definition at line 496 of file vendor_profiler_v1.c.

497{
500 ntv_table_p = NULL;
501 return PAPI_OK;
502}
Here is the caller graph for this function:

◆ get_events()

int get_events ( ntv_event_t events,
int  num_events 
)
static

Definition at line 547 of file vendor_profiler_v1.c.

548{
549 int i = 0;
550 while (vendor_events[i].name != NULL) {
551 snprintf(events[i].name, PAPI_MAX_STR_LEN, "%s", vendor_events[i].name);
552 snprintf(events[i].descr, PAPI_2MAX_STR_LEN, "%s", vendor_events[i].descr);
553 ++i;
554 }
555 return (num_events - i) ? PAPI_EMISC : PAPI_OK;
556}
int i
#define PAPI_EMISC
Definition: f90papi.h:122
#define PAPI_2MAX_STR_LEN
Definition: f90papi.h:180
char events[MAX_EVENTS][BUFSIZ]
static int num_events
static struct @9 vendor_events[]
char * descr
Here is the caller graph for this function:

◆ get_events_count()

int get_events_count ( int num_events)
static

Definition at line 538 of file vendor_profiler_v1.c.

539{
540 int i = 0;
541 while (vendor_events[i++].name != NULL);
542 *num_events = i - 1;
543 return PAPI_OK;
544}
Here is the caller graph for this function:

◆ init_ctx()

int init_ctx ( unsigned int events_id,
int  num_events,
vendorp_ctx_t  ctx 
)
static

Definition at line 505 of file vendor_profiler_v1.c.

506{
507 ctx->events_id = events_id;
508 ctx->num_events = num_events;
509 ctx->counters = papi_calloc(num_events, sizeof(long long));
510 if (NULL == ctx->counters) {
511 return PAPI_ENOMEM;
512 }
513 return PAPI_OK;
514}
#define PAPI_ENOMEM
Definition: f90papi.h:16
#define papi_calloc(a, b)
Definition: papi_memory.h:37
uint64_t * events_id
Here is the caller graph for this function:

◆ initialize_event_table()

int initialize_event_table ( void  )
static

Definition at line 466 of file vendor_profiler_v1.c.

467{
468 int papi_errno, num_events;
469
470 papi_errno = get_events_count(&num_events);
471 if (papi_errno != PAPI_OK) {
472 return papi_errno;
473 }
474
476 if (NULL == events) {
477 return PAPI_ENOMEM;
478 }
479
480 papi_errno = get_events(events, num_events);
481 if (papi_errno != PAPI_OK) {
482 goto fn_fail;
483 }
484
487
488 fn_exit:
489 return papi_errno;
490 fn_fail:
492 goto fn_exit;
493}
static int get_events_count(int *num_events)
static ntv_event_table_t ntv_table
static int get_events(ntv_event_t *events, int num_events)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_profiler_v1_symbols()

int load_profiler_v1_symbols ( void  )
static

Definition at line 451 of file vendor_profiler_v1.c.

452{
453 return PAPI_OK;
454}
Here is the caller graph for this function:

◆ open_ctx() [1/2]

int open_ctx ( vendorp_ctx_t ctx   __attribute__(unused))

Definition at line 517 of file vendor_profiler_v1.c.

518{
519 return PAPI_OK;
520}

◆ open_ctx() [2/2]

static int open_ctx ( vendorp_ctx_t  ctx)
static
Here is the caller graph for this function:

◆ unload_profiler_v1_symbols()

int unload_profiler_v1_symbols ( void  )
static

Definition at line 457 of file vendor_profiler_v1.c.

458{
459 return PAPI_OK;
460}
Here is the caller graph for this function:

◆ 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}
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 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}
long long int long long
Definition: sde_internal.h:85
static int evt_id_to_info(uint32_t event_id, event_info_t *info)
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
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
static nvmlDevice_t * devices
Definition: linux-nvml.c:146
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}
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_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 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:

Variable Documentation

◆ descr

char* descr

Definition at line 57 of file vendor_profiler_v1.c.

◆ name

char* name

Definition at line 56 of file vendor_profiler_v1.c.

◆ ntv_table

ntv_event_table_t ntv_table
static

Definition at line 65 of file vendor_profiler_v1.c.

◆ ntv_table_p

ntv_event_table_t* ntv_table_p
static

Definition at line 66 of file vendor_profiler_v1.c.

◆ 

struct { ... } vendor_events[]
Initial value:
= {
{ "TEMPLATE_ZERO" , "This is a template counter, that always returns 0" },
{ "TEMPLATE_CONSTANT", "This is a template counter, that always returns a constant value of 42" },
{ "TEMPLATE_FUNCTION", "This is a template counter, that allows for different functions" },
{ NULL, NULL }
}