Documentation
¶
Index ¶
- type Device
- type DeviceMock
- func (mock *DeviceMock) GetAttributes() (map[string]interface{}, error)
- func (mock *DeviceMock) GetAttributesCalls() []struct{}
- func (mock *DeviceMock) GetCudaComputeCapability() (int, int, error)
- func (mock *DeviceMock) GetCudaComputeCapabilityCalls() []struct{}
- func (mock *DeviceMock) GetDeviceHandleFromMigDeviceHandle() (Device, error)
- func (mock *DeviceMock) GetDeviceHandleFromMigDeviceHandleCalls() []struct{}
- func (mock *DeviceMock) GetFabricIDs() (string, string, error)
- func (mock *DeviceMock) GetFabricIDsCalls() []struct{}
- func (mock *DeviceMock) GetMigDevices() ([]Device, error)
- func (mock *DeviceMock) GetMigDevicesCalls() []struct{}
- func (mock *DeviceMock) GetName() (string, error)
- func (mock *DeviceMock) GetNameCalls() []struct{}
- func (mock *DeviceMock) GetPCIClass() (uint32, error)
- func (mock *DeviceMock) GetPCIClassCalls() []struct{}
- func (mock *DeviceMock) GetTotalMemoryMiB() (uint64, error)
- func (mock *DeviceMock) GetTotalMemoryMiBCalls() []struct{}
- func (mock *DeviceMock) IsFabricAttached() (bool, error)
- func (mock *DeviceMock) IsFabricAttachedCalls() []struct{}
- func (mock *DeviceMock) IsMigCapable() (bool, error)
- func (mock *DeviceMock) IsMigCapableCalls() []struct{}
- func (mock *DeviceMock) IsMigEnabled() (bool, error)
- func (mock *DeviceMock) IsMigEnabledCalls() []struct{}
- type Manager
- func NewCudaManager() Manager
- func NewFallbackToNullOnInitError(m Manager) Manager
- func NewManager(infolib info.Interface, nvmllib nvml.Interface, devicelib device.Interface, ...) (Manager, error)
- func NewNVMLManager(nvmllib nvml.Interface, devicelib device.Interface) Manager
- func NewNullManager() Manager
- func NewVfioManager() Manager
- func WithConfig(manager Manager, config *spec.Config) Manager
- type ManagerMock
- func (mock *ManagerMock) GetCudaDriverVersion() (int, int, error)
- func (mock *ManagerMock) GetCudaDriverVersionCalls() []struct{}
- func (mock *ManagerMock) GetDevices() ([]Device, error)
- func (mock *ManagerMock) GetDevicesCalls() []struct{}
- func (mock *ManagerMock) GetDriverVersion() (string, error)
- func (mock *ManagerMock) GetDriverVersionCalls() []struct{}
- func (mock *ManagerMock) Init() error
- func (mock *ManagerMock) InitCalls() []struct{}
- func (mock *ManagerMock) Shutdown() error
- func (mock *ManagerMock) ShutdownCalls() []struct{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device interface {
IsFabricAttached() (bool, error)
IsMigEnabled() (bool, error)
IsMigCapable() (bool, error)
GetMigDevices() ([]Device, error)
GetAttributes() (map[string]interface{}, error)
GetName() (string, error)
GetTotalMemoryMiB() (uint64, error)
GetDeviceHandleFromMigDeviceHandle() (Device, error)
GetCudaComputeCapability() (int, int, error)
GetPCIClass() (uint32, error)
GetFabricIDs() (string, string, error)
}
Device defines an interface for a device with which labels are associated
func NewCudaDevice ¶
NewCudaDevice constructs a new CUDA device
type DeviceMock ¶
type DeviceMock struct {
// GetAttributesFunc mocks the GetAttributes method.
GetAttributesFunc func() (map[string]interface{}, error)
// GetCudaComputeCapabilityFunc mocks the GetCudaComputeCapability method.
GetCudaComputeCapabilityFunc func() (int, int, error)
// GetDeviceHandleFromMigDeviceHandleFunc mocks the GetDeviceHandleFromMigDeviceHandle method.
GetDeviceHandleFromMigDeviceHandleFunc func() (Device, error)
// GetFabricIDsFunc mocks the GetFabricIDs method.
GetFabricIDsFunc func() (string, string, error)
// GetMigDevicesFunc mocks the GetMigDevices method.
GetMigDevicesFunc func() ([]Device, error)
// GetNameFunc mocks the GetName method.
GetNameFunc func() (string, error)
// GetPCIClassFunc mocks the GetPCIClass method.
GetPCIClassFunc func() (uint32, error)
// GetTotalMemoryMiBFunc mocks the GetTotalMemoryMiB method.
GetTotalMemoryMiBFunc func() (uint64, error)
// IsFabricAttachedFunc mocks the IsFabricAttached method.
IsFabricAttachedFunc func() (bool, error)
// IsMigCapableFunc mocks the IsMigCapable method.
IsMigCapableFunc func() (bool, error)
// IsMigEnabledFunc mocks the IsMigEnabled method.
IsMigEnabledFunc func() (bool, error)
// contains filtered or unexported fields
}
DeviceMock is a mock implementation of Device.
func TestSomethingThatUsesDevice(t *testing.T) {
// make and configure a mocked Device
mockedDevice := &DeviceMock{
GetAttributesFunc: func() (map[string]interface{}, error) {
panic("mock out the GetAttributes method")
},
GetCudaComputeCapabilityFunc: func() (int, int, error) {
panic("mock out the GetCudaComputeCapability method")
},
GetDeviceHandleFromMigDeviceHandleFunc: func() (Device, error) {
panic("mock out the GetDeviceHandleFromMigDeviceHandle method")
},
GetFabricIDsFunc: func() (string, string, error) {
panic("mock out the GetFabricIDs method")
},
GetMigDevicesFunc: func() ([]Device, error) {
panic("mock out the GetMigDevices method")
},
GetNameFunc: func() (string, error) {
panic("mock out the GetName method")
},
GetPCIClassFunc: func() (uint32, error) {
panic("mock out the GetPCIClass method")
},
GetTotalMemoryMiBFunc: func() (uint64, error) {
panic("mock out the GetTotalMemoryMiB method")
},
IsFabricAttachedFunc: func() (bool, error) {
panic("mock out the IsFabricAttached method")
},
IsMigCapableFunc: func() (bool, error) {
panic("mock out the IsMigCapable method")
},
IsMigEnabledFunc: func() (bool, error) {
panic("mock out the IsMigEnabled method")
},
}
// use mockedDevice in code that requires Device
// and then make assertions.
}
func (*DeviceMock) GetAttributes ¶
func (mock *DeviceMock) GetAttributes() (map[string]interface{}, error)
GetAttributes calls GetAttributesFunc.
func (*DeviceMock) GetAttributesCalls ¶
func (mock *DeviceMock) GetAttributesCalls() []struct { }
GetAttributesCalls gets all the calls that were made to GetAttributes. Check the length with:
len(mockedDevice.GetAttributesCalls())
func (*DeviceMock) GetCudaComputeCapability ¶
func (mock *DeviceMock) GetCudaComputeCapability() (int, int, error)
GetCudaComputeCapability calls GetCudaComputeCapabilityFunc.
func (*DeviceMock) GetCudaComputeCapabilityCalls ¶
func (mock *DeviceMock) GetCudaComputeCapabilityCalls() []struct { }
GetCudaComputeCapabilityCalls gets all the calls that were made to GetCudaComputeCapability. Check the length with:
len(mockedDevice.GetCudaComputeCapabilityCalls())
func (*DeviceMock) GetDeviceHandleFromMigDeviceHandle ¶
func (mock *DeviceMock) GetDeviceHandleFromMigDeviceHandle() (Device, error)
GetDeviceHandleFromMigDeviceHandle calls GetDeviceHandleFromMigDeviceHandleFunc.
func (*DeviceMock) GetDeviceHandleFromMigDeviceHandleCalls ¶
func (mock *DeviceMock) GetDeviceHandleFromMigDeviceHandleCalls() []struct { }
GetDeviceHandleFromMigDeviceHandleCalls gets all the calls that were made to GetDeviceHandleFromMigDeviceHandle. Check the length with:
len(mockedDevice.GetDeviceHandleFromMigDeviceHandleCalls())
func (*DeviceMock) GetFabricIDs ¶ added in v0.17.0
func (mock *DeviceMock) GetFabricIDs() (string, string, error)
GetFabricIDs calls GetFabricIDsFunc.
func (*DeviceMock) GetFabricIDsCalls ¶ added in v0.17.0
func (mock *DeviceMock) GetFabricIDsCalls() []struct { }
GetFabricIDsCalls gets all the calls that were made to GetFabricIDs. Check the length with:
len(mockedDevice.GetFabricIDsCalls())
func (*DeviceMock) GetMigDevices ¶
func (mock *DeviceMock) GetMigDevices() ([]Device, error)
GetMigDevices calls GetMigDevicesFunc.
func (*DeviceMock) GetMigDevicesCalls ¶
func (mock *DeviceMock) GetMigDevicesCalls() []struct { }
GetMigDevicesCalls gets all the calls that were made to GetMigDevices. Check the length with:
len(mockedDevice.GetMigDevicesCalls())
func (*DeviceMock) GetName ¶
func (mock *DeviceMock) GetName() (string, error)
GetName calls GetNameFunc.
func (*DeviceMock) GetNameCalls ¶
func (mock *DeviceMock) GetNameCalls() []struct { }
GetNameCalls gets all the calls that were made to GetName. Check the length with:
len(mockedDevice.GetNameCalls())
func (*DeviceMock) GetPCIClass ¶ added in v0.16.0
func (mock *DeviceMock) GetPCIClass() (uint32, error)
GetPCIClass calls GetPCIClassFunc.
func (*DeviceMock) GetPCIClassCalls ¶ added in v0.16.0
func (mock *DeviceMock) GetPCIClassCalls() []struct { }
GetPCIClassCalls gets all the calls that were made to GetPCIClass. Check the length with:
len(mockedDevice.GetPCIClassCalls())
func (*DeviceMock) GetTotalMemoryMiB ¶ added in v0.17.2
func (mock *DeviceMock) GetTotalMemoryMiB() (uint64, error)
GetTotalMemoryMiB calls GetTotalMemoryMiBFunc.
func (*DeviceMock) GetTotalMemoryMiBCalls ¶ added in v0.17.2
func (mock *DeviceMock) GetTotalMemoryMiBCalls() []struct { }
GetTotalMemoryMiBCalls gets all the calls that were made to GetTotalMemoryMiB. Check the length with:
len(mockedDevice.GetTotalMemoryMiBCalls())
func (*DeviceMock) IsFabricAttached ¶ added in v0.17.0
func (mock *DeviceMock) IsFabricAttached() (bool, error)
IsFabricAttached calls IsFabricAttachedFunc.
func (*DeviceMock) IsFabricAttachedCalls ¶ added in v0.17.0
func (mock *DeviceMock) IsFabricAttachedCalls() []struct { }
IsFabricAttachedCalls gets all the calls that were made to IsFabricAttached. Check the length with:
len(mockedDevice.IsFabricAttachedCalls())
func (*DeviceMock) IsMigCapable ¶
func (mock *DeviceMock) IsMigCapable() (bool, error)
IsMigCapable calls IsMigCapableFunc.
func (*DeviceMock) IsMigCapableCalls ¶
func (mock *DeviceMock) IsMigCapableCalls() []struct { }
IsMigCapableCalls gets all the calls that were made to IsMigCapable. Check the length with:
len(mockedDevice.IsMigCapableCalls())
func (*DeviceMock) IsMigEnabled ¶
func (mock *DeviceMock) IsMigEnabled() (bool, error)
IsMigEnabled calls IsMigEnabledFunc.
func (*DeviceMock) IsMigEnabledCalls ¶
func (mock *DeviceMock) IsMigEnabledCalls() []struct { }
IsMigEnabledCalls gets all the calls that were made to IsMigEnabled. Check the length with:
len(mockedDevice.IsMigEnabledCalls())
type Manager ¶
type Manager interface {
Init() error
Shutdown() error
GetDevices() ([]Device, error)
GetDriverVersion() (string, error)
GetCudaDriverVersion() (int, int, error)
}
Manager defines an interface for managing devices
func NewCudaManager ¶
func NewCudaManager() Manager
NewCudaManager returns an resource manger for CUDA devices
func NewFallbackToNullOnInitError ¶
NewFallbackToNullOnInitError creates a manager that becomes a Null manager on the first Init error.
func NewManager ¶
func NewManager(infolib info.Interface, nvmllib nvml.Interface, devicelib device.Interface, config *spec.Config) (Manager, error)
NewManager is a factory method that creates a resource Manager based on the specified config.
func NewNVMLManager ¶
NewNVMLManager creates a new manager that uses NVML to query and manage devices
func NewNullManager ¶
func NewNullManager() Manager
NewNullManager returns an instance of a CUDA-based library that can be used when no operations are required. This returns no devices and the Init and Shutdown methods are no-ops.
func NewVfioManager ¶ added in v0.16.0
func NewVfioManager() Manager
NewVfioManager returns an resource manger for devices with VFIO PCI driver
type ManagerMock ¶
type ManagerMock struct {
// GetCudaDriverVersionFunc mocks the GetCudaDriverVersion method.
GetCudaDriverVersionFunc func() (int, int, error)
// GetDevicesFunc mocks the GetDevices method.
GetDevicesFunc func() ([]Device, error)
// GetDriverVersionFunc mocks the GetDriverVersion method.
GetDriverVersionFunc func() (string, error)
// InitFunc mocks the Init method.
InitFunc func() error
// ShutdownFunc mocks the Shutdown method.
ShutdownFunc func() error
// contains filtered or unexported fields
}
ManagerMock is a mock implementation of Manager.
func TestSomethingThatUsesManager(t *testing.T) {
// make and configure a mocked Manager
mockedManager := &ManagerMock{
GetCudaDriverVersionFunc: func() (int, int, error) {
panic("mock out the GetCudaDriverVersion method")
},
GetDevicesFunc: func() ([]Device, error) {
panic("mock out the GetDevices method")
},
GetDriverVersionFunc: func() (string, error) {
panic("mock out the GetDriverVersion method")
},
InitFunc: func() error {
panic("mock out the Init method")
},
ShutdownFunc: func() error {
panic("mock out the Shutdown method")
},
}
// use mockedManager in code that requires Manager
// and then make assertions.
}
func (*ManagerMock) GetCudaDriverVersion ¶
func (mock *ManagerMock) GetCudaDriverVersion() (int, int, error)
GetCudaDriverVersion calls GetCudaDriverVersionFunc.
func (*ManagerMock) GetCudaDriverVersionCalls ¶
func (mock *ManagerMock) GetCudaDriverVersionCalls() []struct { }
GetCudaDriverVersionCalls gets all the calls that were made to GetCudaDriverVersion. Check the length with:
len(mockedManager.GetCudaDriverVersionCalls())
func (*ManagerMock) GetDevices ¶
func (mock *ManagerMock) GetDevices() ([]Device, error)
GetDevices calls GetDevicesFunc.
func (*ManagerMock) GetDevicesCalls ¶
func (mock *ManagerMock) GetDevicesCalls() []struct { }
GetDevicesCalls gets all the calls that were made to GetDevices. Check the length with:
len(mockedManager.GetDevicesCalls())
func (*ManagerMock) GetDriverVersion ¶
func (mock *ManagerMock) GetDriverVersion() (string, error)
GetDriverVersion calls GetDriverVersionFunc.
func (*ManagerMock) GetDriverVersionCalls ¶
func (mock *ManagerMock) GetDriverVersionCalls() []struct { }
GetDriverVersionCalls gets all the calls that were made to GetDriverVersion. Check the length with:
len(mockedManager.GetDriverVersionCalls())
func (*ManagerMock) InitCalls ¶
func (mock *ManagerMock) InitCalls() []struct { }
InitCalls gets all the calls that were made to Init. Check the length with:
len(mockedManager.InitCalls())
func (*ManagerMock) Shutdown ¶
func (mock *ManagerMock) Shutdown() error
Shutdown calls ShutdownFunc.
func (*ManagerMock) ShutdownCalls ¶
func (mock *ManagerMock) ShutdownCalls() []struct { }
ShutdownCalls gets all the calls that were made to Shutdown. Check the length with:
len(mockedManager.ShutdownCalls())