1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2024-11-10 22:59:13 +00:00
libcpuid/Readme.md

114 lines
4.1 KiB
Markdown
Raw Normal View History

# libcpuid
libcpuid provides CPU identification. Supported CPU architectures are:
- x86:
- 32-bit CPUs (IA-32, also known as i386, i486, i586 and i686)
2024-06-30 11:50:35 +00:00
- 64-bit CPUs (x86_64, also known as x64, AMD64, and Intel 64)
- ARM (since v0.7.0):
- 64-bit CPUs (ARM64, also known as AArch64)
For details about the programming API, you might want to
take a look at the project's website on sourceforge
2024-07-01 07:46:13 +00:00
(https://libcpuid.sourceforge.net). There you'd find a short
[tutorial](https://libcpuid.sourceforge.net/documentation.html), as well
as the full [API reference](https://anrieff.github.io/libcpuid).
## Getting started
You have two ways to get libcpuid:
- build it from sources
- download a pre-compiled binary
### Sources
#### Prerequisites
Using libcpuid requires no dependencies on any of the supported OSes.
Building it requires build tool commands to be available,
which is a matter of installing a few common packages
with related names (e.g. automake, autoconf, libtool, cmake).
It also requires a POSIX-compatible shell. On NetBSD, you may need
to install one (credits to @brucelilly):
1. Install a POSIX-compatible shell such as ksh93
```shell
pkg_add ast-ksh || pkgin in ast-ksh
```
2. Export `CONFIG_SHELL` with correct path if required:
```shell
export CONFIG_SHELL=/usr/pkg/bin/ksh93
Support for hybrid CPU (#166) * Set CMAKE_C_FLAGS_DEBUG to display warnings during build CI workflows are reporting warnings. Adding more C flags here help to avoid that. * Add new types * Add set_cpu_affinity function * Add cpu_identify_all function * Add cpu_request_core_type function * Add cpuid_get_all_raw_data, cpuid_serialize_all_raw_data and cpuid_deserialize_all_raw_data functions * Detect hybrid architecture for Intel CPUs * Update cpuid_tool to detect all CPU logical cores * Rename tests subdirectories for Intel Core * Update all tests Since e4309a6c4bc3ad875711a1599cba01a205b3103e, new fields are reported by cpuid_tool * Add Intel Alder Lake Fix #157 * Remove convert_instlatx64.c This tool is not useful anymore because the cpuid_deserialize_raw_data_internal() function can natively parse them since 5667e1401c2ad50e1a79769d1f0334369aa44377 * Fix affinity_mask computation * Define _GNU_SOURCE in configure.ac Forgotten in 4f80964db5bab011c1893ad17adcaec20d6d7fae * Use dynamic raw array in cpu_raw_data_array_t * Add cpu_affinity_mask_t type * Improve set_cpu_affinity function - Print a warning if logical CPU number is not supported on operating system - Return a boolean value in case of success instead of an integer * Improve cpu_identify_all and cpu_request_core_type functions * Use dynamic array for cpu_types in system_id_t This commit also adds cleanups, fixes and consistency * Tests: update Ryzen 5 Matisse with all CPU cores * Add affinity_mask_str_r function and address other comments - Fixed cpuid_grow_raw_data_array and cpu_raw_data_array_t.logical_cpu_t with the correct type - Added a note about hard limit of cpu_raw_data_array_t - Fixed a typo in cpuid_deserialize_raw_data_internal * Fix build on Windows
2022-09-15 16:37:08 +00:00
```
#### Configuring after checkout
Two build systems are supported, use the one you prefer.
##### By using autotools
Under POSIX systems, where you download the sources, there's no
configure script to run. This is because it isn't a good practice to keep
such scripts in a source control system. To create it, you need to run the
following commands once, after you checkout the libcpuid sources
from GitHub:
```shell
libtoolize
autoreconf --install
```
You need to have `autoconf`, `automake` and `libtool` installed.
After that you can run `./configure` and `make` - this will build
the library.
`make dist` will create a tarball (with "configure" inside) with the
sources.
##### By using CMake
Basic example to build and install libcpuid by using CMake:
```shell
cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build
cmake --install build # may need administrative privileges, install under /usr/local by default
```
### Downloads
You can find latest versioned archives [here](https://github.com/anrieff/libcpuid/releases/latest), with binaries for macOS and Windows.
#### Binary packages
Also, libcpuid is available for following systems in official repositories:
* [Arch Linux](https://archlinux.org/packages/extra/x86_64/libcpuid/): `pacman -S libcpuid`
* [Debian (since version 11 "Bullseye")](https://packages.debian.org/source/bullseye/libcpuid): `apt install cpuidtool libcpuid-dev`
* [Fedora (since version 25)](https://src.fedoraproject.org/rpms/libcpuid): `dnf install libcpuid libcpuid-devel`
* [FreeBSD (since version 11)](https://www.freshports.org/sysutils/libcpuid): `pkg install libcpuid`
* [OpenMandriva Lx (since version 4.0 "Nitrogen")](https://github.com/OpenMandrivaAssociation/libcpuid): `dnf install libcpuid-tools libcpuid-devel`
* [openSUSE Leap (since version 15.1)](https://software.opensuse.org/package/libcpuid): `zypper install libcpuid-tools libcpuid-devel`
* [Solus](https://packages.getsol.us/shannon/libc/libcpuid/): `eopkg install libcpuid libcpuid-devel`
* [Ubuntu (since version 20.04 "Focal Fossa")](https://packages.ubuntu.com/source/focal/libcpuid) : `apt install cpuidtool libcpuid-dev`
2022-10-27 19:17:32 +00:00
Below, the full lists of repositories:
2022-10-27 19:15:31 +00:00
[![Packaging status](https://repology.org/badge/vertical-allrepos/libcpuid.svg?exclude_unsupported=1)](https://repology.org/project/libcpuid/versions)
#### Build tool
* Vcpkg: `vcpkg install cpuid`
## Contributing
Refer to the [dedicated page](CONTRIBUTING.md).
## Users
So far, I'm aware of the following projects which utilize libcpuid (listed alphabetically):
* CPU-X (https://github.com/TheTumultuousUnicornOfDarkness/CPU-X)
* fre:ac (https://www.freac.org/)
* I-Nex (https://github.com/i-nex/I-Nex)
* Multiprecision Computing Toolbox for MATLAB (https://www.advanpix.com/)
* ucbench (http://anrieff.net/ucbench)
We'd love to hear from you if you are also using libcpuid and want your project listed above.