PAPI  5.0.1.0
papivi.h
Go to the documentation of this file.
00001 /****************************/
00002 /* THIS IS OPEN SOURCE CODE */
00003 /****************************/
00004 
00005 /* 
00006 * File:    papivi.h
00007 * CVS:     $Id$
00008 * Author:  dan terpstra
00009 *          terpstra@cs.utk.edu
00010 * Mods:    your name here
00011 *          yourname@cs.esu.edu
00012 *
00013 * Include this file INSTEAD OF "papi.h" in your application code
00014 * to provide semitransparent version independent PAPI support.
00015 * Follow the rules described below and elsewhere to facilitate
00016 * this support.
00017 *
00018 */
00019 
00020 #ifndef _PAPIVI
00021 #define _PAPIVI
00022 
00023 #include "papi.h"
00024 
00025 /***************************************************************************
00026 * If PAPI_VERSION is not defined, then papi.h is for PAPI 2.
00027 * The preprocessor block below contains the definitions, data structures,
00028 * macros and code needed to emulate much of the PAPI 3 interface in code
00029 * linking to the PAPI 2 library.
00030 ****************************************************************************/
00031 #ifndef PAPI_VERSION
00032 
00033 
00034 #define PAPI_VERSION_NUMBER(maj,min,rev) (((maj)<<16) | ((min)<<8) | (rev))
00035 #define PAPI_VERSION_MAJOR(x)       (((x)>>16)    & 0xffff)
00036 #define PAPI_VERSION_MINOR(x)       (((x)>>8)     & 0xff)
00037 #define PAPI_VERSION_REVISION(x)    ((x)          & 0xff)
00038 
00039 /* This is the PAPI version on which we are running */
00040 #define PAPI_VERSION            PAPI_VERSION_NUMBER(2,3,4)
00041 
00042 /* This is the PAPI 3 version with which we are compatible */
00043 #define PAPI_VI_VERSION             PAPI_VERSION_NUMBER(3,0,6)
00044 
00045 /* PAPI 3 has an error code not defined for PAPI 2 */
00046 #define PAPI_EPERM   PAPI_EMISC /* You lack the necessary permissions */
00047 
00048 /*
00049 * These are defined in papi_internal.h for PAPI 2.
00050 * They need to be exposed for version independent PAPI code to work.
00051 */
00052 //#define PRESET_MASK     0x80000000
00053 #define PAPI_PRESET_MASK 0x80000000
00054 //#define PRESET_AND_MASK 0x7FFFFFFF
00055 #define PAPI_PRESET_AND_MASK 0x7FFFFFFF
00056 #define PAPI_NATIVE_MASK 0x40000000
00057 #define PAPI_NATIVE_AND_MASK 0x3FFFFFFF
00058 
00059 /*
00060 * Some PAPI 3 definitions for PAPI_{set,get}_opt() map
00061 * onto single definitions in PAPI 2. The new definitions
00062 * (shown below) should be used to guarantee PAPI 3 compatibility.
00063 */
00064 #define PAPI_CLOCKRATE     PAPI_GET_CLOCKRATE
00065 #define PAPI_MAX_HWCTRS    PAPI_GET_MAX_HWCTRS
00066 #define PAPI_HWINFO        PAPI_GET_HWINFO
00067 #define PAPI_EXEINFO       PAPI_GET_EXEINFO
00068 #define PAPI_MAX_CPUS      PAPI_GET_MAX_CPUS
00069 #define PAPI_CPUS          PAPI_GET_CPUS
00070 #define PAPI_THREADS       PAPI_GET_THREADS
00071 
00072 /*
00073 * PAPI 2 defined only one string length.
00074 * PAPI 3 defines three. This insures limited compatibility.
00075 */
00076 #define PAPI_MIN_STR_LEN   PAPI_MAX_STR_LEN
00077 #define PAPI_HUGE_STR_LEN  PAPI_MAX_STR_LEN
00078 
00079 /*
00080 * PAPI 2 always profiles into 16-bit buckets.
00081 * PAPI 3 supports multiple bucket sizes.
00082 * Exercise caution if these defines appear in your code.
00083 * There is a potential for data overflow in PAPI 2.
00084 */
00085 #define PAPI_PROFIL_BUCKET_16 0
00086 #define PAPI_PROFIL_BUCKET_32 0
00087 #define PAPI_PROFIL_BUCKET_64 0
00088 
00089 /*
00090 * PAPI 3 defines a new eventcode that can often be emulated
00091 * successfully on PAPI 2. PAPI 3 also deprecates two eventcodes
00092 * found in PAPI 2:
00093 * PAPI_IPS   (instructions per second)
00094 * PAPI_FLOPS (floating point instructions per second)
00095 * Don't use these eventcodes in version independent code
00096 */
00097 #define PAPI_FP_OPS PAPI_FP_INS
00098 
00099 /*
00100 * Two new data structures are introduced in PAPI 3 that are 
00101 * required to support the functionality of:
00102 * PAPI_get_event_info() and
00103 * PAPI_get_executable_info()
00104 * These structures are reproduced below.
00105 * They MUST stay synchronized with their counterparts in papi.h
00106 */
00107 #define PAPI_MAX_INFO_TERMS 8
00108 typedef struct event_info
00109 {
00110     unsigned int event_code;
00111     unsigned int count;
00112     char symbol[PAPI_MAX_STR_LEN + 3];
00113     char short_descr[PAPI_MIN_STR_LEN];
00114     char long_descr[PAPI_HUGE_STR_LEN];
00115     char derived[PAPI_MIN_STR_LEN];
00116     char postfix[PAPI_MIN_STR_LEN];
00117     unsigned int code[PAPI_MAX_INFO_TERMS];
00118     char name[PAPI_MAX_INFO_TERMS]
00119         [PAPI_MIN_STR_LEN];
00120     char note[PAPI_HUGE_STR_LEN];
00121 } PAPI_event_info_t;
00122 
00123 /* Possible values for the 'modifier' parameter of the PAPI_enum_event call.
00124    This enumeration is new in PAPI 3. It will act as a nop in PAPI 2, but
00125    must be defined for code compatibility.
00126 */
00127 enum
00128 {
00129     PAPI_ENUM_ALL = 0,                 /* Always enumerate all events */
00130     PAPI_PRESET_ENUM_AVAIL,  /* Enumerate events that exist here */
00131 
00132     /* PAPI PRESET section */
00133     PAPI_PRESET_ENUM_INS,    /* Instruction related preset events */
00134     PAPI_PRESET_ENUM_BR,     /* branch related preset events */
00135     PAPI_PRESET_ENUM_MEM,    /* memory related preset events */
00136     PAPI_PRESET_ENUM_TLB,    /* Translation Lookaside Buffer events */
00137     PAPI_PRESET_ENUM_FP,     /* Floating Point related preset events */
00138 
00139     /* Pentium 4 specific section */
00140     PAPI_PENT4_ENUM_GROUPS = 0x100, /* 45 groups + custom + user */
00141     PAPI_PENT4_ENUM_COMBOS,  /* all combinations of mask bits for given group */
00142     PAPI_PENT4_ENUM_BITS,    /* all individual bits for given group */
00143 
00144     /* POWER 4 specific section */
00145     PAPI_PWR4_ENUM_GROUPS = 0x200   /* Enumerate groups an event belongs to */
00146 };
00147 
00148 typedef struct _papi_address_map
00149 {
00150     char mapname[PAPI_HUGE_STR_LEN];
00151     caddr_t text_start;                /* Start address of program text segment */
00152     caddr_t text_end;                  /* End address of program text segment */
00153     caddr_t data_start;                /* Start address of program data segment */
00154     caddr_t data_end;                  /* End address of program data segment */
00155     caddr_t bss_start;                 /* Start address of program bss segment */
00156     caddr_t bss_end;                   /* End address of program bss segment */
00157 } PAPI_address_map_t;
00158 
00159 /*
00160  * PAPI 3 beta 3 introduces new structures for static memory description.
00161  * These include structures for tlb and cache description, a structure
00162  * to describe a level in the memory hierarchy, and a structure 
00163  * to describe all levels of the hierarchy.
00164  * These structures, and the requisite data types are defined below.
00165  */
00166 
00167    /* All sizes are in BYTES */
00168    /* Except tlb size, which is in entries */
00169 
00170 #define PAPI_MAX_MEM_HIERARCHY_LEVELS     3
00171 #define PAPI_MH_TYPE_EMPTY    0x0
00172 #define PAPI_MH_TYPE_INST      0x1
00173 #define PAPI_MH_TYPE_DATA     0x2
00174 #define PAPI_MH_TYPE_UNIFIED  PAPI_MH_TYPE_INST|PAPI_MH_TYPE_DATA
00175 
00176 typedef struct _papi_mh_tlb_info
00177 {
00178     int type;                          /* Empty, unified, data, instr */
00179     int num_entries;
00180     int associativity;
00181 } PAPI_mh_tlb_info_t;
00182 
00183 typedef struct _papi_mh_cache_info
00184 {
00185     int type;                          /* Empty, unified, data, instr */
00186     int size;
00187     int line_size;
00188     int num_lines;
00189     int associativity;
00190 } PAPI_mh_cache_info_t;
00191 
00192 typedef struct _papi_mh_level_info
00193 {
00194     PAPI_mh_tlb_info_t tlb[2];
00195     PAPI_mh_cache_info_t cache[2];
00196 } PAPI_mh_level_t;
00197 
00198 typedef struct _papi_mh_info
00199 {                                      /* mh for mem hierarchy maybe? */
00200     int levels;
00201     PAPI_mh_level_t level[PAPI_MAX_MEM_HIERARCHY_LEVELS];
00202 } PAPI_mh_info_t;
00203 
00204 /*
00205 * Three data structures are modified in PAPI 3
00206 * These modifications are 
00207 * required to support the functionality of:
00208 * PAPI_get_hardware_info() and
00209 * PAPI_get_executable_info()
00210 * These structures are reproduced below.
00211 * They MUST stay synchronized with their counterparts in papi.h
00212 * To avoid namespace collisions, these structures have been renamed
00213 * to PAPIvi_xxx, and must also be renamed in your code.
00214 */
00215 typedef struct _papi3_hw_info
00216 {
00217     int ncpu;                          /* Number of CPUs in an SMP Node */
00218     int nnodes;                        /* Number of Nodes in the entire system */
00219     int totalcpus;                     /* Total number of CPUs in the entire system */
00220     int vendor;                        /* Vendor number of CPU */
00221     char vendor_string[PAPI_MAX_STR_LEN];   /* Vendor string of CPU */
00222     int model;                         /* Model number of CPU */
00223     char model_string[PAPI_MAX_STR_LEN];    /* Model string of CPU */
00224     float revision;                    /* Revision of CPU */
00225     float mhz;                         /* Cycle time of this CPU, *may* be estimated at 
00226                                           init time with a quick timing routine */
00227 
00228     PAPI_mh_info_t mem_hierarchy;
00229 } PAPIvi_hw_info_t;
00230 
00231 typedef struct _papi3_preload_option
00232 {
00233     char lib_preload_env[PAPI_MAX_STR_LEN]; /* Model string of CPU */
00234     char lib_preload_sep;
00235     char lib_dir_env[PAPI_MAX_STR_LEN];
00236     char lib_dir_sep;
00237 } PAPIvi_preload_option_t;
00238 
00239 typedef struct _papi3_program_info
00240 {
00241     char fullname[PAPI_MAX_STR_LEN];   /* path+name */
00242     char name[PAPI_MAX_STR_LEN];       /* name */
00243     PAPI_address_map_t address_info;
00244     PAPIvi_preload_option_t preload_info;
00245 } PAPIvi_exe_info_t;
00246 
00247 
00248 /*
00249 * The Low Level API
00250 * Functions in this API are classified in 4 basic categories:
00251 * Modified:   13 functions
00252 * New:         8 functions
00253 * Unchanged:  32 functions
00254 * Deprecated:  9 functions
00255 *
00256 * Each of these categories is discussed further below.
00257 */
00258 
00259 /*
00260 * Modified functions are further divided into 4 subcategories:
00261 * Dereferencing changes: 6 functions
00262 *     These functions simply substitute an EventSet value for
00263 *     a pointer to an EventSet. In the case of PAPI_remove_event{s}()
00264 *     there is also a name change.
00265 * Name changes:          1 function
00266 *     This is a simple name change with no change in functionality.
00267 * Parameter changes:     4 functions
00268 *     Several functions have changed functionality reflected in changed
00269 *     parameters:
00270 *     PAPI_{un}lock() supports multiple locks in PAPI 3
00271 *     PAPI_profil() supports multiple bucket sizes in PAPI 3
00272 *     PAPI_thread_init() removes an unused parameter in PAPI 3
00273 * New functionality:     2 functions
00274 *     These functions support new data in revised data structures
00275 *     The code implemented here maps the old structures to the new
00276 *     where possible.
00277 */
00278 
00279  /* Modified Functons: Dereferencing changes */
00280 #define PAPIvi_add_event(EventSet, Event) \
00281           PAPI_add_event(&EventSet, Event)
00282 #define PAPIvi_add_events(EventSet, Events, number) \
00283           PAPI_add_events(&EventSet, Events, number)
00284 #define PAPIvi_cleanup_eventset(EventSet) \
00285           PAPI_cleanup_eventset(&EventSet)
00286 #define PAPIvi_remove_event(EventSet, EventCode) \
00287           PAPI_rem_event(&EventSet, EventCode)
00288 #define PAPIvi_remove_events(EventSet, Events, number) \
00289           PAPI_rem_events(&EventSet, Events, number)
00290 #define PAPIvi_set_multiplex(EventSet) \
00291           PAPI_set_multiplex(&EventSet)
00292 
00293  /* Modified Functons: Name changes */
00294 #define PAPIvi_is_initialized \
00295           PAPI_initialized
00296 
00297  /* Modified Functons: Parameter changes */
00298 #define PAPIvi_lock(lck) \
00299           PAPI_lock()
00300 #define PAPIvi_profil(buf, bufsiz, offset, scale, EventSet, EventCode, threshold, flags) \
00301           PAPI_profil((unsigned short *)buf, bufsiz, (unsigned long)offset, scale, EventSet, EventCode, threshold, flags)
00302 #define PAPIvi_thread_init(id_fn) \
00303           PAPI_thread_init(id_fn, 0)
00304 #define PAPIvi_unlock(lck) \
00305           PAPI_unlock()
00306 
00307  /* Modified Functons: New functionality */
00308 static const PAPIvi_exe_info_t *
00309 PAPIvi_get_executable_info( void )
00310 {
00311     static PAPIvi_exe_info_t prginfo3;
00312     const PAPI_exe_info_t *prginfo2 = PAPI_get_executable_info(  );
00313 
00314     if ( prginfo2 == NULL )
00315         return ( NULL );
00316 
00317     strcpy( prginfo3.fullname, prginfo2->fullname );
00318     strcpy( prginfo3.name, prginfo2->name );
00319     prginfo3.address_info.mapname[0] = 0;
00320     prginfo3.address_info.text_start = prginfo2->text_start;
00321     prginfo3.address_info.text_end = prginfo2->text_end;
00322     prginfo3.address_info.data_start = prginfo2->data_start;
00323     prginfo3.address_info.data_end = prginfo2->data_end;
00324     prginfo3.address_info.bss_start = prginfo2->bss_start;
00325     prginfo3.address_info.bss_end = prginfo2->bss_end;
00326     strcpy( prginfo3.preload_info.lib_preload_env, prginfo2->lib_preload_env );
00327 
00328     return ( &prginfo3 );
00329 }
00330 
00331 static const PAPIvi_hw_info_t *
00332 PAPIvi_get_hardware_info( void )
00333 {
00334     static PAPIvi_hw_info_t papi3_hw_info;
00335     const PAPI_hw_info_t *papi2_hw_info = PAPI_get_hardware_info(  );
00336     const PAPI_mem_info_t *papi2_mem_info = PAPI_get_memory_info(  );
00337 
00338     /* Copy the basic hardware info (same in both structures */
00339     memcpy( &papi3_hw_info, papi2_hw_info, sizeof ( PAPI_hw_info_t ) );
00340 
00341     memset( &papi3_hw_info.mem_hierarchy, 0, sizeof ( PAPI_mh_info_t ) );
00342     /* check for a unified tlb */
00343     if ( papi2_mem_info->total_tlb_size &&
00344          papi2_mem_info->itlb_size == 0 && papi2_mem_info->dtlb_size == 0 ) {
00345         papi3_hw_info.mem_hierarchy.level[0].tlb[0].type = PAPI_MH_TYPE_UNIFIED;
00346         papi3_hw_info.mem_hierarchy.level[0].tlb[0].num_entries =
00347             papi2_mem_info->total_tlb_size;
00348     } else {
00349         if ( papi2_mem_info->itlb_size ) {
00350             papi3_hw_info.mem_hierarchy.level[0].tlb[0].type =
00351                 PAPI_MH_TYPE_INST;
00352             papi3_hw_info.mem_hierarchy.level[0].tlb[0].num_entries =
00353                 papi2_mem_info->itlb_size;
00354             papi3_hw_info.mem_hierarchy.level[0].tlb[0].associativity =
00355                 papi2_mem_info->itlb_assoc;
00356         }
00357         if ( papi2_mem_info->dtlb_size ) {
00358             papi3_hw_info.mem_hierarchy.level[0].tlb[1].type =
00359                 PAPI_MH_TYPE_DATA;
00360             papi3_hw_info.mem_hierarchy.level[0].tlb[1].num_entries =
00361                 papi2_mem_info->dtlb_size;
00362             papi3_hw_info.mem_hierarchy.level[0].tlb[1].associativity =
00363                 papi2_mem_info->dtlb_assoc;
00364         }
00365     }
00366     /* check for a unified level 1 cache */
00367     if ( papi2_mem_info->total_L1_size )
00368         papi3_hw_info.mem_hierarchy.levels = 1;
00369     if ( papi2_mem_info->total_L1_size &&
00370          papi2_mem_info->L1_icache_size == 0 &&
00371          papi2_mem_info->L1_dcache_size == 0 ) {
00372         papi3_hw_info.mem_hierarchy.level[0].cache[0].type =
00373             PAPI_MH_TYPE_UNIFIED;
00374         papi3_hw_info.mem_hierarchy.level[0].cache[0].size =
00375             papi2_mem_info->total_L1_size << 10;
00376     } else {
00377         if ( papi2_mem_info->L1_icache_size ) {
00378             papi3_hw_info.mem_hierarchy.level[0].cache[0].type =
00379                 PAPI_MH_TYPE_INST;
00380             papi3_hw_info.mem_hierarchy.level[0].cache[0].size =
00381                 papi2_mem_info->L1_icache_size << 10;
00382             papi3_hw_info.mem_hierarchy.level[0].cache[0].associativity =
00383                 papi2_mem_info->L1_icache_assoc;
00384             papi3_hw_info.mem_hierarchy.level[0].cache[0].num_lines =
00385                 papi2_mem_info->L1_icache_lines;
00386             papi3_hw_info.mem_hierarchy.level[0].cache[0].line_size =
00387                 papi2_mem_info->L1_icache_linesize;
00388         }
00389         if ( papi2_mem_info->L1_dcache_size ) {
00390             papi3_hw_info.mem_hierarchy.level[0].cache[1].type =
00391                 PAPI_MH_TYPE_DATA;
00392             papi3_hw_info.mem_hierarchy.level[0].cache[1].size =
00393                 papi2_mem_info->L1_dcache_size << 10;
00394             papi3_hw_info.mem_hierarchy.level[0].cache[1].associativity =
00395                 papi2_mem_info->L1_dcache_assoc;
00396             papi3_hw_info.mem_hierarchy.level[0].cache[1].num_lines =
00397                 papi2_mem_info->L1_dcache_lines;
00398             papi3_hw_info.mem_hierarchy.level[0].cache[1].line_size =
00399                 papi2_mem_info->L1_dcache_linesize;
00400         }
00401     }
00402 
00403     /* check for level 2 cache info */
00404     if ( papi2_mem_info->L2_cache_size ) {
00405         papi3_hw_info.mem_hierarchy.levels = 2;
00406         papi3_hw_info.mem_hierarchy.level[1].cache[0].type =
00407             PAPI_MH_TYPE_UNIFIED;
00408         papi3_hw_info.mem_hierarchy.level[1].cache[0].size =
00409             papi2_mem_info->L2_cache_size << 10;
00410         papi3_hw_info.mem_hierarchy.level[1].cache[0].associativity =
00411             papi2_mem_info->L2_cache_assoc;
00412         papi3_hw_info.mem_hierarchy.level[1].cache[0].num_lines =
00413             papi2_mem_info->L2_cache_lines;
00414         papi3_hw_info.mem_hierarchy.level[1].cache[0].line_size =
00415             papi2_mem_info->L2_cache_linesize;
00416     }
00417 
00418     /* check for level 3 cache info */
00419     if ( papi2_mem_info->L3_cache_size ) {
00420         papi3_hw_info.mem_hierarchy.levels = 3;
00421         papi3_hw_info.mem_hierarchy.level[2].cache[0].type =
00422             PAPI_MH_TYPE_UNIFIED;
00423         papi3_hw_info.mem_hierarchy.level[2].cache[0].size =
00424             papi2_mem_info->L3_cache_size << 10;
00425         papi3_hw_info.mem_hierarchy.level[2].cache[0].associativity =
00426             papi2_mem_info->L3_cache_assoc;
00427         papi3_hw_info.mem_hierarchy.level[2].cache[0].num_lines =
00428             papi2_mem_info->L3_cache_lines;
00429         papi3_hw_info.mem_hierarchy.level[2].cache[0].line_size =
00430             papi2_mem_info->L3_cache_linesize;
00431     }
00432 
00433     return ( &papi3_hw_info );
00434 }
00435 
00436 /*
00437 * New functions are either supported or unsupported.
00438 * Of the three supported functions, two replaced deprecated functions
00439 * to describe events, and one is simply a convenience function.
00440 * The five unsupported new functions include three related to thread
00441 * functionality, a convenience function to return the number of events
00442 * in an event set, and a function to query information about shared libraries.
00443 */
00444 
00445  /* New Supported Functions */
00446 static int
00447 PAPIvi_enum_event( int *EventCode, int modifier )
00448 {
00449     int i = *EventCode;
00450     const PAPI_preset_info_t *presets = PAPI_query_all_events_verbose(  );
00451     i &= PAPI_PRESET_AND_MASK;
00452     while ( ++i < PAPI_MAX_PRESET_EVENTS ) {
00453         if ( ( !modifier ) || ( presets[i].avail ) ) {
00454             *EventCode = i | PAPI_PRESET_MASK;
00455             if ( presets[i].event_name != NULL )
00456                 return ( PAPI_OK );
00457             else
00458                 return ( PAPI_ENOEVNT );
00459         }
00460     }
00461     return ( PAPI_ENOEVNT );
00462 }
00463 
00464 static int
00465 PAPIvi_get_event_info( int EventCode, PAPI_event_info_t * info )
00466 {
00467     int i;
00468     const PAPI_preset_info_t *info2 = PAPI_query_all_events_verbose(  );
00469 
00470     i = EventCode & PAPI_PRESET_AND_MASK;
00471     if ( ( i >= PAPI_MAX_PRESET_EVENTS ) || ( info2[i].event_name == NULL ) )
00472         return ( PAPI_ENOTPRESET );
00473 
00474     info->event_code = info2[i].event_code;
00475     info->count = info2[i].avail;
00476     if ( info2[i].flags & PAPI_DERIVED ) {
00477         info->count++;
00478         strcpy( info->derived, "DERIVED" );
00479     }
00480     if ( info2[i].event_name == NULL )
00481         info->symbol[0] = 0;
00482     else
00483         strcpy( info->symbol, info2[i].event_name );
00484     if ( info2[i].event_label == NULL )
00485         info->short_descr[0] = 0;
00486     else
00487         strcpy( info->short_descr, info2[i].event_label );
00488     if ( info2[i].event_descr == NULL )
00489         info->long_descr[0] = 0;
00490     else
00491         strcpy( info->long_descr, info2[i].event_descr );
00492     if ( info2[i].event_note == NULL )
00493         info->note[0] = 0;
00494     else
00495         strcpy( info->note, info2[i].event_note );
00496     return ( PAPI_OK );
00497 }
00498 
00499 /*
00500 static int PAPI_get_multiplex(int EventSet)
00501 {
00502    PAPI_option_t popt;
00503    int retval;
00504 
00505    popt.multiplex.eventset = EventSet;
00506    retval = PAPI_get_opt(PAPI_GET_MULTIPLEX, &popt);
00507    if (retval < 0)
00508       retval = 0;
00509    return retval;
00510 }
00511 */
00512 
00513  /* New Unsupported Functions */
00514 #define PAPIvi_get_shared_lib_info \
00515           PAPI_get_shared_lib_info
00516 #define PAPIvi_get_thr_specific(tag, ptr) \
00517           PAPI_get_thr_specific(tag, ptr)
00518 #define PAPIvi_num_events(EventSet) \
00519           PAPI_num_events(EventSet)
00520 #define PAPIvi_register_thread \
00521           PAPI_register_thread
00522 #define PAPIvi_set_thr_specific(tag, ptr) \
00523           PAPI_set_thr_specific(tag, ptr)
00524 
00525 /*
00526 * Over half of the functions in the Low Level API remain unchanged
00527 * These are included in the macro list in case they do change in future
00528 * revisions, and to simplify the naming conventions for writing 
00529 * version independent PAPI code.
00530 */
00531 
00532 #define PAPIvi_accum(EventSet, values) \
00533           PAPI_accum(EventSet, values)
00534 #define PAPIvi_create_eventset(EventSet) \
00535           PAPI_create_eventset(EventSet)
00536 #define PAPIvi_destroy_eventset(EventSet) \
00537           PAPI_destroy_eventset(EventSet)
00538 #define PAPIvi_event_code_to_name(EventCode, out) \
00539           PAPI_event_code_to_name(EventCode, out)
00540 #define PAPIvi_event_name_to_code(in, out) \
00541           PAPI_event_name_to_code(in, out)
00542 #define PAPIvi_get_dmem_info(option) \
00543           PAPI_get_dmem_info(option)
00544 #define PAPIvi_get_opt(option, ptr) \
00545           PAPI_get_opt(option, ptr)
00546 #define PAPIvi_get_real_cyc \
00547           PAPI_get_real_cyc
00548 #define PAPIvi_get_real_usec \
00549           PAPI_get_real_usec
00550 #define PAPIvi_get_virt_cyc \
00551           PAPI_get_virt_cyc
00552 #define PAPIvi_get_virt_usec \
00553           PAPI_get_virt_usec
00554 #define PAPIvi_library_init(version) \
00555           PAPI_library_init(version)
00556 #define PAPIvi_list_events(EventSet, Events, number) \
00557           PAPI_list_events(EventSet, Events, number)
00558 #define PAPIvi_multiplex_init \
00559           PAPI_multiplex_init
00560 #define PAPIvi_num_hwctrs \
00561           PAPI_num_hwctrs
00562 #define PAPIvi_overflow(EventSet, EventCode, threshold, flags, handler) \
00563           PAPI_overflow(EventSet, EventCode, threshold, flags, handler)
00564 #define PAPIvi_perror( s ) \
00565           PAPI_perror( s )
00566 #define PAPIvi_query_event(EventCode) \
00567           PAPI_query_event(EventCode)
00568 #define PAPIvi_read(EventSet, values) \
00569           PAPI_read(EventSet, values)
00570 #define PAPIvi_reset(EventSet) \
00571           PAPI_reset(EventSet)
00572 #define PAPIvi_set_debug(level) \
00573           PAPI_set_debug(level)
00574 #define PAPIvi_set_domain(domain) \
00575           PAPI_set_domain(domain)
00576 #define PAPIvi_set_granularity(granularity) \
00577           PAPI_set_granularity(granularity)
00578 #define PAPIvi_set_opt(option, ptr) \
00579           PAPI_set_opt(option, ptr)
00580 #define PAPIvi_shutdown \
00581           PAPI_shutdown
00582 #define PAPIvi_sprofil(prof, profcnt, EventSet, EventCode, threshold, flags) \
00583           PAPI_sprofil(prof, profcnt, EventSet, EventCode, threshold, flags)
00584 #define PAPIvi_start(EventSet) \
00585           PAPI_start(EventSet)
00586 #define PAPIvi_state(EventSet, status) \
00587           PAPI_state(EventSet, status)
00588 #define PAPIvi_stop(EventSet, values) \
00589           PAPI_stop(EventSet, values)
00590 #define PAPIvi_strerror(err) \
00591           PAPI_strerror(err)
00592 #define PAPIvi_thread_id \
00593           PAPI_thread_id
00594 #define PAPIvi_write(EventSet, values) \
00595           PAPI_write(EventSet, values)
00596 
00597 /*
00598 * Of the nine functions deprecated from PAPI 2 to PAPI 3,
00599 * three (PAPI_add_pevent, PAPI_restore, and PAPI_save) were
00600 * never implemented, and four dealt with describing events.
00601 * Two remain:
00602 * PAPI_get_overflow_address() must still be used in version specific overflow handlers
00603 * PAPI_profil_hw() was rarely used, and only on platforms supporting hardware overflow.
00604 * The prototypes of these functions are shown below for completeness.
00605 */
00606 /*
00607 int PAPI_add_pevent(int *EventSet, int code, void *inout);
00608 void *PAPI_get_overflow_address(void *context);
00609 int PAPI_profil_hw(unsigned short *buf, unsigned bufsiz, unsigned long offset, \
00610           unsigned scale, int EventSet, int EventCode, int threshold, int flags);
00611 const PAPI_preset_info_t *PAPI_query_all_events_verbose(void);
00612 int PAPI_describe_event(char *name, int *EventCode, char *description);
00613 int PAPI_label_event(int EventCode, char *label);
00614 int PAPI_query_event_verbose(int EventCode, PAPI_preset_info_t *info);
00615 int PAPI_restore(void);
00616 int PAPI_save(void);
00617 */
00618 
00619 
00620 /*
00621 * The High Level API
00622 * There are 8 functions in this API.
00623 * 6 are unchanged, and 2 are new.
00624 * Of the new functions, one is emulated and one is unsupported.
00625 */
00626 
00627 /* Unchanged Functions */
00628 #define PAPIvi_accum_counters(values, array_len) \
00629           PAPI_accum_counters(values, array_len)
00630 #define PAPIvi_num_counters \
00631           PAPI_num_counters
00632 #define PAPIvi_read_counters(values, array_len) \
00633           PAPI_read_counters(values, array_len)
00634 #define PAPIvi_start_counters(Events, array_len) \
00635           PAPI_start_counters(Events, array_len)
00636 #define PAPIvi_stop_counters(values, array_len) \
00637           PAPI_stop_counters(values, array_len)
00638 #define PAPIvi_flops(rtime, ptime, flpops, mflops) \
00639           PAPI_flops(rtime, ptime, flpops, mflops)
00640 
00641  /* New Supported Functions */
00642 #define PAPIvi_flips(rtime, ptime, flpins, mflips) \
00643           PAPI_flops(rtime, ptime, flpins, mflips)
00644 
00645  /* New Unupported Functions */
00646 #define PAPIvi_ipc(rtime, ptime, ins, ipc) \
00647           PAPI_ipc(rtime, ptime, ins, ipc)
00648 
00649 
00650 /*******************************************************************************
00651 * If PAPI_VERSION is defined, and the MAJOR version number is 3,
00652 * then papi.h is for PAPI 3.
00653 * The preprocessor block below contains definitions and macros needed to 
00654 * allow version independent linking to the PAPI 3 library.
00655 * Other than a handful of definitions to support calls to PAPI_{get,set}_opt(),
00656 * this layer simply converts version independent names to PAPI 3 library calls.
00657 ********************************************************************************/
00658 #elif (PAPI_VERSION_MAJOR(PAPI_VERSION) == 3)
00659 
00660 /*
00661 * The following option definitions reflect the fact that PAPI 2 had separate 
00662 * definitions for options to PAPI_set_opt and PAPI_get_opt, while PAPI 3 has
00663 * only a single set for both. By using the older naming convention, you can 
00664 * create platform independent code for these calls.
00665 */
00666 
00667 #define PAPI_SET_DEBUG     PAPI_DEBUG
00668 #define PAPI_GET_DEBUG     PAPI_DEBUG
00669 
00670 #define PAPI_SET_MULTIPLEX PAPI_MULTIPLEX
00671 #define PAPI_GET_MULTIPLEX PAPI_MULTIPLEX
00672 
00673 #define PAPI_SET_DEFDOM    PAPI_DEFDOM
00674 #define PAPI_GET_DEFDOM    PAPI_DEFDOM
00675 
00676 #define PAPI_SET_DOMAIN    PAPI_DOMAIN
00677 #define PAPI_GET_DOMAIN    PAPI_DOMAIN
00678 
00679 #define PAPI_SET_DEFGRN    PAPI_DEFGRN
00680 #define PAPI_GET_DEFGRN    PAPI_DEFGRN
00681 
00682 #define PAPI_SET_GRANUL    PAPI_GRANUL
00683 #define PAPI_GET_GRANUL    PAPI_GRANUL
00684 
00685 #define PAPI_SET_INHERIT   PAPI_INHERIT
00686 #define PAPI_GET_INHERIT   PAPI_INHERIT
00687 
00688 #define PAPI_GET_NUMCTRS   PAPI_NUMCTRS
00689 #define PAPI_SET_NUMCTRS   PAPI_NUMCTRS
00690 
00691 #define PAPI_SET_PROFIL    PAPI_PROFIL
00692 #define PAPI_GET_PROFIL    PAPI_PROFIL
00693 
00694 /*
00695 * These macros are simple pass-throughs to PAPI 3 structures
00696 */
00697 #define PAPIvi_hw_info_t   PAPI_hw_info_t
00698 #define PAPIvi_exe_info_t  PAPI_exe_info_t
00699 
00700 /*
00701 * The following macros are simple pass-throughs to PAPI 3 library calls
00702 */
00703  /* The Low Level API */
00704 #define PAPIvi_accum(EventSet, values) \
00705           PAPI_accum(EventSet, values)
00706 #define PAPIvi_add_event(EventSet, Event) \
00707           PAPI_add_event(EventSet, Event)
00708 #define PAPIvi_add_events(EventSet, Events, number) \
00709           PAPI_add_events(EventSet, Events, number)
00710 #define PAPIvi_cleanup_eventset(EventSet) \
00711           PAPI_cleanup_eventset(EventSet)
00712 #define PAPIvi_create_eventset(EventSet) \
00713           PAPI_create_eventset(EventSet)
00714 #define PAPIvi_destroy_eventset(EventSet) \
00715           PAPI_destroy_eventset(EventSet)
00716 #define PAPIvi_enum_event(EventCode, modifier) \
00717           PAPI_enum_event(EventCode, modifier)
00718 #define PAPIvi_event_code_to_name(EventCode, out) \
00719           PAPI_event_code_to_name(EventCode, out)
00720 #define PAPIvi_event_name_to_code(in, out) \
00721           PAPI_event_name_to_code(in, out)
00722 #define PAPIvi_get_dmem_info(option) \
00723           PAPI_get_dmem_info(option)
00724 #define PAPIvi_get_event_info(EventCode, info) \
00725           PAPI_get_event_info(EventCode, info)
00726 #define PAPIvi_get_executable_info \
00727           PAPI_get_executable_info
00728 #define PAPIvi_get_hardware_info \
00729           PAPI_get_hardware_info
00730 #define PAPIvi_get_multiplex(EventSet) \
00731           PAPI_get_multiplex(EventSet)
00732 #define PAPIvi_get_opt(option, ptr) \
00733           PAPI_get_opt(option, ptr)
00734 #define PAPIvi_get_real_cyc \
00735           PAPI_get_real_cyc
00736 #define PAPIvi_get_real_usec \
00737           PAPI_get_real_usec
00738 #define PAPIvi_get_shared_lib_info \
00739           PAPI_get_shared_lib_info
00740 #define PAPIvi_get_thr_specific(tag, ptr) \
00741           PAPI_get_thr_specific(tag, ptr)
00742 #define PAPIvi_get_virt_cyc \
00743           PAPI_get_virt_cyc
00744 #define PAPIvi_get_virt_usec \
00745           PAPI_get_virt_usec
00746 #define PAPIvi_is_initialized \
00747           PAPI_is_initialized
00748 #define PAPIvi_library_init(version) \
00749           PAPI_library_init(version)
00750 #define PAPIvi_list_events(EventSet, Events, number) \
00751           PAPI_list_events(EventSet, Events, number)
00752 #define PAPIvi_lock(lck) \
00753           PAPI_lock(lck)
00754 #define PAPIvi_multiplex_init \
00755           PAPI_multiplex_init
00756 #define PAPIvi_num_hwctrs \
00757           PAPI_num_hwctrs
00758 #define PAPIvi_num_events(EventSet) \
00759           PAPI_num_events(EventSet)
00760 #define PAPIvi_overflow(EventSet, EventCode, threshold, flags, handler) \
00761           PAPI_overflow(EventSet, EventCode, threshold, flags, handler)
00762 #define PAPIvi_perror( s ) \
00763           PAPI_perror( s )
00764 #define PAPIvi_profil(buf, bufsiz, offset, scale, EventSet, EventCode, threshold, flags) \
00765           PAPI_profil(buf, bufsiz, offset, scale, EventSet, EventCode, threshold, flags)
00766 #define PAPIvi_query_event(EventCode) \
00767           PAPI_query_event(EventCode)
00768 #define PAPIvi_read(EventSet, values) \
00769           PAPI_read(EventSet, values)
00770 #define PAPIvi_register_thread \
00771           PAPI_register_thread
00772 #define PAPIvi_remove_event(EventSet, EventCode) \
00773           PAPI_remove_event(EventSet, EventCode)
00774 #define PAPIvi_remove_events(EventSet, Events, number) \
00775           PAPI_remove_events(EventSet, Events, number)
00776 #define PAPIvi_reset(EventSet) \
00777           PAPI_reset(EventSet)
00778 #define PAPIvi_set_debug(level) \
00779           PAPI_set_debug(level)
00780 #define PAPIvi_set_domain(domain) \
00781           PAPI_set_domain(domain)
00782 #define PAPIvi_set_granularity(granularity) \
00783           PAPI_set_granularity(granularity)
00784 #define PAPIvi_set_multiplex(EventSet) \
00785           PAPI_set_multiplex(EventSet)
00786 #define PAPIvi_set_opt(option, ptr) \
00787           PAPI_set_opt(option, ptr)
00788 #define PAPIvi_set_thr_specific(tag, ptr) \
00789           PAPI_set_thr_specific(tag, ptr)
00790 #define PAPIvi_shutdown \
00791           PAPI_shutdown
00792 #define PAPIvi_sprofil(prof, profcnt, EventSet, EventCode, threshold, flags) \
00793           PAPI_sprofil(prof, profcnt, EventSet, EventCode, threshold, flags)
00794 #define PAPIvi_start(EventSet) \
00795           PAPI_start(EventSet)
00796 #define PAPIvi_state(EventSet, status) \
00797           PAPI_state(EventSet, status)
00798 #define PAPIvi_stop(EventSet, values) \
00799           PAPI_stop(EventSet, values)
00800 #define PAPIvi_strerror(err) \
00801           PAPI_strerror(err)
00802 #define PAPIvi_thread_id \
00803           PAPI_thread_id
00804 #define PAPIvi_thread_init(id_fn) \
00805           PAPI_thread_init(id_fn)
00806 #define PAPIvi_unlock(lck) \
00807           PAPI_unlock(lck)
00808 #define PAPIvi_write(EventSet, values) \
00809           PAPI_write(EventSet, values)
00810 
00811    /* The High Level API */
00812 
00813 #define PAPIvi_accum_counters(values, array_len) \
00814           PAPI_accum_counters(values, array_len)
00815 #define PAPIvi_num_counters \
00816           PAPI_num_counters
00817 #define PAPIvi_read_counters(values, array_len) \
00818           PAPI_read_counters(values, array_len)
00819 #define PAPIvi_start_counters(Events, array_len) \
00820           PAPI_start_counters(Events, array_len)
00821 #define PAPIvi_stop_counters(values, array_len) \
00822           PAPI_stop_counters(values, array_len)
00823 #define PAPIvi_flips(rtime, ptime, flpins, mflips) \
00824           PAPI_flips(rtime, ptime, flpins, mflips)
00825 #define PAPIvi_flops(rtime, ptime, flpops, mflops) \
00826           PAPI_flops(rtime, ptime, flpops, mflops)
00827 #define PAPIvi_ipc(rtime, ptime, ins, ipc) \
00828           PAPI_ipc(rtime, ptime, ins, ipc)
00829 
00830 
00831 /*******************************************************************************
00832 * If PAPI_VERSION is defined, and the MAJOR version number is not 3, then we
00833 * generate an error message.
00834 * This block allows us to support future version with a 
00835 * version independent syntax.
00836 ********************************************************************************/
00837 #else
00838 #error Compiling against a not yet released PAPI version
00839 #endif
00840 
00841 #endif /* _PAPIVI */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines