mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Bump go-nvlib to v0.2.0 and go-nvml v0.12.0-3
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
9
vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go
generated
vendored
9
vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go
generated
vendored
@@ -152,3 +152,12 @@ const (
|
||||
FEATURE_DISABLED = EnableState(nvml.FEATURE_DISABLED)
|
||||
FEATURE_ENABLED = EnableState(nvml.FEATURE_ENABLED)
|
||||
)
|
||||
|
||||
// Compute mode constants
|
||||
const (
|
||||
COMPUTEMODE_DEFAULT = ComputeMode(nvml.COMPUTEMODE_DEFAULT)
|
||||
COMPUTEMODE_EXCLUSIVE_THREAD = ComputeMode(nvml.COMPUTEMODE_EXCLUSIVE_THREAD)
|
||||
COMPUTEMODE_PROHIBITED = ComputeMode(nvml.COMPUTEMODE_PROHIBITED)
|
||||
COMPUTEMODE_EXCLUSIVE_PROCESS = ComputeMode(nvml.COMPUTEMODE_EXCLUSIVE_PROCESS)
|
||||
COMPUTEMODE_COUNT = ComputeMode(nvml.COMPUTEMODE_COUNT)
|
||||
)
|
||||
|
||||
17
vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go
generated
vendored
17
vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go
generated
vendored
@@ -22,6 +22,11 @@ type nvmlDevice nvml.Device
|
||||
|
||||
var _ Device = (*nvmlDevice)(nil)
|
||||
|
||||
// nvmlDeviceHandle returns a pointer to the underlying device.
|
||||
func (d nvmlDevice) nvmlDeviceHandle() *nvml.Device {
|
||||
return (*nvml.Device)(&d)
|
||||
}
|
||||
|
||||
// GetIndex returns the index of a Device
|
||||
func (d nvmlDevice) GetIndex() (int, Return) {
|
||||
i, r := nvml.Device(d).GetIndex()
|
||||
@@ -181,12 +186,12 @@ func (d nvmlDevice) GetSupportedEventTypes() (uint64, Return) {
|
||||
|
||||
// GetTopologyCommonAncestor retrieves the common ancestor for two devices.
|
||||
func (d nvmlDevice) GetTopologyCommonAncestor(o Device) (GpuTopologyLevel, Return) {
|
||||
other, ok := o.(nvmlDevice)
|
||||
if !ok {
|
||||
other := o.nvmlDeviceHandle()
|
||||
if other == nil {
|
||||
return 0, ERROR_INVALID_ARGUMENT
|
||||
}
|
||||
|
||||
l, r := nvml.Device(d).GetTopologyCommonAncestor(nvml.Device(other))
|
||||
l, r := nvml.Device(d).GetTopologyCommonAncestor(*other)
|
||||
return GpuTopologyLevel(l), Return(r)
|
||||
}
|
||||
|
||||
@@ -202,3 +207,9 @@ func (d nvmlDevice) GetNvLinkRemotePciInfo(link int) (PciInfo, Return) {
|
||||
p, r := nvml.Device(d).GetNvLinkRemotePciInfo(link)
|
||||
return PciInfo(p), Return(r)
|
||||
}
|
||||
|
||||
// SetComputeMode sets the compute mode for the device.
|
||||
func (d nvmlDevice) SetComputeMode(mode ComputeMode) Return {
|
||||
r := nvml.Device(d).SetComputeMode(nvml.ComputeMode(mode))
|
||||
return Return(r)
|
||||
}
|
||||
|
||||
82
vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device_mock.go
generated
vendored
82
vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device_mock.go
generated
vendored
@@ -4,6 +4,7 @@
|
||||
package nvml
|
||||
|
||||
import (
|
||||
"github.com/NVIDIA/go-nvml/pkg/nvml"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -98,9 +99,15 @@ var _ Device = &DeviceMock{}
|
||||
// RegisterEventsFunc: func(v uint64, eventSet EventSet) Return {
|
||||
// panic("mock out the RegisterEvents method")
|
||||
// },
|
||||
// SetComputeModeFunc: func(computeMode ComputeMode) Return {
|
||||
// panic("mock out the SetComputeMode method")
|
||||
// },
|
||||
// SetMigModeFunc: func(Mode int) (Return, Return) {
|
||||
// panic("mock out the SetMigMode method")
|
||||
// },
|
||||
// nvmlDeviceHandleFunc: func() *nvml.Device {
|
||||
// panic("mock out the nvmlDeviceHandle method")
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// // use mockedDevice in code that requires Device
|
||||
@@ -189,9 +196,15 @@ type DeviceMock struct {
|
||||
// RegisterEventsFunc mocks the RegisterEvents method.
|
||||
RegisterEventsFunc func(v uint64, eventSet EventSet) Return
|
||||
|
||||
// SetComputeModeFunc mocks the SetComputeMode method.
|
||||
SetComputeModeFunc func(computeMode ComputeMode) Return
|
||||
|
||||
// SetMigModeFunc mocks the SetMigMode method.
|
||||
SetMigModeFunc func(Mode int) (Return, Return)
|
||||
|
||||
// nvmlDeviceHandleFunc mocks the nvmlDeviceHandle method.
|
||||
nvmlDeviceHandleFunc func() *nvml.Device
|
||||
|
||||
// calls tracks calls to the methods.
|
||||
calls struct {
|
||||
// CreateGpuInstanceWithPlacement holds details about calls to the CreateGpuInstanceWithPlacement method.
|
||||
@@ -299,11 +312,19 @@ type DeviceMock struct {
|
||||
// EventSet is the eventSet argument value.
|
||||
EventSet EventSet
|
||||
}
|
||||
// SetComputeMode holds details about calls to the SetComputeMode method.
|
||||
SetComputeMode []struct {
|
||||
// ComputeMode is the computeMode argument value.
|
||||
ComputeMode ComputeMode
|
||||
}
|
||||
// SetMigMode holds details about calls to the SetMigMode method.
|
||||
SetMigMode []struct {
|
||||
// Mode is the Mode argument value.
|
||||
Mode int
|
||||
}
|
||||
// nvmlDeviceHandle holds details about calls to the nvmlDeviceHandle method.
|
||||
nvmlDeviceHandle []struct {
|
||||
}
|
||||
}
|
||||
lockCreateGpuInstanceWithPlacement sync.RWMutex
|
||||
lockGetArchitecture sync.RWMutex
|
||||
@@ -332,7 +353,9 @@ type DeviceMock struct {
|
||||
lockGetUUID sync.RWMutex
|
||||
lockIsMigDeviceHandle sync.RWMutex
|
||||
lockRegisterEvents sync.RWMutex
|
||||
lockSetComputeMode sync.RWMutex
|
||||
lockSetMigMode sync.RWMutex
|
||||
locknvmlDeviceHandle sync.RWMutex
|
||||
}
|
||||
|
||||
// CreateGpuInstanceWithPlacement calls CreateGpuInstanceWithPlacementFunc.
|
||||
@@ -1122,6 +1145,38 @@ func (mock *DeviceMock) RegisterEventsCalls() []struct {
|
||||
return calls
|
||||
}
|
||||
|
||||
// SetComputeMode calls SetComputeModeFunc.
|
||||
func (mock *DeviceMock) SetComputeMode(computeMode ComputeMode) Return {
|
||||
if mock.SetComputeModeFunc == nil {
|
||||
panic("DeviceMock.SetComputeModeFunc: method is nil but Device.SetComputeMode was just called")
|
||||
}
|
||||
callInfo := struct {
|
||||
ComputeMode ComputeMode
|
||||
}{
|
||||
ComputeMode: computeMode,
|
||||
}
|
||||
mock.lockSetComputeMode.Lock()
|
||||
mock.calls.SetComputeMode = append(mock.calls.SetComputeMode, callInfo)
|
||||
mock.lockSetComputeMode.Unlock()
|
||||
return mock.SetComputeModeFunc(computeMode)
|
||||
}
|
||||
|
||||
// SetComputeModeCalls gets all the calls that were made to SetComputeMode.
|
||||
// Check the length with:
|
||||
//
|
||||
// len(mockedDevice.SetComputeModeCalls())
|
||||
func (mock *DeviceMock) SetComputeModeCalls() []struct {
|
||||
ComputeMode ComputeMode
|
||||
} {
|
||||
var calls []struct {
|
||||
ComputeMode ComputeMode
|
||||
}
|
||||
mock.lockSetComputeMode.RLock()
|
||||
calls = mock.calls.SetComputeMode
|
||||
mock.lockSetComputeMode.RUnlock()
|
||||
return calls
|
||||
}
|
||||
|
||||
// SetMigMode calls SetMigModeFunc.
|
||||
func (mock *DeviceMock) SetMigMode(Mode int) (Return, Return) {
|
||||
if mock.SetMigModeFunc == nil {
|
||||
@@ -1153,3 +1208,30 @@ func (mock *DeviceMock) SetMigModeCalls() []struct {
|
||||
mock.lockSetMigMode.RUnlock()
|
||||
return calls
|
||||
}
|
||||
|
||||
// nvmlDeviceHandle calls nvmlDeviceHandleFunc.
|
||||
func (mock *DeviceMock) nvmlDeviceHandle() *nvml.Device {
|
||||
if mock.nvmlDeviceHandleFunc == nil {
|
||||
panic("DeviceMock.nvmlDeviceHandleFunc: method is nil but Device.nvmlDeviceHandle was just called")
|
||||
}
|
||||
callInfo := struct {
|
||||
}{}
|
||||
mock.locknvmlDeviceHandle.Lock()
|
||||
mock.calls.nvmlDeviceHandle = append(mock.calls.nvmlDeviceHandle, callInfo)
|
||||
mock.locknvmlDeviceHandle.Unlock()
|
||||
return mock.nvmlDeviceHandleFunc()
|
||||
}
|
||||
|
||||
// nvmlDeviceHandleCalls gets all the calls that were made to nvmlDeviceHandle.
|
||||
// Check the length with:
|
||||
//
|
||||
// len(mockedDevice.nvmlDeviceHandleCalls())
|
||||
func (mock *DeviceMock) nvmlDeviceHandleCalls() []struct {
|
||||
} {
|
||||
var calls []struct {
|
||||
}
|
||||
mock.locknvmlDeviceHandle.RLock()
|
||||
calls = mock.calls.nvmlDeviceHandle
|
||||
mock.locknvmlDeviceHandle.RUnlock()
|
||||
return calls
|
||||
}
|
||||
|
||||
6
vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go
generated
vendored
6
vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go
generated
vendored
@@ -67,7 +67,10 @@ type Device interface {
|
||||
GetUUID() (string, Return)
|
||||
IsMigDeviceHandle() (bool, Return)
|
||||
RegisterEvents(uint64, EventSet) Return
|
||||
SetComputeMode(ComputeMode) Return
|
||||
SetMigMode(Mode int) (Return, Return)
|
||||
// nvmlDeviceHandle returns a pointer to the underlying NVML device.
|
||||
nvmlDeviceHandle() *nvml.Device
|
||||
}
|
||||
|
||||
// GpuInstance defines the functions implemented by a GpuInstance
|
||||
@@ -154,3 +157,6 @@ type GpuTopologyLevel nvml.GpuTopologyLevel
|
||||
|
||||
// EnableState represents a generic enable/disable enum
|
||||
type EnableState nvml.EnableState
|
||||
|
||||
// ComputeMode represents the compute mode for a device
|
||||
type ComputeMode nvml.ComputeMode
|
||||
|
||||
Reference in New Issue
Block a user