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

Functions

std::size_t parse_size (const std::string &s)
 Parse the kernel's cache size spelling: a decimal with an optional K/M/G.
std::vector< int > parse_cpu_list (const std::string &s)
 Expand a sysfs cpu list ("0-3,8" or "0,6") to the ids it names.
template<typename Read>
std::size_t distinct_cores (const std::vector< int > &cpus, Read &&read)
 How many distinct PHYSICAL cores appear in a cpu list.
template<typename Read>
void fill_caches_sysfs (cache_info &c, const std::vector< int > &cpus, Read &&read)
 The sysfs walk behind fill_caches_sysfs, over the CPUs cpus, reading through read (a path to its first line; empty if absent), so a test can serve a synthetic tree.
void fill_cpu_fallback_brand (cpu_info &cpu)
os_info detect_os ()
compiler_info detect_compiler ()

Function Documentation

◆ detect_compiler()

compiler_info mtl::util::detail::detect_compiler ( )
inline

◆ detect_os()

os_info mtl::util::detail::detect_os ( )
inline

◆ distinct_cores()

template<typename Read>
std::size_t mtl::util::detail::distinct_cores ( const std::vector< int > & cpus,
Read && read )

How many distinct PHYSICAL cores appear in a cpu list.

SMT siblings collapse to one; a 4-core cluster counts 4. Identity is (package, core_id), because core_id is only unique within a package.

read maps a sysfs path to its first line (empty if absent): read_sysfs on Linux, an in-memory tree in the tests.

◆ fill_caches_sysfs()

template<typename Read>
void mtl::util::detail::fill_caches_sysfs ( cache_info & c,
const std::vector< int > & cpus,
Read && read )

The sysfs walk behind fill_caches_sysfs, over the CPUs cpus, reading through read (a path to its first line; empty if absent), so a test can serve a synthetic tree.

Every CPU lists each cache it uses, so a cache shared by k CPUs appears k times. Each instance – (level, type, shared_cpu_list) – is examined once, and its distinct-core count is computed once per shared_cpu_list. Before #840 both were redone for every CPU, O(cpus^2 * files): about 130k small reads for one L3 shared by 256 threads. The result is the same: a repeated instance has the same per-core budget, which never beats itself.

◆ fill_cpu_fallback_brand()

void mtl::util::detail::fill_cpu_fallback_brand ( cpu_info & cpu)
inline

◆ parse_cpu_list()

std::vector< int > mtl::util::detail::parse_cpu_list ( const std::string & s)
inline

Expand a sysfs cpu list ("0-3,8" or "0,6") to the ids it names.

◆ parse_size()

std::size_t mtl::util::detail::parse_size ( const std::string & s)
inline

Parse the kernel's cache size spelling: a decimal with an optional K/M/G.