PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
papi.c
Go to the documentation of this file.
1 /****************************/
2 /* THIS IS OPEN SOURCE CODE */
3 /****************************/
4 
24 #include <stdio.h>
25 #include <string.h>
26 #include <stdlib.h>
27 #include <unistd.h>
28 
29 #include "papi.h"
30 #include "papi_internal.h"
31 #include "papi_vector.h"
32 #include "papi_memory.h"
33 
34 #include "papi_user_events.h"
35 
36 #include "cpus.h"
37 #include "extras.h"
38 #include "sw_multiplex.h"
39 #include "papi_hl.h"
40 
41 /*******************************/
42 /* BEGIN EXTERNAL DECLARATIONS */
43 /*******************************/
44 
45 
46 #ifdef DEBUG
47 #define papi_return(a) do { \
48  int b = a; \
49  if (b != PAPI_OK) {\
50  _papi_hwi_errno = b;\
51  } \
52  return((_papi_hwi_debug_handler ? _papi_hwi_debug_handler(b) : b)); \
53 } while (0)
54 #else
55 #define papi_return(a) do { \
56  int b = a; \
57  if (b != PAPI_OK) {\
58  _papi_hwi_errno = b;\
59  } \
60  return(b);\
61 } while(0)
62 #endif
63 
64 
65 /*
66 #ifdef DEBUG
67 #define papi_return(a) return((_papi_hwi_debug_handler ? _papi_hwi_debug_handler(a) : a))
68 #else
69 #define papi_return(a) return(a)
70 #endif
71 */
72 
73 #ifdef DEBUG
75 #endif
76 
77 
78 static int init_retval = DEADBEEF;
79 
80 inline_static int
82 {
83  if ( _papi_hwi_invalid_cmp( cidx ) )
84  return ( PAPI_ENOCMP );
85  return ( cidx );
86 }
87 
88 inline_static int
90 {
91  return ( valid_component( ESI->CmpIdx ) );
92 }
93 
117 int
118 PAPI_thread_init( unsigned long int ( *id_fn ) ( void ) )
119 {
120  /* Thread support not implemented on Alpha/OSF because the OSF pfm
121  * counter device driver does not support per-thread counters.
122  * When this is updated, we can remove this if statement
123  */
124  if ( init_level == PAPI_NOT_INITED )
126 
128  papi_return( PAPI_OK );
129 
132 }
133 
156 unsigned long
158 {
159  if ( _papi_hwi_thread_id_fn != NULL )
160  return ( ( *_papi_hwi_thread_id_fn ) ( ) );
161  else
162 #ifdef DEBUG
164  return ( unsigned long ) _papi_hwi_debug_handler( PAPI_EMISC );
165 #endif
166  return ( unsigned long ) PAPI_EMISC;
167 }
168 
169 /* Thread Functions */
170 
171 /*
172  * Notify PAPI that a thread has 'appeared'
173  * We lookup the thread, if it does not exist we create it
174  */
175 
202 int
204 {
206 
207  if ( init_level == PAPI_NOT_INITED )
210 }
211 
212 /*
213  * Notify PAPI that a thread has 'disappeared'
214  * We lookup the thread, if it does not exist we return an error
215  */
238 int
240 {
242 
243  if ( thread )
244  papi_return( _papi_hwi_shutdown_thread( thread, 0 ) );
245 
247 }
248 
280 int
281 PAPI_list_threads( PAPI_thread_id_t *tids, int *number )
282 {
284  int retval;
285 
286  /* If tids == NULL, then just count the threads, don't gather a list. */
287  /* If tids != NULL, then we need the length of the tids array in num. */
288 
289  if ( ( number == NULL ) || ( tids && ( *number <= 0 ) ) )
291 
292  memset( &tmp, 0x0, sizeof ( tmp ) );
293 
294  /* data == NULL, since we don't want the thread specific pointers. */
295  /* tids may be NULL, if the user doesn't want the thread IDs. */
296 
297  tmp.num = *number;
298  tmp.id = tids;
299  tmp.data = NULL;
300 
301  retval = _papi_hwi_gather_all_thrspec_data( 0, &tmp );
302  if ( retval == PAPI_OK )
303  *number = tmp.num;
304 
305  papi_return( retval );
306 }
307 
356 int
357 PAPI_get_thr_specific( int tag, void **ptr )
358 {
360  int doall = 0, retval = PAPI_OK;
361 
362  if ( init_level == PAPI_NOT_INITED )
364  if ( tag & PAPI_TLS_ALL_THREADS ) {
365  tag = tag ^ PAPI_TLS_ALL_THREADS;
366  doall = 1;
367  }
368  if ( ( tag < 0 ) || ( tag > PAPI_TLS_NUM ) )
370 
371  if ( doall )
373  ( tag, ( PAPI_all_thr_spec_t * ) ptr ) );
374 
376  if ( retval == PAPI_OK )
377  *ptr = thread->thread_storage[tag];
378  else
379  papi_return( retval );
380 
381  return ( PAPI_OK );
382 }
383 
432 int
433 PAPI_set_thr_specific( int tag, void *ptr )
434 {
436  int retval = PAPI_OK;
437 
438  if ( init_level == PAPI_NOT_INITED )
440  if ( ( tag < 0 ) || ( tag > PAPI_NUM_TLS ) )
442 
443  retval = _papi_hwi_lookup_or_create_thread( &thread, 0 );
444  if ( retval == PAPI_OK ) {
446  thread->thread_storage[tag] = ptr;
448  }
449  else
450  return ( retval );
451 
452  return ( PAPI_OK );
453 }
454 
455 
494 int
496 {
497  APIDBG( "Entry: version: %#x\n", version);
498  char *filename;
499  int tmp = 0, tmpel;
500 
501  /* This is a poor attempt at a lock.
502  For 3.1 this should be replaced with a
503  true UNIX semaphore. We cannot use PAPI
504  locks here because they are not initialized yet */
505  static int _in_papi_library_init_cnt = 0;
506 #ifdef DEBUG
507  char *var;
508 #endif
510 
511  if ( version != PAPI_VER_CURRENT )
513 
514  ++_in_papi_library_init_cnt;
515  while ( _in_papi_library_init_cnt > 1 ) {
516  PAPIERROR( "Multiple callers of PAPI_library_init" );
517  sleep( 1 );
518  }
519 
520  /* This checks to see if we have forked or called init more than once.
521  If we have forked, then we continue to init. If we have not forked,
522  we check to see the status of initialization. */
523 
524  APIDBG( "Initializing library: current PID %d, old PID %d\n",
525  getpid( ), _papi_hwi_system_info.pid );
526 
527  if ( _papi_hwi_system_info.pid == getpid( ) ) {
528  /* If the magic environment variable PAPI_ALLOW_STOLEN is set,
529  we call shutdown if PAPI has been initialized. This allows
530  tools that use LD_PRELOAD to run on applications that use PAPI.
531  In this circumstance, PAPI_ALLOW_STOLEN will be set to 'stolen'
532  so the tool can check for this case. */
533 
534  if ( getenv( "PAPI_ALLOW_STOLEN" ) ) {
535  char buf[PAPI_HUGE_STR_LEN];
536  if ( init_level != PAPI_NOT_INITED )
537  PAPI_shutdown( );
538  sprintf( buf, "%s=%s", "PAPI_ALLOW_STOLEN", "stolen" );
539  putenv( buf );
540  }
541 
542  /* If the library has been successfully initialized *OR*
543  the library attempted initialization but failed. */
544 
545  else if ( ( init_level != PAPI_NOT_INITED ) ||
546  ( init_retval != DEADBEEF ) ) {
547  _in_papi_library_init_cnt--;
548  if ( init_retval < PAPI_OK )
550  else
551  return ( init_retval );
552  }
553 
554  APIDBG( "system_info was initialized, but init did not succeed\n" );
555  }
556 #ifdef DEBUG
557  var = ( char * ) getenv( "PAPI_DEBUG" );
558  _papi_hwi_debug = 0;
559 
560  if ( var != NULL ) {
561  if ( strlen( var ) != 0 ) {
562  if ( strstr( var, "SUBSTRATE" ) )
564  if ( strstr( var, "API" ) )
566  if ( strstr( var, "INTERNAL" ) )
568  if ( strstr( var, "THREADS" ) )
570  if ( strstr( var, "MULTIPLEX" ) )
572  if ( strstr( var, "OVERFLOW" ) )
574  if ( strstr( var, "PROFILE" ) )
576  if ( strstr( var, "MEMORY" ) )
578  if ( strstr( var, "LEAK" ) )
580  if ( strstr( var, "ALL" ) )
582  }
583 
584  if ( _papi_hwi_debug == 0 )
586  }
587 #endif
588 
589  /* Be verbose for now */
590 
591  tmpel = _papi_hwi_error_level;
593 
594  /* Initialize internal globals */
596  _in_papi_library_init_cnt--;
597  _papi_hwi_error_level = tmpel;
599  }
600 
601  /* Initialize OS */
602  tmp = _papi_hwi_init_os();
603  if ( tmp ) {
604  init_retval = tmp;
606  _in_papi_library_init_cnt--;
607  _papi_hwi_error_level = tmpel;
609  }
610 
611  /* Initialize component globals */
612 
613  tmp = _papi_hwi_init_global( );
614  if ( tmp ) {
615  init_retval = tmp;
617  _in_papi_library_init_cnt--;
618  _papi_hwi_error_level = tmpel;
620  }
621 
622  /* Initialize thread globals, including the main threads */
623 
625  if ( tmp ) {
626  int i;
627  init_retval = tmp;
629  for ( i = 0; i < papi_num_components; i++ ) {
630  if (!_papi_hwd[i]->cmp_info.disabled) {
631  _papi_hwd[i]->shutdown_component( );
632  }
633  }
634  _in_papi_library_init_cnt--;
635  _papi_hwi_error_level = tmpel;
637  }
638 
640  _in_papi_library_init_cnt--;
641  _papi_hwi_error_level = tmpel;
642 
643 #ifdef STATIC_USER_EVENTS
645 #endif
646 
647  if ( (filename = getenv( "PAPI_USER_EVENTS_FILE" )) != NULL ) {
649  }
650 
651  return ( init_retval = PAPI_VER_CURRENT );
652 }
653 
695 int
696 PAPI_query_event( int EventCode )
697 {
698  APIDBG( "Entry: EventCode: %#x\n", EventCode);
699  if ( IS_PRESET(EventCode) ) {
700  EventCode &= PAPI_PRESET_AND_MASK;
701  if ( EventCode >= PAPI_MAX_PRESET_EVENTS )
703 
704  if ( _papi_hwi_presets[EventCode].count )
706  else
707  return PAPI_ENOEVNT;
708  }
709 
710  if ( IS_NATIVE(EventCode) ) {
712  ( ( unsigned int ) EventCode ) );
713  }
714 
715  if ( IS_USER_DEFINED(EventCode) ) {
716  EventCode &= PAPI_UE_AND_MASK;
717  if ( EventCode < 0 || EventCode > (int)_papi_user_events_count)
718  return ( PAPI_EINVAL );
719 
720  papi_return( PAPI_OK );
721  }
722 
724 }
725 
764 int
765 PAPI_query_named_event( char *EventName )
766 {
767  int ret, code;
768 
769  ret = PAPI_event_name_to_code( EventName, &code );
770  if ( ret == PAPI_OK ) ret = PAPI_query_event( code );
771  papi_return( ret);
772 }
773 
774 
804 const PAPI_component_info_t *
806 {
807  APIDBG( "Entry: Component Index %d\n", cidx);
808  if ( _papi_hwi_invalid_cmp( cidx ) )
809  return ( NULL );
810  else
811  return ( &( _papi_hwd[cidx]->cmp_info ) );
812 }
813 
814 /* PAPI_get_event_info:
815  tests input EventCode and returns a filled in PAPI_event_info_t
816  structure containing descriptive strings and values for the
817  specified event. Handles both preset and native events by
818  calling either _papi_hwi_get_event_info or
819  _papi_hwi_get_native_event_info.
820 */
843 int
844 PAPI_get_event_info( int EventCode, PAPI_event_info_t *info )
845 {
846  int i;
847  APIDBG( "Entry: EventCode: %#x\n", EventCode);
848 
849  if ( info == NULL )
851 
852  if ( IS_PRESET(EventCode) ) {
853  i = EventCode & PAPI_PRESET_AND_MASK;
854  if ( i >= PAPI_MAX_PRESET_EVENTS )
856  papi_return( _papi_hwi_get_preset_event_info( EventCode, info ) );
857  }
858 
859  if ( IS_NATIVE(EventCode) ) {
861  ( ( unsigned int ) EventCode, info ) );
862  }
863 
864  if ( IS_USER_DEFINED(EventCode) ) {
865  papi_return( PAPI_OK );
866  }
868 }
869 
870 
923 int
924 PAPI_event_code_to_name( int EventCode, char *out )
925 {
926  APIDBG( "Entry: EventCode: %#x\n", EventCode);
927  if ( out == NULL )
929 
930  if ( IS_PRESET(EventCode) ) {
931  EventCode &= PAPI_PRESET_AND_MASK;
932  if ( ( EventCode >= PAPI_MAX_PRESET_EVENTS )
933  || ( _papi_hwi_presets[EventCode].symbol == NULL ) )
935 
936  strncpy( out, _papi_hwi_presets[EventCode].symbol,
938  papi_return( PAPI_OK );
939  }
940 
941  if ( IS_NATIVE(EventCode) ) {
943  ( ( unsigned int ) EventCode, out, PAPI_MAX_STR_LEN ) );
944  }
945 
946  if ( IS_USER_DEFINED(EventCode) ) {
947  EventCode &= PAPI_UE_AND_MASK;
948 
949  if ( EventCode < 0 || EventCode > (int)_papi_user_events_count )
951 
952  strncpy( out, _papi_user_events[EventCode].symbol,
954  papi_return( PAPI_OK );
955  }
956 
958 }
959 
1007 int
1008 PAPI_event_name_to_code( char *in, int *out )
1009 {
1010  APIDBG("Entry: in: %p, name: %s, out: %p\n", in, in, out);
1011  int i;
1012 
1013  if ( ( in == NULL ) || ( out == NULL ) )
1015 
1016  if ( init_level == PAPI_NOT_INITED )
1018 
1019  /* All presets start with "PAPI_" so no need to */
1020  /* do an exhaustive search if that's not there */
1021  if (strncmp(in, "PAPI_", 5) == 0) {
1022  for(i = 0; i < PAPI_MAX_PRESET_EVENTS; i++ ) {
1023  if ( ( _papi_hwi_presets[i].symbol )
1024  && ( strcasecmp( _papi_hwi_presets[i].symbol, in ) == 0) ) {
1025  *out = ( int ) ( i | PAPI_PRESET_MASK );
1026  papi_return( PAPI_OK );
1027  }
1028  }
1029  }
1030 
1031  for ( i=0; i < (int)_papi_user_events_count; i++ ) {
1032  if ( strcasecmp( _papi_user_events[i].symbol, in ) == 0 ) {
1033  *out = (int) ( i | PAPI_UE_MASK );
1034  papi_return( PAPI_OK );
1035  }
1036  }
1037 
1039 }
1040 
1041 /* Updates EventCode to next valid value, or returns error;
1042  modifier can specify {all / available} for presets, or other values for native tables
1043  and may be platform specific (Major groups / all mask bits; P / M / E chip, etc) */
1044 
1147 int
1148 PAPI_enum_event( int *EventCode, int modifier )
1149 {
1150  int i = *EventCode;
1151  int retval;
1152  int cidx;
1153  int event_code;
1154 
1155  APIDBG( "Entry: EventCode: %#x, modifier: %d\n", *EventCode, modifier);
1156  cidx = _papi_hwi_component_index( *EventCode );
1157  if (cidx < 0) return PAPI_ENOCMP;
1158 
1159  /* Do we handle presets in componets other than CPU? */
1160  /* if (( IS_PRESET(i) ) && cidx > 0 )) return PAPI_ENOCMP; */
1161 
1162  if ( IS_PRESET(i) ) {
1163  if ( modifier == PAPI_ENUM_FIRST ) {
1164  *EventCode = ( int ) PAPI_PRESET_MASK;
1165  return ( PAPI_OK );
1166  }
1167  i &= PAPI_PRESET_AND_MASK;
1168  while ( ++i < PAPI_MAX_PRESET_EVENTS ) {
1169  if ( _papi_hwi_presets[i].symbol == NULL )
1170  return ( PAPI_ENOEVNT ); /* NULL pointer terminates list */
1171  if ( modifier & PAPI_PRESET_ENUM_AVAIL ) {
1172  if ( _papi_hwi_presets[i].count == 0 )
1173  continue;
1174  }
1175  *EventCode = ( int ) ( i | PAPI_PRESET_MASK );
1176  return ( PAPI_OK );
1177  }
1178  } else if ( IS_NATIVE(i) ) {
1179  /* Should check against num native events here */
1180 
1181  event_code=_papi_hwi_eventcode_to_native((int)*EventCode);
1182  retval = _papi_hwd[cidx]->ntv_enum_events((unsigned int *)&event_code, modifier );
1183 
1184  /* re-apply Component ID to the returned Event */
1185  *EventCode = _papi_hwi_native_to_eventcode(cidx,event_code);
1186 
1187  return retval;
1188  } else if ( IS_USER_DEFINED(i) ) {
1189  if ( modifier == PAPI_ENUM_FIRST ) {
1190  *EventCode = (int) 0x0;
1191  return ( PAPI_OK );
1192  }
1193 
1194  i &= PAPI_UE_AND_MASK;
1195  ++i;
1196 
1197  if ( (int)_papi_user_events_count <= i )
1198  *EventCode = i;
1199  return ( PAPI_OK );
1200  }
1201 
1203 }
1204 
1205 
1310 int
1311 PAPI_enum_cmp_event( int *EventCode, int modifier, int cidx )
1312 {
1313  int i = *EventCode;
1314  int retval;
1315  int event_code;
1316 
1317  APIDBG( "Entry: EventCode: %#x, modifier: %d, cidx: %d\n", *EventCode, modifier, cidx);
1318  if ( _papi_hwi_invalid_cmp(cidx) || ( (IS_PRESET(i)) && cidx > 0 ) ) {
1319  return PAPI_ENOCMP;
1320  }
1321 
1322  if (_papi_hwd[cidx]->cmp_info.disabled) {
1323  return PAPI_ENOCMP;
1324  }
1325 
1326  if ( IS_PRESET(i) ) {
1327  if ( modifier == PAPI_ENUM_FIRST ) {
1328  *EventCode = ( int ) PAPI_PRESET_MASK;
1329  return PAPI_OK;
1330  }
1331  i &= PAPI_PRESET_AND_MASK;
1332  while ( ++i < PAPI_MAX_PRESET_EVENTS ) {
1333  if ( _papi_hwi_presets[i].symbol == NULL )
1334  return ( PAPI_ENOEVNT ); /* NULL pointer terminates list */
1335  if ( modifier & PAPI_PRESET_ENUM_AVAIL ) {
1336  if ( _papi_hwi_presets[i].count == 0 )
1337  continue;
1338  }
1339  *EventCode = ( int ) ( i | PAPI_PRESET_MASK );
1340  return PAPI_OK;
1341  }
1342  } else if ( IS_NATIVE(i) ) {
1343 
1344  /* Should we check against num native events here? */
1345  event_code=_papi_hwi_eventcode_to_native(*EventCode);
1346  retval = _papi_hwd[cidx]->ntv_enum_events((unsigned int *)&event_code, modifier );
1347 
1348  if (retval!=PAPI_OK) {
1349  SUBDBG("VMW: retval=%d\n",retval);
1350  return PAPI_EINVAL;
1351  }
1352 
1353  /* re-apply Component ID to the returned Event */
1354  *EventCode = _papi_hwi_native_to_eventcode(cidx,event_code);
1355 
1356  return retval;
1357  }
1358 
1360 }
1361 
1405 int
1407 {
1408  APIDBG("Entry: EventSet: %p\n", EventSet);
1409  ThreadInfo_t *master;
1410  int retval;
1411 
1412  if ( init_level == PAPI_NOT_INITED )
1414  retval = _papi_hwi_lookup_or_create_thread( &master, 0 );
1415  if ( retval )
1416  papi_return( retval );
1417 
1418  papi_return( _papi_hwi_create_eventset( EventSet, master ) );
1419 }
1420 
1466 int
1468 {
1469  EventSetInfo_t *ESI;
1470  int retval;
1471 
1472  ESI = _papi_hwi_lookup_EventSet( EventSet );
1473  if ( ESI == NULL )
1475 
1476 /* validate cidx */
1477  retval = valid_component( cidx );
1478  if ( retval < 0 )
1479  papi_return( retval );
1480 
1481 /* cowardly refuse to reassign eventsets */
1482  if ( ESI->CmpIdx >= 0 )
1483  return PAPI_EINVAL;
1484 
1485  return ( _papi_hwi_assign_eventset( ESI, cidx ) );
1486 }
1487 
1509 int
1511 {
1512  EventSetInfo_t *ESI;
1513  int retval;
1514 
1515 /* validate eventset */
1516  ESI = _papi_hwi_lookup_EventSet( EventSet );
1517  if ( ESI == NULL )
1519 
1520 /* check if a component has been assigned */
1521  if ( ESI->CmpIdx < 0 )
1523 
1524 /* validate CmpIdx */
1525  retval = valid_component( ESI->CmpIdx );
1526  if ( retval < 0 )
1527  papi_return( retval );
1528 
1529 /* return the index */
1530  return ( ESI->CmpIdx );
1531 }
1532 
1533 
1603 int
1604 PAPI_add_event( int EventSet, int EventCode )
1605 {
1606  APIDBG("Entry: EventSet: %d, EventCode: %#x\n", EventSet, EventCode);
1607  EventSetInfo_t *ESI;
1608 
1609  /* Is the EventSet already in existence? */
1610 
1611  ESI = _papi_hwi_lookup_EventSet( EventSet );
1612  if ( ESI == NULL )
1614 
1615  /* Check argument for validity */
1616 
1617  if ( ( ( EventCode & PAPI_PRESET_MASK ) == 0 ) &&
1618  ( EventCode & PAPI_NATIVE_MASK ) == 0 )
1620 
1621  /* Of course, it must be stopped in order to modify it. */
1622 
1623  if ( ESI->state & PAPI_RUNNING )
1625 
1626  /* Now do the magic. */
1627 
1628  papi_return( _papi_hwi_add_event( ESI, EventCode ) );
1629 }
1630 
1698 int
1699 PAPI_remove_event( int EventSet, int EventCode )
1700 {
1701  EventSetInfo_t *ESI;
1702  int i,retval;
1703 
1704  /* check for pre-existing ESI */
1705 
1706  ESI = _papi_hwi_lookup_EventSet( EventSet );
1707  if ( ESI == NULL )
1709 
1710  /* Check argument for validity */
1711 
1712  if ( ( !IS_PRESET(EventCode) ) &&
1713  ( !IS_NATIVE(EventCode) ) &&
1714  ( !IS_USER_DEFINED(EventCode) ))
1716 
1717  /* Of course, it must be stopped in order to modify it. */
1718 
1719  if ( !( ESI->state & PAPI_STOPPED ) )
1721 
1722  /* if the state is PAPI_OVERFLOWING, you must first call
1723  PAPI_overflow with threshold=0 to remove the overflow flag */
1724 
1725  /* Turn off the event that is overflowing */
1726  if ( ESI->state & PAPI_OVERFLOWING ) {
1727  for ( i = 0; i < ESI->overflow.event_counter; i++ ) {
1728  if ( ESI->overflow.EventCode[i] == EventCode ) {
1729  retval = PAPI_overflow( EventSet, EventCode, 0, 0,
1730  ESI->overflow.handler );
1731  if (retval!=PAPI_OK) return retval;
1732  break;
1733  }
1734  }
1735  }
1736 
1737  /* force the user to call PAPI_profil to clear the PAPI_PROFILING flag */
1738  if ( ESI->state & PAPI_PROFILING ) {
1739  for ( i = 0; i < ESI->profile.event_counter; i++ ) {
1740  if ( ESI->profile.EventCode[i] == EventCode ) {
1741  PAPI_sprofil( NULL, 0, EventSet, EventCode, 0, 0 );
1742  break;
1743  }
1744  }
1745  }
1746 
1747  /* Now do the magic. */
1748 
1749  papi_return( _papi_hwi_remove_event( ESI, EventCode ) );
1750 }
1751 
1815 int
1816 PAPI_add_named_event( int EventSet, char *EventName )
1817 {
1818  int ret, code;
1819 
1820  ret = PAPI_event_name_to_code( EventName, &code );
1821  if ( ret == PAPI_OK ) ret = PAPI_add_event( EventSet, code );
1822  papi_return( ret );
1823 }
1824 
1892 int
1893 PAPI_remove_named_event( int EventSet, char *EventName )
1894 {
1895  int ret, code;
1896 
1897  ret = PAPI_event_name_to_code( EventName, &code );
1898  if ( ret == PAPI_OK ) ret = PAPI_remove_event( EventSet, code );
1899  papi_return( ret );
1900 }
1901 
1943 int
1945 {
1946  EventSetInfo_t *ESI;
1947 
1948  APIDBG("Destroying Eventset %d\n",*EventSet);
1949 
1950  /* check for pre-existing ESI */
1951 
1952  if ( EventSet == NULL )
1954 
1955  ESI = _papi_hwi_lookup_EventSet( *EventSet );
1956  if ( ESI == NULL )
1958 
1959  if ( !( ESI->state & PAPI_STOPPED ) )
1961 
1962  if ( ESI->NumberOfEvents )
1964 
1966  *EventSet = PAPI_NULL;
1967 
1968  return PAPI_OK;
1969 }
1970 
1971 /* simply checks for valid EventSet, calls component start() call */
2025 int
2027 {
2028 
2029  int is_dirty=0;
2030  int retval;
2031  EventSetInfo_t *ESI;
2032  ThreadInfo_t *thread = NULL;
2033  CpuInfo_t *cpu = NULL;
2034  hwd_context_t *context;
2035  int cidx;
2036 
2037  APIDBG("Entry: EventSet: %d\n", EventSet);
2038 
2039  ESI = _papi_hwi_lookup_EventSet( EventSet );
2040  if ( ESI == NULL ) {
2042  }
2043 
2044  APIDBG("EventSet: %p\n", ESI);
2045 
2046  cidx = valid_ESI_component( ESI );
2047  if ( cidx < 0 ) {
2048  papi_return( cidx );
2049  }
2050 
2051  /* only one event set per thread can be running at any time, */
2052  /* so if another event set is running, the user must stop that */
2053  /* event set explicitly */
2054 
2055  /* We used to check and not let multiple events be attached */
2056  /* to the same CPU, but this was unnecessary? */
2057 
2058  thread = ESI->master;
2059  cpu = ESI->CpuInfo;
2060 
2061  if ( thread->running_eventset[cidx] ) {
2062  APIDBG("Thread Running already (Only one active Eventset per component)\n");
2064  }
2065 
2066  /* Check that there are added events */
2067  if ( ESI->NumberOfEvents < 1 ) {
2069  }
2070 
2071  /* If multiplexing is enabled for this eventset,
2072  call John May's code. */
2073 
2074  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
2075  retval = MPX_start( ESI->multiplex.mpx_evset );
2076  if ( retval != PAPI_OK ) {
2077  papi_return( retval );
2078  }
2079 
2080  /* Update the state of this EventSet */
2081  ESI->state ^= PAPI_STOPPED;
2082  ESI->state |= PAPI_RUNNING;
2083 
2084  return PAPI_OK;
2085  }
2086 
2087  /* get the context we should use for this event set */
2088  context = _papi_hwi_get_context( ESI, &is_dirty );
2089  if (is_dirty) {
2090  /* we need to reset the context state because it was last used */
2091  /* for some other event set and does not contain the information */
2092  /* for our events. */
2093  retval = _papi_hwd[ESI->CmpIdx]->update_control_state(
2094  ESI->ctl_state,
2095  ESI->NativeInfoArray,
2096  ESI->NativeCount,
2097  context);
2098  if ( retval != PAPI_OK ) {
2099  papi_return( retval );
2100  }
2101 
2102  /* now that the context contains this event sets information, */
2103  /* make sure the position array in the EventInfoArray is correct */
2104 
2105  /* We have to do this because ->update_control_state() can */
2106  /* in theory re-order the native events out from under us. */
2108 
2109  }
2110 
2111  /* If overflowing is enabled, turn it on */
2112  if ( ( ESI->state & PAPI_OVERFLOWING ) &&
2113  !( ESI->overflow.flags & PAPI_OVERFLOW_HARDWARE ) ) {
2115  NEED_CONTEXT, cidx );
2116  if ( retval != PAPI_OK ) {
2117  papi_return( retval );
2118  }
2119 
2120  /* Update the state of this EventSet and thread */
2121  /* before to avoid races */
2122  ESI->state ^= PAPI_STOPPED;
2123  ESI->state |= PAPI_RUNNING;
2124  /* can not be attached to thread or cpu if overflowing */
2125  thread->running_eventset[cidx] = ESI;
2126 
2127  retval = _papi_hwd[cidx]->start( context, ESI->ctl_state );
2128  if ( retval != PAPI_OK ) {
2130  ESI->state ^= PAPI_RUNNING;
2131  ESI->state |= PAPI_STOPPED;
2132  thread->running_eventset[cidx] = NULL;
2133  papi_return( retval );
2134  }
2135 
2139  if ( retval != PAPI_OK ) {
2141  _papi_hwd[cidx]->stop( context, ESI->ctl_state );
2142  ESI->state ^= PAPI_RUNNING;
2143  ESI->state |= PAPI_STOPPED;
2144  thread->running_eventset[cidx] = NULL;
2145  papi_return( retval );
2146  }
2147  } else {
2148  /* Update the state of this EventSet and thread before */
2149  /* to avoid races */
2150  ESI->state ^= PAPI_STOPPED;
2151  ESI->state |= PAPI_RUNNING;
2152 
2153  /* if not attached to cpu or another process */
2154  if ( !(ESI->state & PAPI_CPU_ATTACHED) ) {
2155  if ( !( ESI->state & PAPI_ATTACHED ) ) {
2156  thread->running_eventset[cidx] = ESI;
2157  }
2158  } else {
2159  cpu->running_eventset[cidx] = ESI;
2160  }
2161 
2162  retval = _papi_hwd[cidx]->start( context, ESI->ctl_state );
2163  if ( retval != PAPI_OK ) {
2164  _papi_hwd[cidx]->stop( context, ESI->ctl_state );
2165  ESI->state ^= PAPI_RUNNING;
2166  ESI->state |= PAPI_STOPPED;
2167  if ( !(ESI->state & PAPI_CPU_ATTACHED) ) {
2168  if ( !( ESI->state & PAPI_ATTACHED ) )
2169  thread->running_eventset[cidx] = NULL;
2170  } else {
2171  cpu->running_eventset[cidx] = NULL;
2172  }
2173  papi_return( retval );
2174  }
2175  }
2176 
2177  return retval;
2178 }
2179 
2180 /* checks for valid EventSet, calls component stop() function. */
2231 int
2232 PAPI_stop( int EventSet, long long *values )
2233 {
2234  APIDBG("Entry: EventSet: %d, values: %p\n", EventSet, values);
2235  EventSetInfo_t *ESI;
2236  hwd_context_t *context;
2237  int cidx, retval;
2238 
2239  ESI = _papi_hwi_lookup_EventSet( EventSet );
2240  if ( ESI == NULL )
2242 
2243  cidx = valid_ESI_component( ESI );
2244  if ( cidx < 0 )
2245  papi_return( cidx );
2246 
2247  if ( !( ESI->state & PAPI_RUNNING ) )
2249 
2250  /* If multiplexing is enabled for this eventset, turn if off */
2251 
2252  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
2253  retval = MPX_stop( ESI->multiplex.mpx_evset, values );
2254  if ( retval != PAPI_OK )
2255  papi_return( retval );
2256 
2257  /* Update the state of this EventSet */
2258 
2259  ESI->state ^= PAPI_RUNNING;
2260  ESI->state |= PAPI_STOPPED;
2261 
2262  return ( PAPI_OK );
2263  }
2264 
2265  /* get the context we should use for this event set */
2266  context = _papi_hwi_get_context( ESI, NULL );
2267  /* Read the current counter values into the EventSet */
2268  retval = _papi_hwi_read( context, ESI, ESI->sw_stop );
2269  if ( retval != PAPI_OK )
2270  papi_return( retval );
2271 
2272  /* Remove the control bits from the active counter config. */
2273  retval = _papi_hwd[cidx]->stop( context, ESI->ctl_state );
2274  if ( retval != PAPI_OK )
2275  papi_return( retval );
2276  if ( values )
2277  memcpy( values, ESI->sw_stop,
2278  ( size_t ) ESI->NumberOfEvents * sizeof ( long long ) );
2279 
2280  /* If kernel profiling is in use, flush and process the kernel buffer */
2281 
2282  if ( ESI->state & PAPI_PROFILING ) {
2283  if ( _papi_hwd[cidx]->cmp_info.kernel_profile &&
2284  !( ESI->profile.flags & PAPI_PROFIL_FORCE_SW ) ) {
2285  retval = _papi_hwd[cidx]->stop_profiling( ESI->master, ESI );
2286  if ( retval < PAPI_OK )
2287  papi_return( retval );
2288  }
2289  }
2290 
2291  /* If overflowing is enabled, turn it off */
2292 
2293  if ( ESI->state & PAPI_OVERFLOWING ) {
2294  if ( !( ESI->overflow.flags & PAPI_OVERFLOW_HARDWARE ) ) {
2297  if ( retval != PAPI_OK )
2298  papi_return( retval );
2300  }
2301  }
2302 
2303  /* Update the state of this EventSet */
2304 
2305  ESI->state ^= PAPI_RUNNING;
2306  ESI->state |= PAPI_STOPPED;
2307 
2308  /* Update the running event set for this thread */
2309  if ( !(ESI->state & PAPI_CPU_ATTACHED) ) {
2310  if ( !( ESI->state & PAPI_ATTACHED ))
2311  ESI->master->running_eventset[cidx] = NULL;
2312  } else {
2313  ESI->CpuInfo->running_eventset[cidx] = NULL;
2314  }
2315 
2316 #if defined(DEBUG)
2317  if ( _papi_hwi_debug & DEBUG_API ) {
2318  int i;
2319  for ( i = 0; i < ESI->NumberOfEvents; i++ ) {
2320  APIDBG( "PAPI_stop ESI->sw_stop[%d]:\t%llu\n", i, ESI->sw_stop[i] );
2321  }
2322  }
2323 #endif
2324 
2325  return ( PAPI_OK );
2326 }
2327 
2376 int
2378 {
2379  int retval = PAPI_OK;
2380  EventSetInfo_t *ESI;
2381  hwd_context_t *context;
2382  int cidx;
2383 
2384  ESI = _papi_hwi_lookup_EventSet( EventSet );
2385  if ( ESI == NULL )
2387 
2388  cidx = valid_ESI_component( ESI );
2389  if ( cidx < 0 )
2390  papi_return( cidx );
2391 
2392  if ( ESI->state & PAPI_RUNNING ) {
2393  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
2394  retval = MPX_reset( ESI->multiplex.mpx_evset );
2395  } else {
2396  /* If we're not the only one running, then just
2397  read the current values into the ESI->start
2398  array. This holds the starting value for counters
2399  that are shared. */
2400  /* get the context we should use for this event set */
2401  context = _papi_hwi_get_context( ESI, NULL );
2402  retval = _papi_hwd[cidx]->reset( context, ESI->ctl_state );
2403  }
2404  } else {
2405 #ifdef __bgp__
2406  // For BG/P, we always want to reset the 'real' hardware counters. The counters
2407  // can be controlled via multiple interfaces, and we need to ensure that the values
2408  // are truly zero...
2409  /* get the context we should use for this event set */
2410  context = _papi_hwi_get_context( ESI, NULL );
2411  retval = _papi_hwd[cidx]->reset( context, ESI->ctl_state );
2412 #endif
2413  memset( ESI->sw_stop, 0x00,
2414  ( size_t ) ESI->NumberOfEvents * sizeof ( long long ) );
2415  }
2416 
2417  APIDBG( "PAPI_reset returns %d\n", retval );
2418  papi_return( retval );
2419 }
2420 
2475 int
2476 PAPI_read( int EventSet, long long *values )
2477 {
2478  EventSetInfo_t *ESI;
2479  hwd_context_t *context;
2480  int cidx, retval = PAPI_OK;
2481 
2482  APIDBG( "Entry: EventSet: %d\n", EventSet );
2483  ESI = _papi_hwi_lookup_EventSet( EventSet );
2484  if ( ESI == NULL )
2486 
2487  cidx = valid_ESI_component( ESI );
2488  if ( cidx < 0 )
2489  papi_return( cidx );
2490 
2491  if ( values == NULL )
2493 
2494  if ( ESI->state & PAPI_RUNNING ) {
2495  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
2496  retval = MPX_read( ESI->multiplex.mpx_evset, values, 0 );
2497  } else {
2498  /* get the context we should use for this event set */
2499  context = _papi_hwi_get_context( ESI, NULL );
2500  retval = _papi_hwi_read( context, ESI, values );
2501  }
2502  if ( retval != PAPI_OK )
2503  papi_return( retval );
2504  } else {
2505  memcpy( values, ESI->sw_stop,
2506  ( size_t ) ESI->NumberOfEvents * sizeof ( long long ) );
2507  }
2508 
2509 #if defined(DEBUG)
2510  if ( ISLEVEL( DEBUG_API ) ) {
2511  int i;
2512  for ( i = 0; i < ESI->NumberOfEvents; i++ ) {
2513  APIDBG( "PAPI_read values[%d]:\t%lld\n", i, values[i] );
2514  }
2515  }
2516 #endif
2517 
2518  APIDBG( "PAPI_read returns %d\n", retval );
2519  return ( PAPI_OK );
2520 }
2521 
2564 int
2565 PAPI_read_ts( int EventSet, long long *values, long long *cycles )
2566 {
2567  EventSetInfo_t *ESI;
2568  hwd_context_t *context;
2569  int cidx, retval = PAPI_OK;
2570 
2571  APIDBG( "Entry: EventSet: %d\n", EventSet );
2572  ESI = _papi_hwi_lookup_EventSet( EventSet );
2573  if ( ESI == NULL )
2575 
2576  cidx = valid_ESI_component( ESI );
2577  if ( cidx < 0 )
2578  papi_return( cidx );
2579 
2580  if ( values == NULL )
2582 
2583  if ( ESI->state & PAPI_RUNNING ) {
2584  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
2585  retval = MPX_read( ESI->multiplex.mpx_evset, values, 0 );
2586  } else {
2587  /* get the context we should use for this event set */
2588  context = _papi_hwi_get_context( ESI, NULL );
2589  retval = _papi_hwi_read( context, ESI, values );
2590  }
2591  if ( retval != PAPI_OK )
2592  papi_return( retval );
2593  } else {
2594  memcpy( values, ESI->sw_stop,
2595  ( size_t ) ESI->NumberOfEvents * sizeof ( long long ) );
2596  }
2597 
2598  *cycles = _papi_os_vector.get_real_cycles( );
2599 
2600 #if defined(DEBUG)
2601  if ( ISLEVEL( DEBUG_API ) ) {
2602  int i;
2603  for ( i = 0; i < ESI->NumberOfEvents; i++ ) {
2604  APIDBG( "PAPI_read values[%d]:\t%lld\n", i, values[i] );
2605  }
2606  }
2607 #endif
2608 
2609  APIDBG( "PAPI_read_ts returns %d\n", retval );
2610  return PAPI_OK;
2611 }
2612 
2661 int
2662 PAPI_accum( int EventSet, long long *values )
2663 {
2664  EventSetInfo_t *ESI;
2665  hwd_context_t *context;
2666  int i, cidx, retval;
2667  long long a, b, c;
2668 
2669  ESI = _papi_hwi_lookup_EventSet( EventSet );
2670  if ( ESI == NULL )
2672 
2673  cidx = valid_ESI_component( ESI );
2674  if ( cidx < 0 )
2675  papi_return( cidx );
2676 
2677  if ( values == NULL )
2679 
2680  if ( ESI->state & PAPI_RUNNING ) {
2681  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
2682  retval = MPX_read( ESI->multiplex.mpx_evset, ESI->sw_stop, 0 );
2683  } else {
2684  /* get the context we should use for this event set */
2685  context = _papi_hwi_get_context( ESI, NULL );
2686  retval = _papi_hwi_read( context, ESI, ESI->sw_stop );
2687  }
2688  if ( retval != PAPI_OK )
2689  papi_return( retval );
2690  }
2691 
2692  for ( i = 0; i < ESI->NumberOfEvents; i++ ) {
2693  a = ESI->sw_stop[i];
2694  b = values[i];
2695  c = a + b;
2696  values[i] = c;
2697  }
2698 
2699  papi_return( PAPI_reset( EventSet ) );
2700 }
2701 
2728 int
2729 PAPI_write( int EventSet, long long *values )
2730 {
2731  int cidx, retval = PAPI_OK;
2732  EventSetInfo_t *ESI;
2733  hwd_context_t *context;
2734 
2735  APIDBG( "Entry: EventSet: %d\n", EventSet );
2736  ESI = _papi_hwi_lookup_EventSet( EventSet );
2737  if ( ESI == NULL )
2739 
2740  cidx = valid_ESI_component( ESI );
2741  if ( cidx < 0 )
2742  papi_return( cidx );
2743 
2744  if ( values == NULL )
2746 
2747  if ( ESI->state & PAPI_RUNNING ) {
2748  /* get the context we should use for this event set */
2749  context = _papi_hwi_get_context( ESI, NULL );
2750  retval = _papi_hwd[cidx]->write( context, ESI->ctl_state, values );
2751  if ( retval != PAPI_OK )
2752  return ( retval );
2753  }
2754 
2755  memcpy( ESI->hw_start, values,
2756  ( size_t ) _papi_hwd[cidx]->cmp_info.num_cntrs *
2757  sizeof ( long long ) );
2758 
2759  return ( retval );
2760 }
2761 
2804 int
2806 {
2807  EventSetInfo_t *ESI;
2808  int i, cidx, total, retval;
2809 
2810  APIDBG("Attempting to cleanup Eventset %d\n",EventSet);
2811 
2812  /* Is the EventSet already in existence? */
2813 
2814  ESI = _papi_hwi_lookup_EventSet( EventSet );
2815  if ( ESI == NULL )
2817 
2818  /* if the eventset has no index and no events, return OK
2819  otherwise return NOCMP */
2820  cidx = valid_ESI_component( ESI );
2821  if ( cidx < 0 ) {
2822  if ( ESI->NumberOfEvents )
2823  papi_return( cidx );
2824  papi_return( PAPI_OK );
2825  }
2826 
2827  /* Of course, it must be stopped in order to modify it. */
2828 
2829  if ( ESI->state & PAPI_RUNNING )
2831 
2832  /* clear overflow flag and turn off hardware overflow handler */
2833  if ( ESI->state & PAPI_OVERFLOWING ) {
2834  total = ESI->overflow.event_counter;
2835  for ( i = 0; i < total; i++ ) {
2836  retval = PAPI_overflow( EventSet,
2837  ESI->overflow.EventCode[0], 0, 0, NULL );
2838  if ( retval != PAPI_OK )
2839  papi_return( retval );
2840  }
2841  }
2842 
2843  /* clear profile flag and turn off hardware profile handler */
2844  if ( ( ESI->state & PAPI_PROFILING ) &&
2845  _papi_hwd[cidx]->cmp_info.hardware_intr &&
2846  !( ESI->profile.flags & PAPI_PROFIL_FORCE_SW ) ) {
2847  total = ESI->profile.event_counter;
2848  for ( i = 0; i < total; i++ ) {
2849  retval =
2850  PAPI_sprofil( NULL, 0, EventSet, ESI->profile.EventCode[0], 0,
2852  if ( retval != PAPI_OK )
2853  papi_return( retval );
2854  }
2855  }
2856 
2857  if ( _papi_hwi_is_sw_multiplex( ESI ) ) {
2858  retval = MPX_cleanup( &ESI->multiplex.mpx_evset );
2859  if ( retval != PAPI_OK )
2860  papi_return( retval );
2861  }
2862 
2863  retval = _papi_hwd[cidx]->cleanup_eventset( ESI->ctl_state );
2864  if ( retval != PAPI_OK )
2865  papi_return( retval );
2866 
2867  /* Now do the magic */
2869 }
2870 
2896 int
2898 {
2899  int retval;
2900 
2901  retval = mpx_init( _papi_os_info.itimer_ns );
2902  papi_return( retval );
2903 }
2904 
2965 int
2967 {
2968  EventSetInfo_t *ESI;
2969 
2970  if ( status == NULL )
2972 
2973  /* check for good EventSetIndex value */
2974 
2975  ESI = _papi_hwi_lookup_EventSet( EventSet );
2976  if ( ESI == NULL )
2978 
2979  /*read status FROM ESI->state */
2980 
2981  *status = ESI->state;
2982 
2983  return ( PAPI_OK );
2984 }
2985 
3036 int
3037 PAPI_set_debug( int level )
3038 {
3039  PAPI_option_t option;
3040 
3041  memset( &option, 0x0, sizeof ( option ) );
3042  option.debug.level = level;
3044  return ( PAPI_set_opt( PAPI_DEBUG, &option ) );
3045 }
3046 
3047 /* Attaches to or detaches from the specified thread id */
3048 inline_static int
3049 _papi_set_attach( int option, int EventSet, unsigned long tid )
3050 {
3052 
3053  memset( &attach, 0x0, sizeof ( attach ) );
3054  attach.attach.eventset = EventSet;
3055  attach.attach.tid = tid;
3056  return ( PAPI_set_opt( option, &attach ) );
3057 }
3058 
3109 int
3110 PAPI_attach( int EventSet, unsigned long tid )
3111 {
3112  APIDBG( "Entry: EventSet: %d\n", EventSet);
3113  return ( _papi_set_attach( PAPI_ATTACH, EventSet, tid ) );
3114 }
3115 
3166 int
3168 {
3169  return ( _papi_set_attach( PAPI_DETACH, EventSet, 0 ) );
3170 }
3171 
3240 int
3242 {
3243  PAPI_option_t mpx;
3244  EventSetInfo_t *ESI;
3245  int cidx;
3246  int ret;
3247 
3248  /* Is the EventSet already in existence? */
3249 
3250  ESI = _papi_hwi_lookup_EventSet( EventSet );
3251 
3252  if ( ESI == NULL )
3254 
3255  /* if the eventset has no index return NOCMP */
3256  cidx = valid_ESI_component( ESI );
3257  if ( cidx < 0 )
3258  papi_return( cidx );
3259 
3260  if ( ( ret = mpx_check( EventSet ) ) != PAPI_OK )
3261  papi_return( ret );
3262 
3263  memset( &mpx, 0x0, sizeof ( mpx ) );
3264  mpx.multiplex.eventset = EventSet;
3267  return ( PAPI_set_opt( PAPI_MULTIPLEX, &mpx ) );
3268 }
3269 
3370 int
3372 {
3373  APIDBG("Entry: option: %d, ptr: %p\n", option, ptr);
3374 
3375  _papi_int_option_t internal;
3376  int retval = PAPI_OK;
3377  hwd_context_t *context;
3378  int cidx;
3379 
3380  if ( ( option != PAPI_DEBUG ) && ( init_level == PAPI_NOT_INITED ) )
3382  if ( ptr == NULL )
3384 
3385  memset( &internal, 0x0, sizeof ( _papi_int_option_t ) );
3386 
3387  switch ( option ) {
3388  case PAPI_DETACH:
3389  {
3390  internal.attach.ESI = _papi_hwi_lookup_EventSet( ptr->attach.eventset );
3391  if ( internal.attach.ESI == NULL )
3393 
3394  cidx = valid_ESI_component( internal.attach.ESI );
3395  if ( cidx < 0 )
3396  papi_return( cidx );
3397 
3398  if ( _papi_hwd[cidx]->cmp_info.attach == 0 )
3400 
3401  /* if attached to a cpu, return an error */
3402  if (internal.attach.ESI->state & PAPI_CPU_ATTACHED)
3404 
3405  if ( ( internal.attach.ESI->state & PAPI_STOPPED ) == 0 )
3407 
3408  if ( ( internal.attach.ESI->state & PAPI_ATTACHED ) == 0 )
3410 
3411  internal.attach.tid = internal.attach.ESI->attach.tid;
3412  /* get the context we should use for this event set */
3413  context = _papi_hwi_get_context( internal.attach.ESI, NULL );
3414  retval = _papi_hwd[cidx]->ctl( context, PAPI_DETACH, &internal );
3415  if ( retval != PAPI_OK )
3416  papi_return( retval );
3417 
3418  internal.attach.ESI->state ^= PAPI_ATTACHED;
3419  internal.attach.ESI->attach.tid = 0;
3420  return ( PAPI_OK );
3421  }
3422  case PAPI_ATTACH:
3423  {
3424  internal.attach.ESI = _papi_hwi_lookup_EventSet( ptr->attach.eventset );
3425  if ( internal.attach.ESI == NULL )
3427 
3428  cidx = valid_ESI_component( internal.attach.ESI );
3429  if ( cidx < 0 )
3430  papi_return( cidx );
3431 
3432  if ( _papi_hwd[cidx]->cmp_info.attach == 0 )
3434 
3435  if ( ( internal.attach.ESI->state & PAPI_STOPPED ) == 0 )
3437 
3438  if ( internal.attach.ESI->state & PAPI_ATTACHED )
3440 
3441  /* if attached to a cpu, return an error */
3442  if (internal.attach.ESI->state & PAPI_CPU_ATTACHED)
3444 
3445  internal.attach.tid = ptr->attach.tid;
3446  /* get the context we should use for this event set */
3447  context = _papi_hwi_get_context( internal.attach.ESI, NULL );
3448  retval = _papi_hwd[cidx]->ctl( context, PAPI_ATTACH, &internal );
3449  if ( retval != PAPI_OK )
3450  papi_return( retval );
3451 
3452  internal.attach.ESI->state |= PAPI_ATTACHED;
3453  internal.attach.ESI->attach.tid = ptr->attach.tid;
3454 
3456  &(internal.attach.ESI->master), ptr->attach.tid ));
3457  }
3458  case PAPI_CPU_ATTACH:
3459  {
3460  APIDBG("eventset: %d, cpu_num: %d\n", ptr->cpu.eventset, ptr->cpu.cpu_num);
3461  internal.cpu.ESI = _papi_hwi_lookup_EventSet( ptr->cpu.eventset );
3462  if ( internal.cpu.ESI == NULL )
3464 
3465  internal.cpu.cpu_num = ptr->cpu.cpu_num;
3466  APIDBG("internal: %p, ESI: %p, cpu_num: %d\n", &internal, internal.cpu.ESI, internal.cpu.cpu_num);
3467 
3468  cidx = valid_ESI_component( internal.cpu.ESI );
3469  if ( cidx < 0 )
3470  papi_return( cidx );
3471 
3472  if ( _papi_hwd[cidx]->cmp_info.cpu == 0 )
3474 
3475  // can not attach to a cpu if already attached to a process or
3476  // counters set to be inherited by child processes
3477  if ( internal.cpu.ESI->state & (PAPI_ATTACHED | PAPI_INHERIT) )
3479 
3480  if ( ( internal.cpu.ESI->state & PAPI_STOPPED ) == 0 )
3482 
3483  retval = _papi_hwi_lookup_or_create_cpu(&internal.cpu.ESI->CpuInfo, internal.cpu.cpu_num);
3484  if( retval != PAPI_OK) {
3485  papi_return( retval );
3486  }
3487 
3488  /* get the context we should use for this event set */
3489  context = _papi_hwi_get_context( internal.cpu.ESI, NULL );
3490  retval = _papi_hwd[cidx]->ctl( context, PAPI_CPU_ATTACH, &internal );
3491  if ( retval != PAPI_OK )
3492  papi_return( retval );
3493 
3494  /* set to show this event set is attached to a cpu not a thread */
3495  internal.cpu.ESI->state |= PAPI_CPU_ATTACHED;
3496  return ( PAPI_OK );
3497  }
3498  case PAPI_DEF_MPX_NS:
3499  {
3500  cidx = 0; /* xxxx for now, assume we only check against cpu component */
3501  if ( ptr->multiplex.ns < 0 )
3503  /* We should check the resolution here with the system, either
3504  component if kernel multiplexing or PAPI if SW multiplexing. */
3505  internal.multiplex.ns = ( unsigned long ) ptr->multiplex.ns;
3506  /* get the context we should use for this event set */
3507  context = _papi_hwi_get_context( internal.cpu.ESI, NULL );
3508  /* Low level just checks/adjusts the args for this component */
3509  retval = _papi_hwd[cidx]->ctl( context, PAPI_DEF_MPX_NS, &internal );
3510  if ( retval == PAPI_OK ) {
3511  _papi_os_info.itimer_ns = ( int ) internal.multiplex.ns;
3512  ptr->multiplex.ns = ( int ) internal.multiplex.ns;
3513  }
3514  papi_return( retval );
3515  }
3516  case PAPI_DEF_ITIMER_NS:
3517  {
3518  cidx = 0; /* xxxx for now, assume we only check against cpu component */
3519  if ( ptr->itimer.ns < 0 )
3521  internal.itimer.ns = ptr->itimer.ns;
3522  /* Low level just checks/adjusts the args for this component */
3523  retval = _papi_hwd[cidx]->ctl( NULL, PAPI_DEF_ITIMER_NS, &internal );
3524  if ( retval == PAPI_OK ) {
3525  _papi_os_info.itimer_ns = internal.itimer.ns;
3526  ptr->itimer.ns = internal.itimer.ns;
3527  }
3528  papi_return( retval );
3529  }
3530  case PAPI_DEF_ITIMER:
3531  {
3532  cidx = 0; /* xxxx for now, assume we only check against cpu component */
3533  if ( ptr->itimer.ns < 0 )
3535  memcpy( &internal.itimer, &ptr->itimer,
3537  /* Low level just checks/adjusts the args for this component */
3538  retval = _papi_hwd[cidx]->ctl( NULL, PAPI_DEF_ITIMER, &internal );
3539  if ( retval == PAPI_OK ) {
3542  if ( ptr->itimer.ns > 0 )
3544  /* flags are currently ignored, eventually the flags will be able
3545  to specify whether or not we use POSIX itimers (clock_gettimer) */
3546  }
3547  papi_return( retval );
3548  }
3549  case PAPI_MULTIPLEX:
3550  {
3551  EventSetInfo_t *ESI;
3553 
3554  if ( ESI == NULL )
3556 
3557  cidx = valid_ESI_component( ESI );
3558  if ( cidx < 0 )
3559  papi_return( cidx );
3560 
3561  if ( !( ESI->state & PAPI_STOPPED ) )
3563  if ( ESI->state & PAPI_MULTIPLEXING )
3565 
3566  if ( ptr->multiplex.ns < 0 )
3568  internal.multiplex.ESI = ESI;
3569  internal.multiplex.ns = ( unsigned long ) ptr->multiplex.ns;
3570  internal.multiplex.flags = ptr->multiplex.flags;
3571  if ( ( _papi_hwd[cidx]->cmp_info.kernel_multiplex ) &&
3572  ( ( ptr->multiplex.flags & PAPI_MULTIPLEX_FORCE_SW ) == 0 ) ) {
3573  /* get the context we should use for this event set */
3574  context = _papi_hwi_get_context( ESI, NULL );
3575  retval = _papi_hwd[cidx]->ctl( context, PAPI_MULTIPLEX, &internal );
3576  }
3577  /* Kernel or PAPI may have changed this value so send it back out to the user */
3578  ptr->multiplex.ns = ( int ) internal.multiplex.ns;
3579  if ( retval == PAPI_OK )
3581  ( &internal.multiplex ) );
3582  return ( retval );
3583  }
3584  case PAPI_DEBUG:
3585  {
3586  int level = ptr->debug.level;
3587  switch ( level ) {
3588  case PAPI_QUIET:
3589  case PAPI_VERB_ESTOP:
3590  case PAPI_VERB_ECONT:
3591  _papi_hwi_error_level = level;
3592  break;
3593  default:
3595  }
3597  return ( PAPI_OK );
3598  }
3599  case PAPI_DEFDOM:
3600  {
3601  int dom = ptr->defdomain.domain;
3602  if ( ( dom < PAPI_DOM_MIN ) || ( dom > PAPI_DOM_MAX ) )
3604 
3605  /* Change the global structure. The _papi_hwd_init_control_state function
3606  in the components gets information from the global structure instead of
3607  per-thread information. */
3608  cidx = valid_component( ptr->defdomain.def_cidx );
3609  if ( cidx < 0 )
3610  papi_return( cidx );
3611 
3612  /* Check what the component supports */
3613 
3614  if ( dom == PAPI_DOM_ALL )
3615  dom = _papi_hwd[cidx]->cmp_info.available_domains;
3616 
3617  if ( dom & ~_papi_hwd[cidx]->cmp_info.available_domains )
3619 
3620  _papi_hwd[cidx]->cmp_info.default_domain = dom;
3621 
3622  return ( PAPI_OK );
3623  }
3624  case PAPI_DOMAIN:
3625  {
3626  int dom = ptr->domain.domain;
3627  if ( ( dom < PAPI_DOM_MIN ) || ( dom > PAPI_DOM_MAX ) )
3629 
3630  internal.domain.ESI = _papi_hwi_lookup_EventSet( ptr->domain.eventset );
3631  if ( internal.domain.ESI == NULL )
3633 
3634  cidx = valid_ESI_component( internal.domain.ESI );
3635  if ( cidx < 0 )
3636  papi_return( cidx );
3637 
3638  /* Check what the component supports */
3639 
3640  if ( dom == PAPI_DOM_ALL )
3641  dom = _papi_hwd[cidx]->cmp_info.available_domains;
3642 
3643  if ( dom & ~_papi_hwd[cidx]->cmp_info.available_domains )
3645 
3646  if ( !( internal.domain.ESI->state & PAPI_STOPPED ) )
3648 
3649  /* Try to change the domain of the eventset in the hardware */
3650  internal.domain.domain = dom;
3651  internal.domain.eventset = ptr->domain.eventset;
3652  /* get the context we should use for this event set */
3653  context = _papi_hwi_get_context( internal.domain.ESI, NULL );
3654  retval = _papi_hwd[cidx]->ctl( context, PAPI_DOMAIN, &internal );
3655  if ( retval < PAPI_OK )
3656  papi_return( retval );
3657 
3658  /* Change the domain of the eventset in the library */
3659 
3660  internal.domain.ESI->domain.domain = dom;
3661 
3662  return ( retval );
3663  }
3664  case PAPI_DEFGRN:
3665  {
3666  int grn = ptr->defgranularity.granularity;
3667  if ( ( grn < PAPI_GRN_MIN ) || ( grn > PAPI_GRN_MAX ) )
3669 
3670  cidx = valid_component( ptr->defgranularity.def_cidx );
3671  if ( cidx < 0 )
3672  papi_return( cidx );
3673 
3674  /* Change the component structure. The _papi_hwd_init_control_state function
3675  in the components gets information from the global structure instead of
3676  per-thread information. */
3677 
3678  /* Check what the component supports */
3679 
3680  if ( grn & ~_papi_hwd[cidx]->cmp_info.available_granularities )
3682 
3683  /* Make sure there is only 1 set. */
3684  if ( grn ^ ( 1 << ( ffs( grn ) - 1 ) ) )
3686 
3687  _papi_hwd[cidx]->cmp_info.default_granularity = grn;
3688 
3689  return ( PAPI_OK );
3690  }
3691  case PAPI_GRANUL:
3692  {
3693  int grn = ptr->granularity.granularity;
3694 
3695  if ( ( grn < PAPI_GRN_MIN ) || ( grn > PAPI_GRN_MAX ) )
3697 
3698  internal.granularity.ESI =
3700  if ( internal.granularity.ESI == NULL )
3702 
3703  cidx = valid_ESI_component( internal.granularity.ESI );
3704  if ( cidx < 0 )
3705  papi_return( cidx );
3706 
3707  /* Check what the component supports */
3708 
3709  if ( grn & ~_papi_hwd[cidx]->cmp_info.available_granularities )
3711 
3712  /* Make sure there is only 1 set. */
3713  if ( grn ^ ( 1 << ( ffs( grn ) - 1 ) ) )
3715 
3716  internal.granularity.granularity = grn;
3717  internal.granularity.eventset = ptr->granularity.eventset;
3718  retval = _papi_hwd[cidx]->ctl( NULL, PAPI_GRANUL, &internal );
3719  if ( retval < PAPI_OK )
3720  return ( retval );
3721 
3722  internal.granularity.ESI->granularity.granularity = grn;
3723  return ( retval );
3724  }
3725  case PAPI_INHERIT:
3726  {
3727  EventSetInfo_t *ESI;
3729  if ( ESI == NULL )
3731 
3732  cidx = valid_ESI_component( ESI );
3733  if ( cidx < 0 )
3734  papi_return( cidx );
3735 
3736  if ( _papi_hwd[cidx]->cmp_info.inherit == 0 )
3738 
3739  if ( ( ESI->state & PAPI_STOPPED ) == 0 )
3741 
3742  /* if attached to a cpu, return an error */
3743  if (ESI->state & PAPI_CPU_ATTACHED)
3745 
3746  internal.inherit.ESI = ESI;
3747  internal.inherit.inherit = ptr->inherit.inherit;
3748 
3749  /* get the context we should use for this event set */
3750  context = _papi_hwi_get_context( internal.inherit.ESI, NULL );
3751  retval = _papi_hwd[cidx]->ctl( context, PAPI_INHERIT, &internal );
3752  if ( retval < PAPI_OK )
3753  return ( retval );
3754 
3755  ESI->inherit.inherit = ptr->inherit.inherit;
3756  return ( retval );
3757  }
3758  case PAPI_DATA_ADDRESS:
3759  case PAPI_INSTR_ADDRESS:
3760  {
3761 
3762  EventSetInfo_t *ESI;
3763 
3764  ESI = _papi_hwi_lookup_EventSet( ptr->addr.eventset );
3765  if ( ESI == NULL )
3767 
3768  cidx = valid_ESI_component( ESI );
3769  if ( cidx < 0 )
3770  papi_return( cidx );
3771 
3772  internal.address_range.ESI = ESI;
3773 
3774  if ( !( internal.address_range.ESI->state & PAPI_STOPPED ) )
3776 
3777  /*set domain to be PAPI_DOM_USER */
3778  internal.address_range.domain = PAPI_DOM_USER;
3779 
3780  internal.address_range.start = ptr->addr.start;
3781  internal.address_range.end = ptr->addr.end;
3782  /* get the context we should use for this event set */
3783  context = _papi_hwi_get_context( internal.address_range.ESI, NULL );
3784  retval = _papi_hwd[cidx]->ctl( context, option, &internal );
3785  ptr->addr.start_off = internal.address_range.start_off;
3786  ptr->addr.end_off = internal.address_range.end_off;
3787  papi_return( retval );
3788  }
3789  case PAPI_USER_EVENTS_FILE:
3790  {
3791  SUBDBG("Filename is -%s-\n", ptr->events_file);
3793  return( PAPI_OK );
3794  }
3795  default:
3797  }
3798 }
3799 
3809 int
3811 {
3812  return ( PAPI_num_cmp_hwctrs( 0 ) );
3813 }
3814 
3864 int
3866 {
3867  return ( PAPI_get_cmp_opt( PAPI_MAX_HWCTRS, NULL, cidx ) );
3868 }
3869 
3926 int
3928 {
3929  PAPI_option_t popt;
3930  int retval;
3931 
3932  popt.multiplex.eventset = EventSet;
3933  retval = PAPI_get_opt( PAPI_MULTIPLEX, &popt );
3934  if ( retval < 0 )
3935  retval = 0;
3936  return retval;
3937 }
3938 
4040 int
4042 {
4043  EventSetInfo_t *ESI;
4044 
4045  APIDBG( "Entry: option: %d\n", option);
4046  if ( ( option != PAPI_DEBUG ) && ( init_level == PAPI_NOT_INITED ) )
4048 
4049  switch ( option ) {
4050  case PAPI_DETACH:
4051  {
4052  if ( ptr == NULL )
4055  if ( ESI == NULL )
4057  ptr->attach.tid = ESI->attach.tid;
4058  return ( ( ESI->state & PAPI_ATTACHED ) == 0 );
4059  }
4060  case PAPI_ATTACH:
4061  {
4062  if ( ptr == NULL )
4065  if ( ESI == NULL )
4067  ptr->attach.tid = ESI->attach.tid;
4068  return ( ( ESI->state & PAPI_ATTACHED ) != 0 );
4069  }
4070  case PAPI_CPU_ATTACH:
4071  {
4072  if ( ptr == NULL )
4075  if ( ESI == NULL )
4077  ptr->cpu.cpu_num = ESI->CpuInfo->cpu_num;
4078  return ( ( ESI->state & PAPI_CPU_ATTACHED ) != 0 );
4079  }
4080  case PAPI_DEF_MPX_NS:
4081  {
4082  /* xxxx for now, assume we only check against cpu component */
4083  if ( ptr == NULL )
4086  return ( PAPI_OK );
4087  }
4088  case PAPI_DEF_ITIMER_NS:
4089  {
4090  /* xxxx for now, assume we only check against cpu component */
4091  if ( ptr == NULL )
4094  return ( PAPI_OK );
4095  }
4096  case PAPI_DEF_ITIMER:
4097  {
4098  /* xxxx for now, assume we only check against cpu component */
4099  if ( ptr == NULL )
4104  ptr->itimer.flags = 0;
4105  return ( PAPI_OK );
4106  }
4107  case PAPI_MULTIPLEX:
4108  {
4109  if ( ptr == NULL )
4112  if ( ESI == NULL )
4114  ptr->multiplex.ns = ESI->multiplex.ns;
4115  ptr->multiplex.flags = ESI->multiplex.flags;
4116  return ( ESI->state & PAPI_MULTIPLEXING ) != 0;
4117  }
4118  case PAPI_PRELOAD:
4119  if ( ptr == NULL )
4121  memcpy( &ptr->preload, &_papi_hwi_system_info.preload_info,
4123  break;
4124  case PAPI_DEBUG:
4125  if ( ptr == NULL )
4129  break;
4130  case PAPI_CLOCKRATE:
4131  return ( ( int ) _papi_hwi_system_info.hw_info.cpu_max_mhz );
4132  case PAPI_MAX_CPUS:
4133  return ( _papi_hwi_system_info.hw_info.ncpu );
4134  /* For now, MAX_HWCTRS and MAX CTRS are identical.
4135  At some future point, they may map onto different values.
4136  */
4137  case PAPI_INHERIT:
4138  {
4139  if ( ptr == NULL )
4142  if ( ESI == NULL )
4144  ptr->inherit.inherit = ESI->inherit.inherit;
4145  return ( PAPI_OK );
4146  }
4147  case PAPI_GRANUL:
4148  if ( ptr == NULL )
4151  if ( ESI == NULL )
4154  break;
4155  case PAPI_EXEINFO:
4156  if ( ptr == NULL )
4159  break;
4160  case PAPI_HWINFO:
4161  if ( ptr == NULL )
4164  break;
4165 
4166  case PAPI_DOMAIN:
4167  if ( ptr == NULL )
4170  if ( ESI == NULL )
4172  ptr->domain.domain = ESI->domain.domain;
4173  return ( PAPI_OK );
4174  case PAPI_LIB_VERSION:
4175  return ( PAPI_VERSION );
4176 /* The following cases all require a component index
4177  and are handled by PAPI_get_cmp_opt() with cidx == 0*/
4178  case PAPI_MAX_HWCTRS:
4179  case PAPI_MAX_MPX_CTRS:
4180  case PAPI_DEFDOM:
4181  case PAPI_DEFGRN:
4182  case PAPI_SHLIBINFO:
4183  case PAPI_COMPONENTINFO:
4184  return ( PAPI_get_cmp_opt( option, ptr, 0 ) );
4185  default:
4187  }
4188  return ( PAPI_OK );
4189 }
4190 
4232 int
4234 {
4235 
4236  APIDBG( "Entry: option: %d, cidx: %d\n", option, cidx);
4237  if (_papi_hwi_invalid_cmp(cidx)) {
4238  return PAPI_ECMP;
4239  }
4240 
4241  switch ( option ) {
4242  /* For now, MAX_HWCTRS and MAX CTRS are identical.
4243  At some future point, they may map onto different values.
4244  */
4245  case PAPI_MAX_HWCTRS:
4246  return ( _papi_hwd[cidx]->cmp_info.num_cntrs );
4247  case PAPI_MAX_MPX_CTRS:
4248  return ( _papi_hwd[cidx]->cmp_info.num_mpx_cntrs );
4249  case PAPI_DEFDOM:
4250  return ( _papi_hwd[cidx]->cmp_info.default_domain );
4251  case PAPI_DEFGRN:
4252  return ( _papi_hwd[cidx]->cmp_info.default_granularity );
4253  case PAPI_SHLIBINFO:
4254  {
4255  int retval;
4256  if ( ptr == NULL )
4260  papi_return( retval );
4261  }
4262  case PAPI_COMPONENTINFO:
4263  if ( ptr == NULL )
4265  ptr->cmp_info = &( _papi_hwd[cidx]->cmp_info );
4266  return PAPI_OK;
4267  default:
4269  }
4270  return PAPI_OK;
4271 }
4272 
4284 int
4286 {
4287  return ( papi_num_components );
4288 }
4289 
4322 int
4324 {
4325  EventSetInfo_t *ESI;
4326 
4327  ESI = _papi_hwi_lookup_EventSet( EventSet );
4328  if ( !ESI )
4330 
4331 #ifdef DEBUG
4332  /* Not necessary */
4333  if ( ESI->NumberOfEvents == 0 )
4335 #endif
4336 
4337  return ( ESI->NumberOfEvents );
4338 }
4339 
4340 
4356 void
4358 {
4359  APIDBG( "Enter\n" );
4360  EventSetInfo_t *ESI;
4361  ThreadInfo_t *master;
4363  int i, j = 0, retval;
4364 
4365 
4366  if ( init_retval == DEADBEEF ) {
4368  return;
4369  }
4370 
4371  MPX_shutdown( );
4372 
4373  /* Free all EventSets for this thread */
4374 
4375  master = _papi_hwi_lookup_thread( 0 );
4376 
4377  /* Count number of running EventSets AND */
4378  /* Stop any running EventSets in this thread */
4379 
4380 #ifdef DEBUG
4381 again:
4382 #endif
4383  for( i = 0; i < map->totalSlots; i++ ) {
4384  ESI = map->dataSlotArray[i];
4385  if ( ESI ) {
4386  if ( ESI->master == master ) {
4387  if ( ESI->state & PAPI_RUNNING ) {
4388  retval=PAPI_stop( i, NULL );
4389  }
4391  if (retval!=PAPI_OK) PAPIERROR("Error during cleanup.\n");
4392  _papi_hwi_free_EventSet( ESI );
4393  }
4394  else {
4395  if ( ESI->state & PAPI_RUNNING ) {
4396  j++;
4397  }
4398  }
4399  }
4400  }
4401 
4402  /* No locking required, we're just waiting for the others
4403  to call shutdown or stop their eventsets. */
4404 
4405 #ifdef DEBUG
4406  if ( j != 0 ) {
4408  sleep( 1 );
4409  j = 0;
4410  goto again;
4411  }
4412 #endif
4413 
4414  /* Shutdown the entire component */
4415 
4417 
4421  for( i = 0; i < papi_num_components; i++ ) {
4422  if (!_papi_hwd[i]->cmp_info.disabled) {
4423  _papi_hwd[i]->shutdown_component( );
4424  }
4425  }
4426 
4427  /* Now it is safe to call re-init */
4428 
4432 }
4433 
4482 char *
4483 PAPI_strerror( int errorCode )
4484 {
4485  if ( ( errorCode > 0 ) || ( -errorCode > _papi_hwi_num_errors ) )
4486  return ( NULL );
4487 
4488  return ( _papi_errlist[-errorCode] );
4489 }
4490 
4532 void
4533 PAPI_perror( char *msg )
4534 {
4535  char *foo;
4536 
4537  foo = PAPI_strerror( _papi_hwi_errno );
4538  if ( foo == NULL )
4539  return;
4540 
4541  if ( msg )
4542  if ( *msg )
4543  fprintf( stderr, "%s: ", msg );
4544 
4545  fprintf( stderr, "%s\n", foo );
4546 }
4547 
4667 int
4668 PAPI_overflow( int EventSet, int EventCode, int threshold, int flags,
4670 {
4671  int retval, cidx, index, i;
4672  EventSetInfo_t *ESI;
4673 
4674  ESI = _papi_hwi_lookup_EventSet( EventSet );
4675  if ( ESI == NULL ) {
4676  OVFDBG("No EventSet\n");
4678  }
4679 
4680  cidx = valid_ESI_component( ESI );
4681  if ( cidx < 0 ) {
4682  OVFDBG("Component Error\n");
4683  papi_return( cidx );
4684  }
4685 
4686  if ( ( ESI->state & PAPI_STOPPED ) != PAPI_STOPPED ) {
4687  OVFDBG("Already running\n");
4689  }
4690 
4691  if ( ESI->state & PAPI_ATTACHED ) {
4692  OVFDBG("Attached\n");
4694  }
4695 
4696  if ( ESI->state & PAPI_CPU_ATTACHED ) {
4697  OVFDBG("CPU attached\n");
4699  }
4700 
4701  if ( ( index = _papi_hwi_lookup_EventCodeIndex( ESI,
4702  ( unsigned int ) EventCode ) ) < 0 ) {
4704  }
4705 
4706  if ( threshold < 0 ) {
4707  OVFDBG("Threshold below zero\n");
4709  }
4710 
4711  /* We do not support derived events in overflow */
4712  /* Unless it's DERIVED_CMPD in which no calculations are done */
4713 
4714  if ( !( flags & PAPI_OVERFLOW_FORCE_SW ) && threshold != 0 &&
4715  ( ESI->EventInfoArray[index].derived ) &&
4716  ( ESI->EventInfoArray[index].derived != DERIVED_CMPD ) ) {
4717  OVFDBG("Derived event in overflow\n");
4719  }
4720 
4721  /* the first time to call PAPI_overflow function */
4722 
4723  if ( !( ESI->state & PAPI_OVERFLOWING ) ) {
4724  if ( handler == NULL ) {
4725  OVFDBG("NULL handler\n");
4727  }
4728  if ( threshold == 0 ) {
4729  OVFDBG("Zero threshold\n");
4731  }
4732  }
4733  if ( threshold > 0 &&
4734  ESI->overflow.event_counter >= _papi_hwd[cidx]->cmp_info.num_cntrs )
4736 
4737  if ( threshold == 0 ) {
4738  for ( i = 0; i < ESI->overflow.event_counter; i++ ) {
4739  if ( ESI->overflow.EventCode[i] == EventCode )
4740  break;
4741  }
4742  /* EventCode not found */
4743  if ( i == ESI->overflow.event_counter )
4745  /* compact these arrays */
4746  while ( i < ESI->overflow.event_counter - 1 ) {
4747  ESI->overflow.deadline[i] = ESI->overflow.deadline[i + 1];
4748  ESI->overflow.threshold[i] = ESI->overflow.threshold[i + 1];
4749  ESI->overflow.EventIndex[i] = ESI->overflow.EventIndex[i + 1];
4750  ESI->overflow.EventCode[i] = ESI->overflow.EventCode[i + 1];
4751  i++;
4752  }
4753  ESI->overflow.deadline[i] = 0;
4754  ESI->overflow.threshold[i] = 0;
4755  ESI->overflow.EventIndex[i] = 0;
4756  ESI->overflow.EventCode[i] = 0;
4757  ESI->overflow.event_counter--;
4758  } else {
4759  if ( ESI->overflow.event_counter > 0 ) {
4760  if ( ( flags & PAPI_OVERFLOW_FORCE_SW ) &&
4763  if ( !( flags & PAPI_OVERFLOW_FORCE_SW ) &&
4764  ( ESI->overflow.flags & PAPI_OVERFLOW_FORCE_SW ) )
4766  }
4767  for ( i = 0; i < ESI->overflow.event_counter; i++ ) {
4768  if ( ESI->overflow.EventCode[i] == EventCode )
4769  break;
4770  }
4771  /* A new entry */
4772  if ( i == ESI->overflow.event_counter ) {
4773  ESI->overflow.EventCode[i] = EventCode;
4774  ESI->overflow.event_counter++;
4775  }
4776  /* New or existing entry */
4777  ESI->overflow.deadline[i] = threshold;
4778  ESI->overflow.threshold[i] = threshold;
4779  ESI->overflow.EventIndex[i] = index;
4780  ESI->overflow.flags = flags;
4781 
4782  }
4783 
4784  /* If overflowing is already active, we should check to
4785  make sure that we don't specify a different handler
4786  or different flags here. You can't mix them. */
4787 
4788  ESI->overflow.handler = handler;
4789 
4790  /* Set up the option structure for the low level.
4791  If we have hardware interrupts and we are not using
4792  forced software emulated interrupts */
4793 
4794  if ( _papi_hwd[cidx]->cmp_info.hardware_intr &&
4795  !( ESI->overflow.flags & PAPI_OVERFLOW_FORCE_SW ) ) {
4796  retval = _papi_hwd[cidx]->set_overflow( ESI, index, threshold );
4797  if ( retval == PAPI_OK )
4799  else {
4800  papi_return( retval ); /* We should undo stuff here */
4801  }
4802  } else {
4803  /* Make sure hardware overflow is not set */
4804  ESI->overflow.flags &= ~( PAPI_OVERFLOW_HARDWARE );
4805  }
4806 
4807  APIDBG( "Overflow using: %s\n",
4808  ( ESI->overflow.
4809  flags & PAPI_OVERFLOW_HARDWARE ? "[Hardware]" : ESI->overflow.
4810  flags & PAPI_OVERFLOW_FORCE_SW ? "[Forced Software]" :
4811  "[Software]" ) );
4812 
4813  /* Toggle the overflow flags and ESI state */
4814 
4815  if ( ESI->overflow.event_counter >= 1 )
4816  ESI->state |= PAPI_OVERFLOWING;
4817  else {
4818  ESI->state ^= PAPI_OVERFLOWING;
4819  ESI->overflow.flags = 0;
4820  ESI->overflow.handler = NULL;
4821  }
4822 
4823  return PAPI_OK;
4824 }
4825 
4922 int
4923 PAPI_sprofil( PAPI_sprofil_t *prof, int profcnt, int EventSet,
4924  int EventCode, int threshold, int flags )
4925 {
4926  EventSetInfo_t *ESI;
4927  int retval, index, i, buckets;
4928  int forceSW = 0;
4929  int cidx;
4930 
4931  /* Check to make sure EventSet exists */
4932  ESI = _papi_hwi_lookup_EventSet( EventSet );
4933  if ( ESI == NULL ) {
4935  }
4936 
4937  /* Check to make sure EventSet is stopped */
4938  if ( ( ESI->state & PAPI_STOPPED ) != PAPI_STOPPED ) {
4940  }
4941 
4942  /* We cannot profile if attached */
4943  if ( ESI->state & PAPI_ATTACHED ) {
4945  }
4946 
4947  /* We cannot profile if cpu attached */
4948  if ( ESI->state & PAPI_CPU_ATTACHED ) {
4950  }
4951 
4952  /* Get component for EventSet */
4953  cidx = valid_ESI_component( ESI );
4954  if ( cidx < 0 ) {
4955  papi_return( cidx );
4956  }
4957 
4958  /* Get index of the Event we want to profile */
4959  if ( ( index = _papi_hwi_lookup_EventCodeIndex( ESI,
4960  (unsigned int) EventCode ) ) < 0 ) {
4962  }
4963 
4964  /* We do not support derived events in overflow */
4965  /* Unless it's DERIVED_CMPD in which no calculations are done */
4966  if ( ( ESI->EventInfoArray[index].derived ) &&
4967  ( ESI->EventInfoArray[index].derived != DERIVED_CMPD ) &&
4968  !( flags & PAPI_PROFIL_FORCE_SW ) ) {
4970  }
4971 
4972  /* If no prof structures, then make sure count is 0 */
4973  if ( prof == NULL ) {
4974  profcnt = 0;
4975  }
4976 
4977  /* check all profile regions for valid scale factors of:
4978  2 (131072/65536),
4979  1 (65536/65536),
4980  or < 1 (65535 -> 2) as defined in unix profil()
4981  2/65536 is reserved for single bucket profiling
4982  {0,1}/65536 are traditionally used to terminate profiling
4983  but are unused here since PAPI uses threshold instead
4984  */
4985  for( i = 0; i < profcnt; i++ ) {
4986  if ( !( ( prof[i].pr_scale == 131072 ) ||
4987  ( ( prof[i].pr_scale <= 65536 && prof[i].pr_scale > 1 ) ) ) ) {
4988  APIDBG( "Improper scale factor: %d\n", prof[i].pr_scale );
4990  }
4991  }
4992 
4993  /* Make sure threshold is valid */
4994  if ( threshold < 0 ) {
4996  }
4997 
4998  /* the first time to call PAPI_sprofil */
4999  if ( !( ESI->state & PAPI_PROFILING ) ) {
5000  if ( threshold == 0 ) {
5002  }
5003  }
5004 
5005  /* ??? */
5006  if ( (threshold > 0) &&
5007  (ESI->profile.event_counter >= _papi_hwd[cidx]->cmp_info.num_cntrs) ) {
5009  }
5010 
5011  if ( threshold == 0 ) {
5012  for( i = 0; i < ESI->profile.event_counter; i++ ) {
5013  if ( ESI->profile.EventCode[i] == EventCode ) {
5014  break;
5015  }
5016  }
5017 
5018  /* EventCode not found */
5019  if ( i == ESI->profile.event_counter ) {
5021  }
5022 
5023  /* compact these arrays */
5024  while ( i < ESI->profile.event_counter - 1 ) {
5025  ESI->profile.prof[i] = ESI->profile.prof[i + 1];
5026  ESI->profile.count[i] = ESI->profile.count[i + 1];
5027  ESI->profile.threshold[i] = ESI->profile.threshold[i + 1];
5028  ESI->profile.EventIndex[i] = ESI->profile.EventIndex[i + 1];
5029  ESI->profile.EventCode[i] = ESI->profile.EventCode[i + 1];
5030  i++;
5031  }
5032  ESI->profile.prof[i] = NULL;
5033  ESI->profile.count[i] = 0;
5034  ESI->profile.threshold[i] = 0;
5035  ESI->profile.EventIndex[i] = 0;
5036  ESI->profile.EventCode[i] = 0;
5037  ESI->profile.event_counter--;
5038  } else {
5039  if ( ESI->profile.event_counter > 0 ) {
5040  if ( ( flags & PAPI_PROFIL_FORCE_SW ) &&
5041  !( ESI->profile.flags & PAPI_PROFIL_FORCE_SW ) ) {
5043  }
5044  if ( !( flags & PAPI_PROFIL_FORCE_SW ) &&
5045  ( ESI->profile.flags & PAPI_PROFIL_FORCE_SW ) ) {
5047  }
5048  }
5049 
5050  for( i = 0; i < ESI->profile.event_counter; i++ ) {
5051  if ( ESI->profile.EventCode[i] == EventCode ) {
5052  break;
5053  }
5054  }
5055 
5056  if ( i == ESI->profile.event_counter ) {
5057  i = ESI->profile.event_counter;
5058  ESI->profile.event_counter++;
5059  ESI->profile.EventCode[i] = EventCode;
5060  }
5061  ESI->profile.prof[i] = prof;
5062  ESI->profile.count[i] = profcnt;
5063  ESI->profile.threshold[i] = threshold;
5064  ESI->profile.EventIndex[i] = index;
5065  }
5066 
5067  APIDBG( "Profile event counter is %d\n", ESI->profile.event_counter );
5068 
5069  /* Clear out old flags */
5070  if ( threshold == 0 ) {
5071  flags |= ESI->profile.flags;
5072  }
5073 
5074  /* make sure no invalid flags are set */
5075  if ( flags &
5077  PAPI_PROFIL_COMPRESS | PAPI_PROFIL_BUCKETS | PAPI_PROFIL_FORCE_SW |
5080  }
5081 
5082  /* if we have kernel-based profiling, then we're just asking for
5083  signals on interrupt. */
5084  /* if we don't have kernel-based profiling, then we're asking for
5085  emulated PMU interrupt */
5086  if ( ( flags & PAPI_PROFIL_FORCE_SW ) &&
5087  ( _papi_hwd[cidx]->cmp_info.kernel_profile == 0 ) ) {
5088  forceSW = PAPI_OVERFLOW_FORCE_SW;
5089  }
5090 
5091  /* make sure one and only one bucket size is set */
5092  buckets = flags & PAPI_PROFIL_BUCKETS;
5093  if ( !buckets ) {
5094  flags |= PAPI_PROFIL_BUCKET_16; /* default to 16 bit if nothing set */
5095  }
5096  else {
5097  /* return error if more than one set */
5098  if ( !( ( buckets == PAPI_PROFIL_BUCKET_16 ) ||
5099  ( buckets == PAPI_PROFIL_BUCKET_32 ) ||
5100  ( buckets == PAPI_PROFIL_BUCKET_64 ) ) ) {
5102  }
5103  }
5104 
5105  /* Set up the option structure for the low level */
5106  ESI->profile.flags = flags;
5107 
5108  if ( _papi_hwd[cidx]->cmp_info.kernel_profile &&
5109  !( ESI->profile.flags & PAPI_PROFIL_FORCE_SW ) ) {
5110  retval = _papi_hwd[cidx]->set_profile( ESI, index, threshold );
5111  if ( ( retval == PAPI_OK ) && ( threshold > 0 ) ) {
5112  /* We need overflowing because we use the overflow dispatch handler */
5113  ESI->state |= PAPI_OVERFLOWING;
5115  }
5116  } else {
5117  retval = PAPI_overflow( EventSet, EventCode, threshold, forceSW,
5119  }
5120 
5121  if ( retval < PAPI_OK ) {
5122  papi_return( retval ); /* We should undo stuff here */
5123  }
5124 
5125  /* Toggle the profiling flags and ESI state */
5126 
5127  if ( ESI->profile.event_counter >= 1 ) {
5128  ESI->state |= PAPI_PROFILING;
5129  }
5130  else {
5131  ESI->state ^= PAPI_PROFILING;
5132  ESI->profile.flags = 0;
5133  }
5134 
5135  return PAPI_OK;
5136 }
5137 
5315 int
5316 PAPI_profil( void *buf, unsigned bufsiz, caddr_t offset,
5317  unsigned scale, int EventSet, int EventCode, int threshold,
5318  int flags )
5319 {
5320  EventSetInfo_t *ESI;
5321  int i;
5322  int retval;
5323 
5324  ESI = _papi_hwi_lookup_EventSet( EventSet );
5325  if ( ESI == NULL )
5327 
5328  /* scale factors are checked for validity in PAPI_sprofil */
5329 
5330  if ( threshold > 0 ) {
5331  PAPI_sprofil_t *prof;
5332 
5333  for ( i = 0; i < ESI->profile.event_counter; i++ ) {
5334  if ( ESI->profile.EventCode[i] == EventCode )
5335  break;
5336  }
5337 
5338  if ( i == ESI->profile.event_counter ) {
5339  prof =
5340  ( PAPI_sprofil_t * ) papi_malloc( sizeof ( PAPI_sprofil_t ) );
5341  memset( prof, 0x0, sizeof ( PAPI_sprofil_t ) );
5342  prof->pr_base = buf;
5343  prof->pr_size = bufsiz;
5344  prof->pr_off = offset;
5345  prof->pr_scale = scale;
5346 
5347  retval =
5348  PAPI_sprofil( prof, 1, EventSet, EventCode, threshold, flags );
5349 
5350  if ( retval != PAPI_OK )
5351  papi_free( prof );
5352  } else {
5353  prof = ESI->profile.prof[i];
5354  prof->pr_base = buf;
5355  prof->pr_size = bufsiz;
5356  prof->pr_off = offset;
5357  prof->pr_scale = scale;
5358  retval =
5359  PAPI_sprofil( prof, 1, EventSet, EventCode, threshold, flags );
5360  }
5361  papi_return( retval );
5362  }
5363 
5364  for ( i = 0; i < ESI->profile.event_counter; i++ ) {
5365  if ( ESI->profile.EventCode[i] == EventCode )
5366  break;
5367  }
5368  /* EventCode not found */
5369  if ( i == ESI->profile.event_counter )
5371 
5372  papi_free( ESI->profile.prof[i] );
5373  ESI->profile.prof[i] = NULL;
5374 
5375  papi_return( PAPI_sprofil( NULL, 0, EventSet, EventCode, 0, flags ) );
5376 }
5377 
5378 /* This function sets the low level default granularity
5379  for all newly manufactured eventsets. The first function
5380  preserves API compatibility and assumes component 0;
5381  The second function takes a component argument. */
5382 
5433 int
5434 PAPI_set_granularity( int granularity )
5435 {
5436  return ( PAPI_set_cmp_granularity( granularity, 0 ) );
5437 }
5438 
5498 int
5499 PAPI_set_cmp_granularity( int granularity, int cidx )
5500 {
5502 
5503  memset( &ptr, 0, sizeof ( ptr ) );
5505  ptr.defgranularity.granularity = granularity;
5506  papi_return( PAPI_set_opt( PAPI_DEFGRN, &ptr ) );
5507 }
5508 
5509 /* This function sets the low level default counting domain
5510  for all newly manufactured eventsets. The first function
5511  preserves API compatibility and assumes component 0;
5512  The second function takes a component argument. */
5513 
5564 int
5565 PAPI_set_domain( int domain )
5566 {
5567  return ( PAPI_set_cmp_domain( domain, 0 ) );
5568 }
5569 
5634 int
5635 PAPI_set_cmp_domain( int domain, int cidx )
5636 {
5638 
5639  memset( &ptr, 0, sizeof ( ptr ) );
5640  ptr.defdomain.def_cidx = cidx;
5641  ptr.defdomain.domain = domain;
5642  papi_return( PAPI_set_opt( PAPI_DEFDOM, &ptr ) );
5643 }
5644 
5719 int
5720 PAPI_add_events( int EventSet, int *Events, int number )
5721 {
5722  int i, retval;
5723 
5724  if ( ( Events == NULL ) || ( number <= 0 ) )
5726 
5727  for ( i = 0; i < number; i++ ) {
5728  retval = PAPI_add_event( EventSet, Events[i] );
5729  if ( retval != PAPI_OK ) {
5730  if ( i == 0 )
5731  papi_return( retval );
5732  else
5733  return ( i );
5734  }
5735  }
5736  return ( PAPI_OK );
5737 }
5738 
5806 int
5807 PAPI_remove_events( int EventSet, int *Events, int number )
5808 {
5809  int i, retval;
5810 
5811  if ( ( Events == NULL ) || ( number <= 0 ) )
5813 
5814  for ( i = 0; i < number; i++ ) {
5815  retval = PAPI_remove_event( EventSet, Events[i] );
5816  if ( retval != PAPI_OK ) {
5817  if ( i == 0 )
5818  papi_return( retval );
5819  else
5820  return ( i );
5821  }
5822  }
5823  return ( PAPI_OK );
5824 }
5825 
5875 int
5876 PAPI_list_events( int EventSet, int *Events, int *number )
5877 {
5878  EventSetInfo_t *ESI;
5879  int i, j;
5880 
5881  if ( *number < 0 )
5883 
5884  if ( ( Events == NULL ) && ( *number > 0 ) )
5886 
5887  ESI = _papi_hwi_lookup_EventSet( EventSet );
5888  if ( !ESI )
5890 
5891  if ( ( Events == NULL ) || ( *number == 0 ) ) {
5892  *number = ESI->NumberOfEvents;
5893  papi_return( PAPI_OK );
5894  }
5895 
5896  for ( i = 0, j = 0; j < ESI->NumberOfEvents; i++ ) {
5897  if ( ( int ) ESI->EventInfoArray[i].event_code != PAPI_NULL ) {
5898  Events[j] = ( int ) ESI->EventInfoArray[i].event_code;
5899  j++;
5900  if ( j == *number )
5901  break;
5902  }
5903  }
5904 
5905  *number = j;
5906 
5907  return ( PAPI_OK );
5908 }
5909 
5910 /* xxx This is OS dependent, not component dependent, right? */
5936 int
5938 {
5939  if ( dest == NULL )
5940  return PAPI_EINVAL;
5941 
5942  memset( ( void * ) dest, 0x0, sizeof ( PAPI_dmem_info_t ) );
5943  return ( _papi_os_vector.get_dmem_info( dest ) );
5944 }
5945 
5946 
5987 const PAPI_exe_info_t *
5989 {
5991  int retval;
5992 
5993  memset( &ptr, 0, sizeof ( ptr ) );
5994  retval = PAPI_get_opt( PAPI_EXEINFO, &ptr );
5995  if ( retval == PAPI_OK )
5996  return ( ptr.exe_info );
5997  else
5998  return ( NULL );
5999 }
6000 
6017 const PAPI_shlib_info_t *
6019 {
6021  int retval;
6022 
6023  memset( &ptr, 0, sizeof ( ptr ) );
6024  retval = PAPI_get_opt( PAPI_SHLIBINFO, &ptr );
6025  if ( retval == PAPI_OK )
6026  return ( ptr.shlib_info );
6027  else
6028  return ( NULL );
6029 }
6058 const PAPI_hw_info_t *
6060 {
6062  int retval;
6063 
6064  memset( &ptr, 0, sizeof ( ptr ) );
6065  retval = PAPI_get_opt( PAPI_HWINFO, &ptr );
6066  if ( retval == PAPI_OK )
6067  return ( ptr.hw_info );
6068  else
6069  return ( NULL );
6070 }
6071 
6072 
6073 /* The next 4 timing functions always use component 0 */
6074 
6090 long long
6092 {
6093  return ( _papi_os_vector.get_real_cycles( ) );
6094 }
6095 
6109 /* FIXME */
6110 long long
6112 {
6113  return ( ( _papi_os_vector.get_real_nsec( )));
6114 
6115 }
6116 
6137 long long
6139 {
6140  return ( _papi_os_vector.get_real_usec( ) );
6141 }
6142 
6173 long long
6175 {
6176 
6177  return ( ( long long ) _papi_os_vector.get_virt_cycles( ) );
6178 }
6179 
6203 long long
6205 {
6206 
6207  return ( ( _papi_os_vector.get_virt_nsec()));
6208 
6209 }
6210 
6245 long long
6247 {
6248 
6249  return ( ( long long ) _papi_os_vector.get_virt_usec() );
6250 }
6251 
6274 int
6275 PAPI_lock( int lck )
6276 {
6277  if ( ( lck < 0 ) || ( lck >= PAPI_NUM_LOCK ) )
6279 
6280  papi_return( _papi_hwi_lock( lck ) );
6281 }
6282 
6294 int
6295 PAPI_unlock( int lck )
6296 {
6297  if ( ( lck < 0 ) || ( lck >= PAPI_NUM_LOCK ) )
6299 
6300  papi_return( _papi_hwi_unlock( lck ) );
6301 }
6302 
6336 int
6338 {
6339  return ( init_level );
6340 }
6341 
6342 /* This function maps the overflow_vector to event indexes in the event
6343  set, so that user can know which PAPI event overflowed.
6344  int *array---- an array of event indexes in eventset; the first index
6345  maps to the highest set bit in overflow_vector
6346  int *number--- this is an input/output parameter, user should put the
6347  size of the array into this parameter, after the function
6348  is executed, the number of indexes in *array is written
6349  to this parameter
6350 */
6351 
6390 int
6391 PAPI_get_overflow_event_index( int EventSet, long long overflow_vector,
6392  int *array, int *number )
6393 {
6394  EventSetInfo_t *ESI;
6395  int set_bit, j, pos;
6396  int count = 0, k;
6397 
6398  if ( overflow_vector == ( long long ) 0 )
6400 
6401  if ( ( array == NULL ) || ( number == NULL ) )
6403 
6404  if ( *number < 1 )
6406 
6407  ESI = _papi_hwi_lookup_EventSet( EventSet );
6408  if ( ESI == NULL )
6410 
6411  /* in case the eventset is empty */
6412  if ( ESI->NumberOfEvents == 0 )
6414 
6415  while ( ( set_bit = ffsll( overflow_vector ) ) ) {
6416  set_bit -= 1;
6417  overflow_vector ^= ( long long ) 1 << set_bit;
6418  for ( j = 0; j < ESI->NumberOfEvents; j++ ) {
6419  for ( k = 0, pos = 0; k < PAPI_EVENTS_IN_DERIVED_EVENT && pos >= 0; k++ ) {
6420  pos = ESI->EventInfoArray[j].pos[k];
6421  if ( ( set_bit == pos ) &&
6422  ( ( ESI->EventInfoArray[j].derived == NOT_DERIVED ) ||
6423  ( ESI->EventInfoArray[j].derived == DERIVED_CMPD ) ) ) {
6424  array[count++] = j;
6425  if ( count == *number )
6426  return PAPI_OK;
6427 
6428  break;
6429  }
6430  }
6431  }
6432  }
6433  *number = count;
6434  return PAPI_OK;
6435 }
6436 
6437 
6455 int
6457 {
6458  APIDBG( "Entry: EventCode: %#x\n", EventCode);
6459  return _papi_hwi_component_index( EventCode);
6460 }
6461 
6484 {
6485  int cidx;
6486 
6487  const PAPI_component_info_t *cinfo;
6488 
6489  APIDBG( "Entry:\n" );
6490  for(cidx=0;cidx<papi_num_components;cidx++) {
6491 
6492  cinfo=PAPI_get_component_info(cidx);
6493  if (cinfo==NULL) return PAPI_ENOCMP;
6494 
6495  if (!strcmp(name,cinfo->name)) {
6496  return cidx;
6497  }
6498  }
6499 
6500  return PAPI_ENOCMP;
6501 }
6502 
6503 
6538 int
6540 {
6541 
6542  const PAPI_component_info_t *cinfo;
6543 
6544  /* Can only run before PAPI_library_init() is called */
6545  if (init_level != PAPI_NOT_INITED) {
6546  return PAPI_ENOINIT;
6547  }
6548 
6549  cinfo=PAPI_get_component_info(cidx);
6550  if (cinfo==NULL) return PAPI_ENOCMP;
6551 
6552  ((PAPI_component_info_t *)cinfo)->disabled=1;
6553  strcpy(((PAPI_component_info_t *)cinfo)->disabled_reason,
6554  "Disabled by PAPI_disable_component()");
6555 
6556  return PAPI_OK;
6557 
6558 }
6559 
6588 int
6590 {
6591  int cidx;
6592 
6593  /* I can only be called before init time */
6594  if (init_level!=PAPI_NOT_INITED) {
6595  return PAPI_ENOINIT;
6596  }
6597 
6598  cidx = PAPI_get_component_index(name);
6599  if (cidx>=0) {
6600  return PAPI_disable_component(cidx);
6601  }
6602 
6603  return PAPI_ENOCMP;
6604 }
#define PAPI_NUM_LOCK
Definition: papi.h:333
int _papi_hwi_is_sw_multiplex(EventSetInfo_t *ESI)
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:625
i inherit inherit
#define PAPI_HUGE_STR_LEN
Definition: fpapi.h:42
#define PAPI_PROFIL_WEIGHTED
Definition: fpapi.h:77
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
memset(eventId, 0, size)
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
int PAPI_is_initialized(void)
Definition: papi.c:6337
int _papi_hwi_convert_eventset_to_multiplex(_papi_int_multiplex_t *mpx)
#define PAPI_EINVAL_DOM
Definition: fpapi.h:126
#define PAPI_NATIVE_MASK
#define DEBUG_MULTIPLEX
Definition: papi_debug.h:31
int _papi_hwi_init_global_internal(void)
#define IS_PRESET(EventCode)
Definition: papi.h:227
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:805
#define PAPI_EMISC
Definition: fpapi.h:119
#define DEBUG_PROFILE
Definition: papi_debug.h:33
#define PAPI_CPU_ATTACH
Definition: papi.h:455
char * getenv()
long long(* get_real_nsec)(void)
Definition: papi_vector.h:65
sleep(1)
#define PAPI_PRELOAD
Definition: fpapi.h:56
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1604
void PAPI_perror(char *msg)
Definition: papi.c:4533
Hardware info structure.
Definition: papi.h:775
inline_static int _papi_set_attach(int option, int EventSet, unsigned long tid)
Definition: papi.c:3049
long long PAPI_get_virt_usec(void)
Definition: papi.c:6246
int PAPI_set_cmp_granularity(int granularity, int cidx)
Definition: papi.c:5499
int PAPI_reset(int EventSet)
Definition: papi.c:2377
#define PAPI_SHUTDOWN_str
Definition: papi_internal.h:42
long long flags
Definition: iozone.c:12330
#define PAPI_DEF_ITIMER_NS
Definition: papi.h:453
#define PAPI_NULL
Definition: fpapi.h:13
int PAPI_add_named_event(int EventSet, char *EventName)
Definition: papi.c:1816
int _papi_hwi_set_thread_id_fn(unsigned long(*id_fn)(void))
Definition: threads.c:352
#define IS_USER_DEFINED(EventCode)
Definition: papi.h:228
const PAPI_shlib_info_t * PAPI_get_shared_lib_info(void)
Definition: papi.c:6018
#define papi_free(a)
Definition: papi_memory.h:35
#define PAPI_INSTR_ADDRESS
Definition: papi.h:451
void ** data
Definition: papi.h:560
int _papi_hwi_query_native_event(unsigned int EventCode)
static int Events[NUM_EVENTS]
Definition: init_fini.c:8
#define PAPI_THREAD_LEVEL_INITED
Definition: fpapi.h:20
int _papi_hwi_cleanup_eventset(EventSetInfo_t *ESI)
EventSetInfo_t ** running_eventset
Definition: cpus.h:15
unsigned long PAPI_thread_id(void)
Definition: papi.c:157
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
#define PAPI_GRN_MIN
Definition: fpapi.h:68
#define PAPI_PROFIL_DATA_EAR
Definition: papi.h:402
int PAPI_write(int EventSet, long long *values)
Definition: papi.c:2729
#define PAPI_DOM_ALL
Definition: fpapi.h:25
int _papi_hwi_debug
Definition: papi.c:74
#define papi_return(a)
Definition: papi.c:47
cpu
Definition: iozone.c:3872
int PAPI_remove_event(int EventSet, int EventCode)
Definition: papi.c:1699
#define papi_malloc(a)
Definition: papi_memory.h:34
#define PAPI_MIN_STR_LEN
Definition: fpapi.h:41
long long PAPI_get_virt_cyc(void)
Definition: papi.c:6174
PAPI_debug_handler_t _papi_hwi_debug_handler
Definition: papi_internal.c:56
void MPX_shutdown(void)
long long(* get_real_usec)(void)
Definition: papi_vector.h:63
#define PAPI_ENOEVNT
Definition: fpapi.h:112
#define PAPI_ENOINIT
Definition: fpapi.h:121
off64_t offset
Definition: iozone.c:1279
#define PAPI_DATA_ADDRESS
Definition: papi.h:450
MPX_EventSet * mpx_evset
Definition: sw_multiplex.h:32
#define PAPI_EISRUN
Definition: fpapi.h:115
int PAPI_num_components(void)
Definition: papi.c:4285
int PAPI_enum_event(int *EventCode, int modifier)
Definition: papi.c:1148
int _papi_hwi_native_code_to_name(unsigned int EventCode, char *hwi_name, int len)
void _papi_hwi_dummy_handler(int EventSet, void *address, long long overflow_vector, void *context)
EventSetAttachInfo_t attach
#define PAPI_VERB_ECONT
Definition: fpapi.h:39
PAPI_granularity_option_t granularity
Definition: papi.h:848
int _papi_user_defined_events_setup(char *name)
int MPX_stop(MPX_EventSet *mpx_events, long long *values)
Definition: sw_multiplex.c:974
caddr_t pr_off
Definition: papi.h:580
#define PAPI_TLS_NUM
Definition: fpapi.h:93
int PAPI_detach(int EventSet)
Definition: papi.c:3167
int(* update_shlib_info)(papi_mdi_t *mdi)
Definition: papi_vector.h:67
void(* PAPI_overflow_handler_t)(int EventSet, void *address, long long overflow_vector, void *context)
Definition: papi.h:563
EventSetDomainInfo_t domain
get the executable&#39;s info
Definition: papi.h:702
#define PAPI_PROFIL_RANDOM
Definition: fpapi.h:76
int PAPI_register_thread(void)
Definition: papi.c:203
int _papi_hwi_errno
Definition: papi_internal.c:58
int _papi_hwi_remove_EventSet(EventSetInfo_t *ESI)
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
PAPI_inherit_option_t inherit
Definition: papi.h:847
#define PAPI_PROFIL_COMPRESS
Definition: fpapi.h:78
#define PAPI_ENOCMP
Definition: fpapi.h:122
#define PAPI_RUNNING
Definition: fpapi.h:30
#define PAPI_VERSION
Definition: fpapi.h:15
PAPI_preload_info_t preload_info
char filename[MAXNAMESIZE]
Definition: iozone.c:1360
PAPI_exe_info_t exe_info
long long(* get_virt_usec)(void)
Definition: papi_vector.h:64
int PAPI_overflow(int EventSet, int EventCode, int threshold, int flags, PAPI_overflow_handler_t handler)
Definition: papi.c:4668
#define PAPI_PRESET_MASK
#define PAPI_PROFIL_POSIX
Definition: fpapi.h:75
A pointer to the following is passed to PAPI_set/get_opt()
Definition: papi.h:843
int PAPI_remove_events(int EventSet, int *Events, int number)
Definition: papi.c:5807
long long PAPI_get_virt_nsec(void)
Definition: papi.c:6204
return PAPI_EINVAL
Definition: linux-nvml.c:408
int PAPI_sprofil(PAPI_sprofil_t *prof, int profcnt, int EventSet, int EventCode, int threshold, int flags)
Definition: papi.c:4923
void _papi_hwi_init_errors(void)
int _papi_hwi_remove_event(EventSetInfo_t *ESI, int EventCode)
#define DEBUG_MEMORY
Definition: papi_debug.h:34
EventSetInfo_t * _papi_hwi_lookup_EventSet(int eventset)
#define PAPI_STOPPED
Definition: fpapi.h:29
#define DERIVED_CMPD
Definition: papi_internal.h:73
PAPI_hw_info_t * hw_info
Definition: papi.h:856
double c
Definition: multiplex.c:22
#define PAPI_OVERFLOWING
Definition: fpapi.h:33
PAPI_user_defined_events_file_t events_file
Definition: papi.h:861
int _papi_hwi_native_name_to_code(char *in, int *out)
#define DEBUG_API
Definition: papi_debug.h:28
int PAPI_set_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:3371
long long(* get_real_cycles)(void)
Definition: papi_vector.h:61
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:37
int PAPI_add_events(int EventSet, int *Events, int number)
Definition: papi.c:5720
unsigned int cpu_num
Definition: papi.h:819
#define PAPI_PROFILING
Definition: fpapi.h:34
#define PAPI_INHERIT
Definition: papi.h:456
#define PAPI_ECNFLCT
Definition: fpapi.h:113
unsigned pr_scale
Definition: papi.h:581
PAPI_shlib_info_t shlib_info
Return codes and api definitions.
int MPX_read(MPX_EventSet *mpx_events, long long *values, int called_by_stop)
Definition: sw_multiplex.c:823
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:844
int PAPI_disable_component_by_name(char *name)
Definition: papi.c:6589
void * thread_storage[PAPI_MAX_TLS]
Definition: threads.h:29
PAPI_addr_range_option_t addr
Definition: papi.h:860
#define APIDBG(format, args...)
Definition: papi_debug.h:64
int _papi_hwi_shutdown_global_threads(void)
Definition: threads.c:457
int multiplex(void)
Definition: multiplex.c:35
int PAPI_set_cmp_domain(int domain, int cidx)
Definition: papi.c:5635
long long ret
Definition: iozone.c:1346
int PAPI_disable_component(int cidx)
Definition: papi.c:6539
unsigned pr_size
Definition: papi.h:579
int PAPI_num_cmp_hwctrs(int cidx)
Definition: papi.c:3865
void _papi_mem_cleanup_all()
Definition: papi_memory.c:303
int PAPI_get_thr_specific(int tag, void **ptr)
Definition: papi.c:357
int PAPI_accum(int EventSet, long long *values)
Definition: papi.c:2662
void _papi_hwi_shutdown_highlevel()
Definition: papi_hl.c:836
#define PAPI_TLS_ALL_THREADS
Definition: papi.h:325
#define PAPI_USER_EVENTS_FILE
Definition: papi.h:457
#define DEADBEEF
Definition: papi_internal.h:26
#define PAPI_MULTIPLEXING
Definition: fpapi.h:35
int PAPI_thread_init(unsigned long int(*id_fn)(void))
Definition: papi.c:118
#define DEBUG_ALL
Definition: papi_debug.h:36
void _papi_cleanup_user_events()
#define PAPI_COMPONENTINFO
Definition: fpapi.h:65
int PAPI_library_init(int version)
Definition: papi.c:495
int PAPI_profil(void *buf, unsigned bufsiz, caddr_t offset, unsigned scale, int EventSet, int EventCode, int threshold, int flags)
Definition: papi.c:5316
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288
int i
Definition: fileop.c:140
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:64
EventSetOverflowInfo_t overflow
char buf[200]
Definition: iozone.c:19609
int PAPI_num_hwctrs(void)
Definition: papi.c:3810
#define PAPI_OVERFLOW_HARDWARE
Definition: papi.h:410
EventSetInheritInfo_t inherit
#define PAPI_ENOEVST
Definition: fpapi.h:116
#define PAPI_MAX_HWCTRS
Definition: fpapi.h:58
#define PAPI_SHUTDOWN_SYNC_str
Definition: papi_internal.h:43
struct _CpuInfo * CpuInfo
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
#define PAPI_MULTIPLEX_FORCE_SW
Definition: fpapi.h:46
DynamicArray_t global_eventset_map
struct _ThreadInfo * master
A pointer to the following is passed to PAPI_get_dmem_info()
Definition: papi.h:866
int MPX_start(MPX_EventSet *mpx_events)
Definition: sw_multiplex.c:692
void PAPI_shutdown(void)
Definition: papi.c:4357
Definition: cpus.h:10
#define IS_NATIVE(EventCode)
Definition: papi.h:226
int PAPI_get_cmp_opt(int option, PAPI_option_t *ptr, int cidx)
Definition: papi.c:4233
const PAPI_exe_info_t * PAPI_get_executable_info(void)
Definition: papi.c:5988
#define PAPI_SHLIBINFO
Definition: fpapi.h:63
int PAPI_num_events(int EventSet)
Definition: papi.c:4323
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4041
#define PAPI_HWINFO
Definition: fpapi.h:59
#define NOT_DERIVED
Definition: papi_internal.h:69
int ffsll(long long lli)
Definition: extras.c:497
#define PAPI_MAX_MPX_CTRS
Definition: fpapi.h:54
int k
Definition: iozone.c:19136
static int cidx
Definition: event_info.c:40
#define PAPI_ECMP
Definition: fpapi.h:109
#define PAPI_DOM_MAX
Definition: fpapi.h:27
#define OVFDBG(format, args...)
Definition: papi_debug.h:68
int _papi_hwi_read(hwd_context_t *context, EventSetInfo_t *ESI, long long *values)
#define PAPI_MULTIPLEX_DEFAULT
Definition: fpapi.h:45
PAPI_sprofil_t ** prof
hwi_presets_t _papi_hwi_presets[PAPI_MAX_PRESET_EVENTS]
int _papi_hwi_stop_timer(int timer, int signal)
Definition: extras.c:461
int PAPI_state(int EventSet, int *status)
Definition: papi.c:2966
pthread_attr_t foo
Definition: iozone.c:18592
#define PAPI_PROFIL_BUCKET_64
Definition: fpapi.h:81
inline_static int _papi_hwi_unlock(int lck)
Definition: threads.h:78
void * thread(void *arg)
Definition: kufrin.c:31
#define PAPI_CPU_ATTACHED
Definition: fpapi.h:37
#define PAPI_PROFIL_BUCKET_16
Definition: fpapi.h:79
#define PAPI_DEFDOM
Definition: fpapi.h:49
void *long long tid
Definition: iozone.c:18586
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int MPX_cleanup(MPX_EventSet **mpx_events)
#define PAPI_PROFIL_INST_EAR
Definition: papi.h:403
#define DEBUG_LEAK
Definition: papi_debug.h:35
int _papi_hwi_start_timer(int timer, int signal, int ns)
Definition: extras.c:366
int _papi_hwi_lookup_EventCodeIndex(const EventSetInfo_t *ESI, unsigned int EventCode)
int _papi_hwi_add_event(EventSetInfo_t *ESI, int EventCode)
long long
Definition: iozone.c:19827
int _papi_hwi_get_native_event_info(unsigned int EventCode, PAPI_event_info_t *info)
void PAPIERROR(char *format,...)
int _papi_hwi_start_signal(int signal, int need_context, int cidx)
Definition: extras.c:401
PAPI_cpu_option_t cpu
Definition: papi.h:853
void _papi_hwi_shutdown_global_internal(void)
int _papi_hwi_get_preset_event_info(int EventCode, PAPI_event_info_t *info)
int PAPI_set_granularity(int granularity)
Definition: papi.c:5434
#define PAPI_DOMAIN
Definition: fpapi.h:50
int PAPI_get_component_index(char *name)
Definition: papi.c:6483
#define inline_static
#define DEBUG_INTERNAL
Definition: papi_debug.h:29
#define PAPI_ATTACH
Definition: fpapi.h:62
int _papi_hwi_error_level
Definition: papi_internal.c:55
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1311
#define PAPI_DEFGRN
Definition: fpapi.h:51
PAPI_multiplex_option_t multiplex
Definition: papi.h:854
int _papi_hwi_stop_signal(int signal)
Definition: extras.c:441
long long(* get_virt_nsec)(void)
Definition: papi_vector.h:66
#define THREADS_LOCK
Definition: papi_internal.h:87
void handler(int EventSet, void *address, long long overflow_vector, void *context)
Definition: rapl_overflow.c:16
#define PAPI_GRANUL
Definition: fpapi.h:52
inline_static int valid_ESI_component(EventSetInfo_t *ESI)
Definition: papi.c:89
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2805
int mpx_init(int interval_ns)
int PAPI_assign_eventset_component(int EventSet, int cidx)
Definition: papi.c:1467
NativeInfo_t * NativeInfoArray
int _papi_hwi_num_errors
Definition: papi_internal.c:59
char version[]
Definition: fileop.c:134
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
#define PAPI_GRN_MAX
Definition: fpapi.h:73
EventInfo_t * EventInfoArray
#define PAPI_DEF_MPX_NS
Definition: fpapi.h:53
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
unsigned long int(* _papi_hwi_thread_id_fn)(void)
Definition: threads.c:42
long long * hw_start
int threshold
PAPI_thread_id_t * id
Definition: papi.h:559
static int init_retval
Definition: papi.c:78
#define DEBUG_OVERFLOW
Definition: papi_debug.h:32
#define PAPI_QUIET
Definition: fpapi.h:38
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
strcpy(filename, default_filename)
PAPI_hw_info_t hw_info
again struct sockaddr sizeof(struct sockaddr_in))
#define PAPI_DETACH
Definition: fpapi.h:66
#define PAPI_EXEINFO
Definition: fpapi.h:60
int _papi_hwi_native_to_eventcode(int cidx, int event_code)
int PAPI_event_name_to_code(char *in, int *out)
Definition: papi.c:1008
int PAPI_get_dmem_info(PAPI_dmem_info_t *dest)
Definition: papi.c:5937
EventSetMultiplexInfo_t multiplex
EventSetGranularityInfo_t granularity
hwd_context_t * _papi_hwi_get_context(EventSetInfo_t *ESI, int *is_dirty)
EventSetInfo_t ** dataSlotArray
int PAPI_query_event(int EventCode)
Definition: papi.c:696
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
PAPI_debug_handler_t handler
Definition: papi.h:685
#define PAPI_NUM_TLS
Definition: papi.h:320
int PAPI_get_overflow_event_index(int EventSet, long long overflow_vector, int *array, int *number)
Definition: papi.c:6391
unsigned long tid
Definition: papi.h:813
int EventSet
int MPX_reset(MPX_EventSet *mpx_events)
Definition: sw_multiplex.c:937
long long * sw_stop
int PAPI_multiplex_init(void)
Definition: papi.c:2897
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:38
PAPI_attach_option_t attach
Definition: papi.h:852
#define PAPI_LOW_LEVEL_INITED
Definition: fpapi.h:18
PAPI_granularity_option_t defgranularity
Definition: papi.h:849
#define PAPI_MAX_PRESET_EVENTS
Definition: fpapi.h:16
long long buckets[BUCKETS]
Definition: iozone.c:24212
int papi_num_components
int PAPI_read_ts(int EventSet, long long *values, long long *cycles)
Definition: papi.c:2565
long long PAPI_get_real_usec(void)
Definition: papi.c:6138
PAPI_exe_info_t * exe_info
Definition: papi.h:858
int _papi_hwi_init_os(void)
Definition: aix.c:1213
#define PAPI_OVERFLOW_FORCE_SW
Definition: papi.h:409
#define PAPI_DEF_ITIMER
Definition: papi.h:452
long long status
Definition: iozone.c:1335
EventSetInfo_t ** running_eventset
Definition: threads.h:30
int PAPI_unregister_thread(void)
Definition: papi.c:239
int _papi_hwi_lookup_or_create_cpu(CpuInfo_t **here, unsigned int cpu_num)
Definition: cpus.c:59
int PAPI_set_thr_specific(int tag, void *ptr)
Definition: papi.c:433
char * PAPI_strerror(int errorCode)
Definition: papi.c:4483
char * name
Definition: iozone.c:23648
int PAPI_query_named_event(char *EventName)
Definition: papi.c:765
int _papi_hwi_assign_eventset(EventSetInfo_t *ESI, int cidx)
static int total
Definition: rapl_overflow.c:5
int _papi_hwi_init_global(void)
inline_static int _papi_hwi_lookup_or_create_thread(ThreadInfo_t **here, int tid)
Definition: threads.h:145
#define NEED_CONTEXT
Definition: papi_internal.h:97
int _papi_hwi_gather_all_thrspec_data(int tag, PAPI_all_thr_spec_t *where)
Definition: threads.c:554
long long(* get_virt_cycles)(void)
Definition: papi_vector.h:62
char ** _papi_errlist
Definition: papi_internal.c:77
PAPI_debug_option_t debug
Definition: papi.h:846
int PAPI_unlock(int lck)
Definition: papi.c:6295
int cpu_max_mhz
Definition: papi.h:791
int
Definition: iozone.c:18528
long long PAPI_get_real_nsec(void)
Definition: papi.c:6111
#define PAPI_ATTACHED
Definition: fpapi.h:36
#define PAPI_ENOTRUN
Definition: fpapi.h:114
#define ISLEVEL(a)
Definition: papi_debug.h:54
inline_static ThreadInfo_t * _papi_hwi_lookup_thread(int custom_tid)
Definition: threads.h:92
int _papi_hwi_component_index(int event_code)
#define PAPI_PROFIL_FORCE_SW
Definition: papi.h:401
unsigned int event_code
#define PAPI_UE_AND_MASK
int PAPI_set_multiplex(int EventSet)
Definition: papi.c:3241
#define PAPI_PRESET_AND_MASK
#define PAPI_VERB_ESTOP
Definition: fpapi.h:40
unsigned long PAPI_thread_id_t
Definition: papi.h:554
struct papi_vectors * _papi_hwd[]
#define PAPI_PROFIL_BUCKETS
Definition: papi.h:404
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1944
PAPI_domain_option_t domain
Definition: papi.h:850
int _papi_hwi_invalid_cmp(int cidx)
user_defined_event_t * _papi_user_events
#define DEBUG_THREADS
Definition: papi_debug.h:30
int PAPI_set_domain(int domain)
Definition: papi.c:5565
void _papi_hwi_free_EventSet(EventSetInfo_t *ESI)
int PAPI_attach(int EventSet, unsigned long tid)
Definition: papi.c:3110
int _papi_hwi_eventcode_to_native(int event_code)
#define PAPI_ENOTPRESET
Definition: fpapi.h:117
#define PAPI_PROFIL_BUCKET_32
Definition: fpapi.h:80
void * pr_base
Definition: papi.h:578
static int attach(hwd_control_state_t *ctl, unsigned long tid)
Definition: perfctr.c:242
long long PAPI_get_real_cyc(void)
Definition: papi.c:6091
#define PAPI_DEBUG
Definition: fpapi.h:47
PAPI_shlib_info_t * shlib_info
Definition: papi.h:857
int PAPI_read(int EventSet, long long *values)
Definition: papi.c:2476
#define PAPI_DOM_USER
Definition: fpapi.h:21
int _papi_hwi_shutdown_thread(ThreadInfo_t *thread, int force_shutdown)
Definition: threads.c:418
int PAPI_start(int EventSet)
Definition: papi.c:2026
EventSetProfileInfo_t profile
PAPI_preload_info_t preload
Definition: papi.h:845
int(* get_dmem_info)(PAPI_dmem_info_t *)
Definition: papi_vector.h:70
int init_level
Definition: papi_internal.c:54
hwd_control_state_t * ctl_state
long j
Definition: iozone.c:19135
#define PAPI_CLOCKRATE
Definition: fpapi.h:57
int PAPI_get_multiplex(int EventSet)
Definition: papi.c:3927
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6059
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
int PAPI_lock(int lck)
Definition: papi.c:6275
long long tmp
Definition: iozone.c:12031
int PAPI_remove_named_event(int EventSet, char *EventName)
Definition: papi.c:1893
#define PAPI_UE_MASK
unsigned int _papi_user_events_count
inline_static int valid_component(int cidx)
Definition: papi.c:81
int _papi_hwi_init_global_threads(void)
Definition: threads.c:527
int PAPI_list_threads(PAPI_thread_id_t *tids, int *number)
Definition: papi.c:281
PAPI_itimer_option_t itimer
Definition: papi.h:855
int PAPI_get_event_component(int EventCode)
Definition: papi.c:6456
int PAPI_set_debug(int level)
Definition: papi.c:3037
int mpx_check(int EventSet)
void _papi_hwi_map_events_to_native(EventSetInfo_t *ESI)
#define PAPI_MAX_CPUS
Definition: fpapi.h:61
PAPI_domain_option_t defdomain
Definition: papi.h:851
PAPI_overflow_handler_t handler
#define PAPI_NOT_INITED
Definition: fpapi.h:17
if(gettimeofday(&tp,(struct timezone *) NULL)==-1) perror("gettimeofday")
int _papi_hwi_create_eventset(int *EventSet, ThreadInfo_t *handle)
#define PAPI_MULTIPLEX
Definition: fpapi.h:48
int PAPI_list_events(int EventSet, int *Events, int *number)
Definition: papi.c:5876
#define PAPI_DOM_MIN
Definition: fpapi.h:26
PAPI_component_info_t * cmp_info
Definition: papi.h:859
#define DEBUG_SUBSTRATE
Definition: papi_debug.h:27
int ncpu
Definition: papi.h:776
int PAPI_get_eventset_component(int EventSet)
Definition: papi.c:1510
#define PAPI_LIB_VERSION
Definition: fpapi.h:64
char * ptr
Definition: iozone.c:23586