mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 16:00:39 +01:00
Compare commits
1 Commits
fix-accura
...
i273
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d134f68ffe |
@@ -971,6 +971,9 @@ struct system_on_chip* guess_soc_from_devtree(struct system_on_chip* soc) {
|
||||
DT_EQ(dt, len, soc, "apple,t6030", "M3 Pro", SOC_APPLE_M3_PRO, 3)
|
||||
DT_EQ(dt, len, soc, "apple,t6031", "M3 Max", SOC_APPLE_M3_MAX, 3)
|
||||
DT_EQ(dt, len, soc, "apple,t6034", "M3 Max", SOC_APPLE_M3_MAX, 3)
|
||||
// Qualcomm now also in devtree...
|
||||
// TODO: Integrate this with SOC_EQ
|
||||
DT_EQ(dt, len, soc, "qcom,sc8280", "8cx Gen 3", SOC_SNAPD_SC8280XP, 5)
|
||||
// grep -oR -h --color -E '"fsl,.*' *.dtsi | sort | uniq | cut -d ',' -f1-2 | grep -v '-'
|
||||
// https://elixir.bootlin.com/linux/v6.10.6/source/arch/arm64/boot/dts/freescale
|
||||
DT_EQ(dt, len, soc, "fsl,imx8qm", "i.MX 8QuadMax", SOC_NXP_IMX8QM, 28) // https://www.nxp.com/docs/en/fact-sheet/IMX8FAMFS.pdf
|
||||
|
||||
@@ -318,6 +318,7 @@ enum {
|
||||
SOC_SNAPD_SM8550_AB,
|
||||
SOC_SNAPD_SM8635,
|
||||
SOC_SNAPD_SM8650_AB,
|
||||
SOC_SNAPD_SC8280XP,
|
||||
// APPLE
|
||||
SOC_APPLE_M1,
|
||||
SOC_APPLE_M1_PRO,
|
||||
@@ -403,7 +404,7 @@ inline static VENDOR get_soc_vendor_from_soc(SOC soc) {
|
||||
else if(soc >= SOC_KUNPENG_920 && soc <= SOC_KUNPENG_930) return SOC_VENDOR_KUNPENG;
|
||||
else if(soc >= SOC_EXYNOS_3475 && soc <= SOC_EXYNOS_880) return SOC_VENDOR_EXYNOS;
|
||||
else if(soc >= SOC_MTK_MT6893 && soc <= SOC_MTK_MT8783) return SOC_VENDOR_MEDIATEK;
|
||||
else if(soc >= SOC_SNAPD_QSD8650 && soc <= SOC_SNAPD_SM8650_AB) return SOC_VENDOR_SNAPDRAGON;
|
||||
else if(soc >= SOC_SNAPD_QSD8650 && soc <= SOC_SNAPD_SC8280XP) return SOC_VENDOR_SNAPDRAGON;
|
||||
else if(soc >= SOC_APPLE_M1 && soc <= SOC_APPLE_M3_MAX) return SOC_VENDOR_APPLE;
|
||||
else if(soc >= SOC_ALLWINNER_A10 && soc <= SOC_ALLWINNER_R328) return SOC_VENDOR_ALLWINNER;
|
||||
else if(soc >= SOC_ROCKCHIP_3288 && soc <= SOC_ROCKCHIP_3588) return SOC_VENDOR_ROCKCHIP;
|
||||
|
||||
@@ -34,12 +34,6 @@ 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,11 +60,6 @@ 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 {
|
||||
@@ -193,8 +188,6 @@ 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
|
||||
};
|
||||
@@ -207,9 +200,6 @@ 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);
|
||||
|
||||
@@ -210,14 +210,18 @@ int64_t get_peak_performance(struct cpuInfo* cpu, bool accurate_pp) {
|
||||
|
||||
for(int i=0; i < cpu->num_cpus; ptr = ptr->next_cpu, i++) {
|
||||
struct topology* topo = ptr->topo;
|
||||
int64_t freq = get_freq(ptr->freq);
|
||||
int64_t max_freq = get_freq(ptr->freq);
|
||||
|
||||
int64_t freq;
|
||||
#ifdef __linux__
|
||||
if(accurate_pp)
|
||||
freq = get_freq_pp(ptr->freq);
|
||||
freq = measure_frequency(ptr);
|
||||
else
|
||||
freq = max_freq;
|
||||
#else
|
||||
// Silence compiler warning
|
||||
(void)(accurate_pp);
|
||||
freq = max_freq;
|
||||
#endif
|
||||
|
||||
//First, check we have consistent data
|
||||
@@ -446,23 +450,6 @@ int32_t get_core_type(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
// Gets the max frequency for estimating the peak performance
|
||||
// and fills in the passed cpuInfo parameter.
|
||||
void fill_frequency_info_pp(struct cpuInfo* cpu) {
|
||||
int32_t unused;
|
||||
int32_t *max_freq_pp_vec = malloc(sizeof(int32_t) * cpu->num_cpus);
|
||||
struct cpuInfo* ptr = cpu;
|
||||
|
||||
for (uint32_t i=0; i < cpu->num_cpus; i++) {
|
||||
set_cpu_module(i, cpu->num_cpus, &unused);
|
||||
|
||||
ptr->freq->max_pp = measure_frequency(ptr, max_freq_pp_vec);
|
||||
ptr = ptr->next_cpu;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
struct cpuInfo* get_cpu_info(void) {
|
||||
struct cpuInfo* cpu = emalloc(sizeof(struct cpuInfo));
|
||||
cpu->peak_performance = -1;
|
||||
@@ -559,7 +546,6 @@ struct cpuInfo* get_cpu_info(void) {
|
||||
ptr->core_type = get_core_type();
|
||||
}
|
||||
ptr->first_core_id = first_core;
|
||||
ptr->module_id = i;
|
||||
ptr->feat = get_features_info(ptr);
|
||||
|
||||
ptr->arch = get_cpu_uarch(ptr);
|
||||
@@ -584,13 +570,6 @@ struct cpuInfo* get_cpu_info(void) {
|
||||
if(ptr->topo == NULL) return cpu;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
// If accurate_pp is requested, we need to get the max frequency
|
||||
// after fetching the topology for all CPU modules, since the topology
|
||||
// is required by fill_frequency_info_pp
|
||||
if (accurate_pp()) fill_frequency_info_pp(cpu);
|
||||
#endif
|
||||
|
||||
cpu->peak_performance = get_peak_performance(cpu, accurate_pp());
|
||||
|
||||
return cpu;
|
||||
@@ -1026,7 +1005,6 @@ struct frequency* get_frequency_info(struct cpuInfo* cpu) {
|
||||
}
|
||||
#endif
|
||||
|
||||
freq->max_pp = UNKNOWN_DATA;
|
||||
return freq;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,9 @@
|
||||
#define FREQ_VECTOR_SIZE 1<<16
|
||||
|
||||
struct freq_thread {
|
||||
// Inputs
|
||||
struct cpuInfo* cpu;
|
||||
bool end;
|
||||
bool measure;
|
||||
// Output
|
||||
int32_t *max_pp;
|
||||
double freq;
|
||||
};
|
||||
|
||||
double vector_average_harmonic(double* v, int len) {
|
||||
@@ -51,7 +48,6 @@ void* measure_freq(void *freq_ptr) {
|
||||
char* line = NULL;
|
||||
size_t len = 0;
|
||||
ssize_t read;
|
||||
struct cpuInfo* cpu = freq->cpu;
|
||||
|
||||
int v = 0;
|
||||
double* freq_vector = malloc(sizeof(double) * FREQ_VECTOR_SIZE);
|
||||
@@ -80,43 +76,18 @@ void* measure_freq(void *freq_ptr) {
|
||||
sleep_ms(500);
|
||||
}
|
||||
|
||||
if (cpu->hybrid_flag) {
|
||||
// We have an heterogeneous architecture. After measuring the
|
||||
// frequency for all cores, we now need to compute the average
|
||||
// independently for each CPU module.
|
||||
struct cpuInfo* ptr = cpu;
|
||||
double* freq_vector_ptr = freq_vector;
|
||||
|
||||
for (int i=0; i < cpu->num_cpus; ptr = ptr->next_cpu, i++) {
|
||||
freq->max_pp[i] = vector_average_harmonic(freq_vector_ptr, ptr->topo->total_cores_module);
|
||||
printWarn("AVX2 measured freq=%d (module %d)", freq->max_pp[i], i);
|
||||
|
||||
freq_vector_ptr = freq_vector_ptr + ptr->topo->total_cores_module;
|
||||
}
|
||||
}
|
||||
else {
|
||||
freq->max_pp[0] = vector_average_harmonic(freq_vector, v);
|
||||
printWarn("AVX2 measured freq=%d\n", freq->max_pp[0]);
|
||||
}
|
||||
freq->freq = vector_average_harmonic(freq_vector, v);
|
||||
printWarn("AVX2 measured freq=%f\n", freq->freq);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t measure_frequency(struct cpuInfo* cpu, int32_t *max_freq_pp_vec) {
|
||||
if (cpu->hybrid_flag && cpu->module_id > 0) {
|
||||
// We have a hybrid architecture and we have already
|
||||
// measured the frequency for this module in a previous
|
||||
// call to this function, so now just return it.
|
||||
return max_freq_pp_vec[cpu->module_id];
|
||||
}
|
||||
|
||||
int64_t measure_frequency(struct cpuInfo* cpu) {
|
||||
int ret;
|
||||
int num_spaces;
|
||||
struct freq_thread* freq_struct = malloc(sizeof(struct freq_thread));
|
||||
freq_struct->end = false;
|
||||
freq_struct->measure = false;
|
||||
freq_struct->cpu = cpu;
|
||||
freq_struct->max_pp = max_freq_pp_vec;
|
||||
|
||||
void* (*compute_function)(void*);
|
||||
|
||||
@@ -188,5 +159,5 @@ int32_t measure_frequency(struct cpuInfo* cpu, int32_t *max_freq_pp_vec) {
|
||||
}
|
||||
|
||||
printf("\r%*c", num_spaces, ' ');
|
||||
return max_freq_pp_vec[0];
|
||||
return freq_struct->freq;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
#define MEASURE_TIME_SECONDS 5
|
||||
#define LOOP_ITERS 100000000
|
||||
|
||||
int32_t measure_frequency(struct cpuInfo* cpu, int32_t *max_freq_pp_vec);
|
||||
int64_t measure_frequency(struct cpuInfo* cpu);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user