nfx-cpu 0.1.3
Cross-platform C++ CPU feature detection and system identification library
Loading...
Searching...
No Matches
Identification.h File Reference

CPU identification functions. More...

#include <string>
#include <cstdint>
#include "nfx/detail/cpu/Identification.inl"
Include dependency graph for Identification.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::string nfx::cpu::vendor () noexcept
 Gets the CPU vendor string.
std::string nfx::cpu::brandString () noexcept
 Gets the CPU brand string.
uint32_t nfx::cpu::family () noexcept
 Gets the CPU family identifier.
uint32_t nfx::cpu::model () noexcept
 Gets the CPU model identifier.
uint32_t nfx::cpu::stepping () noexcept
 Gets the CPU stepping identifier.

Detailed Description

CPU identification functions.

Runtime detection of CPU vendor, brand string, family, model, and stepping information using CPUID instructions with static caching for zero overhead

Definition in file Identification.h.

Function Documentation

◆ brandString()

std::string nfx::cpu::brandString ( )
inlinenodiscardnoexcept

Gets the CPU brand string.

Queries CPUID leafs 0x80000002-0x80000004 to retrieve the processor brand string. Result is cached via static initialization for zero runtime overhead. Example: "Intel(R) Core(TM) i7-12800H @ 2.80GHz"

Returns
CPU brand string (up to 48 characters, trimmed)
Note
This function is marked [[nodiscard]] - the return value should not be ignored
Requires extended CPUID leafs 0x80000002, 0x80000003, 0x80000004

◆ family()

uint32_t nfx::cpu::family ( )
inlinenodiscardnoexcept

Gets the CPU family identifier.

Extracts the processor family from CPUID leaf 1. Combines base family + extended family for processors with family >= 15. Result is cached via static initialization for zero runtime overhead.

Returns
CPU family identifier
Note
This function is marked [[nodiscard]] - the return value should not be ignored
Requires CPUID leaf 1, EAX register bits [27:20] (extended) + [11:8] (base)

◆ model()

uint32_t nfx::cpu::model ( )
inlinenodiscardnoexcept

Gets the CPU model identifier.

Extracts the processor model from CPUID leaf 1. Combines base model + extended model for modern processors. Result is cached via static initialization for zero runtime overhead.

Returns
CPU model identifier
Note
This function is marked [[nodiscard]] - the return value should not be ignored
Requires CPUID leaf 1, EAX register bits [19:16] (extended) + [7:4] (base)

◆ stepping()

uint32_t nfx::cpu::stepping ( )
inlinenodiscardnoexcept

Gets the CPU stepping identifier.

Extracts the processor stepping/revision from CPUID leaf 1. Stepping identifies minor hardware revisions within the same model. Result is cached via static initialization for zero runtime overhead.

Returns
CPU stepping identifier
Note
This function is marked [[nodiscard]] - the return value should not be ignored
Requires CPUID leaf 1, EAX register bits [3:0]

◆ vendor()

std::string nfx::cpu::vendor ( )
inlinenodiscardnoexcept

Gets the CPU vendor string.

Queries CPUID leaf 0 to retrieve the vendor identification string. Result is cached via static initialization for zero runtime overhead. Common values:

  • "GenuineIntel" - Intel processors
  • "AuthenticAMD" - AMD processors
    Returns
    CPU vendor string (12 characters)
    Note
    This function is marked [[nodiscard]] - the return value should not be ignored
    Requires CPUID leaf 0, EBX:EDX:ECX registers