Beispiel #1
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;
}
Beispiel #2
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);
    }
}
Beispiel #3
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
}