PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
linux-bgq.c File Reference

This file has the source code for a component that enables PAPI-C to access hardware monitoring counters for BG/Q through the BGPM library. More...

Include dependency graph for linux-bgq.c:

Go to the source code of this file.

Data Structures

struct  bgq_generic_events_t
 

Macros

#define get_cycles   GetTimeBase
 
#define OPCODE_EVENT_CHUNK   8
 

Functions

int _bgq_get_memory_info (PAPI_hw_info_t *pHwInfo, int pCPU_Type)
 
int _bgq_get_dmem_info (PAPI_dmem_info_t *pDmemInfo)
 
void user_signal_handler (int hEvtSet, uint64_t address, uint64_t ovfVector, const ucontext_t *pContext)
 
void _papi_hwd_lock (int lock)
 
void _papi_hwd_unlock (int lock)
 
int _bgq_get_system_info (papi_mdi_t *mdi)
 
int _bgq_init_control_state (hwd_control_state_t *ptr)
 
int _bgq_set_domain (hwd_control_state_t *cntrl, int domain)
 
int _bgq_init (hwd_context_t *ctx)
 
int _bgq_multiplex (hwd_control_state_t *bgq_state)
 
int _bgq_allocate_registers (EventSetInfo_t *ESI)
 
int _bgq_cleanup_eventset (hwd_control_state_t *ctrl)
 
int _bgq_update_control_state (hwd_control_state_t *ptr, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
int _bgq_start (hwd_context_t *ctx, hwd_control_state_t *ptr)
 
int _bgq_stop (hwd_context_t *ctx, hwd_control_state_t *ptr)
 
int _bgq_read (hwd_context_t *ctx, hwd_control_state_t *ptr, long_long **dp, int flags)
 
int _bgq_reset (hwd_context_t *ctx, hwd_control_state_t *ptr)
 
int _bgq_shutdown (hwd_context_t *ctx)
 
int _bgq_write (hwd_context_t *ctx, hwd_control_state_t *cntrl, long_long *from)
 
void _bgq_dispatch_timer (int signal, hwd_siginfo_t *info, void *uc)
 
int _bgq_set_overflow (EventSetInfo_t *ESI, int EventIndex, int threshold)
 
int _bgq_set_profile (EventSetInfo_t *ESI, int EventIndex, int threshold)
 
int _bgq_stop_profiling (ThreadInfo_t *master, EventSetInfo_t *ESI)
 
int _bgq_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
long long _bgq_get_real_usec (void)
 
long long _bgq_get_real_cycles (void)
 
long long _bgq_get_virt_usec (void)
 
long long _bgq_get_virt_cycles (void)
 
int _bgq_init_component (int cidx)
 
int _bgq_ntv_name_to_code (char *name, unsigned int *event_code)
 
int _bgq_ntv_code_to_name (unsigned int EventCode, char *name, int len)
 
int _bgq_ntv_code_to_descr (unsigned int EventCode, char *name, int len)
 
int _bgq_ntv_code_to_bits (unsigned int EventCode, hwd_register_t *bits)
 
int _bgq_ntv_enum_events (unsigned int *EventCode, int modifier)
 
int _papi_hwi_init_os (void)
 

Variables

UPC_Lock_t thdLocks [PAPI_MAX_LOCK]
 
papi_vector_t _bgq_vectors
 
PAPI_os_info_t _papi_os_info
 
static int allocated_opcode_events = 0
 
static int num_opcode_events = 0
 
static struct
bgq_generic_events_t
GenericEvent
 
papi_os_vector_t _papi_os_vector
 

Detailed Description

Author
Heike Jagode jagod.nosp@m.e@ee.nosp@m.cs.ut.nosp@m.k.ed.nosp@m.u Mods: < your name here > < your email address > Blue Gene/Q CPU component: BGPM / Punit

Tested version of bgpm (early access)

Definition in file linux-bgq.c.

Macro Definition Documentation

#define get_cycles   GetTimeBase

Definition at line 48 of file linux-bgq.c.

#define OPCODE_EVENT_CHUNK   8

Definition at line 63 of file linux-bgq.c.

Function Documentation

int _bgq_allocate_registers ( EventSetInfo_t ESI)

Definition at line 323 of file linux-bgq.c.

324 {
325 #ifdef DEBUG_BGQ
326  printf("_bgq_allocate_registers\n");
327 #endif
328  int i, natNum;
329  int xEventId;
330 
331  /*
332  * Start monitoring the events...
333  */
334  natNum = ESI->NativeCount;
335 
336  for ( i = 0; i < natNum; i++ ) {
337  xEventId = ( ESI->NativeInfoArray[i].ni_event & PAPI_NATIVE_AND_MASK ) + 1;
338  ESI->NativeInfoArray[i].ni_position = i;
339  }
340 
341  return PAPI_OK;
342 }
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
int i
Definition: fileop.c:140
NativeInfo_t * NativeInfoArray
#define PAPI_NATIVE_AND_MASK
int _bgq_cleanup_eventset ( hwd_control_state_t ctrl)

Definition at line 351 of file linux-bgq.c.

352 {
353 #ifdef DEBUG_BGQ
354  printf( "_bgq_cleanup_eventset\n" );
355 #endif
356 
357  // set multiplexing flag to OFF (0)
358  ctrl->muxOn = 0;
359  // set overflow flag to OFF (0)
360  ctrl->overflow = 0;
361  ctrl->overflow_count = 0;
362  // set BGPM eventGroup flag back to NOT applied yet (0)
363  ctrl->bgpm_eventset_applied = 0;
364 
365  return ( PAPI_OK );
366 }
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
int _bgq_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)

Definition at line 895 of file linux-bgq.c.

896 {
897 #ifdef DEBUG_BGQ
898  printf( "_bgq_ctl\n" );
899 #endif
900  ( void ) ctx;
901  int retval;
902 
903  switch ( code ) {
904  case PAPI_MULTIPLEX:
905  {
906  hwd_control_state_t * bgq_state = ( ( hwd_control_state_t * ) option->multiplex.ESI->ctl_state );
907  bgq_state->muxOn = 1;
908  retval = _bgq_multiplex( bgq_state );
909  return ( retval );
910  }
911  default:
912  return ( PAPI_OK );
913  }
914 }
int _bgq_multiplex(hwd_control_state_t *bgq_state)
Definition: linux-bgq.c:262
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
_papi_int_multiplex_t multiplex
EventSetInfo_t * ESI
hwd_control_state_t * ctl_state
ssize_t retval
Definition: libasync.c:338
#define PAPI_MULTIPLEX
Definition: fpapi.h:48

Here is the call graph for this function:

void _bgq_dispatch_timer ( int  signal,
hwd_siginfo_t info,
void uc 
)

Definition at line 663 of file linux-bgq.c.

664 {
665  ( void ) signal;
666  ( void ) info;
667  ( void ) uc;
668 #ifdef DEBUG_BGQ
669  printf("BEGIN _bgq_dispatch_timer\n");
670 #endif
671 
672  return;
673 }
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
signal(SIGINT, signal_handler)
int _bgq_get_dmem_info ( PAPI_dmem_info_t pDmemInfo)

Definition at line 53 of file linux-bgq-memory.c.

