core/sys/info
sysinfo
Types
9CPU_Feature
CPU_Feature :: enum u64 {
aes = 0, // AES hardware implementation (AES NI)
adx = 1, // Multi-precision add-carry instruction extensions
avx = 2, // Advanced vector extension
avx2 = 3, // Advanced vector extension 2
bmi1 = 4, // Bit manipulation instruction set 1
bmi2 = 5, // Bit manipulation instruction set 2
erms = 6, // Enhanced REP for MOVSB and STOSB
fma = 7, // Fused-multiply-add instructions
os_xsave = 8, // OS supports XSAVE/XRESTOR for saving/restoring XMM registers.
pclmulqdq = 9, // PCLMULQDQ instruction - most often used for AES-GCM
popcnt = 10, // Hamming weight instruction POPCNT.
rdrand = 11, // RDRAND instruction (on-chip random number generator)
rdseed = 12, // RDSEED instruction (on-chip random number generator)
sha = 13, // SHA Extensions (SHA-1, SHA-224, SHA-256)
sse2 = 14, // Streaming SIMD extension 2 (always available on amd64)
sse3 = 15, // Streaming SIMD extension 3
ssse3 = 16, // Supplemental streaming SIMD extension 3
sse41 = 17, // Streaming SIMD extension 4 and 4.1
sse42 = 18, // Streaming SIMD extension 4 and 4.2
avx512bf16 = 19, // Vector Neural Network Instructions supporting bfloat16
avx512bitalg = 20, // Bit Algorithms
avx512bw = 21, // Byte and Word instructions
avx512cd = 22, // Conflict Detection instructions
avx512dq = 23, // Doubleword and Quadword instructions
avx512er = 24, // Exponential and Reciprocal instructions
avx512f = 25, // Foundation
avx512fp16 = 26, // Vector 16-bit float instructions
avx512ifma = 27, // Integer Fused Multiply Add
avx512pf = 28, // Prefetch instructions
avx512vbmi = 29, // Vector Byte Manipulation Instructions
avx512vbmi2 = 30, // Vector Byte Manipulation Instructions 2
avx512vl = 31, // Vector Length extensions
avx512vnni = 32, // Vector Neural Network Instructions
avx512vp2intersect = 33, // Vector Pair Intersection to a Pair of Mask Registers
avx512vpopcntdq = 34, // Vector Population Count for Doubleword and Quadword
}SourceCPU_Feature
CPU_Feature :: enum u64 {}SourceCPU_Features
CPU_Features :: bit_set[CPU_Feature; u64]SourceCPU_Features
CPU_Features :: bit_set[CPU_Feature; u64]SourceGPU
GPU :: struct {
vendor: string,
model: string,
driver: string,
vram: i64,
}SourceGPU_Iterator
GPU_Iterator :: struct {
// Public iterator index
index: int,
// Internal buffer + index
_buffer: [512]u8,
_index: int,
}SourceOS_Version
OS_Version :: struct {
platform: OS_Version_Platform,
full: string,
release: string,
os: Version,
kernel: Version,
}SourceOS_Version_Platform
OS_Version_Platform :: enum int {
Unknown = 0,
Windows = 1,
Linux = 2,
MacOS = 3,
iOS = 4,
FreeBSD = 5,
OpenBSD = 6,
NetBSD = 7,
}SourceVersion
Version :: struct {
major: int,
minor: int,
patch: int,
}SourceConstants
2Procedures
7cpu_core_count
cpu_core_count :: proc() -> (physical: int, logical: int, ok: bool)SourceRetrieves the number of physical and logical CPU cores
Returns:
- physical: The number of physical cores
- logical: The number of logical cores
- ok:
truewhen we could retrieve the CPU information,falseotherwise
cpu_features
cpu_features :: proc() -> (features: CPU_Features)SourceReturns CPU features where available
The results are looked up before main enters and cached
Returns:
- features: An architecture-specific
bit_set, empty if we couldn't retrieve them
cpu_name
cpu_name :: proc() -> (name: string)SourceReturns the CPU's name
The results are looked up before main enters and cached
Returns:
- name: A
stringcontaining the CPU model name, empty if the lookup failed
destroy_os_version
destroy_os_version :: proc(version: OS_Version, allocator: runtime.Allocator)SourceReleases an OS_Version's strings
Frees Using Provided Allocator
Inputs:
- version: An
OS_Versionstruct - allocator: A
runtime.Allocatoron which the version strings will be freed
iterate_gpus
iterate_gpus :: proc(it: ^GPU_Iterator, minimum_vram: i64 = i64(256 * 1024 * 1024)) -> (gpu: GPU, index: int, ok: bool)SourceIterates over GPU adapters
On Windows: Enumerates Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318} Elsewhere: Unsupported at the moment, returns {}, 0, false
Important: The vendor name, model name and driver version strings are backed by the GPU_Iterator. Clone them if you want to these to persist.
Inputs:
- it: A pointer to a
GPU_Iterator - minimum_vram: The number of bytes of VRAM an adapter has to have to be considered, default 256 MiB
(This excludes most screen mirroring / remote desktop drivers)
Returns:
gpu: A `GPU` struct which contains `vendor` name, `model` name, `driver` version and `vram` in bytes
index: Loop index, optional
ok: `true` if this was a success and we should continue, `false` otherwiseos_version
os_version :: proc(allocator: runtime.Allocator, loc = #caller_location) -> (res: OS_Version, ok: bool)SourceRetrieves OS version information
Allocates Using Provided Allocator
You can use destroy_os_version to free the results
Inputs:
- allocator: A
runtime.Allocatoron which the version strings will be allocated - loc: The caller location
Returns:
- res: An
OS_Versionstruct - ok:
truewhen we could retrieve OS version information,falseotherwise
ram_stats
ram_stats :: proc() -> (total_ram: i64, free_ram: i64, total_swap: i64, free_swap: i64, ok: bool)SourceRetrieves RAM statistics
Unavailable stats will be returned as 0 bytes
Returns:
- total_ram: Total RAM reported by the operating system, in bytes
- free_ram: Free RAM reported by the operating system, in bytes
- total_swap: Total SWAP reported by the operating system, in bytes
- free_swap: Free SWAP reported by the operating system, in bytes
- ok:
truewhen we could retrieve RAM statistics,falseotherwise