PAPI  5.6.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 * Author: Philip Mucci
8 * mucci@cs.utk.edu
9 * Mods: Nils Smeds
10 * smeds@pdc.kth.se
11 * Anders Nilsson
12 * anni@pdc.kth.se
13 * Kevin London
14 * london@cs.utk.edu
15 * dan terpstra
16 * terpstra@cs.utk.edu
17 * Min Zhou
18 * min@cs.utk.edu
19 */
20 
21 #pragma GCC visibility push(default)
22 
23 #include <stdio.h>
24 #include <assert.h>
25 #include <string.h>
26 #include "papi.h"
27 
28 /* Lets use defines to rename all the files */
29 
30 #ifdef FORTRANUNDERSCORE
31 #define PAPI_FCALL(function,caps,args) void function##_ args
32 #elif FORTRANDOUBLEUNDERSCORE
33 #define PAPI_FCALL(function,caps,args) void function##__ args
34 #elif FORTRANCAPS
35 #define PAPI_FCALL(function,caps,args) void caps args
36 #else
37 #define PAPI_FCALL(function,caps,args) void function args
38 #endif
39 
40 /* Many Unix systems passes Fortran string lengths as extra arguments */
41 #if defined(_AIX) || defined(sun) || defined(linux)
42 #define _FORTRAN_STRLEN_AT_END
43 #endif
44 /* The Low Level Wrappers */
45 
48 /* helper routine to convert Fortran strings to C strings */
49 #if defined(_FORTRAN_STRLEN_AT_END)
50 static void Fortran2cstring( char *cstring, char *Fstring, int clen , int Flen )
51 {
52  int slen, i;
53 
54  /* What is the maximum number of chars to copy ? */
55  slen = Flen < clen ? Flen : clen;
56  strncpy( cstring, Fstring, ( size_t ) slen );
57 
58  /* Remove trailing blanks from initial Fortran string */
59  for ( i = slen - 1; i > -1 && cstring[i] == ' '; cstring[i--] = '\0' );
60 
61  /* Make sure string is NULL terminated */
62  cstring[clen - 1] = '\0';
63  if ( slen < clen )
64  cstring[slen] = '\0';
65 }
66 #endif
67 
78 PAPI_FCALL( papif_accum, PAPIF_ACCUM,
79  ( int *EventSet, long long *values, int *check ) )
80 {
81  *check = PAPI_accum( *EventSet, values );
82 }
83 
94 PAPI_FCALL( papif_add_event, PAPIF_ADD_EVENT,
95  ( int *EventSet, int *Event, int *check ) )
96 {
97  *check = PAPI_add_event( *EventSet, *Event );
98 }
99 
110 #if defined(_FORTRAN_STRLEN_AT_END)
111 PAPI_FCALL( papif_add_named_event, PAPIF_ADD_NAMED_EVENT,
112  ( int *EventSet, char *EventName, int *check, int Event_len ) )
113 {
114  char tmp[PAPI_MAX_STR_LEN];
115  Fortran2cstring( tmp, EventName, PAPI_MAX_STR_LEN, Event_len );
116  *check = PAPI_add_named_event( *EventSet, tmp );
117 }
118 #else
119 PAPI_FCALL( papif_add_named_event, PAPIF_ADD_NAMED_EVENT,
120  ( int *EventSet, char *EventName, int *check ) )
121 {
122  *check = PAPI_add_named_event( *EventSet, EventName );
123 }
124 #endif
125 
136 PAPI_FCALL( papif_add_events, PAPIF_ADD_EVENTS,
137  ( int *EventSet, int *Events, int *number, int *check ) )
138 {
139  *check = PAPI_add_events( *EventSet, Events, *number );
140 }
141 
152 PAPI_FCALL( papif_cleanup_eventset, PAPIF_CLEANUP_EVENTSET,
153  ( int *EventSet, int *check ) )
154 {
155  *check = PAPI_cleanup_eventset( *EventSet );
156 }
157 
168 PAPI_FCALL( papif_create_eventset, PAPIF_CREATE_EVENTSET,
169  ( int *EventSet, int *check ) )
170 {
171  *check = PAPI_create_eventset( EventSet );
172 }
173 
184 PAPI_FCALL( papif_assign_eventset_component, PAPIF_ASSIGN_EVENTSET_COMPONENT,
185  ( int *EventSet, int *cidx, int *check ) )
186 {
187  *check = PAPI_assign_eventset_component( *EventSet, *cidx );
188 }
189 
200 PAPI_FCALL( papif_destroy_eventset, PAPIF_DESTROY_EVENTSET,
201  ( int *EventSet, int *check ) )
202 {
203  *check = PAPI_destroy_eventset( EventSet );
204 }
205 
216  /* XXX This looks totally broken. Should be passed all the members of the dmem_info struct. */
217 PAPI_FCALL( papif_get_dmem_info, PAPIF_GET_DMEM_INFO,
218  ( long long *dest, int *check ) )
219 {
220  *check = PAPI_get_dmem_info( ( PAPI_dmem_info_t * ) dest );
221 }
222 
236 #if defined(_FORTRAN_STRLEN_AT_END)
237 PAPI_FCALL( papif_get_exe_info, PAPIF_GET_EXE_INFO,
238  ( char *fullname, char *name, long long *text_start,
239  long long *text_end, long long *data_start, long long *data_end,
240  long long *bss_start, long long *bss_end,
241  int *check, int fullname_len, int name_len ) )
242 #else
243 PAPI_FCALL( papif_get_exe_info, PAPIF_GET_EXE_INFO,
244  ( char *fullname, char *name, long long *text_start,
245  long long *text_end, long long *data_start, long long *data_end,
246  long long *bss_start, long long *bss_end, int *check ) )
247 #endif
248 {
249  PAPI_option_t e;
250 /* WARNING: The casts from caddr_t to long below WILL BREAK on systems with
251  64-bit addresses. I did it here because I was lazy. And because I wanted
252  to get rid of those pesky gcc warnings. If you find a 64-bit system,
253  conditionalize the cast with (yet another) #ifdef...
254 */
255  if ( ( *check = PAPI_get_opt( PAPI_EXEINFO, &e ) ) == PAPI_OK ) {
256 #if defined(_FORTRAN_STRLEN_AT_END)
257  int i;
258  strncpy( fullname, e.exe_info->fullname, ( size_t ) fullname_len );
259  for ( i = ( int ) strlen( e.exe_info->fullname ); i < fullname_len;
260  fullname[i++] = ' ' );
261  strncpy( name, e.exe_info->address_info.name, ( size_t ) name_len );
262  for ( i = ( int ) strlen( e.exe_info->address_info.name ); i < name_len;
263  name[i++] = ' ' );
264 #else
265  strncpy( fullname, e.exe_info->fullname, PAPI_MAX_STR_LEN );
266  strncpy( name, e.exe_info->address_info.name, PAPI_MAX_STR_LEN );
267 #endif
268  *text_start = ( long ) e.exe_info->address_info.text_start;
269  *text_end = ( long ) e.exe_info->address_info.text_end;
270  *data_start = ( long ) e.exe_info->address_info.data_start;
271  *data_end = ( long ) e.exe_info->address_info.data_end;
272  *bss_start = ( long ) e.exe_info->address_info.bss_start;
273  *bss_end = ( long ) e.exe_info->address_info.bss_end;
274  }
275 }
276 
289 #if defined(_FORTRAN_STRLEN_AT_END)
290 PAPI_FCALL( papif_get_hardware_info, PAPIF_GET_HARDWARE_INFO, ( int *ncpu,
291  int *nnodes,
292  int *totalcpus,
293  int *vendor,
294  char
295  *vendor_str,
296  int *model,
297  char *model_str,
298  float *revision,
299  float *mhz,
300  int vendor_len,
301  int
302  model_len ) )
303 #else
304 PAPI_FCALL( papif_get_hardware_info, PAPIF_GET_HARDWARE_INFO, ( int *ncpu,
305  int *nnodes,
306  int *totalcpus,
307  int *vendor,
308  char
309  *vendor_string,
310  int *model,
311  char
312  *model_string,
313  float *revision,
314  float *mhz ) )
315 #endif
316 {
317  const PAPI_hw_info_t *hwinfo;
318  int i;
319  hwinfo = PAPI_get_hardware_info( );
320  if ( hwinfo == NULL ) {
321  *ncpu = 0;
322  *nnodes = 0;
323  *totalcpus = 0;
324  *vendor = 0;
325  *model = 0;
326  *revision = 0;
327  *mhz = 0;
328  } else {
329  *ncpu = hwinfo->ncpu;
330  *nnodes = hwinfo->nnodes;
331  *totalcpus = hwinfo->totalcpus;
332  *vendor = hwinfo->vendor;
333  *model = hwinfo->model;
334  *revision = hwinfo->revision;
335  *mhz = hwinfo->cpu_max_mhz;
336 #if defined(_FORTRAN_STRLEN_AT_END)
337  strncpy( vendor_str, hwinfo->vendor_string, ( size_t ) vendor_len );
338  for ( i = ( int ) strlen( hwinfo->vendor_string ); i < vendor_len;
339  vendor_str[i++] = ' ' );
340  strncpy( model_str, hwinfo->model_string, ( size_t ) model_len );
341  for ( i = ( int ) strlen( hwinfo->model_string ); i < model_len;
342  model_str[i++] = ' ' );
343 #else
344  (void)i; /* unused... */
345  /* This case needs the passed strings to be of sufficient size *
346  * and will include the NULL character in the target string */
347  strcpy( vendor_string, hwinfo->vendor_string );
348  strcpy( model_string, hwinfo->model_string );
349 #endif
350  }
351  return;
352 }
353 
365 PAPI_FCALL( papif_num_hwctrs, PAPIF_num_hwctrs, ( int *num ) )
366 {
367  *num = PAPI_num_hwctrs( );
368 }
369 
381 PAPI_FCALL( papif_num_cmp_hwctrs, PAPIF_num_cmp_hwctrs,
382  ( int *cidx, int *num ) )
383 {
384  *num = PAPI_num_cmp_hwctrs( *cidx );
385 }
386 
397 PAPI_FCALL( papif_get_real_cyc, PAPIF_GET_REAL_CYC, ( long long *real_cyc ) )
398 {
399  *real_cyc = PAPI_get_real_cyc( );
400 }
401 
412 PAPI_FCALL( papif_get_real_usec, PAPIF_GET_REAL_USEC, ( long long *time ) )
413 {
414  *time = PAPI_get_real_usec( );
415 }
416 
427 PAPI_FCALL( papif_get_real_nsec, PAPIF_GET_REAL_NSEC, ( long long *time ) )
428 {
429  *time = PAPI_get_real_nsec( );
430 }
431 
442 PAPI_FCALL( papif_get_virt_cyc, PAPIF_GET_VIRT_CYC, ( long long *virt_cyc ) )
443 {
444  *virt_cyc = PAPI_get_virt_cyc( );
445 }
446 
457 PAPI_FCALL( papif_get_virt_usec, PAPIF_GET_VIRT_USEC, ( long long *time ) )
458 {
459  *time = PAPI_get_virt_usec( );
460 }
461 
472 PAPI_FCALL( papif_is_initialized, PAPIF_IS_INITIALIZED, ( int *level ) )
473 {
474  *level = PAPI_is_initialized( );
475 }
476 
487 PAPI_FCALL( papif_library_init, PAPIF_LIBRARY_INIT, ( int *check ) )
488 {
489  *check = PAPI_library_init( *check );
490 }
491 
502 PAPI_FCALL( papif_thread_id, PAPIF_THREAD_ID, ( unsigned long *id ) )
503 {
504  *id = PAPI_thread_id( );
505 }
506 
517 PAPI_FCALL( papif_register_thread, PAPIF_REGISTER_THREAD, ( int *check ) )
518 {
519  *check = PAPI_register_thread( );
520 }
521 
532 PAPI_FCALL( papif_unregister_thread, PAPIF_UNREGISTER_THREAD, ( int *check ) )
533 {
534  *check = PAPI_unregister_thread( );
535 }
536 
537 /* There was a long (10+ years!) typo that was not noticed here */
538 /* Leaving it here as not to break any existing code out there */
539 
540 PAPI_FCALL( papif_unregster_thread, PAPIF_UNREGSTER_THREAD, ( int *check ) )
541 {
542  *check = PAPI_unregister_thread( );
543 }
544 
555 /* This must be passed an EXTERNAL or INTRINISIC FUNCTION not a SUBROUTINE */
556 PAPI_FCALL( papif_thread_init, PAPIF_THREAD_INIT,
557  ( unsigned long int ( *handle ) ( void ), int *check ) )
558 {
559  *check = PAPI_thread_init( handle );
560 }
561 
572 PAPI_FCALL( papif_list_events, PAPIF_LIST_EVENTS,
573  ( int *EventSet, int *Events, int *number, int *check ) )
574 {
575  *check = PAPI_list_events( *EventSet, Events, number );
576 }
577 
588 PAPI_FCALL( papif_multiplex_init, PAPIF_MULTIPLEX_INIT, ( int *check ) )
589 {
590  *check = PAPI_multiplex_init( );
591 }
592 
603 PAPI_FCALL( papif_get_multiplex, PAPIF_GET_MULTIPLEX,
604  ( int *EventSet, int *check ) )
605 {
606  *check = PAPI_get_multiplex( *EventSet );
607 }
608 
619 PAPI_FCALL( papif_set_multiplex, PAPIF_SET_MULTIPLEX,
620  ( int *EventSet, int *check ) )
621 {
622  *check = PAPI_set_multiplex( *EventSet );
623 }
624 
635 #if defined(_FORTRAN_STRLEN_AT_END)
636 PAPI_FCALL( papif_perror, PAPIF_PERROR,
637  ( char *message,
638  int message_len ) )
639 #else
640 PAPI_FCALL( papif_perror, PAPIF_PERROR,
641  ( char *message ) )
642 #endif
643 {
644 #if defined(_FORTRAN_STRLEN_AT_END)
645  char tmp[PAPI_MAX_STR_LEN];
646  Fortran2cstring( tmp, message, PAPI_MAX_STR_LEN, message_len );
647 
648  PAPI_perror( tmp );
649 #else
650  PAPI_perror( message );
651 #endif
652 }
653 
654 /* This will not work until Fortran2000 :)
655  * PAPI_FCALL(papif_profil, PAPIF_PROFIL, (unsigned short *buf, unsigned *bufsiz, unsigned long *offset, unsigned *scale, unsigned *eventset,
656  * unsigned *eventcode, unsigned *threshold, unsigned *flags, unsigned *check))
657  * {
658  * *check = PAPI_profil(buf, *bufsiz, *offset, *scale, *eventset, *eventcode, *threshold, *flags);
659  * }
660  */
661 
672 PAPI_FCALL( papif_query_event, PAPIF_QUERY_EVENT,
673  ( int *EventCode, int *check ) )
674 {
675  *check = PAPI_query_event( *EventCode );
676 }
677 
688 #if defined(_FORTRAN_STRLEN_AT_END)
689 PAPI_FCALL( papif_query_named_event, PAPIF_QUERY_NAMED_EVENT,
690  ( char *EventName, int *check, int Event_len ) )
691 {
692  char tmp[PAPI_MAX_STR_LEN];
693  Fortran2cstring( tmp, EventName, PAPI_MAX_STR_LEN, Event_len );
694  *check = PAPI_query_named_event( tmp );
695 }
696 #else
697 PAPI_FCALL( papif_query_named_event, PAPIF_QUERY_NAMED_EVENT,
698  ( char *EventName, int *check ) )
699 {
700  *check = PAPI_query_named_event( EventName );
701 }
702 #endif
703 
716 #if defined(_FORTRAN_STRLEN_AT_END)
717 PAPI_FCALL( papif_get_event_info, PAPIF_GET_EVENT_INFO,
718  ( int *EventCode, char *symbol, char *long_descr, char *short_descr,
719  int *count, char *event_note, int *flags, int *check,
720  int symbol_len, int long_descr_len, int short_descr_len,
721  int event_note_len ) )
722 #else
723 PAPI_FCALL( papif_get_event_info, PAPIF_GET_EVENT_INFO,
724  ( int *EventCode, char *symbol, char *long_descr, char *short_descr,
725  int *count, char *event_note, int *flags, int *check ) )
726 #endif
727 {
728  PAPI_event_info_t info;
729  ( void ) flags; /*Unused */
730 #if defined(_FORTRAN_STRLEN_AT_END)
731  int i;
732  if ( ( *check = PAPI_get_event_info( *EventCode, &info ) ) == PAPI_OK ) {
733  strncpy( symbol, info.symbol, ( size_t ) symbol_len );
734  for ( i = ( int ) strlen( info.symbol ); i < symbol_len;
735  symbol[i++] = ' ' );
736  strncpy( long_descr, info.long_descr, ( size_t ) long_descr_len );
737  for ( i = ( int ) strlen( info.long_descr ); i < long_descr_len;
738  long_descr[i++] = ' ' );
739  strncpy( short_descr, info.short_descr, ( size_t ) short_descr_len );
740  for ( i = ( int ) strlen( info.short_descr ); i < short_descr_len;
741  short_descr[i++] = ' ' );
742 
743  *count = ( int ) info.count;
744 
745  int note_len=0;
746 
747  strncpy( event_note, info.note, ( size_t ) event_note_len );
748  note_len=strlen(info.note);
749 
750  for ( i = note_len; i < event_note_len;
751  event_note[i++] = ' ' );
752  }
753 #else
754 /* printf("EventCode: %d\n", *EventCode ); -KSL */
755  if ( ( *check = PAPI_get_event_info( *EventCode, &info ) ) == PAPI_OK ) {
756  strncpy( symbol, info.symbol, PAPI_MAX_STR_LEN );
757  strncpy( long_descr, info.long_descr, PAPI_MAX_STR_LEN );
758  strncpy( short_descr, info.short_descr, PAPI_MAX_STR_LEN );
759  *count = info.count;
760  if (info.note)
761  strncpy( event_note, info.note,
763  }
764 /* printf("Check: %d\n", *check); -KSL */
765 #endif
766 }
767 
778 #if defined(_FORTRAN_STRLEN_AT_END)
779 PAPI_FCALL( papif_event_code_to_name, PAPIF_EVENT_CODE_TO_NAME,
780  ( int *EventCode, char *out_str, int *check, int out_len ) )
781 #else
782 PAPI_FCALL( papif_event_code_to_name, PAPIF_EVENT_CODE_TO_NAME,
783  ( int *EventCode, char *out, int *check ) )
784 #endif
785 {
786 #if defined(_FORTRAN_STRLEN_AT_END)
787  char tmp[PAPI_MAX_STR_LEN];
788  int i;
789  *check = PAPI_event_code_to_name( *EventCode, tmp );
790  /* tmp has \0 within PAPI_MAX_STR_LEN chars so strncpy is safe */
791  strncpy( out_str, tmp, ( size_t ) out_len );
792  /* overwrite any NULLs and trailing garbage in out_str */
793  for ( i = ( int ) strlen( tmp ); i < out_len; out_str[i++] = ' ' );
794 #else
795  /* The array "out" passed by the user must be sufficiently long */
796  *check = PAPI_event_code_to_name( *EventCode, out );
797 #endif
798 }
799 
810 #if defined(_FORTRAN_STRLEN_AT_END)
811 PAPI_FCALL( papif_event_name_to_code, PAPIF_EVENT_NAME_TO_CODE,
812  ( char *in_str, int *out, int *check, int in_len ) )
813 #else
814 PAPI_FCALL( papif_event_name_to_code, PAPIF_EVENT_NAME_TO_CODE,
815  ( char *in, int *out, int *check ) )
816 #endif
817 {
818 #if defined(_FORTRAN_STRLEN_AT_END)
819  int slen, i;
820  char tmpin[PAPI_MAX_STR_LEN];
821 
822  /* What is the maximum number of chars to copy ? */
823  slen = in_len < PAPI_MAX_STR_LEN ? in_len : PAPI_MAX_STR_LEN;
824  strncpy( tmpin, in_str, ( size_t ) slen );
825 
826  /* Remove trailing blanks from initial Fortran string */
827  for ( i = slen - 1; i > -1 && tmpin[i] == ' '; tmpin[i--] = '\0' );
828 
829  /* Make sure string is NULL terminated before call */
830  tmpin[PAPI_MAX_STR_LEN - 1] = '\0';
831  if ( slen < PAPI_MAX_STR_LEN )
832  tmpin[slen] = '\0';
833 
834  *check = PAPI_event_name_to_code( tmpin, out );
835 #else
836  /* This will have trouble if argument in is not null terminated */
837  *check = PAPI_event_name_to_code( in, out );
838 #endif
839 }
840 
851 PAPI_FCALL( papif_num_events, PAPIF_NUM_EVENTS, ( int *EventCode, int *count ) )
852 {
853  *count = PAPI_num_events( *EventCode );
854 }
855 
866 PAPI_FCALL( papif_enum_event, PAPIF_ENUM_EVENT,
867  ( int *EventCode, int *modifier, int *check ) )
868 {
869  *check = PAPI_enum_event( EventCode, *modifier );
870 }
871 
882 PAPI_FCALL( papif_read, PAPIF_READ,
883  ( int *EventSet, long long *values, int *check ) )
884 {
885  *check = PAPI_read( *EventSet, values );
886 }
887 
898 PAPI_FCALL( papif_read_ts, PAPIF_READ_TS,
899  ( int *EventSet, long long *values, long long *cycles, int *check ) )
900 {
901  *check = PAPI_read_ts( *EventSet, values, cycles );
902 }
903 
914 PAPI_FCALL( papif_remove_event, PAPIF_REMOVE_EVENT,
915  ( int *EventSet, int *Event, int *check ) )
916 {
917  *check = PAPI_remove_event( *EventSet, *Event );
918 }
919 
930 #if defined(_FORTRAN_STRLEN_AT_END)
931 PAPI_FCALL( papif_remove_named_event, PAPIF_REMOVE_NAMED_EVENT,
932  ( int *EventSet, char *EventName, int *check, int Event_len ) )
933 {
934  char tmp[PAPI_MAX_STR_LEN];
935  Fortran2cstring( tmp, EventName, PAPI_MAX_STR_LEN, Event_len );
936  *check = PAPI_remove_named_event( *EventSet, tmp );
937 }
938 #else
939 PAPI_FCALL( papif_remove_named_event, PAPIF_REMOVE_NAMED_EVENT,
940  ( int *EventSet, char *EventName, int *check ) )
941 {
942  *check = PAPI_remove_named_event( *EventSet, EventName );
943 }
944 #endif
945 
956 PAPI_FCALL( papif_remove_events, PAPIF_REMOVE_EVENTS,
957  ( int *EventSet, int *Events, int *number, int *check ) )
958 {
959  *check = PAPI_remove_events( *EventSet, Events, *number );
960 }
961 
972 PAPI_FCALL( papif_reset, PAPIF_RESET, ( int *EventSet, int *check ) )
973 {
974  *check = PAPI_reset( *EventSet );
975 }
976 
987 PAPI_FCALL( papif_set_debug, PAPIF_SET_DEBUG, ( int *debug, int *check ) )
988 {
989  *check = PAPI_set_debug( *debug );
990 }
991 
1002 PAPI_FCALL( papif_set_domain, PAPIF_SET_DOMAIN, ( int *domain, int *check ) )
1004  *check = PAPI_set_domain( *domain );
1005 }
1006 
1017 PAPI_FCALL( papif_set_cmp_domain, PAPIF_SET_CMP_DOMAIN,
1018  ( int *domain, int *cidx, int *check ) )
1019 {
1020  *check = PAPI_set_cmp_domain( *domain, *cidx );
1021 }
1022 
1033 PAPI_FCALL( papif_set_granularity, PAPIF_SET_GRANULARITY,
1034  ( int *granularity, int *check ) )
1035 {
1036  *check = PAPI_set_granularity( *granularity );
1037 }
1038 
1049 PAPI_FCALL( papif_set_cmp_granularity, PAPIF_SET_CMP_GRANULARITY,
1050  ( int *granularity, int *cidx, int *check ) )
1051 {
1052  *check = PAPI_set_cmp_granularity( *granularity, *cidx );
1053 }
1054 
1065 PAPI_FCALL( papif_shutdown, PAPIF_SHUTDOWN, ( void ) )
1067  PAPI_shutdown( );
1068 }
1069 
1080 PAPI_FCALL( papif_start, PAPIF_START, ( int *EventSet, int *check ) )
1082  *check = PAPI_start( *EventSet );
1083 }
1084 
1095 PAPI_FCALL( papif_state, PAPIF_STATE,
1096  ( int *EventSet, int *status, int *check ) )
1097 {
1098  *check = PAPI_state( *EventSet, status );
1099 }
1100 
1111 PAPI_FCALL( papif_stop, PAPIF_STOP,
1112  ( int *EventSet, long long *values, int *check ) )
1113 {
1114  *check = PAPI_stop( *EventSet, values );
1115 }
1116 
1127 PAPI_FCALL( papif_write, PAPIF_WRITE,
1128  ( int *EventSet, long long *values, int *check ) )
1129 {
1130  *check = PAPI_write( *EventSet, values );
1131 }
1132 
1143 PAPI_FCALL( papif_lock, PAPIF_LOCK,
1144  ( int *lock, int *check ) )
1145 {
1146  *check = PAPI_lock( *lock );
1147 }
1148 
1159 PAPI_FCALL( papif_unlock, PAPIF_unlock,
1160  ( int *lock, int *check ) )
1161 {
1162  *check = PAPI_unlock( *lock );
1163 }
1164 
1165 /* The High Level API Wrappers */
1166 
1177 PAPI_FCALL( papif_start_counters, PAPIF_START_COUNTERS,
1178  ( int *events, int *array_len, int *check ) )
1179 {
1180  *check = PAPI_start_counters( events, *array_len );
1181 }
1182 
1193 PAPI_FCALL( papif_read_counters, PAPIF_READ_COUNTERS,
1194  ( long long *values, int *array_len, int *check ) )
1195 {
1196  *check = PAPI_read_counters( values, *array_len );
1197 }
1198 
1209 PAPI_FCALL( papif_stop_counters, PAPIF_STOP_COUNTERS,
1210  ( long long *values, int *array_len, int *check ) )
1211 {
1212  *check = PAPI_stop_counters( values, *array_len );
1213 }
1214 
1225 PAPI_FCALL( papif_accum_counters, PAPIF_ACCUM_COUNTERS,
1226  ( long long *values, int *array_len, int *check ) )
1227 {
1228  *check = PAPI_accum_counters( values, *array_len );
1229 }
1230 
1241 PAPI_FCALL( papif_num_counters, PAPIF_NUM_COUNTERS, ( int *numevents ) )
1243  *numevents = PAPI_num_counters( );
1244 }
1245 
1256 PAPI_FCALL( papif_ipc, PAPIF_IPC,
1257  ( float *rtime, float *ptime, long long *ins, float *ipc,
1258  int *check ) )
1259 {
1260  *check = PAPI_ipc( rtime, ptime, ins, ipc );
1261 }
1262 
1273 PAPI_FCALL( papif_epc, PAPIF_EPC,
1274  ( int event, float *rtime, float *ptime,
1275  long long *ref, long long *core, long long *evt, float *epc,
1276  int *check) )
1277 {
1278  *check = PAPI_epc( event, rtime, ptime, ref, core, evt, epc );
1279 }
1280 
1291 PAPI_FCALL( papif_flips, PAPIF_FLIPS,
1292  ( float *real_time, float *proc_time, long long *flpins,
1293  float *mflips, int *check ) )
1294 {
1295  *check = PAPI_flips( real_time, proc_time, flpins, mflips );
1296 }
1297 
1308 PAPI_FCALL( papif_flops, PAPIF_FLOPS,
1309  ( float *real_time, float *proc_time, long long *flpops,
1310  float *mflops, int *check ) )
1311 {
1312  *check = PAPI_flops( real_time, proc_time, flpops, mflops );
1313 }
1314 
1315 
1316 /* Fortran only APIs for get_opt and set_opt functionality */
1317 
1330 PAPI_FCALL( papif_get_clockrate, PAPIF_GET_CLOCKRATE, ( int *cr ) )
1332  *cr = PAPI_get_opt( PAPI_CLOCKRATE, (PAPI_option_t *) NULL );
1333 }
1334 
1347 #if defined(_FORTRAN_STRLEN_AT_END)
1348 PAPI_FCALL( papif_get_preload, PAPIF_GET_PRELOAD,
1349  ( char *lib_preload_env, int *check, int lib_preload_env_len ) )
1350 #else
1351 PAPI_FCALL( papif_get_preload, PAPIF_GET_PRELOAD,
1352  ( char *lib_preload_env, int *check ) )
1353 #endif
1354 {
1355  PAPI_option_t p;
1356 #if defined(_FORTRAN_STRLEN_AT_END)
1357  int i;
1358 
1359  if ( ( *check = PAPI_get_opt( PAPI_PRELOAD, &p ) ) == PAPI_OK ) {
1360  strncpy( lib_preload_env, p.preload.lib_preload_env,
1361  ( size_t ) lib_preload_env_len );
1362  for ( i = ( int ) strlen( p.preload.lib_preload_env );
1363  i < lib_preload_env_len; lib_preload_env[i++] = ' ' );
1364  }
1365 #else
1366  if ( ( *check = PAPI_get_opt( PAPI_PRELOAD, &p ) ) == PAPI_OK ) {
1367  strncpy( lib_preload_env, p.preload.lib_preload_env, PAPI_MAX_STR_LEN );
1368  }
1369 #endif
1370 }
1371 
1382 PAPI_FCALL( papif_get_granularity, PAPIF_GET_GRANULARITY,
1383  ( int *eventset, int *granularity, int *mode, int *check ) )
1384 {
1385  PAPI_option_t g;
1386 
1387  if ( *mode == PAPI_DEFGRN ) {
1388  *granularity = PAPI_get_opt( *mode, &g );
1389  *check = PAPI_OK;
1390  } else if ( *mode == PAPI_GRANUL ) {
1391  g.granularity.eventset = *eventset;
1392  if ( ( *check = PAPI_get_opt( *mode, &g ) ) == PAPI_OK ) {
1393  *granularity = g.granularity.granularity;
1394  }
1395  } else {
1396  *check = PAPI_EINVAL;
1397  }
1398 }
1399 
1410 PAPI_FCALL( papif_get_domain, PAPIF_GET_DOMAIN,
1411  ( int *eventset, int *domain, int *mode, int *check ) )
1412 {
1413  PAPI_option_t d;
1414 
1415  if ( *mode == PAPI_DEFDOM ) {
1416  *domain = PAPI_get_opt( *mode, (PAPI_option_t *) NULL );
1417  *check = PAPI_OK;
1418  } else if ( *mode == PAPI_DOMAIN ) {
1419  d.domain.eventset = *eventset;
1420  if ( ( *check = PAPI_get_opt( *mode, &d ) ) == PAPI_OK ) {
1421  *domain = d.domain.domain;
1422  }
1423  } else {
1424  *check = PAPI_EINVAL;
1425  }
1426 }
1427 
1428 #if 0
1429 PAPI_FCALL( papif_get_inherit, PAPIF_GET_INHERIT, ( int *inherit, int *check ) )
1430 {
1431  PAPI_option_t i;
1432 
1433  if ( ( *check = PAPI_get_opt( PAPI_INHERIT, &i ) ) == PAPI_OK ) {
1434  *inherit = i.inherit.inherit;
1435  }
1436 }
1437 #endif
1438 
1450 PAPI_FCALL( papif_set_event_domain, PAPIF_SET_EVENT_DOMAIN,
1451  ( int *es, int *domain, int *check ) )
1452 {
1453  PAPI_option_t d;
1454 
1455  d.domain.domain = *domain;
1456  d.domain.eventset = *es;
1457  *check = PAPI_set_opt( PAPI_DOMAIN, &d );
1458 }
1459 
1470 PAPI_FCALL( papif_set_inherit, PAPIF_SET_INHERIT, ( int *inherit, int *check ) )
1471 {
1472  PAPI_option_t i;
1473 
1475  *check = PAPI_set_opt( PAPI_INHERIT, &i );
1476 }
1477 
1478 #pragma GCC visibility pop
char name[PAPI_HUGE_STR_LEN]
Definition: papi.h:696
i inherit inherit
unsigned int count
Definition: papi.h:987
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
int PAPI_is_initialized(void)
Definition: papi.c:6463
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
Hardware info structure.
Definition: papi.h:780
long long PAPI_get_virt_usec(void)
Definition: papi.c:6372
int PAPI_set_cmp_granularity(int granularity, int cidx)
Definition: papi.c:5622
int PAPI_reset(int EventSet)
Definition: papi.c:2459
static int numevents
Definition: kufrin.c:22
long long flags
Definition: iozone.c:12330
caddr_t text_end
Definition: papi.h:698
static int Events[NUM_EVENTS]
Definition: init_fini.c:8
unsigned long PAPI_thread_id(void)
Definition: papi.c:162
int PAPI_write(int EventSet, long long *values)
Definition: papi.c:2813
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:1758
long long PAPI_get_virt_cyc(void)
Definition: papi.c:6300
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:969
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:1152
PAPI_granularity_option_t granularity
Definition: papi.h:853
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
int EventSet
int PAPI_register_thread(void)
Definition: papi.c:208
return PAPI_OK
Definition: linux-nvml.c:497
int count
Definition: iozone.c:22422
PAPI_inherit_option_t inherit
Definition: papi.h:852
caddr_t bss_start
Definition: papi.h:701
int PAPI_event_name_to_code(const char *in, int *out)
Definition: papi.c:1004
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:848
void
Definition: iozone.c:18627
char note[PAPI_HUGE_STR_LEN]
Definition: papi.h:1013
int PAPI_remove_events(int EventSet, int *Events, int number)
Definition: papi.c:5931
return PAPI_EINVAL
Definition: linux-nvml.c:436
Return the number of hardware counters on the specified component.
int PAPI_set_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:3465
int PAPI_add_events(int EventSet, int *Events, int number)
Definition: papi.c:5843
#define PAPI_INHERIT
Definition: papi.h:458
#define PAPI_PRELOAD
Definition: papi.h:441
Return codes and api definitions.
* check
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:835
int PAPI_add_named_event(int EventSet, const char *EventName)
Definition: papi.c:1876
char events[MAX_EVENTS][BUFSIZ]
int PAPI_set_cmp_domain(int domain, int cidx)
Definition: papi.c:5758
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:621
int PAPI_num_cmp_hwctrs(int cidx)
Definition: papi.c:3965
int PAPI_accum(int EventSet, long long *values)
Definition: papi.c:2745
static int cidx
int PAPI_thread_init(unsigned long int(*id_fn)(void))
Definition: papi.c:123
int PAPI_library_init(int version)
Definition: papi.c:500
long long debug
Definition: iozone.c:1374
float revision
Definition: papi.h:791
int i
Definition: fileop.c:140
int PAPI_num_hwctrs(void)
Definition: papi.c:3909
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:871
void PAPI_shutdown(void)
Definition: papi.c:4461
int PAPI_num_events(int EventSet)
Definition: papi.c:4426
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4143
caddr_t text_start
Definition: papi.h:697
PAPI_address_map_t address_info
Definition: papi.h:709
char short_descr[PAPI_MIN_STR_LEN]
Definition: papi.h:967
#define PAPI_EXEINFO
Definition: papi.h:445
void int num
Definition: iozone.c:22151
int PAPI_state(int EventSet, int *status)
Definition: papi.c:3053
int PAPI_query_named_event(const char *EventName)
Definition: papi.c:756
#define PAPI_GRANUL
Definition: papi.h:435
#define PAPI_FCALL(function, caps, args)
#define PAPI_DEFGRN
Definition: papi.h:434
long long
Definition: iozone.c:19827
int nnodes
Definition: papi.h:785
static int Event[MAX_EVENTS]
int PAPI_set_granularity(int granularity)
Definition: papi.c:5557
nvmlDevice_t handle
Definition: linux-nvml.c:427
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2890
int PAPI_assign_eventset_component(int EventSet, int cidx)
Definition: papi.c:1526
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:915
atomic_p lock[]
Definition: aix.c:25
char vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:788
strcpy(filename, default_filename)
int PAPI_get_dmem_info(PAPI_dmem_info_t *dest)
Definition: papi.c:6063
#define PAPI_DOMAIN
Definition: papi.h:433
goto out
Definition: pscanf.h:20
caddr_t data_start
Definition: papi.h:699
int PAPI_query_event(int EventCode)
Definition: papi.c:684
int PAPI_multiplex_init(void)
Definition: papi.c:2982
int vendor
Definition: papi.h:787
int PAPI_read_ts(int EventSet, long long *values, long long *cycles)
Definition: papi.c:2648
long long PAPI_get_real_usec(void)
Definition: papi.c:6264
PAPI_exe_info_t * exe_info
Definition: papi.h:863
long long status
Definition: iozone.c:1335
int PAPI_unregister_thread(void)
Definition: papi.c:244
int model
Definition: papi.h:789
char * name
Definition: iozone.c:23648
#define PAPI_CLOCKRATE
Definition: papi.h:442
int PAPI_unlock(int lck)
Definition: papi.c:6421
int cpu_max_mhz
Definition: papi.h:796
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:6237
caddr_t bss_end
Definition: papi.h:702
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:700
#define PAPI_DEFDOM
Definition: papi.h:432
int PAPI_set_multiplex(int EventSet)
Definition: papi.c:3333
int totalcpus
Definition: papi.h:786
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:2014
int PAPI_remove_named_event(int EventSet, const char *EventName)
Definition: papi.c:1961
#define PAPI_MAX_STR_LEN
Definition: papi.h:465
PAPI_domain_option_t domain
Definition: papi.h:855
int PAPI_set_domain(int domain)
Definition: papi.c:5688
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:790
char fullname[PAPI_HUGE_STR_LEN]
Definition: papi.h:708
long long PAPI_get_real_cyc(void)
Definition: papi.c:6217
int PAPI_read(int EventSet, long long *values)
Definition: papi.c:2559
int PAPI_start(int EventSet)
Definition: papi.c:2096
PAPI_preload_info_t preload
Definition: papi.h:850
void PAPI_perror(const char *msg)
Definition: papi.c:4653
int PAPI_get_multiplex(int EventSet)
Definition: papi.c:4028
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6185
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
int PAPI_lock(int lck)
Definition: papi.c:6401
long long tmp
Definition: iozone.c:12031
int PAPI_set_debug(int level)
Definition: papi.c:3126
int PAPI_list_events(int EventSet, int *Events, int *number)
Definition: papi.c:6001
int ncpu
Definition: papi.h:781