/* Register allocation */ int _papi_hwd_allocate_registers( EventSetInfo_t * ESI ) { hwd_control_state_t *this_state = &ESI->machdep; int i, j, natNum, index; ppc64_reg_alloc_t event_list[MAX_COUNTERS]; int group; /* not yet successfully mapped, but have enough slots for events */ /* Initialize the local structure needed for counter allocation and optimization. */ natNum = ESI->NativeCount; for ( i = 0; i < natNum; i++ ) { event_list[i].ra_position = -1; for ( j = 0; j < MAX_COUNTERS; j++ ) { if ( ( index = native_name_map[ESI->NativeInfoArray[i]. ni_event & PAPI_NATIVE_AND_MASK].index ) < 0 ) return PAPI_ECNFLCT; event_list[i].ra_counter_cmd[j] = native_table[index].resources.counter_cmd[j]; } for ( j = 0; j < GROUP_INTS; j++ ) { if ( ( index = native_name_map[ESI->NativeInfoArray[i]. ni_event & PAPI_NATIVE_AND_MASK].index ) < 0 ) return PAPI_ECNFLCT; event_list[i].ra_group[j] = native_table[index].resources.group[j]; } } if ( ( group = do_counter_allocation( event_list, natNum ) ) >= 0 ) { /* successfully mapped */ /* copy counter allocations info back into NativeInfoArray */ this_state->group_id = group; for ( i = 0; i < natNum; i++ ) { // ESI->NativeInfoArray[i].ni_position = event_list[i].ra_position; this_state->control.cpu_control.pmc_map[i] = event_list[i].ra_position; ESI->NativeInfoArray[i].ni_position = i; } /* update the control structure based on the NativeInfoArray */ SUBDBG( "Group ID: %d\n", group ); return PAPI_OK; } else { return PAPI_ECNFLCT; } }
/* this function will be called when there are counters available success return 1 fail return 0 */ int _aix_allocate_registers(EventSetInfo_t *ESI) { hwd_control_state_t *this_state = ESI->ctl_state; unsigned char selector; int i, j, natNum, index; ppc64_reg_alloc_t event_list[MAX_COUNTERS]; int position, group; /* not yet successfully mapped, but have enough slots for events */ /* Initialize the local structure needed for counter allocation and optimization. */ natNum = ESI->NativeCount; for (i = 0; i < natNum; i++) { /* CAUTION: Since this is in the hardware layer, it's ok to access the native table directly, but in general this is a bad idea */ event_list[i].ra_position = -1; /* calculate native event rank, which is number of counters it can live on, this is power3 specific */ for (j = 0; j < MAX_COUNTERS; j++) { if ((index = native_name_map[ESI->NativeInfoArray[i].ni_event & PAPI_NATIVE_AND_MASK].index) < 0) return 0; event_list[i].ra_counter_cmd[j] = native_table[index].resources.counter_cmd[j]; } for (j = 0; j < GROUP_INTS; j++) { if ((index = native_name_map[ESI->NativeInfoArray[i].ni_event & PAPI_NATIVE_AND_MASK].index) < 0) return 0; event_list[i].ra_group[j] = native_table[index].resources.group[j]; } /*event_list[i].ra_mod = -1; */ } if ((group = do_counter_allocation(event_list, natNum)) >= 0) { /* successfully mapped */ /* copy counter allocations info back into NativeInfoArray */ this_state->group_id = group; for (i = 0; i < natNum; i++) ESI->NativeInfoArray[i].ni_position = event_list[i].ra_position; /* update the control structure based on the NativeInfoArray */ /*_papi_hwd_update_control_state(this_state, ESI->NativeInfoArray, natNum);*/ return 1; } else { return 0; } }