static int attach( hwd_control_state_t * ctl, unsigned long tid ) { struct vperfctr_control tmp; #ifdef VPERFCTR_CONTROL_CLOEXEC tmp.flags = VPERFCTR_CONTROL_CLOEXEC; #endif ctl->rvperfctr = rvperfctr_open( ( int ) tid ); if ( ctl->rvperfctr == NULL ) { PAPIERROR( VOPEN_ERROR ); return ( PAPI_ESYS ); } SUBDBG( "_papi_hwd_ctl rvperfctr_open() = %p\n", ctl->rvperfctr ); /* Initialize the per thread/process virtualized TSC */ memset( &tmp, 0x0, sizeof ( tmp ) ); tmp.cpu_control.tsc_on = 1; /* Start the per thread/process virtualized TSC */ if ( rvperfctr_control( ctl->rvperfctr, &tmp ) < 0 ) { PAPIERROR( RCNTRL_ERROR ); return ( PAPI_ESYS ); } return ( PAPI_OK ); } /* end attach() */
static int _x86_start( hwd_context_t * ctx, hwd_control_state_t * state ) { int error; #ifdef DEBUG print_control( &state->control.cpu_control ); #endif if ( state->rvperfctr != NULL ) { if ( ( error = rvperfctr_control( state->rvperfctr, &state->control ) ) < 0 ) { SUBDBG( "rvperfctr_control returns: %d\n", error ); PAPIERROR( RCNTRL_ERROR ); return ( PAPI_ESYS ); } return ( PAPI_OK ); } if ( ( error = vperfctr_control( ctx->perfctr, &state->control ) ) < 0 ) { SUBDBG( "vperfctr_control returns: %d\n", error ); PAPIERROR( VCNTRL_ERROR ); return ( PAPI_ESYS ); } return ( PAPI_OK ); }
int _papi_hwd_start( hwd_context_t * ctx, hwd_control_state_t * state ) { int error; /* clear_unused_pmcsel_bits(this_state); moved to update_control_state */ #ifdef DEBUG print_control( &state->control.cpu_control ); #endif if ( state->rvperfctr != NULL ) { if ( ( error = rvperfctr_control( state->rvperfctr, &state->control ) ) < 0 ) { SUBDBG( "rvperfctr_control returns: %d\n", error ); PAPIERROR( RCNTRL_ERROR ); return ( PAPI_ESYS ); } return ( PAPI_OK ); } if ( ( error = vperfctr_control( ctx->perfctr, &state->control ) ) < 0 ) { SUBDBG( "vperfctr_control returns: %d\n", error ); PAPIERROR( VCNTRL_ERROR ); return ( PAPI_ESYS ); } return ( PAPI_OK ); }