dr-noob / cpufetch Goto Github PK
View Code? Open in Web Editor NEWSimple yet fancy CPU architecture fetching tool
License: GNU General Public License v2.0
Simple yet fancy CPU architecture fetching tool
License: GNU General Public License v2.0
Currently, the port to Windows is impossible due to the udev dependency. Removing it could make cpufetch a better tool, because it would not depend on any operating system. This is probably the most complex feature to add. Removing this dependency, it should be easy to port cpufetch to Windows
Instead of using ASCII characters, print it using spaces with a background color. Something like this:
RED="\e[48;2;255;0;0m"
RESET="\e[0m"
BLUE="\e[48;2;0;0;200m"
echo -e $RED' '$BLUE' '$RESET
Output:
Name: AMD FX(tm)-6300 Six-Core Processor
Microarchitecture: Piledriver
Technology: 32nm
Max Frequency: 3.500 GHz
Cores: 3 cores (6 threads)
AVX: AVX
FMA: FMA3,FMA4
L1i Size: 64KB (192KB Total)
L1d Size: 16KB (96KB Total)
L2 Size: 2MB (6MB Total)
L3 Size: 8MB
Peak Performance: 168.00 GFLOP/s
This processor definitely has 6 physical cores:
cpufetch $ lscpu | grep CPU
CPU op-mode(s): 32-bit, 64-bit
CPU(s): 6
There seems to be no user-level way to get these variables and most kernels just return "0"for all the LEVELn
system configuration variables:
% getconf -a | grep CACHE
LEVEL1_ICACHE_SIZE 0
LEVEL1_ICACHE_ASSOC 0
LEVEL1_ICACHE_LINESIZE 64
LEVEL1_DCACHE_SIZE 0
LEVEL1_DCACHE_ASSOC 0
LEVEL1_DCACHE_LINESIZE 64
...
I've been doing some research and it looks like your best bet is to use the uarch of the chip itself and approximate/best-guess by using a static LUT of known values for each uarch, much like pytorch does by using the technical reference manuals:
In some enviroments like VMs, /sys/devices/system/cpu/cpu0/cpufreq dir may not exist and it will report incorrect values because not contemplating this issue
Is there a Way to compile cpufetch in 32Bit Linux?
I am using Kubuntu 18.04 LTS (32Bit)
Thanks,
This is the output of the command:
╭─eduardo@charles ~/cpufetch ‹master›
╰─$ cpufetch
open: No such file or directory
[ERROR]: Could not open '/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq'
Please, create a new issue with this error message and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues
[ERROR]: SMT level was not found when querying topology
Name: Pentium(R) Dual-Core CPU E5700 @ 3.00GHz
Microarchitecture: Penryn
Technology: 45nm
Max Frequency: Unknown
Cores: 0 cores
AVX: No
FMA: No
L1i Size: 32KB
L1d Size: 32KB
L2 Size: 2MB
Peak Performance: Unknown
╭─eduardo@charles ~/cpufetch ‹master›
╰─$ cpufetch --debug
open: No such file or directory
[ERROR]: Could not open '/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq'
Please, create a new issue with this error message and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues
[ERROR]: SMT level was not found when querying topology
cpufetch v0.96 (x86_64 build)
Pentium(R) Dual-Core CPU E5700 @ 3.00GHz
Git version: 4900c10
openSUSE Leap 15.2
Kernel 5.3.18
AMD A10-8700P Radeon R6, 10 Compute Cores 4C+6G
cpufetch --debug
[ERROR]: Invalid L1i size: 96KB
Please, create a new issue with this error message and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues
In the case of Kryo 260 / 280 (and more), MIDR is not enough for detect specific model, but using SoC we could do so.
sujeet@sujeet-pc:~/MyStuff/cpufetch$ make
gcc -Wall -Wextra -Werror -pedantic -fstack-protector-all -pedantic -std=c99 -DARCH_ARM -Wno-unused-parameter -Wfloat-equal -Wshadow -Wpointer-arith src/common/main.c src/common/cpu.c src/common/udev.c src/common/printer.c src/common/args.c src/common/global.c src/arm/midr.c src/arm/uarch.c src/arm/soc.c src/arm/udev.c -o cpufetch
src/arm/midr.c:8:10: fatal error: asm/hwcap.h: No such file or directory
#include <asm/hwcap.h>
^~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:45: cpufetch] Error 1
how do I deal with this
Print how many NUMA nodes are present
cpufetch v0.67 says:
L1i: 2 x 64 KB = 128 KB
L1d: 4 x 16 KB = 64 KB
lscpu 2.36 says:
L1i: 2 x 64 KB = 128 KB
L1d: 2 x 16 KB = 32 KB
cpuworld agrees with cpufetch, but it looks strange that lscpu (which uses the kernel functionality) is wrong...
[ERROR]: Can't read frequency information from cpuid (needed level is 0x00000016, max is 0x0000000D)
[ERROR]: Found unified cache at level 4 (expected == 2 or 3)
Please, create a new issue with this error message and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues
I gather the first error is a known issue but I couldn't find anything on the second one.
CPU: Crystal Well Core i7 2.8GHz
It is an MSI Laptop if that matters, please tell what else you need to debug this issue.
For fun I tried cpufetch in PS, cmd and WSL2 debian all returned the same errors (both), so at least the code is consistent.
lscpu from WSL2 Debian
oscar@MSI-Laptop:~$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 70
Model name: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
Stepping: 1
CPU MHz: 2801.000
CPU max MHz: 2801.0000
BogoMIPS: 5602.00
Virtualization: VT-x
Hypervisor vendor: Windows Subsystem for Linux
Virtualization type: container
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave osxsave avx f16c rdrand lahf_lm abm fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid ibrs ibpb stibp ssbd
Instead, the topology should be queried properly. For example, on a AMD Ryzen 2600 (see https://en.wikichip.org/wiki/amd/ryzen_5/2600), cpufetch reports 8MB of L3 which is wrong, because it has two L3...
This is because AMD does not have 2 functional units (I have never seen an AMD with two functional units).
At the moment, if cpuid (0x16) does not support it, cpufetch isn't able to do so. To know how we can get this, look at the Linux kernel source code.
For example, in a Ryzen 5 2600, cpufetch reports 3.4 GHz, but the turbo is 3.9 GHz (see https://en.wikichip.org/wiki/amd/ryzen_5/2600)
It does not seem like it can be fetched from cpuid. At least, dmidecode is able to obtain such information.
We could know it by checking the microarchitecture, since 2 VPUs are a thing since Haswell microarchitecture (according to https://github.com/Dr-Noob/FLOPS)
If there is more than one L3 cache, just shows the size of one of them insted of adding the value of each one
Support for VMs; print VM name and other info.
Instead of print the logo in the usual way, print it with random colors, like:
for i = 0; i < len; i++
color = rand
This color idea can also be added as --color wild
Please add a feature to detect and display the microarchitecture level (x86-64 v2, etc.)
This might be helpful if you decide to implement this: https://unix.stackexchange.com/questions/631217/how-do-i-check-if-my-cpu-supports-x86-64-v2
make -j12 -l13
c++ -Os -pipe -march=native -fdiagnostics-color=always -Os -pipe -march=native -fdiagnostics-color=always -fno-plt -fexceptions -Wformat -fstack-clash-protection -fcf-protection -Wall -Wextra -DARCH_X86 -Wfloat-equal -Wshadow -Wpointer-ar
ith src/common/main.c src/common/cpu.c src/common/udev.c src/common/printer.c src/common/args.c src/common/global.c src/x86/cpuid.c src/x86/apic.c src/x86/cpuid_asm.c src/x86/uarch.c -o cpufetch
src/common/cpu.c:58:36: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
58 | sanity_ret = snprintf(*str, 10,"%.4g"STRING_MEGABYTES, (double)value/(1<<20));
| ^
src/common/cpu.c:60:36: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
60 | sanity_ret = snprintf(*str, 10,"%.4g"STRING_KILOBYTES, (double)value/(1<<10));
| ^
src/common/cpu.c:158:26: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
158 | snprintf(string,size,"%.3f "STRING_GIGAHERZ,(float)(freq->max)/1000);
| ^
src/common/cpu.c:160:26: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
160 | snprintf(string,size,"%d "STRING_MEGAHERZ,freq->max);
| ^
src/common/cpu.c: In function ‘char* get_str_sockets(topology*)’:
src/common/cpu.c:39:24: error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]
39 | char* string = malloc(sizeof(char) * 2);
When I type either cpufetch
or cpufetch --debug
the program segfaults with the same message
Please, create a new issue with this error message and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues
zsh: segmentation fault (core dumped) cpufetch --debug
Here is the output of inxi -Fxz
concerning system info and cpu
base: Arch Linux
Machine: Type: Laptop System: LENOVO product: 81N3 v: Lenovo IdeaPad S145-15AST serial: <filter>
Mobo: LENOVO model: LNVNB161216 v: SDK0R32866WIN serial: <filter> UEFI: LENOVO v: AYCN18WW date: 06/05/2019
CPU: Info: Dual Core model: AMD A6-9225 RADEON R4 5 COMPUTE CORES 2C+3G bits: 64 type: MCP arch: Excavator rev: 0
L2 cache: 1024 KiB
flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm bogomips: 10384
Speed: 2595 MHz min/max: 1300/2600 MHz boost: enabled Core speeds (MHz): 1: 2595 2: 2595
Attempting to build on an ARM MacBook Pro shows the below result:
$ make
gcc -Wall -Wextra -Werror -pedantic -fstack-protector-all -pedantic -std=c99 -DARCH_ARM -Wno-unused-parameter -Wfloat-equal -Wshadow -Wpointer-arith src/common/main.c src/common/cpu.c src/common/udev.c src/common/printer.c src/common/args.c src/common/global.c src/arm/midr.c src/arm/uarch.c src/arm/soc.c src/arm/udev.c -o cpufetch
src/arm/midr.c:7:10: fatal error: 'sys/auxv.h' file not found
#include <sys/auxv.h>
^~~~~~~~~~~~
1 error generated.
make: *** [cpufetch] Error 1
uname -a returns this:
Darwin MacBook-Pro.local 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64
This is challenging, though
$ ./cpufetch --debug
open: No such file or directory
[ERROR]: Could not open '/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq'
Please, create a new issue with this error message and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues
cpufetch v0.94 (x86_64 build)
Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
- Max standart level: 0x0000000D
- Max extended level: 0x80000008
also, typo: standart
standard
I noticed it in a Xeon Gold 6248
All of the ascii art would benefit from a big rework. Key ideas are:
--system-color
to use the system colors instead. Remove --color x
$./cpufetch
[ERROR]: Invalid L2 size: 4MB
Please, create a new issue with this error message and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues
Segmentation fault (core dumped)
doing cpufetch --debug it shown this:
open: No such file or directory
[ERROR]: Could not open '/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq'
Please, create a new issue with this error message and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues
cpufetch v0.96 (x86_64 build)
AMD Ryzen 3 3200G with Radeon Vega Graphics
For a future project, developing a cpufetch like tool for GPU could be interesting.
For NVIDIA GPUs, I know that CUDA can give you any kind of details. For radeon and integrated GPUs (Intel, for example), I don't know how to approach it.
The ASCII logo could be improved significantly if it would show the specific model, along with the manufacturer. For example, showing the Intel trademark, and Core below it, for Intel Core family. The same applies for Xeon, AMD Ryzen, etc. Adding colours to this different families could also be interesting.
If using certain terminal colors, output may not be visible(like white background in Ubuntu)
For example, on a Xeon Gold, the logo could appear in yellow, and some other cool tweaks.
Replace 'x86_64' string by a real check of the arch
rPiZeroW.
compiles fine, get a "Segmentation fault" message. nothing else returns. just single line 2 words.
Just like XKB(D) XKB(I)
why -std=c99
on CXXFLAGS
? It's invalid for c++
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.