Пример #1
0
int
IOUNIT_read( hwd_context_t * ctx, hwd_control_state_t * ptr,
		   long_long ** events, int flags )
{
#ifdef DEBUG_BGQ
	printf( "IOUNIT_read\n" );
#endif
	( void ) ctx;
	( void ) flags;
	int i, numEvts;
	IOUNIT_control_state_t * this_state = ( IOUNIT_control_state_t * ) ptr;

	numEvts = Bgpm_NumEvents( this_state->EventGroup );
	if ( numEvts == 0 ) {
#ifdef DEBUG_BGPM
		printf ("Error: ret value is %d for BGPM API function Bgpm_NumEvents.\n", numEvts );
#endif
		//return ( EXIT_FAILURE );
	}
		
	for ( i = 0; i < numEvts; i++ )
		this_state->counts[i] = _common_getEventValue( i, this_state->EventGroup );

	*events = this_state->counts;
	
	return ( PAPI_OK );
}
Пример #2
0
INLINE void PROFILER_PCONTROL(int ctrl) {
  if(isMaster) {
    printf("Pcontrol change from %d to %d\n",curset,ctrl);
  }
  if(isZero) {
    if(ctrl == 0 && curset == 0) return;

    /* Save the current counter values and change curset to the new value of ctrl */
    if(curset != 0) {
      values[curset].time += MPI_Wtime();
      unsigned int cnt = 0;
      uint64_t val;
      unsigned int numEvts = Bgpm_NumEvents(hNWSet);
      assert(numEvts == numevents);
      for(unsigned int i = 0; i < NUM_TORUS_LINKS; i++) {
        for(unsigned int j = 0; j < numevents; j++) {
          Bgpm_NW_ReadLinkEvent(hNWSet, j, linkmask[i], &val);
          values[curset].counters[cnt++] += val;
        }
      }
    }
    if(ctrl != 0) {
      Bgpm_ResetStart(hNWSet);
      values[ctrl].time -= MPI_Wtime();
    }
    curset = ctrl;
    if(curset > maxset) maxset = ctrl;
    
  }
}
Пример #3
0
/*
 * _common_set_overflow_BGPM
 *
 * since update_control_state trashes overflow settings, this puts things
 * back into balance for BGPM
 */
int
_common_set_overflow_BGPM( int EventGroup,
                           int evt_idx,
                           int threshold,
                           void (*handler)(int, uint64_t, uint64_t, const ucontext_t *) )
{
    int retval;
    uint64_t threshold_for_bgpm;

    /* convert threadhold value assigned by PAPI user to value that is
     * programmed into the counter. This value is required by Bgpm_SetOverflow() */
    threshold_for_bgpm = BGPM_PERIOD2THRES( threshold );

#ifdef DEBUG_BGQ
    printf("_common_set_overflow_BGPM\n");

    int i;
    int numEvts = Bgpm_NumEvents( EventGroup );
    for ( i = 0; i < numEvts; i++ ) {
        printf("_common_set_overflow_BGPM: %d = %s\n", i, Bgpm_GetEventLabel( EventGroup, i) );
    }
#endif


    retval = Bgpm_SetOverflow( EventGroup,
                               evt_idx,
                               threshold_for_bgpm );
    retval = _check_BGPM_error( retval, "Bgpm_SetOverflow" );
    if ( retval < 0 ) return retval;

    retval = Bgpm_SetEventUser1( EventGroup,
                                 evt_idx,
                                 1024 );
    retval = _check_BGPM_error( retval, "Bgpm_SetEventUser1" );
    if ( retval < 0 ) return retval;

    /* user signal handler for overflow case */
    retval = Bgpm_SetOverflowHandler( EventGroup,
                                      handler );
    retval = _check_BGPM_error( retval, "Bgpm_SetOverflowHandler" );
    if ( retval < 0 ) return retval;

    return PAPI_OK;
}
Пример #4
0
void PrintCounts(unsigned hEvtSet)
{
    Bgpm_MuxStats_t mStats;
    Bgpm_GetMultiplex(hEvtSet, &mStats);
    printf("\nMux Stats: numGrps=%d, numSwitches=%d, elapsedCycles=0x%016lx\n",
            mStats.numGrps, mStats.numSwitches, mStats.elapsedCycles);

    int i;
    printf("grpCycles: \n");
    for (i=0; i<mStats.numGrps; i++) {
        printf("  cycles[%02d]=0x%016lx\n", i, Bgpm_GetMuxElapsedCycles(hEvtSet, i));
    }
    printf("Counter Results:\n");
    int numEvts = Bgpm_NumEvents(hEvtSet);
    uint64_t cnt;
    for (i=0; i<numEvts; i++) {
        Bgpm_ReadEvent(hEvtSet, i, &cnt);
        const char *label = Bgpm_GetEventLabel(hEvtSet, i);
        printf("      0x%016lx <= %s\n", cnt, label);
    }
}
Пример #5
0
void tw_run(void) {
    tw_pe *me;

    late_sanity_check();

    me = setup_pes();

#ifdef USE_BGPM
    Bgpm_Init(BGPM_MODE_SWDISTRIB);

    // Create event set and add events needed to calculate CPI,
    int hEvtSet = Bgpm_CreateEventSet();

    // Change the type here to get the other performance monitor sets -- defaults to instList set
    // Sets need to be different because there are conflicts when mixing certain events.
    Bgpm_AddEventList(hEvtSet, instList, sizeof(instList)/sizeof(unsigned) );

    if( me->id == 0) {
        printf("***************************************************************************************** \n");
        printf("* NOTICE: Build configured with Blue Gene/Q specific, BGPM performance monitoring code!!* \n");
        printf("***************************************************************************************** \n");
    }

    Bgpm_Apply(hEvtSet);
    Bgpm_Start(hEvtSet);
#endif

    tw_sched_init(me);

    switch(g_tw_synchronization_protocol) {
        case SEQUENTIAL:    // case 1
            tw_scheduler_sequential(me);
            break;

        case CONSERVATIVE: // case 2
            tw_scheduler_conservative(me);
            break;

        case OPTIMISTIC:   // case 3
            tw_scheduler_optimistic(me);
            break;

        case OPTIMISTIC_DEBUG:  // case 4
            tw_scheduler_optimistic_debug(me);
            break;

        default:
            tw_error(TW_LOC, "No Synchronization Protocol Specified! \n");
    }

#ifdef USE_BGPM
    Bgpm_Stop(hEvtSet);

    if( me->id == 0 ) { // Have only RANK 0 output stats
        int i;
        uint64_t cnt;
        int numEvts = Bgpm_NumEvents(hEvtSet);
        printf("\n \n ================================= \n");
        printf( "Performance Counter Results:\n");
        printf("--------------------------------- \n");
        for (i=0; i<numEvts; i++) {
            Bgpm_ReadEvent(hEvtSet, i, &cnt);
            printf("   %40s = %20llu\n", Bgpm_GetEventLabel(hEvtSet, i), cnt);
        }
        printf("================================= \n");
    }
#endif
}