54 {
55 // pid_t xPID = getpid();
56 // prpsinfo_t xInfo;
57 // char xFile[256];
58 // int xFD;
59 
60 // sprintf(xFile, "/proc/%05d", xPID);
61 // if ((fd = open(xFile, O_RDONLY)) < 0) {
62 // SUBDBG("PAPI_get_dmem_info can't open /proc/%d\n", xPID);
63 // return (PAPI_ESYS);
64 // }
65 // if (ioctl(xFD, PIOCPSINFO, &xInfo) < 0) {
66 // return (PAPI_ESYS);
67 // }
68 // close(xFD);
69 
70  pDmemInfo->size = PAPI_EINVAL;
71  pDmemInfo->resident = PAPI_EINVAL;
72  pDmemInfo->high_water_mark = PAPI_EINVAL;
73  pDmemInfo->shared = PAPI_EINVAL;
74  pDmemInfo->text = PAPI_EINVAL;
75  pDmemInfo->library = PAPI_EINVAL;
76  pDmemInfo->heap = PAPI_EINVAL;
77  pDmemInfo->locked = PAPI_EINVAL;
78  pDmemInfo->stack = PAPI_EINVAL;
79  pDmemInfo->pagesize = PAPI_EINVAL;
80 
81  return PAPI_OK;
82 }
return PAPI_OK
Definition: linux-nvml.c:458
long long heap
Definition: papi.h:874
return PAPI_EINVAL
Definition: linux-nvml.c:408
long long resident
Definition: papi.h:869
long long pagesize
Definition: papi.h:877
long long locked
Definition: papi.h:875
long long library
Definition: papi.h:873
long long shared
Definition: papi.h:871
long long text
Definition: papi.h:872
long long stack
Definition: papi.h:876
long long size
Definition: papi.h:868
long long high_water_mark
Definition: papi.h:870
int _bgq_get_memory_info ( PAPI_hw_info_t pHwInfo,
int  pCPU_Type 
)

Definition at line 33 of file linux-bgq-memory.c.

34 {
35  int retval = 0;
36 
37  switch ( pCPU_Type ) {
38  default:
39  //fprintf(stderr,"Default CPU type in %s (%d)\n",__FUNCTION__,__LINE__);
40  retval = init_bgq( &pHwInfo->mem_hierarchy );
41  break;
42  }
43 
44  return retval;
45 }
PAPI_mh_info_t mem_hierarchy
Definition: papi.h:794
ssize_t retval
Definition: libasync.c:338
int init_bgq(PAPI_mh_info_t *pMem_Info)

Here is the call graph for this function:

Here is the caller graph for this function:

long long _bgq_get_real_cycles ( void  )

Definition at line 942 of file linux-bgq.c.

943 {
944 #ifdef DEBUG_BGQ
945  printf( "_bgq_get_real_cycles\n" );
946 #endif
947 
948  return ( ( long long ) get_cycles( ) );
949 
950 }
#define printf
Definition: papi_test.h:125
#define get_cycles
Definition: linux-bgq.c:48

Here is the caller graph for this function:

long long _bgq_get_real_usec ( void  )

Definition at line 920 of file linux-bgq.c.

