|
MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
|
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 () |
|
inline |
|
inline |
| 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.
| 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.
|
inline |
|
inline |
Expand a sysfs cpu list ("0-3,8" or "0,6") to the ids it names.
|
inline |
Parse the kernel's cache size spelling: a decimal with an optional K/M/G.