or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cpu-management.mdgpu-management.mdindex.md
tile.json

cpu-management.mddocs/

CPU Management

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

import "github.com/ROCm/amdsmi"

Initialization

GO_cpu_init

Initializes the CPU subsystem for monitoring AMD EPYC CPUs.

func GO_cpu_init() bool

Returns: bool

  • true on successful initialization
  • false on failure

Example:

if !goamdsmi.GO_cpu_init() {
    log.Fatal("Failed to initialize CPU subsystem")
}

CPU Topology

GO_cpu_number_of_sockets_get

Returns the number of available CPU sockets on the system.

func GO_cpu_number_of_sockets_get() uint

Returns: uint

  • Number of CPU sockets on success
  • 0 on failure

Example:

numSockets := goamdsmi.GO_cpu_number_of_sockets_get()
fmt.Printf("CPU sockets: %d\n", numSockets)

GO_cpu_number_of_threads_get

Returns the number of available CPU threads (logical processors) on the system.

func GO_cpu_number_of_threads_get() uint

Returns: uint

  • Number of CPU threads on success
  • 0 on failure

Example:

numThreads := goamdsmi.GO_cpu_number_of_threads_get()
fmt.Printf("CPU threads: %d\n", numThreads)

GO_cpu_threads_per_core_get

Returns the thread count per CPU core (typically 1 or 2 for SMT enabled systems).

func GO_cpu_threads_per_core_get() uint

Returns: uint

  • Thread count per core on success
  • 0 on failure

Example:

threadsPerCore := goamdsmi.GO_cpu_threads_per_core_get()
fmt.Printf("Threads per core: %d\n", threadsPerCore)

CPU Core Metrics

GO_cpu_core_energy_get

Returns the CPU core energy consumption for the specified thread index.

func GO_cpu_core_energy_get(i int) C.uint64_t

Parameters:

  • i (int): Thread index (0-based)

Returns: C.uint64_t

  • Core energy value on success (units depend on hardware)
  • 0xFFFFFFFFFFFFFFFF on failure

Example:

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)
    }
}

GO_cpu_core_boostlimit_get

Returns the CPU core boost limit for the specified thread index.

func GO_cpu_core_boostlimit_get(i int) C.uint32_t

Parameters:

  • i (int): Thread index (0-based)

Returns: C.uint32_t

  • Core boost limit on success
  • 0xFFFFFFFF on failure

Example:

boostLimit := uint32(goamdsmi.GO_cpu_core_boostlimit_get(0))
if boostLimit != 0xFFFFFFFF {
    fmt.Printf("Core boost limit: %d\n", boostLimit)
}

CPU Socket Metrics

GO_cpu_socket_energy_get

Returns the CPU socket energy consumption for the specified socket index.

func GO_cpu_socket_energy_get(i int) C.uint64_t

Parameters:

  • i (int): Socket index (0-based)

Returns: C.uint64_t

  • Socket energy value on success (units depend on hardware)
  • 0xFFFFFFFFFFFFFFFF on failure

Example:

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)
    }
}

GO_cpu_socket_power_get

Returns the socket power consumption for the specified socket index.

func GO_cpu_socket_power_get(i int) C.uint32_t

Parameters:

  • i (int): Socket index (0-based)

Returns: C.uint32_t

  • Socket power value on success (units depend on hardware)
  • 0xFFFFFFFF on failure

Example:

power := uint32(goamdsmi.GO_cpu_socket_power_get(0))
if power != 0xFFFFFFFF {
    fmt.Printf("Socket power: %d\n", power)
}

GO_cpu_socket_power_cap_get

Returns the socket power cap for the specified socket index.

func GO_cpu_socket_power_cap_get(i int) C.uint32_t

Parameters:

  • i (int): Socket index (0-based)

Returns: C.uint32_t

  • Socket power cap on success (units depend on hardware)
  • 0xFFFFFFFF on failure

Example:

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)

GO_cpu_prochot_status_get

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_t

Parameters:

  • i (int): Socket index (0-based)

Returns: C.uint32_t

  • PROCHOT status on success
  • 0xFFFFFFFF on failure

Example:

prochot := uint32(goamdsmi.GO_cpu_prochot_status_get(0))
if prochot != 0xFFFFFFFF {
    if prochot != 0 {
        fmt.Println("WARNING: CPU thermal throttling detected")
    }
}

Complete Example

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()
    }
}

Usage Notes

Thread and Socket Indexing

  • Thread indices range from 0 to GO_cpu_number_of_threads_get() - 1
  • Socket indices range from 0 to GO_cpu_number_of_sockets_get() - 1
  • Always validate indices are within valid ranges before querying

Energy Monitoring

Energy 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)

PROCHOT Status

The PROCHOT status indicates thermal throttling:

  • 0: Normal operation
  • Non-zero: CPU is thermally throttled, reducing performance to lower temperature

Monitor PROCHOT status in high-load scenarios to detect thermal issues.