MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::util Namespace Reference

Namespaces

namespace  detail

Classes

struct  cache_info
 Detected data-cache hierarchy, in bytes. More...
struct  cpu_info
 CPU identity and the SIMD feature flags that matter for kernel dispatch. More...
struct  os_info
 Operating-system name and a best-effort version/build string. More...
struct  compiler_info
 Compiler identity, resolved entirely at compile time. More...
struct  system_info

Functions

cache_info detect_caches ()
 Detect the data-cache hierarchy.
const cache_info & cached_cache_info ()
 Detect once per process and reuse.
system_info identify ()
 Detect the current machine's CPU, OS, and compiler identity.
std::string simd_feature_list (const cpu_info &c)
 Space-separated list of the detected x86 SIMD features (empty on non-x86).
std::string build_isa_list ()
 The ISA the BINARY WAS COMPILED FOR, read from the compiler's own predefined macros (empty if none apply).
std::string to_string (const system_info &si)
 Human-readable multi-line summary, suitable for a benchmark output header.
std::string to_keyvals (const system_info &si)
 Flat, machine-parseable key=value lines – for embedding in CSV headers or building a tag for docs/benchmarks/systems.md.

Function Documentation

◆ build_isa_list()

std::string mtl::util::build_isa_list ( )
inline

The ISA the BINARY WAS COMPILED FOR, read from the compiler's own predefined macros (empty if none apply).

simd_feature_list above says what the MACHINE can do; this says what the code is actually allowed to use, and the two differ exactly when an intended flag did not take effect. That is not hypothetical: the Zen 4 A/B in #430 was measured as an AVX2 build when AVX-512 was intended, and nothing in the CSV could say so – the flags reached the compiler through target_compile_options and CMAKE_CXX_FLAGS_<CONFIG>, so recording CMAKE_CXX_FLAGS alone shows an empty string on a build that is anything but default.

Asking the compiler what it defined sidesteps every one of those paths: it is the effect, not the intent.

◆ cached_cache_info()

const cache_info & mtl::util::cached_cache_info ( )
inline

Detect once per process and reuse.

The hierarchy cannot change under a running binary, and the CPUID walk / sysfs reads should not sit in any hot path. Thread-safe initialization is guaranteed by the static local.

◆ detect_caches()

cache_info mtl::util::detect_caches ( )
inline

Detect the data-cache hierarchy.

Best effort: any field that could not be determined stays 0, and callers fall back rather than believing the zero.

◆ identify()

system_info mtl::util::identify ( )
inline

Detect the current machine's CPU, OS, and compiler identity.

◆ simd_feature_list()

std::string mtl::util::simd_feature_list ( const cpu_info & c)
inline

Space-separated list of the detected x86 SIMD features (empty on non-x86).

◆ to_keyvals()

std::string mtl::util::to_keyvals ( const system_info & si)
inline

Flat, machine-parseable key=value lines – for embedding in CSV headers or building a tag for docs/benchmarks/systems.md.

◆ to_string()

std::string mtl::util::to_string ( const system_info & si)
inline

Human-readable multi-line summary, suitable for a benchmark output header.