Merge branch 'add-cdi-auto-mode' into 'main'

Add auto mode to CDI spec generation

See merge request nvidia/container-toolkit/container-toolkit!292
This commit is contained in:
Evan Lezar 2023-02-20 14:30:33 +00:00
commit ba50b50a15
12 changed files with 2530 additions and 112 deletions

View File

@ -36,6 +36,7 @@ import (
)
const (
discoveryModeAuto = "auto"
discoveryModeNVML = "nvml"
discoveryModeWSL = "wsl"
@ -96,8 +97,8 @@ func (m command) build() *cli.Command {
},
&cli.StringFlag{
Name: "discovery-mode",
Usage: "The mode to use when discovering the available entities. One of [nvml | wsl]",
Value: discoveryModeNVML,
Usage: "The mode to use when discovering the available entities. One of [auto | nvml | wsl]. I mode is set to 'auto' the mode will be determined based on the system configuration.",
Value: discoveryModeAuto,
Destination: &cfg.discoveryMode,
},
&cli.StringFlag{
@ -132,6 +133,7 @@ func (m command) validateFlags(r *cli.Context, cfg *config) error {
cfg.discoveryMode = strings.ToLower(cfg.discoveryMode)
switch cfg.discoveryMode {
case discoveryModeAuto:
case discoveryModeNVML:
case discoveryModeWSL:
default:

4
go.mod
View File

@ -4,7 +4,7 @@ go 1.18
require (
github.com/BurntSushi/toml v1.0.0
github.com/NVIDIA/go-nvml v0.11.6-0.0.20220823120812-7e2082095e82
github.com/NVIDIA/go-nvml v0.12.0-0
github.com/container-orchestrated-devices/container-device-interface v0.5.4-0.20230111111500-5b3b5d81179a
github.com/fsnotify/fsnotify v1.5.4
github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb
@ -12,7 +12,7 @@ require (
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.3.0
gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20230119114711-6fe07bb33342
gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20230209143738-95328d8c4438
golang.org/x/mod v0.5.0
golang.org/x/sys v0.0.0-20220927170352-d9d178bc13c6
sigs.k8s.io/yaml v1.3.0

4
go.sum
View File

@ -3,6 +3,8 @@ github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU
github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/NVIDIA/go-nvml v0.11.6-0.0.20220823120812-7e2082095e82 h1:x751Xx1tdxkiA/sdkv2J769n21UbYKzVOpe9S/h1M3k=
github.com/NVIDIA/go-nvml v0.11.6-0.0.20220823120812-7e2082095e82/go.mod h1:hy7HYeQy335x6nEss0Ne3PYqleRa6Ct+VKD9RQ4nyFs=
github.com/NVIDIA/go-nvml v0.12.0-0 h1:eHYNHbzAsMgWYshf6dEmTY66/GCXnORJFnzm3TNH4mc=
github.com/NVIDIA/go-nvml v0.12.0-0/go.mod h1:hy7HYeQy335x6nEss0Ne3PYqleRa6Ct+VKD9RQ4nyFs=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E=
@ -88,6 +90,8 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20230119114711-6fe07bb33342 h1:083n9fJt2dWOpJd/X/q9Xgl5XtQLL22uSFYbzVqJssg=
gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20230119114711-6fe07bb33342/go.mod h1:GStidGxhaqJhYFW1YpOnLvYCbL2EsM0od7IW4u7+JgU=
gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20230209143738-95328d8c4438 h1:+qRai7XRl8omFQVCeHcaWzL542Yw64vfmuXG+79ZCIc=
gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20230209143738-95328d8c4438/go.mod h1:GStidGxhaqJhYFW1YpOnLvYCbL2EsM0od7IW4u7+JgU=
golang.org/x/mod v0.5.0 h1:UG21uOlmZabA4fW5i7ZX6bjw1xELEGg/ZLgZq9auk/Q=
golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=

View File

@ -19,6 +19,7 @@ package nvcdi
import (
"github.com/sirupsen/logrus"
"gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvlib/device"
"gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvlib/info"
"gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvml"
)
@ -39,7 +40,7 @@ func New(opts ...Option) Interface {
opt(l)
}
if l.mode == "" {
l.mode = "nvml"
l.mode = "auto"
}
if l.logger == nil {
l.logger = logrus.StandardLogger()
@ -54,7 +55,7 @@ func New(opts ...Option) Interface {
l.nvidiaCTKPath = "/usr/bin/nvidia-ctk"
}
switch l.mode {
switch l.resolveMode() {
case "nvml":
if l.nvmllib == nil {
l.nvmllib = nvml.New()
@ -71,3 +72,24 @@ func New(opts ...Option) Interface {
// TODO: We want an error here.
return nil
}
// resolveMode resolves the mode for CDI spec generation based on the current system.
func (l *nvcdilib) resolveMode() (rmode string) {
if l.mode != "auto" {
return l.mode
}
defer func() {
l.logger.Infof("Auto-detected mode as %q", rmode)
}()
nvinfo := info.New()
isWSL, reason := nvinfo.HasDXCore()
l.logger.Debugf("Is WSL-based system? %v: %v", isWSL, reason)
if isWSL {
return "wsl"
}
return "nvml"
}

View File

@ -44,11 +44,13 @@ const (
// DEVICE_PCI_BUS_ID_FMT as defined in nvml/nvml.h
DEVICE_PCI_BUS_ID_FMT = "%08X:%02X:%02X.0"
// NVLINK_MAX_LINKS as defined in nvml/nvml.h
NVLINK_MAX_LINKS = 12
NVLINK_MAX_LINKS = 18
// TOPOLOGY_CPU as defined in nvml/nvml.h
TOPOLOGY_CPU = 0
// MAX_PHYSICAL_BRIDGE as defined in nvml/nvml.h
MAX_PHYSICAL_BRIDGE = 128
// MAX_THERMAL_SENSORS_PER_GPU as defined in nvml/nvml.h
MAX_THERMAL_SENSORS_PER_GPU = 3
// FlagDefault as defined in nvml/nvml.h
FlagDefault = 0
// FlagForce as defined in nvml/nvml.h
@ -57,6 +59,8 @@ const (
SINGLE_BIT_ECC = 0
// DOUBLE_BIT_ECC as defined in nvml/nvml.h
DOUBLE_BIT_ECC = 0
// MAX_GPU_PERF_PSTATES as defined in nvml/nvml.h
MAX_GPU_PERF_PSTATES = 16
// GRID_LICENSE_EXPIRY_NOT_AVAILABLE as defined in nvml/nvml.h
GRID_LICENSE_EXPIRY_NOT_AVAILABLE = 0
// GRID_LICENSE_EXPIRY_INVALID as defined in nvml/nvml.h
@ -73,6 +77,18 @@ const (
VGPU_NAME_BUFFER_SIZE = 64
// GRID_LICENSE_FEATURE_MAX_COUNT as defined in nvml/nvml.h
GRID_LICENSE_FEATURE_MAX_COUNT = 3
// VGPU_SCHEDULER_POLICY_UNKNOWN as defined in nvml/nvml.h
VGPU_SCHEDULER_POLICY_UNKNOWN = 0
// VGPU_SCHEDULER_POLICY_BEST_EFFORT as defined in nvml/nvml.h
VGPU_SCHEDULER_POLICY_BEST_EFFORT = 1
// VGPU_SCHEDULER_POLICY_EQUAL_SHARE as defined in nvml/nvml.h
VGPU_SCHEDULER_POLICY_EQUAL_SHARE = 2
// VGPU_SCHEDULER_POLICY_FIXED_SHARE as defined in nvml/nvml.h
VGPU_SCHEDULER_POLICY_FIXED_SHARE = 3
// SUPPORTED_VGPU_SCHEDULER_POLICY_COUNT as defined in nvml/nvml.h
SUPPORTED_VGPU_SCHEDULER_POLICY_COUNT = 3
// SCHEDULER_SW_MAX_LOG_ENTRIES as defined in nvml/nvml.h
SCHEDULER_SW_MAX_LOG_ENTRIES = 200
// GRID_LICENSE_STATE_UNKNOWN as defined in nvml/nvml.h
GRID_LICENSE_STATE_UNKNOWN = 0
// GRID_LICENSE_STATE_UNINITIALIZED as defined in nvml/nvml.h
@ -85,6 +101,8 @@ const (
GRID_LICENSE_STATE_UNLICENSED = 4
// GRID_LICENSE_STATE_LICENSED as defined in nvml/nvml.h
GRID_LICENSE_STATE_LICENSED = 5
// GSP_FIRMWARE_VERSION_BUF_SIZE as defined in nvml/nvml.h
GSP_FIRMWARE_VERSION_BUF_SIZE = 64
// DEVICE_ARCH_KEPLER as defined in nvml/nvml.h
DEVICE_ARCH_KEPLER = 2
// DEVICE_ARCH_MAXWELL as defined in nvml/nvml.h
@ -97,6 +115,10 @@ const (
DEVICE_ARCH_TURING = 6
// DEVICE_ARCH_AMPERE as defined in nvml/nvml.h
DEVICE_ARCH_AMPERE = 7
// DEVICE_ARCH_ADA as defined in nvml/nvml.h
DEVICE_ARCH_ADA = 8
// DEVICE_ARCH_HOPPER as defined in nvml/nvml.h
DEVICE_ARCH_HOPPER = 9
// DEVICE_ARCH_UNKNOWN as defined in nvml/nvml.h
DEVICE_ARCH_UNKNOWN = 4294967295
// BUS_TYPE_UNKNOWN as defined in nvml/nvml.h
@ -109,6 +131,10 @@ const (
BUS_TYPE_FPCI = 3
// BUS_TYPE_AGP as defined in nvml/nvml.h
BUS_TYPE_AGP = 4
// FAN_POLICY_TEMPERATURE_CONTINOUS_SW as defined in nvml/nvml.h
FAN_POLICY_TEMPERATURE_CONTINOUS_SW = 0
// FAN_POLICY_MANUAL as defined in nvml/nvml.h
FAN_POLICY_MANUAL = 1
// POWER_SOURCE_AC as defined in nvml/nvml.h
POWER_SOURCE_AC = 0
// POWER_SOURCE_BATTERY as defined in nvml/nvml.h
@ -125,10 +151,14 @@ const (
PCIE_LINK_MAX_SPEED_16000MBPS = 4
// PCIE_LINK_MAX_SPEED_32000MBPS as defined in nvml/nvml.h
PCIE_LINK_MAX_SPEED_32000MBPS = 5
// PCIE_LINK_MAX_SPEED_64000MBPS as defined in nvml/nvml.h
PCIE_LINK_MAX_SPEED_64000MBPS = 6
// ADAPTIVE_CLOCKING_INFO_STATUS_DISABLED as defined in nvml/nvml.h
ADAPTIVE_CLOCKING_INFO_STATUS_DISABLED = 0
// ADAPTIVE_CLOCKING_INFO_STATUS_ENABLED as defined in nvml/nvml.h
ADAPTIVE_CLOCKING_INFO_STATUS_ENABLED = 1
// MAX_GPU_UTILIZATIONS as defined in nvml/nvml.h
MAX_GPU_UTILIZATIONS = 8
// FI_DEV_ECC_CURRENT as defined in nvml/nvml.h
FI_DEV_ECC_CURRENT = 1
// FI_DEV_ECC_PENDING as defined in nvml/nvml.h
@ -449,8 +479,26 @@ const (
FI_DEV_NVLINK_ECC_DATA_ERROR_COUNT_L11 = 159
// FI_DEV_NVLINK_ECC_DATA_ERROR_COUNT_TOTAL as defined in nvml/nvml.h
FI_DEV_NVLINK_ECC_DATA_ERROR_COUNT_TOTAL = 160
// FI_DEV_NVLINK_ERROR_DL_REPLAY as defined in nvml/nvml.h
FI_DEV_NVLINK_ERROR_DL_REPLAY = 161
// FI_DEV_NVLINK_ERROR_DL_RECOVERY as defined in nvml/nvml.h
FI_DEV_NVLINK_ERROR_DL_RECOVERY = 162
// FI_DEV_NVLINK_ERROR_DL_CRC as defined in nvml/nvml.h
FI_DEV_NVLINK_ERROR_DL_CRC = 163
// FI_DEV_NVLINK_GET_SPEED as defined in nvml/nvml.h
FI_DEV_NVLINK_GET_SPEED = 164
// FI_DEV_NVLINK_GET_STATE as defined in nvml/nvml.h
FI_DEV_NVLINK_GET_STATE = 165
// FI_DEV_NVLINK_GET_VERSION as defined in nvml/nvml.h
FI_DEV_NVLINK_GET_VERSION = 166
// FI_DEV_NVLINK_GET_POWER_STATE as defined in nvml/nvml.h
FI_DEV_NVLINK_GET_POWER_STATE = 167
// FI_DEV_NVLINK_GET_POWER_THRESHOLD as defined in nvml/nvml.h
FI_DEV_NVLINK_GET_POWER_THRESHOLD = 168
// FI_DEV_PCIE_L0_TO_RECOVERY_COUNTER as defined in nvml/nvml.h
FI_DEV_PCIE_L0_TO_RECOVERY_COUNTER = 169
// FI_MAX as defined in nvml/nvml.h
FI_MAX = 161
FI_MAX = 170
// EventTypeSingleBitEccError as defined in nvml/nvml.h
EventTypeSingleBitEccError = 1
// EventTypeDoubleBitEccError as defined in nvml/nvml.h
@ -503,6 +551,16 @@ const (
NVFBC_SESSION_FLAG_CAPTURE_WITH_WAIT_INFINITE = 8
// NVFBC_SESSION_FLAG_CAPTURE_WITH_WAIT_TIMEOUT as defined in nvml/nvml.h
NVFBC_SESSION_FLAG_CAPTURE_WITH_WAIT_TIMEOUT = 16
// GPU_FABRIC_UUID_LEN as defined in nvml/nvml.h
GPU_FABRIC_UUID_LEN = 16
// GPU_FABRIC_STATE_NOT_SUPPORTED as defined in nvml/nvml.h
GPU_FABRIC_STATE_NOT_SUPPORTED = 0
// GPU_FABRIC_STATE_NOT_STARTED as defined in nvml/nvml.h
GPU_FABRIC_STATE_NOT_STARTED = 1
// GPU_FABRIC_STATE_IN_PROGRESS as defined in nvml/nvml.h
GPU_FABRIC_STATE_IN_PROGRESS = 2
// GPU_FABRIC_STATE_COMPLETED as defined in nvml/nvml.h
GPU_FABRIC_STATE_COMPLETED = 3
// INIT_FLAG_NO_GPUS as defined in nvml/nvml.h
INIT_FLAG_NO_GPUS = 1
// INIT_FLAG_NO_ATTACH as defined in nvml/nvml.h
@ -551,8 +609,12 @@ const (
GPU_INSTANCE_PROFILE_6_SLICE = 6
// GPU_INSTANCE_PROFILE_1_SLICE_REV1 as defined in nvml/nvml.h
GPU_INSTANCE_PROFILE_1_SLICE_REV1 = 7
// GPU_INSTANCE_PROFILE_2_SLICE_REV1 as defined in nvml/nvml.h
GPU_INSTANCE_PROFILE_2_SLICE_REV1 = 8
// GPU_INSTANCE_PROFILE_1_SLICE_REV2 as defined in nvml/nvml.h
GPU_INSTANCE_PROFILE_1_SLICE_REV2 = 9
// GPU_INSTANCE_PROFILE_COUNT as defined in nvml/nvml.h
GPU_INSTANCE_PROFILE_COUNT = 8
GPU_INSTANCE_PROFILE_COUNT = 10
// COMPUTE_INSTANCE_PROFILE_1_SLICE as defined in nvml/nvml.h
COMPUTE_INSTANCE_PROFILE_1_SLICE = 0
// COMPUTE_INSTANCE_PROFILE_2_SLICE as defined in nvml/nvml.h
@ -567,12 +629,32 @@ const (
COMPUTE_INSTANCE_PROFILE_8_SLICE = 5
// COMPUTE_INSTANCE_PROFILE_6_SLICE as defined in nvml/nvml.h
COMPUTE_INSTANCE_PROFILE_6_SLICE = 6
// COMPUTE_INSTANCE_PROFILE_1_SLICE_REV1 as defined in nvml/nvml.h
COMPUTE_INSTANCE_PROFILE_1_SLICE_REV1 = 7
// COMPUTE_INSTANCE_PROFILE_COUNT as defined in nvml/nvml.h
COMPUTE_INSTANCE_PROFILE_COUNT = 7
COMPUTE_INSTANCE_PROFILE_COUNT = 8
// COMPUTE_INSTANCE_ENGINE_PROFILE_SHARED as defined in nvml/nvml.h
COMPUTE_INSTANCE_ENGINE_PROFILE_SHARED = 0
// COMPUTE_INSTANCE_ENGINE_PROFILE_COUNT as defined in nvml/nvml.h
COMPUTE_INSTANCE_ENGINE_PROFILE_COUNT = 1
// GPM_METRICS_GET_VERSION as defined in nvml/nvml.h
GPM_METRICS_GET_VERSION = 1
// GPM_SUPPORT_VERSION as defined in nvml/nvml.h
GPM_SUPPORT_VERSION = 1
// COUNTER_COLLECTION_UNIT_STREAM_STATE_DISABLE as defined in nvml/nvml.h
COUNTER_COLLECTION_UNIT_STREAM_STATE_DISABLE = 0
// COUNTER_COLLECTION_UNIT_STREAM_STATE_ENABLE as defined in nvml/nvml.h
COUNTER_COLLECTION_UNIT_STREAM_STATE_ENABLE = 1
// NVLINK_POWER_STATE_HIGH_SPEED as defined in nvml/nvml.h
NVLINK_POWER_STATE_HIGH_SPEED = 0
// NVLINK_POWER_STATE_LOW as defined in nvml/nvml.h
NVLINK_POWER_STATE_LOW = 1
// NVLINK_LOW_POWER_THRESHOLD_MIN as defined in nvml/nvml.h
NVLINK_LOW_POWER_THRESHOLD_MIN = 1
// NVLINK_LOW_POWER_THRESHOLD_MAX as defined in nvml/nvml.h
NVLINK_LOW_POWER_THRESHOLD_MAX = 8191
// NVLINK_LOW_POWER_THRESHOLD_RESET as defined in nvml/nvml.h
NVLINK_LOW_POWER_THRESHOLD_RESET = 4294967295
)
// BridgeChipType as declared in nvml/nvml.h
@ -918,32 +1000,34 @@ type Return int32
// Return enumeration from nvml/nvml.h
const (
SUCCESS Return = iota
ERROR_UNINITIALIZED Return = 1
ERROR_INVALID_ARGUMENT Return = 2
ERROR_NOT_SUPPORTED Return = 3
ERROR_NO_PERMISSION Return = 4
ERROR_ALREADY_INITIALIZED Return = 5
ERROR_NOT_FOUND Return = 6
ERROR_INSUFFICIENT_SIZE Return = 7
ERROR_INSUFFICIENT_POWER Return = 8
ERROR_DRIVER_NOT_LOADED Return = 9
ERROR_TIMEOUT Return = 10
ERROR_IRQ_ISSUE Return = 11
ERROR_LIBRARY_NOT_FOUND Return = 12
ERROR_FUNCTION_NOT_FOUND Return = 13
ERROR_CORRUPTED_INFOROM Return = 14
ERROR_GPU_IS_LOST Return = 15
ERROR_RESET_REQUIRED Return = 16
ERROR_OPERATING_SYSTEM Return = 17
ERROR_LIB_RM_VERSION_MISMATCH Return = 18
ERROR_IN_USE Return = 19
ERROR_MEMORY Return = 20
ERROR_NO_DATA Return = 21
ERROR_VGPU_ECC_NOT_SUPPORTED Return = 22
ERROR_INSUFFICIENT_RESOURCES Return = 23
ERROR_FREQ_NOT_SUPPORTED Return = 24
ERROR_UNKNOWN Return = 999
SUCCESS Return = iota
ERROR_UNINITIALIZED Return = 1
ERROR_INVALID_ARGUMENT Return = 2
ERROR_NOT_SUPPORTED Return = 3
ERROR_NO_PERMISSION Return = 4
ERROR_ALREADY_INITIALIZED Return = 5
ERROR_NOT_FOUND Return = 6
ERROR_INSUFFICIENT_SIZE Return = 7
ERROR_INSUFFICIENT_POWER Return = 8
ERROR_DRIVER_NOT_LOADED Return = 9
ERROR_TIMEOUT Return = 10
ERROR_IRQ_ISSUE Return = 11
ERROR_LIBRARY_NOT_FOUND Return = 12
ERROR_FUNCTION_NOT_FOUND Return = 13
ERROR_CORRUPTED_INFOROM Return = 14
ERROR_GPU_IS_LOST Return = 15
ERROR_RESET_REQUIRED Return = 16
ERROR_OPERATING_SYSTEM Return = 17
ERROR_LIB_RM_VERSION_MISMATCH Return = 18
ERROR_IN_USE Return = 19
ERROR_MEMORY Return = 20
ERROR_NO_DATA Return = 21
ERROR_VGPU_ECC_NOT_SUPPORTED Return = 22
ERROR_INSUFFICIENT_RESOURCES Return = 23
ERROR_FREQ_NOT_SUPPORTED Return = 24
ERROR_ARGUMENT_VERSION_MISMATCH Return = 25
ERROR_DEPRECATED Return = 26
ERROR_UNKNOWN Return = 999
)
// MemoryLocation as declared in nvml/nvml.h
@ -983,18 +1067,6 @@ const (
RESTRICTED_API_COUNT RestrictedAPI = 2
)
// NvLinkEccLaneErrorCounter as declared in nvml/nvml.h
type NvLinkEccLaneErrorCounter int32
// NvLinkEccLaneErrorCounter enumeration from nvml/nvml.h
const (
NVLINK_ERROR_DL_ECC_LANE0 NvLinkEccLaneErrorCounter = iota
NVLINK_ERROR_DL_ECC_LANE1 NvLinkEccLaneErrorCounter = 1
NVLINK_ERROR_DL_ECC_LANE2 NvLinkEccLaneErrorCounter = 2
NVLINK_ERROR_DL_ECC_LANE3 NvLinkEccLaneErrorCounter = 3
NVLINK_ERROR_DL_ECC_COUNT NvLinkEccLaneErrorCounter = 4
)
// GpuVirtualizationMode as declared in nvml/nvml.h
type GpuVirtualizationMode int32
@ -1034,6 +1106,50 @@ const (
VGPU_INSTANCE_GUEST_INFO_STATE_INITIALIZED VgpuGuestInfoState = 1
)
// VgpuCapability as declared in nvml/nvml.h
type VgpuCapability int32
// VgpuCapability enumeration from nvml/nvml.h
const (
VGPU_CAP_NVLINK_P2P VgpuCapability = iota
VGPU_CAP_GPUDIRECT VgpuCapability = 1
VGPU_CAP_MULTI_VGPU_EXCLUSIVE VgpuCapability = 2
VGPU_CAP_EXCLUSIVE_TYPE VgpuCapability = 3
VGPU_CAP_EXCLUSIVE_SIZE VgpuCapability = 4
VGPU_CAP_COUNT VgpuCapability = 5
)
// VgpuDriverCapability as declared in nvml/nvml.h
type VgpuDriverCapability int32
// VgpuDriverCapability enumeration from nvml/nvml.h
const (
VGPU_DRIVER_CAP_HETEROGENEOUS_MULTI_VGPU VgpuDriverCapability = iota
VGPU_DRIVER_CAP_COUNT VgpuDriverCapability = 1
)
// DeviceVgpuCapability as declared in nvml/nvml.h
type DeviceVgpuCapability int32
// DeviceVgpuCapability enumeration from nvml/nvml.h
const (
DEVICE_VGPU_CAP_FRACTIONAL_MULTI_VGPU DeviceVgpuCapability = iota
DEVICE_VGPU_CAP_HETEROGENEOUS_TIMESLICE_PROFILES DeviceVgpuCapability = 1
DEVICE_VGPU_CAP_HETEROGENEOUS_TIMESLICE_SIZES DeviceVgpuCapability = 2
DEVICE_VGPU_CAP_COUNT DeviceVgpuCapability = 3
)
// GpuUtilizationDomainId as declared in nvml/nvml.h
type GpuUtilizationDomainId int32
// GpuUtilizationDomainId enumeration from nvml/nvml.h
const (
GPU_UTILIZATION_DOMAIN_GPU GpuUtilizationDomainId = iota
GPU_UTILIZATION_DOMAIN_FB GpuUtilizationDomainId = 1
GPU_UTILIZATION_DOMAIN_VID GpuUtilizationDomainId = 2
GPU_UTILIZATION_DOMAIN_BUS GpuUtilizationDomainId = 3
)
// FanState as declared in nvml/nvml.h
type FanState int32
@ -1125,6 +1241,49 @@ const (
VGPU_COMPATIBILITY_LIMIT_OTHER VgpuPgpuCompatibilityLimitCode = -2147483648
)
// ThermalTarget as declared in nvml/nvml.h
type ThermalTarget int32
// ThermalTarget enumeration from nvml/nvml.h
const (
THERMAL_TARGET_NONE ThermalTarget = iota
THERMAL_TARGET_GPU ThermalTarget = 1
THERMAL_TARGET_MEMORY ThermalTarget = 2
THERMAL_TARGET_POWER_SUPPLY ThermalTarget = 4
THERMAL_TARGET_BOARD ThermalTarget = 8
THERMAL_TARGET_VCD_BOARD ThermalTarget = 9
THERMAL_TARGET_VCD_INLET ThermalTarget = 10
THERMAL_TARGET_VCD_OUTLET ThermalTarget = 11
THERMAL_TARGET_ALL ThermalTarget = 15
THERMAL_TARGET_UNKNOWN ThermalTarget = -1
)
// ThermalController as declared in nvml/nvml.h
type ThermalController int32
// ThermalController enumeration from nvml/nvml.h
const (
THERMAL_CONTROLLER_NONE ThermalController = iota
THERMAL_CONTROLLER_GPU_INTERNAL ThermalController = 1
THERMAL_CONTROLLER_ADM1032 ThermalController = 2
THERMAL_CONTROLLER_ADT7461 ThermalController = 3
THERMAL_CONTROLLER_MAX6649 ThermalController = 4
THERMAL_CONTROLLER_MAX1617 ThermalController = 5
THERMAL_CONTROLLER_LM99 ThermalController = 6
THERMAL_CONTROLLER_LM89 ThermalController = 7
THERMAL_CONTROLLER_LM64 ThermalController = 8
THERMAL_CONTROLLER_G781 ThermalController = 9
THERMAL_CONTROLLER_ADT7473 ThermalController = 10
THERMAL_CONTROLLER_SBMAX6649 ThermalController = 11
THERMAL_CONTROLLER_VBIOSEVT ThermalController = 12
THERMAL_CONTROLLER_OS ThermalController = 13
THERMAL_CONTROLLER_NVSYSCON_CANOAS ThermalController = 14
THERMAL_CONTROLLER_NVSYSCON_E551 ThermalController = 15
THERMAL_CONTROLLER_MAX6649R ThermalController = 16
THERMAL_CONTROLLER_ADT7473S ThermalController = 17
THERMAL_CONTROLLER_UNKNOWN ThermalController = -1
)
// GridLicenseFeatureCode as declared in nvml/nvml.h
type GridLicenseFeatureCode int32
@ -1137,3 +1296,80 @@ const (
GRID_LICENSE_FEATURE_CODE_GAMING GridLicenseFeatureCode = 3
GRID_LICENSE_FEATURE_CODE_COMPUTE GridLicenseFeatureCode = 4
)
// GpmMetricId as declared in nvml/nvml.h
type GpmMetricId int32
// GpmMetricId enumeration from nvml/nvml.h
const (
GPM_METRIC_GRAPHICS_UTIL GpmMetricId = 1
GPM_METRIC_SM_UTIL GpmMetricId = 2
GPM_METRIC_SM_OCCUPANCY GpmMetricId = 3
GPM_METRIC_INTEGER_UTIL GpmMetricId = 4
GPM_METRIC_ANY_TENSOR_UTIL GpmMetricId = 5
GPM_METRIC_DFMA_TENSOR_UTIL GpmMetricId = 6
GPM_METRIC_HMMA_TENSOR_UTIL GpmMetricId = 7
GPM_METRIC_IMMA_TENSOR_UTIL GpmMetricId = 9
GPM_METRIC_DRAM_BW_UTIL GpmMetricId = 10
GPM_METRIC_FP64_UTIL GpmMetricId = 11
GPM_METRIC_FP32_UTIL GpmMetricId = 12
GPM_METRIC_FP16_UTIL GpmMetricId = 13
GPM_METRIC_PCIE_TX_PER_SEC GpmMetricId = 20
GPM_METRIC_PCIE_RX_PER_SEC GpmMetricId = 21
GPM_METRIC_NVDEC_0_UTIL GpmMetricId = 30
GPM_METRIC_NVDEC_1_UTIL GpmMetricId = 31
GPM_METRIC_NVDEC_2_UTIL GpmMetricId = 32
GPM_METRIC_NVDEC_3_UTIL GpmMetricId = 33
GPM_METRIC_NVDEC_4_UTIL GpmMetricId = 34
GPM_METRIC_NVDEC_5_UTIL GpmMetricId = 35
GPM_METRIC_NVDEC_6_UTIL GpmMetricId = 36
GPM_METRIC_NVDEC_7_UTIL GpmMetricId = 37
GPM_METRIC_NVJPG_0_UTIL GpmMetricId = 40
GPM_METRIC_NVJPG_1_UTIL GpmMetricId = 41
GPM_METRIC_NVJPG_2_UTIL GpmMetricId = 42
GPM_METRIC_NVJPG_3_UTIL GpmMetricId = 43
GPM_METRIC_NVJPG_4_UTIL GpmMetricId = 44
GPM_METRIC_NVJPG_5_UTIL GpmMetricId = 45
GPM_METRIC_NVJPG_6_UTIL GpmMetricId = 46
GPM_METRIC_NVJPG_7_UTIL GpmMetricId = 47
GPM_METRIC_NVOFA_0_UTIL GpmMetricId = 50
GPM_METRIC_NVLINK_TOTAL_RX_PER_SEC GpmMetricId = 60
GPM_METRIC_NVLINK_TOTAL_TX_PER_SEC GpmMetricId = 61
GPM_METRIC_NVLINK_L0_RX_PER_SEC GpmMetricId = 62
GPM_METRIC_NVLINK_L0_TX_PER_SEC GpmMetricId = 63
GPM_METRIC_NVLINK_L1_RX_PER_SEC GpmMetricId = 64
GPM_METRIC_NVLINK_L1_TX_PER_SEC GpmMetricId = 65
GPM_METRIC_NVLINK_L2_RX_PER_SEC GpmMetricId = 66
GPM_METRIC_NVLINK_L2_TX_PER_SEC GpmMetricId = 67
GPM_METRIC_NVLINK_L3_RX_PER_SEC GpmMetricId = 68
GPM_METRIC_NVLINK_L3_TX_PER_SEC GpmMetricId = 69
GPM_METRIC_NVLINK_L4_RX_PER_SEC GpmMetricId = 70
GPM_METRIC_NVLINK_L4_TX_PER_SEC GpmMetricId = 71
GPM_METRIC_NVLINK_L5_RX_PER_SEC GpmMetricId = 72
GPM_METRIC_NVLINK_L5_TX_PER_SEC GpmMetricId = 73
GPM_METRIC_NVLINK_L6_RX_PER_SEC GpmMetricId = 74
GPM_METRIC_NVLINK_L6_TX_PER_SEC GpmMetricId = 75
GPM_METRIC_NVLINK_L7_RX_PER_SEC GpmMetricId = 76
GPM_METRIC_NVLINK_L7_TX_PER_SEC GpmMetricId = 77
GPM_METRIC_NVLINK_L8_RX_PER_SEC GpmMetricId = 78
GPM_METRIC_NVLINK_L8_TX_PER_SEC GpmMetricId = 79
GPM_METRIC_NVLINK_L9_RX_PER_SEC GpmMetricId = 80
GPM_METRIC_NVLINK_L9_TX_PER_SEC GpmMetricId = 81
GPM_METRIC_NVLINK_L10_RX_PER_SEC GpmMetricId = 82
GPM_METRIC_NVLINK_L10_TX_PER_SEC GpmMetricId = 83
GPM_METRIC_NVLINK_L11_RX_PER_SEC GpmMetricId = 84
GPM_METRIC_NVLINK_L11_TX_PER_SEC GpmMetricId = 85
GPM_METRIC_NVLINK_L12_RX_PER_SEC GpmMetricId = 86
GPM_METRIC_NVLINK_L12_TX_PER_SEC GpmMetricId = 87
GPM_METRIC_NVLINK_L13_RX_PER_SEC GpmMetricId = 88
GPM_METRIC_NVLINK_L13_TX_PER_SEC GpmMetricId = 89
GPM_METRIC_NVLINK_L14_RX_PER_SEC GpmMetricId = 90
GPM_METRIC_NVLINK_L14_TX_PER_SEC GpmMetricId = 91
GPM_METRIC_NVLINK_L15_RX_PER_SEC GpmMetricId = 92
GPM_METRIC_NVLINK_L15_TX_PER_SEC GpmMetricId = 93
GPM_METRIC_NVLINK_L16_RX_PER_SEC GpmMetricId = 94
GPM_METRIC_NVLINK_L16_TX_PER_SEC GpmMetricId = 95
GPM_METRIC_NVLINK_L17_RX_PER_SEC GpmMetricId = 96
GPM_METRIC_NVLINK_L17_TX_PER_SEC GpmMetricId = 97
GPM_METRIC_MAX GpmMetricId = 98
)

View File

@ -38,21 +38,21 @@ func DeviceGetHandleByIndex(Index int) (Device, Return) {
// nvml.DeviceGetHandleBySerial()
func DeviceGetHandleBySerial(Serial string) (Device, Return) {
var Device Device
ret := nvmlDeviceGetHandleBySerial(Serial + string(rune(0)), &Device)
ret := nvmlDeviceGetHandleBySerial(Serial+string(rune(0)), &Device)
return Device, ret
}
// nvml.DeviceGetHandleByUUID()
func DeviceGetHandleByUUID(Uuid string) (Device, Return) {
var Device Device
ret := nvmlDeviceGetHandleByUUID(Uuid + string(rune(0)), &Device)
ret := nvmlDeviceGetHandleByUUID(Uuid+string(rune(0)), &Device)
return Device, ret
}
// nvml.DeviceGetHandleByPciBusId()
func DeviceGetHandleByPciBusId(PciBusId string) (Device, Return) {
var Device Device
ret := nvmlDeviceGetHandleByPciBusId(PciBusId + string(rune(0)), &Device)
ret := nvmlDeviceGetHandleByPciBusId(PciBusId+string(rune(0)), &Device)
return Device, ret
}
@ -2286,3 +2286,360 @@ func DeviceGetBusType(Device Device) (BusType, Return) {
func (Device Device) GetBusType() (BusType, Return) {
return DeviceGetBusType(Device)
}
// nvml.DeviceSetDefaultFanSpeed_v2()
func DeviceSetDefaultFanSpeed_v2(Device Device, Fan int) Return {
return nvmlDeviceSetDefaultFanSpeed_v2(Device, uint32(Fan))
}
func (Device Device) SetDefaultFanSpeed_v2(Fan int) Return {
return DeviceSetDefaultFanSpeed_v2(Device, Fan)
}
// nvml.DeviceGetMinMaxFanSpeed()
func DeviceGetMinMaxFanSpeed(Device Device) (int, int, Return) {
var MinSpeed, MaxSpeed uint32
ret := nvmlDeviceGetMinMaxFanSpeed(Device, &MinSpeed, &MaxSpeed)
return int(MinSpeed), int(MaxSpeed), ret
}
func (Device Device) GetMinMaxFanSpeed() (int, int, Return) {
return DeviceGetMinMaxFanSpeed(Device)
}
// nvml.DeviceGetThermalSettings()
func DeviceGetThermalSettings(Device Device, SensorIndex uint32) (GpuThermalSettings, Return) {
var PThermalSettings GpuThermalSettings
ret := nvmlDeviceGetThermalSettings(Device, SensorIndex, &PThermalSettings)
return PThermalSettings, ret
}
func (Device Device) GetThermalSettings(SensorIndex uint32) (GpuThermalSettings, Return) {
return DeviceGetThermalSettings(Device, SensorIndex)
}
// nvml.DeviceGetDefaultEccMode()
func DeviceGetDefaultEccMode(Device Device) (EnableState, Return) {
var DefaultMode EnableState
ret := nvmlDeviceGetDefaultEccMode(Device, &DefaultMode)
return DefaultMode, ret
}
func (Device Device) GetDefaultEccMode() (EnableState, Return) {
return DeviceGetDefaultEccMode(Device)
}
// nvml.DeviceGetPcieSpeed()
func DeviceGetPcieSpeed(Device Device) (int, Return) {
var PcieSpeed uint32
ret := nvmlDeviceGetPcieSpeed(Device, &PcieSpeed)
return int(PcieSpeed), ret
}
func (Device Device) GetPcieSpeed() (int, Return) {
return DeviceGetPcieSpeed(Device)
}
// nvml.DeviceGetGspFirmwareVersion()
func DeviceGetGspFirmwareVersion(Device Device) (string, Return) {
Version := make([]byte, GSP_FIRMWARE_VERSION_BUF_SIZE)
ret := nvmlDeviceGetGspFirmwareVersion(Device, &Version[0])
return string(Version[:clen(Version)]), ret
}
func (Device Device) GetGspFirmwareVersion() (string, Return) {
return DeviceGetGspFirmwareVersion(Device)
}
// nvml.DeviceGetGspFirmwareMode()
func DeviceGetGspFirmwareMode(Device Device) (bool, bool, Return) {
var IsEnabled, DefaultMode uint32
ret := nvmlDeviceGetGspFirmwareMode(Device, &IsEnabled, &DefaultMode)
return (IsEnabled != 0), (DefaultMode != 0), ret
}
func (Device Device) GetGspFirmwareMode() (bool, bool, Return) {
return DeviceGetGspFirmwareMode(Device)
}
// nvml.DeviceGetDynamicPstatesInfo()
func DeviceGetDynamicPstatesInfo(Device Device) (GpuDynamicPstatesInfo, Return) {
var PDynamicPstatesInfo GpuDynamicPstatesInfo
ret := nvmlDeviceGetDynamicPstatesInfo(Device, &PDynamicPstatesInfo)
return PDynamicPstatesInfo, ret
}
func (Device Device) GetDynamicPstatesInfo() (GpuDynamicPstatesInfo, Return) {
return DeviceGetDynamicPstatesInfo(Device)
}
// nvml.DeviceSetFanSpeed_v2()
func DeviceSetFanSpeed_v2(Device Device, Fan int, Speed int) Return {
return nvmlDeviceSetFanSpeed_v2(Device, uint32(Fan), uint32(Speed))
}
func (Device Device) SetFanSpeed_v2(Fan int, Speed int) Return {
return DeviceSetFanSpeed_v2(Device, Fan, Speed)
}
// nvml.DeviceGetGpcClkVfOffset()
func DeviceGetGpcClkVfOffset(Device Device) (int, Return) {
var Offset int32
ret := nvmlDeviceGetGpcClkVfOffset(Device, &Offset)
return int(Offset), ret
}
func (Device Device) GetGpcClkVfOffset() (int, Return) {
return DeviceGetGpcClkVfOffset(Device)
}
// nvml.DeviceSetGpcClkVfOffset()
func DeviceSetGpcClkVfOffset(Device Device, Offset int) Return {
return nvmlDeviceSetGpcClkVfOffset(Device, int32(Offset))
}
func (Device Device) SetGpcClkVfOffset(Offset int) Return {
return DeviceSetGpcClkVfOffset(Device, Offset)
}
// nvml.DeviceGetMinMaxClockOfPState()
func DeviceGetMinMaxClockOfPState(Device Device, _type ClockType, Pstate Pstates) (uint32, uint32, Return) {
var MinClockMHz, MaxClockMHz uint32
ret := nvmlDeviceGetMinMaxClockOfPState(Device, _type, Pstate, &MinClockMHz, &MaxClockMHz)
return MinClockMHz, MaxClockMHz, ret
}
func (Device Device) GetMinMaxClockOfPState(_type ClockType, Pstate Pstates) (uint32, uint32, Return) {
return DeviceGetMinMaxClockOfPState(Device, _type, Pstate)
}
// nvml.DeviceGetSupportedPerformanceStates()
func DeviceGetSupportedPerformanceStates(Device Device) ([]Pstates, Return) {
Pstates := make([]Pstates, MAX_GPU_PERF_PSTATES)
ret := nvmlDeviceGetSupportedPerformanceStates(Device, &Pstates[0], MAX_GPU_PERF_PSTATES)
for i := 0; i < MAX_GPU_PERF_PSTATES; i++ {
if Pstates[i] == PSTATE_UNKNOWN {
return Pstates[0:i], ret
}
}
return Pstates, ret
}
func (Device Device) GetSupportedPerformanceStates() ([]Pstates, Return) {
return DeviceGetSupportedPerformanceStates(Device)
}
// nvml.DeviceGetTargetFanSpeed()
func DeviceGetTargetFanSpeed(Device Device, Fan int) (int, Return) {
var TargetSpeed uint32
ret := nvmlDeviceGetTargetFanSpeed(Device, uint32(Fan), &TargetSpeed)
return int(TargetSpeed), ret
}
func (Device Device) GetTargetFanSpeed(Fan int) (int, Return) {
return DeviceGetTargetFanSpeed(Device, Fan)
}
// nvml.DeviceGetMemClkVfOffset()
func DeviceGetMemClkVfOffset(Device Device) (int, Return) {
var Offset int32
ret := nvmlDeviceGetMemClkVfOffset(Device, &Offset)
return int(Offset), ret
}
func (Device Device) GetMemClkVfOffset() (int, Return) {
return DeviceGetMemClkVfOffset(Device)
}
// nvml.DeviceSetMemClkVfOffset()
func DeviceSetMemClkVfOffset(Device Device, Offset int) Return {
return nvmlDeviceSetMemClkVfOffset(Device, int32(Offset))
}
func (Device Device) SetMemClkVfOffset(Offset int) Return {
return DeviceSetMemClkVfOffset(Device, Offset)
}
// nvml.DeviceGetGpcClkMinMaxVfOffset()
func DeviceGetGpcClkMinMaxVfOffset(Device Device) (int, int, Return) {
var MinOffset, MaxOffset int32
ret := nvmlDeviceGetGpcClkMinMaxVfOffset(Device, &MinOffset, &MaxOffset)
return int(MinOffset), int(MaxOffset), ret
}
func (Device Device) GetGpcClkMinMaxVfOffset() (int, int, Return) {
return DeviceGetGpcClkMinMaxVfOffset(Device)
}
// nvml.DeviceGetMemClkMinMaxVfOffset()
func DeviceGetMemClkMinMaxVfOffset(Device Device) (int, int, Return) {
var MinOffset, MaxOffset int32
ret := nvmlDeviceGetMemClkMinMaxVfOffset(Device, &MinOffset, &MaxOffset)
return int(MinOffset), int(MaxOffset), ret
}
func (Device Device) GetMemClkMinMaxVfOffset() (int, int, Return) {
return DeviceGetMemClkMinMaxVfOffset(Device)
}
// nvml.DeviceGetGpuMaxPcieLinkGeneration()
func DeviceGetGpuMaxPcieLinkGeneration(Device Device) (int, Return) {
var MaxLinkGenDevice uint32
ret := nvmlDeviceGetGpuMaxPcieLinkGeneration(Device, &MaxLinkGenDevice)
return int(MaxLinkGenDevice), ret
}
func (Device Device) GetGpuMaxPcieLinkGeneration() (int, Return) {
return DeviceGetGpuMaxPcieLinkGeneration(Device)
}
// nvml.DeviceGetFanControlPolicy_v2()
func DeviceGetFanControlPolicy_v2(Device Device, Fan int) (FanControlPolicy, Return) {
var Policy FanControlPolicy
ret := nvmlDeviceGetFanControlPolicy_v2(Device, uint32(Fan), &Policy)
return Policy, ret
}
func (Device Device) GetFanControlPolicy_v2(Fan int) (FanControlPolicy, Return) {
return DeviceGetFanControlPolicy_v2(Device, Fan)
}
// nvml.DeviceSetFanControlPolicy()
func DeviceSetFanControlPolicy(Device Device, Fan int, Policy FanControlPolicy) Return {
return nvmlDeviceSetFanControlPolicy(Device, uint32(Fan), Policy)
}
func (Device Device) SetFanControlPolicy(Fan int, Policy FanControlPolicy) Return {
return DeviceSetFanControlPolicy(Device, Fan, Policy)
}
// nvml.DeviceClearFieldValues()
func DeviceClearFieldValues(Device Device, Values []FieldValue) Return {
ValuesCount := len(Values)
return nvmlDeviceClearFieldValues(Device, int32(ValuesCount), &Values[0])
}
func (Device Device) ClearFieldValues(Values []FieldValue) Return {
return DeviceClearFieldValues(Device, Values)
}
// nvml.DeviceGetVgpuCapabilities()
func DeviceGetVgpuCapabilities(Device Device, Capability DeviceVgpuCapability) (bool, Return) {
var CapResult uint32
ret := nvmlDeviceGetVgpuCapabilities(Device, Capability, &CapResult)
return (CapResult != 0), ret
}
func (Device Device) GetVgpuCapabilities(Capability DeviceVgpuCapability) (bool, Return) {
return DeviceGetVgpuCapabilities(Device, Capability)
}
// nvml.DeviceGetVgpuSchedulerLog()
func DeviceGetVgpuSchedulerLog(Device Device) (VgpuSchedulerLog, Return) {
var PSchedulerLog VgpuSchedulerLog
ret := nvmlDeviceGetVgpuSchedulerLog(Device, &PSchedulerLog)
return PSchedulerLog, ret
}
func (Device Device) GetVgpuSchedulerLog() (VgpuSchedulerLog, Return) {
return DeviceGetVgpuSchedulerLog(Device)
}
// nvml.DeviceGetVgpuSchedulerState()
func DeviceGetVgpuSchedulerState(Device Device) (VgpuSchedulerGetState, Return) {
var PSchedulerState VgpuSchedulerGetState
ret := nvmlDeviceGetVgpuSchedulerState(Device, &PSchedulerState)
return PSchedulerState, ret
}
func (Device Device) GetVgpuSchedulerState() (VgpuSchedulerGetState, Return) {
return DeviceGetVgpuSchedulerState(Device)
}
// nvml.DeviceSetVgpuSchedulerState()
func DeviceSetVgpuSchedulerState(Device Device, PSchedulerState *VgpuSchedulerSetState) Return {
return nvmlDeviceSetVgpuSchedulerState(Device, PSchedulerState)
}
func (Device Device) SetVgpuSchedulerState(PSchedulerState *VgpuSchedulerSetState) Return {
return DeviceSetVgpuSchedulerState(Device, PSchedulerState)
}
// nvml.DeviceGetVgpuSchedulerCapabilities()
func DeviceGetVgpuSchedulerCapabilities(Device Device) (VgpuSchedulerCapabilities, Return) {
var PCapabilities VgpuSchedulerCapabilities
ret := nvmlDeviceGetVgpuSchedulerCapabilities(Device, &PCapabilities)
return PCapabilities, ret
}
func (Device Device) GetVgpuSchedulerCapabilities() (VgpuSchedulerCapabilities, Return) {
return DeviceGetVgpuSchedulerCapabilities(Device)
}
// nvml.GpuInstanceGetComputeInstancePossiblePlacements()
func GpuInstanceGetComputeInstancePossiblePlacements(GpuInstance GpuInstance, ProfileId int) ([]ComputeInstancePlacement, Return) {
var Count uint32
ret := nvmlGpuInstanceGetComputeInstancePossiblePlacements(GpuInstance, uint32(ProfileId), nil, &Count)
if ret != SUCCESS {
return nil, ret
}
if Count == 0 {
return []ComputeInstancePlacement{}, ret
}
PlacementArray := make([]ComputeInstancePlacement, Count)
ret = nvmlGpuInstanceGetComputeInstancePossiblePlacements(GpuInstance, uint32(ProfileId), &PlacementArray[0], &Count)
return PlacementArray, ret
}
func (GpuInstance GpuInstance) GetComputeInstancePossiblePlacements(ProfileId int) ([]ComputeInstancePlacement, Return) {
return GpuInstanceGetComputeInstancePossiblePlacements(GpuInstance, ProfileId)
}
// nvml.GpuInstanceCreateComputeInstanceWithPlacement()
func GpuInstanceCreateComputeInstanceWithPlacement(GpuInstance GpuInstance, ProfileId int, Placement *ComputeInstancePlacement, ComputeInstance *ComputeInstance) Return {
return nvmlGpuInstanceCreateComputeInstanceWithPlacement(GpuInstance, uint32(ProfileId), Placement, ComputeInstance)
}
func (GpuInstance GpuInstance) CreateComputeInstanceWithPlacement(ProfileId int, Placement *ComputeInstancePlacement, ComputeInstance *ComputeInstance) Return {
return GpuInstanceCreateComputeInstanceWithPlacement(GpuInstance, ProfileId, Placement, ComputeInstance)
}
// nvml.DeviceGetGpuFabricInfo()
func DeviceGetGpuFabricInfo(Device Device) (GpuFabricInfo, Return) {
var GpuFabricInfo GpuFabricInfo
ret := nvmlDeviceGetGpuFabricInfo(Device, &GpuFabricInfo)
return GpuFabricInfo, ret
}
func (Device Device) GetGpuFabricInfo() (GpuFabricInfo, Return) {
return DeviceGetGpuFabricInfo(Device)
}
// nvml.DeviceCcuGetStreamState()
func DeviceCcuGetStreamState(Device Device) (int, Return) {
var State uint32
ret := nvmlDeviceCcuGetStreamState(Device, &State)
return int(State), ret
}
func (Device Device) CcuGetStreamState() (int, Return) {
return DeviceCcuGetStreamState(Device)
}
// nvml.DeviceCcuSetStreamState()
func DeviceCcuSetStreamState(Device Device, State int) Return {
return nvmlDeviceCcuSetStreamState(Device, uint32(State))
}
func (Device Device) CcuSetStreamState(State int) Return {
return DeviceCcuSetStreamState(Device, State)
}
// nvml.DeviceSetNvLinkDeviceLowPowerThreshold()
func DeviceSetNvLinkDeviceLowPowerThreshold(Device Device, Info *NvLinkPowerThres) Return {
return nvmlDeviceSetNvLinkDeviceLowPowerThreshold(Device, Info)
}
func (Device Device) SetNvLinkDeviceLowPowerThreshold(Info *NvLinkPowerThres) Return {
return DeviceSetNvLinkDeviceLowPowerThreshold(Device, Info)
}

View File

@ -486,6 +486,15 @@ func nvmlDeviceGetMaxPcieLinkGeneration(Device Device, MaxLinkGen *uint32) Retur
return __v
}
// nvmlDeviceGetGpuMaxPcieLinkGeneration function as declared in nvml/nvml.h
func nvmlDeviceGetGpuMaxPcieLinkGeneration(Device Device, MaxLinkGenDevice *uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cMaxLinkGenDevice, _ := (*C.uint)(unsafe.Pointer(MaxLinkGenDevice)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetGpuMaxPcieLinkGeneration(cDevice, cMaxLinkGenDevice)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetMaxPcieLinkWidth function as declared in nvml/nvml.h
func nvmlDeviceGetMaxPcieLinkWidth(Device Device, MaxLinkWidth *uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
@ -670,6 +679,55 @@ func nvmlDeviceGetFanSpeed_v2(Device Device, Fan uint32, Speed *uint32) Return {
return __v
}
// nvmlDeviceGetTargetFanSpeed function as declared in nvml/nvml.h
func nvmlDeviceGetTargetFanSpeed(Device Device, Fan uint32, TargetSpeed *uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cFan, _ := (C.uint)(Fan), cgoAllocsUnknown
cTargetSpeed, _ := (*C.uint)(unsafe.Pointer(TargetSpeed)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetTargetFanSpeed(cDevice, cFan, cTargetSpeed)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceSetDefaultFanSpeed_v2 function as declared in nvml/nvml.h
func nvmlDeviceSetDefaultFanSpeed_v2(Device Device, Fan uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cFan, _ := (C.uint)(Fan), cgoAllocsUnknown
__ret := C.nvmlDeviceSetDefaultFanSpeed_v2(cDevice, cFan)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetMinMaxFanSpeed function as declared in nvml/nvml.h
func nvmlDeviceGetMinMaxFanSpeed(Device Device, MinSpeed *uint32, MaxSpeed *uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cMinSpeed, _ := (*C.uint)(unsafe.Pointer(MinSpeed)), cgoAllocsUnknown
cMaxSpeed, _ := (*C.uint)(unsafe.Pointer(MaxSpeed)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetMinMaxFanSpeed(cDevice, cMinSpeed, cMaxSpeed)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetFanControlPolicy_v2 function as declared in nvml/nvml.h
func nvmlDeviceGetFanControlPolicy_v2(Device Device, Fan uint32, Policy *FanControlPolicy) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cFan, _ := (C.uint)(Fan), cgoAllocsUnknown
cPolicy, _ := (*C.nvmlFanControlPolicy_t)(unsafe.Pointer(Policy)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetFanControlPolicy_v2(cDevice, cFan, cPolicy)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceSetFanControlPolicy function as declared in nvml/nvml.h
func nvmlDeviceSetFanControlPolicy(Device Device, Fan uint32, Policy FanControlPolicy) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cFan, _ := (C.uint)(Fan), cgoAllocsUnknown
cPolicy, _ := (C.nvmlFanControlPolicy_t)(Policy), cgoAllocsUnknown
__ret := C.nvmlDeviceSetFanControlPolicy(cDevice, cFan, cPolicy)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetNumFans function as declared in nvml/nvml.h
func nvmlDeviceGetNumFans(Device Device, NumFans *uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
@ -709,6 +767,16 @@ func nvmlDeviceSetTemperatureThreshold(Device Device, ThresholdType TemperatureT
return __v
}
// nvmlDeviceGetThermalSettings function as declared in nvml/nvml.h
func nvmlDeviceGetThermalSettings(Device Device, SensorIndex uint32, PThermalSettings *GpuThermalSettings) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cSensorIndex, _ := (C.uint)(SensorIndex), cgoAllocsUnknown
cPThermalSettings, _ := (*C.nvmlGpuThermalSettings_t)(unsafe.Pointer(PThermalSettings)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetThermalSettings(cDevice, cSensorIndex, cPThermalSettings)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetPerformanceState function as declared in nvml/nvml.h
func nvmlDeviceGetPerformanceState(Device Device, PState *Pstates) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
@ -866,6 +934,15 @@ func nvmlDeviceGetEccMode(Device Device, Current *EnableState, Pending *EnableSt
return __v
}
// nvmlDeviceGetDefaultEccMode function as declared in nvml/nvml.h
func nvmlDeviceGetDefaultEccMode(Device Device, DefaultMode *EnableState) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cDefaultMode, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(DefaultMode)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetDefaultEccMode(cDevice, cDefaultMode)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetBoardId function as declared in nvml/nvml.h
func nvmlDeviceGetBoardId(Device Device, BoardId *uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
@ -1153,6 +1230,15 @@ func nvmlDeviceGetPcieLinkMaxSpeed(Device Device, MaxSpeed *uint32) Return {
return __v
}
// nvmlDeviceGetPcieSpeed function as declared in nvml/nvml.h
func nvmlDeviceGetPcieSpeed(Device Device, PcieSpeed *uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cPcieSpeed, _ := (*C.uint)(unsafe.Pointer(PcieSpeed)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetPcieSpeed(cDevice, cPcieSpeed)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetAdaptiveClockInfoStatus function as declared in nvml/nvml.h
func nvmlDeviceGetAdaptiveClockInfoStatus(Device Device, AdaptiveClockStatus *uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
@ -1635,6 +1721,16 @@ func nvmlDeviceGetFieldValues(Device Device, ValuesCount int32, Values *FieldVal
return __v
}
// nvmlDeviceClearFieldValues function as declared in nvml/nvml.h
func nvmlDeviceClearFieldValues(Device Device, ValuesCount int32, Values *FieldValue) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cValuesCount, _ := (C.int)(ValuesCount), cgoAllocsUnknown
cValues, _ := (*C.nvmlFieldValue_t)(unsafe.Pointer(Values)), cgoAllocsUnknown
__ret := C.nvmlDeviceClearFieldValues(cDevice, cValuesCount, cValues)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetVirtualizationMode function as declared in nvml/nvml.h
func nvmlDeviceGetVirtualizationMode(Device Device, PVirtualMode *GpuVirtualizationMode) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
@ -1682,6 +1778,44 @@ func nvmlDeviceGetProcessUtilization(Device Device, Utilization *ProcessUtilizat
return __v
}
// nvmlDeviceGetGspFirmwareVersion function as declared in nvml/nvml.h
func nvmlDeviceGetGspFirmwareVersion(Device Device, Version *byte) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cVersion, _ := (*C.char)(unsafe.Pointer(Version)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetGspFirmwareVersion(cDevice, cVersion)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetGspFirmwareMode function as declared in nvml/nvml.h
func nvmlDeviceGetGspFirmwareMode(Device Device, IsEnabled *uint32, DefaultMode *uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cIsEnabled, _ := (*C.uint)(unsafe.Pointer(IsEnabled)), cgoAllocsUnknown
cDefaultMode, _ := (*C.uint)(unsafe.Pointer(DefaultMode)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetGspFirmwareMode(cDevice, cIsEnabled, cDefaultMode)
__v := (Return)(__ret)
return __v
}
// nvmlGetVgpuDriverCapabilities function as declared in nvml/nvml.h
func nvmlGetVgpuDriverCapabilities(Capability VgpuDriverCapability, CapResult *uint32) Return {
cCapability, _ := (C.nvmlVgpuDriverCapability_t)(Capability), cgoAllocsUnknown
cCapResult, _ := (*C.uint)(unsafe.Pointer(CapResult)), cgoAllocsUnknown
__ret := C.nvmlGetVgpuDriverCapabilities(cCapability, cCapResult)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetVgpuCapabilities function as declared in nvml/nvml.h
func nvmlDeviceGetVgpuCapabilities(Device Device, Capability DeviceVgpuCapability, CapResult *uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cCapability, _ := (C.nvmlDeviceVgpuCapability_t)(Capability), cgoAllocsUnknown
cCapResult, _ := (*C.uint)(unsafe.Pointer(CapResult)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetVgpuCapabilities(cDevice, cCapability, cCapResult)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetSupportedVgpus function as declared in nvml/nvml.h
func nvmlDeviceGetSupportedVgpus(Device Device, VgpuCount *uint32, VgpuTypeIds *VgpuTypeId) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
@ -1971,6 +2105,16 @@ func nvmlVgpuInstanceGetGpuPciId(VgpuInstance VgpuInstance, VgpuPciId *byte, Len
return __v
}
// nvmlVgpuTypeGetCapabilities function as declared in nvml/nvml.h
func nvmlVgpuTypeGetCapabilities(VgpuTypeId VgpuTypeId, Capability VgpuCapability, CapResult *uint32) Return {
cVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(VgpuTypeId), cgoAllocsUnknown
cCapability, _ := (C.nvmlVgpuCapability_t)(Capability), cgoAllocsUnknown
cCapResult, _ := (*C.uint)(unsafe.Pointer(CapResult)), cgoAllocsUnknown
__ret := C.nvmlVgpuTypeGetCapabilities(cVgpuTypeId, cCapability, cCapResult)
__v := (Return)(__ret)
return __v
}
// nvmlVgpuInstanceGetMetadata function as declared in nvml/nvml.h
func nvmlVgpuInstanceGetMetadata(VgpuInstance VgpuInstance, nvmlVgpuMetadata *nvmlVgpuMetadata, BufferSize *uint32) Return {
cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown
@ -2011,6 +2155,42 @@ func nvmlDeviceGetPgpuMetadataString(Device Device, PgpuMetadata *byte, BufferSi
return __v
}
// nvmlDeviceGetVgpuSchedulerLog function as declared in nvml/nvml.h
func nvmlDeviceGetVgpuSchedulerLog(Device Device, PSchedulerLog *VgpuSchedulerLog) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cPSchedulerLog, _ := (*C.nvmlVgpuSchedulerLog_t)(unsafe.Pointer(PSchedulerLog)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetVgpuSchedulerLog(cDevice, cPSchedulerLog)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetVgpuSchedulerState function as declared in nvml/nvml.h
func nvmlDeviceGetVgpuSchedulerState(Device Device, PSchedulerState *VgpuSchedulerGetState) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cPSchedulerState, _ := (*C.nvmlVgpuSchedulerGetState_t)(unsafe.Pointer(PSchedulerState)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetVgpuSchedulerState(cDevice, cPSchedulerState)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceSetVgpuSchedulerState function as declared in nvml/nvml.h
func nvmlDeviceSetVgpuSchedulerState(Device Device, PSchedulerState *VgpuSchedulerSetState) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cPSchedulerState, _ := (*C.nvmlVgpuSchedulerSetState_t)(unsafe.Pointer(PSchedulerState)), cgoAllocsUnknown
__ret := C.nvmlDeviceSetVgpuSchedulerState(cDevice, cPSchedulerState)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetVgpuSchedulerCapabilities function as declared in nvml/nvml.h
func nvmlDeviceGetVgpuSchedulerCapabilities(Device Device, PCapabilities *VgpuSchedulerCapabilities) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cPCapabilities, _ := (*C.nvmlVgpuSchedulerCapabilities_t)(unsafe.Pointer(PCapabilities)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetVgpuSchedulerCapabilities(cDevice, cPCapabilities)
__v := (Return)(__ret)
return __v
}
// nvmlGetVgpuVersion function as declared in nvml/nvml.h
func nvmlGetVgpuVersion(Supported *VgpuVersion, Current *VgpuVersion) Return {
cSupported, _ := (*C.nvmlVgpuVersion_t)(unsafe.Pointer(Supported)), cgoAllocsUnknown
@ -2266,6 +2446,17 @@ func nvmlGpuInstanceGetComputeInstanceRemainingCapacity(GpuInstance GpuInstance,
return __v
}
// nvmlGpuInstanceGetComputeInstancePossiblePlacements function as declared in nvml/nvml.h
func nvmlGpuInstanceGetComputeInstancePossiblePlacements(GpuInstance GpuInstance, ProfileId uint32, Placements *ComputeInstancePlacement, Count *uint32) Return {
cGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&GpuInstance)), cgoAllocsUnknown
cProfileId, _ := (C.uint)(ProfileId), cgoAllocsUnknown
cPlacements, _ := (*C.nvmlComputeInstancePlacement_t)(unsafe.Pointer(Placements)), cgoAllocsUnknown
cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown
__ret := C.nvmlGpuInstanceGetComputeInstancePossiblePlacements(cGpuInstance, cProfileId, cPlacements, cCount)
__v := (Return)(__ret)
return __v
}
// nvmlGpuInstanceCreateComputeInstance function as declared in nvml/nvml.h
func nvmlGpuInstanceCreateComputeInstance(GpuInstance GpuInstance, ProfileId uint32, ComputeInstance *ComputeInstance) Return {
cGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&GpuInstance)), cgoAllocsUnknown
@ -2276,6 +2467,17 @@ func nvmlGpuInstanceCreateComputeInstance(GpuInstance GpuInstance, ProfileId uin
return __v
}
// nvmlGpuInstanceCreateComputeInstanceWithPlacement function as declared in nvml/nvml.h
func nvmlGpuInstanceCreateComputeInstanceWithPlacement(GpuInstance GpuInstance, ProfileId uint32, Placement *ComputeInstancePlacement, ComputeInstance *ComputeInstance) Return {
cGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&GpuInstance)), cgoAllocsUnknown
cProfileId, _ := (C.uint)(ProfileId), cgoAllocsUnknown
cPlacement, _ := (*C.nvmlComputeInstancePlacement_t)(unsafe.Pointer(Placement)), cgoAllocsUnknown
cComputeInstance, _ := (*C.nvmlComputeInstance_t)(unsafe.Pointer(ComputeInstance)), cgoAllocsUnknown
__ret := C.nvmlGpuInstanceCreateComputeInstanceWithPlacement(cGpuInstance, cProfileId, cPlacement, cComputeInstance)
__v := (Return)(__ret)
return __v
}
// nvmlComputeInstanceDestroy function as declared in nvml/nvml.h
func nvmlComputeInstanceDestroy(ComputeInstance ComputeInstance) Return {
cComputeInstance, _ := *(*C.nvmlComputeInstance_t)(unsafe.Pointer(&ComputeInstance)), cgoAllocsUnknown
@ -2378,6 +2580,191 @@ func nvmlDeviceGetBusType(Device Device, _type *BusType) Return {
return __v
}
// nvmlDeviceGetDynamicPstatesInfo function as declared in nvml/nvml.h
func nvmlDeviceGetDynamicPstatesInfo(Device Device, PDynamicPstatesInfo *GpuDynamicPstatesInfo) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cPDynamicPstatesInfo, _ := (*C.nvmlGpuDynamicPstatesInfo_t)(unsafe.Pointer(PDynamicPstatesInfo)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetDynamicPstatesInfo(cDevice, cPDynamicPstatesInfo)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceSetFanSpeed_v2 function as declared in nvml/nvml.h
func nvmlDeviceSetFanSpeed_v2(Device Device, Fan uint32, Speed uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cFan, _ := (C.uint)(Fan), cgoAllocsUnknown
cSpeed, _ := (C.uint)(Speed), cgoAllocsUnknown
__ret := C.nvmlDeviceSetFanSpeed_v2(cDevice, cFan, cSpeed)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetGpcClkVfOffset function as declared in nvml/nvml.h
func nvmlDeviceGetGpcClkVfOffset(Device Device, Offset *int32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cOffset, _ := (*C.int)(unsafe.Pointer(Offset)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetGpcClkVfOffset(cDevice, cOffset)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceSetGpcClkVfOffset function as declared in nvml/nvml.h
func nvmlDeviceSetGpcClkVfOffset(Device Device, Offset int32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cOffset, _ := (C.int)(Offset), cgoAllocsUnknown
__ret := C.nvmlDeviceSetGpcClkVfOffset(cDevice, cOffset)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetMemClkVfOffset function as declared in nvml/nvml.h
func nvmlDeviceGetMemClkVfOffset(Device Device, Offset *int32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cOffset, _ := (*C.int)(unsafe.Pointer(Offset)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetMemClkVfOffset(cDevice, cOffset)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceSetMemClkVfOffset function as declared in nvml/nvml.h
func nvmlDeviceSetMemClkVfOffset(Device Device, Offset int32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cOffset, _ := (C.int)(Offset), cgoAllocsUnknown
__ret := C.nvmlDeviceSetMemClkVfOffset(cDevice, cOffset)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetMinMaxClockOfPState function as declared in nvml/nvml.h
func nvmlDeviceGetMinMaxClockOfPState(Device Device, _type ClockType, Pstate Pstates, MinClockMHz *uint32, MaxClockMHz *uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
c_type, _ := (C.nvmlClockType_t)(_type), cgoAllocsUnknown
cPstate, _ := (C.nvmlPstates_t)(Pstate), cgoAllocsUnknown
cMinClockMHz, _ := (*C.uint)(unsafe.Pointer(MinClockMHz)), cgoAllocsUnknown
cMaxClockMHz, _ := (*C.uint)(unsafe.Pointer(MaxClockMHz)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetMinMaxClockOfPState(cDevice, c_type, cPstate, cMinClockMHz, cMaxClockMHz)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetSupportedPerformanceStates function as declared in nvml/nvml.h
func nvmlDeviceGetSupportedPerformanceStates(Device Device, Pstates *Pstates, Size uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cPstates, _ := (*C.nvmlPstates_t)(unsafe.Pointer(Pstates)), cgoAllocsUnknown
cSize, _ := (C.uint)(Size), cgoAllocsUnknown
__ret := C.nvmlDeviceGetSupportedPerformanceStates(cDevice, cPstates, cSize)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetGpcClkMinMaxVfOffset function as declared in nvml/nvml.h
func nvmlDeviceGetGpcClkMinMaxVfOffset(Device Device, MinOffset *int32, MaxOffset *int32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cMinOffset, _ := (*C.int)(unsafe.Pointer(MinOffset)), cgoAllocsUnknown
cMaxOffset, _ := (*C.int)(unsafe.Pointer(MaxOffset)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetGpcClkMinMaxVfOffset(cDevice, cMinOffset, cMaxOffset)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetMemClkMinMaxVfOffset function as declared in nvml/nvml.h
func nvmlDeviceGetMemClkMinMaxVfOffset(Device Device, MinOffset *int32, MaxOffset *int32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cMinOffset, _ := (*C.int)(unsafe.Pointer(MinOffset)), cgoAllocsUnknown
cMaxOffset, _ := (*C.int)(unsafe.Pointer(MaxOffset)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetMemClkMinMaxVfOffset(cDevice, cMinOffset, cMaxOffset)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceGetGpuFabricInfo function as declared in nvml/nvml.h
func nvmlDeviceGetGpuFabricInfo(Device Device, GpuFabricInfo *GpuFabricInfo) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cGpuFabricInfo, _ := (*C.nvmlGpuFabricInfo_t)(unsafe.Pointer(GpuFabricInfo)), cgoAllocsUnknown
__ret := C.nvmlDeviceGetGpuFabricInfo(cDevice, cGpuFabricInfo)
__v := (Return)(__ret)
return __v
}
// nvmlGpmMetricsGet function as declared in nvml/nvml.h
func nvmlGpmMetricsGet(MetricsGet *GpmMetricsGetType) Return {
cMetricsGet, _ := (*C.nvmlGpmMetricsGet_t)(unsafe.Pointer(MetricsGet)), cgoAllocsUnknown
__ret := C.nvmlGpmMetricsGet(cMetricsGet)
__v := (Return)(__ret)
return __v
}
// nvmlGpmSampleFree function as declared in nvml/nvml.h
func nvmlGpmSampleFree(GpmSample GpmSample) Return {
cGpmSample, _ := *(*C.nvmlGpmSample_t)(unsafe.Pointer(&GpmSample)), cgoAllocsUnknown
__ret := C.nvmlGpmSampleFree(cGpmSample)
__v := (Return)(__ret)
return __v
}
// nvmlGpmSampleAlloc function as declared in nvml/nvml.h
func nvmlGpmSampleAlloc(GpmSample *GpmSample) Return {
cGpmSample, _ := (*C.nvmlGpmSample_t)(unsafe.Pointer(GpmSample)), cgoAllocsUnknown
__ret := C.nvmlGpmSampleAlloc(cGpmSample)
__v := (Return)(__ret)
return __v
}
// nvmlGpmSampleGet function as declared in nvml/nvml.h
func nvmlGpmSampleGet(Device Device, GpmSample GpmSample) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cGpmSample, _ := *(*C.nvmlGpmSample_t)(unsafe.Pointer(&GpmSample)), cgoAllocsUnknown
__ret := C.nvmlGpmSampleGet(cDevice, cGpmSample)
__v := (Return)(__ret)
return __v
}
// nvmlGpmMigSampleGet function as declared in nvml/nvml.h
func nvmlGpmMigSampleGet(Device Device, GpuInstanceId uint32, GpmSample GpmSample) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cGpuInstanceId, _ := (C.uint)(GpuInstanceId), cgoAllocsUnknown
cGpmSample, _ := *(*C.nvmlGpmSample_t)(unsafe.Pointer(&GpmSample)), cgoAllocsUnknown
__ret := C.nvmlGpmMigSampleGet(cDevice, cGpuInstanceId, cGpmSample)
__v := (Return)(__ret)
return __v
}
// nvmlGpmQueryDeviceSupport function as declared in nvml/nvml.h
func nvmlGpmQueryDeviceSupport(Device Device, GpmSupport *GpmSupport) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cGpmSupport, _ := (*C.nvmlGpmSupport_t)(unsafe.Pointer(GpmSupport)), cgoAllocsUnknown
__ret := C.nvmlGpmQueryDeviceSupport(cDevice, cGpmSupport)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceCcuGetStreamState function as declared in nvml/nvml.h
func nvmlDeviceCcuGetStreamState(Device Device, State *uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cState, _ := (*C.uint)(unsafe.Pointer(State)), cgoAllocsUnknown
__ret := C.nvmlDeviceCcuGetStreamState(cDevice, cState)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceCcuSetStreamState function as declared in nvml/nvml.h
func nvmlDeviceCcuSetStreamState(Device Device, State uint32) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cState, _ := (C.uint)(State), cgoAllocsUnknown
__ret := C.nvmlDeviceCcuSetStreamState(cDevice, cState)
__v := (Return)(__ret)
return __v
}
// nvmlDeviceSetNvLinkDeviceLowPowerThreshold function as declared in nvml/nvml.h
func nvmlDeviceSetNvLinkDeviceLowPowerThreshold(Device Device, Info *NvLinkPowerThres) Return {
cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown
cInfo, _ := (*C.nvmlNvLinkPowerThres_t)(unsafe.Pointer(Info)), cgoAllocsUnknown
__ret := C.nvmlDeviceSetNvLinkDeviceLowPowerThreshold(cDevice, cInfo)
__v := (Return)(__ret)
return __v
}
// nvmlInit_v1 function as declared in nvml/nvml.h
func nvmlInit_v1() Return {
__ret := C.nvmlInit()

File diff suppressed because it is too large Load Diff

View File

@ -119,6 +119,19 @@ type ViolationTime struct {
ViolationTime uint64
}
type GpuThermalSettingsSensor struct {
Controller int32
DefaultMinTemp int32
DefaultMaxTemp int32
CurrentTemp int32
Target int32
}
type GpuThermalSettings struct {
Count uint32
Sensor [3]GpuThermalSettingsSensor
}
type ClkMonFaultInfo struct {
ClkApiDomain uint32
ClkDomainFaultMask uint32
@ -154,6 +167,73 @@ type VgpuProcessUtilizationSample struct {
DecUtil uint32
}
type VgpuSchedulerParamsVgpuSchedDataWithARR struct {
AvgFactor uint32
Timeslice uint32
}
type VgpuSchedulerParamsVgpuSchedData struct {
Timeslice uint32
}
const sizeofVgpuSchedulerParams = unsafe.Sizeof([8]byte{})
type VgpuSchedulerParams [sizeofVgpuSchedulerParams]byte
type VgpuSchedulerLogEntry struct {
Timestamp uint64
TimeRunTotal uint64
TimeRun uint64
SwRunlistId uint32
TargetTimeSlice uint64
CumulativePreemptionTime uint64
}
type VgpuSchedulerLog struct {
EngineId uint32
SchedulerPolicy uint32
IsEnabledARR uint32
SchedulerParams [8]byte
EntriesCount uint32
LogEntries [200]VgpuSchedulerLogEntry
}
type VgpuSchedulerGetState struct {
SchedulerPolicy uint32
IsEnabledARR uint32
SchedulerParams [8]byte
}
type VgpuSchedulerSetParamsVgpuSchedDataWithARR struct {
AvgFactor uint32
Frequency uint32
}
type VgpuSchedulerSetParamsVgpuSchedData struct {
Timeslice uint32
}
const sizeofVgpuSchedulerSetParams = unsafe.Sizeof([8]byte{})
type VgpuSchedulerSetParams [sizeofVgpuSchedulerSetParams]byte
type VgpuSchedulerSetState struct {
SchedulerPolicy uint32
EnableARRMode uint32
SchedulerParams [8]byte
}
type VgpuSchedulerCapabilities struct {
SupportedSchedulers [3]uint32
MaxTimeslice uint32
MinTimeslice uint32
IsArrModeSupported uint32
MaxFrequencyForARR uint32
MinFrequencyForARR uint32
MaxAvgFactorForARR uint32
MinAvgFactorForARR uint32
}
type VgpuLicenseExpiry struct {
Year uint32
Month uint16
@ -210,8 +290,22 @@ type DeviceArchitecture uint32
type BusType uint32
type FanControlPolicy uint32
type PowerSource uint32
type GpuDynamicPstatesInfoUtilization struct {
BIsPresent uint32
Percentage uint32
IncThreshold uint32
DecThreshold uint32
}
type GpuDynamicPstatesInfo struct {
Flags uint32
Utilization [8]GpuDynamicPstatesInfoUtilization
}
type FieldValue struct {
FieldId uint32
ScopeId uint32
@ -314,6 +408,16 @@ type FBCSessionInfo struct {
AverageLatency uint32
}
type GpuFabricState byte
type GpuFabricInfo struct {
ClusterUuid [16]int8
Status uint32
PartitionId uint32
State uint8
Pad_cgo_0 [3]byte
}
type AffinityScope uint32
type VgpuVersion struct {
@ -443,3 +547,37 @@ type ComputeInstanceInfo struct {
type ComputeInstance struct {
Handle *_Ctype_struct_nvmlComputeInstance_st
}
type GpmSample struct {
Handle *_Ctype_struct_nvmlGpmSample_st
}
type GpmMetricMetricInfo struct {
ShortName *int8
LongName *int8
Unit *int8
}
type GpmMetric struct {
MetricId uint32
NvmlReturn uint32
Value float64
MetricInfo GpmMetricMetricInfo
}
type GpmMetricsGetType struct {
Version uint32
NumMetrics uint32
Sample1 GpmSample
Sample2 GpmSample
Metrics [98]GpmMetric
}
type GpmSupport struct {
Version uint32
IsSupportedDevice uint32
}
type NvLinkPowerThres struct {
LowPwrThreshold uint32
}

View File

@ -460,3 +460,21 @@ func VgpuInstanceGetMdevUUID(VgpuInstance VgpuInstance) (string, Return) {
func (VgpuInstance VgpuInstance) GetMdevUUID() (string, Return) {
return VgpuInstanceGetMdevUUID(VgpuInstance)
}
// nvml.VgpuTypeGetCapabilities()
func VgpuTypeGetCapabilities(VgpuTypeId VgpuTypeId, Capability VgpuCapability) (bool, Return) {
var CapResult uint32
ret := nvmlVgpuTypeGetCapabilities(VgpuTypeId, Capability, &CapResult)
return (CapResult != 0), ret
}
func (VgpuTypeId VgpuTypeId) GetCapabilities(Capability VgpuCapability) (bool, Return) {
return VgpuTypeGetCapabilities(VgpuTypeId, Capability)
}
// nvml.GetVgpuDriverCapabilities()
func GetVgpuDriverCapabilities(Capability VgpuDriverCapability) (bool, Return) {
var CapResult uint32
ret := nvmlGetVgpuDriverCapabilities(Capability, &CapResult)
return (CapResult != 0), ret
}

View File

@ -27,6 +27,7 @@ import (
// Interface provides the API to the info package
type Interface interface {
HasDXCore() (bool, string)
HasNvml() (bool, string)
IsTegraSystem() (bool, string)
}
@ -37,17 +38,26 @@ type infolib struct {
var _ Interface = &infolib{}
// HasDXCore returns true if DXCore is detected on the system.
func (i *infolib) HasDXCore() (bool, string) {
const (
libraryName = "libdxcore.so"
)
if err := assertHasLibrary(libraryName); err != nil {
return false, fmt.Sprintf("could not load DXCore library: %v", err)
}
return true, "found DXCore library"
}
// HasNvml returns true if NVML is detected on the system
func (i *infolib) HasNvml() (bool, string) {
const (
nvmlLibraryName = "libnvidia-ml.so.1"
nvmlLibraryLoadFlags = dl.RTLD_LAZY
libraryName = "libnvidia-ml.so.1"
)
lib := dl.New(nvmlLibraryName, nvmlLibraryLoadFlags)
if err := lib.Open(); err != nil {
return false, fmt.Sprintf("could not load NVML: %v", err)
if err := assertHasLibrary(libraryName); err != nil {
return false, fmt.Sprintf("could not load NVML library: %v", err)
}
defer lib.Close()
return true, "found NVML library"
}
@ -76,3 +86,17 @@ func (i *infolib) IsTegraSystem() (bool, string) {
return false, fmt.Sprintf("%v has no 'tegra' prefix", tegraFamilyFile)
}
// assertHasLibrary returns an error if the specified library cannot be loaded
func assertHasLibrary(libraryName string) error {
const (
libraryLoadFlags = dl.RTLD_LAZY
)
lib := dl.New(libraryName, libraryLoadFlags)
if err := lib.Open(); err != nil {
return err
}
defer lib.Close()
return nil
}

4
vendor/modules.txt vendored
View File

@ -2,7 +2,7 @@
## explicit; go 1.16
github.com/BurntSushi/toml
github.com/BurntSushi/toml/internal
# github.com/NVIDIA/go-nvml v0.11.6-0.0.20220823120812-7e2082095e82
# github.com/NVIDIA/go-nvml v0.12.0-0
## explicit; go 1.15
github.com/NVIDIA/go-nvml/pkg/dl
github.com/NVIDIA/go-nvml/pkg/nvml
@ -62,7 +62,7 @@ github.com/syndtr/gocapability/capability
github.com/urfave/cli/v2
# github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb
## explicit
# gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20230119114711-6fe07bb33342
# gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20230209143738-95328d8c4438
## explicit; go 1.16
gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvlib/device
gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvlib/info