Giter Site home page Giter Site logo

dr-noob / cpufetch Goto Github PK

View Code? Open in Web Editor NEW
1.8K 1.8K 93.0 3.47 MB

Simple yet fancy CPU architecture fetching tool

License: GNU General Public License v2.0

C 97.15% Makefile 1.31% Roff 0.96% Shell 0.59%
amd android arm cpus intel linux macos microarchitecture windows

cpufetch's Introduction

GitHub Stats

GitHub stats Top languages

Repositories

cpufetch's People

Contributors

dr-noob avatar wunkolo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpufetch's Issues

Remove udev dependency and port to Windows

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

Print ASCII logo with a different approach

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

AMD FX6300 incorrect core count

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

[ARM] Cache sizes

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:

https://github.com/pytorch/cpuinfo/blob/ed8b86a253800bafdb7b25c5c399f91bff9cb1f3/src/arm/cache.c#L950-L965

cpufreq directory may not exist

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

32Bit compiling?

Is there a Way to compile cpufetch in 32Bit Linux?
I am using Kubuntu 18.04 LTS (32Bit)
Thanks,

Failed to detect some CPU values

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

  • Max standard level: 0x0000000D
  • Max extended level: 0x80000008
  • CPUID dump: 0x0001067A
    ╭─eduardo@charles ~/cpufetch ‹master›
    ╰─$

image

src/arm/midr.c:8:10: fatal error: asm/hwcap.h: No such file or directory #include <asm/hwcap.h>

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

A8-4500M wrong cache size?

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

[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

Wrong Peak FLOPS in AMD

This is because AMD does not have 2 functional units (I have never seen an AMD with two functional units).

Always read frequency from cpuid

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.

AMD Phenom II 955 Issue

Hi,

Thanks for making this nice fetching tool.

When cpufetch (Release 0.7) is executed, I get the error:

[ERROR]: Can't read cache information from cpuid (needed extended level is -2147483619, max is -2147483621)

Screenshot

L3 cache wrong size

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

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

error: invalid conversion from ‘void*’ to ‘char*’

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);

Invalid L1i size: 96KB on AMD A6 CPU

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

cpufetch support for ARM macOS (Apple M1)

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

[ERROR]: Could not open '/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq'

$ ./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

ASCII Art rework

All of the ascii art would benefit from a big rework. Key ideas are:

  • Replace ascii art (using the same characters for all the art) with ascii art with different characters which can enable to do better and more complex shapes
  • Each ascii art should have its own with (but mantaining the height), instead of a common one. This would allow a better fit for each art
  • Fancy style should be removed. Drawing with rectangles may be a good choice for some arts, but not for all of them
  • Default color scheme should be RGB, instead the system color. This would allow more realistic arts. Add option --system-color to use the system colors instead. Remove --color x
  • (Optional) Specify RGB color for each pixel in art, instead of setting a single color for all pixels. This would be very nice, since it could achieve a better feel of the art using fading colors.

[ERROR]: Could not open '/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq'

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

  • Max standard level: 0x0000000D
  • Max extended level: 0x8000001F
  • CPUID dump: 0x00810F81

gpufetch

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.

Model specific ACII logo printing

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.

Color issue

If using certain terminal colors, output may not be visible(like white background in Ubuntu)

Segmentation fault RpiZeroW

rPiZeroW.

compiles fine, get a "Segmentation fault" message. nothing else returns. just single line 2 words.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.