From 9f7204d43d6dd42da871664e15e45a9d7c24d81a Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Wed, 14 Sep 2022 11:07:26 +0200 Subject: [PATCH] [v1.02][ARM] Updating M1/M2 peak performance calculations according to the discussion in #155 --- src/arm/midr.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/arm/midr.c b/src/arm/midr.c index 9d3ee5e..2d8d7bc 100644 --- a/src/arm/midr.c +++ b/src/arm/midr.c @@ -81,12 +81,23 @@ int64_t get_peak_performance(struct cpuInfo* cpu) { } int64_t flops = 0; - ptr = cpu; - for(int i=0; i < cpu->num_cpus; ptr = ptr->next_cpu, i++) { - flops += ptr->topo->total_cores * (get_freq(ptr->freq) * 1000000); + + if(cpu->cpu_vendor == SOC_VENDOR_APPLE) { + // Special case for M1/M2 + // First we find the E cores, then the P + // M1 have 2 (E cores) or 4 (P cores) FMA units + // Source: https://dougallj.github.io/applecpu/firestorm-simd.html + flops += ptr->topo->total_cores * (get_freq(ptr->freq) * 1000000) * 2 * 4 * 2; + ptr = ptr->next_cpu; + flops += ptr->topo->total_cores * (get_freq(ptr->freq) * 1000000) * 2 * 4 * 4; + } + else { + for(int i=0; i < cpu->num_cpus; ptr = ptr->next_cpu, i++) { + flops += ptr->topo->total_cores * (get_freq(ptr->freq) * 1000000); + } + if(cpu->feat->NEON) flops = flops * 4; } - if(cpu->feat->NEON) flops = flops * 4; return flops; }