File: papivi.h

package info (click to toggle)
papi 5.7.0+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 9,856 kB
  • sloc: ansic: 93,265; fortran: 3,338; xml: 2,460; makefile: 815; sh: 290
file content (841 lines) | stat: -rw-r--r-- 29,966 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
/****************************/
/* THIS IS OPEN SOURCE CODE */
/****************************/

/* 
* File:    papivi.h
* CVS:     $Id$
* Author:  dan terpstra
*          terpstra@cs.utk.edu
* Mods:    your name here
*          yourname@cs.esu.edu
*
* Include this file INSTEAD OF "papi.h" in your application code
* to provide semitransparent version independent PAPI support.
* Follow the rules described below and elsewhere to facilitate
* this support.
*
*/

#ifndef _PAPIVI
#define _PAPIVI

#include "papi.h"

/***************************************************************************
* If PAPI_VERSION is not defined, then papi.h is for PAPI 2.
* The preprocessor block below contains the definitions, data structures,
* macros and code needed to emulate much of the PAPI 3 interface in code
* linking to the PAPI 2 library.
****************************************************************************/
#ifndef PAPI_VERSION


#define PAPI_VERSION_NUMBER(maj,min,rev) (((maj)<<16) | ((min)<<8) | (rev))
#define PAPI_VERSION_MAJOR(x)   	(((x)>>16)    & 0xffff)
#define PAPI_VERSION_MINOR(x)		(((x)>>8)     & 0xff)
#define PAPI_VERSION_REVISION(x)	((x)          & 0xff)

/* This is the PAPI version on which we are running */
#define PAPI_VERSION  			PAPI_VERSION_NUMBER(2,3,4)

/* This is the PAPI 3 version with which we are compatible */
#define PAPI_VI_VERSION  			PAPI_VERSION_NUMBER(3,0,6)

/* PAPI 3 has an error code not defined for PAPI 2 */
#define PAPI_EPERM   PAPI_EMISC	/* You lack the necessary permissions */

/*
* These are defined in papi_internal.h for PAPI 2.
* They need to be exposed for version independent PAPI code to work.
*/
//#define PRESET_MASK     0x80000000
#define PAPI_PRESET_MASK 0x80000000
//#define PRESET_AND_MASK 0x7FFFFFFF
#define PAPI_PRESET_AND_MASK 0x7FFFFFFF
#define PAPI_NATIVE_MASK 0x40000000
#define PAPI_NATIVE_AND_MASK 0x3FFFFFFF

/*
* Some PAPI 3 definitions for PAPI_{set,get}_opt() map
* onto single definitions in PAPI 2. The new definitions
* (shown below) should be used to guarantee PAPI 3 compatibility.
*/
#define PAPI_CLOCKRATE     PAPI_GET_CLOCKRATE
#define PAPI_MAX_HWCTRS    PAPI_GET_MAX_HWCTRS
#define PAPI_HWINFO        PAPI_GET_HWINFO
#define PAPI_EXEINFO       PAPI_GET_EXEINFO
#define PAPI_MAX_CPUS      PAPI_GET_MAX_CPUS
#define PAPI_CPUS          PAPI_GET_CPUS
#define PAPI_THREADS       PAPI_GET_THREADS

/*
* PAPI 2 defined only one string length.
* PAPI 3 defines three. This insures limited compatibility.
*/
#define PAPI_MIN_STR_LEN   PAPI_MAX_STR_LEN
#define PAPI_HUGE_STR_LEN  PAPI_MAX_STR_LEN

/*
* PAPI 2 always profiles into 16-bit buckets.
* PAPI 3 supports multiple bucket sizes.
* Exercise caution if these defines appear in your code.
* There is a potential for data overflow in PAPI 2.
*/
#define PAPI_PROFIL_BUCKET_16 0
#define PAPI_PROFIL_BUCKET_32 0
#define PAPI_PROFIL_BUCKET_64 0

/*
* PAPI 3 defines a new eventcode that can often be emulated
* successfully on PAPI 2. PAPI 3 also deprecates two eventcodes
* found in PAPI 2:
* PAPI_IPS   (instructions per second)
* PAPI_FLOPS (floating point instructions per second)
* Don't use these eventcodes in version independent code
*/
#define PAPI_FP_OPS PAPI_FP_INS

