src/components/sde/sde.c
/** Triggered by PAPI_write(), but only if the counters are running */
/*    otherwise, the updated state is written to ESI->hw_start      */
Triggered by PAPI_write(), but only if the counters are running
otherwise, the updated state is written to ESI->hw_start
Triggered by PAPI_write () but only if the counters are running otherwise the updated state is written to ESI - > hw_start
static int
_sde_write( hwd_context_t *ctx, hwd_control_state_t *ctl, long long *values )
{
    int i, ret_val = PAPI_OK;
    (void) ctx;
    (void) ctl;
    papisde_control_t *gctl = _papisde_global_control;   
    SUBDBG( "_sde_write... %p\n", ctx );
    sde_control_state_t *sde_ctl = ( sde_control_state_t * ) ctl;   
    papi_sde_lock();
    for( i = 0; i < sde_ctl->num_events; i++ ) {
        unsigned int counter_uniq_id = sde_ctl->which_counter[i];
        if( counter_uniq_id >= gctl->num_reg_events ){
            PAPIERROR("_sde_write(): Event at index %d does not correspond to a registered counter.\n",i);
            continue;
        }
        sde_counter_t *counter = ht_lookup_by_id(gctl->all_reg_counters, counter_uniq_id);
        if( NULL == counter ){
            PAPIERROR("_sde_read(): Event at index %d corresponds to a clobbered counter.\n",i);
            continue;
        }
        if( NULL != counter->counter_group_head ){
            SUBDBG("_sde_write(): Event '%s' corresponds to a counter group, and writing groups is not supported yet.\n",counter->name);
            continue;
        }
        if( NULL == counter->data ){
            if( NULL == counter->func_ptr ){
                if( NULL != counter->recorder_data ){
                    PAPIERROR("_sde_write(): Attempted write on a recorder: '%s'.\n",counter->name);
                }else{
                    PAPIERROR("_sde_write(): Attempted write on a placeholder: '%s'.\n",counter->name);
                }
            }else{
                PAPIERROR("_sde_write(): Attempted write on an event based on a callback function instead of a counter: '%s'.\n",counter->name);
            }
            continue;
        }
        ret_val = sde_hardware_write( counter, values[i] );
        if( PAPI_OK != ret_val ){
            PAPIERROR("_sde_write(): Error occured when writing counter: '%s'.\n",counter->name);
        }
    }
    papi_sde_unlock();
    return PAPI_OK;
}
static int _sde_write ( hwd_context_t * ctx , hwd_control_state_t * ctl , long long * values ) { int i , ret_val = PAPI_OK ; ( void ) ctx ; ( void ) ctl ; papisde_control_t * gctl = _papisde_global_control ; SUBDBG ( " \n " , ctx ) ; sde_control_state_t * sde_ctl = ( sde_control_state_t * ) ctl ; papi_sde_lock ( ) ; for ( i = 0 ; i < sde_ctl -> num_events ; i ++ ) { unsigned int counter_uniq_id = sde_ctl -> which_counter [ i ] ; if ( counter_uniq_id >= gctl -> num_reg_events ) { PAPIERROR ( " \n " , i ) ; continue ; } sde_counter_t * counter = ht_lookup_by_id ( gctl -> all_reg_counters , counter_uniq_id ) ; if ( NULL == counter ) { PAPIERROR ( " \n " , i ) ; continue ; } if ( NULL != counter -> counter_group_head ) { SUBDBG ( " \n " , counter -> name ) ; continue ; } if ( NULL == counter -> data ) { if ( NULL == counter -> func_ptr ) { if ( NULL != counter -> recorder_data ) { PAPIERROR ( " \n " , counter -> name ) ; } else { PAPIERROR ( " \n " , counter -> name ) ; } } else { PAPIERROR ( " \n " , counter -> name ) ; } continue ; } ret_val = sde_hardware_write ( counter , values [ i ] ) ; if ( PAPI_OK != ret_val ) { PAPIERROR ( " \n " , counter -> name ) ; } } papi_sde_unlock ( ) ; return PAPI_OK ; }
Triggered by PAPI_write(), but only if the counters are running
otherwise, the updated state is written to ESI->hw_start
Triggered by PAPI_write () but only if the counters are running otherwise the updated state is written to ESI - > hw_start
// Lock before we access global data structures. // We currently do not support writing in counter groups. // If we are not dealing with a simple counter but with a "recorder", which cannot be written, we have to error.