/* * 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 ); }
int IOUNIT_update_control_state( hwd_control_state_t * ptr, NativeInfo_t * native, int count, hwd_context_t * ctx ) { #ifdef DEBUG_BGQ printf( "IOUNIT_update_control_state: count = %d\n", count ); #endif ( void ) ctx; int retval, index, i; IOUNIT_control_state_t * this_state = ( IOUNIT_control_state_t * ) ptr; // Delete and re-create BGPM eventset _common_deleteRecreate( &this_state->EventGroup ); // otherwise, add the events to the eventset for ( i = 0; i < count; i++ ) { index = ( native[i].ni_event ) + OFFSET; native[i].ni_position = i; #ifdef DEBUG_BGQ printf("IOUNIT_update_control_state: ADD event: i = %d, index = %d\n", i, index ); #endif /* Add events to the BGPM eventGroup */ retval = Bgpm_AddEvent( this_state->EventGroup, index ); CHECK_BGPM_ERROR( retval, "Bgpm_AddEvent" ); } return ( PAPI_OK ); }
int L2UNIT_update_control_state( hwd_control_state_t * ptr, NativeInfo_t * native, int count, hwd_context_t * ctx ) { #ifdef DEBUG_BGQ printf( "L2UNIT_update_control_state: count = %d\n", count ); #endif ( void ) ctx; int retval, index, i, k; L2UNIT_control_state_t * this_state = ( L2UNIT_control_state_t * ) ptr; // Delete and re-create BGPM eventset _common_deleteRecreate( &this_state->EventGroup ); #ifdef DEBUG_BGQ printf( "L2UNIT_update_control_state: EventGroup=%d, overflow = %d\n", this_state->EventGroup, this_state->overflow ); #endif // otherwise, add the events to the eventset for ( i = 0; i < count; i++ ) { index = ( native[i].ni_event ) + OFFSET; native[i].ni_position = i; #ifdef DEBUG_BGQ printf("L2UNIT_update_control_state: ADD event: i = %d, index = %d\n", i, index ); #endif this_state->EventGroup_local[i] = index; /* Add events to the BGPM eventGroup */ retval = Bgpm_AddEvent( this_state->EventGroup, index ); CHECK_BGPM_ERROR( retval, "Bgpm_AddEvent" ); } // store how many events we added to an EventSet this_state->count = count; // since update_control_state trashes overflow settings, this puts things // back into balance for BGPM if ( 1 == this_state->overflow ) { for ( k = 0; k < this_state->overflow_count; k++ ) { _common_set_overflow_BGPM( this_state->EventGroup, this_state->overflow_list[k].EventIndex, this_state->overflow_list[k].threshold, user_signal_handler_L2UNIT ); } } return ( PAPI_OK ); }
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 ); }
int IOUNIT_reset( hwd_context_t * ctx, hwd_control_state_t * ptr ) { #ifdef DEBUG_BGQ printf( "IOUNIT_reset\n" ); #endif ( void ) ctx; int retval; IOUNIT_control_state_t * this_state = ( IOUNIT_control_state_t * ) ptr; /* we can't simply call Bgpm_Reset() since PAPI doesn't have the restriction that an EventSet has to be stopped before resetting is possible. However, BGPM does have this restriction. Hence we need to stop, reset and start */ retval = Bgpm_Stop( this_state->EventGroup ); CHECK_BGPM_ERROR( retval, "Bgpm_Stop" ); retval = Bgpm_ResetStart( this_state->EventGroup ); CHECK_BGPM_ERROR( retval, "Bgpm_ResetStart" ); return ( PAPI_OK ); }
/* * Control of counters (Reading/Writing/Starting/Stopping/Setup) * functions */ int IOUNIT_init_control_state( hwd_control_state_t * ptr ) { #ifdef DEBUG_BGQ printf( "IOUNIT_init_control_state\n" ); #endif IOUNIT_control_state_t * this_state = ( IOUNIT_control_state_t * ) ptr; this_state->EventGroup = Bgpm_CreateEventSet(); CHECK_BGPM_ERROR( this_state->EventGroup, "Bgpm_CreateEventSet" ); return PAPI_OK; }
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 ); }
int IOUNIT_start( hwd_context_t * ctx, hwd_control_state_t * ptr ) { #ifdef DEBUG_BGQ printf( "IOUNIT_start\n" ); #endif ( void ) ctx; int retval; IOUNIT_control_state_t * this_state = ( IOUNIT_control_state_t * ) ptr; retval = Bgpm_ResetStart( this_state->EventGroup ); CHECK_BGPM_ERROR( retval, "Bgpm_ResetStart" ); return ( PAPI_OK ); }
int IOUNIT_ntv_code_to_descr( unsigned int EventCode, char *name, int len ) { #ifdef DEBUG_BGQ //printf( "IOUNIT_ntv_code_to_descr\n" ); #endif int retval, index; index = ( EventCode ) + OFFSET; retval = Bgpm_GetLongDesc( index, name, &len ); CHECK_BGPM_ERROR( retval, "Bgpm_GetLongDesc" ); return ( PAPI_OK ); }
int CNKUNIT_ntv_code_to_descr( unsigned int EventCode, char *name, int len ) { #ifdef DEBUG_BGQ //printf( "CNKUNIT_ntv_code_to_descr\n" ); #endif int retval, index; index = ( EventCode & PAPI_NATIVE_AND_MASK & PAPI_COMPONENT_AND_MASK ) + OFFSET; retval = Bgpm_GetLongDesc( index, name, &len ); CHECK_BGPM_ERROR( retval, "Bgpm_GetLongDesc" ); return ( PAPI_OK ); }
int CNKUNIT_stop( hwd_context_t * ctx, hwd_control_state_t * ptr ) { #ifdef DEBUG_BGQ printf( "CNKUNIT_stop\n" ); #endif ( void ) ctx; int retval; CNKUNIT_control_state_t * this_state = ( CNKUNIT_control_state_t * ) ptr; retval = Bgpm_Stop( this_state->EventGroup ); CHECK_BGPM_ERROR( retval, "Bgpm_Stop" ); return ( PAPI_OK ); }
/* * Control of counters (Reading/Writing/Starting/Stopping/Setup) * functions */ int L2UNIT_init_control_state( hwd_control_state_t * ptr ) { #ifdef DEBUG_BGQ printf( "L2UNIT_init_control_state\n" ); #endif L2UNIT_control_state_t * this_state = ( L2UNIT_control_state_t * ) ptr; this_state->EventGroup = Bgpm_CreateEventSet(); CHECK_BGPM_ERROR( this_state->EventGroup, "Bgpm_CreateEventSet" ); // initialize overflow flag to OFF (0) this_state->overflow = 0; this_state->overflow_count = 0; // initialized BGPM eventGroup flag to NOT applied yet (0) this_state->bgpm_eventset_applied = 0; return PAPI_OK; }