From 1f80566f635e50312fdef67ac9bd066aa357c197 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Mon, 31 Aug 2020 19:57:29 +0200 Subject: [PATCH] New info to be displayed (uarch and process) instead of other info (sha, aes, sse) --- src/cpuid.c | 6 +-- src/main.c | 2 +- src/printer.c | 100 ++++++++++++++++++++++++++------------------------ src/uarch.c | 16 ++++++++ src/uarch.h | 2 + 5 files changed, 75 insertions(+), 51 deletions(-) diff --git a/src/cpuid.c b/src/cpuid.c index f7181a5..156d658 100644 --- a/src/cpuid.c +++ b/src/cpuid.c @@ -712,7 +712,7 @@ char* get_str_cpu_name(struct cpuInfo* cpu) { char* get_str_avx(struct cpuInfo* cpu) { //If all AVX are available, it will use up to 15 - char* string = malloc(sizeof(char)*15+1); + char* string = malloc(sizeof(char)*17+1); if(!cpu->AVX) snprintf(string,2+1,"No"); else if(!cpu->AVX2) @@ -757,11 +757,11 @@ char* get_str_sse(struct cpuInfo* cpu) { last+=SSE4a_sl; } if(cpu->SSE4_1) { - snprintf(string+last,SSE4_1_sl+1,"SSE4_1,"); + snprintf(string+last,SSE4_1_sl+1,"SSE4.1,"); last+=SSE4_1_sl; } if(cpu->SSE4_2) { - snprintf(string+last,SSE4_2_sl+1,"SSE4_2,"); + snprintf(string+last,SSE4_2_sl+1,"SSE4.2,"); last+=SSE4_2_sl; } diff --git a/src/main.c b/src/main.c index 7be112f..a09a4d7 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ #include "cpuid.h" #include "global.h" -static const char* VERSION = "0.63"; +static const char* VERSION = "0.64"; void print_help(char *argv[]) { printf("Usage: %s [--version] [--help] [--levels] [--style fancy|retro|legacy] [--color 'R,G,B:R,G,B:R,G,B:R,G,B']\n\ diff --git a/src/printer.c b/src/printer.c index 0f148c1..27fc495 100644 --- a/src/printer.c +++ b/src/printer.c @@ -6,6 +6,8 @@ #include "printer.h" #include "ascii.h" #include "global.h" +#include "cpuid.h" +#include "uarch.h" #define COL_NONE "" #define COL_INTEL_FANCY_1 "\x1b[46;1m" @@ -22,50 +24,52 @@ #define COL_AMD_RETRO_2 "\x1b[32;1m" #define RESET "\x1b[m" -#define TITLE_NAME "Name:" -#define TITLE_FREQUENCY "Frequency:" -#define TITLE_SOCKETS "Sockets:" -#define TITLE_NCORES "Cores:" -#define TITLE_NCORES_DUAL "Cores (Total):" -#define TITLE_AVX "AVX:" -#define TITLE_SSE "SSE:" -#define TITLE_FMA "FMA:" -#define TITLE_AES "AES:" -#define TITLE_SHA "SHA:" -#define TITLE_L1i "L1i Size:" -#define TITLE_L1d "L1d Size:" -#define TITLE_L2 "L2 Size:" -#define TITLE_L3 "L3 Size:" -#define TITLE_PEAK "Peak Perf.:" +#define TITLE_NAME "Name:" +#define TITLE_FREQUENCY "Max Frequency:" +#define TITLE_SOCKETS "Sockets:" +#define TITLE_NCORES "Cores:" +#define TITLE_NCORES_DUAL "Cores (Total):" +#define TITLE_AVX "AVX:" +#define TITLE_SSE "SSE:" +#define TITLE_FMA "FMA:" +#define TITLE_AES "AES:" +#define TITLE_SHA "SHA:" +#define TITLE_L1i "L1i Size:" +#define TITLE_L1d "L1d Size:" +#define TITLE_L2 "L2 Size:" +#define TITLE_L3 "L3 Size:" +#define TITLE_PEAK "Peak Performance:" +#define TITLE_UARCH "Microarchitecture:" +#define TITLE_TECHNOLOGY "Technology:" -#define MAX_ATTRIBUTE_COUNT 15 +#define MAX_ATTRIBUTE_COUNT 14 #define ATTRIBUTE_NAME 0 -#define ATTRIBUTE_FREQUENCY 1 -#define ATTRIBUTE_SOCKETS 2 -#define ATTRIBUTE_NCORES 3 -#define ATTRIBUTE_NCORES_DUAL 4 -#define ATTRIBUTE_AVX 5 -#define ATTRIBUTE_SSE 6 -#define ATTRIBUTE_FMA 7 -#define ATTRIBUTE_AES 8 -#define ATTRIBUTE_SHA 9 -#define ATTRIBUTE_L1i 10 -#define ATTRIBUTE_L1d 11 -#define ATTRIBUTE_L2 12 -#define ATTRIBUTE_L3 13 -#define ATTRIBUTE_PEAK 14 +#define ATTRIBUTE_UARCH 1 +#define ATTRIBUTE_TECHNOLOGY 2 +#define ATTRIBUTE_FREQUENCY 3 +#define ATTRIBUTE_SOCKETS 4 +#define ATTRIBUTE_NCORES 5 +#define ATTRIBUTE_NCORES_DUAL 6 +#define ATTRIBUTE_AVX 7 +#define ATTRIBUTE_FMA 8 +#define ATTRIBUTE_L1i 9 +#define ATTRIBUTE_L1d 10 +#define ATTRIBUTE_L2 11 +#define ATTRIBUTE_L3 12 +#define ATTRIBUTE_PEAK 13 -static const char* ATTRIBUTE_FIELDS [MAX_ATTRIBUTE_COUNT] = { TITLE_NAME, TITLE_FREQUENCY, TITLE_SOCKETS, +static const char* ATTRIBUTE_FIELDS [MAX_ATTRIBUTE_COUNT] = { TITLE_NAME, TITLE_UARCH, TITLE_TECHNOLOGY, + TITLE_FREQUENCY, TITLE_SOCKETS, TITLE_NCORES, TITLE_NCORES_DUAL, - TITLE_AVX, TITLE_SSE, - TITLE_FMA, TITLE_AES, TITLE_SHA, - TITLE_L1i, TITLE_L1d, TITLE_L2, TITLE_L3, - TITLE_PEAK + TITLE_AVX, + TITLE_FMA, TITLE_L1i, TITLE_L1d, TITLE_L2, TITLE_L3, + TITLE_PEAK, }; -static const int ATTRIBUTE_LIST[MAX_ATTRIBUTE_COUNT] = { ATTRIBUTE_NAME, ATTRIBUTE_FREQUENCY, ATTRIBUTE_SOCKETS, +static const int ATTRIBUTE_LIST[MAX_ATTRIBUTE_COUNT] = { ATTRIBUTE_NAME, ATTRIBUTE_UARCH, ATTRIBUTE_TECHNOLOGY, + ATTRIBUTE_FREQUENCY, ATTRIBUTE_SOCKETS, ATTRIBUTE_NCORES, ATTRIBUTE_NCORES_DUAL, ATTRIBUTE_AVX, - ATTRIBUTE_SSE, ATTRIBUTE_FMA, ATTRIBUTE_AES, ATTRIBUTE_SHA, + ATTRIBUTE_FMA, ATTRIBUTE_L1i, ATTRIBUTE_L1d, ATTRIBUTE_L2, ATTRIBUTE_L3, ATTRIBUTE_PEAK }; @@ -230,6 +234,7 @@ void print_ascii_intel(struct ascii* art, uint32_t la) { uint32_t space_up = (NUMBER_OF_LINES - art->n_attributes_set)/2; uint32_t space_down = NUMBER_OF_LINES - art->n_attributes_set - space_up; + printf("\n"); for(uint32_t n=0;nn_attributes_set)/2; uint32_t space_down = NUMBER_OF_LINES - art->n_attributes_set - space_up; + printf("\n"); for(uint32_t n=0;nart[n][i] == '@') @@ -283,6 +290,7 @@ void print_ascii_amd(struct ascii* art, uint32_t la) { } else printf("\n"); } + printf("\n"); } @@ -314,15 +322,14 @@ bool print_cpufetch(struct cpuInfo* cpu, struct cache* cach, struct frequency* f return false; char* cpu_name = get_str_cpu_name(cpu); + char* uarch = get_str_uarch(cpu); + char* manufacturing_process = get_str_process(cpu); char* sockets = get_str_sockets(topo); char* max_frequency = get_str_freq(freq); char* n_cores = get_str_topology(cpu, topo, false); char* n_cores_dual = get_str_topology(cpu, topo, true); char* avx = get_str_avx(cpu); - char* sse = get_str_sse(cpu); - char* fma = get_str_fma(cpu); - char* aes = get_str_aes(cpu); - char* sha = get_str_sha(cpu); + char* fma = get_str_fma(cpu); char* l1i = get_str_l1i(topo->cach); char* l1d = get_str_l1d(topo->cach); char* l2 = get_str_l2(topo->cach); @@ -330,13 +337,12 @@ bool print_cpufetch(struct cpuInfo* cpu, struct cache* cach, struct frequency* f char* pp = get_str_peak_performance(cpu,topo,get_freq(freq)); setAttribute(art,ATTRIBUTE_NAME,cpu_name); + setAttribute(art,ATTRIBUTE_UARCH,uarch); + setAttribute(art,ATTRIBUTE_TECHNOLOGY,manufacturing_process); setAttribute(art,ATTRIBUTE_FREQUENCY,max_frequency); setAttribute(art,ATTRIBUTE_NCORES,n_cores); setAttribute(art,ATTRIBUTE_AVX,avx); - setAttribute(art,ATTRIBUTE_SSE,sse); setAttribute(art,ATTRIBUTE_FMA,fma); - setAttribute(art,ATTRIBUTE_AES,aes); - setAttribute(art,ATTRIBUTE_SHA,sha); setAttribute(art,ATTRIBUTE_L1i,l1i); setAttribute(art,ATTRIBUTE_L1d,l1d); setAttribute(art,ATTRIBUTE_L2,l2); @@ -358,15 +364,14 @@ bool print_cpufetch(struct cpuInfo* cpu, struct cache* cach, struct frequency* f print_ascii(art); free(cpu_name); + free(uarch); + free(manufacturing_process); free(max_frequency); free(sockets); free(n_cores); free(n_cores_dual); free(avx); - free(sse); free(fma); - free(aes); - free(sha); free(l1i); free(l1d); free(l2); @@ -375,6 +380,7 @@ bool print_cpufetch(struct cpuInfo* cpu, struct cache* cach, struct frequency* f free(cpu); free(art); + if(cs != NULL) free_colors_struct(cs); free_cache_struct(cach); free_topo_struct(topo); diff --git a/src/uarch.c b/src/uarch.c index e92b5d1..f14a498 100644 --- a/src/uarch.c +++ b/src/uarch.c @@ -373,3 +373,19 @@ int get_number_of_vpus(struct cpuInfo* cpu) { return 1; } } + +char* get_str_uarch(struct cpuInfo* cpu) { + return cpu->arch->uarch_str; +} + +char* get_str_process(struct cpuInfo* cpu) { + char* str = malloc(sizeof(char) * (4+2+1)); + uint32_t process = cpu->arch->process; + + if(process > 100) + sprintf(str, "%.2fum", (double)process/100); + else + sprintf(str, "%dnm", process); + + return str; +} diff --git a/src/uarch.h b/src/uarch.h index 6258399..a876ba2 100644 --- a/src/uarch.h +++ b/src/uarch.h @@ -10,5 +10,7 @@ struct uarch; struct uarch* get_uarch_from_cpuid(struct cpuInfo* cpu, uint32_t ef, uint32_t f, uint32_t em, uint32_t m, int s); bool vpus_are_AVX512(struct cpuInfo* cpu); int get_number_of_vpus(struct cpuInfo* cpu); +char* get_str_uarch(struct cpuInfo* cpu); +char* get_str_process(struct cpuInfo* cpu); #endif