/*
* Two new data structures are introduced in PAPI 3 that are 
* required to support the functionality of:
* PAPI_get_event_info() and
* PAPI_get_executable_info()
* These structures are reproduced below.
* They MUST stay synchronized with their counterparts in papi.h
*/
#define PAPI_MAX_INFO_TERMS 8
typedef struct event_info
{
	unsigned int event_code;
	unsigned int count;
	char symbol[PAPI_MAX_STR_LEN + 3];
	char short_descr[PAPI_MIN_STR_LEN];
	char long_descr[PAPI_HUGE_STR_LEN];
	char derived[PAPI_MIN_STR_LEN];
	char postfix[PAPI_MIN_STR_LEN];
	unsigned int code[PAPI_MAX_INFO_TERMS];
	char name[PAPI_MAX_INFO_TERMS]
		[PAPI_MIN_STR_LEN];
	char note[PAPI_HUGE_STR_LEN];
} PAPI_event_info_t;

/* Possible values for the 'modifier' parameter of the PAPI_enum_event call.
   This enumeration is new in PAPI 3. It will act as a nop in PAPI 2, but
   must be defined for code compatibility.
*/
enum
{
	PAPI_ENUM_ALL = 0,				   /* Always enumerate all events */
	PAPI_PRESET_ENUM_AVAIL,	 /* Enumerate events that exist here */

	/* PAPI PRESET section */
	PAPI_PRESET_ENUM_INS,	 /* Instruction related preset events */
	PAPI_PRESET_ENUM_BR,	 /* branch related preset events */
	PAPI_PRESET_ENUM_MEM,	 /* memory related preset events */
	PAPI_PRESET_ENUM_TLB,	 /* Translation Lookaside Buffer events */
	PAPI_PRESET_ENUM_FP,	 /* Floating Point related preset events */

	/* Pentium 4 specific section */
	PAPI_PENT4_ENUM_GROUPS = 0x100,	/* 45 groups + custom + user */
	PAPI_PENT4_ENUM_COMBOS,	 /* all combinations of mask bits for given group */
	PAPI_PENT4_ENUM_BITS,	 /* all individual bits for given group */

	/* POWER 4 specific section */
	PAPI_PWR4_ENUM_GROUPS = 0x200	/* Enumerate groups an event belongs to */
};

typedef struct _papi_address_map
{
	char mapname[PAPI_HUGE_STR_LEN];
	caddr_t text_start;				   /* Start address of program text segment */
	caddr_t text_end;				   /* End address of program text segment */
	caddr_t data_start;				   /* Start address of program data segment */
	caddr_t data_end;				   /* End address of program data segment */
	caddr_t bss_start;				   /* Start address of program bss segment */
	caddr_t bss_end;				   /* End address of program bss segment */
} PAPI_address_map_t;

/*
 * PAPI 3 beta 3 introduces new structures for static memory description.
 * These include structures for tlb and cache description, a structure
 * to describe a level in the memory hierarchy, and a structure 
 * to describe all levels of the hierarchy.
 * These structures, and the requisite data types are defined below.
 */

   /* All sizes are in BYTES */
   /* Except tlb size, which is in entries */

#define PAPI_MAX_MEM_HIERARCHY_LEVELS 	  3
#define PAPI_MH_TYPE_EMPTY    0x0
#define PAPI_MH_TYPE_INST	   0x1
#define PAPI_MH_TYPE_DATA     0x2
#define PAPI_MH_TYPE_UNIFIED  PAPI_MH_TYPE_INST|PAPI_MH_TYPE_DATA

typedef struct _papi_mh_tlb_info
{
	int type;						   /* Empty, unified, data, instr */
	int num_entries;
	int associativity;
} PAPI_mh_tlb_info_t;

typedef struct _papi_mh_cache_info
{
	int type;						   /* Empty, unified, data, instr */
	int size;
	int line_size;
	int num_lines;
	int associativity;
} PAPI_mh_cache_info_t;

typedef struct _papi_mh_level_info
{
	PAPI_mh_tlb_info_t tlb[2];
	PAPI_mh_cache_info_t cache[2];
} PAPI_mh_level_t;

typedef struct _papi_mh_info
{									   /* mh for mem hierarchy maybe? */
	int levels;
	PAPI_mh_level_t level[PAPI_MAX_MEM_HIERARCHY_LEVELS];
} PAPI_mh_info_t;

/*
* Three data structures are modified in PAPI 3
* These modifications are 
* required to support the functionality of:
* PAPI_get_hardware_info() and
* PAPI_get_executable_info()
* These structures are reproduced below.
* They MUST stay synchronized with their counterparts in papi.h
* To avoid namespace collisions, these structures have been renamed
* to PAPIvi_xxx, and must also be renamed in your code.
*/
typedef struct _papi3_hw_info
{
	int ncpu;						   /* Number of CPUs in an SMP Node */
	int nnodes;						   /* Number of Nodes in the entire system */
	int totalcpus;					   /* Total number of CPUs in the entire system */
	int vendor;						   /* Vendor number of CPU */
	char vendor_string[PAPI_MAX_STR_LEN];	/* Vendor string of CPU */
	int model;						   /* Model number of CPU */
	char model_string[PAPI_MAX_STR_LEN];	/* Model string of CPU */
	float revision;					   /* Revision of CPU */
	float mhz;						   /* Cycle time of this CPU, *may* be estimated at 
									      init time with a quick timing routine */

	PAPI_mh_info_t mem_hierarchy;
} PAPIvi_hw_info_t;

