PAPI  5.1.0.2
papi_fwrappers.c
Go to the documentation of this file.
00001 /****************************/
00002 /* THIS IS OPEN SOURCE CODE */
00003 /****************************/
00004 
00005 /* 
00006 * File:    papi_fwrappers.c
00007 * CVS:     $Id$
00008 * Author:  Philip Mucci
00009 *          mucci@cs.utk.edu
00010 * Mods:    Nils Smeds
00011 *          smeds@pdc.kth.se
00012 *          Anders Nilsson
00013 *          anni@pdc.kth.se
00014 *      Kevin London
00015 *      london@cs.utk.edu
00016 *      dan terpstra
00017 *      terpstra@cs.utk.edu
00018 *          Min Zhou
00019 *      min@cs.utk.edu
00020 */
00021 
00022 #include <stdio.h>
00023 #include <assert.h>
00024 #include <string.h>
00025 #include "papi.h"
00026 
00027 /* Lets use defines to rename all the files */
00028 
00029 #ifdef FORTRANUNDERSCORE
00030 #define PAPI_FCALL(function,caps,args) void function##_ args
00031 #elif FORTRANDOUBLEUNDERSCORE
00032 #define PAPI_FCALL(function,caps,args) void function##__ args
00033 #elif FORTRANCAPS
00034 #define PAPI_FCALL(function,caps,args) void caps args
00035 #else
00036 #define PAPI_FCALL(function,caps,args) void function args
00037 #endif
00038 
00039 /* Many Unix systems passes Fortran string lengths as extra arguments */
00040 #if defined(_AIX) || defined(sun) || defined(linux)
00041 #define _FORTRAN_STRLEN_AT_END
00042 #endif
00043 /* The Low Level Wrappers */
00044 
00047 /* helper routine to convert Fortran strings to C strings */
00048 #if defined(_FORTRAN_STRLEN_AT_END)
00049 static void Fortran2cstring( char *cstring, char *Fstring, int clen , int Flen )
00050 {
00051     int slen, i;
00052 
00053     /* What is the maximum number of chars to copy ? */
00054     slen = Flen < clen ? Flen : clen;
00055     strncpy( cstring, Fstring, ( size_t ) slen );
00056 
00057     /* Remove trailing blanks from initial Fortran string */
00058     for ( i = slen - 1; i > -1 && cstring[i] == ' '; cstring[i--] = '\0' );
00059 
00060     /* Make sure string is NULL terminated */
00061     cstring[clen - 1] = '\0';
00062     if ( slen < clen )
00063         cstring[slen] = '\0';
00064 }
00065 #endif
00066 
00077 PAPI_FCALL( papif_accum, PAPIF_ACCUM,
00078             ( int *EventSet, long long *values, int *check ) )
00079 {
00080     *check = PAPI_accum( *EventSet, values );
00081 }
00082 
00093 PAPI_FCALL( papif_add_event, PAPIF_ADD_EVENT,
00094             ( int *EventSet, int *Event, int *check ) )
00095 {
00096     *check = PAPI_add_event( *EventSet, *Event );
00097 }
00098 
00109 #if defined(_FORTRAN_STRLEN_AT_END)
00110 PAPI_FCALL( papif_add_named_event, PAPIF_ADD_NAMED_EVENT,
00111             ( int *EventSet, char *EventName, int *check, int Event_len ) )
00112 {
00113     char tmp[PAPI_MAX_STR_LEN];
00114     Fortran2cstring( tmp, EventName, PAPI_MAX_STR_LEN, Event_len );
00115     *check = PAPI_add_named_event( *EventSet, tmp );    
00116 }
00117 #else
00118 PAPI_FCALL( papif_add_named_event, PAPIF_ADD_NAMED_EVENT,
00119             ( int *EventSet, char *EventName, int *check ) )
00120 {
00121     *check = PAPI_add_named_event( *EventSet, EventName );
00122 }
00123 #endif
00124 
00135 PAPI_FCALL( papif_add_events, PAPIF_ADD_EVENTS,
00136             ( int *EventSet, int *Events, int *number, int *check ) )
00137 {
00138     *check = PAPI_add_events( *EventSet, Events, *number );
00139 }
00140 
00151 PAPI_FCALL( papif_cleanup_eventset, PAPIF_CLEANUP_EVENTSET,
00152             ( int *EventSet, int *check ) )
00153 {
00154     *check = PAPI_cleanup_eventset( *EventSet );
00155 }
00156 
00167 PAPI_FCALL( papif_create_eventset, PAPIF_CREATE_EVENTSET,
00168             ( int *EventSet, int *check ) )
00169 {
00170     *check = PAPI_create_eventset( EventSet );
00171 }
00172 
00183 PAPI_FCALL( papif_assign_eventset_component, PAPIF_ASSIGN_EVENTSET_COMPONENT,
00184             ( int *EventSet, int *cidx, int *check ) )
00185 {
00186     *check = PAPI_assign_eventset_component( *EventSet, *cidx );
00187 }
00188 
00199 PAPI_FCALL( papif_destroy_eventset, PAPIF_DESTROY_EVENTSET,
00200             ( int *EventSet, int *check ) )
00201 {
00202     *check = PAPI_destroy_eventset( EventSet );
00203 }
00204 
00215  /* XXX This looks totally broken. Should be passed all the members of the dmem_info struct. */
00216 PAPI_FCALL( papif_get_dmem_info, PAPIF_GET_DMEM_INFO,
00217             ( long long *dest, int *check ) )
00218 {
00219     *check = PAPI_get_dmem_info( ( PAPI_dmem_info_t * ) dest );
00220 }
00221 
00235 #if defined(_FORTRAN_STRLEN_AT_END)
00236 PAPI_FCALL( papif_get_exe_info, PAPIF_GET_EXE_INFO,
00237             ( char *fullname, char *name, long long *text_start,
00238               long long *text_end, long long *data_start, long long *data_end,
00239               long long *bss_start, long long *bss_end,
00240               int *check, int fullname_len, int name_len ) )
00241 #else
00242 PAPI_FCALL( papif_get_exe_info, PAPIF_GET_EXE_INFO,
00243             ( char *fullname, char *name, long long *text_start,
00244               long long *text_end, long long *data_start, long long *data_end,
00245               long long *bss_start, long long *bss_end, int *check ) )
00246 #endif
00247 {
00248     PAPI_option_t e;
00249 /* WARNING: The casts from caddr_t to long below WILL BREAK on systems with
00250     64-bit addresses. I did it here because I was lazy. And because I wanted
00251     to get rid of those pesky gcc warnings. If you find a 64-bit system,
00252     conditionalize the cast with (yet another) #ifdef...
00253 */
00254     if ( ( *check = PAPI_get_opt( PAPI_EXEINFO, &e ) ) == PAPI_OK ) {
00255 #if defined(_FORTRAN_STRLEN_AT_END)
00256         int i;
00257         strncpy( fullname, e.exe_info->fullname, ( size_t ) fullname_len );
00258         for ( i = ( int ) strlen( e.exe_info->fullname ); i < fullname_len;
00259               fullname[i++] = ' ' );
00260         strncpy( name, e.exe_info->address_info.name, ( size_t ) name_len );
00261         for ( i = ( int ) strlen( e.exe_info->address_info.name ); i < name_len;
00262               name[i++] = ' ' );
00263 #else
00264         strncpy( fullname, e.exe_info->fullname, PAPI_MAX_STR_LEN );
00265         strncpy( name, e.exe_info->address_info.name, PAPI_MAX_STR_LEN );
00266 #endif
00267         *text_start = ( long ) e.exe_info->address_info.text_start;
00268         *text_end = ( long ) e.exe_info->address_info.text_end;
00269         *data_start = ( long ) e.exe_info->address_info.data_start;
00270         *data_end = ( long ) e.exe_info->address_info.data_end;
00271         *bss_start = ( long ) e.exe_info->address_info.bss_start;
00272         *bss_end = ( long ) e.exe_info->address_info.bss_end;
00273     }
00274 }
00275 
00288 #if defined(_FORTRAN_STRLEN_AT_END)
00289 PAPI_FCALL( papif_get_hardware_info, PAPIF_GET_HARDWARE_INFO, ( int *ncpu,
00290                                                                 int *nnodes,
00291                                                                 int *totalcpus,
00292                                                                 int *vendor,
00293                                                                 char
00294                                                                 *vendor_str,
00295                                                                 int *model,
00296                                                                 char *model_str,
00297                                                                 float *revision,
00298                                                                 float *mhz,
00299                                                                 int vendor_len,
00300                                                                 int
00301                                                                 model_len ) )
00302 #else
00303 PAPI_FCALL( papif_get_hardware_info, PAPIF_GET_HARDWARE_INFO, ( int *ncpu,
00304                                                                 int *nnodes,
00305                                                                 int *totalcpus,
00306                                                                 int *vendor,
00307                                                                 char
00308                                                                 *vendor_string,
00309                                                                 int *model,
00310                                                                 char
00311                                                                 *model_string,
00312                                                                 float *revision,
00313                                                                 float *mhz ) )
00314 #endif
00315 {
00316     const PAPI_hw_info_t *hwinfo;
00317     int i;
00318     hwinfo = PAPI_get_hardware_info(  );
00319     if ( hwinfo == NULL ) {
00320         *ncpu = 0;
00321         *nnodes = 0;
00322         *totalcpus = 0;
00323         *vendor = 0;
00324         *model = 0;
00325         *revision = 0;
00326         *mhz = 0;
00327     } else {
00328         *ncpu = hwinfo->ncpu;
00329         *nnodes = hwinfo->nnodes;
00330         *totalcpus = hwinfo->totalcpus;
00331         *vendor = hwinfo->vendor;
00332         *model = hwinfo->model;
00333         *revision = hwinfo->revision;
00334         *mhz = hwinfo->cpu_max_mhz;
00335 #if defined(_FORTRAN_STRLEN_AT_END)
00336         strncpy( vendor_str, hwinfo->vendor_string, ( size_t ) vendor_len );
00337         for ( i = ( int ) strlen( hwinfo->vendor_string ); i < vendor_len;
00338               vendor_str[i++] = ' ' );
00339         strncpy( model_str, hwinfo->model_string, ( size_t ) model_len );
00340         for ( i = ( int ) strlen( hwinfo->model_string ); i < model_len;
00341               model_str[i++] = ' ' );
00342 #else
00343         (void)i; /* unused...  */
00344         /* This case needs the passed strings to be of sufficient size *
00345          * and will include the NULL character in the target string    */
00346         strcpy( vendor_string, hwinfo->vendor_string );
00347         strcpy( model_string, hwinfo->model_string );
00348 #endif
00349     }
00350     return;
00351 }
00352 
00364 PAPI_FCALL( papif_num_hwctrs, PAPIF_num_hwctrs, ( int *num ) )
00365 {
00366     *num = PAPI_num_hwctrs(  );
00367 }
00368 
00380 PAPI_FCALL( papif_num_cmp_hwctrs, PAPIF_num_cmp_hwctrs,
00381             ( int *cidx, int *num ) )
00382 {
00383     *num = PAPI_num_cmp_hwctrs( *cidx );
00384 }
00385 
00396 PAPI_FCALL( papif_get_real_cyc, PAPIF_GET_REAL_CYC, ( long long *real_cyc ) )
00397 {
00398     *real_cyc = PAPI_get_real_cyc(  );
00399 }
00400 
00411 PAPI_FCALL( papif_get_real_usec, PAPIF_GET_REAL_USEC, ( long long *time ) )
00412 {
00413     *time = PAPI_get_real_usec(  );
00414 }
00415 
00426 PAPI_FCALL( papif_get_real_nsec, PAPIF_GET_REAL_NSEC, ( long long *time ) )
00427 {
00428     *time = PAPI_get_real_nsec(  );
00429 }
00430 
00441 PAPI_FCALL( papif_get_virt_cyc, PAPIF_GET_VIRT_CYC, ( long long *virt_cyc ) )
00442 {
00443     *virt_cyc = PAPI_get_virt_cyc(  );
00444 }
00445 
00456 PAPI_FCALL( papif_get_virt_usec, PAPIF_GET_VIRT_USEC, ( long long *time ) )
00457 {
00458     *time = PAPI_get_virt_usec(  );
00459 }
00460 
00471 PAPI_FCALL( papif_is_initialized, PAPIF_IS_INITIALIZED, ( int *level ) )
00472 {
00473     *level = PAPI_is_initialized(  );
00474 }
00475 
00486 PAPI_FCALL( papif_library_init, PAPIF_LIBRARY_INIT, ( int *check ) )
00487 {
00488     *check = PAPI_library_init( *check );
00489 }
00490 
00501 PAPI_FCALL( papif_thread_id, PAPIF_THREAD_ID, ( unsigned long *id ) )
00502 {
00503     *id = PAPI_thread_id(  );
00504 }
00505 
00516 PAPI_FCALL( papif_register_thread, PAPIF_REGISTER_THREAD, ( int *check ) )
00517 {
00518     *check = PAPI_register_thread(  );
00519 }
00520 
00531 PAPI_FCALL( papif_unregster_thread, PAPIF_UNREGSTER_THREAD, ( int *check ) )
00532 {
00533     *check = PAPI_unregister_thread(  );
00534 }
00535 
00546 /* This must be passed an EXTERNAL or INTRINISIC FUNCTION not a SUBROUTINE */
00547 PAPI_FCALL( papif_thread_init, PAPIF_THREAD_INIT,
00548             ( unsigned long int ( *handle ) ( void ), int *check ) )
00549 {
00550     *check = PAPI_thread_init( handle );
00551 }
00552 
00563 PAPI_FCALL( papif_list_events, PAPIF_LIST_EVENTS,
00564             ( int *EventSet, int *Events, int *number, int *check ) )
00565 {
00566     *check = PAPI_list_events( *EventSet, Events, number );
00567 }
00568 
00579 PAPI_FCALL( papif_multiplex_init, PAPIF_MULTIPLEX_INIT, ( int *check ) )
00580 {
00581     *check = PAPI_multiplex_init(  );
00582 }
00583 
00594 PAPI_FCALL( papif_get_multiplex, PAPIF_GET_MULTIPLEX,
00595             ( int *EventSet, int *check ) )
00596 {
00597     *check = PAPI_get_multiplex( *EventSet );
00598 }
00599 
00610 PAPI_FCALL( papif_set_multiplex, PAPIF_SET_MULTIPLEX,
00611             ( int *EventSet, int *check ) )
00612 {
00613     *check = PAPI_set_multiplex( *EventSet );
00614 }
00615 
00626 #if defined(_FORTRAN_STRLEN_AT_END)
00627 PAPI_FCALL( papif_perror, PAPIF_PERROR,
00628             ( char *message,
00629               int message_len ) )
00630 #else
00631 PAPI_FCALL( papif_perror, PAPIF_PERROR,
00632             ( char *message ) )
00633 #endif
00634 {
00635 #if defined(_FORTRAN_STRLEN_AT_END)
00636         char tmp[PAPI_MAX_STR_LEN];
00637         Fortran2cstring( tmp, message, PAPI_MAX_STR_LEN, message_len );
00638 
00639     PAPI_perror( tmp );
00640 #else
00641     PAPI_perror( message );
00642 #endif
00643 }
00644 
00645 /* This will not work until Fortran2000 :)
00646  * PAPI_FCALL(papif_profil, PAPIF_PROFIL, (unsigned short *buf, unsigned *bufsiz, unsigned long *offset, unsigned *scale, unsigned *eventset, 
00647  *            unsigned *eventcode, unsigned *threshold, unsigned *flags, unsigned *check))
00648  * {
00649  * *check = PAPI_profil(buf, *bufsiz, *offset, *scale, *eventset, *eventcode, *threshold, *flags);
00650  * }
00651  */
00652 
00663 PAPI_FCALL( papif_query_event, PAPIF_QUERY_EVENT,
00664             ( int *EventCode, int *check ) )
00665 {
00666     *check = PAPI_query_event( *EventCode );
00667 }
00668 
00679 #if defined(_FORTRAN_STRLEN_AT_END)
00680 PAPI_FCALL( papif_query_named_event, PAPIF_QUERY_NAMED_EVENT,
00681             ( char *EventName, int *check, int Event_len ) )
00682 {
00683     char tmp[PAPI_MAX_STR_LEN];
00684     Fortran2cstring( tmp, EventName, PAPI_MAX_STR_LEN, Event_len );
00685     *check = PAPI_query_named_event( tmp ); 
00686 }
00687 #else
00688 PAPI_FCALL( papif_query_named_event, PAPIF_QUERY_NAMED_EVENT,
00689             ( char *EventName, int *check ) )
00690 {
00691     *check = PAPI_query_named_event( EventName );
00692 }
00693 #endif
00694 
00707 #if defined(_FORTRAN_STRLEN_AT_END)
00708 PAPI_FCALL( papif_get_event_info, PAPIF_GET_EVENT_INFO,
00709             ( int *EventCode, char *symbol, char *long_descr, char *short_descr,
00710               int *count, char *event_note, int *flags, int *check,
00711               int symbol_len, int long_descr_len, int short_descr_len,
00712               int event_note_len ) )
00713 #else
00714 PAPI_FCALL( papif_get_event_info, PAPIF_GET_EVENT_INFO,
00715             ( int *EventCode, char *symbol, char *long_descr, char *short_descr,
00716               int *count, char *event_note, int *flags, int *check ) )
00717 #endif
00718 {
00719     PAPI_event_info_t info;
00720     ( void ) flags;          /*Unused */
00721 #if defined(_FORTRAN_STRLEN_AT_END)
00722     int i;
00723     if ( ( *check = PAPI_get_event_info( *EventCode, &info ) ) == PAPI_OK ) {
00724         strncpy( symbol, info.symbol, ( size_t ) symbol_len );
00725         for ( i = ( int ) strlen( info.symbol ); i < symbol_len;
00726               symbol[i++] = ' ' );
00727         strncpy( long_descr, info.long_descr, ( size_t ) long_descr_len );
00728         for ( i = ( int ) strlen( info.long_descr ); i < long_descr_len;
00729               long_descr[i++] = ' ' );
00730         strncpy( short_descr, info.short_descr, ( size_t ) short_descr_len );
00731         for ( i = ( int ) strlen( info.short_descr ); i < short_descr_len;
00732               short_descr[i++] = ' ' );
00733 
00734         *count = ( int ) info.count;
00735 
00736         int note_len=0;
00737 
00738         strncpy( event_note, info.note,  ( size_t ) event_note_len );
00739         note_len=strlen(info.note);
00740 
00741         for ( i =  note_len; i < event_note_len;
00742               event_note[i++] = ' ' );
00743     }
00744 #else
00745 /* printf("EventCode: %d\n", *EventCode ); -KSL */
00746     if ( ( *check = PAPI_get_event_info( *EventCode, &info ) ) == PAPI_OK ) {
00747         strncpy( symbol, info.symbol, PAPI_MAX_STR_LEN );
00748         strncpy( long_descr, info.long_descr, PAPI_MAX_STR_LEN );
00749         strncpy( short_descr, info.short_descr, PAPI_MAX_STR_LEN );
00750         *count = info.count;
00751         if (info.note) 
00752                    strncpy( event_note, info.note, 
00753                 PAPI_MAX_STR_LEN );
00754     }
00755 /*  printf("Check: %d\n", *check); -KSL */
00756 #endif
00757 }
00758 
00769 #if defined(_FORTRAN_STRLEN_AT_END)
00770 PAPI_FCALL( papif_event_code_to_name, PAPIF_EVENT_CODE_TO_NAME,
00771             ( int *EventCode, char *out_str, int *check, int out_len ) )
00772 #else
00773 PAPI_FCALL( papif_event_code_to_name, PAPIF_EVENT_CODE_TO_NAME,
00774             ( int *EventCode, char *out, int *check ) )
00775 #endif
00776 {
00777 #if defined(_FORTRAN_STRLEN_AT_END)
00778     char tmp[PAPI_MAX_STR_LEN];
00779     int i;
00780     *check = PAPI_event_code_to_name( *EventCode, tmp );
00781     /* tmp has \0 within PAPI_MAX_STR_LEN chars so strncpy is safe */
00782     strncpy( out_str, tmp, ( size_t ) out_len );
00783     /* overwrite any NULLs and trailing garbage in out_str */
00784     for ( i = ( int ) strlen( tmp ); i < out_len; out_str[i++] = ' ' );
00785 #else
00786     /* The array "out" passed by the user must be sufficiently long */
00787     *check = PAPI_event_code_to_name( *EventCode, out );
00788 #endif
00789 }
00790 
00801 #if defined(_FORTRAN_STRLEN_AT_END)
00802 PAPI_FCALL( papif_event_name_to_code, PAPIF_EVENT_NAME_TO_CODE,
00803             ( char *in_str, int *out, int *check, int in_len ) )
00804 #else
00805 PAPI_FCALL( papif_event_name_to_code, PAPIF_EVENT_NAME_TO_CODE,
00806             ( char *in, int *out, int *check ) )
00807 #endif
00808 {
00809 #if defined(_FORTRAN_STRLEN_AT_END)
00810     int slen, i;
00811     char tmpin[PAPI_MAX_STR_LEN];
00812 
00813     /* What is the maximum number of chars to copy ? */
00814     slen = in_len < PAPI_MAX_STR_LEN ? in_len : PAPI_MAX_STR_LEN;
00815     strncpy( tmpin, in_str, ( size_t ) slen );
00816 
00817     /* Remove trailing blanks from initial Fortran string */
00818     for ( i = slen - 1; i > -1 && tmpin[i] == ' '; tmpin[i--] = '\0' );
00819 
00820     /* Make sure string is NULL terminated before call */
00821     tmpin[PAPI_MAX_STR_LEN - 1] = '\0';
00822     if ( slen < PAPI_MAX_STR_LEN )
00823         tmpin[slen] = '\0';
00824 
00825     *check = PAPI_event_name_to_code( tmpin, out );
00826 #else
00827     /* This will have trouble if argument in is not null terminated */
00828     *check = PAPI_event_name_to_code( in, out );
00829 #endif
00830 }
00831 
00842 PAPI_FCALL( papif_num_events, PAPIF_NUM_EVENTS, ( int *EventCode, int *count ) )
00843 {
00844     *count = PAPI_num_events( *EventCode );
00845 }
00846 
00857 PAPI_FCALL( papif_enum_event, PAPIF_ENUM_EVENT,
00858             ( int *EventCode, int *modifier, int *check ) )
00859 {
00860     *check = PAPI_enum_event( EventCode, *modifier );
00861 }
00862 
00873 PAPI_FCALL( papif_read, PAPIF_READ,
00874             ( int *EventSet, long long *values, int *check ) )
00875 {
00876     *check = PAPI_read( *EventSet, values );
00877 }
00878 
00889 PAPI_FCALL( papif_read_ts, PAPIF_READ_TS,
00890             ( int *EventSet, long long *values, long long *cycles, int *check ) )
00891 {
00892     *check = PAPI_read_ts( *EventSet, values, cycles );
00893 }
00894 
00905 PAPI_FCALL( papif_remove_event, PAPIF_REMOVE_EVENT,
00906             ( int *EventSet, int *Event, int *check ) )
00907 {
00908     *check = PAPI_remove_event( *EventSet, *Event );
00909 }
00910 
00921 #if defined(_FORTRAN_STRLEN_AT_END)
00922 PAPI_FCALL( papif_remove_named_event, PAPIF_REMOVE_NAMED_EVENT,
00923             ( int *EventSet, char *EventName, int *check, int Event_len ) )
00924 {
00925     char tmp[PAPI_MAX_STR_LEN];
00926     Fortran2cstring( tmp, EventName, PAPI_MAX_STR_LEN, Event_len );
00927     *check = PAPI_remove_named_event( *EventSet, tmp ); 
00928 }
00929 #else
00930 PAPI_FCALL( papif_remove_named_event, PAPIF_REMOVE_NAMED_EVENT,
00931             ( int *EventSet, char *EventName, int *check ) )
00932 {
00933     *check = PAPI_remove_named_event( *EventSet, EventName );
00934 }
00935 #endif
00936 
00947 PAPI_FCALL( papif_remove_events, PAPIF_REMOVE_EVENTS,
00948             ( int *EventSet, int *Events, int *number, int *check ) )
00949 {
00950     *check = PAPI_remove_events( *EventSet, Events, *number );
00951 }
00952 
00963 PAPI_FCALL( papif_reset, PAPIF_RESET, ( int *EventSet, int *check ) )
00964 {
00965     *check = PAPI_reset( *EventSet );
00966 }
00967 
00978 PAPI_FCALL( papif_set_debug, PAPIF_SET_DEBUG, ( int *debug, int *check ) )
00979 {
00980     *check = PAPI_set_debug( *debug );
00981 }
00982 
00993 PAPI_FCALL( papif_set_domain, PAPIF_SET_DOMAIN, ( int *domain, int *check ) )
00994 {
00995     *check = PAPI_set_domain( *domain );
00996 }
00997 
01008 PAPI_FCALL( papif_set_cmp_domain, PAPIF_SET_CMP_DOMAIN,
01009             ( int *domain, int *cidx, int *check ) )
01010 {
01011     *check = PAPI_set_cmp_domain( *domain, *cidx );
01012 }
01013 
01024 PAPI_FCALL( papif_set_granularity, PAPIF_SET_GRANULARITY,
01025             ( int *granularity, int *check ) )
01026 {
01027     *check = PAPI_set_granularity( *granularity );
01028 }
01029 
01040 PAPI_FCALL( papif_set_cmp_granularity, PAPIF_SET_CMP_GRANULARITY,
01041             ( int *granularity, int *cidx, int *check ) )
01042 {
01043     *check = PAPI_set_cmp_granularity( *granularity, *cidx );
01044 }
01045 
01056 PAPI_FCALL( papif_shutdown, PAPIF_SHUTDOWN, ( void ) )
01057 {
01058     PAPI_shutdown(  );
01059 }
01060 
01071 PAPI_FCALL( papif_start, PAPIF_START, ( int *EventSet, int *check ) )
01072 {
01073     *check = PAPI_start( *EventSet );
01074 }
01075 
01086 PAPI_FCALL( papif_state, PAPIF_STATE,
01087             ( int *EventSet, int *status, int *check ) )
01088 {
01089     *check = PAPI_state( *EventSet, status );
01090 }
01091 
01102 PAPI_FCALL( papif_stop, PAPIF_STOP,
01103             ( int *EventSet, long long *values, int *check ) )
01104 {
01105     *check = PAPI_stop( *EventSet, values );
01106 }
01107 
01118 PAPI_FCALL( papif_write, PAPIF_WRITE,
01119             ( int *EventSet, long long *values, int *check ) )
01120 {
01121     *check = PAPI_write( *EventSet, values );
01122 }
01123 
01134 PAPI_FCALL( papif_lock, PAPIF_LOCK,
01135             ( int *lock, int *check ) )
01136 {
01137     *check = PAPI_lock( *lock );
01138 }
01139 
01150 PAPI_FCALL( papif_unlock, PAPIF_unlock,
01151             ( int *lock, int *check ) )
01152 {
01153     *check = PAPI_unlock( *lock );
01154 }
01155 
01156 /* The High Level API Wrappers */
01157 
01168 PAPI_FCALL( papif_start_counters, PAPIF_START_COUNTERS,
01169             ( int *events, int *array_len, int *check ) )
01170 {
01171     *check = PAPI_start_counters( events, *array_len );
01172 }
01173 
01184 PAPI_FCALL( papif_read_counters, PAPIF_READ_COUNTERS,
01185             ( long long *values, int *array_len, int *check ) )
01186 {
01187     *check = PAPI_read_counters( values, *array_len );
01188 }
01189 
01200 PAPI_FCALL( papif_stop_counters, PAPIF_STOP_COUNTERS,
01201             ( long long *values, int *array_len, int *check ) )
01202 {
01203     *check = PAPI_stop_counters( values, *array_len );
01204 }
01205 
01216 PAPI_FCALL( papif_accum_counters, PAPIF_ACCUM_COUNTERS,
01217             ( long long *values, int *array_len, int *check ) )
01218 {
01219     *check = PAPI_accum_counters( values, *array_len );
01220 }
01221 
01232 PAPI_FCALL( papif_num_counters, PAPIF_NUM_COUNTERS, ( int *numevents ) )
01233 {
01234     *numevents = PAPI_num_counters(  );
01235 }
01236 
01247 PAPI_FCALL( papif_ipc, PAPIF_IPC,
01248             ( float *rtime, float *ptime, long long *ins, float *ipc,
01249               int *check ) )
01250 {
01251     *check = PAPI_ipc( rtime, ptime, ins, ipc );
01252 }
01253 
01264 PAPI_FCALL( papif_flips, PAPIF_FLIPS,
01265             ( float *real_time, float *proc_time, long long *flpins,
01266               float *mflips, int *check ) )
01267 {
01268     *check = PAPI_flips( real_time, proc_time, flpins, mflips );
01269 }
01270 
01281 PAPI_FCALL( papif_flops, PAPIF_FLOPS,
01282             ( float *real_time, float *proc_time, long long *flpops,
01283               float *mflops, int *check ) )
01284 {
01285     *check = PAPI_flops( real_time, proc_time, flpops, mflops );
01286 }
01287 
01288 
01289 /* Fortran only APIs for get_opt and set_opt functionality */
01290 
01303 PAPI_FCALL( papif_get_clockrate, PAPIF_GET_CLOCKRATE, ( int *cr ) )
01304 {
01305     *cr = PAPI_get_opt( PAPI_CLOCKRATE, NULL );
01306 }
01307 
01320 #if defined(_FORTRAN_STRLEN_AT_END)
01321 PAPI_FCALL( papif_get_preload, PAPIF_GET_PRELOAD,
01322             ( char *lib_preload_env, int *check, int lib_preload_env_len ) )
01323 #else
01324 PAPI_FCALL( papif_get_preload, PAPIF_GET_PRELOAD,
01325             ( char *lib_preload_env, int *check ) )
01326 #endif
01327 {
01328     PAPI_option_t p;
01329 #if defined(_FORTRAN_STRLEN_AT_END)
01330     int i;
01331 
01332     if ( ( *check = PAPI_get_opt( PAPI_PRELOAD, &p ) ) == PAPI_OK ) {
01333         strncpy( lib_preload_env, p.preload.lib_preload_env,
01334                  ( size_t ) lib_preload_env_len );
01335         for ( i = ( int ) strlen( p.preload.lib_preload_env );
01336               i < lib_preload_env_len; lib_preload_env[i++] = ' ' );
01337     }
01338 #else
01339     if ( ( *check = PAPI_get_opt( PAPI_PRELOAD, &p ) ) == PAPI_OK ) {
01340         strncpy( lib_preload_env, p.preload.lib_preload_env, PAPI_MAX_STR_LEN );
01341     }
01342 #endif
01343 }
01344 
01355 PAPI_FCALL( papif_get_granularity, PAPIF_GET_GRANULARITY,
01356             ( int *eventset, int *granularity, int *mode, int *check ) )
01357 {
01358     PAPI_option_t g;
01359 
01360     if ( *mode == PAPI_DEFGRN ) {
01361         *granularity = PAPI_get_opt( *mode, &g );
01362         *check = PAPI_OK;
01363     } else if ( *mode == PAPI_GRANUL ) {
01364         g.granularity.eventset = *eventset;
01365         if ( ( *check = PAPI_get_opt( *mode, &g ) ) == PAPI_OK ) {
01366             *granularity = g.granularity.granularity;
01367         }
01368     } else {
01369         *check = PAPI_EINVAL;
01370     }
01371 }
01372 
01383 PAPI_FCALL( papif_get_domain, PAPIF_GET_DOMAIN,
01384             ( int *eventset, int *domain, int *mode, int *check ) )
01385 {
01386     PAPI_option_t d;
01387 
01388     if ( *mode == PAPI_DEFDOM ) {
01389         *domain = PAPI_get_opt( *mode, NULL );
01390         *check = PAPI_OK;
01391     } else if ( *mode == PAPI_DOMAIN ) {
01392         d.domain.eventset = *eventset;
01393         if ( ( *check = PAPI_get_opt( *mode, &d ) ) == PAPI_OK ) {
01394             *domain = d.domain.domain;
01395         }
01396     } else {
01397         *check = PAPI_EINVAL;
01398     }
01399 }
01400 
01401 #if 0
01402 PAPI_FCALL( papif_get_inherit, PAPIF_GET_INHERIT, ( int *inherit, int *check ) )
01403 {
01404     PAPI_option_t i;
01405 
01406     if ( ( *check = PAPI_get_opt( PAPI_INHERIT, &i ) ) == PAPI_OK ) {
01407         *inherit = i.inherit.inherit;
01408     }
01409 }
01410 #endif
01411 
01423 PAPI_FCALL( papif_set_event_domain, PAPIF_SET_EVENT_DOMAIN,
01424             ( int *es, int *domain, int *check ) )
01425 {
01426     PAPI_option_t d;
01427 
01428     d.domain.domain = *domain;
01429     d.domain.eventset = *es;
01430     *check = PAPI_set_opt( PAPI_DOMAIN, &d );
01431 }
01432 
01443 PAPI_FCALL( papif_set_inherit, PAPIF_SET_INHERIT, ( int *inherit, int *check ) )
01444 {
01445     PAPI_option_t i;
01446 
01447     i.inherit.inherit = *inherit;
01448     *check = PAPI_set_opt( PAPI_INHERIT, &i );
01449 }
01450 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines