PAPI 7.1.0.0
Loading...
Searching...
No Matches
papivi.h
Go to the documentation of this file.
1/****************************/
2/* THIS IS OPEN SOURCE CODE */
3/****************************/
4
5/*
6* File: papivi.h
7* CVS: $Id$
8* Author: dan terpstra
9* terpstra@cs.utk.edu
10* Mods: your name here
11* yourname@cs.esu.edu
12*
13* Include this file INSTEAD OF "papi.h" in your application code
14* to provide semitransparent version independent PAPI support.
15* Follow the rules described below and elsewhere to facilitate
16* this support.
17*
18*/
19
20#ifndef _PAPIVI
21#define _PAPIVI
22
23#include "papi.h"
24
25/***************************************************************************
26* If PAPI_VERSION is not defined, then papi.h is for PAPI 2.
27* The preprocessor block below contains the definitions, data structures,
28* macros and code needed to emulate much of the PAPI 3 interface in code
29* linking to the PAPI 2 library.
30****************************************************************************/
31#ifndef PAPI_VERSION
32
33
34#define PAPI_VERSION_NUMBER(maj,min,rev) (((maj)<<16) | ((min)<<8) | (rev))
35#define PAPI_VERSION_MAJOR(x) (((x)>>16) & 0xffff)
36#define PAPI_VERSION_MINOR(x) (((x)>>8) & 0xff)
37#define PAPI_VERSION_REVISION(x) ((x) & 0xff)
38
39/* This is the PAPI version on which we are running */
40#define PAPI_VERSION PAPI_VERSION_NUMBER(2,3,4)
41
42/* This is the PAPI 3 version with which we are compatible */
43#define PAPI_VI_VERSION PAPI_VERSION_NUMBER(3,0,6)
44
45/* PAPI 3 has an error code not defined for PAPI 2 */
46#define PAPI_EPERM PAPI_EMISC /* You lack the necessary permissions */
47
48/*
49* These are defined in papi_internal.h for PAPI 2.
50* They need to be exposed for version independent PAPI code to work.
51*/
52//#define PRESET_MASK 0x80000000
53#define PAPI_PRESET_MASK 0x80000000
54//#define PRESET_AND_MASK 0x7FFFFFFF
55#define PAPI_PRESET_AND_MASK 0x7FFFFFFF
56#define PAPI_NATIVE_MASK 0x40000000
57#define PAPI_NATIVE_AND_MASK 0x3FFFFFFF
58
59/*
60* Some PAPI 3 definitions for PAPI_{set,get}_opt() map
61* onto single definitions in PAPI 2. The new definitions
62* (shown below) should be used to guarantee PAPI 3 compatibility.
63*/
64#define PAPI_CLOCKRATE PAPI_GET_CLOCKRATE
65#define PAPI_MAX_HWCTRS PAPI_GET_MAX_HWCTRS
66#define PAPI_HWINFO PAPI_GET_HWINFO
67#define PAPI_EXEINFO PAPI_GET_EXEINFO
68#define PAPI_MAX_CPUS PAPI_GET_MAX_CPUS
69#define PAPI_CPUS PAPI_GET_CPUS
70#define PAPI_THREADS PAPI_GET_THREADS
71
72/*
73* PAPI 2 defined only one string length.
74* PAPI 3 defines three. This insures limited compatibility.
75*/
76#define PAPI_MIN_STR_LEN PAPI_MAX_STR_LEN
77#define PAPI_HUGE_STR_LEN PAPI_MAX_STR_LEN
78
79/*
80* PAPI 2 always profiles into 16-bit buckets.
81* PAPI 3 supports multiple bucket sizes.
82* Exercise caution if these defines appear in your code.
83* There is a potential for data overflow in PAPI 2.
84*/
85#define PAPI_PROFIL_BUCKET_16 0
86#define PAPI_PROFIL_BUCKET_32 0
87#define PAPI_PROFIL_BUCKET_64 0
88
89/*
90* PAPI 3 defines a new eventcode that can often be emulated
91* successfully on PAPI 2. PAPI 3 also deprecates two eventcodes
92* found in PAPI 2:
93* PAPI_IPS (instructions per second)
94* PAPI_FLOPS (floating point instructions per second)
95* Don't use these eventcodes in version independent code
96*/
97#define PAPI_FP_OPS PAPI_FP_INS
98
99/*
100* Two new data structures are introduced in PAPI 3 that are
101* required to support the functionality of:
102* PAPI_get_event_info() and
103* PAPI_get_executable_info()
104* These structures are reproduced below.
105* They MUST stay synchronized with their counterparts in papi.h
106*/
107#define PAPI_MAX_INFO_TERMS 8
108typedef struct event_info
109{
110 unsigned int event_code;
111 unsigned int count;
112 char symbol[PAPI_MAX_STR_LEN + 3];
113 char short_descr[PAPI_MIN_STR_LEN];
114 char long_descr[PAPI_HUGE_STR_LEN];
115 char derived[PAPI_MIN_STR_LEN];
116 char postfix[PAPI_MIN_STR_LEN];
117 unsigned int code[PAPI_MAX_INFO_TERMS];
120 char note[PAPI_HUGE_STR_LEN];
122
123/* Possible values for the 'modifier' parameter of the PAPI_enum_event call.
124 This enumeration is new in PAPI 3. It will act as a nop in PAPI 2, but
125 must be defined for code compatibility.
126*/
127enum
128{
129 PAPI_ENUM_ALL = 0, /* Always enumerate all events */
130 PAPI_PRESET_ENUM_AVAIL, /* Enumerate events that exist here */
131
132 /* PAPI PRESET section */
133 PAPI_PRESET_ENUM_INS, /* Instruction related preset events */
134 PAPI_PRESET_ENUM_BR, /* branch related preset events */
135 PAPI_PRESET_ENUM_MEM, /* memory related preset events */
136 PAPI_PRESET_ENUM_TLB, /* Translation Lookaside Buffer events */
137 PAPI_PRESET_ENUM_FP, /* Floating Point related preset events */
138
139 /* Pentium 4 specific section */
140 PAPI_PENT4_ENUM_GROUPS = 0x100, /* 45 groups + custom + user */
141 PAPI_PENT4_ENUM_COMBOS, /* all combinations of mask bits for given group */
142 PAPI_PENT4_ENUM_BITS, /* all individual bits for given group */
143
144 /* POWER 4 specific section */
145 PAPI_PWR4_ENUM_GROUPS = 0x200 /* Enumerate groups an event belongs to */
146};
147
148typedef struct _papi_address_map
149{
150 char mapname[PAPI_HUGE_STR_LEN];
151 vptr_t text_start; /* Start address of program text segment */
152 vptr_t text_end; /* End address of program text segment */
153 vptr_t data_start; /* Start address of program data segment */
154 vptr_t data_end; /* End address of program data segment */
155 vptr_t bss_start; /* Start address of program bss segment */
156 vptr_t bss_end; /* End address of program bss segment */
158
159/*
160 * PAPI 3 beta 3 introduces new structures for static memory description.
161 * These include structures for tlb and cache description, a structure
162 * to describe a level in the memory hierarchy, and a structure
163 * to describe all levels of the hierarchy.
164 * These structures, and the requisite data types are defined below.
165 */
166
167 /* All sizes are in BYTES */
168 /* Except tlb size, which is in entries */
169
170#define PAPI_MAX_MEM_HIERARCHY_LEVELS 3
171#define PAPI_MH_TYPE_EMPTY 0x0
172#define PAPI_MH_TYPE_INST 0x1
173#define PAPI_MH_TYPE_DATA 0x2
174#define PAPI_MH_TYPE_UNIFIED PAPI_MH_TYPE_INST|PAPI_MH_TYPE_DATA
175
176typedef struct _papi_mh_tlb_info
177{
178 int type; /* Empty, unified, data, instr */
179 int num_entries;
180 int associativity;
182
183typedef struct _papi_mh_cache_info
184{
185 int type; /* Empty, unified, data, instr */
186 int size;
187 int line_size;
188 int num_lines;
189 int associativity;
191
192typedef struct _papi_mh_level_info
193{
194 PAPI_mh_tlb_info_t tlb[2];
195 PAPI_mh_cache_info_t cache[2];
197
198typedef struct _papi_mh_info
199{ /* mh for mem hierarchy maybe? */
200 int levels;
203
204/*
205* Three data structures are modified in PAPI 3
206* These modifications are
207* required to support the functionality of:
208* PAPI_get_hardware_info() and
209* PAPI_get_executable_info()
210* These structures are reproduced below.
211* They MUST stay synchronized with their counterparts in papi.h
212* To avoid namespace collisions, these structures have been renamed
213* to PAPIvi_xxx, and must also be renamed in your code.
214*/
215typedef struct _papi3_hw_info
216{
217 int ncpu; /* Number of CPUs in an SMP Node */
218 int nnodes; /* Number of Nodes in the entire system */
219 int totalcpus; /* Total number of CPUs in the entire system */
220 int vendor; /* Vendor number of CPU */
221 char vendor_string[PAPI_MAX_STR_LEN]; /* Vendor string of CPU */
222 int model; /* Model number of CPU */
223 char model_string[PAPI_MAX_STR_LEN]; /* Model string of CPU */
224 float revision; /* Revision of CPU */
225 float mhz; /* Cycle time of this CPU, *may* be estimated at
226 init time with a quick timing routine */
227
228 PAPI_mh_info_t mem_hierarchy;
229} PAPIvi_hw_info_t;
230
231typedef struct _papi3_preload_option
232{
233 char lib_preload_env[PAPI_MAX_STR_LEN]; /* Model string of CPU */
234 char lib_preload_sep;
235 char lib_dir_env[PAPI_MAX_STR_LEN];
236 char lib_dir_sep;
237} PAPIvi_preload_option_t;
238
239typedef struct _papi3_program_info
240{
241 char fullname[PAPI_MAX_STR_LEN]; /* path+name */
242 char name[PAPI_MAX_STR_LEN]; /* name */
243 PAPI_address_map_t address_info;
244 PAPIvi_preload_option_t preload_info;
245} PAPIvi_exe_info_t;
246
247
248/*
249* The Low Level API
250* Functions in this API are classified in 4 basic categories:
251* Modified: 13 functions
252* New: 8 functions
253* Unchanged: 32 functions
254* Deprecated: 9 functions
255*
256* Each of these categories is discussed further below.
257*/
258
259/*
260* Modified functions are further divided into 4 subcategories:
261* Dereferencing changes: 6 functions
262* These functions simply substitute an EventSet value for
263* a pointer to an EventSet. In the case of PAPI_remove_event{s}()
264* there is also a name change.
265* Name changes: 1 function
266* This is a simple name change with no change in functionality.
267* Parameter changes: 4 functions
268* Several functions have changed functionality reflected in changed
269* parameters:
270* PAPI_{un}lock() supports multiple locks in PAPI 3
271* PAPI_profil() supports multiple bucket sizes in PAPI 3
272* PAPI_thread_init() removes an unused parameter in PAPI 3
273* New functionality: 2 functions
274* These functions support new data in revised data structures
275* The code implemented here maps the old structures to the new
276* where possible.
277*/
278
279 /* Modified Functons: Dereferencing changes */
280#define PAPIvi_add_event(EventSet, Event) \
281 PAPI_add_event(&EventSet, Event)
282#define PAPIvi_add_events(EventSet, Events, number) \
283 PAPI_add_events(&EventSet, Events, number)
284#define PAPIvi_cleanup_eventset(EventSet) \
285 PAPI_cleanup_eventset(&EventSet)
286#define PAPIvi_remove_event(EventSet, EventCode) \
287 PAPI_rem_event(&EventSet, EventCode)
288#define PAPIvi_remove_events(EventSet, Events, number) \
289 PAPI_rem_events(&EventSet, Events, number)
290#define PAPIvi_set_multiplex(EventSet) \
291 PAPI_set_multiplex(&EventSet)
292
293 /* Modified Functons: Name changes */
294#define PAPIvi_is_initialized \
295 PAPI_initialized
296
297 /* Modified Functons: Parameter changes */
298#define PAPIvi_lock(lck) \
299 PAPI_lock()
300#define PAPIvi_profil(buf, bufsiz, offset, scale, EventSet, EventCode, threshold, flags) \
301 PAPI_profil((unsigned short *)buf, bufsiz, (unsigned long)offset, scale, EventSet, EventCode, threshold, flags)
302#define PAPIvi_thread_init(id_fn) \
303 PAPI_thread_init(id_fn, 0)
304#define PAPIvi_unlock(lck) \
305 PAPI_unlock()
306
307 /* Modified Functons: New functionality */
308static const PAPIvi_exe_info_t *
309PAPIvi_get_executable_info( void )
310{
311 static PAPIvi_exe_info_t prginfo3;
312 const PAPI_exe_info_t *prginfo2 = PAPI_get_executable_info( );
313
314 if ( prginfo2 == NULL )
315 return ( NULL );
316
317 strcpy( prginfo3.fullname, prginfo2->fullname );
318 strcpy( prginfo3.name, prginfo2->name );
319 prginfo3.address_info.mapname[0] = 0;
320 prginfo3.address_info.text_start = prginfo2->text_start;
321 prginfo3.address_info.text_end = prginfo2->text_end;
322 prginfo3.address_info.data_start = prginfo2->data_start;
323 prginfo3.address_info.data_end = prginfo2->data_end;
324 prginfo3.address_info.bss_start = prginfo2->bss_start;
325 prginfo3.address_info.bss_end = prginfo2->bss_end;
326 strcpy( prginfo3.preload_info.lib_preload_env, prginfo2->lib_preload_env );
327
328 return ( &prginfo3 );
329}
330
331static const PAPIvi_hw_info_t *
332PAPIvi_get_hardware_info( void )
333{
334 static PAPIvi_hw_info_t papi3_hw_info;
335 const PAPI_hw_info_t *papi2_hw_info = PAPI_get_hardware_info( );
336 const PAPI_mem_info_t *papi2_mem_info = PAPI_get_memory_info( );
337
338 /* Copy the basic hardware info (same in both structures */
339 memcpy( &papi3_hw_info, papi2_hw_info, sizeof ( PAPI_hw_info_t ) );
340
341 memset( &papi3_hw_info.mem_hierarchy, 0, sizeof ( PAPI_mh_info_t ) );
342 /* check for a unified tlb */
343 if ( papi2_mem_info->total_tlb_size &&
344 papi2_mem_info->itlb_size == 0 && papi2_mem_info->dtlb_size == 0 ) {
345 papi3_hw_info.mem_hierarchy.level[0].tlb[0].type = PAPI_MH_TYPE_UNIFIED;
346 papi3_hw_info.mem_hierarchy.level[0].tlb[0].num_entries =
347 papi2_mem_info->total_tlb_size;
348 } else {
349 if ( papi2_mem_info->itlb_size ) {
350 papi3_hw_info.mem_hierarchy.level[0].tlb[0].type =
352 papi3_hw_info.mem_hierarchy.level[0].tlb[0].num_entries =
353 papi2_mem_info->itlb_size;
354 papi3_hw_info.mem_hierarchy.level[0].tlb[0].associativity =
355 papi2_mem_info->itlb_assoc;
356 }
357 if ( papi2_mem_info->dtlb_size ) {
358 papi3_hw_info.mem_hierarchy.level[0].tlb[1].type =
360 papi3_hw_info.mem_hierarchy.level[0].tlb[1].num_entries =
361 papi2_mem_info->dtlb_size;
362 papi3_hw_info.mem_hierarchy.level[0].tlb[1].associativity =
363 papi2_mem_info->dtlb_assoc;
364 }
365 }
366 /* check for a unified level 1 cache */
367 if ( papi2_mem_info->total_L1_size )
368 papi3_hw_info.mem_hierarchy.levels = 1;
369 if ( papi2_mem_info->total_L1_size &&
370 papi2_mem_info->L1_icache_size == 0 &&
371 papi2_mem_info->L1_dcache_size == 0 ) {
372 papi3_hw_info.mem_hierarchy.level[0].cache[0].type =
374 papi3_hw_info.mem_hierarchy.level[0].cache[0].size =
375 papi2_mem_info->total_L1_size << 10;
376 } else {
377 if ( papi2_mem_info->L1_icache_size ) {
378 papi3_hw_info.mem_hierarchy.level[0].cache[0].type =
380 papi3_hw_info.mem_hierarchy.level[0].cache[0].size =
381 papi2_mem_info->L1_icache_size << 10;
382 papi3_hw_info.mem_hierarchy.level[0].cache[0].associativity =
383 papi2_mem_info->L1_icache_assoc;
384 papi3_hw_info.mem_hierarchy.level[0].cache[0].num_lines =
385 papi2_mem_info->L1_icache_lines;
386 papi3_hw_info.mem_hierarchy.level[0].cache[0].line_size =
387 papi2_mem_info->L1_icache_linesize;
388 }
389 if ( papi2_mem_info->L1_dcache_size ) {
390 papi3_hw_info.mem_hierarchy.level[0].cache[1].type =
392 papi3_hw_info.mem_hierarchy.level[0].cache[1].size =
393 papi2_mem_info->L1_dcache_size << 10;
394 papi3_hw_info.mem_hierarchy.level[0].cache[1].associativity =
395 papi2_mem_info->L1_dcache_assoc;
396 papi3_hw_info.mem_hierarchy.level[0].cache[1].num_lines =
397 papi2_mem_info->L1_dcache_lines;
398 papi3_hw_info.mem_hierarchy.level[0].cache[1].line_size =
399 papi2_mem_info->L1_dcache_linesize;
400 }
401 }
402
403 /* check for level 2 cache info */
404 if ( papi2_mem_info->L2_cache_size ) {
405 papi3_hw_info.mem_hierarchy.levels = 2;
406 papi3_hw_info.mem_hierarchy.level[1].cache[0].type =
408 papi3_hw_info.mem_hierarchy.level[1].cache[0].size =
409 papi2_mem_info->L2_cache_size << 10;
410 papi3_hw_info.mem_hierarchy.level[1].cache[0].associativity =
411 papi2_mem_info->L2_cache_assoc;
412 papi3_hw_info.mem_hierarchy.level[1].cache[0].num_lines =
413 papi2_mem_info->L2_cache_lines;
414 papi3_hw_info.mem_hierarchy.level[1].cache[0].line_size =
415 papi2_mem_info->L2_cache_linesize;
416 }
417
418 /* check for level 3 cache info */
419 if ( papi2_mem_info->L3_cache_size ) {
420 papi3_hw_info.mem_hierarchy.levels = 3;
421 papi3_hw_info.mem_hierarchy.level[2].cache[0].type =
423 papi3_hw_info.mem_hierarchy.level[2].cache[0].size =
424 papi2_mem_info->L3_cache_size << 10;
425 papi3_hw_info.mem_hierarchy.level[2].cache[0].associativity =
426 papi2_mem_info->L3_cache_assoc;
427 papi3_hw_info.mem_hierarchy.level[2].cache[0].num_lines =
428 papi2_mem_info->L3_cache_lines;
429 papi3_hw_info.mem_hierarchy.level[2].cache[0].line_size =
430 papi2_mem_info->L3_cache_linesize;
431 }
432
433 return ( &papi3_hw_info );
434}
435
436/*
437* New functions are either supported or unsupported.
438* Of the three supported functions, two replaced deprecated functions
439* to describe events, and one is simply a convenience function.
440* The five unsupported new functions include three related to thread
441* functionality, a convenience function to return the number of events
442* in an event set, and a function to query information about shared libraries.
443*/
444
445 /* New Supported Functions */
446static int
447PAPIvi_enum_event( int *EventCode, int modifier )
448{
449 int i = *EventCode;
450 const PAPI_preset_info_t *presets = PAPI_query_all_events_verbose( );
452 while ( ++i < PAPI_MAX_PRESET_EVENTS ) {
453 if ( ( !modifier ) || ( presets[i].avail ) ) {
454 *EventCode = i | PAPI_PRESET_MASK;
455 if ( presets[i].event_name != NULL )
456 return ( PAPI_OK );
457 else
458 return ( PAPI_ENOEVNT );
459 }
460 }
461 return ( PAPI_ENOEVNT );
462}
463
464static int
465PAPIvi_get_event_info( int EventCode, PAPI_event_info_t * info )
466{
467 int i;
468 const PAPI_preset_info_t *info2 = PAPI_query_all_events_verbose( );
469
470 i = EventCode & PAPI_PRESET_AND_MASK;
471 if ( ( i >= PAPI_MAX_PRESET_EVENTS ) || ( info2[i].event_name == NULL ) )
472 return ( PAPI_ENOTPRESET );
473
474 info->event_code = info2[i].event_code;
475 info->count = info2[i].avail;
476 if ( info2[i].flags & PAPI_DERIVED ) {
477 info->count++;
478 strcpy( info->derived, "DERIVED" );
479 }
480 if ( info2[i].event_name == NULL )
481 info->symbol[0] = 0;
482 else
483 strcpy( info->symbol, info2[i].event_name );
484 if ( info2[i].event_label == NULL )
485 info->short_descr[0] = 0;
486 else
487 strcpy( info->short_descr, info2[i].event_label );
488 if ( info2[i].event_descr == NULL )
489 info->long_descr[0] = 0;
490 else
491 strcpy( info->long_descr, info2[i].event_descr );
492 if ( info2[i].event_note == NULL )
493 info->note[0] = 0;
494 else
495 strcpy( info->note, info2[i].event_note );
496 return ( PAPI_OK );
497}
498
499/*
500static int PAPI_get_multiplex(int EventSet)
501{
502 PAPI_option_t popt;
503 int retval;
504
505 popt.multiplex.eventset = EventSet;
506 retval = PAPI_get_opt(PAPI_GET_MULTIPLEX, &popt);
507 if (retval < 0)
508 retval = 0;
509 return retval;
510}
511*/
512
513 /* New Unsupported Functions */
514#define PAPIvi_get_shared_lib_info \
515 PAPI_get_shared_lib_info
516#define PAPIvi_get_thr_specific(tag, ptr) \
517 PAPI_get_thr_specific(tag, ptr)
518#define PAPIvi_num_events(EventSet) \
519 PAPI_num_events(EventSet)
520#define PAPIvi_register_thread \
521 PAPI_register_thread
522#define PAPIvi_set_thr_specific(tag, ptr) \
523 PAPI_set_thr_specific(tag, ptr)
524
525/*
526* Over half of the functions in the Low Level API remain unchanged
527* These are included in the macro list in case they do change in future
528* revisions, and to simplify the naming conventions for writing
529* version independent PAPI code.
530*/
531
532#define PAPIvi_accum(EventSet, values) \
533 PAPI_accum(EventSet, values)
534#define PAPIvi_create_eventset(EventSet) \
535 PAPI_create_eventset(EventSet)
536#define PAPIvi_destroy_eventset(EventSet) \
537 PAPI_destroy_eventset(EventSet)
538#define PAPIvi_event_code_to_name(EventCode, out) \
539 PAPI_event_code_to_name(EventCode, out)
540#define PAPIvi_event_name_to_code(in, out) \
541 PAPI_event_name_to_code(in, out)
542#define PAPIvi_get_dmem_info(option) \
543 PAPI_get_dmem_info(option)
544#define PAPIvi_get_opt(option, ptr) \
545 PAPI_get_opt(option, ptr)
546#define PAPIvi_get_real_cyc \
547 PAPI_get_real_cyc
548#define PAPIvi_get_real_usec \
549 PAPI_get_real_usec
550#define PAPIvi_get_virt_cyc \
551 PAPI_get_virt_cyc
552#define PAPIvi_get_virt_usec \
553 PAPI_get_virt_usec
554#define PAPIvi_library_init(version) \
555 PAPI_library_init(version)
556#define PAPIvi_list_events(EventSet, Events, number) \
557 PAPI_list_events(EventSet, Events, number)
558#define PAPIvi_multiplex_init \
559 PAPI_multiplex_init
560#define PAPIvi_num_hwctrs \
561 PAPI_num_hwctrs
562#define PAPIvi_overflow(EventSet, EventCode, threshold, flags, handler) \
563 PAPI_overflow(EventSet, EventCode, threshold, flags, handler)
564#define PAPIvi_perror( s ) \
565 PAPI_perror( s )
566#define PAPIvi_query_event(EventCode) \
567 PAPI_query_event(EventCode)
568#define PAPIvi_read(EventSet, values) \
569 PAPI_read(EventSet, values)
570#define PAPIvi_reset(EventSet) \
571 PAPI_reset(EventSet)
572#define PAPIvi_set_debug(level) \
573 PAPI_set_debug(level)
574#define PAPIvi_set_domain(domain) \
575 PAPI_set_domain(domain)
576#define PAPIvi_set_granularity(granularity) \
577 PAPI_set_granularity(granularity)
578#define PAPIvi_set_opt(option, ptr) \
579 PAPI_set_opt(option, ptr)
580#define PAPIvi_shutdown \
581 PAPI_shutdown
582#define PAPIvi_sprofil(prof, profcnt, EventSet, EventCode, threshold, flags) \
583 PAPI_sprofil(prof, profcnt, EventSet, EventCode, threshold, flags)
584#define PAPIvi_start(EventSet) \
585 PAPI_start(EventSet)
586#define PAPIvi_state(EventSet, status) \
587 PAPI_state(EventSet, status)
588#define PAPIvi_stop(EventSet, values) \
589 PAPI_stop(EventSet, values)
590#define PAPIvi_strerror(err) \
591 PAPI_strerror(err)
592#define PAPIvi_thread_id \
593 PAPI_thread_id
594#define PAPIvi_write(EventSet, values) \
595 PAPI_write(EventSet, values)
596
597/*
598* Of the nine functions deprecated from PAPI 2 to PAPI 3,
599* three (PAPI_add_pevent, PAPI_restore, and PAPI_save) were
600* never implemented, and four dealt with describing events.
601* Two remain:
602* PAPI_get_overflow_address() must still be used in version specific overflow handlers
603* PAPI_profil_hw() was rarely used, and only on platforms supporting hardware overflow.
604* The prototypes of these functions are shown below for completeness.
605*/
606/*
607int PAPI_add_pevent(int *EventSet, int code, void *inout);
608void *PAPI_get_overflow_address(void *context);
609int PAPI_profil_hw(unsigned short *buf, unsigned bufsiz, unsigned long offset, \
610 unsigned scale, int EventSet, int EventCode, int threshold, int flags);
611const PAPI_preset_info_t *PAPI_query_all_events_verbose(void);
612int PAPI_describe_event(char *name, int *EventCode, char *description);
613int PAPI_label_event(int EventCode, char *label);
614int PAPI_query_event_verbose(int EventCode, PAPI_preset_info_t *info);
615int PAPI_restore(void);
616int PAPI_save(void);
617*/
618
619
620/*
621* The High Level API
622* There are 8 functions in this API.
623* 6 are unchanged, and 2 are new.
624* Of the new functions, one is emulated and one is unsupported.
625*/
626
627/* Unchanged Functions */
628#define PAPIvi_accum_counters(values, array_len) \
629 PAPI_accum_counters(values, array_len)
630#define PAPIvi_num_counters \
631 PAPI_num_counters
632#define PAPIvi_read_counters(values, array_len) \
633 PAPI_read_counters(values, array_len)
634#define PAPIvi_start_counters(Events, array_len) \
635 PAPI_start_counters(Events, array_len)
636#define PAPIvi_stop_counters(values, array_len) \
637 PAPI_stop_counters(values, array_len)
638#define PAPIvi_flops(rtime, ptime, flpops, mflops) \
639 PAPI_flops(rtime, ptime, flpops, mflops)
640
641 /* New Supported Functions */
642#define PAPIvi_flips(rtime, ptime, flpins, mflips) \
643 PAPI_flops(rtime, ptime, flpins, mflips)
644
645 /* New Unupported Functions */
646#define PAPIvi_ipc(rtime, ptime, ins, ipc) \
647 PAPI_ipc(rtime, ptime, ins, ipc)
648
649
650/*******************************************************************************
651* If PAPI_VERSION is defined, and the MAJOR version number is 3,
652* then papi.h is for PAPI 3.
653* The preprocessor block below contains definitions and macros needed to
654* allow version independent linking to the PAPI 3 library.
655* Other than a handful of definitions to support calls to PAPI_{get,set}_opt(),
656* this layer simply converts version independent names to PAPI 3 library calls.
657********************************************************************************/
658#elif (PAPI_VERSION_MAJOR(PAPI_VERSION) == 3)
659
660/*
661* The following option definitions reflect the fact that PAPI 2 had separate
662* definitions for options to PAPI_set_opt and PAPI_get_opt, while PAPI 3 has
663* only a single set for both. By using the older naming convention, you can
664* create platform independent code for these calls.
665*/
666
667#define PAPI_SET_DEBUG PAPI_DEBUG
668#define PAPI_GET_DEBUG PAPI_DEBUG
669
670#define PAPI_SET_MULTIPLEX PAPI_MULTIPLEX
671#define PAPI_GET_MULTIPLEX PAPI_MULTIPLEX
672
673#define PAPI_SET_DEFDOM PAPI_DEFDOM
674#define PAPI_GET_DEFDOM PAPI_DEFDOM
675
676#define PAPI_SET_DOMAIN PAPI_DOMAIN
677#define PAPI_GET_DOMAIN PAPI_DOMAIN
678
679#define PAPI_SET_DEFGRN PAPI_DEFGRN
680#define PAPI_GET_DEFGRN PAPI_DEFGRN
681
682#define PAPI_SET_GRANUL PAPI_GRANUL
683#define PAPI_GET_GRANUL PAPI_GRANUL
684
685#define PAPI_SET_INHERIT PAPI_INHERIT
686#define PAPI_GET_INHERIT PAPI_INHERIT
687
688#define PAPI_GET_NUMCTRS PAPI_NUMCTRS
689#define PAPI_SET_NUMCTRS PAPI_NUMCTRS
690
691#define PAPI_SET_PROFIL PAPI_PROFIL
692#define PAPI_GET_PROFIL PAPI_PROFIL
693
694/*
695* These macros are simple pass-throughs to PAPI 3 structures
696*/
697#define PAPIvi_hw_info_t PAPI_hw_info_t
698#define PAPIvi_exe_info_t PAPI_exe_info_t
699
700/*
701* The following macros are simple pass-throughs to PAPI 3 library calls
702*/
703 /* The Low Level API */
704#define PAPIvi_accum(EventSet, values) \
705 PAPI_accum(EventSet, values)
706#define PAPIvi_add_event(EventSet, Event) \
707 PAPI_add_event(EventSet, Event)
708#define PAPIvi_add_events(EventSet, Events, number) \
709 PAPI_add_events(EventSet, Events, number)
710#define PAPIvi_cleanup_eventset(EventSet) \
711 PAPI_cleanup_eventset(EventSet)
712#define PAPIvi_create_eventset(EventSet) \
713 PAPI_create_eventset(EventSet)
714#define PAPIvi_destroy_eventset(EventSet) \
715 PAPI_destroy_eventset(EventSet)
716#define PAPIvi_enum_event(EventCode, modifier) \
717 PAPI_enum_event(EventCode, modifier)
718#define PAPIvi_event_code_to_name(EventCode, out) \
719 PAPI_event_code_to_name(EventCode, out)
720#define PAPIvi_event_name_to_code(in, out) \
721 PAPI_event_name_to_code(in, out)
722#define PAPIvi_get_dmem_info(option) \
723 PAPI_get_dmem_info(option)
724#define PAPIvi_get_event_info(EventCode, info) \
725 PAPI_get_event_info(EventCode, info)
726#define PAPIvi_get_executable_info \
727 PAPI_get_executable_info
728#define PAPIvi_get_hardware_info \
729 PAPI_get_hardware_info
730#define PAPIvi_get_multiplex(EventSet) \
731 PAPI_get_multiplex(EventSet)
732#define PAPIvi_get_opt(option, ptr) \
733 PAPI_get_opt(option, ptr)
734#define PAPIvi_get_real_cyc \
735 PAPI_get_real_cyc
736#define PAPIvi_get_real_usec \
737 PAPI_get_real_usec
738#define PAPIvi_get_shared_lib_info \
739 PAPI_get_shared_lib_info
740#define PAPIvi_get_thr_specific(tag, ptr) \
741 PAPI_get_thr_specific(tag, ptr)
742#define PAPIvi_get_virt_cyc \
743 PAPI_get_virt_cyc
744#define PAPIvi_get_virt_usec \
745 PAPI_get_virt_usec
746#define PAPIvi_is_initialized \
747 PAPI_is_initialized
748#define PAPIvi_library_init(version) \
749 PAPI_library_init(version)
750#define PAPIvi_list_events(EventSet, Events, number) \
751 PAPI_list_events(EventSet, Events, number)
752#define PAPIvi_lock(lck) \
753 PAPI_lock(lck)
754#define PAPIvi_multiplex_init \
755 PAPI_multiplex_init
756#define PAPIvi_num_hwctrs \
757 PAPI_num_hwctrs
758#define PAPIvi_num_events(EventSet) \
759 PAPI_num_events(EventSet)
760#define PAPIvi_overflow(EventSet, EventCode, threshold, flags, handler) \
761 PAPI_overflow(EventSet, EventCode, threshold, flags, handler)
762#define PAPIvi_perror( s ) \
763 PAPI_perror( s )
764#define PAPIvi_profil(buf, bufsiz, offset, scale, EventSet, EventCode, threshold, flags) \
765 PAPI_profil(buf, bufsiz, offset, scale, EventSet, EventCode, threshold, flags)
766#define PAPIvi_query_event(EventCode) \
767 PAPI_query_event(EventCode)
768#define PAPIvi_read(EventSet, values) \
769 PAPI_read(EventSet, values)
770#define PAPIvi_register_thread \
771 PAPI_register_thread
772#define PAPIvi_remove_event(EventSet, EventCode) \
773 PAPI_remove_event(EventSet, EventCode)
774#define PAPIvi_remove_events(EventSet, Events, number) \
775 PAPI_remove_events(EventSet, Events, number)
776#define PAPIvi_reset(EventSet) \
777 PAPI_reset(EventSet)
778#define PAPIvi_set_debug(level) \
779 PAPI_set_debug(level)
780#define PAPIvi_set_domain(domain) \
781 PAPI_set_domain(domain)
782#define PAPIvi_set_granularity(granularity) \
783 PAPI_set_granularity(granularity)
784#define PAPIvi_set_multiplex(EventSet) \
785 PAPI_set_multiplex(EventSet)
786#define PAPIvi_set_opt(option, ptr) \
787 PAPI_set_opt(option, ptr)
788#define PAPIvi_set_thr_specific(tag, ptr) \
789 PAPI_set_thr_specific(tag, ptr)
790#define PAPIvi_shutdown \
791 PAPI_shutdown
792#define PAPIvi_sprofil(prof, profcnt, EventSet, EventCode, threshold, flags) \
793 PAPI_sprofil(prof, profcnt, EventSet, EventCode, threshold, flags)
794#define PAPIvi_start(EventSet) \
795 PAPI_start(EventSet)
796#define PAPIvi_state(EventSet, status) \
797 PAPI_state(EventSet, status)
798#define PAPIvi_stop(EventSet, values) \
799 PAPI_stop(EventSet, values)
800#define PAPIvi_strerror(err) \
801 PAPI_strerror(err)
802#define PAPIvi_thread_id \
803 PAPI_thread_id
804#define PAPIvi_thread_init(id_fn) \
805 PAPI_thread_init(id_fn)
806#define PAPIvi_unlock(lck) \
807 PAPI_unlock(lck)
808#define PAPIvi_write(EventSet, values) \
809 PAPI_write(EventSet, values)
810
811 /* The High Level API */
812
813#define PAPIvi_accum_counters(values, array_len) \
814 PAPI_accum_counters(values, array_len)
815#define PAPIvi_num_counters \
816 PAPI_num_counters
817#define PAPIvi_read_counters(values, array_len) \
818 PAPI_read_counters(values, array_len)
819#define PAPIvi_start_counters(Events, array_len) \
820 PAPI_start_counters(Events, array_len)
821#define PAPIvi_stop_counters(values, array_len) \
822 PAPI_stop_counters(values, array_len)
823#define PAPIvi_flips(rtime, ptime, flpins, mflips) \
824 PAPI_flips(rtime, ptime, flpins, mflips)
825#define PAPIvi_flops(rtime, ptime, flpops, mflops) \
826 PAPI_flops(rtime, ptime, flpops, mflops)
827#define PAPIvi_ipc(rtime, ptime, ins, ipc) \
828 PAPI_ipc(rtime, ptime, ins, ipc)
829
830
831/*******************************************************************************
832* If PAPI_VERSION is defined, and the MAJOR version number is not 3, then we
833* generate an error message.
834* This block allows us to support future version with a
835* version independent syntax.
836********************************************************************************/
837#else
838#error Compiling against a not yet released PAPI version
839#endif
840
841#endif /* _PAPIVI */
int i
static long count
Get the executable's address space info.
get information about the system hardware
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_MIN_STR_LEN
Definition: f90papi.h:208
#define PAPI_ENOEVNT
Definition: f90papi.h:139
#define PAPI_DERIVED
Definition: f90papi.h:24
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define PAPI_ENUM_ALL
Definition: f90papi.h:107
#define PAPI_MAX_MEM_HIERARCHY_LEVELS
Definition: f90papi.h:103
#define PAPI_ENOTPRESET
Definition: f90papi.h:178
#define PAPI_MAX_INFO_TERMS
Definition: f90papi.h:147
#define PAPI_HUGE_STR_LEN
Definition: f90papi.h:120
uint16_t type
static struct counter_info * event_info
#define PAPI_PRESET_MASK
#define PAPI_PRESET_AND_MASK
#define PAPI_MAX_PRESET_EVENTS
Return codes and api definitions.
#define PAPI_MH_TYPE_DATA
Definition: papi.h:720
@ PAPI_PRESET_ENUM_FP
Definition: papi.h:504
@ PAPI_PRESET_ENUM_MEM
Definition: papi.h:498
@ PAPI_PRESET_ENUM_AVAIL
Definition: papi.h:490
@ PAPI_PRESET_ENUM_INS
Definition: papi.h:494
@ PAPI_PRESET_ENUM_TLB
Definition: papi.h:503
@ PAPI_PRESET_ENUM_BR
Definition: papi.h:496
void * vptr_t
Definition: papi.h:576
#define PAPI_MH_TYPE_INST
Definition: papi.h:719
#define PAPI_MH_TYPE_UNIFIED
Definition: papi.h:723
int model
Definition: pfmlib_amd64.c:86
amd64_rev_t revision
Definition: pfmlib_amd64.c:81
const char * name
Definition: rocs.c:225
get the executable's address space info
Definition: papi.h:684
vptr_t text_end
Definition: papi.h:687
vptr_t bss_start
Definition: papi.h:690
vptr_t data_end
Definition: papi.h:689
vptr_t data_start
Definition: papi.h:688
vptr_t bss_end
Definition: papi.h:691
unsigned int count
Definition: papi.h:981
char note[PAPI_HUGE_STR_LEN]
Definition: papi.h:1007
unsigned int event_code
Definition: papi.h:958
char short_descr[PAPI_MIN_STR_LEN]
Definition: papi.h:961
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:960
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:989
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
get the executable's info
Definition: papi.h:696
char fullname[PAPI_HUGE_STR_LEN]
Definition: papi.h:697
PAPI_address_map_t address_info
Definition: papi.h:698
Hardware info structure.
Definition: papi.h:774
mh for mem hierarchy maybe?
Definition: papi.h:767