typedef struct _papi3_preload_option
{
	char lib_preload_env[PAPI_MAX_STR_LEN];	/* Model string of CPU */
	char lib_preload_sep;
	char lib_dir_env[PAPI_MAX_STR_LEN];
	char lib_dir_sep;
} PAPIvi_preload_option_t;

typedef struct _papi3_program_info
{
	char fullname[PAPI_MAX_STR_LEN];   /* path+name */
	char name[PAPI_MAX_STR_LEN];	   /* name */
	PAPI_address_map_t address_info;
	PAPIvi_preload_option_t preload_info;
} PAPIvi_exe_info_t;


/*
* The Low Level API
* Functions in this API are classified in 4 basic categories:
* Modified:   13 functions
* New:         8 functions
* Unchanged:  32 functions
* Deprecated:  9 functions
*
* Each of these categories is discussed further below.
*/

/*
* Modified functions are further divided into 4 subcategories:
* Dereferencing changes: 6 functions
*     These functions simply substitute an EventSet value for
*     a pointer to an EventSet. In the case of PAPI_remove_event{s}()
*     there is also a name change.
* Name changes:          1 function
*     This is a simple name change with no change in functionality.
* Parameter changes:     4 functions
*     Several functions have changed functionality reflected in changed
*     parameters:
*     PAPI_{un}lock() supports multiple locks in PAPI 3
*     PAPI_profil() supports multiple bucket sizes in PAPI 3
*     PAPI_thread_init() removes an unused parameter in PAPI 3
* New functionality:     2 functions
*     These functions support new data in revised data structures
*     The code implemented here maps the old structures to the new
*     where possible.
*/

 /* Modified Functons: Dereferencing changes */
#define PAPIvi_add_event(EventSet, Event) \
          PAPI_add_event(&EventSet, Event)
#define PAPIvi_add_events(EventSet, Events, number) \
          PAPI_add_events(&EventSet, Events, number)
#define PAPIvi_cleanup_eventset(EventSet) \
          PAPI_cleanup_eventset(&EventSet)
#define PAPIvi_remove_event(EventSet, EventCode) \
          PAPI_rem_event(&EventSet, EventCode)
#define PAPIvi_remove_events(EventSet, Events, number) \
          PAPI_rem_events(&EventSet, Events, number)
#define PAPIvi_set_multiplex(EventSet) \
          PAPI_set_multiplex(&EventSet)

 /* Modified Functons: Name changes */
#define PAPIvi_is_initialized \
          PAPI_initialized

 /* Modified Functons: Parameter changes */
#define PAPIvi_lock(lck) \
          PAPI_lock()
#define PAPIvi_profil(buf, bufsiz, offset, scale, EventSet, EventCode, threshold, flags) \
          PAPI_profil((unsigned short *)buf, bufsiz, (unsigned long)offset, scale, EventSet, EventCode, threshold, flags)
#define PAPIvi_thread_init(id_fn) \
          PAPI_thread_init(id_fn, 0)
#define PAPIvi_unlock(lck) \
          PAPI_unlock()

 /* Modified Functons: New functionality */
static const PAPIvi_exe_info_t *
PAPIvi_get_executable_info( void )
{
	static PAPIvi_exe_info_t prginfo3;
	const PAPI_exe_info_t *prginfo2 = PAPI_get_executable_info(  );

	if ( prginfo2 == NULL )
		return ( NULL );

	strcpy( prginfo3.fullname, prginfo2->fullname );
	strcpy( prginfo3.name, prginfo2->name );
	prginfo3.address_info.mapname[0] = 0;
	prginfo3.address_info.text_start = prginfo2->text_start;
	prginfo3.address_info.text_end = prginfo2->text_end;
	prginfo3.address_info.data_start = prginfo2->data_start;
	prginfo3.address_info.data_end = prginfo2->data_end;
	prginfo3.address_info.bss_start = prginfo2->bss_start;
	prginfo3.address_info.bss_end = prginfo2->bss_end;
	strcpy( prginfo3.preload_info.lib_preload_env, prginfo2->lib_preload_env );

	return ( &prginfo3 );
}

