This document describes all CPU management functions in the goamdsmi package. These functions enable monitoring AMD EPYC CPUs for topology information, energy consumption, boost limits, power metrics, and thermal status.
import "github.com/ROCm/amdsmi"Initializes the CPU subsystem for monitoring AMD EPYC CPUs.
func GO_cpu_init() boolReturns: bool
true on successful initializationfalse on failureExample:
if !goamdsmi.GO_cpu_init() {
log.Fatal("Failed to initialize CPU subsystem")
}Returns the number of available CPU sockets on the system.
func GO_cpu_number_of_sockets_get() uintReturns: uint
0 on failureExample:
numSockets := goamdsmi.GO_cpu_number_of_sockets_get()
fmt.Printf("CPU sockets: %d\n", numSockets)Returns the number of available CPU threads (logical processors) on the system.
func GO_cpu_number_of_threads_get() uintReturns: uint
0 on failureExample:
numThreads := goamdsmi.GO_cpu_number_of_threads_get()
fmt.Printf("CPU threads: %d\n", numThreads)Returns the thread count per CPU core (typically 1 or 2 for SMT enabled systems).
func GO_cpu_threads_per_core_get() uintReturns: uint
0 on failureExample:
threadsPerCore := goamdsmi.GO_cpu_threads_per_core_get()
fmt.Printf("Threads per core: %d\n", threadsPerCore)Returns the CPU core energy consumption for the specified thread index.
func GO_cpu_core_energy_get(i int) C.uint64_tParameters:
i (int): Thread index (0-based)Returns: C.uint64_t
0xFFFFFFFFFFFFFFFF on failureExample:
numThreads := int(goamdsmi.GO_cpu_number_of_threads_get())
for i := 0; i < numThreads; i++ {
energy := uint64(goamdsmi.GO_cpu_core_energy_get(i))
if energy != 0xFFFFFFFFFFFFFFFF {
fmt.Printf("Thread %d energy: %d\n", i, energy)
}
}Returns the CPU core boost limit for the specified thread index.
func GO_cpu_core_boostlimit_get(i int) C.uint32_tParameters:
i (int): Thread index (0-based)Returns: C.uint32_t
0xFFFFFFFF on failureExample:
boostLimit := uint32(goamdsmi.GO_cpu_core_boostlimit_get(0))
if boostLimit != 0xFFFFFFFF {
fmt.Printf("Core boost limit: %d\n", boostLimit)
}Returns the CPU socket energy consumption for the specified socket index.
func GO_cpu_socket_energy_get(i int) C.uint64_tParameters:
i (int): Socket index (0-based)Returns: C.uint64_t
0xFFFFFFFFFFFFFFFF on failureExample:
numSockets := int(goamdsmi.GO_cpu_number_of_sockets_get())
for i := 0; i < numSockets; i++ {
energy := uint64(goamdsmi.GO_cpu_socket_energy_get(i))
if energy != 0xFFFFFFFFFFFFFFFF {
fmt.Printf("Socket %d energy: %d\n", i, energy)
}
}Returns the socket power consumption for the specified socket index.
func GO_cpu_socket_power_get(i int) C.uint32_tParameters:
i (int): Socket index (0-based)Returns: C.uint32_t
0xFFFFFFFF on failureExample:
power := uint32(goamdsmi.GO_cpu_socket_power_get(0))
if power != 0xFFFFFFFF {
fmt.Printf("Socket power: %d\n", power)
}Returns the socket power cap for the specified socket index.
func GO_cpu_socket_power_cap_get(i int) C.uint32_tParameters:
i (int): Socket index (0-based)Returns: C.uint32_t
0xFFFFFFFF on failureExample:
powerCap := uint32(goamdsmi.GO_cpu_socket_power_cap_get(0))
power := uint32(goamdsmi.GO_cpu_socket_power_get(0))
fmt.Printf("Socket power: %d / %d\n", power, powerCap)Returns the PROCHOT (processor hot) status for the specified socket index. PROCHOT indicates thermal throttling.
func GO_cpu_prochot_status_get(i int) C.uint32_tParameters:
i (int): Socket index (0-based)Returns: C.uint32_t
0xFFFFFFFF on failureExample:
prochot := uint32(goamdsmi.GO_cpu_prochot_status_get(0))
if prochot != 0xFFFFFFFF {
if prochot != 0 {
fmt.Println("WARNING: CPU thermal throttling detected")
}
}package main
import (
"fmt"
"github.com/ROCm/amdsmi"
)
func main() {
// Initialize CPU subsystem
if !goamdsmi.GO_cpu_init() {
fmt.Println("Failed to initialize CPU")
return
}
// Get CPU topology
numSockets := int(goamdsmi.GO_cpu_number_of_sockets_get())
numThreads := int(goamdsmi.GO_cpu_number_of_threads_get())
threadsPerCore := int(goamdsmi.GO_cpu_threads_per_core_get())
fmt.Printf("CPU Topology:\n")
fmt.Printf(" Sockets: %d\n", numSockets)
fmt.Printf(" Threads: %d\n", numThreads)
fmt.Printf(" Threads per core: %d\n", threadsPerCore)
// Query socket metrics
fmt.Printf("\nSocket Metrics:\n")
for i := 0; i < numSockets; i++ {
fmt.Printf("\n=== Socket %d ===\n", i)
// Energy and power
energy := uint64(goamdsmi.GO_cpu_socket_energy_get(i))
power := uint32(goamdsmi.GO_cpu_socket_power_get(i))
powerCap := uint32(goamdsmi.GO_cpu_socket_power_cap_get(i))
if energy != 0xFFFFFFFFFFFFFFFF {
fmt.Printf("Energy: %d\n", energy)
}
if power != 0xFFFFFFFF {
fmt.Printf("Power: %d / %d\n", power, powerCap)
}
// PROCHOT status
prochot := uint32(goamdsmi.GO_cpu_prochot_status_get(i))
if prochot != 0xFFFFFFFF {
if prochot != 0 {
fmt.Printf("PROCHOT: ACTIVE (thermal throttling)\n")
} else {
fmt.Printf("PROCHOT: Normal\n")
}
}
}
// Query per-thread core metrics (first 4 threads as example)
fmt.Printf("\nCore Metrics (first 4 threads):\n")
maxThreads := numThreads
if maxThreads > 4 {
maxThreads = 4
}
for i := 0; i < maxThreads; i++ {
energy := uint64(goamdsmi.GO_cpu_core_energy_get(i))
boostLimit := uint32(goamdsmi.GO_cpu_core_boostlimit_get(i))
fmt.Printf("Thread %d: ", i)
if energy != 0xFFFFFFFFFFFFFFFF {
fmt.Printf("Energy=%d ", energy)
}
if boostLimit != 0xFFFFFFFF {
fmt.Printf("BoostLimit=%d", boostLimit)
}
fmt.Println()
}
}0 to GO_cpu_number_of_threads_get() - 10 to GO_cpu_number_of_sockets_get() - 1Energy values are cumulative counters that increase over time. To calculate power consumption:
// Sample energy at two time points
energy1 := uint64(goamdsmi.GO_cpu_socket_energy_get(0))
time.Sleep(1 * time.Second)
energy2 := uint64(goamdsmi.GO_cpu_socket_energy_get(0))
// Calculate energy delta (units depend on hardware)
energyDelta := energy2 - energy1
fmt.Printf("Energy consumed in 1s: %d\n", energyDelta)The PROCHOT status indicates thermal throttling:
0: Normal operationMonitor PROCHOT status in high-load scenarios to detect thermal issues.