void abstract_cpu::measurement_end(void) { unsigned int i, j; total_stamp = 0; gettimeofday(&stamp_after, NULL); for (i = 0; i < children.size(); i++) if (children[i]) children[i]->wiggle(); time_factor = 1000000.0 * (stamp_after.tv_sec - stamp_before.tv_sec) + stamp_after.tv_usec - stamp_before.tv_usec; for (i = 0; i < children.size(); i++) if (children[i]) children[i]->measurement_end(); for (i = 0; i < children.size(); i++) if (children[i]) { for (j = 0; j < children[i]->cstates.size(); j++) { struct idle_state *state; state = children[i]->cstates[j]; if (!state) continue; update_cstate( state->linux_name, state->human_name, state->usage_before, state->duration_before, state->before_count); finalize_cstate(state->linux_name, state->usage_after, state->duration_after, state->after_count); } for (j = 0; j < children[i]->pstates.size(); j++) { struct frequency *state; state = children[i]->pstates[j]; if (!state) continue; update_pstate( state->freq, state->human_name, state->time_before, state->before_count); finalize_pstate(state->freq, state->time_after, state->after_count); } } for (i = 0; i < cstates.size(); i++) { struct idle_state *state = cstates[i]; if (state->after_count == 0) { cout << "after count is 0 " << state->linux_name << "\n"; continue; } if (state->after_count != state->before_count) { cout << "count mismatch " << state->after_count << " " << state->before_count << " on cpu " << number << "\n"; continue; } state->usage_delta = (state->usage_after - state->usage_before) / state->after_count; state->duration_delta = (state->duration_after - state->duration_before) / state->after_count; } }
void nhm_package::measurement_end(void) { uint64_t time_delta; double ratio; unsigned int i, j; for (i = 0; i < children.size(); i++) if (children[i]) children[i]->wiggle(); if (this->has_c2c7_res) c2_after = get_msr(number, MSR_PKG_C2_RESIDENCY); if (this->has_c3_res) c3_after = get_msr(number, MSR_PKG_C3_RESIDENCY); c6_after = get_msr(number, MSR_PKG_C6_RESIDENCY); if (this->has_c2c7_res) c7_after = get_msr(number, MSR_PKG_C7_RESIDENCY); if (has_c8c9c10_res) { c8_after = get_msr(number, MSR_PKG_C8_RESIDENCY); c9_after = get_msr(number, MSR_PKG_C9_RESIDENCY); c10_after = get_msr(number, MSR_PKG_C10_RESIDENCY); } tsc_after = get_msr(first_cpu, MSR_TSC); gettimeofday(&stamp_after, NULL); time_factor = 1000000.0 * (stamp_after.tv_sec - stamp_before.tv_sec) + stamp_after.tv_usec - stamp_before.tv_usec; if (this->has_c2c7_res) finalize_cstate("pkg c2", 0, c2_after, 1); if (this->has_c3_res) finalize_cstate("pkg c3", 0, c3_after, 1); finalize_cstate("pkg c6", 0, c6_after, 1); if (this->has_c2c7_res) finalize_cstate("pkg c7", 0, c7_after, 1); if (has_c8c9c10_res) { finalize_cstate("pkg c8", 0, c8_after, 1); finalize_cstate("pkg c9", 0, c9_after, 1); finalize_cstate("pkg c10", 0, c10_after, 1); } for (i = 0; i < children.size(); i++) if (children[i]) children[i]->measurement_end(); time_delta = 1000000 * (stamp_after.tv_sec - stamp_before.tv_sec) + stamp_after.tv_usec - stamp_before.tv_usec; ratio = 1.0 * time_delta / (tsc_after - tsc_before); for (i = 0; i < cstates.size(); i++) { struct idle_state *state = cstates[i]; if (state->after_count == 0) { cout << "after count is 0\n"; continue; } if (state->after_count != state->before_count) { cout << "count mismatch\n"; continue; } state->usage_delta = ratio * (state->usage_after - state->usage_before) / state->after_count; state->duration_delta = ratio * (state->duration_after - state->duration_before) / state->after_count; } for (i = 0; i < children.size(); i++) if (children[i]) { for (j = 0; j < children[i]->pstates.size(); j++) { struct frequency *state; state = children[i]->pstates[j]; if (!state) continue; update_pstate( state->freq, state->human_name, state->time_before, state->before_count); finalize_pstate(state->freq, state->time_after, state->after_count); } } total_stamp = 0; }
void nhm_core::measurement_end(void) { unsigned int i; uint64_t time_delta; double ratio; if (this->has_c1_res) c1_after = get_msr(first_cpu, MSR_CORE_C1_RESIDENCY); if (this->has_c3_res) c3_after = get_msr(first_cpu, MSR_CORE_C3_RESIDENCY); c6_after = get_msr(first_cpu, MSR_CORE_C6_RESIDENCY); if (this->has_c7_res) c7_after = get_msr(first_cpu, MSR_CORE_C7_RESIDENCY); tsc_after = get_msr(first_cpu, MSR_TSC); if (this->has_c1_res) finalize_cstate("core c1", 0, c1_after, 1); if (this->has_c3_res) finalize_cstate("core c3", 0, c3_after, 1); finalize_cstate("core c6", 0, c6_after, 1); if (this->has_c7_res) finalize_cstate("core c7", 0, c7_after, 1); gettimeofday(&stamp_after, NULL); time_factor = 1000000.0 * (stamp_after.tv_sec - stamp_before.tv_sec) + stamp_after.tv_usec - stamp_before.tv_usec; for (i = 0; i < children.size(); i++) if (children[i]) { children[i]->measurement_end(); children[i]->wiggle(); } time_delta = 1000000 * (stamp_after.tv_sec - stamp_before.tv_sec) + stamp_after.tv_usec - stamp_before.tv_usec; ratio = 1.0 * time_delta / (tsc_after - tsc_before); for (i = 0; i < cstates.size(); i++) { struct idle_state *state = cstates[i]; if (state->after_count == 0) { cout << "after count is 0\n"; continue; } if (state->after_count != state->before_count) { cout << "count mismatch\n"; continue; } state->usage_delta = ratio * (state->usage_after - state->usage_before) / state->after_count; state->duration_delta = ratio * (state->duration_after - state->duration_before) / state->after_count; } #if 0 for (i = 0; i < children.size(); i++) if (children[i]) { for (j = 0; j < children[i]->pstates.size(); j++) { struct frequency *state; state = children[i]->pstates[j]; if (!state) continue; update_pstate( state->freq, state->human_name, state->time_before, state->before_count); finalize_pstate(state->freq, state->time_after, state->after_count); } } #endif total_stamp = 0; }