static const PAPIvi_hw_info_t *
PAPIvi_get_hardware_info( void )
{
	static PAPIvi_hw_info_t papi3_hw_info;
	const PAPI_hw_info_t *papi2_hw_info = PAPI_get_hardware_info(  );
	const PAPI_mem_info_t *papi2_mem_info = PAPI_get_memory_info(  );

	/* Copy the basic hardware info (same in both structures */
	memcpy( &papi3_hw_info, papi2_hw_info, sizeof ( PAPI_hw_info_t ) );

	memset( &papi3_hw_info.mem_hierarchy, 0, sizeof ( PAPI_mh_info_t ) );
	/* check for a unified tlb */
	if ( papi2_mem_info->total_tlb_size &&
		 papi2_mem_info->itlb_size == 0 && papi2_mem_info->dtlb_size == 0 ) {
		papi3_hw_info.mem_hierarchy.level[0].tlb[0].type = PAPI_MH_TYPE_UNIFIED;
		papi3_hw_info.mem_hierarchy.level[0].tlb[0].num_entries =
			papi2_mem_info->total_tlb_size;
	} else {
		if ( papi2_mem_info->itlb_size ) {
			papi3_hw_info.mem_hierarchy.level[0].tlb[0].type =
				PAPI_MH_TYPE_INST;
			papi3_hw_info.mem_hierarchy.level[0].tlb[0].num_entries =
				papi2_mem_info->itlb_size;
			papi3_hw_info.mem_hierarchy.level[0].tlb[0].associativity =
				papi2_mem_info->itlb_assoc;
		}
		if ( papi2_mem_info->dtlb_size ) {
			papi3_hw_info.mem_hierarchy.level[0].tlb[1].type =
				PAPI_MH_TYPE_DATA;
			papi3_hw_info.mem_hierarchy.level[0].tlb[1].num_entries =
				papi2_mem_info->dtlb_size;
			papi3_hw_info.mem_hierarchy.level[0].tlb[1].associativity =
				papi2_mem_info->dtlb_assoc;
		}
	}
	/* check for a unified level 1 cache */
	if ( papi2_mem_info->total_L1_size )
		papi3_hw_info.mem_hierarchy.levels = 1;
	if ( papi2_mem_info->total_L1_size &&
		 papi2_mem_info->L1_icache_size == 0 &&
		 papi2_mem_info->L1_dcache_size == 0 ) {
		papi3_hw_info.mem_hierarchy.level[0].cache[0].type =
			PAPI_MH_TYPE_UNIFIED;
		papi3_hw_info.mem_hierarchy.level[0].cache[0].size =
			papi2_mem_info->total_L1_size << 10;
	} else {
		if ( papi2_mem_info->L1_icache_size ) {
			papi3_hw_info.mem_hierarchy.level[0].cache[0].type =
				PAPI_MH_TYPE_INST;
			papi3_hw_info.mem_hierarchy.level[0].cache[0].size =
				papi2_mem_info->L1_icache_size << 10;
			papi3_hw_info.mem_hierarchy.level[0].cache[0].associativity =
				papi2_mem_info->L1_icache_assoc;
			papi3_hw_info.mem_hierarchy.level[0].cache[0].num_lines =
				papi2_mem_info->L1_icache_lines;
			papi3_hw_info.mem_hierarchy.level[0].cache[0].line_size =
				papi2_mem_info->L1_icache_linesize;
		}
		if ( papi2_mem_info->L1_dcache_size ) {
			papi3_hw_info.mem_hierarchy.level[0].cache[1].type =
				PAPI_MH_TYPE_DATA;
			papi3_hw_info.mem_hierarchy.level[0].cache[1].size =
				papi2_mem_info->L1_dcache_size << 10;
			papi3_hw_info.mem_hierarchy.level[0].cache[1].associativity =
				papi2_mem_info->L1_dcache_assoc;
			papi3_hw_info.mem_hierarchy.level[0].cache[1].num_lines =
				papi2_mem_info->L1_dcache_lines;
			papi3_hw_info.mem_hierarchy.level[0].cache[1].line_size =
				papi2_mem_info->L1_dcache_linesize;
		}
	}

	/* check for level 2 cache info */
	if ( papi2_mem_info->L2_cache_size ) {
		papi3_hw_info.mem_hierarchy.levels = 2;
		papi3_hw_info.mem_hierarchy.level[1].cache[0].type =
			PAPI_MH_TYPE_UNIFIED;
		papi3_hw_info.mem_hierarchy.level[1].cache[0].size =
			papi2_mem_info->L2_cache_size << 10;
		papi3_hw_info.mem_hierarchy.level[1].cache[0].associativity =
			papi2_mem_info->L2_cache_assoc;
		papi3_hw_info.mem_hierarchy.level[1].cache[0].num_lines =
			papi2_mem_info->L2_cache_lines;
		papi3_hw_info.mem_hierarchy.level[1].cache[0].line_size =
			papi2_mem_info->L2_cache_linesize;
	}

	/* check for level 3 cache info */
	if ( papi2_mem_info->L3_cache_size ) {
		papi3_hw_info.mem_hierarchy.levels = 3;
		papi3_hw_info.mem_hierarchy.level[2].cache[0].type =
			PAPI_MH_TYPE_UNIFIED;
		papi3_hw_info.mem_hierarchy.level[2].cache[0].size =
			papi2_mem_info->L3_cache_size << 10;
		papi3_hw_info.mem_hierarchy.level[2].cache[0].associativity =
			papi2_mem_info->L3_cache_assoc;
		papi3_hw_info.mem_hierarchy.level[2].cache[0].num_lines =
			papi2_mem_info->L3_cache_lines;
		papi3_hw_info.mem_hierarchy.level[2].cache[0].line_size =
			papi2_mem_info->L3_cache_linesize;
	}

	return ( &papi3_hw_info );
}

