PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
linux-bgq.c
Go to the documentation of this file.
1 /****************************/
2 /* THIS IS OPEN SOURCE CODE */
3 /****************************/
4 
20 #include "papi.h"
21 #include "papi_internal.h"
22 #include "papi_lock.h"
23 #include "papi_memory.h"
24 #include "extras.h"
25 
26 #include "linux-bgq.h"
27 
28 #include "papi_vector.h"
29 #include "error.h"
30 
31 /*
32  * BG/Q specific 'stuff'
33  */
34 #include <ucontext.h>
35 #include <stdlib.h>
36 #include <signal.h>
37 #include <sys/time.h>
38 #include <errno.h>
39 #include <stdio.h>
40 #include <string.h>
41 #include <sys/utsname.h>
42 #include "spi/include/upci/upci.h"
43 #ifdef DEBUG_BGQ
44 #include <inttypes.h>
45 #endif
46 
47 // BG/Q macros
48 #define get_cycles GetTimeBase
49 
50 // BG/Q external structures/functions/stuff
51 #if 1
52 UPC_Lock_t thdLocks[PAPI_MAX_LOCK];
53 #else
54 pthread_mutex_t thdLocks[PAPI_MAX_LOCK];
55 #endif
56 
57 /* Defined in papi_data.c */
58 //extern papi_mdi_t _papi_hwi_system_info;
59 
62 
63 #define OPCODE_EVENT_CHUNK 8
64 static int allocated_opcode_events = 0;
65 static int num_opcode_events = 0;
66 
68  int idx;
69  int eventId;
72  uint64_t opcode_mask;
73 };
74 
76 
77 /* Defined in linux-bgq-memory.c */
78 extern int _bgq_get_memory_info( PAPI_hw_info_t * pHwInfo, int pCPU_Type );
79 extern int _bgq_get_dmem_info( PAPI_dmem_info_t * pDmemInfo );
80 
81 /* prototypes */
82 void user_signal_handler( int hEvtSet, uint64_t address, uint64_t ovfVector, const ucontext_t *pContext );
83 
84 /*******************************************************************************
85  ******** BEGIN FUNCTIONS USED INTERNALLY SPECIFIC TO THIS COMPONENT **********
86  ******************************************************************************/
87 
88 
89 /*
90  * Lock
91  */
92 void
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 }
111 
112 /*
113  * Unlock
114  */
115 void
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 }
130 
131 
132 /*
133  * Get System Information
134  *
135  * Initialize system information structure
136  */
137 int
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 }
172 
173 
174 /*
175  * Initialize Control State
176  *
177  */
178 int
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 }
200 
201 
202 /*
203  * Set Domain
204  */
205 int
206 _bgq_set_domain( hwd_control_state_t * cntrl, int domain )
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 }
228 
229 /*
230  * PAPI Initialization
231  * This is called whenever a thread is initialized
232  */
233 int
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 }
259 
260 
261 int
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 }
313 
314 
315 
316 
317 
318 /*
319  * Register Allocation
320  *
321  */
322 int
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 }
343 
344 
345 /*
346  * PAPI Cleanup Eventset
347  *
348  * Destroy and re-create the BGPM / Punit EventSet
349  */
350 int
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 }
367 
368 
369 /*
370  * Update Control State
371  *
372  * This function clears the current contents of the control
373  * structure and updates it with whatever resources are allocated
374  * for all the native events in the native info structure array.
375  */
376 int
378  NativeInfo_t * native, int count,
379  hwd_context_t * ctx )
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_EVENTS ) {
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,
424  GenericEvent[j].eventId,
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,
433  GenericEvent[j].opcode_mask );
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,
442  GenericEvent[j].opcode_mask );
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 }
492 
493 
494 
495 /*
496  * PAPI Start
497  */
498 int
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 }
530 
531 /*
532  * PAPI Stop
533  */
534 int
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 }
549 
550 /*
551  * PAPI Read Counters
552  *
553  * Read the counters into local storage
554  */
555 int
557  long_long ** dp, int flags )
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 }
581 
582 /*
583  * PAPI Reset
584  *
585  * Zero the counter values
586  */
587 int
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 }
610 
611 
612 /*
613  * PAPI Shutdown
614  *
615  * This routine is for shutting down threads,
616  * including the master thread.
617  * Effectively a no-op, same as BG/L/P...
618  */
619 int
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 }
635 
636 /*
637  * PAPI Write
638  *
639  * Write counter values
640  * NOTE: Could possible support, but signal error as BG/L/P does...
641  */
642 int
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 }
654 
655 /*
656  * Dispatch Timer
657  *
658  * NOT the same as BG/L/P where we simply return
659  * This function is used when hardware overflows are working or when
660  * software overflows are forced
661  */
662 void
663 _bgq_dispatch_timer( int signal, hwd_siginfo_t * info, void *uc )
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 }
674 
675 
676 
677 /*
678  * user_signal_handler
679  *
680  * This function is used when hardware overflows are working or when
681  * software overflows are forced
682  */
683 void
684 user_signal_handler( int hEvtSet, uint64_t address, uint64_t ovfVector, const ucontext_t *pContext )
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;
693  int cidx = _bgq_vectors.cmp_info.CmpIdx;
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 }
765 
766 
767 /*
768  * Set Overflow
769  *
770  * This is commented out in BG/L/P - need to explore and complete...
771  * However, with true 64-bit counters in BG/Q and all counters for PAPI
772  * always starting from a true zero (we don't allow write...), the possibility
773  * for overflow is remote at best...
774  */
775 int
776 _bgq_set_overflow( EventSetInfo_t * ESI, int EventIndex, int threshold )
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,
837  _bgq_vectors.cmp_info.CmpIdx );
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 }
850 
851 
852 /*
853  * Set Profile
854  *
855  * Same as for BG/L/P, routine not used and returns error
856  */
857 int
858 _bgq_set_profile( EventSetInfo_t * ESI, int EventIndex, int threshold )
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 }
870 
871 /*
872  * Stop Profiling
873  *
874  * Same as for BG/L/P...
875  */
876 int
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 }
888 
889 /*
890  * PAPI Control
891  *
892  * Same as for BG/L/P - initialize the domain
893  */
894 int
895 _bgq_ctl( hwd_context_t * ctx, int code, _papi_int_option_t * option )
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 }
915 
916 /*
917  * Get Real Micro-seconds
918  */
919 long long
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 }
935 
936 /*
937  * Get Real Cycles
938  *
939  * Same for BG/L/P, using native function...
940  */
941 long long
943 {
944 #ifdef DEBUG_BGQ
945  printf( "_bgq_get_real_cycles\n" );
946 #endif
947 
948  return ( ( long long ) get_cycles( ) );
949 
950 }
951 
952 /*
953  * Get Virtual Micro-seconds
954  *
955  * Same calc as for BG/L/P, returns real usec...
956  */
957 long long
959 {
960 #ifdef DEBUG_BGQ
961  printf( "_bgq_get_virt_usec\n" );
962 #endif
963 
964  return _bgq_get_real_usec( );
965 }
966 
967 /*
968  * Get Virtual Cycles
969  *
970  * Same calc as for BG/L/P, returns real cycles...
971  */
972 long long
974 {
975 #ifdef DEBUG_BGQ
976  printf( "_bgq_get_virt_cycles\n" );
977 #endif
978 
979  return _bgq_get_real_cycles( );
980 }
981 
982 /*
983  * Component setup and shutdown
984  *
985  * Initialize hardware counters, setup the function vector table
986  * and get hardware information, this routine is called when the
987  * PAPI process is initialized (IE PAPI_library_init)
988  */
989 int
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 
1009  _bgq_vectors.cmp_info.CmpIdx = cidx;
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 }
1050 
1051 
1052 /*************************************/
1053 /* CODE TO SUPPORT OPAQUE NATIVE MAP */
1054 /*************************************/
1055 
1056 /*
1057  * Event Name to Native Code
1058  */
1059 int
1060 _bgq_ntv_name_to_code( char *name, unsigned int *event_code )
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 = %#lX (%lu)\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_EVENTS ) // not a PUnit event
1146  return PAPI_ENOEVNT;
1147  else
1148  *event_code = ( ret - 1 );
1149  }
1150 
1151  return PAPI_OK;
1152 }
1153 
1154 
1155 /*
1156  * Native Code to Event Name
1157  *
1158  * Given a native event code, returns the short text label
1159  */
1160 int
1161 _bgq_ntv_code_to_name( unsigned int EventCode, char *name, int len )
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 }
1185 
1186 /*
1187  * Native Code to Event Description
1188  *
1189  * Given a native event code, returns the longer native event description
1190  */
1191 int
1192 _bgq_ntv_code_to_descr( unsigned int EventCode, char *name, int len )
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 }
1206 
1207 /*
1208  * Native Code to Bit Configuration
1209  *
1210  * Given a native event code, assigns the native event's
1211  * information to a given pointer.
1212  * NOTE: The info must be COPIED to location addressed by
1213  * the provided pointer, not just referenced!
1214  * NOTE: For BG/Q, the bit configuration is not needed,
1215  * as the native SPI is used to configure events.
1216  */
1217 int
1218 _bgq_ntv_code_to_bits( unsigned int EventCode, hwd_register_t * bits )
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 }
1229 
1230 /*
1231  * Native ENUM Events
1232  *
1233  */
1234 int
1235 _bgq_ntv_enum_events( unsigned int *EventCode, int modifier )
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_EVENTS ) {
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 }
1266 
1267 
1268 int
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 
1280  _papi_os_info.itimer_sig = PAPI_INT_MPX_SIGNAL;
1281  _papi_os_info.itimer_num = PAPI_INT_ITIMER;
1282  _papi_os_info.itimer_res_ns = 1;
1283 
1284  return PAPI_OK;
1285 }
1286 
1287 
1288 /*
1289  * PAPI Vector Table for BG/Q
1290  */
1291 papi_vector_t _bgq_vectors = {
1292  .cmp_info = {
1293  /* Default component information (unspecified values are initialized to 0) */
1294  .name = "linux-bgq",
1295  .short_name = "bgq",
1296  .description = "Blue Gene/Q component",
1297  .num_cntrs = BGQ_PUNIT_MAX_COUNTERS,
1298  .num_mpx_cntrs = BGQ_PUNIT_MAX_COUNTERS,
1299  .num_native_events = BGQ_PUNIT_MAX_EVENTS,
1300  .default_domain = PAPI_DOM_USER,
1301  .available_domains = PAPI_DOM_USER | PAPI_DOM_KERNEL,
1302  .default_granularity = PAPI_GRN_THR,
1303  .available_granularities = PAPI_GRN_THR,
1304  .hardware_intr_sig = PAPI_INT_SIGNAL,
1305  .hardware_intr = 1,
1306  .kernel_multiplex = 1,
1307 
1308  /* component specific cmp_info initializations */
1309  .fast_real_timer = 1,
1310  .fast_virtual_timer = 0,
1311  }
1312  ,
1313 
1314  /* Sizes of framework-opaque component-private structures */
1315  .size = {
1316  .context = sizeof ( hwd_context_t ),
1317  .control_state = sizeof ( hwd_control_state_t ),
1318  .reg_value = sizeof ( hwd_register_t ),
1319  .reg_alloc = sizeof ( hwd_reg_alloc_t ),
1320  }
1321  ,
1322  /* Function pointers in this component */
1323 // .get_overflow_address =
1324  .start = _bgq_start,
1325  .stop = _bgq_stop,
1326  .read = _bgq_read,
1327  .reset = _bgq_reset,
1328  .write = _bgq_write,
1329  .stop_profiling = _bgq_stop_profiling,
1330  .init_component = _bgq_init_component,
1331  .init_thread = _bgq_init,
1332  .init_control_state = _bgq_init_control_state,
1333  .update_control_state = _bgq_update_control_state,
1334  .ctl = _bgq_ctl,
1335  .set_overflow = _bgq_set_overflow,
1336  //.dispatch_timer = _bgq_dispatch_timer,
1337  .set_profile = _bgq_set_profile,
1338  .set_domain = _bgq_set_domain,
1339  .ntv_enum_events = _bgq_ntv_enum_events,
1340  .ntv_name_to_code = _bgq_ntv_name_to_code,
1341  .ntv_code_to_name = _bgq_ntv_code_to_name,
1342  .ntv_code_to_descr = _bgq_ntv_code_to_descr,
1343  .ntv_code_to_bits = _bgq_ntv_code_to_bits,
1344  .allocate_registers = _bgq_allocate_registers,
1345  .cleanup_eventset = _bgq_cleanup_eventset,
1346  .shutdown_thread = _bgq_shutdown
1347 // .shutdown_global =
1348 // .user =
1349 };
1350 
1353  .get_dmem_info = _bgq_get_dmem_info,
1354  .get_real_cycles = _bgq_get_real_cycles,
1355  .get_real_usec = _bgq_get_real_usec,
1356  .get_virt_cycles = _bgq_get_virt_cycles,
1357  .get_virt_usec = _bgq_get_virt_usec,
1358  .get_system_info = _bgq_get_system_info
1359 };
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:626
#define PAPI_ENOEVNT
Definition: papi.h:258
int _bgq_shutdown(hwd_context_t *ctx)
Definition: linux-bgq.c:620
#define PAPI_NATIVE_MASK
int errno
int _bgq_ntv_code_to_bits(unsigned int EventCode, hwd_register_t *bits)
Definition: linux-bgq.c:1218
Hardware info structure.
Definition: papi.h:777
This file has the source code for a component that enables PAPI-C to access hardware monitoring count...
long long flags
Definition: iozone.c:12330
long long _bgq_get_virt_cycles(void)
Definition: linux-bgq.c:973
char mask[PAPI_MIN_STR_LEN]
Definition: linux-bgq.c:70
void user_signal_handler(int hEvtSet, uint64_t address, uint64_t ovfVector, const ucontext_t *pContext)
Definition: linux-bgq.c:684
int cpu_min_mhz
Definition: papi.h:794
#define PAPI_DOM_KERNEL
Definition: papi.h:298
int _common_deleteRecreate(int *EventGroup_ptr)
int _check_BGPM_error(int err, char *bgpmfunc)
void _bgq_dispatch_timer(int signal, hwd_siginfo_t *info, void *uc)
Definition: linux-bgq.c:663
int _bgq_multiplex(hwd_control_state_t *bgq_state)
Definition: linux-bgq.c:262
char opcode[PAPI_MIN_STR_LEN]
Definition: linux-bgq.c:71
#define MAX_COUNTERS
Definition: perfctr-x86.h:8
papi_vector_t _bgq_vectors
Definition: linux-bgq.c:60
return PAPI_OK
Definition: linux-nvml.c:458
int count
Definition: iozone.c:22422
#define BGQ_PUNIT_MAX_EVENTS
Definition: linux-bgq.h:46
int _bgq_ntv_enum_events(unsigned int *EventCode, int modifier)
Definition: linux-bgq.c:1235
#define PAPI_DOM_USER
Definition: papi.h:296
void
Definition: iozone.c:18627
return PAPI_EINVAL
Definition: linux-nvml.c:408
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
int _bgq_read(hwd_context_t *ctx, hwd_control_state_t *ptr, long_long **dp, int flags)
Definition: linux-bgq.c:556
#define printf
Definition: papi_test.h:125
static double
Definition: fileop.c:1281
int _bgq_init_component(int cidx)
Definition: linux-bgq.c:990
int _bgq_ntv_code_to_descr(unsigned int EventCode, char *name, int len)
Definition: linux-bgq.c:1192
Return codes and api definitions.
#define PAPI_MAX_LOCK
Definition: papi_lock.h:18
char name[PAPI_MAX_STR_LEN]
static int num_opcode_events
Definition: linux-bgq.c:65
long long ret
Definition: iozone.c:1346
#define OPCODE_BUF
Definition: linux-bgq.h:49
static int allocated_opcode_events
Definition: linux-bgq.c:64
int _bgq_reset(hwd_context_t *ctx, hwd_control_state_t *ptr)
Definition: linux-bgq.c:588
float mhz
Definition: papi.h:804
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288
int i
Definition: fileop.c:140
EventSetOverflowInfo_t overflow
#define PAPI_OVERFLOW_HARDWARE
Definition: papi.h:410
int _bgq_update_control_state(hwd_control_state_t *ptr, NativeInfo_t *native, int count, hwd_context_t *ctx)
Definition: linux-bgq.c:377
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
A pointer to the following is passed to PAPI_get_dmem_info()
Definition: papi.h:868
static struct bgq_generic_events_t * GenericEvent
Definition: linux-bgq.c:75
long long found
Definition: libasync.c:735
long long _bgq_get_real_usec(void)
Definition: linux-bgq.c:920
static int cidx
Definition: event_info.c:40
int k
Definition: iozone.c:19136
#define hwd_context_t
int _common_rebuildEventgroup(int count, int *EventGroup_local, int *EventGroup_ptr)
hwd_ucontext_t * ucontext
#define PAPI_ESYS
Definition: papi.h:253
static int native
Definition: event_info.c:39
int _bgq_cleanup_eventset(hwd_control_state_t *ctrl)
Definition: linux-bgq.c:351
long long _bgq_get_virt_usec(void)
Definition: linux-bgq.c:958
void * thread(void *arg)
Definition: kufrin.c:31
int _bgq_set_profile(EventSetInfo_t *ESI, int EventIndex, int threshold)
Definition: linux-bgq.c:858
#define _AT_
#define _papi_hwd_unlock(lck)
Definition: aix-lock.h:11
int _bgq_stop(hwd_context_t *ctx, hwd_control_state_t *ptr)
Definition: linux-bgq.c:535
#define SUBDBG(format, args...)
Definition: papi_debug.h:63
#define PAPI_INT_ITIMER
Definition: papi_internal.h:54
int nnodes
Definition: papi.h:782
void PAPIERROR(char *format,...)
int _papi_hwi_start_signal(int signal, int need_context, int cidx)
Definition: extras.c:401
char version[PAPI_MAX_STR_LEN]
#define PAPI_ECMP
Definition: papi.h:254
long_long _common_getEventValue(unsigned event_id, int EventGroup)
int _bgq_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
Definition: linux-bgq.c:895
int _bgq_ntv_code_to_name(unsigned int EventCode, char *name, int len)
Definition: linux-bgq.c:1161
#define PAPI_INT_SIGNAL
Definition: papi_internal.h:53
int _bgq_stop_profiling(ThreadInfo_t *master, EventSetInfo_t *ESI)
Definition: linux-bgq.c:877
int _papi_load_preset_table(char *pmu_str, int pmu_type, int cidx)
Definition: papi_preset.c:299
#define PAPI_MULTIPLEX
Definition: papi.h:429
int _papi_hwi_stop_signal(int signal)
Definition: extras.c:441
#define PAPI_GRN_THR
Definition: papi.h:360
_papi_int_multiplex_t multiplex
char ** counters
Definition: freebsd.h:59
int _bgq_get_memory_info(PAPI_hw_info_t *pHwInfo, int pCPU_Type)
NativeInfo_t * NativeInfoArray
EventInfo_t * EventInfoArray
#define PAPI_ENOMEM
Definition: papi.h:252
int _bgq_write(hwd_context_t *ctx, hwd_control_state_t *cntrl, long_long *from)
Definition: linux-bgq.c:643
#define PAPI_INT_MPX_SIGNAL
Definition: papi_internal.h:52
atomic_p lock[]
Definition: aix.c:25
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 _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
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
int _bgq_set_overflow(EventSetInfo_t *ESI, int EventIndex, int threshold)
Definition: linux-bgq.c:776
#define get_cycles
Definition: linux-bgq.c:48
int _bgq_allocate_registers(EventSetInfo_t *ESI)
Definition: linux-bgq.c:323
struct sigcontext hwd_ucontext_t
Definition: aix-context.h:10
#define OPCODE_EVENT_CHUNK
Definition: linux-bgq.c:63
int _papi_hwi_init_os(void)
Definition: aix.c:1213
#define PAPI_OVERFLOW_FORCE_SW
Definition: papi.h:409
EventSetInfo_t ** running_eventset
Definition: threads.h:30
int _bgq_set_domain(hwd_control_state_t *cntrl, int domain)
Definition: linux-bgq.c:206
char * name
Definition: iozone.c:23648
#define NEED_CONTEXT
Definition: papi_internal.h:97
int cpu_max_mhz
Definition: papi.h:793
#define PAPI_MIN_STR_LEN
Definition: papi.h:462
#define long_long
Definition: papi.h:550
int _bgq_init_control_state(hwd_control_state_t *ptr)
Definition: linux-bgq.c:179
inline_static ThreadInfo_t * _papi_hwi_lookup_thread(int custom_tid)
Definition: threads.h:92
#define PAPI_NATIVE_AND_MASK
int _bgq_start(hwd_context_t *ctx, hwd_control_state_t *ptr)
Definition: linux-bgq.c:499
int totalcpus
Definition: papi.h:783
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
int _bgq_init(hwd_context_t *ctx)
Definition: linux-bgq.c:234
#define BGQ_PUNIT_MAX_COUNTERS
Definition: linux-bgq.h:45
#define PAPI_DOM_OTHER
Definition: papi.h:299
long long _bgq_get_real_cycles(void)
Definition: linux-bgq.c:942
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
EventSetInfo_t * ESI
int _bgq_ntv_name_to_code(char *name, unsigned int *event_code)
Definition: linux-bgq.c:1060
hwd_control_state_t * ctl_state
long j
Definition: iozone.c:19135
uint64_t opcode_mask
Definition: linux-bgq.c:72
ssize_t retval
Definition: libasync.c:338
int(* get_memory_info)(PAPI_hw_info_t *, int)
Definition: papi_vector.h:69
#define GET_OVERFLOW_ADDRESS(ctx)
Definition: aix-context.h:12
#define _papi_hwd_lock(lck)
Definition: aix-lock.h:6
UPC_Lock_t thdLocks[PAPI_MAX_LOCK]
Definition: linux-bgq.c:52
int _bgq_get_dmem_info(PAPI_dmem_info_t *pDmemInfo)
#define hwd_register_t
CUpti_EventID * eventId
Definition: linux-cuda.c:291
signal(SIGINT, signal_handler)
int ncpu
Definition: papi.h:778
char * ptr
Definition: iozone.c:23586