src/components/sde/sde.c
/** Enumerate Native Events
 *   @param EventCode is the event of interest
 *   @param modifier is one of PAPI_ENUM_FIRST, PAPI_ENUM_EVENTS
 *  If your component has attribute masks then these need to
 *   be handled here as well.
 */
Enumerate Native Events
@param EventCode is the event of interest
@param modifier is one of PAPI_ENUM_FIRST, PAPI_ENUM_EVENTS
If your component has attribute masks then these need to
be handled here as well.
Enumerate Native Events @param EventCode is the event of interest @param modifier is one of PAPI_ENUM_FIRST PAPI_ENUM_EVENTS If your component has attribute masks then these need to be handled here as well .
static int
_sde_ntv_enum_events( unsigned int *EventCode, int modifier )
{
    unsigned int curr_code, next_code;
    SUBDBG("_sde_ntv_enum_events begin\n\tEventCode=%u modifier=%d\n", *EventCode, modifier);
    papisde_control_t *gctl = _papisde_global_control; 
    if( NULL == gctl ){
        return PAPI_ENOEVNT;
    }
    switch ( modifier ) {
        case PAPI_ENUM_FIRST:
            *EventCode = 0;
            return PAPI_OK;
        case PAPI_ENUM_EVENTS:
            curr_code = *EventCode & PAPI_NATIVE_AND_MASK;
            papi_sde_lock();
            if( curr_code >= gctl->num_reg_events-1 ){
                papi_sde_unlock();
                return PAPI_ENOEVNT;
            }
            next_code = curr_code;
            do{
                next_code++;
                sde_counter_t *item = ht_lookup_by_id(gctl->all_reg_counters, next_code);
                if( (NULL != item) && (NULL != item->name) ){
                    *EventCode = next_code;
                    SUBDBG("Event name = %s (unique id = %d)\n", item->name, item->glb_uniq_id); 
                    papi_sde_unlock();
                    return PAPI_OK;
                }
            }while(next_code < gctl->num_reg_events);
            papi_sde_unlock();
            break;
        default:
            return PAPI_EINVAL;
    }
    return PAPI_EINVAL;
}
static int _sde_ntv_enum_events ( unsigned int * EventCode , int modifier ) { unsigned int curr_code , next_code ; SUBDBG ( " \n \t \n " , * EventCode , modifier ) ; papisde_control_t * gctl = _papisde_global_control ; if ( NULL == gctl ) { return PAPI_ENOEVNT ; } switch ( modifier ) { case PAPI_ENUM_FIRST : * EventCode = 0 ; return PAPI_OK ; case PAPI_ENUM_EVENTS : curr_code = * EventCode & PAPI_NATIVE_AND_MASK ; papi_sde_lock ( ) ; if ( curr_code >= gctl -> num_reg_events - 1 ) { papi_sde_unlock ( ) ; return PAPI_ENOEVNT ; } next_code = curr_code ; do { next_code ++ ; sde_counter_t * item = ht_lookup_by_id ( gctl -> all_reg_counters , next_code ) ; if ( ( NULL != item ) && ( NULL != item -> name ) ) { * EventCode = next_code ; SUBDBG ( " \n " , item -> name , item -> glb_uniq_id ) ; papi_sde_unlock ( ) ; return PAPI_OK ; } } while ( next_code < gctl -> num_reg_events ) ; papi_sde_unlock ( ) ; break ; default : return PAPI_EINVAL ; } return PAPI_EINVAL ; }
Enumerate Native Events
   @param EventCode is the event of interest
   @param modifier is one of PAPI_ENUM_FIRST, PAPI_ENUM_EVENTS
  If your component has attribute masks then these need to
   be handled here as well.
Enumerate Native Events @param EventCode is the event of interest @param modifier is one of PAPI_ENUM_FIRST PAPI_ENUM_EVENTS If your component has attribute masks then these need to be handled here as well .
/* return EventCode of first event */ /* return the first event that we support */ /* return EventCode of next available event */ // Lock before we read num_reg_events and the hash-tables. /*
             * We have to check the events which follow the current one, because unregistering
             * will create sparcity in the global SDE table, so we can't just return the next
             * index.
             */