AMD SMI Go API reference#
Go interface – Consists of Go function declarations, which directly call the C interface via CGO. The client can use the Go interface to build applications in Go.
Requirements#
Go 1.18+ 64-bit
AMD SMI C library installed (
libamdsmi.soon Linux)AMD GPU hardware (for runtime)
Overview#
Folder structure#
File Name |
Note |
|---|---|
|
AMD SMI library Go interface (types, constants, functions) |
|
Usage examples for the APIs in |
|
Go module definition |
|
Documentation |
Architecture#
The bindings are a single file (amdsmi/amdsmi_interface.go) that calls the AMD SMI C library directly via CGO.
Go application
│
▼
amdsmi package (amdsmi_interface.go) ← idiomatic Go API
│
▼ (CGO)
libamdsmi.so ← AMD SMI C library
│
▼
AMD GPU hardware
Build & Run#
Navigate to the go/ directory and run:
sudo go run examples/usage.go
Ensure libamdsmi.so is on the linker path (e.g., /usr/local/lib or set LD_LIBRARY_PATH).
Amdsmi usage#
The amdsmi package should be imported and used as follows:
package main
import (
"fmt"
"smi-lib/go/amdsmi"
)
func main() {
if err := amdsmi.Init(amdsmi.AMDSMI_INIT_AMD_GPUS); err != nil {
fmt.Printf("Init failed: %v\n", err)
return
}
defer amdsmi.ShutDown()
handles, _ := amdsmi.GetProcessorHandles()
for _, h := range handles {
info, _ := amdsmi.GetGpuAsicInfo(h)
fmt.Printf("GPU: %s (0x%X)\n", info.MarketName, info.DeviceID)
}
}
To initialize the library, Init must be called before all other calls.
To close connection to the driver, ShutDown must be the last call.
Amdsmi Error Handling#
All functions return error as the last return value.
Errors are *StatusError with a Code field mapping to amdsmi_status_t values and a Name field with the status name string.
Example:
info, err := amdsmi.GetGpuAsicInfo(handle)
if err != nil {
var smiErr *amdsmi.StatusError
if errors.As(err, &smiErr) {
fmt.Printf("SMI error: %s (code %d)\n", smiErr.Name, smiErr.Code)
}
}
Status codes returned (type Status):
Field |
Value |
Description |
|---|---|---|
|
0 |
Call succeeded |
|
1 |
Invalid parameters |
|
2 |
Command not supported |
|
3 |
Not implemented yet |
|
4 |
Fail to load lib |
|
5 |
Fail to load symbol |
|
6 |
Error when call libdrm |
|
7 |
API call failed |
|
8 |
Timeout in API call |
|
9 |
Retry operation |
|
10 |
Permission denied |
|
11 |
An interrupt occurred during execution of function |
|
12 |
I/O error |
|
13 |
Bad address |
|
14 |
Problem accessing a file |
|
15 |
Not enough memory |
|
16 |
An internal exception was caught |
|
17 |
The provided input is out of allowable or safe range |
|
18 |
An error occurred when initializing internal data structures |
|
19 |
An internal reference counter exceeded INT32_MAX |
|
20 |
Error when a directory is not found, maps to ENOTDIR |
|
30 |
Processor busy |
|
31 |
Processor not found |
|
32 |
Processor not initialized |
|
33 |
No more free slot |
|
34 |
Processor driver not loaded |
|
39 |
There is more data than the buffer size the user passed |
|
40 |
No data was found for a given input |
|
41 |
Not enough resources were available for the operation |
|
42 |
An unexpected amount of data was read |
|
43 |
The data read or provided to function is not what was expected |
|
44 |
System has different cpu than AMD |
|
45 |
Energy driver not found |
|
46 |
MSR driver not found |
|
47 |
HSMP driver not found |
|
48 |
HSMP not supported |
|
49 |
HSMP message/feature not supported |
|
50 |
HSMP message timed out |
|
51 |
No Energy and HSMP driver present |
|
52 |
File or directory not found |
|
53 |
Parsed argument is invalid |
|
54 |
AMDGPU restart failed |
|
55 |
Setting is not available |
|
56 |
EEPROM is corrupted |
|
0xFFFFFFFE |
The internal library error did not map to a status code |
|
0xFFFFFFFF |
An unknown error occurred |
Amdsmi API#
Init#
Description: Initialize smi lib and connect to driver
Input parameters:
flagsInitFlagstype value (Optional concept: if usingAMDSMI_INIT_ALL_PROCESSORS, all processor types are initialized)
InitFlags type:
Field |
Description |
|---|---|
|
AMD CPUs |
|
AMD GPUs |
|
Non-AMD CPUs |
|
Non-AMD GPUs |
|
AMD APUs (CPUs + GPUs) |
|
AMD NICs |
|
All processors |
Output: error
Errors that can be returned by Init function:
*StatusError
Example:
if err := amdsmi.Init(amdsmi.AMDSMI_INIT_AMD_GPUS); err != nil {
fmt.Printf("Init failed: %v\n", err)
return
}
defer amdsmi.ShutDown()
ShutDown#
Description: Finalize and close connection to driver
Input parameters: None
Output: error
Errors that can be returned by ShutDown function:
*StatusError
Example:
err := amdsmi.ShutDown()
if err != nil {
fmt.Printf("ShutDown failed: %v\n", err)
}
GetProcessorHandlesByType#
Description: Returns a slice of processor handles of the specified type in the system.
Input parameters:
ptone ofProcessorTypetype values:
Field |
Description |
|---|---|
|
Unknown processor type |
|
AMD GPU device |
|
AMD CPU device (Not supported yet) |
|
Non-AMD GPU device (Not supported yet) |
|
Non-AMD CPU device (Not supported yet) |
|
AMD CPU core (Not supported yet) |
|
AMD APU (Not supported yet) |
|
AMD Network Interface Card (NIC) |
|
Broadcom Network Interface Card (NIC) |
|
Broadcom switch |
Output: []ProcessorHandle, error
Errors that can be returned by GetProcessorHandlesByType function:
*StatusError
Example:
gpus, err := amdsmi.GetProcessorHandlesByType(amdsmi.AMDSMI_PROCESSOR_TYPE_AMD_GPU)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(gpus) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, gpu := range gpus {
uuid, _ := amdsmi.GetGpuDeviceUuid(gpu)
fmt.Println(uuid)
}
}
GetProcessorType#
Description: Returns the processor type of the given processor handle
Input parameters:
ph(ProcessorHandle) processor handle for which to query
Output: ProcessorType, error
ProcessorType type values:
Field |
Description |
|---|---|
|
Unknown processor type |
|
AMD GPU processor |
|
AMD CPU processor |
|
Non-AMD GPU processor |
|
Non-AMD CPU processor |
|
AMD CPU core processor |
|
AMD APU processor |
|
AMD NIC processor |
|
Broadcom NIC processor |
|
Broadcom switch processor |
Errors that can be returned by GetProcessorType function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
ptype, _ := amdsmi.GetProcessorType(processor)
fmt.Printf("Processor Type: %s (%d)\n", ptype, ptype)
}
}
GetProcessorHandles#
Description: Returns slice of GPU device handle objects on current machine
Note: This function currently supports only AMD GPUs. To enumerate other devices, such as AMD NICs, use GetProcessorHandlesByType function.
Input parameters: None
Output: []ProcessorHandle, error
Errors that can be returned by GetProcessorHandles function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
fmt.Println(amdsmi.GetGpuDeviceUuid(processor))
}
}
GetProcessorHandleFromBdf#
Description: Returns processor handle from the given BDF
Input parameters:
bdfInput(Bdf) BDF identifier as uint64
Output: ProcessorHandle, error
Errors that can be returned by GetProcessorHandleFromBdf function:
*StatusError
Example:
processor, err := amdsmi.GetProcessorHandleFromBdf(0x00002300) // 0000:23:00.0
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
uuid, _ := amdsmi.GetGpuDeviceUuid(processor)
fmt.Println(uuid)
GetGpuDeviceBdf#
Description: Returns BDF of the given processor (GPU PF).
Input parameters:
ph(ProcessorHandle) GPU device for which to query
Output: Bdf, error
Bdf is a uint64 with helper methods and String() returning format <domain>:<bus>:<device>.<function> in hex.
Where:
<domain>is 4 hex digits long from 0000-FFFF interval<bus>is 2 hex digits long from 00-FF interval<device>is 2 hex digits long from 00-1F interval<function>is 1 hex digit long from 0-7 interval
Errors that can be returned by GetGpuDeviceBdf function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
bdf, _ := amdsmi.GetGpuDeviceBdf(processor)
fmt.Printf("GPU BDF: %s\n", bdf)
}
}
GetGpuDeviceUuid#
Description: Returns the UUID of the device
Input parameters:
ph(ProcessorHandle) GPU device for which to query
Output: UUID string, error
Errors that can be returned by GetGpuDeviceUuid function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
uuid, _ := amdsmi.GetGpuDeviceUuid(processor)
fmt.Printf("GPU UUID: %s\n", uuid)
}
}
GetGpuVirtualizationMode#
Description: Retrieve the current GPU virtualization mode.
Input parameters:
ph(ProcessorHandle) The handle to the GPU device for which the virtualization mode is being queried.
Output: VirtualizationMode, error
VirtualizationMode type:
Field |
Description |
|---|---|
|
unknown virtualization mode |
|
bare metal virtualization mode |
|
host virtualization mode |
|
guest virtualization mode |
|
passthrough virtualization mode |
Errors that can be returned by GetGpuVirtualizationMode function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
mode, _ := amdsmi.GetGpuVirtualizationMode(processor)
fmt.Printf("Virtualization Mode: %d\n", mode)
}
}
GetCpuAffinityWithScope#
Description: Returns slice of bitmask information for the given GPU.
Input parameters:
ph(ProcessorHandle) GPU device for which to queryscope(AffinityScope) value for numa or socket affinity
AffinityScope type:
Field |
Description |
|---|---|
|
NUMA node scope |
|
Socket scope |
Output: []uint64 (bitmask array of length 4), error
Errors that can be returned by GetCpuAffinityWithScope function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
cpuSet, _ := amdsmi.GetCpuAffinityWithScope(processor, amdsmi.AMDSMI_AFFINITY_SCOPE_NODE)
fmt.Printf("CPU Affinity: %v\n", cpuSet)
}
}
GetNodeHandle#
Description: Get the node handle associated with processor handle. Note: This function retrieves the node handle of a processor handle. The processor_handle must be provided for the processor. Currently, only AMD GPUs are supported.
Input parameters:
ph(ProcessorHandle) processor handle
Output: NodeHandle, error
Errors that can be returned by GetNodeHandle function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
nh, err := amdsmi.GetNodeHandle(processor)
if err != nil {
fmt.Printf("Error: %v\n", err)
continue
}
fmt.Printf("Node handle: %v\n", nh)
}
}
GetIndexFromProcessorHandle#
Description: Returns the index of the given processor handle
Input parameters:
ph(ProcessorHandle) GPU device for which to query
Output: uint32, error
Errors that can be returned by GetIndexFromProcessorHandle function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
idx, err := amdsmi.GetIndexFromProcessorHandle(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" GetIndexFromProcessorHandle: %d\n", idx)
}
GetProcessorHandleFromIndex#
Description: Returns the processor handle from the given processor index
Input parameters:
index(uint32) 0-based processor index
Output: ProcessorHandle, error
Errors that can be returned by GetProcessorHandleFromIndex function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for i := uint32(0); i < uint32(len(processors)); i++ {
handle, err := amdsmi.GetProcessorHandleFromIndex(i)
if err != nil {
fmt.Printf("Index %d: %v\n", i, err)
continue
}
fmt.Printf("Index %d: handle acquired\n", i)
_ = handle
}
}
GetProcessorBdf#
Description: Returns BDF of the given processor.
Input parameters:
ph(ProcessorHandle) Processor for which to query
Output: Bdf, error
BDF string format: <domain>:<bus>:<device>.<function> in hex.
Where:
<domain>is 4 hex digits long from 0000-FFFF interval<bus>is 2 hex digits long from 00-FF interval<device>is 2 hex digits long from 00-1F interval<function>is 1 hex digit long from 0-7 interval
Errors that can be returned by GetProcessorBdf function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
bdf, _ := amdsmi.GetProcessorBdf(processor)
fmt.Printf("Processor BDF: %s\n", bdf)
}
}
GetProcessorHandleFromUuid#
Description: Returns processor handle from the given UUID
Input parameters:
uuid(string) GPU device UUID
Output: ProcessorHandle, error
Errors that can be returned by GetProcessorHandleFromUuid function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
uuid, _ := amdsmi.GetGpuDeviceUuid(processor)
recovered, err := amdsmi.GetProcessorHandleFromUuid(uuid)
if err != nil {
fmt.Printf("Error: %v\n", err)
continue
}
fmt.Printf("Processor UUID: %s\n", uuid)
_ = recovered
}
}
GetVfHandleFromBdf#
Description: Returns processor handle (VF) from the given BDF
Input parameters:
bdfInput(Bdf) BDF identifier
Output: VfHandle, error
Errors that can be returned by GetVfHandleFromBdf function:
*StatusError
Example:
vf, err := amdsmi.GetVfHandleFromBdf(bdf)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
uuid, _ := amdsmi.GetVfUuid(vf)
fmt.Printf("VF UUID: %s\n", uuid)
GetVfHandleFromUuid#
Description: Returns the handle of a virtual function (VF) from the given UUID
Input parameters:
uuid(string) VF UUID
Output: VfHandle, error
Errors that can be returned by GetVfHandleFromUuid function:
*StatusError
Example:
vf, err := amdsmi.GetVfHandleFromUuid("87007460-0000-1000-8059-3ae746ab9206")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
uuid, _ := amdsmi.GetVfUuid(vf)
fmt.Printf("VF UUID: %s\n", uuid)
GetVfHandleFromVfIndex#
Description: Returns VF id of the VF referenced by its index (in partitioning info)
Input parameters:
ph(ProcessorHandle) PF or child VF of a GPU device for which to queryfcnIdx(int) Index of VF (0-31) in GPU’s partitioning info
Output: VfHandle, error
Errors that can be returned by GetVfHandleFromVfIndex function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
vf, err := amdsmi.GetVfHandleFromVfIndex(processors[0], 0)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
info, _ := amdsmi.GetVfInfo(vf)
fmt.Printf("FB Size: %d MB\n", info.Fb.FbSize)
}
GetVfBdf#
Description: Returns BDF of the given VF
Input parameters:
vh(VfHandle) VF for which to query
Output: Bdf, error
BDF string format: <domain>:<bus>:<device>.<function> in hex.
Where:
<domain>is 4 hex digits long from 0000-FFFF interval<bus>is 2 hex digits long from 00-FF interval<device>is 2 hex digits long from 00-1F interval<function>is 1 hex digit long from 0-7 interval
Errors that can be returned by GetVfBdf function:
*StatusError
Example:
vf, err := amdsmi.GetVfHandleFromBdf(bdf)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
vfBdf, _ := amdsmi.GetVfBdf(vf)
fmt.Printf("VF BDF: %s\n", vfBdf)
GetVfUuid#
Description: Returns the UUID of the device
Input parameters:
vh(VfHandle) VF handle for which to query
Output: UUID string, error
Errors that can be returned by GetVfUuid function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
vf, err := amdsmi.GetVfHandleFromVfIndex(processors[0], 0)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
uuid, _ := amdsmi.GetVfUuid(vf)
fmt.Printf("VF UUID: %s\n", uuid)
}
GetNicProcessorHandles#
Description: Returns all discovered NIC device handle objects on current machine
Input parameters: None
Output: []ProcessorHandle, error
Errors that can be returned by GetNicProcessorHandles function:
*StatusError
Example:
nics, err := amdsmi.GetNicProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(nics) == 0 {
fmt.Println("No NICs on machine")
} else {
for _, nic := range nics {
bdf, _ := amdsmi.GetNicDeviceBdf(nic)
fmt.Printf("NIC BDF: %s\n", bdf)
}
}
GetNicDeviceBdf#
Description: Returns BDF of the given processor (NIC).
Input parameters:
ph(ProcessorHandle) NIC device for which to query
Output: Bdf, error
BDF string format: <domain>:<bus>:<device>.<function> in hex.
Where:
<domain>is 4 hex digits long from 0000-FFFF interval<bus>is 2 hex digits long from 00-FF interval<device>is 2 hex digits long from 00-1F interval<function>is 1 hex digit long from 0-7 interval
Errors that can be returned by GetNicDeviceBdf function:
*StatusError
Example:
nics, err := amdsmi.GetNicProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for _, nic := range nics {
bdf, _ := amdsmi.GetNicDeviceBdf(nic)
fmt.Printf("NIC BDF: %s\n", bdf)
}
GetLibVersion#
Description: Get the build version information for the currently running build of AMDSMI.
Input parameters: None
Output: Version, error
Version fields:
Field |
Description |
|---|---|
|
Major version number |
|
Minor version number |
|
Release version number |
Errors that can be returned by GetLibVersion function:
*StatusError
Example:
ver, err := amdsmi.GetLibVersion()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Library version: %d.%d.%d\n", ver.Major, ver.Minor, ver.Release)
StatusCodeToString#
Description: Get a description of a provided AMDSMI error status
Input parameters:
statusThe error status for which a description is desired
Output: string, error
Errors that can be returned by StatusCodeToString function:
*StatusError
Example:
statusCode, err := amdsmi.StatusCodeToString(amdsmi.AMDSMI_STATUS_INVAL)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" StatusCodeToString: %s \n", statusCode)
GetGpuDriverInfo#
Description: Returns GPU driver information such as driver version, date, and driver name.
Input parameters:
ph(ProcessorHandle) processor handle
Output: DriverInfo, error
DriverInfo fields:
Field |
Description |
|---|---|
|
driver version string |
|
driver build/release date string |
|
driver name string |
Errors that can be returned by GetGpuDriverInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
GPUDrvInfo, err := amdsmi.GetGpuDriverInfo(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" GetGpuDriverInfo:\n")
fmt.Printf(" Driver version : %s\n", GPUDrvInfo.DriverVersion)
fmt.Printf(" Driver date : %s\n", GPUDrvInfo.DriverDate)
fmt.Printf(" Driver name : %s\n", GPUDrvInfo.DriverName)
}
GetGpuDriverModel#
Description: Returns driver model information
Input parameters:
ph(ProcessorHandle) GPU device for which to query
Output: DriverModel, error
Errors that can be returned by GetGpuDriverModel function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
dm, err := amdsmi.GetGpuDriverModel(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" Driver model : %s (%d)\n", dm.String(), dm)
}
GetGpuAsicInfo#
Description: Returns asic information for the given GPU
Input parameters:
ph(ProcessorHandle) GPU device which to query
Output: AsicInfo, error
AsicInfo fields:
Field |
Description |
|---|---|
|
market name |
|
vendor id |
|
vendor name |
|
subsystem vendor id |
|
unique id of a GPU |
|
revision id |
|
asic serial |
|
xgmi physical id |
|
number of compute units |
|
target graphics version (Not supported yet, currently hardcoded to -1) |
|
subsystem device id |
|
chip flags (Not supported yet, currently hardcoded to -1) |
Errors that can be returned by GetGpuAsicInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
asicInfo, _ := amdsmi.GetGpuAsicInfo(processor)
fmt.Println(asicInfo.MarketName)
fmt.Println(asicInfo.VendorID)
fmt.Println(asicInfo.VendorName)
fmt.Println(asicInfo.SubvendorID)
fmt.Println(asicInfo.DeviceID)
fmt.Println(asicInfo.SubsystemID)
fmt.Println(asicInfo.RevID)
fmt.Println(asicInfo.AsicSerial)
fmt.Println(asicInfo.OamID)
fmt.Println(asicInfo.NumComputeUnits)
fmt.Println(asicInfo.TargetGraphicsVersion)
fmt.Println(asicInfo.Flags)
}
}
GetPowerCapInfo#
Description: Returns power cap information as currently configured on the given GPU
Input parameters:
ph(ProcessorHandle) GPU device which to querysensorInd(uint32) sensor index. Normally, this will be 0. If a processor has more than one sensor, it could be greater than 0. Parameter sensor_ind is unused on @platform{host}. It is an optional parameter and is set to 0 by default.
Output: PowerCapInfo, error
PowerCapInfo fields:
Field |
Description |
|---|---|
|
power capability |
|
default power capability |
|
dynamic power management capability |
|
minimum power capability |
|
maximum power capability |
Errors that can be returned by GetPowerCapInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
powerInfo, _ := amdsmi.GetPowerCapInfo(processor, 0)
fmt.Println(powerInfo.PowerCap)
fmt.Println(powerInfo.DefaultPowerCap)
fmt.Println(powerInfo.DpmCap)
fmt.Println(powerInfo.MinPowerCap)
fmt.Println(powerInfo.MaxPowerCap)
}
}
GetPcieInfo#
Description: Returns static and metric information about PCIe link for the given GPU
Input parameters:
ph(ProcessorHandle) GPU device which to query
Output: PcieInfo, error
PcieInfo fields:
Field |
Content |
||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
||||||||||||||||||||
|
|
Errors that can be returned by GetPcieInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
pcieInfo, _ := amdsmi.GetPcieInfo(processor)
fmt.Println(pcieInfo.Static.MaxPcieWidth)
fmt.Println(pcieInfo.Static.MaxPcieSpeed)
fmt.Println(pcieInfo.Static.SlotType)
fmt.Println(pcieInfo.Static.MaxPcieInterfaceVersion)
fmt.Println(pcieInfo.Metric.PcieSpeed)
fmt.Println(pcieInfo.Metric.PcieWidth)
fmt.Println(pcieInfo.Metric.PcieBandwidth)
fmt.Println(pcieInfo.Metric.PcieReplayCount)
fmt.Println(pcieInfo.Metric.PcieL0ToRecoveryCount)
fmt.Println(pcieInfo.Metric.PcieReplayRollOverCount)
fmt.Println(pcieInfo.Metric.PcieNakSentCount)
fmt.Println(pcieInfo.Metric.PcieNakReceivedCount)
fmt.Println(pcieInfo.Metric.PcieLcPerfOtherEndRecoveryCount)
}
}
GetGpuPciBandwidth#
Description: Returns supported PCIe bandwidth combinations for the device, including transfer rates and matching lane widths.
Input parameters:
ph(ProcessorHandle) GPU device for which to query
Output: GpuPciBandwidth, error
GpuPciBandwidth fields:
Field |
Description |
|---|---|
|
supported transfer rates ( |
|
lane count per supported rate; parallel to |
Frequencies fields:
Field |
Description |
|---|---|
|
whether deep-sleep frequency is supported |
|
number of supported entries |
|
index of the current selection |
|
supported values (first |
Errors that can be returned by GetGpuPciBandwidth function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
bw, err := amdsmi.GetGpuPciBandwidth(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
tr := bw.TransferRate
fmt.Printf(" GetGpuPciBandwidth: deep_sleep=%v num=%d current=%d\n",
tr.HasDeepSleep, tr.NumSupported, tr.Current)
}
GetGpuVramInfo#
Description: Returns the static information for the VRAM info
Input parameters:
ph(ProcessorHandle) GPU device which to query
Output: VramInfo, error
VramInfo fields:
Field |
Description |
|---|---|
|
VRAM type from |
|
VRAM vendor name |
|
VRAM size in MB |
|
VRAM bit width |
|
Maximum VRAM bandwidth at current memory clock (GB/s) |
VramType type:
Field |
Description |
|---|---|
|
Unknown VRAM type |
|
HBM VRAM type |
|
HBM2 VRAM type |
|
HBM2E VRAM type |
|
HBM3 VRAM type |
|
HBM3E VRAM type |
|
DDR2 VRAM type |
|
DDR3 VRAM type |
|
DDR4 VRAM type |
|
DDR5 VRAM type |
|
GDDR1 VRAM type |
|
GDDR2 VRAM type |
|
GDDR3 VRAM type |
|
GDDR4 VRAM type |
|
GDDR5 VRAM type |
|
GDDR6 VRAM type |
|
GDDR7 VRAM type |
|
LPDDR4 VRAM type |
|
LPDDR5 VRAM type |
Errors that can be returned by GetGpuVramInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
vramInfo, _ := amdsmi.GetGpuVramInfo(processor)
fmt.Println(vramInfo.VramType)
fmt.Println(vramInfo.VramVendor)
fmt.Println(vramInfo.VramSize)
}
}
GetGpuBoardInfo#
Description: Returns board related information for the given GPU
Input parameters:
ph(ProcessorHandle) GPU device for which to query
Output: BoardInfo, error
BoardInfo fields:
Field |
Description |
|---|---|
|
board model number |
|
board product serial number |
|
fru (field-replaceable unit) id |
|
board product name |
|
board manufacturer name |
Errors that can be returned by GetGpuBoardInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
boardInfo, _ := amdsmi.GetGpuBoardInfo(processor)
fmt.Println(boardInfo.ModelNumber)
fmt.Println(boardInfo.ProductSerial)
fmt.Println(boardInfo.FruID)
fmt.Println(boardInfo.ManufacturerName)
fmt.Println(boardInfo.ProductName)
}
}
GetFbLayout#
Description: Returns framebuffer related information for the given GPU
Input parameters:
ph(ProcessorHandle) PF of a GPU device for which to query
Output: PfFbInfo, error
PfFbInfo fields:
Field |
Description |
|---|---|
|
total framebuffer size in MB |
|
framebuffer reserved space in MB |
|
framebuffer offset in MB |
|
framebuffer alignment in MB |
|
maximum framebuffer size in MB |
|
minimum framebuffer size in MB |
Errors that can be returned by GetFbLayout function:
*StatusErrorExample:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
FbLayout, err := amdsmi.GetFbLayout(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" GetFbLayout:\n")
fmt.Printf(" TotalFbSize : %d\n", FbLayout.TotalFbSize)
fmt.Printf(" PfFbReserved : %d\n", FbLayout.PfFbReserved)
fmt.Printf(" PfFbOffset : %d\n", FbLayout.PfFbOffset)
fmt.Printf(" FbAlignment : %d\n", FbLayout.FbAlignment)
fmt.Printf(" MaxVfFbUsable : %d\n", FbLayout.MaxVfFbUsable)
fmt.Printf(" MinVfFbUsable : %d\n", FbLayout.MinVfFbUsable)
}
GetFwInfo#
Description: Returns the firmware information for the given GPU.
Input parameters:
ph(ProcessorHandle) GPU device which to query
Output: FwInfo, error
FwInfo fields:
Field |
Description |
|---|---|
|
number of valid firmware entries |
|
firmware entry array ( |
Errors that can be returned by GetFwInfo function:
*StatusErrorExample:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
FwInfo, err := amdsmi.GetFwInfo(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" GetFwInfo:\n")
fmt.Printf(" NumFwInfo : %d\n", FwInfo.NumFwInfo)
for i := 0; i < int(FwInfo.NumFwInfo); i++ {
e := FwInfo.FwList[i]
fmt.Printf(" [%d] FwID %s FwVersion %d\n", i, e.FwID.String(), e.FwVersion)
}
}
GetGpuVbiosInfo#
Description: Returns the static information for the VBIOS on the GPU device.
Input parameters:
ph(ProcessorHandle) GPU device which to query
Output: VbiosInfo, error
VbiosInfo fields:
Field |
Description |
|---|---|
|
vbios name |
|
vbios build date |
|
vbios part number |
|
vbios version string |
|
boot firmware string |
Errors that can be returned by GetGpuVbiosInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
GPUVBIOSInfo, err := amdsmi.GetGpuVbiosInfo(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" GetGpuVbiosInfo:\n")
fmt.Printf(" Name : %s\n", GPUVBIOSInfo.Name)
fmt.Printf(" Build date : %s\n", GPUVBIOSInfo.BuildDate)
fmt.Printf(" Part number : %s\n", GPUVBIOSInfo.PartNumber)
fmt.Printf(" Version : %s\n", GPUVBIOSInfo.Version)
fmt.Printf(" Boot firmware : %s\n", GPUVBIOSInfo.BootFirmware)
}
GetFwErrorRecords#
Description: Gets firmware error records
Input parameters:
ph(ProcessorHandle) PF of a GPU device
Output: FwErrorRecord, error
FwErrorRecord fields:
Field |
Description |
|---|---|
|
number of valid error records |
|
firmware load error entry array ( |
FwLoadErrorRecord fields:
Field |
Description |
|---|---|
|
system time in seconds |
|
vf index |
|
firmware id |
|
firmware load status ( |
Errors that can be returned by GetFwErrorRecords function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
rec, err := amdsmi.GetFwErrorRecords(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" GetFwErrorRecords:\n")
fmt.Printf(" NumErrRecords : %d\n", rec.NumErrRecords)
n := int(rec.NumErrRecords)
if n > amdsmi.AMDSMI_MAX_ERR_RECORDS {
n = amdsmi.AMDSMI_MAX_ERR_RECORDS
}
for i := 0; i < n; i++ {
e := rec.ErrRecords[i]
fmt.Printf(" [%d] ts=%d vf_idx=%d fw_id=%d status=%s\n",
i, e.Timestamp, e.VfIdx, e.FwID, e.Status.String())
}
}
GetDfcFwTable#
Description: Gets dfc firmware table
Input parameters:
ph(ProcessorHandle) processor handle
Output: DfcFw, error
DfcFw fields:
Field |
Description |
|---|---|
|
Dfc header structure ( |
|
list of |
DfcFwHeader fields:
Field |
Description |
|---|---|
|
DFC firmware version |
|
number of entries in the dfc table |
|
gart wr guest min |
|
gart wr guest max |
DfcFwData fields:
Field |
Description |
|---|---|
|
DFC firmware type |
|
verification enabled |
|
customer ordinal |
|
white list |
|
black list |
DfcFwWhiteList fields:
Field |
Description |
|---|---|
|
oldest |
|
latest |
Errors that can be returned by GetDfcFwTable function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
t, err := amdsmi.GetDfcFwTable(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" GetDfcFwTable:\n")
fmt.Printf(" DfcFwVersion : %d\n", t.Header.DfcFwVersion)
fmt.Printf(" DfcFwTotalEntries : %d\n", t.Header.DfcFwTotalEntries)
fmt.Printf(" DfcGartWrGuestMin : %d\n", t.Header.DfcGartWrGuestMin)
fmt.Printf(" DfcGartWrGuestMax : %d\n", t.Header.DfcGartWrGuestMax)
for i := 0; i < int(t.Header.DfcFwTotalEntries); i++ {
d := t.Data[i]
fmt.Printf(" data[%d] type=%d verification_enabled=%d customer_ordinal=%d\n",
i, d.DfcFwType, d.VerificationEnabled, d.CustomerOrdinal)
fmt.Printf(" white_list=%v\n", d.WhiteList)
fmt.Printf(" black_list=%v\n", d.BlackList)
}
}
GetGpuActivity#
Description: Returns the engine usage for the given GPU.
Input parameters:
ph(ProcessorHandle) GPU device which to query
Output: EngineUsage, error
EngineUsage fields:
Field |
Description |
|---|---|
|
graphics engine usage/activity percentage (0 - 100) |
|
memory/UMC engine usage/activity percentage (0 - 100) |
|
average multimedia engine usages/activities in percentage (0 - 100) |
Errors that can be returned by GetGpuActivity function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
engineActivity, _ := amdsmi.GetGpuActivity(processor)
fmt.Println(engineActivity.GfxActivity)
fmt.Println(engineActivity.UmcActivity)
fmt.Println(engineActivity.MmActivity)
}
}
GetPowerInfo#
Description: Returns the current power, power limit, and voltage for the given GPU
Input parameters:
ph(ProcessorHandle) GPU device which to query
Output: PowerInfo, error
PowerInfo fields:
Field |
Description |
|---|---|
|
total socket power |
|
current socket power value (not supported on host, always 0) |
|
average socket power value (not supported on host, always 0) |
|
graphics rail voltage |
|
SoC rail voltage |
|
memory rail voltage |
|
configured power limit (not supported on host, always 0) |
|
UBB node power in W (MI350X and newer) |
Errors that can be returned by GetPowerInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
PowerInfo, err := amdsmi.GetPowerInfo(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" GetPowerInfo:\n")
fmt.Printf(" SocketPower : %d\n", PowerInfo.SocketPower)
fmt.Printf(" CurrentSocketPower : %d\n", PowerInfo.CurrentSocketPower) // not supported on host, always 0
fmt.Printf(" AverageSocketPower : %d\n", PowerInfo.AverageSocketPower) // not supported on host, always 0
fmt.Printf(" GfxVoltage : %d\n", PowerInfo.GfxVoltage)
fmt.Printf(" SocVoltage : %d\n", PowerInfo.SocVoltage)
fmt.Printf(" MemVoltage : %d\n", PowerInfo.MemVoltage)
fmt.Printf(" PowerLimit : %d\n", PowerInfo.PowerLimit) // not supported on host, always 0
fmt.Printf(" UbbPower : %d\n", PowerInfo.UbbPower)
}
IsGpuPowerManagementEnabled#
Description: Returns whether GPU power management is enabled.
Input parameters:
ph(ProcessorHandle) processor handle
Output: bool, error
Errors that can be returned by IsGpuPowerManagementEnabled function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
enabled, err := amdsmi.IsGpuPowerManagementEnabled(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" IsGpuPowerManagementEnabled : %v\n", enabled)
}
GetClockInfo#
Description: Returns the clock measurements for the given GPU
Input parameters:
ph(ProcessorHandle) GPU device for which to queryclkType(ClkType) clock domain to query, one of:
Value |
Description |
|---|---|
|
system clock domain |
|
gfx clock domain |
|
Data Fabric clock domain (for ASICs running on a separate clock) (Not supported yet) |
|
Display Controller Engine clock domain (Not supported yet) |
|
SOC clock domain (Not supported yet) |
|
memory clock domain |
|
PCIe clock domain (Not supported yet) |
|
first multimedia engine (VCLK0) clock domain |
|
second multimedia engine (VCLK1) clock domain |
|
DCLK0 clock domain |
|
DCLK1 clock domain |
Output: ClkInfo, error
ClkInfo fields:
Field |
Description |
|---|---|
|
current clock value for the given domain |
|
minimum clock value for the given domain |
|
maximum clock value for the given domain |
|
clock locked flag only supported on GFX clock domain |
|
clock deep sleep mode flag |
Errors that can be returned by GetClockInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
fmt.Printf(" GetClockInfo:\n")
clockTypes := []struct {
label string
typ amdsmi.ClkType
}{
{"GFX", amdsmi.AMDSMI_CLK_TYPE_GFX},
{"MEM", amdsmi.AMDSMI_CLK_TYPE_MEM},
{"SOC", amdsmi.AMDSMI_CLK_TYPE_SOC},
}
for _, ct := range clockTypes {
info, err := amdsmi.GetClockInfo(processors[0], ct.typ)
if err != nil {
fmt.Printf("Error: %v\n", err)
continue
}
fmt.Printf(" %-3s MHz clk=%d min=%d max=%d locked=%v deep_sleep=%v\n",
ct.label, info.Clk, info.MinClk, info.MaxClk, info.ClkLocked, info.ClkDeepSleep)
}
}
GetTempMetric#
Description: Returns the current temperature or limit temperature for the given processor
Input parameters:
ph(ProcessorHandle) processor handlesensorType(TemperatureType) sensor to query, one of:
Value |
Description |
|---|---|
|
edge thermal domain |
|
hotspot/junction thermal domain |
|
memory/vram thermal domain |
|
PLX thermal domain (not supported yet, always returns 0) |
|
HBM 0 thermal domain (not supported yet, always returns 0) |
|
HBM 1 thermal domain (not supported yet, always returns 0) |
|
HBM 2 thermal domain (not supported yet, always returns 0) |
|
HBM 3 thermal domain (not supported yet, always returns 0) |
metric(TemperatureMetric) metric type to query, one of:
Value |
Description |
|---|---|
|
current temperature |
|
max temperature (not supported yet, returns 0) |
|
min temperature (not supported yet, returns 0) |
|
max hyst thermal metric (not supported yet, returns 0) |
|
min hyst thermal metric (not supported yet, returns 0) |
|
limit thermal metric |
|
critical hyst thermal metric (not supported yet, returns 0) |
|
emergency temperature (not supported yet, returns 0) |
|
emergency hyst thermal metric (not supported yet, returns 0) |
|
critical min temperature (not supported yet, returns 0) |
|
critical min hyst thermal metric (not supported yet, returns 0) |
|
offset thermal metric (not supported yet, returns 0) |
|
lowest thermal metric (not supported yet, returns 0) |
|
highest thermal metric (not supported yet, returns 0) |
|
shutdown thermal metric |
Output: int64, error — temperature value in Celsius
Errors that can be returned by GetTempMetric function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
fmt.Printf(" GetTempMetric:\n")
temp, err := amdsmi.GetTempMetric(processors[0], amdsmi.AMDSMI_TEMPERATURE_TYPE_EDGE, amdsmi.AMDSMI_TEMP_CURRENT)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" EDGE / CURRENT (C): %d\n", temp)
temp2, err := amdsmi.GetTempMetric(processors[0], amdsmi.AMDSMI_TEMPERATURE_TYPE_HOTSPOT, amdsmi.AMDSMI_TEMP_CURRENT)
if err != nil {
fmt.Printf("Error: %v\n", err)
} else {
fmt.Printf(" HOTSPOT / CURRENT (C): %d\n", temp2)
}
}
GetGpuMetrics#
Description: Gets GPU metric information
Input parameters:
ph(ProcessorHandle) PF of a GPU device
Output: []Metric, error
Metric fields:
Field |
Description |
|---|---|
|
value of the metric |
|
unit of the metric from |
|
name of the metric from |
|
category of the metric from |
|
bitmask of |
|
mask of all active VFs + PF that this metric applies to |
|
resource group from |
|
resource subgroup from |
|
resource instance number |
MetricUnit type:
Constant |
Description |
|---|---|
|
counter |
|
unsigned integer |
|
boolean |
|
megahertz |
|
percentage |
|
millivolt |
|
celsius |
|
watt |
|
joule |
|
gigabyte per second |
|
megabit per second |
|
PCIe generation |
|
PCIe lanes |
|
15.625 millijoule |
|
unknown unit |
MetricName type:
Constant |
Description |
|---|---|
|
accumulated counter |
|
firmware timestamp |
|
gfx clock |
|
socket clock |
|
memory clock |
|
vclk clock |
|
dclk clock |
|
gfx usage |
|
memory usage |
|
mm usage |
|
vcn usage |
|
jpeg usage |
|
gfx voltage |
|
socket voltage |
|
memory voltage |
|
current hotspot temperature |
|
hotspot temperature limit |
|
current memory temperature |
|
memory temperature limit |
|
current vr temperature |
|
shutdown temperature |
|
current power |
|
power limit |
|
socket energy |
|
ccd energy |
|
xcd energy |
|
aid energy |
|
memory energy |
|
active socket throttle |
|
active vr throttle |
|
active memory throttle |
|
active prochot throttle |
|
active ppt throttle |
|
pcie bandwidth |
|
pcie l0 recovery count |
|
pcie replay count |
|
pcie replay rollover count |
|
pcie nak sent count |
|
pcie nak received count |
|
maximum gfx clock limit |
|
maximum socket clock limit |
|
maximum memory clock limit |
|
maximum vclk clock limit |
|
maximum dclk clock limit |
|
minimum gfx clock limit |
|
minimum socket clock limit |
|
minimum memory clock limit |
|
minimum vclk clock limit |
|
minimum dclk clock limit |
|
gfx clock locked |
|
gfx deep sleep |
|
memory deep sleep |
|
socket deep sleep |
|
vclk deep sleep |
|
dclk deep sleep |
|
pcie link speed |
|
pcie link width |
|
dram bandwidth |
|
maximum dram bandwidth |
|
gfx clock below host limit ppt |
|
gfx clock below host limit thermal |
|
gfx clock below host limit total |
|
gfx clock low utilization |
|
input telemetry voltage |
|
pldm version |
|
xcd temperature |
|
aid temperature |
|
hbm temperature |
|
system metric accumulated counter |
|
system temperature ubb fpga |
|
system temperature ubb front |
|
system temperature ubb back |
|
system temperature ubb oam7 |
|
system temperature ubb ibc |
|
system temperature ubb ufpga |
|
system temperature ubb oam1 |
|
system temperature oam 0 1 hsc |
|
system temperature oam 2 3 hsc |
|
system temperature oam 4 5 hsc |
|
system temperature oam 6 7 hsc |
|
system temperature ubb fpga 0v72 vr |
|
system temperature ubb fpga 3v3 vr |
|
system temperature retimer 0 1 2 3 1v2 vr |
|
system temperature retimer 4 5 6 7 1v2 vr |
|
system temperature retimer 0 1 0v9 vr |
|
system temperature retimer 4 5 0v9 vr |
|
system temperature retimer 2 3 0v9 vr |
|
system temperature retimer 6 7 0v9 vr |
|
system temperature oam 0 1 2 3 3v3 vr |
|
system temperature oam 4 5 6 7 3v3 vr |
|
system temperature ibc hsc |
|
system temperature ibc |
|
node temperature retimer |
|
node temperature ibc temp |
|
node temperature ibc 2 temp |
|
node temperature vdd18 vr temp |
|
node temperature 04 hbm b vr temp |
|
node temperature 04 hbm d vr temp |
|
vr temperature vddcr vdd0 |
|
vr temperature vddcr vdd1 |
|
vr temperature vddcr vdd2 |
|
vr temperature vddcr vdd3 |
|
vr temperature vddcr soc a |
|
vr temperature vddcr soc c |
|
vr temperature vddcr socio a |
|
vr temperature vddcr socio c |
|
vr temperature vdd 085 hbm |
|
vr temperature vddcr 11 hbm b |
|
vr temperature vddcr 11 hbm d |
|
vr temperature vdd usr |
|
vr temperature vddio 11 e32 |
|
system power ubb power |
|
system power ubb power threshold |
|
unknown name |
MetricCategory type:
Constant |
Description |
|---|---|
|
counter |
|
frequency |
|
activity |
|
temperature |
|
power |
|
energy |
|
throttle |
|
pcie |
|
static |
|
system accumulated counter |
|
system baseboard temperature |
|
system gpu board temperature |
|
system baseboard power |
|
unknown category |
MetricType bitmask (Flags field):
Constant |
Value |
Description |
|---|---|---|
|
|
counter |
|
|
chiplet |
|
|
instantaneous data |
|
|
accumulated data |
MetricResGroup type:
Constant |
Description |
|---|---|
|
unknown resource group |
|
resource group is not applicable |
|
gpu resource group |
|
xcp resource group |
|
aid resource group |
|
mid resource group |
|
system resource group |
MetricResSubgroup type:
Constant |
Description |
|---|---|
|
unknown resource subgroup |
|
resource subgroup is not applicable |
|
xcc resource subgroup |
|
engine resource subgroup |
|
hbm resource subgroup |
|
baseboard resource subgroup |
|
gpuboard resource subgroup |
Errors that can be returned by GetGpuMetrics function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
metrics, err := amdsmi.GetGpuMetrics(processor)
if err != nil {
fmt.Printf("GetGpuMetrics failed: %v\n", err)
continue
}
fmt.Printf("Metrics: %d\n", len(metrics))
for i, m := range metrics {
fmt.Printf(" [%d] %s = %d %s (category=%s flags=%v res=%s/%s/%d vf_mask=0x%X)\n",
i, m.Name, m.Val, m.Unit, m.Category,
m.Flags.Flags(),
m.ResGroup, m.ResSubgroup, m.ResInstance,
m.VfMask)
}
}
}
GetGpuMemoryPartitionConfig#
Description: Returns current gpu memory partition config and mode capabilities
Input parameters:
ph(ProcessorHandle) PF of a GPU device
Output: MemoryPartitionConfig, error
MemoryPartitionConfig fields:
Field |
Description |
||||||||
|---|---|---|---|---|---|---|---|---|---|
|
memory partition capabilities ( |
||||||||
|
memory partition mode from |
||||||||
|
number of NUMA ranges |
||||||||
|
|
NpsCaps fields:
Field |
Description |
|---|---|
|
NPS1 supported |
|
NPS2 supported |
|
NPS4 supported |
|
NPS8 supported |
NpsCaps also provides Supported() returning []MemoryPartitionType and String().
MemoryPartitionType type:
Field |
Description |
|---|---|
|
unknown memory partition |
|
memory partition with 1 number per socket |
|
memory partition with 2 numbers per socket |
|
memory partition with 4 numbers per socket |
|
memory partition with 8 numbers per socket |
Errors that can be returned by GetGpuMemoryPartitionConfig function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
config, _ := amdsmi.GetGpuMemoryPartitionConfig(processor)
fmt.Printf("NPS Mode: %s\n", config.Mode)
fmt.Printf("Capabilities: %s\n", config.PartitionCaps)
fmt.Printf("NUMA Ranges: %d\n", config.NumNumaRanges)
}
}
SetGpuMemoryPartitionMode#
Description: Sets memory partition mode
Input parameters:
ph(ProcessorHandle) PF of a GPU devicemode(MemoryPartitionType) Desired NPS mode fromMemoryPartitionTypetype
MemoryPartitionType type:
Field |
Description |
|---|---|
|
unknown memory partition |
|
memory partition with 1 number per socket |
|
memory partition with 2 numbers per socket |
|
memory partition with 4 numbers per socket |
|
memory partition with 8 numbers per socket |
Output: error
Errors that can be returned by SetGpuMemoryPartitionMode function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
err := amdsmi.SetGpuMemoryPartitionMode(processor, amdsmi.AMDSMI_MEMORY_PARTITION_NPS1)
if err != nil {
fmt.Printf("SetGpuMemoryPartitionMode failed: %v\n", err)
}
}
}
GetGpuAcceleratorPartitionProfileConfig#
Description: Returns gpu accelerator partition caps as currently configured in the system
Input parameters:
ph(ProcessorHandle) PF of a GPU device
Output: AcceleratorPartitionProfileConfig, error
AcceleratorPartitionProfileConfig fields:
Field |
Description |
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
||||||||||||
|
index of the default profile |
||||||||||||
|
|
AcceleratorPartitionResourceType type:
Field |
Description |
|---|---|
|
XCC resource capabilities |
|
encoder resource capabilities |
|
decoder resource capabilities |
|
DMA resource capabilities |
|
JPEG resource capabilities |
AcceleratorPartitionType type:
Field |
Description |
|---|---|
|
invalid compute partition |
|
compute partition with all XCCs in group (8/1) |
|
compute partition with four XCCs in group (8/2) |
|
compute partition with two XCCs in group (6/3) |
|
compute partition with two XCCs in group (8/4) |
|
compute partition with one XCC in group (8/8) |
Errors that can be returned by GetGpuAcceleratorPartitionProfileConfig function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
config, _ := amdsmi.GetGpuAcceleratorPartitionProfileConfig(processor)
fmt.Printf("Profiles: %d, Default: %d\n",
config.NumProfiles, config.DefaultProfileIndex)
}
}
GetGpuAcceleratorPartitionProfile#
Description: Returns current gpu accelerator partition cap
Input parameters:
ph(ProcessorHandle) PF of a GPU device
Output: AcceleratorPartitionProfile, []uint32 (partition IDs), error
AcceleratorPartitionProfile fields:
Field |
Description |
|---|---|
|
current profile type from |
|
number of partitions in the profile |
|
memory capabilities of the profile |
|
index of the profile |
|
resources in the profile |
Errors that can be returned by GetGpuAcceleratorPartitionProfile function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
profile, partIDs, _ := amdsmi.GetGpuAcceleratorPartitionProfile(processor)
fmt.Printf("Active: %s, Partitions: %d, IDs: %v\n",
profile.ProfileType, profile.NumPartitions, partIDs)
}
}
SetGpuAcceleratorPartitionProfile#
Description: Sets accelerator partition setting based on profile_index from GetGpuAcceleratorPartitionProfileConfig
Input parameters:
ph(ProcessorHandle) PF of a GPU deviceprofileIndex(uint32) Represents index of a partition user wants to set
Output: error
Errors that can be returned by SetGpuAcceleratorPartitionProfile function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
err := amdsmi.SetGpuAcceleratorPartitionProfile(processor, 1)
if err != nil {
fmt.Printf("SetGpuAcceleratorPartitionProfile failed: %v\n", err)
}
}
}
GetGpuAcceleratorPartitionProfileConfigGlobal#
Description: Returns all GPU accelerator partition capabilities which can be configured on the system
Input parameters:
ph(ProcessorHandle) PF of a GPU device
Output: AcceleratorPartitionProfileConfigGlobal, error
AcceleratorPartitionProfileConfigGlobal fields:
Field |
Description |
||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Array of
|
||||||||||||||
|
Index of the default profile used if no custom configuration is set |
VfMode type:
Field |
Description |
|---|---|
|
1 VF mode |
|
2 VF mode |
|
4 VF mode |
|
8 VF mode |
|
All VF modes |
Errors that can be returned by GetGpuAcceleratorPartitionProfileConfigGlobal function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
config, _ := amdsmi.GetGpuAcceleratorPartitionProfileConfigGlobal(processor)
for i := uint32(0); i < config.NumProfiles; i++ {
p := config.Profiles[i]
fmt.Printf("Profile %d: %s, VF Modes: %v\n",
i, p.Profile.ProfileType, p.VfMode)
}
}
}
GetLinkMetrics#
Description: Gets link metric information
Input parameters:
ph(ProcessorHandle) PF of a GPU device
Output: LinkMetrics, error
LinkMetrics fields:
Field |
Description |
|---|---|
|
Number of active links |
|
Slice of |
LinkMetricInfo fields:
Field |
Description |
|---|---|
|
BDF of the given processor |
|
current link speed in Gb/s |
|
max bandwidth of the link |
|
type of the link ( |
|
total data received for each link in KB |
|
total data transferred for each link in KB |
|
HW status of the link ( |
LinkType values:
Field |
Description |
|---|---|
|
Internal link |
|
PCIe link type |
|
XGMI link type |
|
Link not applicable |
|
Unknown |
LinkStatus values:
Field |
Description |
|---|---|
|
Enabled |
|
Disabled |
|
Inactive |
|
Error |
Errors that can be returned by GetLinkMetrics function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
metrics, _ := amdsmi.GetLinkMetrics(processor)
fmt.Printf("Links: %d\n", metrics.NumLinks)
for i, l := range metrics.Links {
fmt.Printf(" [%d] bdf=%s bit_rate=%d max_bw=%d type=%d read=%d write=%d status=%d\n",
i, l.Bdf, l.BitRate, l.MaxBandwidth, l.LinkType, l.Read, l.Write, l.LinkStatus)
}
}
}
GetLinkTopologyNearest#
Description: Retrieve the set of GPUs that are nearest to a given device at a specific interconnectivity level.
Input parameters:
ph(ProcessorHandle) GPU device for which to querylinkType(LinkType) The link type level to search for nearest devices
LinkType type:
Field |
Description |
|---|---|
|
Internal link |
|
PCIe link type |
|
XGMI link type |
|
Link not applicable |
|
Unknown |
Output: TopologyNearest, error
TopologyNearest fields:
Field |
Description |
|---|---|
|
Number of nearest GPUs found |
|
Slice of |
Errors that can be returned by GetLinkTopologyNearest function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
nearest, _ := amdsmi.GetLinkTopologyNearest(processor, amdsmi.AMDSMI_LINK_TYPE_XGMI)
fmt.Printf("Nearest GPUs (XGMI): %d found\n", nearest.Count)
for i, p := range nearest.ProcessorList {
bdf, _ := amdsmi.GetGpuDeviceBdf(p)
fmt.Printf(" [%d] BDF=%s\n", i, bdf)
}
}
}
TopoGetP2pStatus#
Description: Retrieve connection type and P2P capabilities between two GPUs
Input parameters:
phSrc(ProcessorHandle) the source processor handlephDst(ProcessorHandle) the destination processor handle
Output: LinkType, P2pCapability, error
LinkType type:
Field |
Description |
|---|---|
|
Internal link |
|
PCIe link type |
|
XGMI link type |
|
Link not applicable |
|
Unknown |
|
Same NUMA node, different PCIe switch (NIC-to-GPU only) |
|
Different NUMA nodes (NIC-to-GPU only) |
P2pCapability fields:
Field |
Description |
|---|---|
|
1 = true, 0 = false, 255 = not defined |
|
1 = true, 0 = false, 255 = not defined |
|
1 = true, 0 = false, 255 = not defined |
|
1 = true, 0 = false, 255 = not defined |
|
1 = true, 0 = false, 255 = not defined |
Errors that can be returned by TopoGetP2pStatus function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) < 2 {
fmt.Println("Need at least 2 GPUs for P2P status")
} else {
linkType, cap, _ := amdsmi.TopoGetP2pStatus(processors[0], processors[1])
fmt.Printf("Link type: %d\n", linkType)
fmt.Printf("Coherent: %d, Atomics32: %d, Atomics64: %d, DMA: %d, BiDir: %d\n",
cap.IsIolinkCoherent, cap.IsIolinkAtomics32bit,
cap.IsIolinkAtomics64bit, cap.IsIolinkDma, cap.IsIolinkBiDirectional)
}
TopoGetNumaNodeNumber#
Description: Get the NUMA node associated with a device
Input parameters:
ph(ProcessorHandle) GPU device for which to query
Output: uint32 (NUMA node value), error
Errors that can be returned by TopoGetNumaNodeNumber function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
numaNode, _ := amdsmi.TopoGetNumaNodeNumber(processor)
fmt.Printf("NUMA Node: %d\n", numaNode)
}
}
TopoGetLinkType#
Description: Get the hop count and link type between two processors. Supports both GPU-to-GPU and NIC-to-GPU queries.
Input parameters:
phSrc(ProcessorHandle) source processor handle (GPU or NIC)phDst(ProcessorHandle) destination processor handle (GPU)
Output: hops (uint64), LinkType, error
For GPU-to-GPU queries LinkType is one of INTERNAL, PCIE, XGMI, NOT_APPLICABLE, or UNKNOWN, and hops carries the hop count.
For NIC-to-GPU queries LinkType is one of PCIE, NUMA, XNUMA, or UNKNOWN. The hop count is not meaningful in this case; hops is set to ^uint64(0) (UINT64_MAX).
LinkType type:
Field |
Description |
|---|---|
|
Internal link (GPU-to-GPU) |
|
PCIe link (GPU-to-GPU or NIC-to-GPU via same PCIe switch) |
|
XGMI link (GPU-to-GPU) |
|
Not applicable (GPU-to-GPU) |
|
Unknown |
|
Same NUMA node, different PCIe switch (NIC-to-GPU only) |
|
Different NUMA nodes (NIC-to-GPU only) |
Errors that can be returned by TopoGetLinkType function:
*StatusError
Example:
// GPU-to-GPU
gpus, _ := amdsmi.GetProcessorHandles()
if len(gpus) >= 2 {
hops, linkType, _ := amdsmi.TopoGetLinkType(gpus[0], gpus[1])
fmt.Printf("Link type: %s, hops: %d\n", linkType, hops)
}
// NIC-to-GPU
nics, _ := amdsmi.GetNicProcessorHandles()
if len(nics) > 0 && len(gpus) > 0 {
hops, linkType, _ := amdsmi.TopoGetLinkType(nics[0], gpus[0])
if hops == ^uint64(0) {
fmt.Printf("NIC<->GPU link type: %s (hops N/A)\n", linkType)
}
}
GetLinkTopology#
Description: Gets link topology information between two connected processors
Input parameters:
phSrc(ProcessorHandle) PF of a source GPU devicephDst(ProcessorHandle) PF of a destination GPU device
Output: LinkTopology, error
LinkTopology fields:
Field |
Description |
|---|---|
|
link weight between two GPUs |
|
HW status of the link from |
|
type of the link from |
|
number of hops between two GPUs |
|
framebuffer sharing between two GPUs |
LinkType type:
Field |
Description |
|---|---|
|
Internal link |
|
PCIe link type |
|
XGMI link type |
|
Link not applicable |
|
Unknown |
|
Same NUMA node, different PCIe switch (NIC-to-GPU only) |
|
Different NUMA nodes (NIC-to-GPU only) |
LinkStatus type:
Field |
Description |
|---|---|
|
Enabled |
|
Disabled |
|
Inactive |
|
Error |
Errors that can be returned by GetLinkTopology function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, srcProcessor := range processors {
for _, dstProcessor := range processors {
topo, _ := amdsmi.GetLinkTopology(srcProcessor, dstProcessor)
fmt.Printf("Link: type=%d, status=%d, weight=%d, hops=%d\n",
topo.LinkType, topo.LinkStatus, topo.Weight, topo.NumHops)
}
}
}
GetXgmiFbSharingCaps#
Description: Returns XGMI framebuffer sharing capabilities for the given processor
Input parameters:
ph(ProcessorHandle) GPU device for which to query
Output: XgmiFbSharingCaps, error
XgmiFbSharingCaps fields:
Field |
Description |
|---|---|
|
Custom sharing mode capability (1 = supported, 0 = not supported) |
|
Mode 1 sharing capability (1 = supported, 0 = not supported) |
|
Mode 2 sharing capability (1 = supported, 0 = not supported) |
|
Mode 4 sharing capability (1 = supported, 0 = not supported) |
|
Mode 8 sharing capability (1 = supported, 0 = not supported) |
Errors that can be returned by GetXgmiFbSharingCaps function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
caps, _ := amdsmi.GetXgmiFbSharingCaps(processor)
fmt.Printf("Custom: %d, Mode1: %d, Mode2: %d, Mode4: %d, Mode8: %d\n",
caps.ModeCustomCap, caps.Mode1Cap, caps.Mode2Cap, caps.Mode4Cap, caps.Mode8Cap)
}
}
GetXgmiFbSharingModeInfo#
Description: Returns XGMI framebuffer sharing information between two GPUs for a specified sharing mode
Input parameters:
phSrc(ProcessorHandle) Source PF of a processor for which to queryphDst(ProcessorHandle) Destination PF of a processor for which to querymode(XgmiFbSharingMode) Framebuffer sharing mode to query
XgmiFbSharingMode values:
Field |
Description |
|---|---|
|
Custom sharing mode |
|
Mode 1 sharing |
|
Mode 2 sharing |
|
Mode 4 sharing |
|
Mode 8 sharing |
|
Unknown sharing mode |
Output: uint8 (indicates whether framebuffer is shared between the two processors), error
Errors that can be returned by GetXgmiFbSharingModeInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) < 2 {
fmt.Println("Need at least 2 GPUs for FB sharing mode info")
} else {
fbSharing, _ := amdsmi.GetXgmiFbSharingModeInfo(
processors[0], processors[1], amdsmi.AMDSMI_XGMI_FB_SHARING_MODE_1)
fmt.Printf("FB sharing (Mode 1): %d\n", fbSharing)
}
SetXgmiFbSharingMode#
Description: Sets framebuffer sharing mode
Note: This API will only work if there’s no guest VM running. If all processors in the list are not located within the same NUMA node, the API must be called separately for each NUMA node, as the set operation only applies to processors within a single NUMA node. To determine how many times the set operation needs to be called, it is essential to first invoke the set API for the first processor in the list. After this, you should retrieve the configuration for the selected mode using amdsmi_get_xgmi_fb_sharing_mode_info and verify the settings with amdsmi_get_link_topology. We need to compare the is_fb_sharing_enabled status for each GPU pair to gather the necessary information, alongside topology_info.fb_sharing to verify the link topology between them. If these two values differ, it indicates that the processors are in different NUMA nodes, suggesting that the initial set operation did not complete the intended configuration. In this case, the set API should be invoked again for each NUMA node to ensure that the proper settings are applied.
Input parameters:
ph(ProcessorHandle) PF of a GPU devicemode(XgmiFbSharingMode) framebuffer sharing mode to set
XgmiFbSharingMode values:
Field |
Description |
|---|---|
|
custom framebuffer sharing mode |
|
framebuffer sharing mode_1 |
|
framebuffer sharing mode_2 |
|
framebuffer sharing mode_4 |
|
framebuffer sharing mode_8 |
Output: error
Errors that can be returned by SetXgmiFbSharingMode function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
err := amdsmi.SetXgmiFbSharingMode(processor, amdsmi.AMDSMI_XGMI_FB_SHARING_MODE_4)
if err != nil {
fmt.Printf("SetXgmiFbSharingMode failed: %v\n", err)
}
}
}
SetXgmiFbSharingModeV2#
Description: Sets framebuffer sharing mode
Note: This API will only work if there’s no guest VM running. This api can be used for custom and auto setting of xgmi frame buffer sharing. In case of custom mode: - All processors in the list must be on the same NUMA node. Otherwise, api will return error. - If any processor from the list already belongs to an existing group, the existing group will be released automatically. In case of auto mode(MODE_X): - The input parameter processor_list[0] should be valid. Only the first element of processor_list is taken into account and it can be any gpu0,gpu1,…
Input parameters:
processorList([]ProcessorHandle) list of PFs of GPU devicesmode(XgmiFbSharingMode) framebuffer sharing mode to set
XgmiFbSharingMode values:
Field |
Description |
|---|---|
|
custom framebuffer sharing mode |
|
framebuffer sharing mode_1 |
|
framebuffer sharing mode_2 |
|
framebuffer sharing mode_4 |
|
framebuffer sharing mode_8 |
Output: error
Errors that can be returned by SetXgmiFbSharingModeV2 function:
*StatusError
Example (custom mode):
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
var customGroup []amdsmi.ProcessorHandle
if len(processors) > 3 {
customGroup = []amdsmi.ProcessorHandle{processors[0], processors[2]}
} else {
customGroup = processors
}
err := amdsmi.SetXgmiFbSharingModeV2(customGroup, amdsmi.AMDSMI_XGMI_FB_SHARING_MODE_CUSTOM)
if err != nil {
fmt.Printf("SetXgmiFbSharingModeV2 (CUSTOM) failed: %v\n", err)
}
}
GetSocPstate#
Description: Gets the soc pstate policy for the processor
Input parameters:
ph(ProcessorHandle) PF of a GPU device
Output: DpmPolicy, error
DpmPolicy fields:
Field |
Description |
|---|---|
|
the number of supported policies |
|
current policy index |
|
slice of |
DpmPolicyEntry fields:
Field |
Description |
|---|---|
|
policy id |
|
policy description |
Errors that can be returned by GetSocPstate function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
policy, _ := amdsmi.GetSocPstate(processor)
fmt.Printf("Current: %d, Supported: %d\n", policy.Current, policy.NumSupported)
for _, p := range policy.Policies {
fmt.Printf(" id=%d description=%s\n", p.PolicyID, p.PolicyDescription)
}
}
}
SetSocPstate#
Description: Sets the soc pstate policy for the processor
Input parameters:
ph(ProcessorHandle) PF of a GPU devicepolicyID(uint32) policy id from the policies list obtained viaGetSocPstate
Output: error
Errors that can be returned by SetSocPstate function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
err := amdsmi.SetSocPstate(processor, 0)
if err != nil {
fmt.Printf("SetSocPstate failed: %v\n", err)
}
}
}
GetXgmiPlpd#
Description: Gets the XGMI per-link power down policy parameter for the processor
Input parameters:
ph(ProcessorHandle) PF of a GPU device
Output: DpmPolicy, error
DpmPolicy fields:
Field |
Description |
|---|---|
|
the number of supported policies |
|
current policy index |
|
slice of |
DpmPolicyEntry fields:
Field |
Description |
|---|---|
|
policy id |
|
policy description |
Errors that can be returned by GetXgmiPlpd function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
policy, _ := amdsmi.GetXgmiPlpd(processor)
fmt.Printf("Current: %d, Supported: %d\n", policy.Current, policy.NumSupported)
for _, p := range policy.Policies {
fmt.Printf(" id=%d description=%s\n", p.PolicyID, p.PolicyDescription)
}
}
}
SetXgmiPlpd#
Description: Sets the XGMI per-link power down policy parameter for the processor
Input parameters:
ph(ProcessorHandle) PF of a GPU devicepolicyID(uint32) policy id from the policies list obtained viaGetXgmiPlpd
Output: error
Errors that can be returned by SetXgmiPlpd function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
err := amdsmi.SetXgmiPlpd(processor, 0)
if err != nil {
fmt.Printf("SetXgmiPlpd failed: %v\n", err)
}
}
}
SetPowerCap#
Description: Sets GPU power cap.
Input parameters:
ph(ProcessorHandle) processor handlesensorInd(uint32) sensor index. Normally, this will be 0. If a processor has more than one sensor, it could be greater than 0. Parameter sensor_ind is unused on @platform{host}.cap(uint64) value representing power cap to set. The value must be between the minimum (MinPowerCap) and maximum (MaxPowerCap) power cap values, which can be obtained fromGetPowerCapInfo.
Output: error
Errors that can be returned by SetPowerCap function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
sensorInd := uint32(0)
for _, processor := range processors {
powerInfo, err := amdsmi.GetPowerCapInfo(processor, sensorInd)
if err != nil {
fmt.Printf("GetPowerCapInfo failed: %v\n", err)
continue
}
powerLimit := powerInfo.MinPowerCap +
uint64(rand.Int63n(int64(powerInfo.MaxPowerCap-powerInfo.MinPowerCap)+1))
err = amdsmi.SetPowerCap(processor, sensorInd, powerLimit)
if err != nil {
fmt.Printf("SetPowerCap failed: %v\n", err)
}
}
}
GetSupportedPowerCap#
Description: Returns the supported power cap sensors and their types for a device.
Note: This function is not yet implemented and will return a *StatusError with status AMDSMI_STATUS_NOT_YET_IMPLEMENTED.
Input parameters:
ph(ProcessorHandle) processor handle
Output: []SupportedPowerCapEntry, error
SupportedPowerCapEntry fields:
Field |
Description |
|---|---|
|
sensor index to use with power-cap APIs (for example |
|
power-cap rail / sensor type ( |
Errors that can be returned by GetSupportedPowerCap function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
caps, err := amdsmi.GetSupportedPowerCap(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" Count: %d\n", len(caps))
for i, e := range caps {
fmt.Printf(" [%d] sensor_index=%d type=%s (%d)\n", i, e.SensorIndex, e.Type.String(), e.Type)
}
}
GetGpuCacheInfo#
Description: Returns the cache info for the given processor
Input parameters:
ph(ProcessorHandle) GPU device which to query
Output: GpuCacheInfo, error
GpuCacheInfo fields:
Field |
Description |
|---|---|
|
Number of cache types |
|
Slice of |
CacheEntry fields:
Field |
Description |
|---|---|
|
Bitmask of cache properties from |
|
Cache size in KB |
|
Cache level (1, 2, 3, …) |
|
Number of Compute Units shared |
|
Number of instances of this cache type |
CachePropertyType type values:
Field |
Description |
|---|---|
|
Cache enabled |
|
Data cache |
|
Instruction cache |
|
CPU cache |
|
SIMD cache |
Errors that can be returned by GetGpuCacheInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
cacheInfo, _ := amdsmi.GetGpuCacheInfo(processor)
for _, cache := range cacheInfo.Cache {
fmt.Println(cache.CacheProperties)
fmt.Println(cache.CacheSize)
fmt.Println(cache.CacheLevel)
fmt.Println(cache.MaxNumCuShared)
fmt.Println(cache.NumCacheInstance)
}
}
}
GetGpuEccCount#
Description: Returns the number of ECC errors on the GPU device for the given block
Input parameters:
ph(ProcessorHandle) GPU device which to queryblockThe block for which error counts should be retrieved
block is GpuBlock type:
Field |
Description |
|---|---|
|
UMC block |
|
SDMA block |
|
GFX block |
|
MMHUB block |
|
ATHUB block |
|
PCIE_BIF block |
|
HDP block |
|
XGMI_WAFL block |
|
DF block |
|
SMN block |
|
SEM block |
|
MP0 block |
|
MP1 block |
|
FUSE block |
|
MCA block |
|
VCN block |
|
JPEG block |
|
IH block |
|
MPIO block |
Output: ErrorCount, error
ErrorCount fields:
Field |
Description |
|---|---|
|
Count of ECC correctable errors |
|
Count of ECC uncorrectable errors |
|
Count of ECC deferred errors |
Errors that can be returned by GetGpuEccCount function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
ecc, _ := amdsmi.GetGpuEccCount(processor, amdsmi.AMDSMI_GPU_BLOCK_UMC)
fmt.Printf("UMC ECC: correctable=%d, uncorrectable=%d, deferred=%d\n",
ecc.CorrectableCount, ecc.UncorrectableCount, ecc.DeferredCount)
}
}
GetGpuEccEnabled#
Description: Returns ECC capabilities (disable/enable) for each GPU block.
Input parameters:
ph(ProcessorHandle) GPU device which to query
Output: map[GpuBlock]bool, error
Each GPU block in the map is from GpuBlock type (false if the block is not enabled, true if the block is enabled):
Field |
Description |
|---|---|
|
UMC block |
|
SDMA block |
|
GFX block |
|
MMHUB block |
|
ATHUB block |
|
PCIE_BIF block |
|
HDP block |
|
XGMI_WAFL block |
|
DF block |
|
SMN block |
|
SEM block |
|
MP0 block |
|
MP1 block |
|
FUSE block |
|
MCA block |
|
VCN block |
|
JPEG block |
|
IH block |
|
MPIO block |
Errors that can be returned by GetGpuEccEnabled function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
eccMap, _ := amdsmi.GetGpuEccEnabled(processor)
for block, enabled := range eccMap {
if enabled {
fmt.Printf("Block 0x%X: ECC enabled\n", block)
}
}
}
}
GetGpuTotalEccCount#
Description: Returns the number of ECC errors on the GPU device
Input parameters:
ph(ProcessorHandle) GPU device which to query
Output: ErrorCount, error
ErrorCount fields:
Field |
Description |
|---|---|
|
Count of ECC correctable errors |
|
Count of ECC uncorrectable errors |
|
Count of ECC deferred errors |
Errors that can be returned by GetGpuTotalEccCount function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
total, _ := amdsmi.GetGpuTotalEccCount(processor)
fmt.Printf("Total ECC: correctable=%d, uncorrectable=%d, deferred=%d\n",
total.CorrectableCount, total.UncorrectableCount, total.DeferredCount)
}
}
GetGpuCperEntries#
Description: Dump CPER entries for a given GPU in a file using from CPER header file from RAS tool.
Input parameters:
ph(ProcessorHandle) PF of a GPU deviceseverityMask(uint32) bitmask of severities to retrieve (e.g.0xFFFFFFFFfor all)cursor(uint64) cursor returned by a previous call (use0for the first call)bufferSize(uint64) size of the CPER data buffer in bytes; pass0to use the default4 MiB
Each call returns at most 20 entries (matching the Python wrapper). Use the returned cursor to fetch additional pages.
Output: []CperEntry, uint64 (next cursor), error
CperEntry fields:
Field |
Description |
|---|---|
|
parsed |
|
raw bytes of the full CPER record (length == |
CperHeader fields (mirror amdsmi_cper_hdr_t):
Field |
Description |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CperSeverity type (mirrors amdsmi_cper_sev_t):
Field |
Value |
Description |
|---|---|---|
|
0 |
non-fatal, uncorrected |
|
1 |
fatal |
|
2 |
non-fatal, corrected |
|
3 |
severity count |
|
10 |
unused |
CperNotifyType type (mirrors amdsmi_cper_notify_type_t): CMC, CPE, MCE, PCIE, INIT, NMI, BOOT, DMAR, SEA, SEI, PEI, CXL_COMPONENT. Use entry.Header.NotifyType.NotifyType() to decode the GUID.
Errors that can be returned by GetGpuCperEntries function:
*StatusError(e.g.AMDSMI_STATUS_OUT_OF_RESOURCESifbufferSizeis too small to hold even one record)
Note: AMDSMI_STATUS_MORE_DATA from the underlying C call is treated as success — partial entries are still returned and the caller should retry with the new cursor when there is more data.
Example:
processors, _ := amdsmi.GetProcessorHandles()
for _, p := range processors {
cursor := uint64(0)
for {
entries, next, err := amdsmi.GetGpuCperEntries(p, 0xFFFFFFFF, cursor, 0)
if err != nil {
fmt.Printf("GetGpuCperEntries failed: %v\n", err)
break
}
for i, e := range entries {
fmt.Printf("[%s] sev=%s notify=%s record_len=%d\n",
e.Header.Timestamp,
e.Header.ErrorSeverity,
e.Header.NotifyType.NotifyType(),
e.Header.RecordLength)
afids, _ := amdsmi.GetAfidsFromCper(e.Bytes)
fmt.Printf(" entry %d AFIDs: %v\n", i, afids)
}
if next == 0 || next == cursor {
break
}
cursor = next
}
}
GetAfidsFromCper#
Description: Extracts AF IDs from a single CPER record buffer. Up to MAX_NUMBER_OF_AFIDS_PER_RECORD (12) ids are returned.
Input parameters:
cperBuffer([]byte) bytes of a single CPER record (e.g.entry.Bytesreturned byGetGpuCperEntries)
Output: []uint64, error
Errors that can be returned by GetAfidsFromCper function:
*StatusError(e.g.AMDSMI_STATUS_INVALifcperBufferis empty)
Example:
afids, err := amdsmi.GetAfidsFromCper(entry.Bytes)
if err != nil {
fmt.Printf("GetAfidsFromCper failed: %v\n", err)
return
}
for _, id := range afids {
fmt.Printf("AFID: 0x%X\n", id)
}
GetGpuRasFeatureInfo#
Description: Returns RAS feature info
Input parameters:
ph(ProcessorHandle) GPU device which to query
Output: RasFeatureInfo, error
RasFeatureInfo fields:
Field |
Description |
|---|---|
|
RAS EEPROM version |
|
ECC correction schema flag |
Errors that can be returned by GetGpuRasFeatureInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
info, _ := amdsmi.GetGpuRasFeatureInfo(processor)
fmt.Printf("EEPROM Version: %d, ECC Schema: 0x%X\n",
info.RasEepromVersion, info.EccCorrectionSchemaFlag)
}
}
GetGpuBadPageInfo#
Description: Returns bad page info.
Input parameters:
ph(ProcessorHandle) PF of a GPU device to query
Output: []EepromTableRecord, error
EepromTableRecord fields:
Field |
Description |
|---|---|
|
64K/4K Driver managed location that is blocked from further use |
|
Marks the last time when the RAS event was observed |
|
Identifies the memory channel the issue has been reported on |
|
Identifies the memory controller the issue has been reported on |
Errors that can be returned by GetGpuBadPageInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
records, _ := amdsmi.GetGpuBadPageInfo(processor)
if records == nil {
fmt.Println("No bad pages")
} else {
for _, r := range records {
fmt.Printf("Page: 0x%X, Channel: %d\n",
r.RetiredPage, r.MemChannel)
}
}
}
}
GetGpuRasPolicyInfo#
Description: Retrieve the Reliability, Availability, and Serviceability (RAS) policy information for a specified GPU device.
Input parameters:
ph(ProcessorHandle) GPU device which to query
Output: RasPolicyInfo, error
RasPolicyInfo fields:
Field |
Description |
|---|---|
|
Policy major version |
|
Policy minor version |
|
v4.0 policy data ( |
RasPolicyV4_0 fields (when V4_0 is non-nil):
Field |
Description |
|---|---|
|
Non-critical region threshold |
|
Critical region threshold |
Errors that can be returned by GetGpuRasPolicyInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
policy, _ := amdsmi.GetGpuRasPolicyInfo(processor)
fmt.Printf("RAS Policy: v%d.%d\n", policy.MajorVersion, policy.MinorVersion)
if policy.V4_0 != nil {
fmt.Printf(" Non-critical threshold: %d\n",
policy.V4_0.DramNonCriticalRegionThreshold)
fmt.Printf(" Critical threshold: %d\n",
policy.V4_0.DramCriticalRegionThreshold)
}
}
}
GetBadPageThreshold#
Description: Returns bad page threshold
Input parameters:
ph(ProcessorHandle) GPU device which to query
Output: uint32, error
Errors that can be returned by GetBadPageThreshold function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
threshold, _ := amdsmi.GetBadPageThreshold(processor)
fmt.Printf("Bad page threshold: %d\n", threshold)
}
}
ResetGpu#
Description: Triggers a chain that resets all GPUs.
Input parameters:
ph(ProcessorHandle) processor handle
Output: error
Errors that can be returned by ResetGpu function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
err := amdsmi.ResetGpu(processor)
if err != nil {
fmt.Printf("ResetGpu failed: %v\n", err)
}
}
}
GetNpmInfo#
Description: Returns node power management (NPM) status and the node power limit in watts for the given NUMA node.
Note: This function queries the NPM controller for the given node and returns whether NPM is enabled, along with the current node-level power limit in Watts. The NPM status and limit are set out-of-band and reported via this API.
Input parameters:
nh(NodeHandle) node handle (typically fromGetNodeHandle)
Output: NpmInfo, error
NpmInfo fields:
Field |
Description |
|---|---|
|
NPM status ( |
|
currently set limit |
Errors that can be returned by GetNpmInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
nh, err := amdsmi.GetNodeHandle(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
npm, err := amdsmi.GetNpmInfo(nh)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" GetNpmInfo: status=%s limit=%d W\n", npm.Status.String(), npm.Limit)
}
GetGpuPtlState#
Description: Returns whether PTL (Peak Tops Limiter) is enabled/disabled on the GPU.
Input parameters:
ph(ProcessorHandle) processor handle
Output: bool, error
Errors that can be returned by GetGpuPtlState function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
state, err := amdsmi.GetGpuPtlState(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" GetGpuPtlState: %v\n", state)
}
SetGpuPtlState#
Description: Sets the PTL (Peak Tops Limiter) enable/disable state for the processor
Input parameters:
ph(ProcessorHandle) processor handleenable(bool) True to enable PTL with default formats, False to disable PTL
Output: error
Errors that can be returned by SetGpuPtlState function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
// Enable PTL
if err := amdsmi.SetGpuPtlState(processor, true); err != nil {
fmt.Printf("SetGpuPtlState failed: %v\n", err)
}
// Disable PTL
// amdsmi.SetGpuPtlState(processor, false)
}
}
GetGpuPtlFormats#
Description: Gets the current PTL (Peak Tops Limiter) preferred data formats for the processor
Input parameters:
ph(ProcessorHandle) processor handle
Output: PtlDataFormat, PtlDataFormat, error (first and second format)
PtlDataFormat values:
Field |
Value |
Description |
|---|---|---|
|
|
Integer 8-bit format |
|
|
Float 16-bit format |
|
|
Brain Float 16-bit format |
|
|
Float 32-bit format |
|
|
Float 64-bit format |
|
|
Float 8-bit format |
|
|
Vector format |
|
|
Invalid format |
Note: if both returned formats equal AMDSMI_PTL_DATA_FORMAT_I8 (value 0x0), PTL has not been enabled yet on the system and the PTL state is disabled.
Errors that can be returned by GetGpuPtlFormats function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
f1, f2, err := amdsmi.GetGpuPtlFormats(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" GetGpuPtlFormats: %s / %s\n", f1.String(), f2.String())
}
SetGpuPtlFormats#
Description: Sets the PTL (Peak Tops Limiter) with specified preferred data format pair. PTL must already be enabled before calling this.
Input parameters:
ph(ProcessorHandle) processor handledataFormat1(PtlDataFormat) First preferred data formatdataFormat2(PtlDataFormat) Second preferred data format (must be different from data_format1)
The two specified formats will receive accurate performance monitoring and peak performance. F8 and XF32 formats always receive peak performance regardless of this setting.
Output: error
Errors that can be returned by SetGpuPtlFormats function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
on, err := amdsmi.GetGpuPtlState(processors[0])
if err != nil || !on {
fmt.Printf("SetGpuPtlFormats: PTL not available or disabled\n")
return
}
f1, f2, err := amdsmi.GetGpuPtlFormats(processors[0])
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if err := amdsmi.SetGpuPtlFormats(processors[0], f1, f2); err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" SetGpuPtlFormats: round-trip ok\n")
}
GetNumVf#
Description: Returns number of enabled VFs and number of supported VFs for the given GPU
Input parameters:
ph(ProcessorHandle) PF of a GPU device for which to query
Output: numEnabled (uint32), numSupported (uint32), error
Errors that can be returned by GetNumVf function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
enabled, supported, _ := amdsmi.GetNumVf(processor)
fmt.Printf("VFs: %d enabled, %d supported\n", enabled, supported)
}
}
GetVfPartitionInfo#
Description: Returns a slice of the current framebuffer partitioning structures on the given GPU
Input parameters:
ph(ProcessorHandle) PF of a GPU device for which to query
Output: []PartitionInfo, error
PartitionInfo fields:
Field |
Description |
||||||
|---|---|---|---|---|---|---|---|
|
VF handle |
||||||
|
|
Errors that can be returned by GetVfPartitionInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
partitions, _ := amdsmi.GetVfPartitionInfo(processor)
for i, p := range partitions {
fmt.Printf("VF %d: offset=%d MB, size=%d MB\n",
i, p.Fb.FbOffset, p.Fb.FbSize)
}
}
}
GetPartitionProfileInfo#
Description: Gets partition profile info
Input parameters:
ph(ProcessorHandle) PF of a GPU device
Output: ProfileInfo, error
ProfileInfo fields:
Field |
Description |
|---|---|
|
current profile index |
|
number of profiles |
|
slice of all profiles |
Where, Profiles is a slice of PartitionProfileEntry containing:
Field |
Description |
|---|---|
|
number of VFs |
|
array of |
ProfileCapsInfo fields:
Field |
Description |
|---|---|
|
total |
|
available |
|
optimal |
|
minimum |
|
maximum |
Keys for ProfileCaps array are ProfileCapability constants:
Field |
Description |
|---|---|
|
memory |
|
encode engine |
|
decode engine |
|
compute engine |
Errors that can be returned by GetPartitionProfileInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
profileInfo, _ := amdsmi.GetPartitionProfileInfo(processor)
fmt.Printf("Profiles: %d, Current: %d\n",
profileInfo.ProfileCount, profileInfo.CurrentProfileIndex)
for i, p := range profileInfo.Profiles {
fmt.Printf(" Profile %d: %d VFs\n", i, p.VfCount)
}
}
}
GetVfInfo#
Description: Returns the configuration structure for a given VF
Input parameters:
vh(VfHandle) VF handle
Output: VfInfo, error
VfInfo fields:
Field |
Description |
||||||
|---|---|---|---|---|---|---|---|
|
|
||||||
|
gfx timeslice in us |
Errors that can be returned by GetVfInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
partitions, _ := amdsmi.GetVfPartitionInfo(processor)
if len(partitions) == 0 {
continue
}
config, _ := amdsmi.GetVfInfo(partitions[0].VfHandle)
fmt.Printf("fb_offset: %d\n", config.Fb.FbOffset)
fmt.Printf("fb_size: %d\n", config.Fb.FbSize)
fmt.Printf("gfx_timeslice: %d\n", config.GfxTimeslice)
}
}
GetVfData#
Description: Returns the scheduler information and guard structure for the given VF.
Input parameters:
vh(VfHandle) VF handle
Output: VfData, error
VfData fields:
Field |
Description |
|---|---|
|
Scheduling info (see |
|
Guard info (see |
SchedInfo fields:
Field |
Description |
|---|---|
|
function level reset counter |
|
boot up time in microseconds |
|
shutdown time in microseconds |
|
reset time in microseconds |
|
VF state from |
|
last boot start time |
|
last boot end time |
|
last shutdown start time |
|
last shutdown end time |
|
last reset start time |
|
last reset end time |
|
current session active time, reset after guest reload |
|
current session running time, reset after guest reload |
|
total active time, reset after host reload |
|
total running time, reset after host reload |
GuardInfo fields:
Field |
Description |
|---|---|
|
show if guard info is enabled for VF |
|
array of |
GuardEventInfo fields:
Field |
Description |
|---|---|
|
VF guard state from |
|
amount of monitor events after enabled |
|
interval in seconds (sliding window) in which events are counted |
|
maximum number of events that will be processed in the given sliding window interval |
|
current number of events in the interval |
GuardEventType type values are guard event types:
Field |
Description |
|---|---|
|
function level reset status |
|
exclusive access mode status |
|
exclusive access time out status |
|
generic interrupt status |
|
RAS error count status |
|
RAS CPER dump status |
|
RAS bad pages status |
GuardState type values:
Field |
Description |
|---|---|
|
the event number is within the threshold |
|
the event number hits the threshold |
|
the event number is bigger than the threshold |
VfSchedState type values:
Field |
Description |
|---|---|
|
VF state unavailable |
|
VF state available |
|
VF state active |
|
VF state suspended |
|
VF state fullaccess |
|
same as available, indicates this is a default VF |
Errors that can be returned by GetVfData function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
partitions, _ := amdsmi.GetVfPartitionInfo(processor)
if len(partitions) == 0 {
continue
}
vfData, _ := amdsmi.GetVfData(partitions[0].VfHandle)
schedInfo := vfData.Sched
guardInfo := vfData.Guard
fmt.Println(schedInfo.BootUpTime)
fmt.Println(schedInfo.FlrCount)
fmt.Println(schedInfo.State)
fmt.Println(schedInfo.LastBootStart)
fmt.Println(schedInfo.LastBootEnd)
fmt.Println(schedInfo.LastShutdownStart)
fmt.Println(schedInfo.LastShutdownEnd)
fmt.Println(schedInfo.ShutdownTime)
fmt.Println(schedInfo.LastResetStart)
fmt.Println(schedInfo.LastResetEnd)
fmt.Println(schedInfo.ResetTime)
fmt.Println(schedInfo.CurrentActiveTime)
fmt.Println(schedInfo.CurrentRunningTime)
fmt.Println(schedInfo.TotalActiveTime)
fmt.Println(schedInfo.TotalRunningTime)
fmt.Println(guardInfo.Enabled)
for i, g := range guardInfo.Guard {
fmt.Printf("Guard %d: state=%s, amount=%d, interval=%d, threshold=%d, active=%d\n",
i, g.State, g.Amount, g.Interval, g.Threshold, g.Active)
}
}
}
EventCreate#
Description: Allocate a new event set notifier to monitor different types of issues with the GPU running virtualization SW.
Input parameters:
processors([]ProcessorHandle) Processor handles for the GPUs to listen for eventseventTypes(uint64) Bitmask of event categories and severities to monitor (useBuildEventMaskto construct it)
Bitmask layout (matches the C API amdsmi_event_create):
| 63 62 61 60 | 59 .......... 0 |
| event severity | event category bit field |
Output: EventSet, error
Errors that can be returned by EventCreate function:
*StatusError(e.g.AMDSMI_STATUS_INVALifprocessorsis empty)
The returned EventSet is opaque and must be released by EventDestroy.
EventCategory type:
Field |
Description |
|---|---|
|
placeholder, no events |
|
driver layer events |
|
reset events (GPU/FLR) |
|
world-switch / scheduler events |
|
VBIOS load and parsing events |
|
ECC error events |
|
power play events |
|
SR-IOV events |
|
per-VF events |
|
firmware events |
|
GPU device-level events |
|
guard threshold events |
|
gpumon configuration events |
|
MMSCH events |
|
XGMI topology / FB sharing events |
|
count sentinel from the C enum (not a real category bit) |
EventSeverity type (same numbering as the Level field returned by EventRead):
Field |
Value |
Description |
|---|---|---|
|
0 |
high severity only |
|
1 |
include medium severity (also includes HIGH) |
|
2 |
include low severity (also includes HIGH+MED) |
|
3 |
include warnings |
|
4 |
include informational events |
Mask helpers:
BuildEventMask(categories []EventCategory, severity EventSeverity) uint64— sets1 << catfor each entry incategories, plus the severity bits implied byseverity(HIGH adds none, MED adds bit 60, LOW adds bit 61, WARN adds bit 62, INFO adds bit 63).BuildEventMaskAllCategories(severity EventSeverity) uint64— enables every category bit (bits 0…59) with the given severity.BuildEventMaskAllSeverities(categories []EventCategory) uint64— enables every severity bit (bits 60…63) with the given categories.
Raw mask constants (mirror the AMDSMI_MASK_* macros from amdsmi.h, suitable to pass directly to EventCreate):
Constant |
Value |
Description |
|---|---|---|
|
|
clear mask |
|
|
every category + HIGH/MED/LOW severities (no WARN/INFO) |
|
|
every category + every severity |
|
|
every category bit only (bits 0…59) |
|
|
every severity bit only (bits 60…63) |
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
mask := amdsmi.BuildEventMaskAllCategories(amdsmi.AMDSMI_EVENT_SEVERITY_INFO)
set, err := amdsmi.EventCreate(processors, mask)
if err != nil {
fmt.Printf("EventCreate failed: %v\n", err)
return
}
defer amdsmi.EventDestroy(set)
EventRead#
Description: Block until an event is delivered, the timeout expires, or return immediately when timeoutUsec == 0. A negative timeout blocks indefinitely.
Note: Internally the timeout in microseconds is converted to milliseconds by the library; values smaller than 1000 us are clamped to 1000 us (i.e. 1 ms).
Input parameters:
set(EventSet) event set returned byEventCreatetimeoutUsec(int64) timeout in microseconds
Output: EventEntry, error
EventEntry fields:
Field |
Description |
|---|---|
|
|
|
originating device id |
|
UTC microseconds |
|
category-specific payload; for |
|
|
|
category-specific subcode; cast to the matching |
|
|
|
UTC date and time string |
|
human-readable description (up to 256 bytes) |
|
handle of the GPU that produced the event |
Errors that can be returned by EventRead function:
*StatusError(e.g.AMDSMI_STATUS_TIMEOUTwhen no event arrives in time)
Example:
entry, err := amdsmi.EventRead(set, 500_000) // 500 ms
if err != nil {
fmt.Printf("EventRead failed: %v\n", err)
return
}
fmt.Printf("Event @ %s [%s/%s] %s: %s\n",
entry.Date, entry.Category, entry.Level,
amdsmi.SubcodeName(entry.Category, entry.Subcode),
entry.Message)
Subcode constants#
For every EventCategory the package exposes a typed int32 with named constants that mirror the matching amdsmi_event_<category>_t type in interface/amdsmi.h, plus a String() method on each:
C type |
Go type |
Constant prefix |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SubcodeName(category EventCategory, subcode uint32) string decodes a (Category, Subcode) pair using the right type. Cast directly when you already know the category, e.g. amdsmi.EventEccSubcode(entry.Subcode) == amdsmi.AMDSMI_EVENT_ECC_FATAL_ERROR.
Data payload constants#
A few (Category, Subcode) combinations encode an extra enum value in the Data field. The package exposes typed constants for these as well:
C type |
Go type |
Constant prefix |
When |
|---|---|---|---|
|
|
|
|
Each typed constant has a String() method, e.g. amdsmi.PpThrottlerType(entry.Data).String() returns "THROTTLER_VR" for AMDSMI_EVENT_THROTTLER_VR.
EventDestroy#
Description: Destroys and frees an event set previously returned by EventCreate. Calling it on a zero-valued EventSet is a no-op.
Input parameters:
set(EventSet) event set to destroy
Output: error
Errors that can be returned by EventDestroy function:
*StatusError
Example (low-level lifecycle — for the higher-level EventReader see above):
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
mask := amdsmi.BuildEventMask(
[]amdsmi.EventCategory{
amdsmi.AMDSMI_EVENT_CATEGORY_DRIVER,
amdsmi.AMDSMI_EVENT_CATEGORY_ECC,
amdsmi.AMDSMI_EVENT_CATEGORY_GPU,
},
amdsmi.AMDSMI_EVENT_SEVERITY_LOW,
)
set, err := amdsmi.EventCreate(processors, mask)
if err != nil {
fmt.Printf("EventCreate failed: %v\n", err)
return
}
defer amdsmi.EventDestroy(set)
for i := 0; i < 5; i++ {
entry, err := amdsmi.EventRead(set, 1_000_000) // 1 s
if err != nil {
fmt.Printf("EventRead [%d]: %v\n", i, err)
continue
}
fmt.Printf("[%s] %s/%s subcode=%s msg=%q\n",
entry.Date, entry.Category, entry.Level,
amdsmi.SubcodeName(entry.Category, entry.Subcode),
entry.Message)
}
EventReader#
Description: A small lifetime wrapper around EventCreate / EventRead / EventDestroy that owns the underlying EventSet. This is the Go equivalent of Python’s AmdSmiEventReader — Python uses a context manager (with); Go uses defer reader.Close().
Constructors:
NewEventReader(processors []ProcessorHandle, categories []EventCategory, severity EventSeverity) (*EventReader, error)— builds the mask viaBuildEventMask.NewEventReaderAllCategories(processors []ProcessorHandle, severity EventSeverity) (*EventReader, error)— every category at the chosen severity (usesBuildEventMaskAllCategories).NewEventReaderMask(processors []ProcessorHandle, mask uint64) (*EventReader, error)— full control; pass anyuint64(e.g.AMDSMI_MASK_DEFAULT,AMDSMI_MASK_ALL, or a hand-built mask).
Methods:
Method |
Description |
|---|---|
|
thin wrapper over |
|
calls |
|
returns the underlying |
Errors:
*StatusErrorfrom any of the underlying calls (e.g.AMDSMI_STATUS_INVALifprocessorsis empty,AMDSMI_STATUS_TIMEOUTfromRead)
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
reader, err := amdsmi.NewEventReader(processors,
[]amdsmi.EventCategory{
amdsmi.AMDSMI_EVENT_CATEGORY_DRIVER,
amdsmi.AMDSMI_EVENT_CATEGORY_ECC,
amdsmi.AMDSMI_EVENT_CATEGORY_GPU,
},
amdsmi.AMDSMI_EVENT_SEVERITY_LOW,
)
if err != nil {
fmt.Printf("NewEventReader failed: %v\n", err)
return
}
defer reader.Close()
for i := 0; i < 5; i++ {
entry, err := reader.Read(1_000_000) // 1 s timeout
if err != nil {
fmt.Printf("Read [%d]: %v\n", i, err)
continue
}
fmt.Printf("[%s] %s/%s subcode=%s msg=%q\n",
entry.Date, entry.Category, entry.Level,
amdsmi.SubcodeName(entry.Category, entry.Subcode),
entry.Message)
}
GetGuestData#
Description: Gets guest OS information of the queried VF
Input parameters:
vh(VfHandle) VF handle (for example fromGetVfPartitionInfo)
Output: GuestData, error
GuestData fields:
Field |
Description |
|---|---|
|
guest driver version string |
|
guest framebuffer usage (MB) |
Errors that can be returned by GetGuestData function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
parts, err := amdsmi.GetVfPartitionInfo(processors[0])
if err != nil || len(parts) == 0 {
fmt.Printf("No VF partitions\n")
return
}
gd, err := amdsmi.GetGuestData(parts[0].VfHandle)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" GetGuestData: driver=%q fb_usage=%d\n", gd.DriverVersion, gd.FbUsage)
}
GetVfFwInfo#
Description: Returns firmware block IDs and versions as reported for the VF (amdsmi_get_vf_fw_info).
Input parameters:
vh(VfHandle) VF handle (for example fromGetVfPartitionInfo)
Output: FwInfo, error
FwInfo fields:
Field |
Description |
|---|---|
|
number of valid firmware entries |
|
firmware entry array ( |
Errors that can be returned by GetVfFwInfo function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
parts, err := amdsmi.GetVfPartitionInfo(processors[0])
if err != nil || len(parts) == 0 {
fmt.Printf("No VF partitions\n")
return
}
fw, err := amdsmi.GetVfFwInfo(parts[0].VfHandle)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf(" GetVfFwInfo: num_fw_info=%d\n", fw.NumFwInfo)
}
ClearVfFb#
Description: Clears framebuffer of the given VF on the given GPU.
If trying to clear the framebuffer of an active function,
the call will fail
Input parameters:
vh(VfHandle) VF device handle
Output: error
Errors that can be returned by ClearVfFb function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
partitions, _ := amdsmi.GetVfPartitionInfo(processors[0])
if len(partitions) > 0 {
err = amdsmi.ClearVfFb(partitions[0].VfHandle)
if err != nil {
fmt.Printf("ClearVfFb failed: %v\n", err)
}
}
}
SetNumVf#
Description: Set number of enabled VFs for the given GPU
Input parameters:
ph(ProcessorHandle) GPU device which to querynumVf(uint32) number of enabled VFs to be set
Output: error
Errors that can be returned by SetNumVf function:
*StatusError
Example:
processors, err := amdsmi.GetProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if len(processors) == 0 {
fmt.Println("No GPUs on machine")
} else {
for _, processor := range processors {
err := amdsmi.SetNumVf(processor, 2)
if err != nil {
fmt.Printf("SetNumVf failed: %v\n", err)
}
}
}
GetNicDriverInfo#
Description: Returns driver information for the given NIC
Input parameters:
ph(ProcessorHandle) NIC device for which to query
Output: NicDriverInfo, error
NicDriverInfo fields:
Field |
Description |
|---|---|
|
Driver name |
|
Driver version |
Errors that can be returned by GetNicDriverInfo function:
*StatusError
Example:
nics, err := amdsmi.GetNicProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for _, nic := range nics {
info, _ := amdsmi.GetNicDriverInfo(nic)
fmt.Printf("Driver: %s v%s\n", info.Name, info.Version)
}
GetNicAsicInfo#
Description: Returns ASIC information for the given NIC
Input parameters:
ph(ProcessorHandle) NIC device for which to query
Output: NicAsicInfo, error
NicAsicInfo fields:
Field |
Description |
|---|---|
|
Vendor ID |
|
Subsystem vendor ID |
|
Device ID |
|
Subsystem device ID |
|
Revision |
|
Permanent MAC address |
|
Product name |
|
Part number |
|
Serial number |
|
Vendor name |
Errors that can be returned by GetNicAsicInfo function:
*StatusError
Example:
nics, err := amdsmi.GetNicProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for _, nic := range nics {
info, _ := amdsmi.GetNicAsicInfo(nic)
fmt.Printf("NIC: %s (0x%04X)\n", info.ProductName, info.DeviceID)
fmt.Printf(" Vendor: %s (0x%04X)\n", info.VendorName, info.VendorID)
fmt.Printf(" Serial: %s\n", info.SerialNumber)
}
GetNicBusInfo#
Description: Returns bus information for the given NIC
Input parameters:
ph(ProcessorHandle) NIC device for which to query
Output: NicBusInfo, error
NicBusInfo fields:
Field |
Description |
|---|---|
|
NIC BDF address |
|
Maximum PCIe width |
|
Maximum PCIe speed in GT/s |
|
PCIe interface version string |
|
Slot type string |
Errors that can be returned by GetNicBusInfo function:
*StatusError
Example:
nics, err := amdsmi.GetNicProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for _, nic := range nics {
info, _ := amdsmi.GetNicBusInfo(nic)
fmt.Printf("NIC BDF: %s, PCIe x%d @ %d GT/s\n",
info.Bdf, info.MaxPcieWidth, info.MaxPcieSpeed)
}
GetNicNumaInfo#
Description: Returns NUMA information for the given NIC
Input parameters:
ph(ProcessorHandle) NIC device for which to query
Output: NicNumaInfo, error
NicNumaInfo fields:
Field |
Description |
|---|---|
|
NUMA node number |
|
CPU affinity string |
Errors that can be returned by GetNicNumaInfo function:
*StatusError
Example:
nics, err := amdsmi.GetNicProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for _, nic := range nics {
info, _ := amdsmi.GetNicNumaInfo(nic)
fmt.Printf("NUMA node: %d, Affinity: %s\n", info.Node, info.Affinity)
}
GetNicFwInfo#
Description: Retrieves firmware version information for the NIC
Note: This API depends on libmnl. If libmnl is not installed on the
system, this function raises AmdSmiLibraryException with status AMDSMI_STATUS_NOT_SUPPORTED.
Input parameters:
ph(ProcessorHandle) NIC device for which to query
Output: NicFwInfo, error
NicFwInfo fields:
Field |
Description |
|---|---|
|
Number of valid entries in |
|
Slice of |
NicFwEntry fields:
Field |
Description |
|---|---|
|
|
|
|
NicFwVersionType values:
Value |
Description |
|---|---|
|
Hardware-fixed firmware version |
|
Currently running firmware version |
|
Stored (pending) firmware version |
Errors that can be returned by GetNicFwInfo function:
*StatusError
Example:
nics, err := amdsmi.GetNicProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for _, nic := range nics {
info, _ := amdsmi.GetNicFwInfo(nic)
fmt.Printf("Num FW entries: %d\n", info.NumFw)
for i, fw := range info.Fw {
fmt.Printf(" fw %d: type=%s name=%s version=%s\n",
i, fw.Type, fw.Fw.Name, fw.Fw.Version)
}
}
GetNicPortInfo#
Description: Returns the port information (L2/physical) for all NIC ports on the given NIC.
Input parameters:
ph(ProcessorHandle) NIC device for which to query
Output: NicPortInfo, error
NicPortInfo fields:
Field |
Description |
|---|---|
|
Number of valid entries in |
|
Slice of |
NicPort fields:
Field |
Description |
|---|---|
|
BDF of the port |
|
Port number |
|
Type of the port |
|
Port flavour |
|
Associated network device name |
|
Interface index of the port |
|
MAC address assigned to the port |
|
Carrier state |
|
Maximum Transmission Unit size |
|
Current link state |
|
Link speed in Mbps |
|
Currently active Forward Error Correction mode |
|
Auto-negotiation status |
|
Pause frame auto-negotiation status |
|
Receive pause frame status |
|
Transmit pause frame status |
Active FEC Modes:
The ActiveFec field provides a bitmask representation of Active FEC (Active Forward Error Correction) modes.
The bitmask values are derived from the ethtool_fecparam structure, specifically the active_fec field.
Below are examples of the defined FEC modes:
ETHTOOL_FEC_NONE(0x01)ETHTOOL_FEC_AUTO(0x02)ETHTOOL_FEC_RS(0x04)ETHTOOL_FEC_BASER(0x08)ETHTOOL_FEC_LLRS(0x10)ETHTOOL_FEC_OFF(0x20)
Note: These definitions are based on the latest available ethtool information. Users should verify if there are any updates or changes to these definitions in the relevant ethtool structure or field before implementing them in their code.
Errors that can be returned by GetNicPortInfo function:
*StatusError
Example:
nics, err := amdsmi.GetNicProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for _, nic := range nics {
info, _ := amdsmi.GetNicPortInfo(nic)
fmt.Printf("Num ports: %d\n", info.NumPorts)
for i, p := range info.Ports {
fmt.Printf(" port %d: netdev=%s mac=%s link=%s speed=%d\n",
i, p.Netdev, p.MacAddress, p.LinkState, p.LinkSpeed)
}
}
GetNicRdmaDevInfo#
Description: Returns RDMA devices and per-port information for the given NIC.
Input parameters:
ph(ProcessorHandle) NIC device for which to query
Output: NicRdmaDevicesInfo, error
NicRdmaDevicesInfo fields:
Field |
Description |
|---|---|
|
Number of valid entries in |
|
Slice of |
NicRdmaDevInfo fields:
Field |
Description |
|---|---|
|
RDMA device name |
|
Node GUID |
|
Node type |
|
System image GUID |
|
Firmware version |
|
Number of valid entries in |
|
Slice of |
NicRdmaPortInfo fields:
Field |
Description |
|---|---|
|
Associated netdev name |
|
Port state string (e.g. |
|
RDMA port number |
|
Maximum MTU size |
|
Currently active MTU |
Errors that can be returned by GetNicRdmaDevInfo function:
*StatusError
Example:
nics, err := amdsmi.GetNicProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for _, nic := range nics {
info, _ := amdsmi.GetNicRdmaDevInfo(nic)
for _, d := range info.RdmaDevInfo {
fmt.Printf("rdma_dev=%s fw=%s ports=%d\n", d.RdmaDev, d.FwVer, d.NumRdmaPorts)
for _, p := range d.RdmaPortInfo {
fmt.Printf(" port %d: state=%s mtu=%d/%d\n",
p.RdmaPort, p.State, p.ActiveMtu, p.MaxMtu)
}
}
}
GetNicPortStatistics#
Description: Retrieve all available PORT statistics for the specified NIC port
Uses a two-call pattern internally: first queries the count, then retrieves the entries.
Input parameters:
ph(ProcessorHandle) NIC device for which to queryportIndex(uint32) zero-based NIC port index
Output: []NicStat, error
NicStat fields:
Field |
Description |
|---|---|
|
Statistic name |
|
Statistic value (uint64) |
Errors that can be returned by GetNicPortStatistics function:
*StatusError
Example:
nics, err := amdsmi.GetNicProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for _, nic := range nics {
stats, _ := amdsmi.GetNicPortStatistics(nic, 0)
for _, s := range stats {
fmt.Printf("%s = %d\n", s.Name, s.Value)
}
}
GetNicVendorStatistics#
Description: Retrieve vendor specific statistics for the NIC port
Uses a two-call pattern internally: first queries the count, then retrieves the entries.
Input parameters:
ph(ProcessorHandle) NIC device for which to queryportIndex(uint32) zero-based NIC port index
Output: []NicStat, error
This API provides access to vendor/driver specific statistics that may vary between different NIC vendors and driver/firmware versions. The statistic names are preserved as provided by the underlying driver implementation.
Note: The exact statistics available depend on the NIC vendor, hardware and driver version.
Errors that can be returned by GetNicVendorStatistics function:
*StatusError
Example:
nics, err := amdsmi.GetNicProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for _, nic := range nics {
stats, _ := amdsmi.GetNicVendorStatistics(nic, 0)
for _, s := range stats {
fmt.Printf("%s = %d\n", s.Name, s.Value)
}
}
GetNicRdmaPortStatistics#
Description: Retrieve RDMA port statistics for the NIC
Uses a two-call pattern internally: first queries the count, then retrieves the entries.
Input parameters:
ph(ProcessorHandle) NIC device for which to queryrdmaPortIndex(uint32) zero-based NIC RDMA port index
Output: []NicStat, error
Errors that can be returned by GetNicRdmaPortStatistics function:
*StatusError
Example:
nics, err := amdsmi.GetNicProcessorHandles()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for _, nic := range nics {
stats, _ := amdsmi.GetNicRdmaPortStatistics(nic, 0)
for _, s := range stats {
fmt.Printf("%s = %d\n", s.Name, s.Value)
}
}
GetTdiState#
Description: Returns the lifecycle state of the TDI (TEE Device Interface) for a virtual function.
Input parameters:
vh(VfHandle) VF for which to query
Output: TdiState, error
TdiState values:
Value |
Description |
|---|---|
|
TDI is unlocked |
|
TDI is locked |
|
TDI is actively running |
|
TDI is in an error state and cannot be used |
Errors that can be returned by GetTdiState function:
*StatusError
Example:
partitions, err := amdsmi.GetVfPartitionInfo(handle)
if err != nil || len(partitions) == 0 {
return
}
state, err := amdsmi.GetTdiState(partitions[0].VfHandle)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("TDI state: %s (%d)\n", state, state)
GetCcMode#
Description: Returns the Confidential Compute mode currently configured on a GPU.
Input parameters:
ph(ProcessorHandle) PF of a processor for which to query
Output: CcMode, error
CcMode values:
Value |
Description |
|---|---|
|
Confidential Compute disabled |
|
Confidential Compute enabled |
|
Confidential Compute enabled in developer mode |
Errors that can be returned by GetCcMode function:
*StatusError
Example:
mode, err := amdsmi.GetCcMode(handle)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("CC mode: %s (%d)\n", mode, mode)
SetCcMode#
Description: Sets the Confidential Compute mode on a GPU.
Input parameters:
ph(ProcessorHandle) PF of a processor for which to set the modemode(CcMode) mode to apply (seeGetCcModefor the value table)
Output: error
Errors that can be returned by SetCcMode function:
*StatusError
Example:
if err := amdsmi.SetCcMode(handle, amdsmi.AMDSMI_CC_MODE_ON); err != nil {
fmt.Printf("Error: %v\n", err)
return
}
GetVfHbmInfo#
Description: Returns HBM (High Bandwidth Memory) information for a virtual function.
Input parameters:
vh(VfHandle) VF for which to query
Output: VfHbmInfo, error
VfHbmInfo fields:
Field |
Description |
|---|---|
|
Physical address of the HBM region |
|
Physical size in bytes |
|
NUMA node id for driver-managed VF HBM. |
|
Backing device or region name |
Errors that can be returned by GetVfHbmInfo function:
*StatusError
Example:
partitions, err := amdsmi.GetVfPartitionInfo(handle)
if err != nil || len(partitions) == 0 {
return
}
info, err := amdsmi.GetVfHbmInfo(partitions[0].VfHandle)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("HBM phy_addr=0x%X size=%d numa=%d name=%s\n",
info.PhyAddr, info.PhySize, info.NumaID, info.Name)
GetGpuFabricInfo#
Description: Returns Fabric (scale-up networking) configuration for a GPU. The C structure is versioned with a discriminated union; the Go type exposes the version number and the parsed variant.
Input parameters:
ph(ProcessorHandle) PF of a processor for which to query
Output: FabricInfo, error
FabricInfo fields:
Field |
Description |
|---|---|
|
BDF of the Fabric device |
|
Variant version number; selects which |
|
Parsed |
FabricInfoV1 fields:
Field |
Description |
|---|---|
|
Accelerator identifier (range 0…1023) |
|
|
|
Station bandwidth share in Mb/s |
|
Latency in nanoseconds |
|
Physical PoD identifier (128-bit UUID as |
|
Physical PoD size |
|
Virtual PoD identifier |
|
Virtual PoD size |
|
1024-bit list stored as 32 x |
|
Up to 8 local accelerator IDs |
|
|
|
|
FabricType values:
Value |
Description |
|---|---|
|
UALink-over-Ethernet fabric |
|
Native UALink fabric |
|
Unknown fabric type |
FabricNpaAddressMode values:
Value |
Description |
|---|---|
|
NPA remaps source IDs per vPoD |
|
Original source IDs preserved |
|
Unknown address mode |
FabricAcceleratorVpodState values:
Value |
Description |
|---|---|
|
Not yet assigned to a vPoD |
|
Assigned but not ready for traffic |
|
Configured and ready, awaiting activation |
|
Live and participating in the vPoD |
|
In an error state |
|
Unknown accelerator vPoD state |
Errors that can be returned by GetGpuFabricInfo function:
*StatusError
Example:
info, err := amdsmi.GetGpuFabricInfo(handle)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Fabric BDF=%s version=%d\n", info.Bdf, info.Version)
if info.Version == 1 {
v1 := info.InfoV1
fmt.Printf(" accel_id=%d type=%s bw=%d Mb/s latency=%d ns\n",
v1.AcceleratorID, v1.FabricType, v1.Bandwidth, v1.Latency)
fmt.Printf(" ppod=%x/%d vpod=%d/%d state=%s addr_mode=%s\n",
v1.PpodID, v1.PpodSize, v1.VpodID, v1.VpodSize,
v1.AccelState, v1.AddrMode)
}
AllocFabricTelemetry#
Description: Allocates a Fabric telemetry session for the requested categories.
The returned *FabricTelemetry is the lifecycle wrapper around C-allocated storage. Call .Get() to populate it with the latest snapshot, and .Close() to release it. A finalizer is installed as a safety net, but callers should always pair the call with defer t.Close().
This function mirrors the Python AmdSmiFabricTelemetry class.
Input parameters:
ph(ProcessorHandle) GPU for which to allocate telemetrycategories(...FabricTelemetryCategory) variadic list of categories to request. If empty, all categories fromUALOEthroughDERIVED_NETPORTare requested (matching the Python default).
Output: *FabricTelemetry, error
FabricTelemetryCategory values:
Value |
Description |
|---|---|
|
UALOE telemetry |
|
Switch telemetry |
|
Crypto telemetry |
|
PFC telemetry |
|
Network Port telemetry |
|
Derived UALOE telemetry |
|
Derived Network Port telemetry |
|
Maximum number of categories |
|
Unknown / invalid category |
*FabricTelemetry methods:
Method |
Description |
|---|---|
|
Refresh the telemetry snapshot ( |
|
Release the C-allocated storage ( |
|
Return the categories this session was allocated for. |
FabricTelemetryData fields:
Field |
Description |
|---|---|
|
|
FabricTelemetryDataset fields:
Field |
Description |
|---|---|
|
|
|
Sequence number incremented each time telemetry is written |
|
UTC timestamp seconds since epoch ( |
|
UTC timestamp sub-second part ( |
|
Number of instances in this category |
|
Slice of |
FabricTelemetryInstance fields:
Field |
Description |
|---|---|
|
Instance label (max 32 chars) |
|
Logical index for this instance |
|
Number of telemetry items |
|
Slice of |
FabricTelemetryItem fields:
Field |
Description |
|---|---|
|
Identifier of the telemetry item |
|
Value of the telemetry item |
Errors that can be returned by AllocFabricTelemetry function:
*StatusErrorerrorif any of the supplied categories is out of range or the C call returns a NULL pointer
Example:
tel, err := amdsmi.AllocFabricTelemetry(handle,
amdsmi.AMDSMI_FABRIC_TELEMETRY_CATEGORY_UALOE,
amdsmi.AMDSMI_FABRIC_TELEMETRY_CATEGORY_NETPORT)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
defer tel.Close()
snap, err := tel.Get()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for cat, ds := range snap.Datasets {
fmt.Printf("category=%s instances=%d gen=%d ts=%d.%09d\n",
cat, ds.InstanceCount, ds.GenerationCount,
ds.TimestampSec, ds.TimestampNsec)
for _, inst := range ds.Instances {
fmt.Printf(" inst %s/%d items=%d\n", inst.Name, inst.LogicalIdx, inst.ItemCount)
}
}
GetFabricTelemetry#
Description: Convenience wrapper that allocates a telemetry session, fetches one snapshot, and frees the session before returning. Mirrors the Python amdsmi_get_fabric_telemetry helper.
Input parameters:
ph(ProcessorHandle) GPU for which to fetch telemetrycategories(...FabricTelemetryCategory) variadic list of categories to request. If empty, all categories fromUALOEthroughDERIVED_NETPORTare requested.
Output: FabricTelemetryData, error
See AllocFabricTelemetry above for the description of FabricTelemetryData and the available FabricTelemetryCategory values.
Errors that can be returned by GetFabricTelemetry function:
*StatusError
Example:
snap, err := amdsmi.GetFabricTelemetry(handle)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for cat, ds := range snap.Datasets {
fmt.Printf("%-20s instances=%d items=%d\n",
cat, ds.InstanceCount,
func() int {
n := 0
for _, i := range ds.Instances {
n += int(i.ItemCount)
}
return n
}())
}