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

CPU feature detection for SIMD instruction sets. More...

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

Go to the source code of this file.

Functions

bool nfx::cpu::hasSse42Support () noexcept
 Gets the cached SSE4.2 support status.
bool nfx::cpu::hasAvxSupport () noexcept
 Gets the cached AVX support status.
bool nfx::cpu::hasAvx2Support () noexcept
 Gets the cached AVX2 support status.
bool nfx::cpu::verifySse42Support () noexcept
 Verifies that compile-time flags match runtime capabilities for SSE4.2.
bool nfx::cpu::verifyAvxSupport () noexcept
 Verifies that compile-time flags match runtime capabilities for AVX.
bool nfx::cpu::verifyAvx2Support () noexcept
 Verifies that compile-time flags match runtime capabilities for AVX2.

Detailed Description

CPU feature detection for SIMD instruction sets.

Runtime detection of SSE4.2, AVX, and AVX2 support with static caching for zero-overhead repeated queries

Definition in file FeatureDetection.h.

Function Documentation

◆ hasAvx2Support()

bool nfx::cpu::hasAvx2Support ( )
inlinenodiscardnoexcept

Gets the cached AVX2 support status.

Checks CPU capabilities for AVX2 (Advanced Vector Extensions 2) instructions, which provide 256-bit SIMD operations for vectorized processing. AVX2 enables:

  • 256-bit integer operations (vs 128-bit SSE)
  • Vectorized string processing and comparison
  • Parallel integer computation for multiple data elements
  • SIMD-accelerated mathematical operations Result is cached via static initialization for zero runtime overhead.
    Returns
    true if AVX2 is supported, false otherwise.
    Note
    This function is marked [[nodiscard]] - the return value should not be ignored
    Requires CPUID leaf 7, subfunction 0, EBX bit 5

◆ hasAvxSupport()

bool nfx::cpu::hasAvxSupport ( )
inlinenodiscardnoexcept

Gets the cached AVX support status.

Checks CPU capabilities for AVX (Advanced Vector Extensions) instructions, which provide 256-bit SIMD operations for floating-point processing. AVX enables:

  • 256-bit floating-point operations (vs 128-bit SSE)
  • Vectorized mathematical computations
  • SIMD-accelerated floating-point algorithms Result is cached via static initialization for zero runtime overhead.
    Returns
    true if AVX is supported, false otherwise.
    Note
    This function is marked [[nodiscard]] - the return value should not be ignored
    Requires CPUID leaf 1, ECX bit 28

◆ hasSse42Support()

bool nfx::cpu::hasSse42Support ( )
inlinenodiscardnoexcept

Gets the cached SSE4.2 support status.

Checks CPU capabilities for SSE4.2 CRC32 instructions. Result is cached via static initialization for zero runtime overhead.

Returns
true if SSE4.2 is supported, false otherwise.
Note
This function is marked [[nodiscard]] - the return value should not be ignored
Requires CPUID leaf 1, ECX bit 20

◆ verifyAvx2Support()

bool nfx::cpu::verifyAvx2Support ( )
inlinenodiscardnoexcept

Verifies that compile-time flags match runtime capabilities for AVX2.

Checks if AVX2 was compiled in and is available at runtime. Issues warnings or assertions if there's a mismatch.

Returns
true if AVX2 is both compiled and available, false otherwise.
Note
In debug builds, this may assert on compile/runtime mismatches

◆ verifyAvxSupport()

bool nfx::cpu::verifyAvxSupport ( )
inlinenodiscardnoexcept

Verifies that compile-time flags match runtime capabilities for AVX.

Checks if AVX was compiled in and is available at runtime. Issues warnings or assertions if there's a mismatch.

Returns
true if AVX is both compiled and available, false otherwise.
Note
In debug builds, this may assert on compile/runtime mismatches

◆ verifySse42Support()

bool nfx::cpu::verifySse42Support ( )
inlinenodiscardnoexcept

Verifies that compile-time flags match runtime capabilities for SSE4.2.

Checks if SSE4.2 was compiled in and is available at runtime. Issues warnings or assertions if there's a mismatch.

Returns
true if SSE4.2 is both compiled and available, false otherwise.
Note
In debug builds, this may assert on compile/runtime mismatches