mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-24 23:40:39 +01:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2410fd16d3 | ||
|
|
f63178b41c | ||
|
|
2788e6831e | ||
|
|
146f2a13aa | ||
|
|
90624b9aaa | ||
|
|
e42f04cca8 | ||
|
|
3aacaf5f9e | ||
|
|
50f66ec571 | ||
|
|
cb186a2f97 | ||
|
|
6164884415 | ||
|
|
260f9ec3b8 | ||
|
|
79013d0ec9 | ||
|
|
e4227388b9 |
11
Makefile
11
Makefile
@@ -38,10 +38,16 @@ ifneq ($(OS),Windows_NT)
|
||||
CFLAGS += -DARCH_PPC -std=gnu99 -fstack-protector-all -Wno-language-extension-token
|
||||
else ifeq ($(arch), $(filter $(arch), arm aarch64_be aarch64 arm64 armv8b armv8l armv7l armv6l))
|
||||
SRC_DIR=src/arm/
|
||||
SOURCE += $(COMMON_SRC) $(SRC_DIR)midr.c $(SRC_DIR)uarch.c $(SRC_COMMON)soc.c $(SRC_DIR)soc.c $(SRC_COMMON)pci.c $(SRC_DIR)udev.c
|
||||
SOURCE += $(COMMON_SRC) $(SRC_DIR)midr.c $(SRC_DIR)uarch.c $(SRC_COMMON)soc.c $(SRC_DIR)soc.c $(SRC_COMMON)pci.c $(SRC_DIR)udev.c sve.o
|
||||
HEADERS += $(COMMON_HDR) $(SRC_DIR)midr.h $(SRC_DIR)uarch.h $(SRC_COMMON)soc.h $(SRC_DIR)soc.h $(SRC_COMMON)pci.h $(SRC_DIR)udev.c $(SRC_DIR)socs.h
|
||||
CFLAGS += -DARCH_ARM -Wno-unused-parameter -std=c99 -fstack-protector-all
|
||||
|
||||
# Check if the compiler supports -march=armv8-a+sve. We will use it (if supported) to compile SVE detection code later
|
||||
is_sve_flag_supported := $(shell $(CC) -march=armv8-a+sve -c $(SRC_DIR)sve.c -o sve_test.o 2> /dev/null && echo 'yes'; rm -f sve_test.o)
|
||||
ifeq ($(is_sve_flag_supported), yes)
|
||||
SVE_FLAGS += -march=armv8-a+sve
|
||||
endif
|
||||
|
||||
ifeq ($(os), Darwin)
|
||||
SOURCE += $(SRC_COMMON)sysctl.c
|
||||
HEADERS += $(SRC_COMMON)sysctl.h
|
||||
@@ -91,6 +97,9 @@ freq_avx.o: Makefile $(SRC_DIR)freq/freq_avx.c $(SRC_DIR)freq/freq_avx.h $(SRC_D
|
||||
freq_avx512.o: Makefile $(SRC_DIR)freq/freq_avx512.c $(SRC_DIR)freq/freq_avx512.h $(SRC_DIR)freq/freq.h
|
||||
$(CC) $(CFLAGS) $(SANITY_FLAGS) -c -mavx512f -pthread $(SRC_DIR)freq/freq_avx512.c -o $@
|
||||
|
||||
sve.o: Makefile $(SRC_DIR)sve.c $(SRC_DIR)sve.h
|
||||
$(CC) $(CFLAGS) $(SANITY_FLAGS) $(SVE_FLAGS) -c $(SRC_DIR)sve.c -o $@
|
||||
|
||||
$(OUTPUT): Makefile $(SOURCE) $(HEADERS)
|
||||
ifeq ($(GIT_VERSION),"")
|
||||
$(CC) $(CFLAGS) $(SANITY_FLAGS) $(SOURCE) -o $(OUTPUT)
|
||||
|
||||
@@ -45,6 +45,7 @@ cpufetch is a command-line tool written in C that displays the CPU information i
|
||||
- [3.1 x86_64](#31-x86_64)
|
||||
- [3.2 ARM](#32-arm)
|
||||
- [3.3 PowerPC](#33-powerpc)
|
||||
- [3.4 RISC-V](#34-risc-v)
|
||||
- [4. Colors](#4-colors)
|
||||
- [4.1 Specifying a name](#41-specifying-a-name)
|
||||
- [4.2 Specifying the colors in RGB format](#42-specifying-the-colors-in-rgb-format)
|
||||
@@ -120,6 +121,11 @@ make
|
||||
<p align="center"><img width=90% src="pictures/ibm.png"></p>
|
||||
<p align="center">Talos II</p>
|
||||
|
||||
## 3.4 RISC-V
|
||||
|
||||
<p align="center"><img width=80% src="pictures/starfive.png"></p>
|
||||
<p align="center">StarFive VisionFive 2</p>
|
||||
|
||||
## 4. Colors
|
||||
By default, `cpufetch` will print the CPU logo with the system colorscheme. However, you can set a custom color scheme in two different ways:
|
||||
|
||||
@@ -175,6 +181,7 @@ Thanks to the fellow contributors and interested people in the project. Special
|
||||
- [mdoksa76](https://github.com/mdoksa76) and [exkc](https://github.com/exkc): Excellent ideas and feedback for supporting Allwinner SoCs.
|
||||
- [Sakura286](https://github.com/Sakura286), [exkc](https://github.com/exkc) and [Patola](https://github.com/Patola): Helped with RISC-V port with ssh access, ideas, testing, etc.
|
||||
- [ThomasKaiser](https://github.com/ThomasKaiser): Very valuable feedback on improving ARM SoC detection (Apple, Allwinner, Rockchip).
|
||||
- [zerkerX](https://github.com/zerkerX): Helped with feedback for supporting old (e.g., Pentium III) Intel CPUs.
|
||||
|
||||
## 8. cpufetch for GPUs (gpufetch)
|
||||
See [gpufetch](https://github.com/Dr-Noob/gpufetch) project!
|
||||
|
||||
BIN
pictures/starfive.png
Normal file
BIN
pictures/starfive.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
@@ -19,6 +19,7 @@
|
||||
#include "udev.h"
|
||||
#include "midr.h"
|
||||
#include "uarch.h"
|
||||
#include "sve.h"
|
||||
|
||||
bool cores_are_equal(int c1pos, int c2pos, uint32_t* midr_array, int32_t* freq_array) {
|
||||
return midr_array[c1pos] == midr_array[c2pos] && freq_array[c1pos] == freq_array[c2pos];
|
||||
@@ -168,6 +169,15 @@ struct features* get_features_info(void) {
|
||||
feat->SHA1 = hwcaps & HWCAP_SHA1;
|
||||
feat->SHA2 = hwcaps & HWCAP_SHA2;
|
||||
feat->NEON = hwcaps & HWCAP_ASIMD;
|
||||
feat->SVE = hwcaps & HWCAP_SVE;
|
||||
|
||||
hwcaps = getauxval(AT_HWCAP2);
|
||||
if (errno == ENOENT) {
|
||||
printWarn("Unable to retrieve AT_HWCAP2 using getauxval");
|
||||
}
|
||||
else {
|
||||
feat->SVE2 = hwcaps & HWCAP2_SVE2;
|
||||
}
|
||||
}
|
||||
#else
|
||||
else {
|
||||
@@ -183,6 +193,8 @@ struct features* get_features_info(void) {
|
||||
feat->CRC32 = hwcaps & HWCAP2_CRC32;
|
||||
feat->SHA1 = hwcaps & HWCAP2_SHA1;
|
||||
feat->SHA2 = hwcaps & HWCAP2_SHA2;
|
||||
feat->SVE = false;
|
||||
feat->SVE2 = false;
|
||||
}
|
||||
#endif // ifdef __aarch64__
|
||||
#elif defined __APPLE__ || __MACH__
|
||||
@@ -192,8 +204,14 @@ struct features* get_features_info(void) {
|
||||
feat->SHA1 = true;
|
||||
feat->SHA2 = true;
|
||||
feat->NEON = true;
|
||||
feat->SVE = false;
|
||||
feat->SVE2 = false;
|
||||
#endif // ifdef __linux__
|
||||
|
||||
if (feat->SVE || feat->SVE2) {
|
||||
feat->cntb = sve_cntb();
|
||||
}
|
||||
|
||||
return feat;
|
||||
}
|
||||
|
||||
@@ -430,7 +448,7 @@ char* get_str_topology(struct cpuInfo* cpu, struct topology* topo, bool dual_soc
|
||||
|
||||
char* get_str_features(struct cpuInfo* cpu) {
|
||||
struct features* feat = cpu->feat;
|
||||
uint32_t max_len = strlen("NEON,SHA1,SHA2,AES,CRC32,") + 1;
|
||||
uint32_t max_len = strlen("NEON,SHA1,SHA2,AES,CRC32,SVE,SVE2") + 1;
|
||||
uint32_t len = 0;
|
||||
char* string = ecalloc(max_len, sizeof(char));
|
||||
|
||||
@@ -438,6 +456,14 @@ char* get_str_features(struct cpuInfo* cpu) {
|
||||
strcat(string, "NEON,");
|
||||
len += 5;
|
||||
}
|
||||
if(feat->SVE) {
|
||||
strcat(string, "SVE,");
|
||||
len += 4;
|
||||
}
|
||||
if(feat->SVE2) {
|
||||
strcat(string, "SVE2,");
|
||||
len += 5;
|
||||
}
|
||||
if(feat->SHA1) {
|
||||
strcat(string, "SHA1,");
|
||||
len += 5;
|
||||
@@ -487,6 +513,10 @@ void print_debug(struct cpuInfo* cpu) {
|
||||
}
|
||||
}
|
||||
|
||||
if (cpu->feat->SVE || cpu->feat->SVE2) {
|
||||
printf("- cntb: %d\n", (int) cpu->feat->cntb);
|
||||
}
|
||||
|
||||
#if defined(__APPLE__) || defined(__MACH__)
|
||||
printf("hw.cpufamily: 0x%.8X\n", get_sys_info_by_name("hw.cpufamily"));
|
||||
printf("hw.cpusubfamily: 0x%.8X\n", get_sys_info_by_name("hw.cpusubfamily"));
|
||||
|
||||
@@ -167,11 +167,13 @@ bool match_google(char* soc_name, struct system_on_chip* soc) {
|
||||
|
||||
// https://www.techinsights.com/
|
||||
// https://datasheetspdf.com/pdf-file/1316605/HiSilicon/Hi3660/1
|
||||
// https://github.com/Dr-Noob/cpufetch/issues/259
|
||||
bool match_hisilicon(char* soc_name, struct system_on_chip* soc) {
|
||||
char* tmp;
|
||||
|
||||
if((tmp = strstr(soc_name, "hi")) == NULL)
|
||||
return false;
|
||||
if((tmp = strstr(soc_name, "hi")) != NULL);
|
||||
else if((tmp = strstr(soc_name, "kirin")) != NULL);
|
||||
else return false;
|
||||
|
||||
soc->soc_vendor = SOC_VENDOR_KIRIN;
|
||||
|
||||
@@ -204,6 +206,7 @@ bool match_hisilicon(char* soc_name, struct system_on_chip* soc) {
|
||||
SOC_EQ(tmp, "hi3680", "980", SOC_HISILICON_3680, soc, 7)
|
||||
//SOC_EQ(tmp, "?", "985", SOC_KIRIN, soc, 7)
|
||||
SOC_EQ(tmp, "hi3690", "990", SOC_HISILICON_3690, soc, 7)
|
||||
SOC_EQ(tmp, "kirin9000s", "9000s", SOC_HISILICON_9000S,soc, 7)
|
||||
SOC_END
|
||||
}
|
||||
|
||||
@@ -421,6 +424,9 @@ bool match_mediatek(char* soc_name, struct system_on_chip* soc) {
|
||||
}
|
||||
|
||||
/*
|
||||
* Good sources:
|
||||
* https://www.geektopia.es/es/products/company/qualcomm/socs/
|
||||
*
|
||||
* APQ: Application Processor Qualcomm
|
||||
* MSM: Mobile Station Modem
|
||||
* In a APQXXXX or MSMXXXX, the second digit represents:
|
||||
@@ -578,6 +584,25 @@ bool match_qualcomm(char* soc_name, struct system_on_chip* soc) {
|
||||
SOC_EQ(tmp, "SM8250-AB", "865+", SOC_SNAPD_SM8250_AB, soc, 7)
|
||||
SOC_EQ(tmp, "SM8350", "888", SOC_SNAPD_SM8350, soc, 5)
|
||||
SOC_EQ(tmp, "SM8350-AC", "888+", SOC_SNAPD_SM8350, soc, 5)
|
||||
// Snapdragon Gen 4 //
|
||||
SOC_EQ(tmp, "SM4375", "4 Gen 1", SOC_SNAPD_SM4375, soc, 6)
|
||||
SOC_EQ(tmp, "SM4450", "4 Gen 2", SOC_SNAPD_SM4450, soc, 4)
|
||||
SOC_EQ(tmp, "SM4635", "4s Gen 2", SOC_SNAPD_SM4635, soc, 4)
|
||||
// Snapdragon Gen 6 //
|
||||
SOC_EQ(tmp, "SM6375-AC", "6s Gen 3", SOC_SNAPD_SM6375_AC, soc, 6)
|
||||
SOC_EQ(tmp, "SM6450", "6 Gen 1", SOC_SNAPD_SM6450, soc, 4)
|
||||
// Snapdragon Gen 7 //
|
||||
SOC_EQ(tmp, "SM7435-AB", "7s Gen 2", SOC_SNAPD_SM7435_AB, soc, 4)
|
||||
SOC_EQ(tmp, "SM7450", "7 Gen 1", SOC_SNAPD_SM7450, soc, 4)
|
||||
SOC_EQ(tmp, "SM7475", "7+ Gen 2", SOC_SNAPD_SM7475, soc, 4)
|
||||
SOC_EQ(tmp, "SM7550-AB", "7 Gen 3", SOC_SNAPD_SM7550_AB, soc, 4)
|
||||
SOC_EQ(tmp, "SM7675-AB", "7+ Gen 3", SOC_SNAPD_SM7675_AB, soc, 4)
|
||||
// Snapdragon Gen 8 //
|
||||
SOC_EQ(tmp, "SM8450", "8 Gen 1", SOC_SNAPD_SM8450, soc, 4)
|
||||
SOC_EQ(tmp, "SM8475", "8+ Gen 1", SOC_SNAPD_SM8475, soc, 4)
|
||||
SOC_EQ(tmp, "SM8550-AB", "8 Gen 2", SOC_SNAPD_SM8550_AB, soc, 4)
|
||||
SOC_EQ(tmp, "SM8635", "8s Gen 3", SOC_SNAPD_SM8635, soc, 4)
|
||||
SOC_EQ(tmp, "SM8650-AB", "8 Gen 3", SOC_SNAPD_SM8650_AB, soc, 4)
|
||||
SOC_END
|
||||
}
|
||||
|
||||
@@ -624,12 +649,37 @@ bool match_special(char* soc_name, struct system_on_chip* soc) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Snapdragon 8 Gen 1 reported as "taro"
|
||||
// New Snapdragon SoCs codenames
|
||||
// https://github.com/sm8450-mainline/fdt?tab=readme-ov-file#chipsets
|
||||
// https://github.com/Dr-Noob/cpufetch/issues/253
|
||||
if (strcmp(soc_name, "cape") == 0) {
|
||||
fill_soc(soc, "8+ Gen 1", SOC_SNAPD_SM8475, 4);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(strcmp(soc_name, "taro") == 0) {
|
||||
fill_soc(soc, "8 Gen 1", SOC_SNAPD_SM8450, 4);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(strcmp(soc_name, "ukee") == 0) {
|
||||
fill_soc(soc, "7+ Gen 2", SOC_SNAPD_SM7475, 4);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(strcmp(soc_name, "diwali") == 0) {
|
||||
fill_soc(soc, "7 Gen 1", SOC_SNAPD_SM7450, 4);
|
||||
return true;
|
||||
}
|
||||
|
||||
// parrot can be either SM7435 or SM6450, we need more data
|
||||
// to distingish between those two
|
||||
|
||||
if(strcmp(soc_name, "ravelin") == 0) {
|
||||
fill_soc(soc, "4 Gen 2", SOC_SNAPD_SM4450, 4);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Google Pixel 6
|
||||
// https://github.com/Dr-Noob/cpufetch/issues/134
|
||||
if(strcmp(soc_name, "oriole") == 0) {
|
||||
@@ -702,6 +752,16 @@ struct system_on_chip* guess_soc_from_android(struct system_on_chip* soc) {
|
||||
else return soc;
|
||||
}
|
||||
|
||||
// https://github.com/Dr-Noob/cpufetch/issues/253
|
||||
// ro.soc.model might be more reliable than ro.product.board or
|
||||
// ro.board.platform, so try with it first
|
||||
property_len = android_property_get("ro.soc.model", (char *) &tmp);
|
||||
if(property_len > 0) {
|
||||
try_parse_soc_from_string(soc, property_len, tmp);
|
||||
if(soc->soc_vendor == SOC_VENDOR_UNKNOWN) printWarn("SoC detection failed using Android property ro.soc.model: %s", tmp);
|
||||
else return soc;
|
||||
}
|
||||
|
||||
property_len = android_property_get("ro.product.board", (char *) &tmp);
|
||||
if(property_len > 0) {
|
||||
try_parse_soc_from_string(soc, property_len, tmp);
|
||||
|
||||
@@ -29,6 +29,7 @@ enum {
|
||||
SOC_HISILICON_3670,
|
||||
SOC_HISILICON_3680,
|
||||
SOC_HISILICON_3690,
|
||||
SOC_HISILICON_9000S,
|
||||
// Kunpeng //
|
||||
SOC_KUNPENG_920,
|
||||
SOC_KUNPENG_930,
|
||||
@@ -270,11 +271,16 @@ enum {
|
||||
SOC_SNAPD_SDM660,
|
||||
SOC_SNAPD_SM6115,
|
||||
SOC_SNAPD_SM6125,
|
||||
SOC_SNAPD_SM6375_AC,
|
||||
SOC_SNAPD_SM6450,
|
||||
SOC_SNAPD_SDM670,
|
||||
SOC_SNAPD_SM6150,
|
||||
SOC_SNAPD_SM6350,
|
||||
SOC_SNAPD_SDM710,
|
||||
SOC_SNAPD_SDM712,
|
||||
SOC_SNAPD_SM4375,
|
||||
SOC_SNAPD_SM4450,
|
||||
SOC_SNAPD_SM4635,
|
||||
SOC_SNAPD_SM7125,
|
||||
SOC_SNAPD_SM7150_AA,
|
||||
SOC_SNAPD_SM7150_AB,
|
||||
@@ -283,6 +289,11 @@ enum {
|
||||
SOC_SNAPD_SM7250_AA,
|
||||
SOC_SNAPD_SM7250_AB,
|
||||
SOC_SNAPD_SM7250_AC,
|
||||
SOC_SNAPD_SM7435_AB,
|
||||
SOC_SNAPD_SM7450,
|
||||
SOC_SNAPD_SM7475,
|
||||
SOC_SNAPD_SM7550_AB,
|
||||
SOC_SNAPD_SM7675_AB,
|
||||
SOC_SNAPD_MSM8974AA,
|
||||
SOC_SNAPD_MSM8974AB,
|
||||
SOC_SNAPD_MSM8974AC,
|
||||
@@ -303,6 +314,10 @@ enum {
|
||||
SOC_SNAPD_SM8250_AB,
|
||||
SOC_SNAPD_SM8350,
|
||||
SOC_SNAPD_SM8450,
|
||||
SOC_SNAPD_SM8475,
|
||||
SOC_SNAPD_SM8550_AB,
|
||||
SOC_SNAPD_SM8635,
|
||||
SOC_SNAPD_SM8650_AB,
|
||||
// APPLE
|
||||
SOC_APPLE_M1,
|
||||
SOC_APPLE_M1_PRO,
|
||||
@@ -371,11 +386,11 @@ enum {
|
||||
|
||||
inline static VENDOR get_soc_vendor_from_soc(SOC soc) {
|
||||
if(soc >= SOC_BCM_2835 && soc <= SOC_BCM_2712) return SOC_VENDOR_BROADCOM;
|
||||
else if(soc >= SOC_HISILICON_3620 && soc <= SOC_HISILICON_3690) return SOC_VENDOR_KIRIN;
|
||||
else if(soc >= SOC_HISILICON_3620 && soc <= SOC_HISILICON_9000S) return SOC_VENDOR_KIRIN;
|
||||
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_SM8450) return SOC_VENDOR_SNAPDRAGON;
|
||||
else if(soc >= SOC_SNAPD_QSD8650 && soc <= SOC_SNAPD_SM8650_AB) 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;
|
||||
|
||||
15
src/arm/sve.c
Normal file
15
src/arm/sve.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <stdint.h>
|
||||
#include "../common/global.h"
|
||||
|
||||
// https://learn.arm.com/learning-paths/servers-and-cloud-computing/sve/sve_basics/#:~:text=Using%20a%20text%20editor%20of%20your%20choice%2C%20copy,svcntb%28%29%29%3B%20%7D%20This%20program%20prints%20the%20vector%20length
|
||||
uint64_t sve_cntb(void) {
|
||||
#ifdef __ARM_FEATURE_SVE
|
||||
uint64_t x0 = 0;
|
||||
__asm volatile("cntb %0"
|
||||
: "=r"(x0));
|
||||
return x0;
|
||||
#else
|
||||
printWarn("sve_cntb: Hardware supports SVE, but it was not enabled by the compiler");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
6
src/arm/sve.h
Normal file
6
src/arm/sve.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef __SVE_DETECTION__
|
||||
#define __SVE_DETECTION__
|
||||
|
||||
uint64_t sve_cntb(void);
|
||||
|
||||
#endif
|
||||
@@ -75,6 +75,7 @@ static const ISA isas_uarch[] = {
|
||||
[UARCH_THUNDERX] = ISA_ARMv8_A,
|
||||
[UARCH_THUNDERX2] = ISA_ARMv8_1_A,
|
||||
[UARCH_TAISHAN_V110] = ISA_ARMv8_2_A,
|
||||
[UARCH_TAISHAN_V120] = ISA_ARMv8_2_A, // Not confirmed
|
||||
[UARCH_TAISHAN_V200] = ISA_ARMv8_2_A, // Not confirmed
|
||||
[UARCH_DENVER] = ISA_ARMv8_A,
|
||||
[UARCH_DENVER2] = ISA_ARMv8_A,
|
||||
@@ -202,8 +203,10 @@ struct uarch* get_uarch_from_midr(uint32_t midr, struct cpuInfo* cpu) {
|
||||
CHECK_UARCH(arch, cpu, 'C', 0x0AF, NA, NA, "ThunderX2 99XX", UARCH_THUNDERX2, CPU_VENDOR_CAVIUM)
|
||||
|
||||
CHECK_UARCH(arch, cpu, 'H', 0xD01, NA, NA, "TaiShan v110", UARCH_TAISHAN_V110, CPU_VENDOR_HUAWEI) // Kunpeng 920 series
|
||||
CHECK_UARCH(arch, cpu, 'H', 0xD02, 2, 2, "TaiShan v120", UARCH_TAISHAN_V120, CPU_VENDOR_HUAWEI) // Kiring 9000S Big cores (https://github.com/Dr-Noob/cpufetch/issues/259)
|
||||
CHECK_UARCH(arch, cpu, 'H', 0xD02, NA, NA, "TaiShan v200", UARCH_TAISHAN_V200, CPU_VENDOR_HUAWEI) // Kunpeng 930 series (found in openeuler: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/XQCV7NX2UKRIUWUFKRF4PO3QENCOUFR3)
|
||||
CHECK_UARCH(arch, cpu, 'H', 0xD40, NA, NA, "Cortex-A76", UARCH_CORTEX_A76, CPU_VENDOR_ARM) // Kirin 980 Big/Medium cores -> Cortex-A76
|
||||
CHECK_UARCH(arch, cpu, 'H', 0xD42, NA, NA, "TaiShan v120", UARCH_TAISHAN_V120, CPU_VENDOR_HUAWEI) // Kiring 9000S Small Cores (https://github.com/Dr-Noob/cpufetch/issues/259)
|
||||
|
||||
CHECK_UARCH(arch, cpu, 'N', 0x000, NA, NA, "Denver", UARCH_DENVER, CPU_VENDOR_NVIDIA)
|
||||
CHECK_UARCH(arch, cpu, 'N', 0x003, NA, NA, "Denver2", UARCH_DENVER2, CPU_VENDOR_NVIDIA)
|
||||
@@ -291,7 +294,10 @@ int get_vpus_width(struct cpuInfo* cpu) {
|
||||
case UARCH_NEOVERSE_V1:
|
||||
return 256;
|
||||
default:
|
||||
if(cpu->feat->NEON) {
|
||||
if (cpu->feat->SVE && cpu->feat->cntb > 0) {
|
||||
return cpu->feat->cntb * 8;
|
||||
}
|
||||
else if (cpu->feat->NEON) {
|
||||
if(is_ARMv8_or_newer(cpu)) {
|
||||
return 128;
|
||||
}
|
||||
@@ -325,6 +331,7 @@ int get_number_of_vpus(struct cpuInfo* cpu) {
|
||||
case UARCH_ICESTORM: // [https://dougallj.github.io/applecpu/icestorm-simd.html]
|
||||
case UARCH_BLIZZARD: // [https://en.wikipedia.org/wiki/Comparison_of_ARM_processors]
|
||||
case UARCH_TAISHAN_V110:// [https://www-file.huawei.com/-/media/corp2020/pdf/publications/huawei-research/2022/huawei-research-issue1-en.pdf]: "128-bit x 2 for single precision"
|
||||
case UARCH_TAISHAN_V120:// Not confirmed, asssuming same as v110
|
||||
case UARCH_TAISHAN_V200:// Not confirmed, asssuming same as v110
|
||||
case UARCH_CORTEX_A57: // [https://www.anandtech.com/show/8718/the-samsung-galaxy-note-4-exynos-review/5]
|
||||
case UARCH_CORTEX_A72: // [https://www.anandtech.com/show/10347/arm-cortex-a73-artemis-unveiled/2]
|
||||
|
||||
@@ -83,7 +83,9 @@ enum {
|
||||
UARCH_BRAHMA_B15,
|
||||
UARCH_BRAHMA_B53,
|
||||
UARCH_XGENE, // Applied Micro X-Gene.
|
||||
// HUAWEI
|
||||
UARCH_TAISHAN_V110, // HiSilicon TaiShan v110
|
||||
UARCH_TAISHAN_V120, // HiSilicon TaiShan v120
|
||||
UARCH_TAISHAN_V200, // HiSilicon TaiShan v200
|
||||
// PHYTIUM
|
||||
UARCH_XIAOMI, // Not to be confused with Xiaomi Inc
|
||||
|
||||
@@ -124,6 +124,9 @@ struct features {
|
||||
bool SHA1;
|
||||
bool SHA2;
|
||||
bool CRC32;
|
||||
bool SVE;
|
||||
bool SVE2;
|
||||
uint64_t cntb;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef GIT_FULL_VERSION
|
||||
static const char* VERSION = "1.05";
|
||||
static const char* VERSION = "1.06";
|
||||
#endif
|
||||
|
||||
enum {
|
||||
|
||||
@@ -634,9 +634,10 @@ bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct color** cs, struct
|
||||
}
|
||||
|
||||
// Show the most modern vector instructions.
|
||||
// If AVX is supported show it, otherwise show SSE
|
||||
if (strcmp(avx, "No") == 0) {
|
||||
setAttribute(art, ATTRIBUTE_SSE, sse);
|
||||
if (strcmp(sse, "No") != 0) {
|
||||
setAttribute(art, ATTRIBUTE_SSE, sse);
|
||||
}
|
||||
}
|
||||
else {
|
||||
setAttribute(art, ATTRIBUTE_AVX, avx);
|
||||
|
||||
113
src/x86/cpuid.c
113
src/x86/cpuid.c
@@ -656,10 +656,15 @@ bool get_cache_topology_amd(struct cpuInfo* cpu, struct topology* topo) {
|
||||
void get_topology_from_udev(struct topology* topo) {
|
||||
topo->total_cores = get_ncores_from_cpuinfo();
|
||||
// TODO: To be improved in the future
|
||||
// Conservative setting as we only know the total
|
||||
// number of cores.
|
||||
topo->logical_cores = UNKNOWN_DATA;
|
||||
topo->physical_cores = UNKNOWN_DATA;
|
||||
if (topo->total_cores == 1) {
|
||||
// We can assume it's a single core CPU
|
||||
topo->logical_cores = topo->total_cores;
|
||||
topo->physical_cores = topo->total_cores;
|
||||
}
|
||||
else {
|
||||
topo->logical_cores = UNKNOWN_DATA;
|
||||
topo->physical_cores = UNKNOWN_DATA;
|
||||
}
|
||||
topo->smt_available = 1;
|
||||
topo->smt_supported = 1;
|
||||
topo->sockets = 1;
|
||||
@@ -704,29 +709,27 @@ struct topology* get_topology_info(struct cpuInfo* cpu, struct cache* cach, int
|
||||
topo->total_cores_module = topo->total_cores;
|
||||
}
|
||||
|
||||
bool toporet = false;
|
||||
switch(cpu->cpu_vendor) {
|
||||
case CPU_VENDOR_INTEL:
|
||||
if (cpu->maxLevels >= 0x00000004) {
|
||||
bool toporet = get_topology_from_apic(cpu, topo);
|
||||
if(!toporet) {
|
||||
#ifdef __linux__
|
||||
printWarn("Failed to retrieve topology from APIC, using udev...\n");
|
||||
get_topology_from_udev(topo);
|
||||
#else
|
||||
printErr("Failed to retrieve topology from APIC, assumming default values...\n");
|
||||
topo->logical_cores = UNKNOWN_DATA;
|
||||
topo->physical_cores = UNKNOWN_DATA;
|
||||
topo->smt_available = 1;
|
||||
topo->smt_supported = 1;
|
||||
#endif
|
||||
}
|
||||
toporet = get_topology_from_apic(cpu, topo);
|
||||
}
|
||||
else {
|
||||
printWarn("Can't read topology information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000001, cpu->maxLevels);
|
||||
topo->physical_cores = UNKNOWN_DATA;
|
||||
topo->logical_cores = UNKNOWN_DATA;
|
||||
topo->smt_available = 1;
|
||||
topo->smt_supported = 1;
|
||||
printWarn("Can't read topology information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000004, cpu->maxLevels);
|
||||
}
|
||||
if(!toporet) {
|
||||
#ifdef __linux__
|
||||
printWarn("Failed to retrieve topology from APIC, using udev...");
|
||||
get_topology_from_udev(topo);
|
||||
#else
|
||||
if (cpu->maxLevels >= 0x00000004)
|
||||
printErr("Failed to retrieve topology from APIC, assumming default values...");
|
||||
topo->logical_cores = UNKNOWN_DATA;
|
||||
topo->physical_cores = UNKNOWN_DATA;
|
||||
topo->smt_available = 1;
|
||||
topo->smt_supported = 1;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case CPU_VENDOR_AMD:
|
||||
@@ -747,10 +750,15 @@ struct topology* get_topology_info(struct cpuInfo* cpu, struct cache* cach, int
|
||||
}
|
||||
}
|
||||
else {
|
||||
printWarn("Can't read topology information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", 0x80000008, cpu->maxExtendedLevels);
|
||||
topo->physical_cores = 1;
|
||||
topo->logical_cores = 1;
|
||||
topo->smt_supported = 1;
|
||||
#ifdef __linux__
|
||||
printWarn("Can't read topology information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X), using udev...", 0x80000008, cpu->maxExtendedLevels);
|
||||
get_topology_from_udev(topo);
|
||||
#else
|
||||
printWarn("Can't read topology information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", 0x80000008, cpu->maxExtendedLevels);
|
||||
topo->physical_cores = 1;
|
||||
topo->logical_cores = 1;
|
||||
topo->smt_supported = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (cpu->maxLevels >= 0x00000001) {
|
||||
@@ -1006,24 +1014,33 @@ char* get_str_topology(struct cpuInfo* cpu, struct topology* topo, bool dual_soc
|
||||
string = emalloc(sizeof(char) * (strlen(STRING_UNKNOWN) + 1));
|
||||
strcpy(string, STRING_UNKNOWN);
|
||||
}
|
||||
else if(topo->smt_supported > 1) {
|
||||
// 4 for digits, 21 for ' cores (SMT disabled)' which is the longest possible output
|
||||
uint32_t max_size = 4+21+1;
|
||||
string = emalloc(sizeof(char) * max_size);
|
||||
|
||||
if(topo->smt_available > 1)
|
||||
snprintf(string, max_size, "%d cores (%d threads)", topo->physical_cores * topo_sockets, topo->logical_cores * topo_sockets);
|
||||
else {
|
||||
if(cpu->cpu_vendor == CPU_VENDOR_AMD)
|
||||
snprintf(string, max_size, "%d cores (SMT disabled)", topo->physical_cores * topo_sockets);
|
||||
else
|
||||
snprintf(string, max_size, "%d cores (HT disabled)", topo->physical_cores * topo_sockets);
|
||||
}
|
||||
}
|
||||
else {
|
||||
uint32_t max_size = 4+7+1;
|
||||
string = emalloc(sizeof(char) * max_size);
|
||||
snprintf(string, max_size, "%d cores",topo->physical_cores * topo_sockets);
|
||||
char cores_str[6];
|
||||
memset(cores_str, 0, sizeof(char) * 6);
|
||||
if (topo->physical_cores * topo_sockets > 1)
|
||||
strcpy(cores_str, "cores");
|
||||
else
|
||||
strcpy(cores_str, "core");
|
||||
|
||||
if(topo->smt_supported > 1) {
|
||||
// 4 for digits, 21 for ' cores (SMT disabled)' which is the longest possible output
|
||||
uint32_t max_size = 4+21+1;
|
||||
string = emalloc(sizeof(char) * max_size);
|
||||
|
||||
if(topo->smt_available > 1)
|
||||
snprintf(string, max_size, "%d %s (%d threads)", topo->physical_cores * topo_sockets, cores_str, topo->logical_cores * topo_sockets);
|
||||
else {
|
||||
if(cpu->cpu_vendor == CPU_VENDOR_AMD)
|
||||
snprintf(string, max_size, "%d %s (SMT disabled)", topo->physical_cores * topo_sockets, cores_str);
|
||||
else
|
||||
snprintf(string, max_size, "%d %s (HT disabled)", topo->physical_cores * topo_sockets, cores_str);
|
||||
}
|
||||
}
|
||||
else {
|
||||
uint32_t max_size = 4+7+1;
|
||||
string = emalloc(sizeof(char) * max_size);
|
||||
snprintf(string, max_size, "%d %s",topo->physical_cores * topo_sockets, cores_str);
|
||||
}
|
||||
}
|
||||
|
||||
return string;
|
||||
@@ -1084,8 +1101,14 @@ char* get_str_sse(struct cpuInfo* cpu) {
|
||||
last+=SSE4_2_sl;
|
||||
}
|
||||
|
||||
//Purge last comma
|
||||
string[last-1] = '\0';
|
||||
if (last == 0) {
|
||||
snprintf(string, 2+1, "No");
|
||||
}
|
||||
else {
|
||||
//Purge last comma
|
||||
string[last-1] = '\0';
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user