#include "system_topology.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <dirent.h>#include <ctype.h>#include <sched.h>#include <sys/utsname.h>#include <sys/sysinfo.h>#include <sys/time.h>#include <time.h>Go to the source code of this file.
Macros | |
| #define | _GNU_SOURCE |
Functions | |
| static int | cache_compare (const void *a, const void *b) |
| static int | count_set_bits (const char *hex_mask) |
| static int | get_current_cpu (void) |
| static int | get_numa_node_for_cpu (int cpu) |
| static int | has_cpu_flag (const char *flags, const char *flag) |
| static float | pcie_bandwidth_gbs (int gen, int width) |
| static int | read_file_int (const char *path) |
| static int | read_file_string (const char *path, char *buf, size_t buf_size) |
| static uint64_t | read_file_uint64 (const char *path) |
| static int | run_command (const char *cmd, char *output, size_t output_size) |
| int | topology_discover (SystemTopology *topo) |
| int | topology_discover_affinity (AffinityInfo *aff) |
| int | topology_discover_cache (CacheTopology *cache) |
| int | topology_discover_cpu (CPUInfo *cpu) |
| int | topology_discover_memory (MemoryInfo *mem) |
| int | topology_discover_network (NetworkTopology *net) |
| int | topology_discover_numa (NUMATopology *numa) |
| int | topology_discover_pcie (PCIeTopology *pcie) |
| int | topology_estimate_channels_from_bandwidth (float measured_bw_gbs, int memory_speed_mhz, const char *memory_type) |
| float | topology_estimate_memory_bandwidth (const MemoryInfo *mem) |
| float | topology_estimate_network_training_time (const NetworkTopology *net, uint64_t model_size_mb) |
| int | topology_generate_recommendations (const SystemTopology *topo, RecommendationList *recs) |
| float | topology_measure_memory_bandwidth (void) |
| float | topology_measure_memory_bandwidth_ex (int *numa_node_out, int *num_threads_out) |
| static void | trim_string (char *str) |
| #define _GNU_SOURCE |
Definition at line 8 of file system_topology.c.
|
static |
Definition at line 228 of file system_topology.c.
References CacheInfo::level, and CacheInfo::type.
Referenced by topology_discover_cache().
|
static |
|
static |
Definition at line 414 of file system_topology.c.
Referenced by topology_measure_memory_bandwidth_ex().
|
static |
Definition at line 399 of file system_topology.c.
Referenced by topology_measure_memory_bandwidth_ex().
|
static |
|
static |
|
static |
Definition at line 50 of file system_topology.c.
References read_file_string().
Referenced by topology_discover_cache(), topology_discover_cpu(), and topology_discover_network().
|
static |
Definition at line 38 of file system_topology.c.
References trim_string().
Referenced by read_file_int(), read_file_uint64(), topology_discover_cache(), topology_discover_network(), and topology_discover_numa().
|
static |
|
static |
Definition at line 62 of file system_topology.c.
Referenced by topology_discover_memory(), and topology_discover_pcie().
| int topology_discover | ( | SystemTopology * | topo | ) |
Definition at line 979 of file system_topology.c.
References SystemTopology::affinity, SystemTopology::cache, SystemTopology::cpu, SystemTopology::has_root_access, SystemTopology::hostname, SystemTopology::kernel_version, SystemTopology::memory, SystemTopology::network, SystemTopology::numa, SystemTopology::pcie, topology_discover_affinity(), topology_discover_cache(), topology_discover_cpu(), topology_discover_memory(), topology_discover_network(), topology_discover_numa(), and topology_discover_pcie().
Referenced by main().
| int topology_discover_affinity | ( | AffinityInfo * | aff | ) |
Definition at line 936 of file system_topology.c.
References AffinityInfo::affinity_cpus, AffinityInfo::affinity_set, mask, MAX_CPUS, AffinityInfo::num_affinity_cpus, AffinityInfo::omp_num_threads, AffinityInfo::omp_places, and AffinityInfo::omp_proc_bind.
Referenced by topology_discover().
| int topology_discover_cache | ( | CacheTopology * | cache | ) |
Definition at line 246 of file system_topology.c.
References cache_compare(), count_set_bits(), CacheTopology::l3_total_kb, CacheInfo::level, CacheTopology::levels, CacheInfo::line_size_bytes, MAX_CACHE_LEVELS, CacheTopology::num_levels, read_file_int(), read_file_string(), CacheInfo::shared_by_cores, CacheInfo::size_kb, CacheInfo::type, and CacheInfo::ways_of_associativity.
Referenced by topology_discover().
| int topology_discover_cpu | ( | CPUInfo * | cpu | ) |
Definition at line 112 of file system_topology.c.
References CPUInfo::base_freq_mhz, CPUInfo::cores_per_socket, CPUInfo::family, CPUInfo::has_amx, CPUInfo::has_amx_bf16, CPUInfo::has_amx_int8, CPUInfo::has_amx_tile, CPUInfo::has_avx, CPUInfo::has_avx2, CPUInfo::has_avx512_bf16, CPUInfo::has_avx512bw, CPUInfo::has_avx512f, CPUInfo::has_avx512vl, has_cpu_flag(), CPUInfo::has_sse4_2, CPUInfo::has_vnni, id, CPUInfo::logical_cores, MAX_CPUS, CPUInfo::max_freq_mhz, CPUInfo::model, CPUInfo::model_name, CPUInfo::pcie_generation, CPUInfo::pcie_lanes_total, CPUInfo::physical_cores, read_file_int(), CPUInfo::sockets, CPUInfo::stepping, CPUInfo::threads_per_core, trim_string(), and CPUInfo::vendor.
Referenced by topology_discover().
| int topology_discover_memory | ( | MemoryInfo * | mem | ) |
Definition at line 553 of file system_topology.c.
References MemoryInfo::available_mb, MemoryInfo::bw_test_num_threads, MemoryInfo::bw_test_numa_node, MemoryInfo::cached_mb, MemoryInfo::channel_config, MemoryInfo::channels_populated, MemorySlot::data_width_bits, MemoryInfo::estimated_channels, MemorySlot::locator, MAX_MEMORY_SLOTS, MemoryInfo::measured_bandwidth_gbs, MemoryInfo::memory_speed_mhz, MemoryInfo::memory_type, MemoryInfo::num_channels, MemoryInfo::num_slots, MemorySlot::populated, MemorySlot::rank, run_command(), MemorySlot::size_mb, MemorySlot::slot_number, MemoryInfo::slots, MemoryInfo::slots_populated, MemorySlot::speed_mhz, MemoryInfo::theoretical_bandwidth_gbs, topology_estimate_channels_from_bandwidth(), topology_measure_memory_bandwidth_ex(), MemoryInfo::total_mb, trim_string(), and MemorySlot::type.
Referenced by topology_discover().
| int topology_discover_network | ( | NetworkTopology * | net | ) |
Definition at line 832 of file system_topology.c.
References NetworkTopology::best_interface_idx, NetworkInterface::driver, NetworkInterface::has_link, NetworkTopology::has_rdma, NetworkTopology::interfaces, NetworkInterface::is_infiniband, NetworkInterface::is_up, NetworkInterface::mac_address, NetworkTopology::max_bandwidth_gbs, MAX_NICS, NetworkInterface::mtu, NetworkInterface::name, NetworkTopology::num_interfaces, NetworkInterface::pci_address, read_file_int(), read_file_string(), NetworkInterface::speed_mbps, NetworkInterface::supports_rdma, and NetworkInterface::supports_roce.
Referenced by topology_discover().
| int topology_discover_numa | ( | NUMATopology * | numa | ) |
Definition at line 303 of file system_topology.c.
References NUMANode::cpu_list, NUMATopology::distances, end, MAX_CPUS, MAX_NUMA_NODES, NUMANode::memory_free_mb, NUMANode::memory_total_mb, NUMANode::node_id, NUMATopology::nodes, NUMANode::num_cpus, NUMATopology::num_nodes, read_file_string(), start, and token.
Referenced by topology_discover().
| int topology_discover_pcie | ( | PCIeTopology * | pcie | ) |
Definition at line 730 of file system_topology.c.
References PCIeDevice::bandwidth_gbs, PCIeDevice::bandwidth_max_gbs, PCIeDevice::bus, PCIeDevice::device, PCIeDevice::device_name, PCIeTopology::devices, PCIeDevice::function, PCIeDevice::is_gpu, PCIeDevice::is_nic, PCIeDevice::is_nvme, PCIeDevice::link_speed, PCIeDevice::link_speed_max, PCIeDevice::link_width, PCIeDevice::link_width_max, MAX_PCIE_DEVICES, PCIeTopology::num_devices, pcie_bandwidth_gbs(), run_command(), and PCIeTopology::total_lanes_used.
Referenced by topology_discover().
| int topology_estimate_channels_from_bandwidth | ( | float | measured_bw_gbs, |
| int | memory_speed_mhz, | ||
| const char * | memory_type | ||
| ) |
| float topology_estimate_memory_bandwidth | ( | const MemoryInfo * | mem | ) |
Definition at line 1116 of file system_topology.c.
References MemoryInfo::theoretical_bandwidth_gbs.
| float topology_estimate_network_training_time | ( | const NetworkTopology * | net, |
| uint64_t | model_size_mb | ||
| ) |
Definition at line 1120 of file system_topology.c.
References NetworkTopology::max_bandwidth_gbs.
Referenced by topology_print_distributed_potential().
| int topology_generate_recommendations | ( | const SystemTopology * | topo, |
| RecommendationList * | recs | ||
| ) |
Definition at line 1010 of file system_topology.c.
References Recommendation::action, SystemTopology::affinity, AffinityInfo::affinity_set, Recommendation::category, MemoryInfo::channels_populated, SystemTopology::cpu, Recommendation::description, CPUInfo::has_avx2, NetworkTopology::has_rdma, NetworkTopology::max_bandwidth_gbs, SystemTopology::memory, SystemTopology::network, NetworkTopology::num_interfaces, NUMATopology::num_nodes, RecommendationList::num_recommendations, MemoryInfo::num_slots, SystemTopology::numa, Recommendation::priority, REC_CATEGORY_AFFINITY, REC_CATEGORY_CPU, REC_CATEGORY_MEMORY, REC_CATEGORY_NETWORK, REC_PRIORITY_HIGH, REC_PRIORITY_LOW, REC_PRIORITY_MEDIUM, RecommendationList::recommendations, MemoryInfo::slots_populated, and Recommendation::title.
Referenced by topology_print_summary().
| float topology_measure_memory_bandwidth | ( | void | ) |
Definition at line 517 of file system_topology.c.
References topology_measure_memory_bandwidth_ex().
| float topology_measure_memory_bandwidth_ex | ( | int * | numa_node_out, |
| int * | num_threads_out | ||
| ) |
Definition at line 427 of file system_topology.c.
References end, get_current_cpu(), get_numa_node_for_cpu(), and start.
Referenced by topology_discover_memory(), and topology_measure_memory_bandwidth().
|
static |
Definition at line 29 of file system_topology.c.
Referenced by read_file_string(), topology_discover_cpu(), and topology_discover_memory().