/*
* New functions are either supported or unsupported.
* Of the three supported functions, two replaced deprecated functions
* to describe events, and one is simply a convenience function.
* The five unsupported new functions include three related to thread
* functionality, a convenience function to return the number of events
* in an event set, and a function to query information about shared libraries.
*/

 /* New Supported Functions */
static int
PAPIvi_enum_event( int *EventCode, int modifier )
{
	int i = *EventCode;
	const PAPI_preset_info_t *presets = PAPI_query_all_events_verbose(  );
	i &= PAPI_PRESET_AND_MASK;
	while ( ++i < PAPI_MAX_PRESET_EVENTS ) {
		if ( ( !modifier ) || ( presets[i].avail ) ) {
			*EventCode = i | PAPI_PRESET_MASK;
			if ( presets[i].event_name != NULL )
				return ( PAPI_OK );
			else
				return ( PAPI_ENOEVNT );
		}
	}
	return ( PAPI_ENOEVNT );
}

static int
PAPIvi_get_event_info( int EventCode, PAPI_event_info_t * info )
{
	int i;
	const PAPI_preset_info_t *info2 = PAPI_query_all_events_verbose(  );

	i = EventCode & PAPI_PRESET_AND_MASK;
	if ( ( i >= PAPI_MAX_PRESET_EVENTS ) || ( info2[i].event_name == NULL ) )
		return ( PAPI_ENOTPRESET );

	info->event_code = info2[i].event_code;
	info->count = info2[i].avail;
	if ( info2[i].flags & PAPI_DERIVED ) {
		info->count++;
		strcpy( info->derived, "DERIVED" );
	}
	if ( info2[i].event_name == NULL )
		info->symbol[0] = 0;
	else
		strcpy( info->symbol, info2[i].event_name );
	if ( info2[i].event_label == NULL )
		info->short_descr[0] = 0;
	else
		strcpy( info->short_descr, info2[i].event_label );
	if ( info2[i].event_descr == NULL )
		info->long_descr[0] = 0;
	else
		strcpy( info->long_descr, info2[i].event_descr );
	if ( info2[i].event_note == NULL )
		info->note[0] = 0;
	else
		strcpy( info->note, info2[i].event_note );
	return ( PAPI_OK );
}

/*
static int PAPI_get_multiplex(int EventSet)
{
   PAPI_option_t popt;
   int retval;

   popt.multiplex.eventset = EventSet;
   retval = PAPI_get_opt(PAPI_GET_MULTIPLEX, &popt);
   if (retval < 0)
      retval = 0;
   return retval;
}
*/

 /* New Unsupported Functions */
#define PAPIvi_get_shared_lib_info \
          PAPI_get_shared_lib_info
#define PAPIvi_get_thr_specific(tag, ptr) \
          PAPI_get_thr_specific(tag, ptr)
#define PAPIvi_num_events(EventSet) \
          PAPI_num_events(EventSet)
#define PAPIvi_register_thread \
          PAPI_register_thread
#define PAPIvi_set_thr_specific(tag, ptr) \
          PAPI_set_thr_specific(tag, ptr)

/*
* Over half of the functions in the Low Level API remain unchanged
* These are included in the macro list in case they do change in future
* revisions, and to simplify the naming conventions for writing 
* version independent PAPI code.
*/

#define PAPIvi_accum(EventSet, values) \
          PAPI_accum(EventSet, values)
#define PAPIvi_create_eventset(EventSet) \
          PAPI_create_eventset(EventSet)