921 {
922 #ifdef DEBUG_BGQ
923  printf( "_bgq_get_real_usec\n" );
924 #endif
925 
926  /*
927  * NOTE: _papi_hwi_system_info.hw_info.mhz is really a representation of unit of time per cycle.
928  * On BG/P, it's value is 8.5e-4. Therefore, to get cycles per sec, we have to multiply
929  * by 1.0e12. To then convert to usec, we have to divide by 1.0e-3.
930  */
931  return ( ( long long ) ( ( ( float ) get_cycles( ) ) /
933 
934 }
#define printf
Definition: papi_test.h:125
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
PAPI_hw_info_t hw_info
#define get_cycles
Definition: linux-bgq.c:48
int cpu_max_mhz
Definition: papi.h:791

Here is the caller graph for this function:

int _bgq_get_system_info ( papi_mdi_t mdi)

Definition at line 138 of file linux-bgq.c.

139 {
140 #ifdef DEBUG_BGQ
141  printf( "_bgq_get_system_info\n" );
142 #endif
143 
144  ( void ) mdi;
145  Personality_t personality;
146  int retval;
147 
148  /* Hardware info */
149  retval = Kernel_GetPersonality( &personality, sizeof( Personality_t ) );
150  if ( retval ) {
151  fprintf( stdout, "Kernel_GetPersonality returned %d (sys error=%d).\n"
152  "\t%s\n", retval, errno, strerror( errno ) );
153  return PAPI_ESYS;
154  }
155 
156  /* Returns the number of processors that are associated with the currently
157  * running process */
158  _papi_hwi_system_info.hw_info.ncpu = Kernel_ProcessorCount( );
159  // TODO: HJ Those values need to be fixed
160  _papi_hwi_system_info.hw_info.nnodes = Kernel_ProcessCount( );
162 
163  _papi_hwi_system_info.hw_info.cpu_max_mhz = personality.Kernel_Config.FreqMHz;
164  _papi_hwi_system_info.hw_info.cpu_min_mhz = personality.Kernel_Config.FreqMHz;
165 
166  _papi_hwi_system_info.hw_info.mhz = ( float ) personality.Kernel_Config.FreqMHz;
167  SUBDBG( "_bgq_get_system_info: Detected MHZ is %f\n",
169 
170  return ( PAPI_OK );
171 }
int errno
int cpu_min_mhz
Definition: papi.h:792
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
float mhz
Definition: papi.h:802
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int nnodes
Definition: papi.h:780
#define PAPI_ESYS
Definition: fpapi.h:108
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
PAPI_hw_info_t hw_info
int cpu_max_mhz
Definition: papi.h:791
int totalcpus
Definition: papi.h:781
ssize_t retval
Definition: libasync.c:338
int ncpu
Definition: papi.h:776

Here is the caller graph for this function:

long long _bgq_get_virt_cycles ( void  )

Definition at line 973 of file linux-bgq.c.

974 {
975 #ifdef DEBUG_BGQ
976  printf( "_bgq_get_virt_cycles\n" );
977 #endif
978 
979  return _bgq_get_real_cycles( );
980 }
#define printf
Definition: papi_test.h:125
long long _bgq_get_real_cycles(void)
Definition: linux-bgq.c:942

Here is the call graph for this function:

long long _bgq_get_virt_usec ( void  )

Definition at line 958 of file linux-bgq.c.

959 {
960 #ifdef DEBUG_BGQ
961  printf( "_bgq_get_virt_usec\n" );
962 #endif
963 
964  return _bgq_get_real_usec( );
965 }
#define printf
Definition: papi_test.h:125
long long _bgq_get_real_usec(void)
Definition: linux-bgq.c:920

Here is the call graph for this function:

int _bgq_init ( hwd_context_t ctx)

Definition at line 234 of file linux-bgq.c.

235 {
236 #ifdef DEBUG_BGQ
237  printf( "_bgq_init\n" );
238 #endif
239  ( void ) ctx;
240  int retval;
241 
242 #ifdef DEBUG_BGPM
243  Bgpm_PrintOnError(1);
244  Bgpm_ExitOnError(0);
245 #else
246  Bgpm_PrintOnError(0);
247  // avoid bgpm default of exiting when error occurs - caller will check return code instead.
248  Bgpm_ExitOnError(0);
249 #endif
250 
251  retval = Bgpm_Init( BGPM_MODE_SWDISTRIB );
252  retval = _check_BGPM_error( retval, "Bgpm_Init" );
253  if ( retval < 0 ) return retval;
254 
255  //_common_initBgpm();
256 
257  return PAPI_OK;
258 }
int _check_BGPM_error(int err, char *bgpmfunc)
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int _bgq_init_component ( int  cidx)

Definition at line 990 of file linux-bgq.c.

991 {
992 #ifdef DEBUG_BGQ
993  printf("_bgq_init_substrate\n");
994  //printf("_bgq_init_substrate: 1. BGPM_INITIALIZED = %d \n", BGPM_INITIALIZED);
995 #endif
996  int retval;
997  int i;
998 
999  /* allocate the opcode event structure */
1000  GenericEvent = calloc( OPCODE_EVENT_CHUNK, sizeof( struct bgq_generic_events_t ) );
1001  if ( NULL == GenericEvent ) {
1002  return PAPI_ENOMEM;
1003  }
1004 
1005  /* init opcode event stuff */
1007  num_opcode_events = 0;
1008 
1010 
1011  /*
1012  * Fill in what we can of the papi_system_info
1013  */
1014  SUBDBG( "Before _bgq_get_system_info()...\n" );
1016  SUBDBG( "After _bgq_get_system_info(), retval=%d...\n", retval );
1017  if ( retval != PAPI_OK )
1018  return ( retval );
1019 
1020  /*
1021  * Setup memory info
1022  */
1023 
1024  SUBDBG( "Before _bgq_get_memory_info...\n" );
1027  model );
1028  SUBDBG( "After _bgq_get_memory_info, retval=%d...\n", retval );
1029  if ( retval )
1030  return ( retval );
1031 #if 1
1032  /* Setup Locks */
1033  for ( i = 0; i < PAPI_MAX_LOCK; i++ )
1034  thdLocks[i] = 0; // MUTEX_OPEN
1035 #else
1036  for( i = 0; i < PAPI_MAX_LOCK; i++ ) {
1037  pthread_mutex_init( &thdLocks[i], NULL );
1038  }
1039 #endif
1040 
1041  /* Setup presets */
1042  retval = _papi_load_preset_table( "BGQ", 0, cidx );
1043  if ( retval ) {
1044  return retval;
1045  }
1046 
1047 
1048  return ( PAPI_OK );
1049 }
#define PAPI_ENOMEM
Definition: fpapi.h:107
papi_vector_t _bgq_vectors
Definition: linux-bgq.c:60
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
#define printf
Definition: papi_test.h:125
#define PAPI_MAX_LOCK
Definition: papi_lock.h:18
static int num_opcode_events
Definition: linux-bgq.c:65
static int allocated_opcode_events
Definition: linux-bgq.c:64
int i
Definition: fileop.c:140
static struct bgq_generic_events_t * GenericEvent
Definition: linux-bgq.c:75
static int cidx
Definition: event_info.c:40
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int _papi_load_preset_table(char *pmu_str, int pmu_type, int cidx)
Definition: papi_preset.c:299
int _bgq_get_memory_info(PAPI_hw_info_t *pHwInfo, int pCPU_Type)
int _bgq_get_system_info(papi_mdi_t *mdi)
Definition: linux-bgq.c:138
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
PAPI_hw_info_t hw_info
#define OPCODE_EVENT_CHUNK
Definition: linux-bgq.c:63
ssize_t retval
Definition: libasync.c:338
UPC_Lock_t thdLocks[PAPI_MAX_LOCK]
Definition: linux-bgq.c:52

Here is the call graph for this function:

int _bgq_init_control_state ( hwd_control_state_t ptr)

Definition at line 179 of file linux-bgq.c.

180 {
181 #ifdef DEBUG_BGQ
182  printf( "_bgq_init_control_state\n" );
183 #endif
184  int retval;
185 
186  ptr->EventGroup = Bgpm_CreateEventSet();
187  retval = _check_BGPM_error( ptr->EventGroup, "Bgpm_CreateEventSet" );
188  if ( retval < 0 ) return retval;
189 
190  // initialize multiplexing flag to OFF (0)
191  ptr->muxOn = 0;
192  // initialize overflow flag to OFF (0)
193  ptr->overflow = 0;
194  ptr->overflow_count = 0;
195  // initialized BGPM eventGroup flag to NOT applied yet (0)
196  ptr->bgpm_eventset_applied = 0;
197 
198  return PAPI_OK;
199 }
int _check_BGPM_error(int err, char *bgpmfunc)
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int _bgq_multiplex ( hwd_control_state_t bgq_state)

Definition at line 262 of file linux-bgq.c.

263 {
264  int retval;
265  uint64_t bgpm_period;
266  double Sec, Hz;
267 
268 #ifdef DEBUG_BGQ
269  printf("_bgq_multiplex BEGIN: Num of Events = %d (vs %d)\n", Bgpm_NumEvents( bgq_state->EventGroup ), bgq_state->count );
270 #endif
271 
272  // convert Mhz to Hz ( = cycles / sec )
273  Hz = (double) _papi_hwi_system_info.hw_info.cpu_max_mhz * 1000 * 1000;
274  // convert PAPI multiplex period (in ns) to BGPM period (in cycles)
275  Sec = (double) _papi_os_info.itimer_ns / ( 1000 * 1000 * 1000 );
276  bgpm_period = Hz * Sec;
277 
278  // if EventGroup is not empty -- which is required by BGPM before
279  // we can call SetMultiplex() -- then drain the events from the
280  // BGPM EventGroup, turn on multiplex flag, and rebuild BGPM EventGroup.
281  if ( 0 < bgq_state->count ) {
282  // Delete and re-create BGPM eventset
283  retval = _common_deleteRecreate( &bgq_state->EventGroup );
284  if ( retval < 0 ) return retval;
285 
286  // turn on multiplex for BGPM
287  retval = Bgpm_SetMultiplex( bgq_state->EventGroup, bgpm_period, BGPM_NORMAL );
288  retval = _check_BGPM_error( retval, "Bgpm_SetMultiplex" );
289  if ( retval < 0 ) return retval;
290 
291  // rebuild BGPM EventGroup
292  retval = _common_rebuildEventgroup( bgq_state->count,
293  bgq_state->EventGroup_local,
294  &bgq_state->EventGroup );
295  if ( retval < 0 ) return retval;
296  }
297  else {
298  // need to pass either BGPM_NORMAL or BGPM_NOTNORMAL
299  // BGPM_NORMAL: numbers reported by Bgpm_ReadEvent() are normalized
300  // to the maximum time spent in a multiplexed group
301  retval = Bgpm_SetMultiplex( bgq_state->EventGroup, bgpm_period, BGPM_NORMAL );
302  retval = _check_BGPM_error( retval, "Bgpm_SetMultiplex" );
303  if ( retval < 0 ) return retval;
304  }
305 
306 #ifdef DEBUG_BGQ
307  printf("_bgq_multiplex END: Num of Events = %d (vs %d) --- retval = %d\n",
308  Bgpm_NumEvents( bgq_state->EventGroup ), bgq_state->count, retval );
309 #endif
310 
311  return ( retval );
312 }
int _common_deleteRecreate(int *EventGroup_ptr)
int _check_BGPM_error(int err, char *bgpmfunc)
#define printf
Definition: papi_test.h:125
static double
Definition: fileop.c:1281
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
int _common_rebuildEventgroup(int count, int *EventGroup_local, int *EventGroup_ptr)
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:57
PAPI_hw_info_t hw_info
int cpu_max_mhz
Definition: papi.h:791
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int _bgq_ntv_code_to_bits ( unsigned int  EventCode,
hwd_register_t bits 
)

Definition at line 1218 of file linux-bgq.c.

1219 {
1220 #ifdef DEBUG_BGQ
1221  printf( "_bgq_ntv_code_to_bits\n" );
1222 #endif
1223 
1224  ( void ) EventCode;
1225  ( void ) bits;
1226 
1227  return ( PAPI_OK );
1228 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
int _bgq_ntv_code_to_descr ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 1192 of file linux-bgq.c.

1193 {
1194 #ifdef DEBUG_BGQ
1195  printf( "_bgq_ntv_code_to_descr\n" );
1196 #endif
1197  int retval;
1198  int index = ( EventCode & PAPI_NATIVE_AND_MASK ) + 1;
1199 
1200  retval = Bgpm_GetLongDesc( index, name, &len );
1201  retval = _check_BGPM_error( retval, "Bgpm_GetLongDesc" );
1202  if ( retval < 0 ) return retval;
1203 
1204  return ( PAPI_OK );
1205 }
int _check_BGPM_error(int err, char *bgpmfunc)
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
char * name
Definition: iozone.c:23648
#define PAPI_NATIVE_AND_MASK
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int _bgq_ntv_code_to_name ( unsigned int  EventCode,
char *  name,
int  len 
)

Definition at line 1161 of file linux-bgq.c.

1162 {
1163 #ifdef DEBUG_BGQ
1164  printf( "_bgq_ntv_code_to_name\n" );
1165 #endif
1166  int index = ( EventCode & PAPI_NATIVE_AND_MASK ) + 1;
1167 
1168  if ( index >= MAX_COUNTERS )
1169  return PAPI_ENOEVNT;
1170 
1171  strncpy( name, Bgpm_GetEventIdLabel( index ), len );
1172 
1173  if ( name == NULL ) {
1174 #ifdef DEBUG_BGPM
1175  printf ("Error: ret value is NULL for BGPM API function Bgpm_GetEventIdLabel.\n" );
1176 #endif
1177  return PAPI_ENOEVNT;
1178  }
1179 #ifdef DEBUG_BGQ
1180  printf( "name = ===%s===\n", name );
1181 #endif
1182 
1183  return ( PAPI_OK );
1184 }
#define PAPI_ENOEVNT
Definition: fpapi.h:112
#define MAX_COUNTERS
Definition: perfctr-x86.h:8
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
char * name
Definition: iozone.c:23648
#define PAPI_NATIVE_AND_MASK
int _bgq_ntv_enum_events ( unsigned int EventCode,
int  modifier 
)

Definition at line 1235 of file linux-bgq.c.

1236 {
1237 #ifdef DEBUG_BGQ
1238  printf( "_bgq_ntv_enum_events\n" );
1239 #endif
1240 
1241  switch ( modifier ) {
1242  case PAPI_ENUM_FIRST:
1243  *EventCode = PAPI_NATIVE_MASK;
1244 
1245  return ( PAPI_OK );
1246  break;
1247 
1248  case PAPI_ENUM_EVENTS:
1249  {
1250  int index = ( *EventCode & PAPI_NATIVE_AND_MASK ) + 1;
1251 
1252  if ( index < BGQ_PUNIT_MAX_COUNTERS ) {
1253  *EventCode = *EventCode + 1;
1254  return ( PAPI_OK );
1255  } else
1256  return ( PAPI_ENOEVNT );
1257 
1258  break;
1259  }
1260  default:
1261  return ( PAPI_EINVAL );
1262  }
1263 
1264  return ( PAPI_EINVAL );
1265 }
#define PAPI_NATIVE_MASK
#define PAPI_ENOEVNT
Definition: fpapi.h:112
return PAPI_OK
Definition: linux-nvml.c:458
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define printf
Definition: papi_test.h:125
#define PAPI_NATIVE_AND_MASK
#define BGQ_PUNIT_MAX_COUNTERS
Definition: linux-bgq.h:45
int _bgq_ntv_name_to_code ( char *  name,
unsigned int event_code 
)

Definition at line 1060 of file linux-bgq.c.

1061 {
1062 #ifdef DEBUG_BGQ
1063  printf( "_bgq_ntv_name_to_code\n" );
1064 #endif
1065  int ret;
1066 #ifdef DEBUG_BGQ
1067  printf( "name = ===%s===\n", name );
1068 #endif
1069 
1070  /* Treat events differently if BGPM Opcodes are used */
1071  /* Opcode group selection values are "OR"ed together to create a desired
1072  mask of instruction group events to accumulate in the same counter */
1073  if ( 0 == strncmp( name, "PEVT_INST_XU_GRP_MASK", strlen( "PEVT_INST_XU_GRP_MASK" ) ) ||
1074  0 == strncmp( name, "PEVT_INST_QFPU_GRP_MASK", strlen( "PEVT_INST_QFPU_GRP_MASK" ) ) ) {
1075 
1076  char *pcolon;
1077  pcolon = strchr( name, ':' );
1078 
1079  // Found colon separator
1080  if ( pcolon != NULL ) {
1081  int mask_len = pcolon - name;
1082  strncpy( GenericEvent[num_opcode_events].mask, name, mask_len );
1083  strncpy( GenericEvent[num_opcode_events].opcode, pcolon+1, strlen(name) - 1 - mask_len );
1084  /* opcode_mask needs to be 'uint64_t',
1085  hence we use strtoull() which returns an 'unsigned long long int' */
1086  GenericEvent[num_opcode_events].opcode_mask = strtoull( GenericEvent[num_opcode_events].opcode, (char **)NULL, 16 );
1088  /* Return event id matching the generic XU/QFPU event string */
1089  GenericEvent[num_opcode_events].eventId = Bgpm_GetEventIdFromLabel( GenericEvent[num_opcode_events].mask );
1090  if ( GenericEvent[num_opcode_events].eventId <= 0 ) {
1091 #ifdef DEBUG_BGPM
1092  printf ("Error: ret value is %d for BGPM API function '%s'.\n",
1093  ret, "Bgpm_GetEventIdFromLabel" );
1094 #endif
1095  return PAPI_ENOEVNT;
1096  }
1097 
1098  *event_code = GenericEvent[num_opcode_events].idx;
1099 
1100  num_opcode_events++;
1101 
1102  /* If there are too many opcode events than allocated, then allocate more room */
1103  if( num_opcode_events >= allocated_opcode_events ) {
1104 
1105  SUBDBG("Allocating more room for BGPM opcode events (%d %ld)\n",
1106  ( allocated_opcode_events + NATIVE_OPCODE_CHUNK ),
1107  ( long )sizeof( struct bgq_generic_events_t ) *
1108  ( allocated_opcode_events + NATIVE_OPCODE_CHUNK ) );
1109 
1110  GenericEvent = realloc( GenericEvent, sizeof( struct bgq_generic_events_t ) *
1112  if ( NULL == GenericEvent ) {
1113  return PAPI_ENOMEM;
1114  }
1116  }
1117  }
1118  else {
1119  SUBDBG( "Error: Found a generic BGPM event mask without opcode string\n" );
1120  return PAPI_ENOEVNT;
1121  }
1122 
1123 
1124 #ifdef DEBUG_BGQ
1125  printf(_AT_ " _bgq_ntv_name_to_code: GenericEvent no. %d: \n", num_opcode_events-1 );
1126  printf( "idx = %d\n", GenericEvent[num_opcode_events-1].idx);
1127  printf( "eventId = %d\n", GenericEvent[num_opcode_events-1].eventId);
1128  printf( "mask = %s\n", GenericEvent[num_opcode_events-1].mask);
1129  printf( "opcode = %s\n", GenericEvent[num_opcode_events-1].opcode);
1130  printf( "opcode_mask = %" PRIX64 " (%" PRIu64 ")\n", GenericEvent[num_opcode_events-1].opcode_mask,
1131  GenericEvent[num_opcode_events-1].opcode_mask );
1132 #endif
1133  }
1134  else {
1135  /* Return event id matching a given event label string */
1136  ret = Bgpm_GetEventIdFromLabel ( name );
1137 
1138  if ( ret <= 0 ) {
1139 #ifdef DEBUG_BGPM
1140  printf ("Error: ret value is %d for BGPM API function '%s'.\n",
1141  ret, "Bgpm_GetEventIdFromLabel" );
1142 #endif
1143  return PAPI_ENOEVNT;
1144  }
1145  else if ( ret > BGQ_PUNIT_MAX_COUNTERS ) // not a PUnit event
1146  return PAPI_ENOEVNT;
1147  else
1148  *event_code = ( ret - 1 );
1149  }
1150 
1151  return PAPI_OK;
1152 }
#define PAPI_ENOMEM
Definition: fpapi.h:107
#define PAPI_ENOEVNT
Definition: fpapi.h:112
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
static int num_opcode_events
Definition: linux-bgq.c:65
long long ret
Definition: iozone.c:1346
#define OPCODE_BUF
Definition: linux-bgq.h:48
static int allocated_opcode_events
Definition: linux-bgq.c:64
static struct bgq_generic_events_t * GenericEvent
Definition: linux-bgq.c:75
#define _AT_
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
#define OPCODE_EVENT_CHUNK
Definition: linux-bgq.c:63
char * name
Definition: iozone.c:23648
#define BGQ_PUNIT_MAX_COUNTERS
Definition: linux-bgq.h:45
uint64_t opcode_mask
Definition: linux-bgq.c:72
CUpti_EventID * eventId
Definition: linux-cuda.c:291
int _bgq_read ( hwd_context_t ctx,
hwd_control_state_t ptr,
long_long **  dp,
int  flags 
)

Definition at line 556 of file linux-bgq.c.

558 {
559 #ifdef DEBUG_BGQ
560  printf( "_bgq_read\n" );
561 #endif
562  ( void ) ctx;
563  ( void ) flags;
564  int i, numEvts;
565 
566  numEvts = Bgpm_NumEvents( ptr->EventGroup );
567  if ( numEvts == 0 ) {
568 #ifdef DEBUG_BGPM
569  printf ("Error: ret value is %d for BGPM API function Bgpm_NumEvents.\n", numEvts );
570  //return ( EXIT_FAILURE );
571 #endif
572  }
573 
574  for ( i = 0; i < numEvts; i++ )
575  ptr->counters[i] = _common_getEventValue( i, ptr->EventGroup );
576 
577  *dp = ptr->counters;
578 
579  return ( PAPI_OK );
580 }
long long flags
Definition: iozone.c:12330
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
int i
Definition: fileop.c:140
long_long _common_getEventValue(unsigned event_id, int EventGroup)
char ** counters
Definition: freebsd.h:59

Here is the call graph for this function:

int _bgq_reset ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

Definition at line 588 of file linux-bgq.c.

589 {
590 #ifdef DEBUG_BGQ
591  printf( "_bgq_reset\n" );
592 #endif
593  ( void ) ctx;
594  int retval;
595 
596  /* we can't simply call Bgpm_Reset() since PAPI doesn't have the
597  restriction that an EventSet has to be stopped before resetting is
598  possible. However, BGPM does have this restriction.
599  Hence we need to stop, reset and start */
600  retval = Bgpm_Stop( ptr->EventGroup );
601  retval = _check_BGPM_error( retval, "Bgpm_Stop" );
602  if ( retval < 0 ) return retval;
603 
604  retval = Bgpm_ResetStart( ptr->EventGroup );
605  retval = _check_BGPM_error( retval, "Bgpm_ResetStart" );
606  if ( retval < 0 ) return retval;
607 
608  return ( PAPI_OK );
609 }
int _check_BGPM_error(int err, char *bgpmfunc)
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int _bgq_set_domain ( hwd_control_state_t cntrl,
int  domain 
)

Definition at line 206 of file linux-bgq.c.

207 {
208 #ifdef DEBUG_BGQ
209  printf( "_bgq_set_domain\n" );
210 #endif
211  int found = 0;
212  ( void ) cntrl;
213 
214  if ( PAPI_DOM_USER & domain )
215  found = 1;
216 
217  if ( PAPI_DOM_KERNEL & domain )
218  found = 1;
219 
220  if ( PAPI_DOM_OTHER & domain )
221  found = 1;
222 
223  if ( !found )
224  return ( PAPI_EINVAL );
225 
226  return ( PAPI_OK );
227 }
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_DOM_OTHER
Definition: fpapi.h:23
#define PAPI_DOM_KERNEL
Definition: fpapi.h:22
void
Definition: iozone.c:18627
return PAPI_EINVAL
Definition: linux-nvml.c:408
#define printf
Definition: papi_test.h:125
long long found
Definition: libasync.c:735
#define PAPI_DOM_USER
Definition: fpapi.h:21
int _bgq_set_overflow ( EventSetInfo_t ESI,
int  EventIndex,
int  threshold 
)

Definition at line 776 of file linux-bgq.c.

777 {
778 #ifdef DEBUG_BGQ
779  printf("BEGIN _bgq_set_overflow\n");
780 #endif
781  hwd_control_state_t * this_state = ( hwd_control_state_t * ) ESI->ctl_state;
782  int retval;
783  int evt_idx;
784 
785  /*
786  * In case an BGPM eventGroup HAS BEEN applied or attached before
787  * overflow is set, delete the eventGroup and create an new empty one,
788  * and rebuild as it was prior to deletion
789  */
790 #ifdef DEBUG_BGQ
791  printf( "_bgq_set_overflow: bgpm_eventset_applied = %d, threshold = %d\n",
792  this_state->bgpm_eventset_applied, threshold );
793 #endif
794  if ( 1 == this_state->bgpm_eventset_applied && 0 != threshold ) {
795  retval = _common_deleteRecreate( &this_state->EventGroup );
796  if ( retval < 0 ) return retval;
797 
798  retval = _common_rebuildEventgroup( this_state->count,
799  this_state->EventGroup_local,
800  &this_state->EventGroup );
801  if ( retval < 0 ) return retval;
802 
803  /* set BGPM eventGroup flag back to NOT applied yet (0)
804  * because the eventGroup has been recreated from scratch */
805  this_state->bgpm_eventset_applied = 0;
806  }
807 
808 
809  evt_idx = ESI->EventInfoArray[EventIndex].pos[0];
810  //evt_id = ( ESI->NativeInfoArray[EventIndex].ni_event & PAPI_NATIVE_AND_MASK ) + 1;
811  SUBDBG( "Hardware counter %d (vs %d) used in overflow, threshold %d\n",
812  evt_idx, EventIndex, threshold );
813 #ifdef DEBUG_BGQ
814  printf( "Hardware counter %d (vs %d) used in overflow, threshold %d\n",
815  evt_idx, EventIndex, threshold );
816 #endif
817 
818  /* If this counter isn't set to overflow, it's an error */
819  if ( threshold == 0 ) {
820  /* Remove the signal handler */
822  if ( retval != PAPI_OK )
823  return ( retval );
824  }
825  else {
826  this_state->overflow = 1;
827  this_state->overflow_count++;
828  this_state->overflow_list[this_state->overflow_count-1].threshold = threshold;
829  this_state->overflow_list[this_state->overflow_count-1].EventIndex = evt_idx;
830 
831 #ifdef DEBUG_BGQ
832  printf( "_bgq_set_overflow: Enable the signal handler\n" );
833 #endif
834  /* Enable the signal handler */
836  NEED_CONTEXT,
838  if ( retval != PAPI_OK )
839  return ( retval );
840 
841  retval = _common_set_overflow_BGPM( this_state->EventGroup,
842  this_state->overflow_list[this_state->overflow_count-1].EventIndex,
843  this_state->overflow_list[this_state->overflow_count-1].threshold,
845  if ( retval < 0 ) return retval;
846  }
847 
848  return ( PAPI_OK );
849 }
void user_signal_handler(int hEvtSet, uint64_t address, uint64_t ovfVector, const ucontext_t *pContext)
Definition: linux-bgq.c:684
int _common_deleteRecreate(int *EventGroup_ptr)
papi_vector_t _bgq_vectors
Definition: linux-bgq.c:60
return PAPI_OK
Definition: linux-nvml.c:458
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
#define printf
Definition: papi_test.h:125
int _common_rebuildEventgroup(int count, int *EventGroup_local, int *EventGroup_ptr)
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
int _papi_hwi_start_signal(int signal, int need_context, int cidx)
Definition: extras.c:401
int _papi_hwi_stop_signal(int signal)
Definition: extras.c:441
EventInfo_t * EventInfoArray
int threshold
int _common_set_overflow_BGPM(int EventGroup, int evt_idx, int threshold, void(*handler)(int, uint64_t, uint64_t, const ucontext_t *))
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
#define NEED_CONTEXT
Definition: papi_internal.h:97
hwd_control_state_t * ctl_state
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int _bgq_set_profile ( EventSetInfo_t ESI,
int  EventIndex,
int  threshold 
)

Definition at line 858 of file linux-bgq.c.

859 {
860 #ifdef DEBUG_BGQ
861  printf("BEGIN _bgq_set_profile\n");
862 #endif
863 
864  ( void ) ESI;
865  ( void ) EventIndex;
866  ( void ) threshold;
867 
868  return PAPI_ECMP;
869 }
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
#define PAPI_ECMP
Definition: fpapi.h:109
int threshold
int _bgq_shutdown ( hwd_context_t ctx)

Definition at line 620 of file linux-bgq.c.

621 {
622 #ifdef DEBUG_BGQ
623  printf( "_bgq_shutdown\n" );
624 #endif
625  ( void ) ctx;
626  int retval;
627 
628  /* Disable BGPM library */
629  retval = Bgpm_Disable();
630  retval = _check_BGPM_error( retval, "Bgpm_Disable" );
631  if ( retval < 0 ) return retval;
632 
633  return ( PAPI_OK );
634 }
int _check_BGPM_error(int err, char *bgpmfunc)
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int _bgq_start ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

Definition at line 499 of file linux-bgq.c.

500 {
501 #ifdef DEBUG_BGQ
502  printf( "BEGIN _bgq_start\n" );
503 #endif
504  ( void ) ctx;
505  int retval;
506 
507  retval = Bgpm_Apply( ptr->EventGroup );
508  retval = _check_BGPM_error( retval, "Bgpm_Apply" );
509  if ( retval < 0 ) return retval;
510 
511  // set flag to 1: BGPM eventGroup HAS BEEN applied
512  ptr->bgpm_eventset_applied = 1;
513 
514 #ifdef DEBUG_BGQ
515  int i;
516  int numEvts = Bgpm_NumEvents( ptr->EventGroup );
517  for ( i = 0; i < numEvts; i++ ) {
518  printf("%d = %s\n", i, Bgpm_GetEventLabel( ptr->EventGroup, i) );
519  }
520 #endif
521 
522  /* Bgpm_Apply() does an implicit reset;
523  hence no need to use Bgpm_ResetStart */
524  retval = Bgpm_Start( ptr->EventGroup );
525  retval = _check_BGPM_error( retval, "Bgpm_Start" );
526  if ( retval < 0 ) return retval;
527 
528  return ( PAPI_OK );
529 }
int _check_BGPM_error(int err, char *bgpmfunc)
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
int i
Definition: fileop.c:140
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int _bgq_stop ( hwd_context_t ctx,
hwd_control_state_t ptr 
)

Definition at line 535 of file linux-bgq.c.

536 {
537 #ifdef DEBUG_BGQ
538  printf( "BEGIN _bgq_stop\n" );
539 #endif
540  ( void ) ctx;
541  int retval;
542 
543  retval = Bgpm_Stop( ptr->EventGroup );
544  retval = _check_BGPM_error( retval, "Bgpm_Stop" );
545  if ( retval < 0 ) return retval;
546 
547  return ( PAPI_OK );
548 }
int _check_BGPM_error(int err, char *bgpmfunc)
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

int _bgq_stop_profiling ( ThreadInfo_t master,
EventSetInfo_t ESI 
)

Definition at line 877 of file linux-bgq.c.

878 {
879 #ifdef DEBUG_BGQ
880  printf("BEGIN _bgq_stop_profiling\n");
881 #endif
882 
883  ( void ) master;
884  ( void ) ESI;
885 
886  return ( PAPI_OK );
887 }
return PAPI_OK
Definition: linux-nvml.c:458
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
int _bgq_update_control_state ( hwd_control_state_t ptr,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)

Definition at line 377 of file linux-bgq.c.

380 {
381 #ifdef DEBUG_BGQ
382  printf( _AT_ " _bgq_update_control_state: count = %d, EventGroup=%d\n", count, ptr->EventGroup );
383 #endif
384  ( void ) ctx;
385  int i, j, k, index, retval;
386  unsigned evtIdx;
387 
388  // Delete and re-create BGPM eventset
389  retval = _common_deleteRecreate( &ptr->EventGroup );
390  if ( retval < 0 ) return retval;
391 
392 #ifdef DEBUG_BGQ
393  printf( _AT_ " _bgq_update_control_state: EventGroup=%d, muxOn = %d, overflow = %d\n",
394  ptr->EventGroup, ptr->muxOn, ptr->overflow );
395 #endif
396 
397  // add the events to the eventset
398  for ( i = 0; i < count; i++ ) {
399  index = ( native[i].ni_event & PAPI_NATIVE_AND_MASK ) + 1;
400 
401  ptr->EventGroup_local[i] = index;
402 
403  // we found an opcode event
404  if ( index > BGQ_PUNIT_MAX_COUNTERS ) {
405  for( j = 0; j < num_opcode_events; j++ ) {
406 #ifdef DEBUG_BGQ
407  printf(_AT_ " _bgq_update_control_state: %d out of %d OPCODES\n",
408  j, num_opcode_events );
409 #endif
410 #ifdef DEBUG_BGQ
411  printf(_AT_ " _bgq_update_control_state: j's idx = %d, index = %d\n",
412  GenericEvent[j].idx, index );
413 #endif
414  if ( GenericEvent[j].idx == ( index - 1) ) {
415  /* Add events to the BGPM eventGroup */
416  retval = Bgpm_AddEvent( ptr->EventGroup, GenericEvent[j].eventId );
417  retval = _check_BGPM_error( retval, "Bgpm_AddEvent" );
418  if ( retval < 0 ) return retval;
419 #ifdef DEBUG_BGQ
420  printf(_AT_ " _bgq_update_control_state: ADD event: i = %d, eventId = %d\n", i, GenericEvent[j].eventId );
421 #endif
422 
423  evtIdx = Bgpm_GetEventIndex( ptr->EventGroup,
425  i );
426 #ifdef DEBUG_BGQ
427  printf(_AT_ " _bgq_update_control_state: evtIdx in EventGroup = %d\n",
428  evtIdx );
429 #endif
430  if ( 0 == strcmp( GenericEvent[j].mask, "PEVT_INST_XU_GRP_MASK" ) ) {
431  retval = Bgpm_SetXuGrpMask( ptr->EventGroup,
432  evtIdx,
434  retval = _check_BGPM_error( retval, "Bgpm_SetXuGrpMask" );
435  if ( retval < 0 ) return retval;
436 #ifdef DEBUG_BGQ
437  printf(_AT_ " _bgq_update_control_state: it's PEVT_INST_XU_GRP_MASK\n" );
438 #endif
439  } else if ( 0 == strcmp( GenericEvent[j].mask, "PEVT_INST_QFPU_GRP_MASK" ) ) {
440  retval = Bgpm_SetQfpuGrpMask( ptr->EventGroup,
441  evtIdx,
443  retval = _check_BGPM_error( retval, "Bgpm_SetQfpuGrpMask" );
444  if ( retval < 0 ) return retval;
445 #ifdef DEBUG_BGQ
446  printf(_AT_ " _bgq_update_control_state: it's PEVT_INST_QFPU_GRP_MASK\n" );
447 #endif
448  }
449  }
450  }
451  }
452  else {
453 #ifdef DEBUG_BGQ
454  printf(_AT_ " _bgq_update_control_state: no OPCODE\n" );
455 #endif
456 
457  /* Add events to the BGPM eventGroup */
458  retval = Bgpm_AddEvent( ptr->EventGroup, index );
459  retval = _check_BGPM_error( retval, "Bgpm_AddEvent" );
460  if ( retval < 0 ) return retval;
461 #ifdef DEBUG_BGQ
462  printf(_AT_ " _bgq_update_control_state: ADD event: i = %d, index = %d\n", i, index );
463 #endif
464 
465  }
466  }
467 
468  // store how many events we added to an EventSet
469  ptr->count = count;
470 
471  // if muxOn and EventGroup is not empty -- which is required by BGPM before
472  // we can call SetMultiplex() -- then drain the events from the
473  // BGPM EventGroup, turn on multiplex flag, and rebuild BGPM EventGroup.
474  if ( 1 == ptr->muxOn ) {
475  retval = _bgq_multiplex( ptr );
476  }
477 
478  // since update_control_state trashes overflow settings, this puts things
479  // back into balance for BGPM
480  if ( 1 == ptr->overflow ) {
481  for ( k = 0; k < ptr->overflow_count; k++ ) {
482  retval = _common_set_overflow_BGPM( ptr->EventGroup,
483  ptr->overflow_list[k].EventIndex,
484  ptr->overflow_list[k].threshold,
486  if ( retval < 0 ) return retval;
487  }
488  }
489 
490  return ( PAPI_OK );
491 }
void user_signal_handler(int hEvtSet, uint64_t address, uint64_t ovfVector, const ucontext_t *pContext)
Definition: linux-bgq.c:684
int _common_deleteRecreate(int *EventGroup_ptr)
int _check_BGPM_error(int err, char *bgpmfunc)
int _bgq_multiplex(hwd_control_state_t *bgq_state)
Definition: linux-bgq.c:262
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
static int num_opcode_events
Definition: linux-bgq.c:65
int i
Definition: fileop.c:140
static struct bgq_generic_events_t * GenericEvent
Definition: linux-bgq.c:75
int k
Definition: iozone.c:19136
#define _AT_
int _common_set_overflow_BGPM(int EventGroup, int evt_idx, int threshold, void(*handler)(int, uint64_t, uint64_t, const ucontext_t *))
#define PAPI_NATIVE_AND_MASK
#define BGQ_PUNIT_MAX_COUNTERS
Definition: linux-bgq.h:45
long j
Definition: iozone.c:19135
uint64_t opcode_mask
Definition: linux-bgq.c:72
ssize_t retval
Definition: libasync.c:338
CUpti_EventID * eventId
Definition: linux-cuda.c:291

Here is the call graph for this function:

int _bgq_write ( hwd_context_t ctx,
hwd_control_state_t cntrl,
long_long from 
)

Definition at line 643 of file linux-bgq.c.

644 {
645 #ifdef DEBUG_BGQ
646  printf( "_bgq_write\n" );
647 #endif
648  ( void ) ctx;
649  ( void ) cntrl;
650  ( void ) from;
651 
652  return PAPI_ECMP;
653 }
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
#define PAPI_ECMP
Definition: fpapi.h:109
void _papi_hwd_lock ( int  lock)

Definition at line 93 of file linux-bgq.c.

94 {
95 #ifdef DEBUG_BGQ
96  printf( _AT_ " _papi_hwd_lock %d\n", lock);
97 #endif
98  assert( lock < PAPI_MAX_LOCK );
99 #if 1
100  UPC_Lock( &thdLocks[lock] );
101 #else
102  pthread_mutex_lock( &thdLocks[lock] );
103 #endif
104 
105 #ifdef DEBUG_BGQ
106  printf( _AT_ " _papi_hwd_lock got lock %d\n", lock );
107 #endif
108 
109  return;
110 }
#define printf
Definition: papi_test.h:125
#define PAPI_MAX_LOCK
Definition: papi_lock.h:18
#define _AT_
atomic_p lock[]
Definition: aix.c:25
UPC_Lock_t thdLocks[PAPI_MAX_LOCK]
Definition: linux-bgq.c:52
void _papi_hwd_unlock ( int  lock)

Definition at line 116 of file linux-bgq.c.

117 {
118 #ifdef DEBUG_BGQ
119  printf( _AT_ " _papi_hwd_unlock %d\n", lock );
120 #endif
121  assert( lock < PAPI_MAX_LOCK );
122 #if 1
123  UPC_Unlock( &thdLocks[lock] );
124 #else
125  pthread_mutex_unlock( &thdLocks[lock] );
126 #endif
127 
128  return;
129 }
#define printf
Definition: papi_test.h:125
#define PAPI_MAX_LOCK
Definition: papi_lock.h:18
#define _AT_
atomic_p lock[]
Definition: aix.c:25
UPC_Lock_t thdLocks[PAPI_MAX_LOCK]
Definition: linux-bgq.c:52
int _papi_hwi_init_os ( void  )

Definition at line 1269 of file linux-bgq.c.

1269  {
1270 
1271  struct utsname uname_buffer;
1272 
1273  /* Get the kernel info */
1274  uname(&uname_buffer);
1275 
1276  strncpy(_papi_os_info.name,uname_buffer.sysname,PAPI_MAX_STR_LEN);
1277 
1278  strncpy(_papi_os_info.version,uname_buffer.release,PAPI_MAX_STR_LEN);
1279 
1283 
1284  return PAPI_OK;
1285 }
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
return PAPI_OK
Definition: linux-nvml.c:458
char name[PAPI_MAX_STR_LEN]
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
#define PAPI_INT_ITIMER
Definition: papi_internal.h:54
char version[PAPI_MAX_STR_LEN]
#define PAPI_INT_MPX_SIGNAL
Definition: papi_internal.h:52
void user_signal_handler ( int  hEvtSet,
uint64_t  address,
uint64_t  ovfVector,
const ucontext_t *  pContext 
)

Definition at line 684 of file linux-bgq.c.

685 {
686 #ifdef DEBUG_BGQ
687  printf( "user_signal_handler start\n" );
688 #endif
689  ( void ) address;
690  int retval;
691  unsigned i;
692  int isHardware = 1;
694  long_long overflow_bit = 0;
695  caddr_t address1;
697  ctx.ucontext = ( hwd_ucontext_t * ) pContext;
699 
700  //printf(_AT_ " thread = %p\n", thread); // <<<<<<<<<<<<<<<<<<
701 
702  EventSetInfo_t *ESI;
703  ESI = thread->running_eventset[cidx];
704  // Get the indices of all events which have overflowed.
705  unsigned ovfIdxs[BGPM_MAX_OVERFLOW_EVENTS];
706  unsigned len = BGPM_MAX_OVERFLOW_EVENTS;
707 
708  retval = Bgpm_GetOverflowEventIndices( hEvtSet, ovfVector, ovfIdxs, &len );
709 
710  if ( retval < 0 ) {
711 #ifdef DEBUG_BGPM
712  printf ( "Error: ret value is %d for BGPM API function Bgpm_GetOverflowEventIndices.\n",
713  retval );
714 #endif
715  return;
716  }
717 
718  if ( thread == NULL ) {
719  PAPIERROR( "thread == NULL in user_signal_handler!" );
720  return;
721  }
722 
723  if ( ESI == NULL ) {
724  PAPIERROR( "ESI == NULL in user_signal_handler!");
725  return;
726  }
727 
728  if ( ESI->overflow.flags == 0 ) {
729  PAPIERROR( "ESI->overflow.flags == 0 in user_signal_handler!");
730  return;
731  }
732 
733  for ( i = 0; i < len; i++ ) {
734  uint64_t hProf;
735  Bgpm_GetEventUser1( hEvtSet, ovfIdxs[i], &hProf );
736  if ( hProf ) {
737  overflow_bit ^= 1 << ovfIdxs[i];
738  break;
739  }
740 
741  }
742 
743  if ( ESI->overflow.flags & PAPI_OVERFLOW_FORCE_SW ) {
744 #ifdef DEBUG_BGQ
745  printf("OVERFLOW_SOFTWARE\n");
746 #endif
747  address1 = GET_OVERFLOW_ADDRESS( ctx );
748  _papi_hwi_dispatch_overflow_signal( ( void * ) &ctx, address1, NULL, 0, 0, &thread, cidx );
749  return;
750  }
751  else if ( ESI->overflow.flags & PAPI_OVERFLOW_HARDWARE ) {
752 #ifdef DEBUG_BGQ
753  printf("OVERFLOW_HARDWARE\n");
754 #endif
755  address1 = GET_OVERFLOW_ADDRESS( ctx );
756  _papi_hwi_dispatch_overflow_signal( ( void * ) &ctx, address1, &isHardware, overflow_bit, 0, &thread, cidx );
757  }
758  else {
759 #ifdef DEBUG_BGQ
760  printf("OVERFLOW_NONE\n");
761 #endif
762  PAPIERROR( "ESI->overflow.flags is set to something other than PAPI_OVERFLOW_HARDWARE or PAPI_OVERFLOW_FORCE_SW (%#x)", thread->running_eventset[cidx]->overflow.flags);
763  }
764 }
papi_vector_t _bgq_vectors
Definition: linux-bgq.c:60
void
Definition: iozone.c:18627
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
#define printf
Definition: papi_test.h:125
int i
Definition: fileop.c:140
EventSetOverflowInfo_t overflow
#define PAPI_OVERFLOW_HARDWARE
Definition: papi.h:410
static int cidx
Definition: event_info.c:40
hwd_ucontext_t * ucontext
void * thread(void *arg)
Definition: kufrin.c:31
void PAPIERROR(char *format,...)
struct sigcontext hwd_ucontext_t
Definition: aix-context.h:10
#define PAPI_OVERFLOW_FORCE_SW
Definition: papi.h:409
EventSetInfo_t ** running_eventset
Definition: threads.h:30
#define long_long
Definition: papi.h:549
inline_static ThreadInfo_t * _papi_hwi_lookup_thread(int custom_tid)
Definition: threads.h:92
int _papi_hwi_dispatch_overflow_signal(void *papiContext, caddr_t address, int *isHardware, long long overflow_bit, int genOverflowBit, ThreadInfo_t **t, int cidx)
Definition: extras.c:214
ssize_t retval
Definition: libasync.c:338
#define GET_OVERFLOW_ADDRESS(ctx)
Definition: aix-context.h:12

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

papi_vector_t _bgq_vectors

Definition at line 60 of file linux-bgq.c.

PAPI_os_info_t _papi_os_info

Definition at line 61 of file linux-bgq.c.

papi_os_vector_t _papi_os_vector
Initial value:
= {
.get_memory_info = _bgq_get_memory_info,
.get_dmem_info = _bgq_get_dmem_info,
.get_real_cycles = _bgq_get_real_cycles,
.get_real_usec = _bgq_get_real_usec,
.get_virt_cycles = _bgq_get_virt_cycles,
.get_virt_usec = _bgq_get_virt_usec,
.get_system_info = _bgq_get_system_info
}
long long _bgq_get_virt_cycles(void)
Definition: linux-bgq.c:973
long long _bgq_get_real_usec(void)
Definition: linux-bgq.c:920
long long _bgq_get_virt_usec(void)
Definition: linux-bgq.c:958
int _bgq_get_memory_info(PAPI_hw_info_t *pHwInfo, int pCPU_Type)
int _bgq_get_system_info(papi_mdi_t *mdi)
Definition: linux-bgq.c:138
long long _bgq_get_real_cycles(void)
Definition: linux-bgq.c:942
int _bgq_get_dmem_info(PAPI_dmem_info_t *pDmemInfo)

Definition at line 1350 of file linux-bgq.c.

int allocated_opcode_events = 0
static

Definition at line 64 of file linux-bgq.c.

struct bgq_generic_events_t* GenericEvent
static

Definition at line 75 of file linux-bgq.c.

int num_opcode_events = 0
static

Definition at line 65 of file linux-bgq.c.

UPC_Lock_t thdLocks[PAPI_MAX_LOCK]

Definition at line 52 of file linux-bgq.c.