mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 16:00:39 +01:00
[v1.06][X86] Fix accurate-pp in hybrid architectures (fixes #169)
Overview of changes: - Adds field max_pp in frequency struct to hold the max freq for peak-performance estimation. - Instead of getting the max frequency in get_peak_performance, we get it in get_cpu_info (more natural). - Adds fill_frequency_info_pp which fills the max_pp of the passed cpu by calling measure_frequency. The approach is to call measure_frequency with a vector where the max frequencies are stored. Then, the first time measure_frequency is called, the frequency is measured while running all the cores, and the max frequency is computed per module (e.g., in the case of 2 modules, we would compute the freq for the first and for the second module), and saved into this vector. Subsequent calls to measure_frequency will just read the corresponding value for the vector. In other words, the frequency is only measured once for the whole CPU.
This commit is contained in:
@@ -34,6 +34,12 @@ int64_t get_freq(struct frequency* freq) {
|
||||
return freq->max;
|
||||
}
|
||||
|
||||
#ifdef ARCH_X86
|
||||
int64_t get_freq_pp(struct frequency* freq) {
|
||||
return freq->max_pp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ARCH_X86) || defined(ARCH_PPC)
|
||||
char* get_str_cpu_name(struct cpuInfo* cpu, bool fcpuname) {
|
||||
#ifdef ARCH_X86
|
||||
|
||||
@@ -60,6 +60,11 @@ struct frequency {
|
||||
int32_t max;
|
||||
// Indicates if max frequency was measured
|
||||
bool measured;
|
||||
#ifdef ARCH_X86
|
||||
// Max frequency when running vectorized code.
|
||||
// Used only for peak performance computation.
|
||||
int32_t max_pp;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct hypervisor {
|
||||
@@ -188,6 +193,8 @@ struct cpuInfo {
|
||||
#ifdef ARCH_X86
|
||||
// The index of the first core in the module
|
||||
uint32_t first_core_id;
|
||||
// The index of this module
|
||||
uint32_t module_id;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
@@ -200,6 +207,9 @@ uint32_t get_nsockets(struct topology* topo);
|
||||
|
||||
VENDOR get_cpu_vendor(struct cpuInfo* cpu);
|
||||
int64_t get_freq(struct frequency* freq);
|
||||
#ifdef ARCH_X86
|
||||
int64_t get_freq_pp(struct frequency* freq);
|
||||
#endif
|
||||
|
||||
char* get_str_aes(struct cpuInfo* cpu);
|
||||
char* get_str_sha(struct cpuInfo* cpu);
|
||||
|
||||
Reference in New Issue
Block a user