#define PAPIvi_destroy_eventset(EventSet) \
          PAPI_destroy_eventset(EventSet)
#define PAPIvi_event_code_to_name(EventCode, out) \
          PAPI_event_code_to_name(EventCode, out)
#define PAPIvi_event_name_to_code(in, out) \
          PAPI_event_name_to_code(in, out)
#define PAPIvi_get_dmem_info(option) \
          PAPI_get_dmem_info(option)
#define PAPIvi_get_opt(option, ptr) \
          PAPI_get_opt(option, ptr)
#define PAPIvi_get_real_cyc \
          PAPI_get_real_cyc
#define PAPIvi_get_real_usec \
          PAPI_get_real_usec
#define PAPIvi_get_virt_cyc \
          PAPI_get_virt_cyc
#define PAPIvi_get_virt_usec \
          PAPI_get_virt_usec
#define PAPIvi_library_init(version) \
          PAPI_library_init(version)
#define PAPIvi_list_events(EventSet, Events, number) \
          PAPI_list_events(EventSet, Events, number)
#define PAPIvi_multiplex_init \
          PAPI_multiplex_init
#define PAPIvi_num_hwctrs \
          PAPI_num_hwctrs
#define PAPIvi_overflow(EventSet, EventCode, threshold, flags, handler) \
          PAPI_overflow(EventSet, EventCode, threshold, flags, handler)
#define PAPIvi_perror( s ) \
          PAPI_perror( s )
#define PAPIvi_query_event(EventCode) \
          PAPI_query_event(EventCode)
#define PAPIvi_read(EventSet, values) \
          PAPI_read(EventSet, values)
#define PAPIvi_reset(EventSet) \
          PAPI_reset(EventSet)
#define PAPIvi_set_debug(level) \
          PAPI_set_debug(level)
#define PAPIvi_set_domain(domain) \
          PAPI_set_domain(domain)
#define PAPIvi_set_granularity(granularity) \
          PAPI_set_granularity(granularity)
#define PAPIvi_set_opt(option, ptr) \
          PAPI_set_opt(option, ptr)
#define PAPIvi_shutdown \
          PAPI_shutdown
#define PAPIvi_sprofil(prof, profcnt, EventSet, EventCode, threshold, flags) \
          PAPI_sprofil(prof, profcnt, EventSet, EventCode, threshold, flags)
#define PAPIvi_start(EventSet) \
          PAPI_start(EventSet)
#define PAPIvi_state(EventSet, status) \
          PAPI_state(EventSet, status)
#define PAPIvi_stop(EventSet, values) \
          PAPI_stop(EventSet, values)
#define PAPIvi_strerror(err) \
          PAPI_strerror(err)
#define PAPIvi_thread_id \
          PAPI_thread_id
#define PAPIvi_write(EventSet, values) \
          PAPI_write(EventSet, values)

/*
* Of the nine functions deprecated from PAPI 2 to PAPI 3,
* three (PAPI_add_pevent, PAPI_restore, and PAPI_save) were
* never implemented, and four dealt with describing events.
* Two remain:
* PAPI_get_overflow_address() must still be used in version specific overflow handlers
* PAPI_profil_hw() was rarely used, and only on platforms supporting hardware overflow.
* The prototypes of these functions are shown below for completeness.
*/
/*
int PAPI_add_pevent(int *EventSet, int code, void *inout);
void *PAPI_get_overflow_address(void *context);
int PAPI_profil_hw(unsigned short *buf, unsigned bufsiz, unsigned long offset, \
          unsigned scale, int EventSet, int EventCode, int threshold, int flags);
const PAPI_preset_info_t *PAPI_query_all_events_verbose(void);
int PAPI_describe_event(char *name, int *EventCode, char *description);
int PAPI_label_event(int EventCode, char *label);
int PAPI_query_event_verbose(int EventCode, PAPI_preset_info_t *info);
int PAPI_restore(void);
int PAPI_save(void);
*/


/*
* The High Level API
* There are 8 functions in this API.
* 6 are unchanged, and 2 are new.
* Of the new functions, one is emulated and one is unsupported.
*/

/* Unchanged Functions */
#define PAPIvi_accum_counters(values, array_len) \
          PAPI_accum_counters(values, array_len)
#define PAPIvi_num_counters \
          PAPI_num_counters
#define PAPIvi_read_counters(values, array_len) \
          PAPI_read_counters(values, array_len)
#define PAPIvi_start_counters(Events, array_len) \
          PAPI_start_counters(Events, array_len)
#define PAPIvi_stop_counters(values, array_len) \
          PAPI_stop_counters(values, array_len)
