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