コード例 #1
0
ファイル: linux-IOunit.c プロジェクト: jtombiamba/MABTools
/*
 * Set Overflow
 *
 * This is commented out in BG/L/P - need to explore and complete...
 * However, with true 64-bit counters in BG/Q and all counters for PAPI
 * always starting from a true zero (we don't allow write...), the possibility
 * for overflow is remote at best...
 */
int
IOUNIT_set_overflow( EventSetInfo_t * ESI, int EventIndex, int threshold )
{
#ifdef DEBUG_BGQ
	printf("BEGIN IOUNIT_set_overflow\n");
#endif
	IOUNIT_control_state_t * this_state = ( IOUNIT_control_state_t * ) ESI->ctl_state;
	int retval;
	int evt_idx;
	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 );

	evt_idx = ESI->EventInfoArray[EventIndex].pos[0];
	SUBDBG( "Hardware counter %d (vs %d) used in overflow, threshold %d\n",
		   evt_idx, EventIndex, threshold );
#ifdef DEBUG_BGQ
	printf( "Hardware counter %d (vs %d) used in overflow, threshold %d\n",
		   evt_idx, EventIndex, threshold );
#endif
	/* If this counter isn't set to overflow, it's an error */
	if ( threshold == 0 ) {
		/* Remove the signal handler */
		retval = _papi_hwi_stop_signal( _IOunit_vector.cmp_info.hardware_intr_sig );
		if ( retval != PAPI_OK )
			return ( retval );
	}
	else {
#ifdef DEBUG_BGQ
		printf( "IOUNIT_set_overflow: Enable the signal handler\n" );
#endif
		/* Enable the signal handler */
		retval = _papi_hwi_start_signal( _IOunit_vector.cmp_info.hardware_intr_sig, 
										NEED_CONTEXT, 
										_IOunit_vector.cmp_info.CmpIdx );
		if ( retval != PAPI_OK )
			return ( retval );
		
		retval = Bgpm_SetOverflow( this_state->EventGroup,
								   evt_idx,
								   threshold_for_bgpm );
		CHECK_BGPM_ERROR( retval, "Bgpm_SetOverflow" );
		
        retval = Bgpm_SetEventUser1( this_state->EventGroup,
									 evt_idx,
									 1024 );
		CHECK_BGPM_ERROR( retval, "Bgpm_SetEventUser1" );
		
		/* user signal handler for overflow case */
		retval = Bgpm_SetOverflowHandler( this_state->EventGroup, user_signal_handler_IOUNIT );
		CHECK_BGPM_ERROR( retval, "Bgpm_SetOverflowHandler" );
	}
	
	return ( PAPI_OK );
}
コード例 #2
0
ファイル: linux-bgq-common.c プロジェクト: bpgriner01/pbdPAPI
/*
 * _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;
}