Exemple #1
0
void multiplex(period,normalize)
{
    // initialize sw thread to use BGPM in sw thread distributed mode
    // Allows up to 12 simultaineous punit counter per thread when using only
    // 2 threads/core
    Bgpm_Init(BGPM_MODE_SWDISTRIB);
  
    // Create event set and add events needed to calculate CPI,
    int hEvtSet = Bgpm_CreateEventSet();

    // Multiplexing must be enabled prior to adding events to a Punit event set.
    // With Multiplexing active on Punit event set, we can have as many Punit events as we like,
    // regardless of Max Events. Muxing will create as many groups as needed to hold all the events,
    // but by default only assigns up to 5 events per group (And reserves the 6th counter to track the number of
    // cycles a group has been active).
    // However, a few of the core-wide attributes used by events must still remain consistent
    // (like the l1p mode associated with the l1p events)
    //
    // Parameters:
    // period-> number of cycles between multiplex switches. A value of 0 disables multiplexing for this thread,
    //     which means you must explicitly call Bgpm_SwitchMux to switch between groups.
    // normalize->Pass in BGPM_NORMAL or BGPM_NOTNORMAL to choose whether event counts
    //     reported by Bgpm_ReadEvent() or Bgpm_ReadEventList() will be scaled to the to the maximum number of cycles spent
    //     by any mux group.
    //     With BGPM_NOTNORMAL, Bgpm_ReadEvent() and Bgpm_ReadEventList() report the raw numbers and you may use
    //     Bgpm_GetMultiplex() and Bgpm_GetMuxEventElapsedCycles() to do your own normalization as desired.
    Bgpm_SetMultiplex2(hEvtSet, period, normalize, BGPMMuxMinEvts);

    Bgpm_AddEventList(hEvtSet, evtList, sizeof(evtList)/sizeof(unsigned) );

    Bgpm_Apply(hEvtSet);
    Bgpm_Start(hEvtSet);

    const int loops = 100;
    int i; 
    for (i=0; i<loops; i++) {
        CreateEvents();
        if(!period){Bgpm_SwitchMux(hEvtSet);} // Switching mutiplex is needed only in case of period=0.
    }

    Bgpm_Stop(hEvtSet);
    PrintCounts(hEvtSet);
    Bgpm_Disable();
}
Exemple #2
0
int
CNKUNIT_start( hwd_context_t * ctx, hwd_control_state_t * ptr )
{
#ifdef DEBUG_BGQ
	printf( "CNKUNIT_start\n" );
#endif
	( void ) ctx;
	int retval;
	CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr;
	
	retval = Bgpm_Apply( this_state->EventGroup ); 
	CHECK_BGPM_ERROR( retval, "Bgpm_Apply" );

	/* Bgpm_Apply() does an implicit reset; 
	 hence no need to use Bgpm_ResetStart */
	retval = Bgpm_Start( this_state->EventGroup );
	CHECK_BGPM_ERROR( retval, "Bgpm_Start" );
	
	return ( PAPI_OK );
}
Exemple #3
0
int
L2UNIT_start( hwd_context_t * ctx, hwd_control_state_t * ptr )
{
#ifdef DEBUG_BGQ
	printf( "L2UNIT_start\n" );
#endif
	( void ) ctx;
	int retval;
	L2UNIT_control_state_t * this_state = ( L2UNIT_control_state_t * ) ptr;
	
	retval = Bgpm_Apply( this_state->EventGroup ); 
	CHECK_BGPM_ERROR( retval, "Bgpm_Apply" );

	// set flag to 1: BGPM eventGroup HAS BEEN applied
	this_state->bgpm_eventset_applied = 1;

	/* Bgpm_Apply() does an implicit reset; 
	 hence no need to use Bgpm_ResetStart */
	retval = Bgpm_Start( this_state->EventGroup );
	CHECK_BGPM_ERROR( retval, "Bgpm_Start" );
	
	return ( PAPI_OK );
}
Exemple #4
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
}