PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
papi_fwrappers.c
Go to the documentation of this file.
1 /****************************/
2 /* THIS IS OPEN SOURCE CODE */
3 /****************************/
4 
5 /*
6 * File: papi_fwrappers.c
7 * CVS: $Id$
8 * Author: Philip Mucci
9 * mucci@cs.utk.edu
10 * Mods: Nils Smeds
11 * smeds@pdc.kth.se
12 * Anders Nilsson
13 * anni@pdc.kth.se
14 * Kevin London
15 * london@cs.utk.edu
16 * dan terpstra
17 * terpstra@cs.utk.edu
18 * Min Zhou
19 * min@cs.utk.edu
20 */
21 
22 #include <stdio.h>
23 #include <assert.h>
24 #include <string.h>
25 #include "papi.h"
26 
27 /* Lets use defines to rename all the files */
28 
29 #ifdef FORTRANUNDERSCORE
30 #define PAPI_FCALL(function,caps,args) void function##_ args
31 #elif FORTRANDOUBLEUNDERSCORE
32 #define PAPI_FCALL(function,caps,args) void function##__ args
33 #elif FORTRANCAPS
34 #define PAPI_FCALL(function,caps,args) void caps args
35 #else
36 #define PAPI_FCALL(function,caps,args) void function args
37 #endif
38 
39 /* Many Unix systems passes Fortran string lengths as extra arguments */
40 #if defined(_AIX) || defined(sun) || defined(linux)
41 #define _FORTRAN_STRLEN_AT_END
42 #endif
43 /* The Low Level Wrappers */
44 
47 /* helper routine to convert Fortran strings to C strings */
48 #if defined(_FORTRAN_STRLEN_AT_END)
49 static void Fortran2cstring( char *cstring, char *Fstring, int clen , int Flen )
50 {
51  int slen, i;
52 
53  /* What is the maximum number of chars to copy ? */
54  slen = Flen < clen ? Flen : clen;
55  strncpy( cstring, Fstring, ( size_t ) slen );
56 
57  /* Remove trailing blanks from initial Fortran string */
58  for ( i = slen - 1; i > -1 && cstring[i] == ' '; cstring[i--] = '\0' );
59 
60  /* Make sure string is NULL terminated */
61  cstring[clen - 1] = '\0';
62  if ( slen < clen )
63  cstring[slen] = '\0';
64 }
65 #endif
66 
77 PAPI_FCALL( papif_accum, PAPIF_ACCUM,
78  ( int *EventSet, long long *values, int *check ) )
79 {
80  *check = PAPI_accum( *EventSet, values );
81 }
82 
93 PAPI_FCALL( papif_add_event, PAPIF_ADD_EVENT,
94  ( int *EventSet, int *Event, int *check ) )
95 {
96  *check = PAPI_add_event( *EventSet, *Event );
97 }
98 
109 #if defined(_FORTRAN_STRLEN_AT_END)
110 PAPI_FCALL( papif_add_named_event, PAPIF_ADD_NAMED_EVENT,
111  ( int *EventSet, char *EventName, int *check, int Event_len ) )
112 {
113  char tmp[PAPI_MAX_STR_LEN];
114  Fortran2cstring( tmp, EventName, PAPI_MAX_STR_LEN, Event_len );
115  *check = PAPI_add_named_event( *EventSet, tmp );
116 }
117 #else
118 PAPI_FCALL( papif_add_named_event, PAPIF_ADD_NAMED_EVENT,
119  ( int *EventSet, char *EventName, int *check ) )
120 {
121  *check = PAPI_add_named_event( *EventSet, EventName );
122 }
123 #endif
124 
135 PAPI_FCALL( papif_add_events, PAPIF_ADD_EVENTS,
136  ( int *EventSet, int *Events, int *number, int *check ) )
137 {
138  *check = PAPI_add_events( *EventSet, Events, *number );
139 }
140 
151 PAPI_FCALL( papif_cleanup_eventset, PAPIF_CLEANUP_EVENTSET,
152  ( int *EventSet, int *check ) )
153 {
154  *check = PAPI_cleanup_eventset( *EventSet );
155 }
156 
167 PAPI_FCALL( papif_create_eventset, PAPIF_CREATE_EVENTSET,
168  ( int *EventSet, int *check ) )
169 {
170  *check = PAPI_create_eventset( EventSet );
171 }
172 
183 PAPI_FCALL( papif_assign_eventset_component, PAPIF_ASSIGN_EVENTSET_COMPONENT,
184  ( int *EventSet, int *cidx, int *check ) )
185 {
186  *check = PAPI_assign_eventset_component( *EventSet, *cidx );
187 }
188 
199 PAPI_FCALL( papif_destroy_eventset, PAPIF_DESTROY_EVENTSET,
200  ( int *EventSet, int *check ) )
201 {
202  *check = PAPI_destroy_eventset( EventSet );
203 }
204 
215  /* XXX This looks totally broken. Should be passed all the members of the dmem_info struct. */
216 PAPI_FCALL( papif_get_dmem_info, PAPIF_GET_DMEM_INFO,
217  ( long long *dest, int *check ) )
218 {
219  *check = PAPI_get_dmem_info( ( PAPI_dmem_info_t * ) dest );
220 }
221 
235 #if defined(_FORTRAN_STRLEN_AT_END)
236 PAPI_FCALL( papif_get_exe_info, PAPIF_GET_EXE_INFO,
237  ( char *fullname, char *name, long long *text_start,
238  long long *text_end, long long *data_start, long long *data_end,
239  long long *bss_start, long long *bss_end,
240  int *check, int fullname_len, int name_len ) )
241 #else
242 PAPI_FCALL( papif_get_exe_info, PAPIF_GET_EXE_INFO,
243  ( char *fullname, char *name, long long *text_start,
244  long long *text_end, long long *data_start, long long *data_end,
245  long long *bss_start, long long *bss_end, int *check ) )
246 #endif
247 {
248  PAPI_option_t e;
249 /* WARNING: The casts from caddr_t to long below WILL BREAK on systems with
250  64-bit addresses. I did it here because I was lazy. And because I wanted
251  to get rid of those pesky gcc warnings. If you find a 64-bit system,
252  conditionalize the cast with (yet another) #ifdef...
253 */
254  if ( ( *check = PAPI_get_opt( PAPI_EXEINFO, &e ) ) == PAPI_OK ) {
255 #if defined(_FORTRAN_STRLEN_AT_END)
256  int i;
257  strncpy( fullname, e.exe_info->fullname, ( size_t ) fullname_len );
258  for ( i = ( int ) strlen( e.exe_info->fullname ); i < fullname_len;
259  fullname[i++] = ' ' );
260  strncpy( name, e.exe_info->address_info.name, ( size_t ) name_len );
261  for ( i = ( int ) strlen( e.exe_info->address_info.name ); i < name_len;
262  name[i++] = ' ' );
263 #else
264  strncpy( fullname, e.exe_info->fullname, PAPI_MAX_STR_LEN );
265  strncpy( name, e.exe_info->address_info.name, PAPI_MAX_STR_LEN );
266 #endif
267  *text_start = ( long ) e.exe_info->address_info.text_start;
268  *text_end = ( long ) e.exe_info->address_info.text_end;
269  *data_start = ( long ) e.exe_info->address_info.data_start;
270  *data_end = ( long ) e.exe_info->address_info.data_end;
271  *bss_start = ( long ) e.exe_info->address_info.bss_start;
272  *bss_end = ( long ) e.exe_info->address_info.bss_end;
273  }
274 }
275 
288 #if defined(_FORTRAN_STRLEN_AT_END)
289 PAPI_FCALL( papif_get_hardware_info, PAPIF_GET_HARDWARE_INFO, ( int *ncpu,
290  int *nnodes,
291  int *totalcpus,
292  int *vendor,
293  char
294  *vendor_str,
295  int *model,
296  char *model_str,
297  float *revision,
298  float *mhz,
299  int vendor_len,
300  int
301  model_len ) )
302 #else
303 PAPI_FCALL( papif_get_hardware_info, PAPIF_GET_HARDWARE_INFO, ( int *ncpu,
304  int *nnodes,
305  int *totalcpus,
306  int *vendor,
307  char
308  *vendor_string,
309  int *model,
310  char
311  *model_string,
312  float *revision,
313  float *mhz ) )
314 #endif
315 {
316  const PAPI_hw_info_t *hwinfo;
317  int i;
318  hwinfo = PAPI_get_hardware_info( );
319  if ( hwinfo == NULL ) {
320  *ncpu = 0;
321  *nnodes = 0;
322  *totalcpus = 0;
323  *vendor = 0;
324  *model = 0;
325  *revision = 0;
326  *mhz = 0;
327  } else {
328  *ncpu = hwinfo->ncpu;
329  *nnodes = hwinfo->nnodes;
330  *totalcpus = hwinfo->totalcpus;
331  *vendor = hwinfo->vendor;
332  *model = hwinfo->model;
333  *revision = hwinfo->revision;
334  *mhz = hwinfo->cpu_max_mhz;
335 #if defined(_FORTRAN_STRLEN_AT_END)
336  strncpy( vendor_str, hwinfo->vendor_string, ( size_t ) vendor_len );
337  for ( i = ( int ) strlen( hwinfo->vendor_string ); i < vendor_len;
338  vendor_str[i++] = ' ' );
339  strncpy( model_str, hwinfo->model_string, ( size_t ) model_len );
340  for ( i = ( int ) strlen( hwinfo->model_string ); i < model_len;
341  model_str[i++] = ' ' );
342 #else
343  (void)i; /* unused... */
344  /* This case needs the passed strings to be of sufficient size *
345  * and will include the NULL character in the target string */
346  strcpy( vendor_string, hwinfo->vendor_string );
347  strcpy( model_string, hwinfo->model_string );
348 #endif
349  }
350  return;
351 }
352 
364 PAPI_FCALL( papif_num_hwctrs, PAPIF_num_hwctrs, ( int *num ) )
365 {
366  *num = PAPI_num_hwctrs( );
367 }
368 
380 PAPI_FCALL( papif_num_cmp_hwctrs, PAPIF_num_cmp_hwctrs,
381  ( int *cidx, int *num ) )
382 {
383  *num = PAPI_num_cmp_hwctrs( *cidx );
384 }
385 
396 PAPI_FCALL( papif_get_real_cyc, PAPIF_GET_REAL_CYC, ( long long *real_cyc ) )
397 {
398  *real_cyc = PAPI_get_real_cyc( );
399 }
400 
411 PAPI_FCALL( papif_get_real_usec, PAPIF_GET_REAL_USEC, ( long long *time ) )
412 {
413  *time = PAPI_get_real_usec( );
414 }
415 
426 PAPI_FCALL( papif_get_real_nsec, PAPIF_GET_REAL_NSEC, ( long long *time ) )
427 {
428  *time = PAPI_get_real_nsec( );
429 }
430 
441 PAPI_FCALL( papif_get_virt_cyc, PAPIF_GET_VIRT_CYC, ( long long *virt_cyc ) )
442 {
443  *virt_cyc = PAPI_get_virt_cyc( );
444 }
445 
456 PAPI_FCALL( papif_get_virt_usec, PAPIF_GET_VIRT_USEC, ( long long *time ) )
457 {
458  *time = PAPI_get_virt_usec( );
459 }
460 
471 PAPI_FCALL( papif_is_initialized, PAPIF_IS_INITIALIZED, ( int *level ) )
472 {
473  *level = PAPI_is_initialized( );
474 }
475 
486 PAPI_FCALL( papif_library_init, PAPIF_LIBRARY_INIT, ( int *check ) )
487 {
488  *check = PAPI_library_init( *check );
489 }
490 
501 PAPI_FCALL( papif_thread_id, PAPIF_THREAD_ID, ( unsigned long *id ) )
502 {
503  *id = PAPI_thread_id( );
504 }
505 
516 PAPI_FCALL( papif_register_thread, PAPIF_REGISTER_THREAD, ( int *check ) )
517 {
518  *check = PAPI_register_thread( );
519 }
520 
531 PAPI_FCALL( papif_unregster_thread, PAPIF_UNREGSTER_THREAD, ( int *check ) )
532 {
533  *check = PAPI_unregister_thread( );
534 }
535 
546 /* This must be passed an EXTERNAL or INTRINISIC FUNCTION not a SUBROUTINE */
547 PAPI_FCALL( papif_thread_init, PAPIF_THREAD_INIT,
548  ( unsigned long int ( *handle ) ( void ), int *check ) )
549 {
550  *check = PAPI_thread_init( handle );
551 }
552 
563 PAPI_FCALL( papif_list_events, PAPIF_LIST_EVENTS,
564  ( int *EventSet, int *Events, int *number, int *check ) )
565 {
566  *check = PAPI_list_events( *EventSet, Events, number );
567 }
568 
579 PAPI_FCALL( papif_multiplex_init, PAPIF_MULTIPLEX_INIT, ( int *check ) )
580 {
581  *check = PAPI_multiplex_init( );
582 }
583 
594 PAPI_FCALL( papif_get_multiplex, PAPIF_GET_MULTIPLEX,
595  ( int *EventSet, int *check ) )
596 {
597  *check = PAPI_get_multiplex( *EventSet );
598 }
599 
610 PAPI_FCALL( papif_set_multiplex, PAPIF_SET_MULTIPLEX,
611  ( int *EventSet, int *check ) )
612 {
613  *check = PAPI_set_multiplex( *EventSet );
614 }
615 
626 #if defined(_FORTRAN_STRLEN_AT_END)
627 PAPI_FCALL( papif_perror, PAPIF_PERROR,
628  ( char *message,
629  int message_len ) )
630 #else
631 PAPI_FCALL( papif_perror, PAPIF_PERROR,
632  ( char *message ) )
633 #endif
634 {
635 #if defined(_FORTRAN_STRLEN_AT_END)
636  char tmp[PAPI_MAX_STR_LEN];
637  Fortran2cstring( tmp, message, PAPI_MAX_STR_LEN, message_len );
638 
639  PAPI_perror( tmp );
640 #else
641  PAPI_perror( message );
642 #endif
643 }
644 
645 /* This will not work until Fortran2000 :)
646  * PAPI_FCALL(papif_profil, PAPIF_PROFIL, (unsigned short *buf, unsigned *bufsiz, unsigned long *offset, unsigned *scale, unsigned *eventset,
647  * unsigned *eventcode, unsigned *threshold, unsigned *flags, unsigned *check))
648  * {
649  * *check = PAPI_profil(buf, *bufsiz, *offset, *scale, *eventset, *eventcode, *threshold, *flags);
650  * }
651  */
652 
663 PAPI_FCALL( papif_query_event, PAPIF_QUERY_EVENT,
664  ( int *EventCode, int *check ) )
665 {
666  *check = PAPI_query_event( *EventCode );
667 }
668 
679 #if defined(_FORTRAN_STRLEN_AT_END)
680 PAPI_FCALL( papif_query_named_event, PAPIF_QUERY_NAMED_EVENT,
681  ( char *EventName, int *check, int Event_len ) )
682 {
683  char tmp[PAPI_MAX_STR_LEN];
684  Fortran2cstring( tmp, EventName, PAPI_MAX_STR_LEN, Event_len );
685  *check = PAPI_query_named_event( tmp );
686 }
687 #else
688 PAPI_FCALL( papif_query_named_event, PAPIF_QUERY_NAMED_EVENT,
689  ( char *EventName, int *check ) )
690 {
691  *check = PAPI_query_named_event( EventName );
692 }
693 #endif
694 
707 #if defined(_FORTRAN_STRLEN_AT_END)
708 PAPI_FCALL( papif_get_event_info, PAPIF_GET_EVENT_INFO,
709  ( int *EventCode, char *symbol, char *long_descr, char *short_descr,
710  int *count, char *event_note, int *flags, int *check,
711  int symbol_len, int long_descr_len, int short_descr_len,
712  int event_note_len ) )
713 #else
714 PAPI_FCALL( papif_get_event_info, PAPIF_GET_EVENT_INFO,
715  ( int *EventCode, char *symbol, char *long_descr, char *short_descr,
716  int *count, char *event_note, int *flags, int *check ) )
717 #endif
718 {
719  PAPI_event_info_t info;
720  ( void ) flags; /*Unused */
721 #if defined(_FORTRAN_STRLEN_AT_END)
722  int i;
723  if ( ( *check = PAPI_get_event_info( *EventCode, &info ) ) == PAPI_OK ) {
724  strncpy( symbol, info.symbol, ( size_t ) symbol_len );
725  for ( i = ( int ) strlen( info.symbol ); i < symbol_len;
726  symbol[i++] = ' ' );
727  strncpy( long_descr, info.long_descr, ( size_t ) long_descr_len );
728  for ( i = ( int ) strlen( info.long_descr ); i < long_descr_len;
729  long_descr[i++] = ' ' );
730  strncpy( short_descr, info.short_descr, ( size_t ) short_descr_len );
731  for ( i = ( int ) strlen( info.short_descr ); i < short_descr_len;
732  short_descr[i++] = ' ' );
733 
734  *count = ( int ) info.count;
735 
736  int note_len=0;
737 
738  strncpy( event_note, info.note, ( size_t ) event_note_len );
739  note_len=strlen(info.note);
740 
741  for ( i = note_len; i < event_note_len;
742  event_note[i++] = ' ' );
743  }
744 #else
745 /* printf("EventCode: %d\n", *EventCode ); -KSL */
746  if ( ( *check = PAPI_get_event_info( *EventCode, &info ) ) == PAPI_OK ) {
747  strncpy( symbol, info.symbol, PAPI_MAX_STR_LEN );
748  strncpy( long_descr, info.long_descr, PAPI_MAX_STR_LEN );
749  strncpy( short_descr, info.short_descr, PAPI_MAX_STR_LEN );
750  *count = info.count;
751  if (info.note)
752  strncpy( event_note, info.note,
754  }
755 /* printf("Check: %d\n", *check); -KSL */
756 #endif
757 }
758 
769 #if defined(_FORTRAN_STRLEN_AT_END)
770 PAPI_FCALL( papif_event_code_to_name, PAPIF_EVENT_CODE_TO_NAME,
771  ( int *EventCode, char *out_str, int *check, int out_len ) )
772 #else
773 PAPI_FCALL( papif_event_code_to_name, PAPIF_EVENT_CODE_TO_NAME,
774  ( int *EventCode, char *out, int *check ) )
775 #endif
776 {
777 #if defined(_FORTRAN_STRLEN_AT_END)
778  char tmp[PAPI_MAX_STR_LEN];
779  int i;
780  *check = PAPI_event_code_to_name( *EventCode, tmp );
781  /* tmp has \0 within PAPI_MAX_STR_LEN chars so strncpy is safe */
782  strncpy( out_str, tmp, ( size_t ) out_len );
783  /* overwrite any NULLs and trailing garbage in out_str */
784  for ( i = ( int ) strlen( tmp ); i < out_len; out_str[i++] = ' ' );
785 #else
786  /* The array "out" passed by the user must be sufficiently long */
787  *check = PAPI_event_code_to_name( *EventCode, out );
788 #endif
789 }
790 
801 #if defined(_FORTRAN_STRLEN_AT_END)
802 PAPI_FCALL( papif_event_name_to_code, PAPIF_EVENT_NAME_TO_CODE,
803  ( char *in_str, int *out, int *check, int in_len ) )
804 #else
805 PAPI_FCALL( papif_event_name_to_code, PAPIF_EVENT_NAME_TO_CODE,
806  ( char *in, int *out, int *check ) )
807 #endif
808 {
809 #if defined(_FORTRAN_STRLEN_AT_END)
810  int slen, i;
811  char tmpin[PAPI_MAX_STR_LEN];
812 
813  /* What is the maximum number of chars to copy ? */
814  slen = in_len < PAPI_MAX_STR_LEN ? in_len : PAPI_MAX_STR_LEN;
815  strncpy( tmpin, in_str, ( size_t ) slen );
816 
817  /* Remove trailing blanks from initial Fortran string */
818  for ( i = slen - 1; i > -1 && tmpin[i] == ' '; tmpin[i--] = '\0' );
819 
820  /* Make sure string is NULL terminated before call */
821  tmpin[PAPI_MAX_STR_LEN - 1] = '\0';
822  if ( slen < PAPI_MAX_STR_LEN )
823  tmpin[slen] = '\0';
824 
825  *check = PAPI_event_name_to_code( tmpin, out );
826 #else
827  /* This will have trouble if argument in is not null terminated */
828  *check = PAPI_event_name_to_code( in, out );
829 #endif
830 }
831 
842 PAPI_FCALL( papif_num_events, PAPIF_NUM_EVENTS, ( int *EventCode, int *count ) )
843 {
844  *count = PAPI_num_events( *EventCode );
845 }
846 
857 PAPI_FCALL( papif_enum_event, PAPIF_ENUM_EVENT,
858  ( int *EventCode, int *modifier, int *check ) )
859 {
860  *check = PAPI_enum_event( EventCode, *modifier );
861 }
862 
873 PAPI_FCALL( papif_read, PAPIF_READ,
874  ( int *EventSet, long long *values, int *check ) )
875 {
876  *check = PAPI_read( *EventSet, values );
877 }
878 
889 PAPI_FCALL( papif_read_ts, PAPIF_READ_TS,
890  ( int *EventSet, long long *values, long long *cycles, int *check ) )
891 {
892  *check = PAPI_read_ts( *EventSet, values, cycles );
893 }
894 
905 PAPI_FCALL( papif_remove_event, PAPIF_REMOVE_EVENT,
906  ( int *EventSet, int *Event, int *check ) )
907 {
908  *check = PAPI_remove_event( *EventSet, *Event );
909 }
910 
921 #if defined(_FORTRAN_STRLEN_AT_END)
922 PAPI_FCALL( papif_remove_named_event, PAPIF_REMOVE_NAMED_EVENT,
923  ( int *EventSet, char *EventName, int *check, int Event_len ) )
924 {
925  char tmp[PAPI_MAX_STR_LEN];
926  Fortran2cstring( tmp, EventName, PAPI_MAX_STR_LEN, Event_len );
927  *check = PAPI_remove_named_event( *EventSet, tmp );
928 }
929 #else
930 PAPI_FCALL( papif_remove_named_event, PAPIF_REMOVE_NAMED_EVENT,
931  ( int *EventSet, char *EventName, int *check ) )
932 {
933  *check = PAPI_remove_named_event( *EventSet, EventName );
934 }
935 #endif
936 
947 PAPI_FCALL( papif_remove_events, PAPIF_REMOVE_EVENTS,
948  ( int *EventSet, int *Events, int *number, int *check ) )
949 {
950  *check = PAPI_remove_events( *EventSet, Events, *number );
951 }
952 
963 PAPI_FCALL( papif_reset, PAPIF_RESET, ( int *EventSet, int *check ) )
964 {
965  *check = PAPI_reset( *EventSet );
966 }
967 
978 PAPI_FCALL( papif_set_debug, PAPIF_SET_DEBUG, ( int *debug, int *check ) )
979 {
980  *check = PAPI_set_debug( *debug );
981 }
982 
993 PAPI_FCALL( papif_set_domain, PAPIF_SET_DOMAIN, ( int *domain, int *check ) )
994 {
995  *check = PAPI_set_domain( *domain );
996 }
997 
1008 PAPI_FCALL( papif_set_cmp_domain, PAPIF_SET_CMP_DOMAIN,
1009  ( int *domain, int *cidx, int *check ) )
1010 {
1011  *check = PAPI_set_cmp_domain( *domain, *cidx );
1012 }
1013 
1024 PAPI_FCALL( papif_set_granularity, PAPIF_SET_GRANULARITY,
1025  ( int *granularity, int *check ) )
1026 {
1027  *check = PAPI_set_granularity( *granularity );
1028 }
1029 
1040 PAPI_FCALL( papif_set_cmp_granularity, PAPIF_SET_CMP_GRANULARITY,
1041  ( int *granularity, int *cidx, int *check ) )
1042 {
1043  *check = PAPI_set_cmp_granularity( *granularity, *cidx );
1044 }
1045 
1056 PAPI_FCALL( papif_shutdown, PAPIF_SHUTDOWN, ( void ) )
1058  PAPI_shutdown( );
1059 }
1060 
1071 PAPI_FCALL( papif_start, PAPIF_START, ( int *EventSet, int *check ) )
1073  *check = PAPI_start( *EventSet );
1074 }
1075 
1086 PAPI_FCALL( papif_state, PAPIF_STATE,
1087  ( int *EventSet, int *status, int *check ) )
1088 {
1089  *check = PAPI_state( *EventSet, status );
1090 }
1091 
1102 PAPI_FCALL( papif_stop, PAPIF_STOP,
1103  ( int *EventSet, long long *values, int *check ) )
1104 {
1105  *check = PAPI_stop( *EventSet, values );
1106 }
1107 
1118 PAPI_FCALL( papif_write, PAPIF_WRITE,
1119  ( int *EventSet, long long *values, int *check ) )
1120 {
1121  *check = PAPI_write( *EventSet, values );
1122 }
1123 
1134 PAPI_FCALL( papif_lock, PAPIF_LOCK,
1135  ( int *lock, int *check ) )
1136 {
1137  *check = PAPI_lock( *lock );
1138 }
1139 
1150 PAPI_FCALL( papif_unlock, PAPIF_unlock,
1151  ( int *lock, int *check ) )
1152 {
1153  *check = PAPI_unlock( *lock );
1154 }
1155 
1156 /* The High Level API Wrappers */
1157 
1168 PAPI_FCALL( papif_start_counters, PAPIF_START_COUNTERS,
1169  ( int *events, int *array_len, int *check ) )
1170 {
1171  *check = PAPI_start_counters( events, *array_len );
1172 }
1173 
1184 PAPI_FCALL( papif_read_counters, PAPIF_READ_COUNTERS,
1185  ( long long *values, int *array_len, int *check ) )
1186 {
1187  *check = PAPI_read_counters( values, *array_len );
1188 }
1189 
1200 PAPI_FCALL( papif_stop_counters, PAPIF_STOP_COUNTERS,
1201  ( long long *values, int *array_len, int *check ) )
1202 {
1203  *check = PAPI_stop_counters( values, *array_len );
1204 }
1205 
1216 PAPI_FCALL( papif_accum_counters, PAPIF_ACCUM_COUNTERS,
1217  ( long long *values, int *array_len, int *check ) )
1218 {
1219  *check = PAPI_accum_counters( values, *array_len );
1220 }
1221 
1232 PAPI_FCALL( papif_num_counters, PAPIF_NUM_COUNTERS, ( int *numevents ) )
1234  *numevents = PAPI_num_counters( );
1235 }
1236 
1247 PAPI_FCALL( papif_ipc, PAPIF_IPC,
1248  ( float *rtime, float *ptime, long long *ins, float *ipc,
1249  int *check ) )
1250 {
1251  *check = PAPI_ipc( rtime, ptime, ins, ipc );
1252 }
1253 
1264 PAPI_FCALL( papif_epc, PAPIF_EPC,
1265  ( int event, float *rtime, float *ptime,
1266  long long *ref, long long *core, long long *evt, float *epc,
1267  int *check) )
1268 {
1269  *check = PAPI_epc( event, rtime, ptime, ref, core, evt, epc );
1270 }
1271 
1282 PAPI_FCALL( papif_flips, PAPIF_FLIPS,
1283  ( float *real_time, float *proc_time, long long *flpins,
1284  float *mflips, int *check ) )
1285 {
1286  *check = PAPI_flips( real_time, proc_time, flpins, mflips );
1287 }
1288 
1299 PAPI_FCALL( papif_flops, PAPIF_FLOPS,
1300  ( float *real_time, float *proc_time, long long *flpops,
1301  float *mflops, int *check ) )
1302 {
1303  *check = PAPI_flops( real_time, proc_time, flpops, mflops );
1304 }
1305 
1306 
1307 /* Fortran only APIs for get_opt and set_opt functionality */
1308 
1321 PAPI_FCALL( papif_get_clockrate, PAPIF_GET_CLOCKRATE, ( int *cr ) )
1323  *cr = PAPI_get_opt( PAPI_CLOCKRATE, NULL );
1324 }
1325 
1338 #if defined(_FORTRAN_STRLEN_AT_END)
1339 PAPI_FCALL( papif_get_preload, PAPIF_GET_PRELOAD,
1340  ( char *lib_preload_env, int *check, int lib_preload_env_len ) )
1341 #else
1342 PAPI_FCALL( papif_get_preload, PAPIF_GET_PRELOAD,
1343  ( char *lib_preload_env, int *check ) )
1344 #endif
1345 {
1346  PAPI_option_t p;
1347 #if defined(_FORTRAN_STRLEN_AT_END)
1348  int i;
1349 
1350  if ( ( *check = PAPI_get_opt( PAPI_PRELOAD, &p ) ) == PAPI_OK ) {
1351  strncpy( lib_preload_env, p.preload.lib_preload_env,
1352  ( size_t ) lib_preload_env_len );
1353  for ( i = ( int ) strlen( p.preload.lib_preload_env );
1354  i < lib_preload_env_len; lib_preload_env[i++] = ' ' );
1355  }
1356 #else
1357  if ( ( *check = PAPI_get_opt( PAPI_PRELOAD, &p ) ) == PAPI_OK ) {
1358  strncpy( lib_preload_env, p.preload.lib_preload_env, PAPI_MAX_STR_LEN );
1359  }
1360 #endif
1361 }
1362 
1373 PAPI_FCALL( papif_get_granularity, PAPIF_GET_GRANULARITY,
1374  ( int *eventset, int *granularity, int *mode, int *check ) )
1375 {
1376  PAPI_option_t g;
1377 
1378  if ( *mode == PAPI_DEFGRN ) {
1379  *granularity = PAPI_get_opt( *mode, &g );
1380  *check = PAPI_OK;
1381  } else if ( *mode == PAPI_GRANUL ) {
1382  g.granularity.eventset = *eventset;
1383  if ( ( *check = PAPI_get_opt( *mode, &g ) ) == PAPI_OK ) {
1384  *granularity = g.granularity.granularity;
1385  }
1386  } else {
1387  *check = PAPI_EINVAL;
1388  }
1389 }
1390 
1401 PAPI_FCALL( papif_get_domain, PAPIF_GET_DOMAIN,
1402  ( int *eventset, int *domain, int *mode, int *check ) )
1403 {
1404  PAPI_option_t d;
1405 
1406  if ( *mode == PAPI_DEFDOM ) {
1407  *domain = PAPI_get_opt( *mode, NULL );
1408  *check = PAPI_OK;
1409  } else if ( *mode == PAPI_DOMAIN ) {
1410  d.domain.eventset = *eventset;
1411  if ( ( *check = PAPI_get_opt( *mode, &d ) ) == PAPI_OK ) {
1412  *domain = d.domain.domain;
1413  }
1414  } else {
1415  *check = PAPI_EINVAL;
1416  }
1417 }
1418 
1419 #if 0
1420 PAPI_FCALL( papif_get_inherit, PAPIF_GET_INHERIT, ( int *inherit, int *check ) )
1421 {
1422  PAPI_option_t i;
1423 
1424  if ( ( *check = PAPI_get_opt( PAPI_INHERIT, &i ) ) == PAPI_OK ) {
1425  *inherit = i.inherit.inherit;
1426  }
1427 }
1428 #endif
1429 
1441 PAPI_FCALL( papif_set_event_domain, PAPIF_SET_EVENT_DOMAIN,
1442  ( int *es, int *domain, int *check ) )
1443 {
1444  PAPI_option_t d;
1445 
1446  d.domain.domain = *domain;
1447  d.domain.eventset = *es;
1448  *check = PAPI_set_opt( PAPI_DOMAIN, &d );
1449 }
1450 
1461 PAPI_FCALL( papif_set_inherit, PAPIF_SET_INHERIT, ( int *inherit, int *check ) )
1462 {
1463  PAPI_option_t i;
1464 
1466  *check = PAPI_set_opt( PAPI_INHERIT, &i );
1467 }
1468 
char name[PAPI_HUGE_STR_LEN]
Definition: papi.h:693
i inherit inherit
unsigned int count
Definition: papi.h:984
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2258
int PAPI_is_initialized(void)
Definition: papi.c:6389
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1622
void PAPI_perror(char *msg)
Definition: papi.c:4579
Hardware info structure.
Definition: papi.h:777
long long PAPI_get_virt_usec(void)
Definition: papi.c:6298
int PAPI_set_cmp_granularity(int granularity, int cidx)
Definition: papi.c:5548
int PAPI_reset(int EventSet)
Definition: papi.c:2403
int numevents
Definition: kufrin.c:15
long long flags
Definition: iozone.c:12330
int PAPI_add_named_event(int EventSet, char *EventName)
Definition: papi.c:1835
caddr_t text_end
Definition: papi.h:695
static int Events[NUM_EVENTS]
Definition: init_fini.c:8
unsigned long PAPI_thread_id(void)
Definition: papi.c:159
int PAPI_write(int EventSet, long long *values)
Definition: papi.c:2757
int PAPI_ipc(float *rtime, float *ptime, long long *ins, float *ipc)
Definition: papi_hl.c:316
int PAPI_remove_event(int EventSet, int EventCode)
Definition: papi.c:1717
long long PAPI_get_virt_cyc(void)
Definition: papi.c:6226
int PAPI_flops(float *rtime, float *ptime, long long *flpops, float *mflops)
Definition: papi_hl.c:259
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
int EventSet
Definition: data_range.c:25
int PAPI_accum_counters(long long *values, int array_len)
Definition: papi_hl.c:756
int PAPI_enum_event(int *EventCode, int modifier)
Definition: papi.c:1150
PAPI_granularity_option_t granularity
Definition: papi.h:850
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
device[deviceId] domain[domainId] event
Definition: linux-cuda.c:306
int PAPI_register_thread(void)
Definition: papi.c:205
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
PAPI_inherit_option_t inherit
Definition: papi.h:849
caddr_t bss_start
Definition: papi.h:698
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:845
void
Definition: iozone.c:18627
char note[PAPI_HUGE_STR_LEN]
Definition: papi.h:1010
int PAPI_remove_events(int EventSet, int *Events, int number)
Definition: papi.c:5857
return PAPI_EINVAL
Definition: linux-nvml.c:408
Return the number of hardware counters on the specified component.
int PAPI_set_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:3409
int PAPI_add_events(int EventSet, int *Events, int number)
Definition: papi.c:5769
#define PAPI_INHERIT
Definition: papi.h:456
#define PAPI_PRELOAD
Definition: papi.h:439
Return codes and api definitions.
* check
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:846
char events[MAX_EVENTS][BUFSIZ]
int PAPI_set_cmp_domain(int domain, int cidx)
Definition: papi.c:5684
int PAPI_flips(float *rtime, float *ptime, long long *flpins, float *mflips)
Definition: papi_hl.c:204
int PAPI_epc(int event, float *rtime, float *ptime, long long *ref, long long *core, long long *evt, float *epc)
Definition: papi_hl.c:383
char lib_preload_env[PAPI_MAX_STR_LEN]
Definition: papi.h:618
int PAPI_num_cmp_hwctrs(int cidx)
Definition: papi.c:3904
int PAPI_accum(int EventSet, long long *values)
Definition: papi.c:2689
int PAPI_thread_init(unsigned long int(*id_fn)(void))
Definition: papi.c:120
int PAPI_library_init(int version)
Definition: papi.c:497
long long debug
Definition: iozone.c:1374
float revision
Definition: papi.h:788
int i
Definition: fileop.c:140
int PAPI_num_hwctrs(void)
Definition: papi.c:3848
int PAPI_stop_counters(long long *values, int array_len)
Definition: papi_hl.c:803
Return the number of hardware counters on the cpu.
A pointer to the following is passed to PAPI_get_dmem_info()
Definition: papi.h:868
void PAPI_shutdown(void)
Definition: papi.c:4400
int PAPI_num_events(int EventSet)
Definition: papi.c:4365
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4082
static int cidx
Definition: event_info.c:40
caddr_t text_start
Definition: papi.h:694
PAPI_address_map_t address_info
Definition: papi.h:706
char short_descr[PAPI_MIN_STR_LEN]
Definition: papi.h:964
#define PAPI_EXEINFO
Definition: papi.h:443
void int num
Definition: iozone.c:22151
int PAPI_state(int EventSet, int *status)
Definition: papi.c:2997
#define PAPI_GRANUL
Definition: papi.h:433
#define PAPI_FCALL(function, caps, args)
#define PAPI_DEFGRN
Definition: papi.h:432
long long
Definition: iozone.c:19827
int nnodes
Definition: papi.h:782
int PAPI_set_granularity(int granularity)
Definition: papi.c:5483
nvmlDevice_t handle
Definition: linux-nvml.c:399
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2834
int PAPI_assign_eventset_component(int EventSet, int cidx)
Definition: papi.c:1485
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1424
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:926
atomic_p lock[]
Definition: aix.c:25
char vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:785
strcpy(filename, default_filename)
int PAPI_event_name_to_code(char *in, int *out)
Definition: papi.c:1010
int PAPI_get_dmem_info(PAPI_dmem_info_t *dest)
Definition: papi.c:5989
#define PAPI_DOMAIN
Definition: papi.h:431
goto out
Definition: pscanf.h:20
caddr_t data_start
Definition: papi.h:696
int PAPI_query_event(int EventCode)
Definition: papi.c:698
int PAPI_multiplex_init(void)
Definition: papi.c:2926
int vendor
Definition: papi.h:784
int PAPI_read_ts(int EventSet, long long *values, long long *cycles)
Definition: papi.c:2592
long long PAPI_get_real_usec(void)
Definition: papi.c:6190
PAPI_exe_info_t * exe_info
Definition: papi.h:860
long long status
Definition: iozone.c:1335
int PAPI_unregister_thread(void)
Definition: papi.c:241
int model
Definition: papi.h:786
int PAPI_query_named_event(char *EventName)
Definition: papi.c:767
char * name
Definition: iozone.c:23648
#define PAPI_CLOCKRATE
Definition: papi.h:440
int PAPI_unlock(int lck)
Definition: papi.c:6347
int cpu_max_mhz
Definition: papi.h:793
int PAPI_read_counters(long long *values, int array_len)
Definition: papi_hl.c:706
int
Definition: iozone.c:18528
long long PAPI_get_real_nsec(void)
Definition: papi.c:6163
caddr_t bss_end
Definition: papi.h:699
int PAPI_num_counters(void)
Definition: papi_hl.c:537
int PAPI_start_counters(int *events, int array_len)
Definition: papi_hl.c:593
Unlock one of the mutex variables defined in papi.h.
caddr_t data_end
Definition: papi.h:697
int Event[MAX_EVENTS]
#define PAPI_DEFDOM
Definition: papi.h:430
int PAPI_set_multiplex(int EventSet)
Definition: papi.c:3277
int totalcpus
Definition: papi.h:783
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1971
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
PAPI_domain_option_t domain
Definition: papi.h:852
int PAPI_set_domain(int domain)
Definition: papi.c:5614
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:787
char fullname[PAPI_HUGE_STR_LEN]
Definition: papi.h:705
long long PAPI_get_real_cyc(void)
Definition: papi.c:6143
int PAPI_read(int EventSet, long long *values)
Definition: papi.c:2503
int PAPI_start(int EventSet)
Definition: papi.c:2053
PAPI_preload_info_t preload
Definition: papi.h:847
int PAPI_get_multiplex(int EventSet)
Definition: papi.c:3967
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6111
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
int PAPI_lock(int lck)
Definition: papi.c:6327
long long tmp
Definition: iozone.c:12031
int PAPI_remove_named_event(int EventSet, char *EventName)
Definition: papi.c:1919
int PAPI_set_debug(int level)
Definition: papi.c:3070
int PAPI_list_events(int EventSet, int *Events, int *number)
Definition: papi.c:5927
int ncpu
Definition: papi.h:778