mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 07:50:40 +01:00
Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c4a2a0253 | ||
|
|
61cd0783ac | ||
|
|
5242adf4ac | ||
|
|
3a2b04de1e | ||
|
|
8f2f3d3a16 | ||
|
|
6dd041bf9f | ||
|
|
b45c09efff | ||
|
|
ec5f80adc1 | ||
|
|
ecca042d86 | ||
|
|
c718d83868 | ||
|
|
32b035f1a2 | ||
|
|
8bb65e0cc0 | ||
|
|
e8d2898ae3 | ||
|
|
b699fdc3f2 | ||
|
|
812ee0acc6 | ||
|
|
7916e8cbb4 | ||
|
|
41dbb22a20 | ||
|
|
bb9fb17ec8 | ||
|
|
b3ed3e9240 | ||
|
|
044608f31f | ||
|
|
2879876500 | ||
|
|
c7cc8be712 | ||
|
|
654d2e27e1 | ||
|
|
09cbb8874b | ||
|
|
fe95ca3e10 | ||
|
|
ec2ad4fef6 | ||
|
|
d56f7ffd14 | ||
|
|
4900c10eb3 | ||
|
|
9f0dc85bd8 | ||
|
|
36aeba0e73 | ||
|
|
ca7091bc5e | ||
|
|
8abbd8f69f | ||
|
|
7420792ef5 | ||
|
|
db32cccd91 | ||
|
|
a8d8ac2e91 |
31
Makefile
31
Makefile
@@ -1,8 +1,10 @@
|
|||||||
CXX=gcc
|
CC=gcc
|
||||||
|
|
||||||
CXXFLAGS=-Wall -Wextra -Werror -pedantic -fstack-protector-all -pedantic -std=c99
|
CFLAGS=-Wall -Wextra -Werror -pedantic -fstack-protector-all -pedantic -std=c99
|
||||||
SANITY_FLAGS=-Wfloat-equal -Wshadow -Wpointer-arith
|
SANITY_FLAGS=-Wfloat-equal -Wshadow -Wpointer-arith
|
||||||
|
|
||||||
|
PREFIX ?= /usr
|
||||||
|
|
||||||
SRC_COMMON=src/common/
|
SRC_COMMON=src/common/
|
||||||
|
|
||||||
COMMON_SRC = $(SRC_COMMON)main.c $(SRC_COMMON)cpu.c $(SRC_COMMON)udev.c $(SRC_COMMON)printer.c $(SRC_COMMON)args.c $(SRC_COMMON)global.c
|
COMMON_SRC = $(SRC_COMMON)main.c $(SRC_COMMON)cpu.c $(SRC_COMMON)udev.c $(SRC_COMMON)printer.c $(SRC_COMMON)args.c $(SRC_COMMON)global.c
|
||||||
@@ -10,16 +12,16 @@ COMMON_HDR = $(SRC_COMMON)ascii.h $(SRC_COMMON)cpu.h $(SRC_COMMON)udev.h $(SRC_C
|
|||||||
|
|
||||||
ifneq ($(OS),Windows_NT)
|
ifneq ($(OS),Windows_NT)
|
||||||
arch := $(shell uname -m)
|
arch := $(shell uname -m)
|
||||||
ifeq ($(arch), x86_64)
|
ifeq ($(arch), $(filter $(arch), x86_64 i686))
|
||||||
SRC_DIR=src/x86/
|
SRC_DIR=src/x86/
|
||||||
SOURCE += $(COMMON_SRC) $(SRC_DIR)cpuid.c $(SRC_DIR)apic.c $(SRC_DIR)cpuid_asm.c $(SRC_DIR)uarch.c
|
SOURCE += $(COMMON_SRC) $(SRC_DIR)cpuid.c $(SRC_DIR)apic.c $(SRC_DIR)cpuid_asm.c $(SRC_DIR)uarch.c
|
||||||
HEADERS += $(COMMON_HDR) $(SRC_DIR)cpuid.h $(SRC_DIR)apic.h $(SRC_DIR)cpuid_asm.h $(SRC_DIR)uarch.h
|
HEADERS += $(COMMON_HDR) $(SRC_DIR)cpuid.h $(SRC_DIR)apic.h $(SRC_DIR)cpuid_asm.h $(SRC_DIR)uarch.h
|
||||||
CXXFLAGS += -DARCH_X86
|
CFLAGS += -DARCH_X86
|
||||||
else
|
else
|
||||||
SRC_DIR=src/arm/
|
SRC_DIR=src/arm/
|
||||||
SOURCE += $(COMMON_SRC) $(SRC_DIR)midr.c $(SRC_DIR)uarch.c $(SRC_DIR)soc.c $(SRC_DIR)udev.c
|
SOURCE += $(COMMON_SRC) $(SRC_DIR)midr.c $(SRC_DIR)uarch.c $(SRC_DIR)soc.c $(SRC_DIR)udev.c
|
||||||
HEADERS += $(COMMON_HDR) $(SRC_DIR)midr.h $(SRC_DIR)uarch.h $(SRC_DIR)soc.h $(SRC_DIR)udev.c $(SRC_DIR)socs.h
|
HEADERS += $(COMMON_HDR) $(SRC_DIR)midr.h $(SRC_DIR)uarch.h $(SRC_DIR)soc.h $(SRC_DIR)udev.c $(SRC_DIR)socs.h
|
||||||
CXXFLAGS += -DARCH_ARM -Wno-unused-parameter
|
CFLAGS += -DARCH_ARM -Wno-unused-parameter
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OUTPUT=cpufetch
|
OUTPUT=cpufetch
|
||||||
@@ -28,21 +30,21 @@ else
|
|||||||
SRC_DIR=src/x86/
|
SRC_DIR=src/x86/
|
||||||
SOURCE += $(COMMON_SRC) $(SRC_DIR)cpuid.c $(SRC_DIR)apic.c $(SRC_DIR)cpuid_asm.c $(SRC_DIR)uarch.c
|
SOURCE += $(COMMON_SRC) $(SRC_DIR)cpuid.c $(SRC_DIR)apic.c $(SRC_DIR)cpuid_asm.c $(SRC_DIR)uarch.c
|
||||||
HEADERS += $(COMMON_HDR) $(SRC_DIR)cpuid.h $(SRC_DIR)apic.h $(SRC_DIR)cpuid_asm.h $(SRC_DIR)uarch.h
|
HEADERS += $(COMMON_HDR) $(SRC_DIR)cpuid.h $(SRC_DIR)apic.h $(SRC_DIR)cpuid_asm.h $(SRC_DIR)uarch.h
|
||||||
CXXFLAGS += -DARCH_X86
|
CFLAGS += -DARCH_X86
|
||||||
SANITY_FLAGS += -Wno-pedantic-ms-format
|
SANITY_FLAGS += -Wno-pedantic-ms-format
|
||||||
OUTPUT=cpufetch.exe
|
OUTPUT=cpufetch.exe
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: $(OUTPUT)
|
all: $(OUTPUT)
|
||||||
|
|
||||||
debug: CXXFLAGS += -g -O0
|
debug: CFLAGS += -g -O0
|
||||||
debug: $(OUTPUT)
|
debug: $(OUTPUT)
|
||||||
|
|
||||||
release: CXXFLAGS += -static -O3
|
release: CFLAGS += -static -O3
|
||||||
release: $(OUTPUT)
|
release: $(OUTPUT)
|
||||||
|
|
||||||
$(OUTPUT): Makefile $(SOURCE) $(HEADERS)
|
$(OUTPUT): Makefile $(SOURCE) $(HEADERS)
|
||||||
$(CXX) $(CXXFLAGS) $(SANITY_FLAGS) $(SOURCE) -o $(OUTPUT)
|
$(CC) $(CFLAGS) $(SANITY_FLAGS) $(SOURCE) -o $(OUTPUT)
|
||||||
|
|
||||||
run: $(OUTPUT)
|
run: $(OUTPUT)
|
||||||
./$(OUTPUT)
|
./$(OUTPUT)
|
||||||
@@ -51,6 +53,11 @@ clean:
|
|||||||
@rm $(OUTPUT)
|
@rm $(OUTPUT)
|
||||||
|
|
||||||
install: $(OUTPUT)
|
install: $(OUTPUT)
|
||||||
install -Dm755 "cpufetch" "/usr/bin/cpufetch"
|
install -Dm755 "cpufetch" "$(PREFIX)/bin/cpufetch"
|
||||||
install -Dm644 "LICENSE" "/usr/share/licenses/cpufetch-git/LICENSE"
|
install -Dm644 "LICENSE" "$(PREFIX)/share/licenses/cpufetch-git/LICENSE"
|
||||||
install -Dm644 "cpufetch.8" "/usr/share/man/man8/cpufetch.8.gz"
|
install -Dm644 "cpufetch.8" "$(PREFIX)/share/man/man8/cpufetch.8.gz"
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -f "$(PREFIX)/bin/cpufetch"
|
||||||
|
rm -f "$(PREFIX)/share/licenses/cpufetch-git/LICENSE"
|
||||||
|
rm -f "$(PREFIX)/share/man/man8/cpufetch.8.gz"
|
||||||
|
|||||||
102
README.md
102
README.md
@@ -1,35 +1,54 @@
|
|||||||
# cpufetch
|
<p align="center"><img width=50% src="./pictures/cpufetch.png"></p>
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
[](https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
<h4 align="center">Simple yet fancy CPU architecture fetching tool</h4>
|
||||||
|
|
||||||
|
|
||||||
Simplistic yet fancy CPU architecture fetching tool
|
|
||||||

|

|
||||||
|
|
||||||
### Platforms
|
</div>
|
||||||
cpufetch currently supports x86_64 CPUs (both Intel and AMD) and ARM.
|
|
||||||
|
# Table of contents
|
||||||
|
<!-- UPDATE with: doctoc --notitle README.md -->
|
||||||
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||||
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||||
|
|
||||||
|
|
||||||
|
- [1. Support](#1-support)
|
||||||
|
- [2. Installation](#2-installation)
|
||||||
|
- [2.1 Building from source](#21-building-from-source)
|
||||||
|
- [2.2 Linux](#22-linux)
|
||||||
|
- [2.2 Windows](#22-windows)
|
||||||
|
- [2.3 macOS](#23-macos)
|
||||||
|
- [2.4 Android](#24-android)
|
||||||
|
- [3. Examples](#3-examples)
|
||||||
|
- [3.1 x86_64 CPUs](#31-x86_64-cpus)
|
||||||
|
- [3.2 ARM CPUs](#32-arm-cpus)
|
||||||
|
- [4. Colors and style](#4-colors-and-style)
|
||||||
|
- [5. Implementation](#5-implementation)
|
||||||
|
- [6. Bugs or improvements](#6-bugs-or-improvements)
|
||||||
|
|
||||||
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||||
|
|
||||||
|
# 1. Support
|
||||||
|
cpufetch supports x86, x86_64 (Intel and AMD) and ARM.
|
||||||
|
|
||||||
| Platform | x86_64 | ARM | Notes |
|
| Platform | x86_64 | ARM | Notes |
|
||||||
|:---------:|:------------------------:|:-------------------:|:-----------------:|
|
|:---------:|:------------------------:|:-------------------:|:-----------------:|
|
||||||
| Linux | :heavy_check_mark: | :heavy_check_mark: | Prefered platform. <br> Experimental ARM support |
|
| GNU/Linux | :heavy_check_mark: | :heavy_check_mark: | Best support |
|
||||||
| Windows | :heavy_check_mark: | :x: | Some information may be missing. <br> Colors will be used if supported |
|
| Windows | :heavy_check_mark: | :x: | Some information may be missing. <br> Colors will be used if supported |
|
||||||
| Android | :heavy_exclamation_mark: | :heavy_check_mark: | Experimental ARM support |
|
| Android | :heavy_exclamation_mark: | :heavy_check_mark: | Some information may be missing. <br> Not tested under x86_64 |
|
||||||
| macOS | :heavy_check_mark: | :x: | Some information may be missing |
|
| macOS | :heavy_check_mark: | :x: | Some information may be missing. <br> Apple M1 support may be added <br> in the future (see [#47](https://github.com/Dr-Noob/cpufetch/issues/47))|
|
||||||
|
|
||||||
| Emoji | Meaning |
|
# 2. Installation
|
||||||
|:-----------------------:|:-------------:|
|
## 2.1 Building from source
|
||||||
|:heavy_check_mark: | Supported |
|
|
||||||
|:x: | Not supported |
|
|
||||||
|:heavy_exclamation_mark: | Not tested |
|
|
||||||
|
|
||||||
|
|
||||||
### Usage and installation
|
|
||||||
#### Linux
|
|
||||||
There is a cpufetch package available in Arch Linux ([cpufetch-git](https://aur.archlinux.org/packages/cpufetch-git)).
|
|
||||||
|
|
||||||
If you are in another distro, you can build `cpufetch` from source (see below)
|
|
||||||
|
|
||||||
#### Windows
|
|
||||||
In the [releases](https://github.com/Dr-Noob/cpufetch/releases) section you will find some cpufetch executables compiled for Windows. Just download and run it from Windows CMD.
|
|
||||||
|
|
||||||
#### Building from source
|
|
||||||
Just clone the repo and use `make` to compile it
|
Just clone the repo and use `make` to compile it
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -39,41 +58,58 @@ make
|
|||||||
./cpufetch
|
./cpufetch
|
||||||
```
|
```
|
||||||
|
|
||||||
The Makefile is designed to work on both Linux and Windows.
|
The Makefile is designed to work on Linux, Windows and macOS.
|
||||||
|
|
||||||
### Examples
|
## 2.2 Linux
|
||||||
|
There is a cpufetch package available in Arch Linux ([cpufetch-git](https://aur.archlinux.org/packages/cpufetch-git)). If you are in another distribution, you can build `cpufetch` from source.
|
||||||
|
|
||||||
|
## 2.2 Windows
|
||||||
|
In the [releases](https://github.com/Dr-Noob/cpufetch/releases) section you will find some cpufetch executables compiled for Windows. Just download and run it from Windows CMD. You can also build `cpufetch` from source.
|
||||||
|
|
||||||
|
## 2.3 macOS
|
||||||
|
You need to build `cpufetch` from source.
|
||||||
|
|
||||||
|
## 2.4 Android
|
||||||
|
1. Install `termux` app (terminal emulator)
|
||||||
|
2. Run `pkg install -y git make clang` inside termux.
|
||||||
|
3. Build from source normally:
|
||||||
|
- git clone https://github.com/Dr-Noob/cpufetch
|
||||||
|
- cd cpufetch
|
||||||
|
- make
|
||||||
|
- ./cpufetch
|
||||||
|
|
||||||
|
# 3. Examples
|
||||||
Here are more examples of how `cpufetch` looks on different CPUs.
|
Here are more examples of how `cpufetch` looks on different CPUs.
|
||||||
|
|
||||||
##### x86_64 CPUs
|
## 3.1 x86_64 CPUs
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
##### ARM CPUs
|
## 3.2 ARM CPUs
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Colors and style
|
# 4. Colors and style
|
||||||
By default, `cpufetch` will print the CPU art with the system colorscheme. However, you can always set a custom color scheme, either
|
By default, `cpufetch` will print the CPU art with the system colorscheme. However, you can always set a custom color scheme, either
|
||||||
specifying Intel or AMD, or specifying the colors in RGB format:
|
specifying Intel or AMD, or specifying the colors in RGB format:
|
||||||
|
|
||||||
```
|
```
|
||||||
./cpufetch --color intel (default color for Intel)
|
./cpufetch --color intel (default color for Intel)
|
||||||
./cpufetch --color amd (default color for AND)
|
./cpufetch --color amd (default color for AMD)
|
||||||
./cpufetch --color 239,90,45:210,200,200:100,200,45:0,200,200 (example)
|
./cpufetch --color 239,90,45:210,200,200:100,200,45:0,200,200 (example)
|
||||||
```
|
```
|
||||||
|
|
||||||
In the case of setting the colors using RGB, 4 colors must be given in with the format: ``[R,G,B:R,G,B:R,G,B:R,G,B]``. These colors correspond to CPU art color (2 colors) and for the text colors (following 2). Thus, you can customize all the colors.
|
In the case of setting the colors using RGB, 4 colors must be given in with the format: ``[R,G,B:R,G,B:R,G,B:R,G,B]``. These colors correspond to CPU art color (2 colors) and for the text colors (following 2). Thus, you can customize all the colors.
|
||||||
|
|
||||||
### Implementation
|
# 5. Implementation
|
||||||
|
|
||||||
See [cpufetch programming documentation](https://github.com/Dr-Noob/cpufetch/blob/master/doc/README.md).
|
See [cpufetch programming documentation](https://github.com/Dr-Noob/cpufetch/blob/master/doc/README.md).
|
||||||
|
|
||||||
### Bugs or improvements
|
# 6. Bugs or improvements
|
||||||
There are many open issues in github (see [issues](https://github.com/Dr-Noob/cpufetch/issues)). Feel free to open a new one report an issue or propose any improvement in `cpufetch`
|
There are many open issues in github (see [issues](https://github.com/Dr-Noob/cpufetch/issues)). Feel free to open a new one report an issue or propose any improvement in `cpufetch`
|
||||||
|
|
||||||
### Testing
|
|
||||||
I would like to thank [Gonzalocl](https://github.com/Gonzalocl) and [OdnetninI](https://github.com/OdnetninI) for their help, running `cpufetch` in many different CPUs they have access to, which makes it easier to debug and check the correctness of `cpufetch`.
|
I would like to thank [Gonzalocl](https://github.com/Gonzalocl) and [OdnetninI](https://github.com/OdnetninI) for their help, running `cpufetch` in many different CPUs they have access to, which makes it easier to debug and check the correctness of `cpufetch`.
|
||||||
|
|||||||
100
cpufetch.8
100
cpufetch.8
@@ -1,57 +1,67 @@
|
|||||||
.TH man 8 "1 Sep 2020" "0.7" "cpufetch man page"
|
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.2.
|
||||||
|
.TH CPUFETCH "1" "March 2021" "cpufetch v0.97 (x86_64 build)" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
cpufetch \- Simplistic yet fancy CPU architecture fetching tool
|
cpufetch \- manual page for cpufetch v0.97 (x86_64 build)
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
cpufetch [--version] [--help] [--levels] [--style fancy|retro|legacy] [--color intel|amd|'R,G,B:R,G,B:R,G,B:R,G,B']
|
.B cpufetch
|
||||||
|
[\fI\,OPTION\/\fR]...
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
cpufetch will print CPU information, for which will query CPUID instructions and udev directories on Linux as a fallback method. Some of this features are:
|
Simple yet fancy CPU architecture fetching tool
|
||||||
.IP \[bu] 2
|
|
||||||
Name
|
|
||||||
.IP \[bu]
|
|
||||||
Frequency
|
|
||||||
.IP \[bu]
|
|
||||||
Number of cores (Physical and Logical)
|
|
||||||
.IP \[bu]
|
|
||||||
Cache sizes
|
|
||||||
.IP \[bu]
|
|
||||||
Theoretical peak performance in floating point operations per second (FLOP/s)
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-style\fR \f[I][intel|amd|R,G,B:R,G,B:R,G,B:R,G,B]\f[]
|
\fB\-c\fR, \fB\-\-color\fR
|
||||||
Set the color scheme. By default, cpufetch uses the system color scheme. This option lets the user use different colors to print the CPU art:
|
Set the color scheme (by default, cpufetch uses the system color scheme)
|
||||||
.IP \[bu]
|
|
||||||
\fB"intel"\fR: Use intel color scheme
|
|
||||||
.IP \[bu]
|
|
||||||
\fB"amd"\fR: Use amd color scheme
|
|
||||||
.IP \[bu]
|
|
||||||
\fBcustom\fR: If color do not match "intel" or "amd", a custom scheme can be specified: 4 colors must be given in RGB with the format: R,G,B:R,G,B:...
|
|
||||||
These colors correspond to CPU art color (2 colors) and for the text colors (following 2)
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-style\fR \f[I]STYLE\f[]
|
\fB\-s\fR, \fB\-\-style\fR
|
||||||
Specify the style of ascii logo:
|
Set the style of CPU art
|
||||||
.IP \[bu]
|
|
||||||
\fB"fancy"\fR: Default style
|
|
||||||
.IP \[bu]
|
|
||||||
\fB"retro"\fR: Old cpufetch style
|
|
||||||
.IP \[bu]
|
|
||||||
\fB"legacy"\fR: Fallback style for terminals that does not support colors
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-levels\fR
|
\fB\-d\fR, \fB\-\-debug\fR
|
||||||
Prints CPUID levels and CPU name
|
Prints CPU model and cpuid levels (debug purposes)
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-verbose\fR
|
\fB\-v\fR, \fB\-\-verbose\fR
|
||||||
Prints extra information (if available) about how cpufetch tried fetching information
|
Prints extra information (if available) about how cpufetch tried fetching information
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-help\fR
|
\fB\-r\fR, \fB\-\-raw\fR
|
||||||
Prints help
|
Prints raw cpuid data
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-version\fR
|
\fB\-h\fR, \fB\-\-help\fR
|
||||||
Prints cpufetch version
|
Prints this help and exit
|
||||||
.SH BUGS
|
.TP
|
||||||
Bugs should be posted on: https://github.com/Dr-Noob/cpufetch/issues
|
\fB\-V\fR, \fB\-\-version\fR
|
||||||
.SH NOTES
|
Prints cpufetch version and exit
|
||||||
Peak performance information is NOT accurate. cpufetch computes peak performance using the max
|
.SH "COLORS:"
|
||||||
frequency. However, to properly compute peak performance, you need to know the frequency of the
|
.TP
|
||||||
CPU running AVX code, which is not be fetched by cpufetch since it depends on each specific CPU.
|
* "intel":
|
||||||
.SH AUTHOR
|
Use Intel default color scheme
|
||||||
|
.TP
|
||||||
|
* "amd":
|
||||||
|
Use AMD default color scheme
|
||||||
|
.TP
|
||||||
|
* "arm":
|
||||||
|
Use ARM default color scheme
|
||||||
|
.TP
|
||||||
|
* custom:
|
||||||
|
If color argument do not match "intel", "amd" or "arm", a custom scheme can be specified.
|
||||||
|
4 colors must be given in RGB with the format: R,G,B:R,G,B:...The first 2 colors are the CPU art color and the next 2 colors are the text colors
|
||||||
|
.SH "STYLES:"
|
||||||
|
.TP
|
||||||
|
* "fancy":
|
||||||
|
Default style
|
||||||
|
.TP
|
||||||
|
* "retro":
|
||||||
|
Old cpufetch style
|
||||||
|
.TP
|
||||||
|
* "legacy":
|
||||||
|
Fallback style for terminals that do not support colors
|
||||||
|
.SH "EXAMPLES:"
|
||||||
|
Run cpufetch with Intel color scheme:
|
||||||
|
\&./cpufetch \fB\-\-color\fR intel
|
||||||
|
Run cpufetch with a custom color scheme:
|
||||||
|
\&./cpufetch \fB\-\-color\fR 239,90,45:210,200,200:100,200,45:0,200,200
|
||||||
|
.SH "BUGS:"
|
||||||
|
Report bugs to https://github.com/Dr\-Noob/cpufetch/issues
|
||||||
|
.SH "NOTE:"
|
||||||
|
Peak performance information is NOT accurate. cpufetch computes peak performance using the max frequency. However, to properly compute peak performance, you need to know the frequency of the CPU running AVX code, which is not be fetched by cpufetch since it depends on each specific CPU. For peak performance measurement see: https://github.com/Dr\-Noob/peakperf
|
||||||
|
.SH "AUTHOR:"
|
||||||
Dr-Noob (https://github.com/Dr-Noob)
|
Dr-Noob (https://github.com/Dr-Noob)
|
||||||
|
|
||||||
|
|||||||
BIN
pictures/cpufetch.png
Normal file
BIN
pictures/cpufetch.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
@@ -436,12 +436,21 @@ bool match_special(char* soc_name, struct system_on_chip* soc) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Snapdragon 730 reported as "Qualcomm Technologies, Inc. SDMMAGPIE"
|
||||||
|
if((tmp = strstr(soc_name, "SDMMAGPIE")) != NULL) {
|
||||||
|
fill_soc(soc, "730", SOC_SNAPD_SM7150_AA, 8);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct system_on_chip* parse_soc_from_string(struct system_on_chip* soc) {
|
struct system_on_chip* parse_soc_from_string(struct system_on_chip* soc) {
|
||||||
char* raw_name = soc->raw_name;
|
char* raw_name = soc->raw_name;
|
||||||
|
|
||||||
|
if(match_special(raw_name, soc))
|
||||||
|
return soc;
|
||||||
|
|
||||||
if (match_qualcomm(raw_name, soc))
|
if (match_qualcomm(raw_name, soc))
|
||||||
return soc;
|
return soc;
|
||||||
|
|
||||||
@@ -454,10 +463,7 @@ struct system_on_chip* parse_soc_from_string(struct system_on_chip* soc) {
|
|||||||
if(match_hisilicon(raw_name, soc))
|
if(match_hisilicon(raw_name, soc))
|
||||||
return soc;
|
return soc;
|
||||||
|
|
||||||
if(match_broadcom(raw_name, soc))
|
match_broadcom(raw_name, soc);
|
||||||
return soc;
|
|
||||||
|
|
||||||
match_special(raw_name, soc);
|
|
||||||
|
|
||||||
return soc;
|
return soc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,24 +17,39 @@ static const char *SYTLES_STR_LIST[] = {
|
|||||||
[STYLE_INVALID] = NULL
|
[STYLE_INVALID] = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
|
||||||
ARG_CHAR_STYLE,
|
|
||||||
ARG_CHAR_COLOR,
|
|
||||||
ARG_CHAR_HELP,
|
|
||||||
ARG_CHAR_DEBUG,
|
|
||||||
ARG_CHAR_VERBOSE,
|
|
||||||
ARG_CHAR_VERSION
|
|
||||||
};
|
|
||||||
|
|
||||||
struct args_struct {
|
struct args_struct {
|
||||||
bool debug_flag;
|
bool debug_flag;
|
||||||
bool help_flag;
|
bool help_flag;
|
||||||
|
bool loop_flag;
|
||||||
|
bool raw_flag;
|
||||||
bool verbose_flag;
|
bool verbose_flag;
|
||||||
bool version_flag;
|
bool version_flag;
|
||||||
STYLE style;
|
STYLE style;
|
||||||
struct colors* colors;
|
struct colors* colors;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char args_chr[] = {
|
||||||
|
/* [ARG_CHAR_STYLE] = */ 's',
|
||||||
|
/* [ARG_CHAR_COLOR] = */ 'c',
|
||||||
|
/* [ARG_CHAR_LOPP] = */ 'l',
|
||||||
|
/* [ARG_CHAR_HELP] = */ 'h',
|
||||||
|
/* [ARG_CHAR_RAW] = */ 'r',
|
||||||
|
/* [ARG_CHAR_DEBUG] = */ 'd',
|
||||||
|
/* [ARG_CHAR_VERBOSE] = */ 'v',
|
||||||
|
/* [ARG_CHAR_VERSION] = */ 'V',
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *args_str[] = {
|
||||||
|
/* [ARG_CHAR_STYLE] = */ "style",
|
||||||
|
/* [ARG_CHAR_COLOR] = */ "color",
|
||||||
|
/* [ARG_CHAR_LOOP] = */ "loop",
|
||||||
|
/* [ARG_CHAR_HELP] = */ "help",
|
||||||
|
/* [ARG_CHAR_RAW] = */ "raw",
|
||||||
|
/* [ARG_CHAR_DEBUG] = */ "debug",
|
||||||
|
/* [ARG_CHAR_VERBOSE] = */ "verbose",
|
||||||
|
/* [ARG_CHAR_VERSION] = */ "version",
|
||||||
|
};
|
||||||
|
|
||||||
static struct args_struct args;
|
static struct args_struct args;
|
||||||
|
|
||||||
STYLE get_style() {
|
STYLE get_style() {
|
||||||
@@ -53,14 +68,31 @@ bool show_version() {
|
|||||||
return args.version_flag;
|
return args.version_flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool loop_mode() {
|
||||||
|
return args.loop_flag;
|
||||||
|
}
|
||||||
|
|
||||||
bool show_debug() {
|
bool show_debug() {
|
||||||
return args.debug_flag;
|
return args.debug_flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool show_raw() {
|
||||||
|
return args.raw_flag;
|
||||||
|
}
|
||||||
|
|
||||||
bool verbose_enabled() {
|
bool verbose_enabled() {
|
||||||
return args.verbose_flag;
|
return args.verbose_flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int max_arg_str_length() {
|
||||||
|
int max_len = -1;
|
||||||
|
int len = sizeof(args_str) / sizeof(args_str[0]);
|
||||||
|
for(int i=0; i < len; i++) {
|
||||||
|
max_len = max(max_len, (int) strlen(args_str[i]));
|
||||||
|
}
|
||||||
|
return max_len;
|
||||||
|
}
|
||||||
|
|
||||||
STYLE parse_style(char* style) {
|
STYLE parse_style(char* style) {
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
uint8_t styles_count = sizeof(SYTLES_STR_LIST) / sizeof(SYTLES_STR_LIST[0]);
|
uint8_t styles_count = sizeof(SYTLES_STR_LIST) / sizeof(SYTLES_STR_LIST[0]);
|
||||||
@@ -158,32 +190,58 @@ bool parse_color(char* optarg_str, struct colors** cs) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* build_short_options() {
|
||||||
|
const char *c = args_chr;
|
||||||
|
int len = sizeof(args_chr) / sizeof(args_chr[0]);
|
||||||
|
char* str = (char *) malloc(sizeof(char) * (len*2 + 1));
|
||||||
|
memset(str, 0, sizeof(char) * (len*2 + 1));
|
||||||
|
|
||||||
|
#ifdef ARCH_X86
|
||||||
|
sprintf(str, "%c:%c:%c%c%c%c%c%c",
|
||||||
|
c[ARG_STYLE], c[ARG_COLOR], c[ARG_HELP], c[ARG_RAW],
|
||||||
|
c[ARG_DEBUG], c[ARG_VERBOSE], c[ARG_VERSION], c[ARG_LOOP]);
|
||||||
|
#else
|
||||||
|
sprintf(str, "%c:%c:%c%c%c%c%c",
|
||||||
|
c[ARG_STYLE], c[ARG_COLOR], c[ARG_HELP],
|
||||||
|
c[ARG_DEBUG], c[ARG_VERBOSE], c[ARG_VERSION], c[ARG_LOOP]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
bool parse_args(int argc, char* argv[]) {
|
bool parse_args(int argc, char* argv[]) {
|
||||||
int c;
|
int opt;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
opterr = 0;
|
opterr = 0;
|
||||||
|
|
||||||
bool color_flag = false;
|
bool color_flag = false;
|
||||||
args.debug_flag = false;
|
args.debug_flag = false;
|
||||||
|
args.raw_flag = false;
|
||||||
|
args.loop_flag = false;
|
||||||
args.verbose_flag = false;
|
args.verbose_flag = false;
|
||||||
args.help_flag = false;
|
args.help_flag = false;
|
||||||
args.style = STYLE_EMPTY;
|
args.style = STYLE_EMPTY;
|
||||||
args.colors = NULL;
|
args.colors = NULL;
|
||||||
|
|
||||||
static struct option long_options[] = {
|
const struct option long_options[] = {
|
||||||
{"style", required_argument, 0, ARG_CHAR_STYLE },
|
{args_str[ARG_STYLE], required_argument, 0, args_chr[ARG_STYLE] },
|
||||||
{"color", required_argument, 0, ARG_CHAR_COLOR },
|
{args_str[ARG_COLOR], required_argument, 0, args_chr[ARG_COLOR] },
|
||||||
{"help", no_argument, 0, ARG_CHAR_HELP },
|
{args_str[ARG_HELP], no_argument, 0, args_chr[ARG_HELP] },
|
||||||
{"debug", no_argument, 0, ARG_CHAR_DEBUG },
|
#ifdef ARCH_X86
|
||||||
{"verbose", no_argument, 0, ARG_CHAR_VERBOSE },
|
{args_str[ARG_RAW], no_argument, 0, args_chr[ARG_RAW] },
|
||||||
{"version", no_argument, 0, ARG_CHAR_VERSION },
|
#endif
|
||||||
|
{args_str[ARG_DEBUG], no_argument, 0, args_chr[ARG_DEBUG] },
|
||||||
|
{args_str[ARG_LOOP], no_argument, 0, args_chr[ARG_LOOP] },
|
||||||
|
{args_str[ARG_VERBOSE], no_argument, 0, args_chr[ARG_VERBOSE] },
|
||||||
|
{args_str[ARG_VERSION], no_argument, 0, args_chr[ARG_VERSION] },
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
c = getopt_long(argc, argv, "", long_options, &option_index);
|
char* short_options = build_short_options();
|
||||||
|
opt = getopt_long(argc, argv, short_options, long_options, &option_index);
|
||||||
|
|
||||||
while (c != -1) {
|
while (!args.help_flag && !args.debug_flag && !args.version_flag && opt != -1) {
|
||||||
if(c == ARG_CHAR_COLOR) {
|
if(opt == args_chr[ARG_COLOR]) {
|
||||||
if(color_flag) {
|
if(color_flag) {
|
||||||
printErr("Color option specified more than once");
|
printErr("Color option specified more than once");
|
||||||
return false;
|
return false;
|
||||||
@@ -194,7 +252,7 @@ bool parse_args(int argc, char* argv[]) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(c == ARG_CHAR_STYLE) {
|
else if(opt == args_chr[ARG_STYLE]) {
|
||||||
if(args.style != STYLE_EMPTY) {
|
if(args.style != STYLE_EMPTY) {
|
||||||
printErr("Style option specified more than once");
|
printErr("Style option specified more than once");
|
||||||
return false;
|
return false;
|
||||||
@@ -204,48 +262,36 @@ bool parse_args(int argc, char* argv[]) {
|
|||||||
printErr("Invalid style '%s'",optarg);
|
printErr("Invalid style '%s'",optarg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if(c == ARG_CHAR_HELP) {
|
|
||||||
if(args.help_flag) {
|
|
||||||
printErr("Help option specified more than once");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
args.help_flag = true;
|
|
||||||
}
|
|
||||||
else if(c == ARG_CHAR_VERBOSE) {
|
|
||||||
if(args.verbose_flag) {
|
|
||||||
printErr("Verbose option specified more than once");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
args.verbose_flag = true;
|
|
||||||
}
|
|
||||||
else if(c == ARG_CHAR_DEBUG) {
|
|
||||||
if(args.debug_flag) {
|
|
||||||
printErr("Debug option specified more than once");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
args.debug_flag = true;
|
|
||||||
}
|
|
||||||
else if (c == ARG_CHAR_VERSION) {
|
|
||||||
if(args.version_flag) {
|
|
||||||
printErr("Version option specified more than once");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
args.version_flag = true;
|
|
||||||
}
|
|
||||||
else if(c == '?') {
|
|
||||||
printWarn("Invalid options");
|
|
||||||
args.help_flag = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else if(opt == args_chr[ARG_LOOP]) {
|
||||||
printBug("Bug at line number %d in file %s", __LINE__, __FILE__);
|
args.loop_flag = true;
|
||||||
|
}
|
||||||
option_index = 0;
|
else if(opt == args_chr[ARG_HELP]) {
|
||||||
c = getopt_long(argc, argv,"",long_options, &option_index);
|
args.help_flag = true;
|
||||||
|
}
|
||||||
|
else if(opt == args_chr[ARG_RAW]) {
|
||||||
|
args.raw_flag = true;
|
||||||
|
}
|
||||||
|
else if(opt == args_chr[ARG_VERBOSE]) {
|
||||||
|
args.verbose_flag = true;
|
||||||
|
}
|
||||||
|
else if(opt == args_chr[ARG_DEBUG]) {
|
||||||
|
args.debug_flag = true;
|
||||||
|
}
|
||||||
|
else if(opt == args_chr[ARG_VERSION]) {
|
||||||
|
args.version_flag = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printWarn("Invalid options");
|
||||||
|
args.help_flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind < argc) {
|
option_index = 0;
|
||||||
|
opt = getopt_long(argc, argv, short_options, long_options, &option_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(optind < argc) {
|
||||||
printWarn("Invalid options");
|
printWarn("Invalid options");
|
||||||
args.help_flag = true;
|
args.help_flag = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,10 +26,27 @@ enum {
|
|||||||
STYLE_INVALID
|
STYLE_INVALID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
ARG_STYLE,
|
||||||
|
ARG_COLOR,
|
||||||
|
ARG_LOOP,
|
||||||
|
ARG_HELP,
|
||||||
|
ARG_RAW,
|
||||||
|
ARG_DEBUG,
|
||||||
|
ARG_VERBOSE,
|
||||||
|
ARG_VERSION
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const char args_chr[];
|
||||||
|
extern const char *args_str[];
|
||||||
|
|
||||||
#include "printer.h"
|
#include "printer.h"
|
||||||
|
|
||||||
|
int max_arg_str_length();
|
||||||
bool parse_args(int argc, char* argv[]);
|
bool parse_args(int argc, char* argv[]);
|
||||||
bool show_help();
|
bool show_help();
|
||||||
|
bool loop_mode();
|
||||||
|
bool show_raw();
|
||||||
bool show_debug();
|
bool show_debug();
|
||||||
bool show_version();
|
bool show_version();
|
||||||
bool verbose_enabled();
|
bool verbose_enabled();
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
\
|
\
|
||||||
\
|
\
|
||||||
@@@@ @@@ @@@ @@@@@@@@ ############ \
|
@@@@ @@@ @@@ @@@@@@@@ ############ \
|
||||||
@@@@@@ @@@@@ @@@@ @@@ @@@@ ########## \
|
@@@@@@ @@@@@ @@@@@ @@@ @@@ ########## \
|
||||||
@@@ @@@ @@@@@@@@@@@@@ @@@ @@ # #### \
|
@@@ @@@ @@@@@@@@@@@@@ @@@ @@ # ##### \
|
||||||
@@@ @@@ @@@ @@@ @@@ @@@ @@@ ### #### \
|
@@@ @@@ @@@ @@@ @@@ @@@ @@ ### ##### \
|
||||||
@@@@@@@@@@@@ @@@ @@@ @@@ @@@ #### ## ### \
|
@@@@@@@@@@@@ @@@ @@@ @@@ @@@ ######### ### \
|
||||||
@@@ @@@ @@@ @@@ @@@@@@@@@ ######## ## \
|
@@@ @@@ @@@ @@@ @@@@@@@@@ ######## ## \
|
||||||
\
|
\
|
||||||
\
|
\
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ char* get_str_l3(struct cache* cach) {
|
|||||||
|
|
||||||
char* get_str_freq(struct frequency* freq) {
|
char* get_str_freq(struct frequency* freq) {
|
||||||
//Max 3 digits and 3 for '(M/G)Hz' plus 1 for '\0'
|
//Max 3 digits and 3 for '(M/G)Hz' plus 1 for '\0'
|
||||||
uint32_t size = (4+3+1);
|
uint32_t size = (5+1+3+1);
|
||||||
assert(strlen(STRING_UNKNOWN)+1 <= size);
|
assert(strlen(STRING_UNKNOWN)+1 <= size);
|
||||||
char* string = malloc(sizeof(char)*size);
|
char* string = malloc(sizeof(char)*size);
|
||||||
memset(string, 0, sizeof(char)*size);
|
memset(string, 0, sizeof(char)*size);
|
||||||
@@ -155,9 +155,9 @@ char* get_str_freq(struct frequency* freq) {
|
|||||||
if(freq->max == UNKNOWN_FREQ || freq->max < 0)
|
if(freq->max == UNKNOWN_FREQ || freq->max < 0)
|
||||||
snprintf(string,strlen(STRING_UNKNOWN)+1,STRING_UNKNOWN);
|
snprintf(string,strlen(STRING_UNKNOWN)+1,STRING_UNKNOWN);
|
||||||
else if(freq->max >= 1000)
|
else if(freq->max >= 1000)
|
||||||
snprintf(string,size,"%.2f"STRING_GIGAHERZ,(float)(freq->max)/1000);
|
snprintf(string,size,"%.3f "STRING_GIGAHERZ,(float)(freq->max)/1000);
|
||||||
else
|
else
|
||||||
snprintf(string,size,"%d"STRING_MEGAHERZ,freq->max);
|
snprintf(string,size,"%d "STRING_MEGAHERZ,freq->max);
|
||||||
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ struct cpuInfo {
|
|||||||
uint32_t maxLevels;
|
uint32_t maxLevels;
|
||||||
// Max cpuids extended levels
|
// Max cpuids extended levels
|
||||||
uint32_t maxExtendedLevels;
|
uint32_t maxExtendedLevels;
|
||||||
|
// Topology Extensions (AMD only)
|
||||||
|
bool topology_extensions;
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
// Main ID register
|
// Main ID register
|
||||||
uint32_t midr;
|
uint32_t midr;
|
||||||
|
|||||||
@@ -64,3 +64,11 @@ void set_log_level(bool verbose) {
|
|||||||
if(verbose) LOG_LEVEL = LOG_LEVEL_VERBOSE;
|
if(verbose) LOG_LEVEL = LOG_LEVEL_VERBOSE;
|
||||||
else LOG_LEVEL = LOG_LEVEL_NORMAL;
|
else LOG_LEVEL = LOG_LEVEL_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int max(int a, int b) {
|
||||||
|
return a > b ? a : b;
|
||||||
|
}
|
||||||
|
|
||||||
|
int min(int a, int b) {
|
||||||
|
return a < b ? a : b;
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,5 +7,7 @@ void set_log_level(bool verbose);
|
|||||||
void printWarn(const char *fmt, ...);
|
void printWarn(const char *fmt, ...);
|
||||||
void printErr(const char *fmt, ...);
|
void printErr(const char *fmt, ...);
|
||||||
void printBug(const char *fmt, ...);
|
void printBug(const char *fmt, ...);
|
||||||
|
int max(int a, int b);
|
||||||
|
int min(int a, int b);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "args.h"
|
#include "args.h"
|
||||||
#include "printer.h"
|
#include "printer.h"
|
||||||
@@ -13,41 +14,59 @@
|
|||||||
#include "../arm/midr.h"
|
#include "../arm/midr.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char* VERSION = "0.95";
|
static const char* VERSION = "0.97";
|
||||||
|
|
||||||
void print_help(char *argv[]) {
|
void print_help(char *argv[]) {
|
||||||
printf("Usage: %s [--version] [--help] [--debug] [--style \"fancy\"|\"retro\"|\"legacy\"] [--color \"intel\"|\"amd\"|'R,G,B:R,G,B:R,G,B:R,G,B']\n\n", argv[0]);
|
const char **t = args_str;
|
||||||
|
const char *c = args_chr;
|
||||||
|
int max_len = max_arg_str_length();
|
||||||
|
|
||||||
printf("Options: \n\
|
printf("Usage: %s [OPTION]...\n", argv[0]);
|
||||||
--color Set the color scheme. By default, cpufetch uses the system color scheme. This option \n\
|
printf("Simple yet fancy CPU architecture fetching tool\n\n");
|
||||||
lets the user use different colors to print the CPU art: \n\
|
|
||||||
* \"intel\": Use Intel default color scheme \n\
|
|
||||||
* \"amd\": Use AMD default color scheme \n\
|
|
||||||
* \"arm\": Use ARM default color scheme \n\
|
|
||||||
* custom: If color argument do not match \"Intel\", \"AMD\" or \"ARM\", a custom scheme can be specified: \n\
|
|
||||||
4 colors must be given in RGB with the format: R,G,B:R,G,B:... \n\
|
|
||||||
These colors correspond to CPU art color (2 colors) and for the text colors (following 2) \n\
|
|
||||||
For example: --color 239,90,45:210,200,200:100,200,45:0,200,200 \n\n\
|
|
||||||
--style Set the style of CPU art: \n\
|
|
||||||
* \"fancy\": Default style \n\
|
|
||||||
* \"retro\": Old cpufetch style \n\
|
|
||||||
* \"legacy\": Fallback style for terminals that does not support colors \n\n");
|
|
||||||
|
|
||||||
|
printf("Options: \n");
|
||||||
|
printf(" -%c, --%s %*s Set the color scheme (by default, cpufetch uses the system color scheme)\n", c[ARG_COLOR], t[ARG_COLOR], (int) (max_len-strlen(t[ARG_COLOR])), "");
|
||||||
|
printf(" -%c, --%s %*s Set the style of CPU art\n", c[ARG_STYLE], t[ARG_STYLE], (int) (max_len-strlen(t[ARG_STYLE])), "");
|
||||||
|
printf(" -%c, --%s %*s Runs cpufetch in a loop\n", c[ARG_LOOP], t[ARG_LOOP], (int) (max_len-strlen(t[ARG_LOOP])), "");
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
printf(" --debug Prints CPU model and cpuid levels (debug purposes)\n\n");
|
printf(" -%c, --%s %*s Prints CPU model and cpuid levels (debug purposes)\n", c[ARG_DEBUG], t[ARG_DEBUG], (int) (max_len-strlen(t[ARG_DEBUG])), "");
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
printf(" --debug Prints main ID register values for all cores (debug purposes)\n\n");
|
printf(" -%c, --%s %*s Prints main ID register values for all cores (debug purposes)\n", c[ARG_DEBUG], t[ARG_DEBUG], (int) (max_len-strlen(t[ARG_DEBUG])), "");
|
||||||
#endif
|
#endif
|
||||||
|
printf(" -%c, --%s %*s Prints extra information (if available) about how cpufetch tried fetching information\n", c[ARG_VERBOSE], t[ARG_VERBOSE], (int) (max_len-strlen(t[ARG_VERBOSE])), "");
|
||||||
|
#ifdef ARCH_X86
|
||||||
|
printf(" -%c, --%s %*s Prints raw cpuid data\n", c[ARG_RAW], t[ARG_RAW], (int) (max_len-strlen(t[ARG_RAW])), "");
|
||||||
|
#endif
|
||||||
|
printf(" -%c, --%s %*s Prints this help and exit\n", c[ARG_HELP], t[ARG_HELP], (int) (max_len-strlen(t[ARG_HELP])), "");
|
||||||
|
printf(" -%c, --%s %*s Prints cpufetch version and exit\n", c[ARG_VERSION], t[ARG_VERSION], (int) (max_len-strlen(t[ARG_VERSION])), "");
|
||||||
|
|
||||||
printf(" --verbose Prints extra information (if available) about how cpufetch tried fetching information\n\n\
|
printf("\nCOLORS: \n");
|
||||||
--help Prints this help and exit\n\n\
|
printf(" * \"intel\": Use Intel default color scheme \n");
|
||||||
--version Prints cpufetch version and exit\n\n\
|
printf(" * \"amd\": Use AMD default color scheme \n");
|
||||||
\n\
|
printf(" * \"arm\": Use ARM default color scheme \n");
|
||||||
NOTES: \n\
|
printf(" * custom: If color argument do not match \"intel\", \"amd\" or \"arm\", a custom scheme can be specified.\n");
|
||||||
- Bugs or improvements should be submitted to: github.com/Dr-Noob/cpufetch/issues \n\
|
printf(" 4 colors must be given in RGB with the format: R,G,B:R,G,B:...\n");
|
||||||
- Peak performance information is NOT accurate. cpufetch computes peak performance using the max \n\
|
printf(" The first 2 colors are the CPU art color and the next 2 colors are the text colors\n");
|
||||||
frequency. However, to properly compute peak performance, you need to know the frequency of the \n\
|
|
||||||
CPU running AVX code, which is not be fetched by cpufetch since it depends on each specific CPU. \n");
|
printf("\nSTYLES: \n");
|
||||||
|
printf(" * \"fancy\": Default style\n");
|
||||||
|
printf(" * \"retro\": Old cpufetch style\n");
|
||||||
|
printf(" * \"legacy\": Fallback style for terminals that do not support colors\n");
|
||||||
|
|
||||||
|
printf("\nEXAMPLES: \n");
|
||||||
|
printf(" Run cpufetch with Intel color scheme:\n");
|
||||||
|
printf(" ./cpufetch --color intel\n");
|
||||||
|
printf(" Run cpufetch with a custom color scheme:\n");
|
||||||
|
printf(" ./cpufetch --color 239,90,45:210,200,200:100,200,45:0,200,200\n");
|
||||||
|
|
||||||
|
printf("\nBUGS: \n");
|
||||||
|
printf(" Report bugs to https://github.com/Dr-Noob/cpufetch/issues\n");
|
||||||
|
|
||||||
|
printf("\nNOTE: \n");
|
||||||
|
printf(" Peak performance information is NOT accurate. cpufetch computes peak performance using the max\n");
|
||||||
|
printf(" frequency. However, to properly compute peak performance, you need to know the frequency of the\n");
|
||||||
|
printf(" CPU running AVX code, which is not be fetched by cpufetch since it depends on each specific CPU.\n");
|
||||||
|
printf(" For peak performance measurement see: https://github.com/Dr-Noob/peakperf\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_version() {
|
void print_version() {
|
||||||
@@ -59,7 +78,6 @@ int main(int argc, char* argv[]) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
if(show_help()) {
|
if(show_help()) {
|
||||||
print_version();
|
|
||||||
print_help(argv);
|
print_help(argv);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -81,6 +99,17 @@ int main(int argc, char* argv[]) {
|
|||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(show_raw()) {
|
||||||
|
#ifdef ARCH_X86
|
||||||
|
print_version();
|
||||||
|
print_raw(cpu);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
#else
|
||||||
|
printErr("raw option is valid only in x86_64");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if(print_cpufetch(cpu, get_style(), get_colors()))
|
if(print_cpufetch(cpu, get_style(), get_colors()))
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
|
#ifdef _WIN32
|
||||||
|
#define NOMINMAX
|
||||||
|
#include <Windows.h>
|
||||||
|
#else
|
||||||
|
#ifdef __linux__
|
||||||
|
#define _POSIX_C_SOURCE 199309L
|
||||||
|
#endif
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -17,11 +29,6 @@
|
|||||||
#include "../arm/soc.h"
|
#include "../arm/soc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define NOMINMAX
|
|
||||||
#include <Windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define max(a,b) (((a)>(b))?(a):(b))
|
#define max(a,b) (((a)>(b))?(a):(b))
|
||||||
#define MAX_ATTRIBUTES 100
|
#define MAX_ATTRIBUTES 100
|
||||||
|
|
||||||
@@ -118,6 +125,29 @@ struct ascii {
|
|||||||
STYLE style;
|
STYLE style;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct terminal {
|
||||||
|
int w;
|
||||||
|
int h;
|
||||||
|
};
|
||||||
|
|
||||||
|
volatile sig_atomic_t loop = 1;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
BOOL WINAPI loop_mode_handler(DWORD signum) {
|
||||||
|
if (signum == CTRL_C_EVENT) {
|
||||||
|
loop = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void loop_mode_handler(int signum) {
|
||||||
|
if(signum == SIGINT) {
|
||||||
|
loop = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void setAttribute(struct ascii* art, int type, char* value) {
|
void setAttribute(struct ascii* art, int type, char* value) {
|
||||||
art->attributes[art->n_attributes_set]->value = value;
|
art->attributes[art->n_attributes_set]->value = value;
|
||||||
art->attributes[art->n_attributes_set]->type = type;
|
art->attributes[art->n_attributes_set]->type = type;
|
||||||
@@ -345,6 +375,33 @@ uint32_t longest_attribute_length(struct ascii* art) {
|
|||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool run_loop_mode() {
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (!SetConsoleCtrlHandler(loop_mode_handler, TRUE)) {
|
||||||
|
printErr("SetConsoleCtrlHandler failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
struct sigaction act;
|
||||||
|
memset(&act, 0, sizeof(struct sigaction));
|
||||||
|
act.sa_handler = loop_mode_handler;
|
||||||
|
if(sigaction(SIGINT, &act, NULL) == -1) {
|
||||||
|
perror("sigaction");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
while (loop) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
Sleep(1000);
|
||||||
|
#else
|
||||||
|
sleep(1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
void print_algorithm_intel(struct ascii* art, int n, bool* flag) {
|
void print_algorithm_intel(struct ascii* art, int n, bool* flag) {
|
||||||
for(int i=0; i < LINE_SIZE; i++) {
|
for(int i=0; i < LINE_SIZE; i++) {
|
||||||
@@ -382,46 +439,59 @@ void print_algorithm_amd(struct ascii* art, int n, bool* flag) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_ascii_x86(struct ascii* art, uint32_t la, void (*callback_print_algorithm)(struct ascii* art, int i, bool* flag)) {
|
void print_ascii_x86(struct ascii* art, struct terminal* term, uint32_t la, void (*callback_print_algorithm)(struct ascii* art, int i, bool* flag)) {
|
||||||
int attr_to_print = 0;
|
int attr_to_print = 0;
|
||||||
int attr_type;
|
int attr_type;
|
||||||
char* attr_value;
|
char* attr_value;
|
||||||
|
int attr_print_len;
|
||||||
|
uint32_t attr_space_left;
|
||||||
uint32_t space_right;
|
uint32_t space_right;
|
||||||
uint32_t space_up = (NUMBER_OF_LINES - art->n_attributes_set)/2;
|
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;
|
uint32_t space_down = NUMBER_OF_LINES - art->n_attributes_set - space_up;
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
|
bool print_ascii_art;
|
||||||
|
|
||||||
|
if(term->w - LINE_SIZE - 1 - (int) la > 0) {
|
||||||
|
print_ascii_art = true;
|
||||||
|
attr_space_left = term->w - LINE_SIZE - 1 - la;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print_ascii_art = false;
|
||||||
|
attr_space_left = term->w - 1 - la;
|
||||||
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
for(uint32_t n=0;n<NUMBER_OF_LINES;n++) {
|
for(uint32_t n=0;n<NUMBER_OF_LINES;n++) {
|
||||||
callback_print_algorithm(art, n, &flag);
|
if(print_ascii_art) callback_print_algorithm(art, n, &flag);
|
||||||
|
|
||||||
if(n > space_up-1 && n < NUMBER_OF_LINES-space_down) {
|
if(n > space_up-1 && n < NUMBER_OF_LINES-space_down) {
|
||||||
attr_type = art->attributes[attr_to_print]->type;
|
attr_type = art->attributes[attr_to_print]->type;
|
||||||
attr_value = art->attributes[attr_to_print]->value;
|
attr_value = art->attributes[attr_to_print]->value;
|
||||||
attr_to_print++;
|
attr_to_print++;
|
||||||
|
|
||||||
|
attr_print_len = min(strlen(attr_value), attr_space_left);
|
||||||
|
attr_print_len = max(attr_print_len, 0);
|
||||||
space_right = 1 + (la - strlen(ATTRIBUTE_FIELDS[attr_type]));
|
space_right = 1 + (la - strlen(ATTRIBUTE_FIELDS[attr_type]));
|
||||||
printf("%s%s%s%*s%s%s%s\n", art->color1_text, ATTRIBUTE_FIELDS[attr_type], art->reset, space_right, "", art->color2_text, attr_value, art->reset);
|
printf("%s%s%s%*s%s%.*s%s\n", art->color1_text, ATTRIBUTE_FIELDS[attr_type], art->reset, space_right, "", art->color2_text, attr_print_len, attr_value, art->reset);
|
||||||
}
|
}
|
||||||
else printf("\n");
|
else printf("\n");
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_ascii(struct ascii* art) {
|
void print_ascii(struct ascii* art, struct terminal* term) {
|
||||||
uint32_t longest_attribute = longest_attribute_length(art);
|
uint32_t longest_attribute = longest_attribute_length(art);
|
||||||
|
|
||||||
if(art->vendor == CPU_VENDOR_INTEL)
|
if(art->vendor == CPU_VENDOR_INTEL)
|
||||||
print_ascii_x86(art, longest_attribute, &print_algorithm_intel);
|
print_ascii_x86(art, term, longest_attribute, &print_algorithm_intel);
|
||||||
else if(art->vendor == CPU_VENDOR_AMD)
|
else if(art->vendor == CPU_VENDOR_AMD)
|
||||||
print_ascii_x86(art, longest_attribute, &print_algorithm_amd);
|
print_ascii_x86(art, term, longest_attribute, &print_algorithm_amd);
|
||||||
else {
|
else {
|
||||||
printBug("Invalid CPU vendor: %d\n", art->vendor);
|
printBug("Invalid CPU vendor: %d\n", art->vendor);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct colors* cs, struct terminal* term) {
|
||||||
struct ascii* art = set_ascii(get_cpu_vendor(cpu), s, cs);
|
struct ascii* art = set_ascii(get_cpu_vendor(cpu), s, cs);
|
||||||
if(art == NULL)
|
if(art == NULL)
|
||||||
return false;
|
return false;
|
||||||
@@ -436,7 +506,6 @@ bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
|||||||
char* avx = get_str_avx(cpu);
|
char* avx = get_str_avx(cpu);
|
||||||
char* fma = get_str_fma(cpu);
|
char* fma = get_str_fma(cpu);
|
||||||
|
|
||||||
|
|
||||||
char* l1i = get_str_l1i(cpu->cach);
|
char* l1i = get_str_l1i(cpu->cach);
|
||||||
char* l1d = get_str_l1d(cpu->cach);
|
char* l1d = get_str_l1d(cpu->cach);
|
||||||
char* l2 = get_str_l2(cpu->cach);
|
char* l2 = get_str_l2(cpu->cach);
|
||||||
@@ -474,7 +543,11 @@ bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_ascii(art);
|
print_ascii(art, term);
|
||||||
|
|
||||||
|
if(loop_mode()) {
|
||||||
|
return run_loop_mode();
|
||||||
|
}
|
||||||
|
|
||||||
free(manufacturing_process);
|
free(manufacturing_process);
|
||||||
free(max_frequency);
|
free(max_frequency);
|
||||||
@@ -542,7 +615,7 @@ void print_algorithm_arm(struct ascii* art, int n) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_ascii_arm(struct ascii* art, uint32_t la, void (*callback_print_algorithm)(struct ascii* art, int n)) {
|
void print_ascii_arm(struct ascii* art, struct terminal* term, uint32_t la, void (*callback_print_algorithm)(struct ascii* art, int n)) {
|
||||||
int attr_to_print = 0;
|
int attr_to_print = 0;
|
||||||
int attr_type;
|
int attr_type;
|
||||||
char* attr_value;
|
char* attr_value;
|
||||||
@@ -601,18 +674,18 @@ void print_ascii(struct ascii* art) {
|
|||||||
uint32_t longest_attribute = longest_attribute_length(art);
|
uint32_t longest_attribute = longest_attribute_length(art);
|
||||||
|
|
||||||
if(art->vendor == SOC_VENDOR_SNAPDRAGON || art->vendor == SOC_VENDOR_MEDIATEK || art->vendor == SOC_VENDOR_KIRIN || art->vendor == SOC_VENDOR_BROADCOM)
|
if(art->vendor == SOC_VENDOR_SNAPDRAGON || art->vendor == SOC_VENDOR_MEDIATEK || art->vendor == SOC_VENDOR_KIRIN || art->vendor == SOC_VENDOR_BROADCOM)
|
||||||
print_ascii_arm(art, longest_attribute, &print_algorithm_snapd_mtk);
|
print_ascii_arm(art, term, longest_attribute, &print_algorithm_snapd_mtk);
|
||||||
else if(art->vendor == SOC_VENDOR_EXYNOS)
|
else if(art->vendor == SOC_VENDOR_EXYNOS)
|
||||||
print_ascii_arm(art, longest_attribute, &print_algorithm_samsung);
|
print_ascii_arm(art, term, longest_attribute, &print_algorithm_samsung);
|
||||||
else {
|
else {
|
||||||
if(art->vendor != SOC_VENDOR_UNKNOWN)
|
if(art->vendor != SOC_VENDOR_UNKNOWN)
|
||||||
printWarn("Invalid SOC vendor: %d\n", art->vendor);
|
printWarn("Invalid SOC vendor: %d\n", art->vendor);
|
||||||
print_ascii_arm(art, longest_attribute, &print_algorithm_arm);
|
print_ascii_arm(art, term, longest_attribute, &print_algorithm_arm);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool print_cpufetch_arm(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
bool print_cpufetch_arm(struct cpuInfo* cpu, STYLE s, struct colors* cs, struct terminal* term) {
|
||||||
struct ascii* art = set_ascii(get_soc_vendor(cpu->soc), s, cs);
|
struct ascii* art = set_ascii(get_soc_vendor(cpu->soc), s, cs);
|
||||||
if(art == NULL)
|
if(art == NULL)
|
||||||
return false;
|
return false;
|
||||||
@@ -680,7 +753,11 @@ bool print_cpufetch_arm(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
|||||||
if(cpu->hv->present)
|
if(cpu->hv->present)
|
||||||
setAttribute(art, ATTRIBUTE_HYPERVISOR, cpu->hv->hv_name);
|
setAttribute(art, ATTRIBUTE_HYPERVISOR, cpu->hv->hv_name);
|
||||||
|
|
||||||
print_ascii(art);
|
print_ascii(art, term);
|
||||||
|
|
||||||
|
if(loop_mode()) {
|
||||||
|
return run_loop_mode();
|
||||||
|
}
|
||||||
|
|
||||||
free(manufacturing_process);
|
free(manufacturing_process);
|
||||||
free(pp);
|
free(pp);
|
||||||
@@ -697,6 +774,31 @@ bool print_cpufetch_arm(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct terminal* get_terminal_size() {
|
||||||
|
struct terminal* term = malloc(sizeof(struct terminal));
|
||||||
|
memset(term, 0, sizeof(struct terminal));
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
if(GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) == 0) {
|
||||||
|
printWarn("GetConsoleScreenBufferInfo failed");
|
||||||
|
return term;
|
||||||
|
}
|
||||||
|
term->w = csbi.srWindow.Right - csbi.srWindow.Left + 1;
|
||||||
|
term->h = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
|
||||||
|
#else
|
||||||
|
struct winsize w;
|
||||||
|
if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) == -1) {
|
||||||
|
perror("ioctl");
|
||||||
|
return term;
|
||||||
|
}
|
||||||
|
term->h = w.ws_row;
|
||||||
|
term->w = w.ws_col;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return term;
|
||||||
|
}
|
||||||
|
|
||||||
bool print_cpufetch(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
bool print_cpufetch(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
||||||
// Sanity check of ASCII arts
|
// Sanity check of ASCII arts
|
||||||
int len = sizeof(ASCII_ARRAY) / sizeof(ASCII_ARRAY[0]);
|
int len = sizeof(ASCII_ARRAY) / sizeof(ASCII_ARRAY[0]);
|
||||||
@@ -708,9 +810,11 @@ bool print_cpufetch(struct cpuInfo* cpu, STYLE s, struct colors* cs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct terminal* term = get_terminal_size();
|
||||||
|
|
||||||
#ifdef ARCH_X86
|
#ifdef ARCH_X86
|
||||||
return print_cpufetch_x86(cpu, s, cs);
|
return print_cpufetch_x86(cpu, s, cs, term);
|
||||||
#elif ARCH_ARM
|
#elif ARCH_ARM
|
||||||
return print_cpufetch_arm(cpu, s, cs);
|
return print_cpufetch_arm(cpu, s, cs, term);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,17 +32,11 @@ long get_freq_from_file(char* path, bool hv_present) {
|
|||||||
int filelen;
|
int filelen;
|
||||||
char* buf;
|
char* buf;
|
||||||
if((buf = read_file(path, &filelen)) == NULL) {
|
if((buf = read_file(path, &filelen)) == NULL) {
|
||||||
#ifdef ARCH_X86
|
if(hv_present)
|
||||||
if(hv_present) {
|
printWarn("Could not open '%s' (HV is present)", path);
|
||||||
|
else
|
||||||
printWarn("Could not open '%s'", path);
|
printWarn("Could not open '%s'", path);
|
||||||
}
|
|
||||||
else {
|
|
||||||
perror("open");
|
|
||||||
printBug("Could not open '%s'", path);
|
|
||||||
}
|
|
||||||
#elif ARCH_ARM
|
|
||||||
printWarn("Could not open '%s'", path);
|
|
||||||
#endif
|
|
||||||
return UNKNOWN_FREQ;
|
return UNKNOWN_FREQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#define NOMINMAX
|
||||||
|
#include <windows.h>
|
||||||
#elif defined __linux__
|
#elif defined __linux__
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#elif defined __APPLE__
|
#elif defined __APPLE__
|
||||||
#define UNUSED(x) (void)(x)
|
#define UNUSED(x) (void)(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -318,7 +319,22 @@ bool get_topology_from_apic(struct cpuInfo* cpu, struct topology* topo) {
|
|||||||
uint32_t* apic_smt = malloc(sizeof(uint32_t) * topo->total_cores);
|
uint32_t* apic_smt = malloc(sizeof(uint32_t) * topo->total_cores);
|
||||||
uint32_t** cache_smt_id_apic = malloc(sizeof(uint32_t*) * topo->total_cores);
|
uint32_t** cache_smt_id_apic = malloc(sizeof(uint32_t*) * topo->total_cores);
|
||||||
uint32_t** cache_id_apic = malloc(sizeof(uint32_t*) * topo->total_cores);
|
uint32_t** cache_id_apic = malloc(sizeof(uint32_t*) * topo->total_cores);
|
||||||
bool x2apic_id = cpu->maxLevels >= 0x0000000B;
|
bool x2apic_id;
|
||||||
|
|
||||||
|
if(cpu->maxLevels >= 0x0000000B) {
|
||||||
|
uint32_t eax = 0x0000000B;
|
||||||
|
uint32_t ebx = 0;
|
||||||
|
uint32_t ecx = 0;
|
||||||
|
uint32_t edx = 0;
|
||||||
|
|
||||||
|
cpuid(&eax, &ebx, &ecx, &edx);
|
||||||
|
|
||||||
|
if(ebx == 0) x2apic_id = false;
|
||||||
|
else x2apic_id = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x2apic_id = false;
|
||||||
|
}
|
||||||
|
|
||||||
for(int i=0; i < topo->total_cores; i++) {
|
for(int i=0; i < topo->total_cores; i++) {
|
||||||
cache_smt_id_apic[i] = malloc(sizeof(uint32_t) * (topo->cach->max_cache_level));
|
cache_smt_id_apic[i] = malloc(sizeof(uint32_t) * (topo->cach->max_cache_level));
|
||||||
|
|||||||
@@ -17,4 +17,8 @@ struct apic {
|
|||||||
bool get_topology_from_apic(struct cpuInfo* cpu, struct topology* topo);
|
bool get_topology_from_apic(struct cpuInfo* cpu, struct topology* topo);
|
||||||
uint32_t is_smt_enabled_amd(struct topology* topo);
|
uint32_t is_smt_enabled_amd(struct topology* topo);
|
||||||
|
|
||||||
|
#ifndef __APPLE__
|
||||||
|
bool bind_to_cpu(int cpu_id);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
175
src/x86/cpuid.c
175
src/x86/cpuid.c
@@ -1,4 +1,5 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#define NOMINMAX
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
#include "../common/udev.h"
|
#include "../common/udev.h"
|
||||||
@@ -309,16 +310,26 @@ struct cpuInfo* get_cpu_info() {
|
|||||||
printWarn("Can't read cpu name from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", 0x80000004, cpu->maxExtendedLevels);
|
printWarn("Can't read cpu name from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", 0x80000004, cpu->maxExtendedLevels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cpu->topology_extensions = false;
|
||||||
|
if(cpu->cpu_vendor == CPU_VENDOR_AMD && cpu->maxExtendedLevels >= 0x80000001) {
|
||||||
|
eax = 0x80000001;
|
||||||
|
cpuid(&eax, &ebx, &ecx, &edx);
|
||||||
|
cpu->topology_extensions = (ecx >> 22) & 1;
|
||||||
|
}
|
||||||
|
|
||||||
cpu->arch = get_cpu_uarch(cpu);
|
cpu->arch = get_cpu_uarch(cpu);
|
||||||
cpu->freq = get_frequency_info(cpu);
|
cpu->freq = get_frequency_info(cpu);
|
||||||
cpu->cach = get_cache_info(cpu);
|
cpu->cach = get_cache_info(cpu);
|
||||||
cpu->topo = get_topology_info(cpu, cpu->cach);
|
cpu->topo = get_topology_info(cpu, cpu->cach);
|
||||||
|
|
||||||
|
if(cpu->cach == NULL || cpu->topo == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return cpu;
|
return cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_cache_topology_amd(struct cpuInfo* cpu, struct topology* topo) {
|
bool get_cache_topology_amd(struct cpuInfo* cpu, struct topology* topo) {
|
||||||
if(cpu->maxExtendedLevels >= 0x8000001D) {
|
if(cpu->maxExtendedLevels >= 0x8000001D && cpu->topology_extensions) {
|
||||||
uint32_t i, eax, ebx, ecx, edx, num_sharing_cache, cache_type, cache_level;
|
uint32_t i, eax, ebx, ecx, edx, num_sharing_cache, cache_type, cache_level;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
@@ -361,13 +372,12 @@ bool get_cache_topology_amd(struct cpuInfo* cpu, struct topology* topo) {
|
|||||||
topo->cach->L3->num_caches = topo->logical_cores / num_sharing_cache;
|
topo->cach->L3->num_caches = topo->logical_cores / num_sharing_cache;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printBug("Found unified cache at level %d (expected == 2 or 3)", cache_level);
|
printWarn("Found unknown unified cache at level %d", cache_level);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: // Unknown Type Cache
|
default: // Unknown cache type
|
||||||
printBug("Unknown Type Cache found at ID %d", i);
|
printBug("Unknown cache type %d with level %d found at i=%d", cache_type, cache_level, i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,7 +386,7 @@ bool get_cache_topology_amd(struct cpuInfo* cpu, struct topology* topo) {
|
|||||||
} while (cache_type > 0);
|
} while (cache_type > 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printWarn("Can't read topology information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X). Guessing cache sizes", 0x8000001D, cpu->maxExtendedLevels);
|
printWarn("Can't read topology information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X and topology_extensions=%s). Guessing cache topology", 0x8000001D, cpu->maxExtendedLevels, cpu->topology_extensions ? "true" : "false");
|
||||||
topo->cach->L1i->num_caches = topo->physical_cores;
|
topo->cach->L1i->num_caches = topo->physical_cores;
|
||||||
topo->cach->L1d->num_caches = topo->physical_cores;
|
topo->cach->L1d->num_caches = topo->physical_cores;
|
||||||
|
|
||||||
@@ -424,7 +434,7 @@ struct topology* get_topology_info(struct cpuInfo* cpu, struct cache* cach) {
|
|||||||
get_topology_from_apic(cpu, topo);
|
get_topology_from_apic(cpu, topo);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printErr("Can't read topology information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000001, cpu->maxLevels);
|
printWarn("Can't read topology information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000001, cpu->maxLevels);
|
||||||
topo->physical_cores = 1;
|
topo->physical_cores = 1;
|
||||||
topo->logical_cores = 1;
|
topo->logical_cores = 1;
|
||||||
topo->smt_available = 1;
|
topo->smt_available = 1;
|
||||||
@@ -437,18 +447,18 @@ struct topology* get_topology_info(struct cpuInfo* cpu, struct cache* cach) {
|
|||||||
cpuid(&eax, &ebx, &ecx, &edx);
|
cpuid(&eax, &ebx, &ecx, &edx);
|
||||||
topo->logical_cores = (ecx & 0xFF) + 1;
|
topo->logical_cores = (ecx & 0xFF) + 1;
|
||||||
|
|
||||||
if (cpu->maxExtendedLevels >= 0x8000001E) {
|
if (cpu->maxExtendedLevels >= 0x8000001E && cpu->topology_extensions) {
|
||||||
eax = 0x8000001E;
|
eax = 0x8000001E;
|
||||||
cpuid(&eax, &ebx, &ecx, &edx);
|
cpuid(&eax, &ebx, &ecx, &edx);
|
||||||
topo->smt_supported = ((ebx >> 8) & 0x03) + 1;
|
topo->smt_supported = ((ebx >> 8) & 0x03) + 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printWarn("Can't read topology information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", 0x8000001E, cpu->maxExtendedLevels);
|
printWarn("Can't read topology information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X and topology_extensions=%s)", 0x8000001E, cpu->maxExtendedLevels, cpu->topology_extensions ? "true" : "false");
|
||||||
topo->smt_supported = 1;
|
topo->smt_supported = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printErr("Can't read topology information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", 0x80000008, cpu->maxExtendedLevels);
|
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->physical_cores = 1;
|
||||||
topo->logical_cores = 1;
|
topo->logical_cores = 1;
|
||||||
topo->smt_supported = 1;
|
topo->smt_supported = 1;
|
||||||
@@ -570,13 +580,12 @@ struct cache* get_cache_info_general(struct cache* cach, uint32_t level) {
|
|||||||
cach->L3->exists = true;
|
cach->L3->exists = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printBug("Found unified cache at level %d (expected == 2 or 3)", cache_level);
|
printWarn("Found unknown unified cache at level %d (size is %d bytes)", cache_level, cache_total_size);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: // Unknown Type Cache
|
default: // Unknown cache type
|
||||||
printBug("Unknown Type Cache found at ID %d", i);
|
printBug("Unknown cache type %d with level %d found at i=%d", cache_type, cache_level, i);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -599,7 +608,7 @@ struct cache* get_cache_info(struct cpuInfo* cpu) {
|
|||||||
if(cpu->cpu_vendor == CPU_VENDOR_INTEL) {
|
if(cpu->cpu_vendor == CPU_VENDOR_INTEL) {
|
||||||
level = 0x00000004;
|
level = 0x00000004;
|
||||||
if(cpu->maxLevels < level) {
|
if(cpu->maxLevels < level) {
|
||||||
printErr("Can't read cache information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", level, cpu->maxLevels);
|
printWarn("Can't read cache information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", level, cpu->maxLevels);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -608,11 +617,11 @@ struct cache* get_cache_info(struct cpuInfo* cpu) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
level = 0x8000001D;
|
level = 0x8000001D;
|
||||||
if(cpu->maxExtendedLevels < level) {
|
if(cpu->maxExtendedLevels < level || !cpu->topology_extensions) {
|
||||||
printWarn("Can't read cache information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", level, cpu->maxExtendedLevels);
|
printWarn("Can't read cache information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X and topology_extensions=%s)", level, cpu->maxExtendedLevels, cpu->topology_extensions ? "true" : "false");
|
||||||
level = 0x80000006;
|
level = 0x80000006;
|
||||||
if(cpu->maxExtendedLevels < level) {
|
if(cpu->maxExtendedLevels < level) {
|
||||||
printErr("Can't read cache information from cpuid using old method (needed extended level is 0x%.8X, max is 0x%.8X)", level, cpu->maxExtendedLevels);
|
printWarn("Can't read cache information from cpuid using old method (needed extended level is 0x%.8X, max is 0x%.8X)", level, cpu->maxExtendedLevels);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
printWarn("Fallback to old method using 0x%.8X and 0x%.8X", level-1, level);
|
printWarn("Fallback to old method using 0x%.8X and 0x%.8X", level-1, level);
|
||||||
@@ -623,35 +632,6 @@ struct cache* get_cache_info(struct cpuInfo* cpu) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanity checks. If we read values greater than this, they can't be valid ones
|
|
||||||
// The values were chosen by me
|
|
||||||
if(cach->L1i->size > 64 * 1024) {
|
|
||||||
printBug("Invalid L1i size: %dKB", cach->L1i->size/1024);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if(cach->L1d->size > 64 * 1024) {
|
|
||||||
printBug("Invalid L1d size: %dKB", cach->L1d->size/1024);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if(cach->L2->exists) {
|
|
||||||
if(cach->L3->exists && cach->L2->size > 2 * 1048576) {
|
|
||||||
printBug("Invalid L2 size: %dMB", cach->L2->size/(1048576));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else if(cach->L2->size > 100 * 1048576) {
|
|
||||||
printBug("Invalid L2 size: %dMB", cach->L2->size/(1048576));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(cach->L3->exists && cach->L3->size > 100 * 1048576) {
|
|
||||||
printBug("Invalid L3 size: %dMB", cach->L3->size/(1048576));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if(!cach->L2->exists) {
|
|
||||||
printBug("Could not find L2 cache");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cach;
|
return cach;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -659,17 +639,8 @@ struct frequency* get_frequency_info(struct cpuInfo* cpu) {
|
|||||||
struct frequency* freq = malloc(sizeof(struct frequency));
|
struct frequency* freq = malloc(sizeof(struct frequency));
|
||||||
|
|
||||||
if(cpu->maxLevels < 0x00000016) {
|
if(cpu->maxLevels < 0x00000016) {
|
||||||
#ifdef _WIN32
|
#if defined (_WIN32) || defined (__APPLE__)
|
||||||
if(cpu->hv->present) {
|
|
||||||
printWarn("Can't read frequency information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000016, cpu->maxLevels);
|
printWarn("Can't read frequency information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000016, cpu->maxLevels);
|
||||||
}
|
|
||||||
else {
|
|
||||||
printErr("Can't read frequency information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000016, cpu->maxLevels);
|
|
||||||
}
|
|
||||||
freq->base = UNKNOWN_FREQ;
|
|
||||||
freq->max = UNKNOWN_FREQ;
|
|
||||||
#elif defined __APPLE__
|
|
||||||
printErr("Can't read frequency information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000016, cpu->maxLevels);
|
|
||||||
freq->base = UNKNOWN_FREQ;
|
freq->base = UNKNOWN_FREQ;
|
||||||
freq->max = UNKNOWN_FREQ;
|
freq->max = UNKNOWN_FREQ;
|
||||||
#else
|
#else
|
||||||
@@ -903,14 +874,102 @@ void print_debug(struct cpuInfo* cpu) {
|
|||||||
cpuid(&eax, &ebx, &ecx, &edx);
|
cpuid(&eax, &ebx, &ecx, &edx);
|
||||||
|
|
||||||
printf("%s\n", cpu->cpu_name);
|
printf("%s\n", cpu->cpu_name);
|
||||||
if(cpu->hv->present) printf("- Hypervisor: %s\n", cpu->hv->hv_name);
|
if(cpu->hv->present) {
|
||||||
|
printf("- Hypervisor: %s\n", cpu->hv->hv_name);
|
||||||
|
}
|
||||||
printf("- Max standard level: 0x%.8X\n", cpu->maxLevels);
|
printf("- Max standard level: 0x%.8X\n", cpu->maxLevels);
|
||||||
printf("- Max extended level: 0x%.8X\n", cpu->maxExtendedLevels);
|
printf("- Max extended level: 0x%.8X\n", cpu->maxExtendedLevels);
|
||||||
|
if(cpu->cpu_vendor == CPU_VENDOR_AMD) {
|
||||||
|
printf("- AMD topology extensions: %d\n", cpu->topology_extensions);
|
||||||
|
}
|
||||||
printf("- CPUID dump: 0x%.8X\n", eax);
|
printf("- CPUID dump: 0x%.8X\n", eax);
|
||||||
|
|
||||||
free_cpuinfo_struct(cpu);
|
free_cpuinfo_struct(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Query HV and Xeon Phi levels
|
||||||
|
void print_raw(struct cpuInfo* cpu) {
|
||||||
|
uint32_t eax;
|
||||||
|
uint32_t ebx;
|
||||||
|
uint32_t ecx;
|
||||||
|
uint32_t edx;
|
||||||
|
printf("%s\n\n", cpu->cpu_name);
|
||||||
|
printf(" CPUID leaf sub EAX EBX ECX EDX \n");
|
||||||
|
printf("--------------------------------------------------------------\n");
|
||||||
|
|
||||||
|
for(int c=0; c < cpu->topo->total_cores; c++) {
|
||||||
|
#ifndef __APPLE__
|
||||||
|
if(!bind_to_cpu(c)) {
|
||||||
|
printErr("Failed binding to CPU %d", c);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("CPU %d:\n", c);
|
||||||
|
|
||||||
|
for(uint32_t reg=0x00000000; reg <= cpu->maxLevels; reg++) {
|
||||||
|
if(reg == 0x00000004) {
|
||||||
|
for(uint32_t reg2=0x00000000; reg2 < cpu->cach->max_cache_level; reg2++) {
|
||||||
|
eax = reg;
|
||||||
|
ebx = 0;
|
||||||
|
ecx = reg2;
|
||||||
|
edx = 0;
|
||||||
|
|
||||||
|
cpuid(&eax, &ebx, &ecx, &edx);
|
||||||
|
|
||||||
|
printf(" 0x%.8X 0x%.2X: 0x%.8X 0x%.8X 0x%.8X 0x%.8X\n", reg, reg2, eax, ebx, ecx, edx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(reg == 0x0000000B) {
|
||||||
|
for(uint32_t reg2=0x00000000; reg2 < cpu->topo->smt_supported; reg2++) {
|
||||||
|
eax = reg;
|
||||||
|
ebx = 0;
|
||||||
|
ecx = reg2;
|
||||||
|
edx = 0;
|
||||||
|
|
||||||
|
cpuid(&eax, &ebx, &ecx, &edx);
|
||||||
|
|
||||||
|
printf(" 0x%.8X 0x%.2X: 0x%.8X 0x%.8X 0x%.8X 0x%.8X\n", reg, reg2, eax, ebx, ecx, edx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
eax = reg;
|
||||||
|
ebx = 0;
|
||||||
|
ecx = 0;
|
||||||
|
edx = 0;
|
||||||
|
|
||||||
|
cpuid(&eax, &ebx, &ecx, &edx);
|
||||||
|
|
||||||
|
printf(" 0x%.8X 0x%.2X: 0x%.8X 0x%.8X 0x%.8X 0x%.8X\n", reg, 0x00, eax, ebx, ecx, edx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(uint32_t reg=0x80000000; reg <= cpu->maxExtendedLevels; reg++) {
|
||||||
|
if(reg == 0x8000001D) {
|
||||||
|
for(uint32_t reg2=0x00000000; reg2 < cpu->cach->max_cache_level; reg2++) {
|
||||||
|
eax = reg;
|
||||||
|
ebx = 0;
|
||||||
|
ecx = reg2;
|
||||||
|
edx = 0;
|
||||||
|
|
||||||
|
cpuid(&eax, &ebx, &ecx, &edx);
|
||||||
|
|
||||||
|
printf(" 0x%.8X 0x%.2X: 0x%.8X 0x%.8X 0x%.8X 0x%.8X\n", reg, reg2, eax, ebx, ecx, edx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
eax = reg;
|
||||||
|
ebx = 0;
|
||||||
|
ecx = 0;
|
||||||
|
edx = 0;
|
||||||
|
|
||||||
|
cpuid(&eax, &ebx, &ecx, &edx);
|
||||||
|
|
||||||
|
printf(" 0x%.8X 0x%.2X: 0x%.8X 0x%.8X 0x%.8X 0x%.8X\n", reg, 0x00, eax, ebx, ecx, edx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void free_topo_struct(struct topology* topo) {
|
void free_topo_struct(struct topology* topo) {
|
||||||
free(topo->apic->cache_select_mask);
|
free(topo->apic->cache_select_mask);
|
||||||
free(topo->apic->cache_id_apic);
|
free(topo->apic->cache_id_apic);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ char* get_str_topology(struct cpuInfo* cpu, struct topology* topo, bool dual_soc
|
|||||||
char* get_str_peak_performance(struct cpuInfo* cpu, struct topology* topo, int64_t freq);
|
char* get_str_peak_performance(struct cpuInfo* cpu, struct topology* topo, int64_t freq);
|
||||||
|
|
||||||
void print_debug(struct cpuInfo* cpu);
|
void print_debug(struct cpuInfo* cpu);
|
||||||
|
void print_raw(struct cpuInfo* cpu);
|
||||||
|
|
||||||
void free_topo_struct(struct topology* topo);
|
void free_topo_struct(struct topology* topo);
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ enum {
|
|||||||
UARCH_AIRMONT,
|
UARCH_AIRMONT,
|
||||||
UARCH_KABY_LAKE,
|
UARCH_KABY_LAKE,
|
||||||
UARCH_COMET_LAKE,
|
UARCH_COMET_LAKE,
|
||||||
|
UARCH_ROCKET_LAKE,
|
||||||
UARCH_AMBER_LAKE,
|
UARCH_AMBER_LAKE,
|
||||||
UARCH_WHISKEY_LAKE,
|
UARCH_WHISKEY_LAKE,
|
||||||
UARCH_SKYLAKE,
|
UARCH_SKYLAKE,
|
||||||
@@ -233,6 +234,7 @@ struct uarch* get_uarch_from_cpuid_intel(uint32_t ef, uint32_t f, uint32_t em, u
|
|||||||
CHECK_UARCH(arch, 0, 6, 9, 14, 13, "Coffee Lake", UARCH_COFFE_LAKE, 14)
|
CHECK_UARCH(arch, 0, 6, 9, 14, 13, "Coffee Lake", UARCH_COFFE_LAKE, 14)
|
||||||
CHECK_UARCH(arch, 0, 6, 10, 5, NA, "Comet Lake", UARCH_COMET_LAKE, 14) // wikichip
|
CHECK_UARCH(arch, 0, 6, 10, 5, NA, "Comet Lake", UARCH_COMET_LAKE, 14) // wikichip
|
||||||
CHECK_UARCH(arch, 0, 6, 10, 6, NA, "Comet Lake", UARCH_COMET_LAKE, 14) // instlatx64.atw.hu (i7-10710U)
|
CHECK_UARCH(arch, 0, 6, 10, 6, NA, "Comet Lake", UARCH_COMET_LAKE, 14) // instlatx64.atw.hu (i7-10710U)
|
||||||
|
CHECK_UARCH(arch, 0, 6, 10, 7, NA, "Rocket Lake", UARCH_ROCKET_LAKE, 14) // instlatx64.atw.hu (i7-11700K)
|
||||||
CHECK_UARCH(arch, 0, 11, 0, 0, NA, "Knights Ferry", UARCH_KNIGHTS_FERRY, 45) // found only on en.wikichip.org
|
CHECK_UARCH(arch, 0, 11, 0, 0, NA, "Knights Ferry", UARCH_KNIGHTS_FERRY, 45) // found only on en.wikichip.org
|
||||||
CHECK_UARCH(arch, 0, 11, 0, 1, NA, "Knights Corner", UARCH_KNIGHTS_CORNER, 22)
|
CHECK_UARCH(arch, 0, 11, 0, 1, NA, "Knights Corner", UARCH_KNIGHTS_CORNER, 22)
|
||||||
CHECK_UARCH(arch, 0, 15, 0, 0, NA, "Willamette", UARCH_WILLAMETTE, 180)
|
CHECK_UARCH(arch, 0, 15, 0, 0, NA, "Willamette", UARCH_WILLAMETTE, 180)
|
||||||
@@ -367,6 +369,7 @@ bool is_knights_landing(struct cpuInfo* cpu) {
|
|||||||
|
|
||||||
int get_number_of_vpus(struct cpuInfo* cpu) {
|
int get_number_of_vpus(struct cpuInfo* cpu) {
|
||||||
switch(cpu->arch->uarch) {
|
switch(cpu->arch->uarch) {
|
||||||
|
// Intel
|
||||||
case UARCH_HASWELL:
|
case UARCH_HASWELL:
|
||||||
case UARCH_BROADWELL:
|
case UARCH_BROADWELL:
|
||||||
|
|
||||||
@@ -374,6 +377,7 @@ int get_number_of_vpus(struct cpuInfo* cpu) {
|
|||||||
case UARCH_CASCADE_LAKE:
|
case UARCH_CASCADE_LAKE:
|
||||||
case UARCH_KABY_LAKE:
|
case UARCH_KABY_LAKE:
|
||||||
case UARCH_COMET_LAKE:
|
case UARCH_COMET_LAKE:
|
||||||
|
case UARCH_ROCKET_LAKE:
|
||||||
case UARCH_AMBER_LAKE:
|
case UARCH_AMBER_LAKE:
|
||||||
case UARCH_WHISKEY_LAKE:
|
case UARCH_WHISKEY_LAKE:
|
||||||
case UARCH_COFFE_LAKE:
|
case UARCH_COFFE_LAKE:
|
||||||
@@ -384,7 +388,7 @@ int get_number_of_vpus(struct cpuInfo* cpu) {
|
|||||||
|
|
||||||
case UARCH_ICE_LAKE:
|
case UARCH_ICE_LAKE:
|
||||||
|
|
||||||
// Right now is just a guess!
|
// AMD
|
||||||
case UARCH_ZEN2:
|
case UARCH_ZEN2:
|
||||||
case UARCH_ZEN3:
|
case UARCH_ZEN3:
|
||||||
return 2;
|
return 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user