#define PAPIvi_flops(rtime, ptime, flpops, mflops) \
          PAPI_flops(rtime, ptime, flpops, mflops)

 /* New Supported Functions */
#define PAPIvi_flips(rtime, ptime, flpins, mflips) \
          PAPI_flops(rtime, ptime, flpins, mflips)

 /* New Unupported Functions */
#define PAPIvi_ipc(rtime, ptime, ins, ipc) \
          PAPI_ipc(rtime, ptime, ins, ipc)


/*******************************************************************************
* If PAPI_VERSION is defined, and the MAJOR version number is 3,
* then papi.h is for PAPI 3.
* The preprocessor block below contains definitions and macros needed to 
* allow version independent linking to the PAPI 3 library.
* Other than a handful of definitions to support calls to PAPI_{get,set}_opt(),
* this layer simply converts version independent names to PAPI 3 library calls.
********************************************************************************/
#elif (PAPI_VERSION_MAJOR(PAPI_VERSION) == 3)

/*
* The following option definitions reflect the fact that PAPI 2 had separate 
* definitions for options to PAPI_set_opt and PAPI_get_opt, while PAPI 3 has
* only a single set for both. By using the older naming convention, you can 
* create platform independent code for these calls.
*/

#define PAPI_SET_DEBUG     PAPI_DEBUG
#define PAPI_GET_DEBUG     PAPI_DEBUG

#define PAPI_SET_MULTIPLEX PAPI_MULTIPLEX
#define PAPI_GET_MULTIPLEX PAPI_MULTIPLEX

#define PAPI_SET_DEFDOM    PAPI_DEFDOM
#define PAPI_GET_DEFDOM    PAPI_DEFDOM

#define PAPI_SET_DOMAIN    PAPI_DOMAIN
#define PAPI_GET_DOMAIN    PAPI_DOMAIN

#define PAPI_SET_DEFGRN    PAPI_DEFGRN
#define PAPI_GET_DEFGRN    PAPI_DEFGRN

#define PAPI_SET_GRANUL    PAPI_GRANUL
#define PAPI_GET_GRANUL    PAPI_GRANUL

#define PAPI_SET_INHERIT   PAPI_INHERIT
#define PAPI_GET_INHERIT   PAPI_INHERIT

#define PAPI_GET_NUMCTRS   PAPI_NUMCTRS
#define PAPI_SET_NUMCTRS   PAPI_NUMCTRS

#define PAPI_SET_PROFIL    PAPI_PROFIL
#define PAPI_GET_PROFIL    PAPI_PROFIL

/*
* These macros are simple pass-throughs to PAPI 3 structures
*/
#define PAPIvi_hw_info_t   PAPI_hw_info_t
#define PAPIvi_exe_info_t  PAPI_exe_info_t

/*
* The following macros are simple pass-throughs to PAPI 3 library calls
*/
 /* The Low Level API */
#define PAPIvi_accum(EventSet, values) \
          PAPI_accum(EventSet, values)
#define PAPIvi_add_event(EventSet, Event) \
          PAPI_add_event(EventSet, Event)
#define PAPIvi_add_events(EventSet, Events, number) \
          PAPI_add_events(EventSet, Events, number)
#define PAPIvi_cleanup_eventset(EventSet) \
          PAPI_cleanup_eventset(EventSet)
#define PAPIvi_create_eventset(EventSet) \
          PAPI_create_eventset(EventSet)
#define PAPIvi_destroy_eventset(EventSet) \
          PAPI_destroy_eventset(EventSet)
#define PAPIvi_enum_event(EventCode, modifier) \
          PAPI_enum_event(EventCode, modifier)
#define PAPIvi_event_code_to_name(EventCode, out) \
          PAPI_event_code_to_name(EventCode, out)
#define PAPIvi_event_name_to_code(in, out) \
          PAPI_event_name_to_code(in, out)
#define PAPIvi_get_dmem_info(option) \
          PAPI_get_dmem_info(option)
#define PAPIvi_get_event_info(EventCode, info) \
          PAPI_get_event_info(EventCode, info)
#define PAPIvi_get_executable_info \
          PAPI_get_executable_info
#define PAPIvi_get_hardware_info \
          PAPI_get_hardware_info
#define PAPIvi_get_multiplex(EventSet) \
          PAPI_get_multiplex(EventSet)
#define PAPIvi_get_opt(option, ptr) \
          PAPI_get_opt(option, ptr)
#define PAPIvi_get_real_cyc \
          PAPI_get_real_cyc
#define PAPIvi_get_real_usec \
          PAPI_get_real_usec
#define PAPIvi_get_shared_lib_info \
          PAPI_get_shared_lib_info
#define PAPIvi_get_thr_specific(tag, ptr) \
          PAPI_get_thr_specific(tag, ptr)
#define PAPIvi_get_virt_cyc \
          PAPI_get_virt_cyc
#define PAPIvi_get_virt_usec \
          PAPI_get_virt_usec
#define PAPIvi_is_initialized \
          PAPI_is_initialized
#define PAPIvi_library_init(version) \
          PAPI_library_init(version)
#define PAPIvi_list_events(EventSet, Events, number) \
          PAPI_list_events(EventSet, Events, number)
#define PAPIvi_lock(lck) \
          PAPI_lock(lck)
#define PAPIvi_multiplex_init \
          PAPI_multiplex_init
#define PAPIvi_num_hwctrs \
          PAPI_num_hwctrs
#define PAPIvi_num_events(EventSet) \
          PAPI_num_events(EventSet)
#define PAPIvi_overflow(EventSet, EventCode, threshold, flags, handler) \
          PAPI_overflow(EventSet, EventCode, threshold, flags, handler)
#define PAPIvi_perror( s ) \
          PAPI_perror( s )
#define PAPIvi_profil(buf, bufsiz, offset, scale, EventSet, EventCode, threshold, flags) \
          PAPI_profil(buf, bufsiz, offset, scale, EventSet, EventCode, threshold, flags)
#define PAPIvi_query_event(EventCode) \
          PAPI_query_event(EventCode)
#define PAPIvi_read(EventSet, values) \
          PAPI_read(EventSet, values)
#define PAPIvi_register_thread \
          PAPI_register_thread
#define PAPIvi_remove_event(EventSet, EventCode) \
          PAPI_remove_event(EventSet, EventCode)
#define PAPIvi_remove_events(EventSet, Events, number) \
          PAPI_remove_events(EventSet, Events, number)
#define PAPIvi_reset(EventSet) \
          PAPI_reset(EventSet)
#define PAPIvi_set_debug(level) \
          PAPI_set_debug(level)
#define PAPIvi_set_domain(domain) \
          PAPI_set_domain(domain)
#define PAPIvi_set_granularity(granularity) \
          PAPI_set_granularity(granularity)
#define PAPIvi_set_multiplex(EventSet) \
          PAPI_set_multiplex(EventSet)
#define PAPIvi_set_opt(option, ptr) \
          PAPI_set_opt(option, ptr)
#define PAPIvi_set_thr_specific(tag, ptr) \
          PAPI_set_thr_specific(tag, ptr)
#define PAPIvi_shutdown \
          PAPI_shutdown
#define PAPIvi_sprofil(prof, profcnt, EventSet, EventCode, threshold, flags) \
          PAPI_sprofil(prof, profcnt, EventSet, EventCode, threshold, flags)
#define PAPIvi_start(EventSet) \
          PAPI_start(EventSet)
#define PAPIvi_state(EventSet, status) \
          PAPI_state(EventSet, status)
#define PAPIvi_stop(EventSet, values) \
          PAPI_stop(EventSet, values)
#define PAPIvi_strerror(err) \
          PAPI_strerror(err)
#define PAPIvi_thread_id \
          PAPI_thread_id
#define PAPIvi_thread_init(id_fn) \
          PAPI_thread_init(id_fn)
#define PAPIvi_unlock(lck) \
          PAPI_unlock(lck)
#define PAPIvi_write(EventSet, values) \
          PAPI_write(EventSet, values)

   /* The High Level API */

#define PAPIvi_accum_counters(values, array_len) \
          PAPI_accum_counters(values, array_len)
#define PAPIvi_num_counters \
          PAPI_num_counters
#define PAPIvi_read_counters(values, array_len) \
          PAPI_read_counters(values, array_len)
#define PAPIvi_start_counters(Events, array_len) \
          PAPI_start_counters(Events, array_len)
#define PAPIvi_stop_counters(values, array_len) \
          PAPI_stop_counters(values, array_len)
#define PAPIvi_flips(rtime, ptime, flpins, mflips) \
          PAPI_flips(rtime, ptime, flpins, mflips)
#define PAPIvi_flops(rtime, ptime, flpops, mflops) \
          PAPI_flops(rtime, ptime, flpops, mflops)
#define PAPIvi_ipc(rtime, ptime, ins, ipc) \
          PAPI_ipc(rtime, ptime, ins, ipc)


/*******************************************************************************
* If PAPI_VERSION is defined, and the MAJOR version number is not 3, then we
* generate an error message.
* This block allows us to support future version with a 
* version independent syntax.
********************************************************************************/
#else
#error Compiling against a not yet released PAPI version
#endif

#endif /* _PAPIVI */