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) GetMigDevices() ([]Device, error)
- func (mock *DeviceMock) GetMigDevicesCalls() []struct{}
- func (mock *DeviceMock) GetName() (string, error)
- func (mock *DeviceMock) GetNameCalls() []struct{}
- func (mock *DeviceMock) GetTotalMemoryMB() (uint64, error)
- func (mock *DeviceMock) GetTotalMemoryMBCalls() []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
- type ManagerMock
- func (mock *ManagerMock) GetCudaDriverVersion() (*uint, *uint, 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 { IsMigEnabled() (bool, error) IsMigCapable() (bool, error) GetMigDevices() ([]Device, error) GetAttributes() (map[string]interface{}, error) GetName() (string, error) GetTotalMemoryMB() (uint64, error) GetDeviceHandleFromMigDeviceHandle() (Device, error) GetCudaComputeCapability() (int, int, 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) // GetMigDevicesFunc mocks the GetMigDevices method. GetMigDevicesFunc func() ([]Device, error) // GetNameFunc mocks the GetName method. GetNameFunc func() (string, error) // GetTotalMemoryMBFunc mocks the GetTotalMemoryMB method. GetTotalMemoryMBFunc func() (uint64, 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") }, GetMigDevicesFunc: func() ([]Device, error) { panic("mock out the GetMigDevices method") }, GetNameFunc: func() (string, error) { panic("mock out the GetName method") }, GetTotalMemoryMBFunc: func() (uint64, error) { panic("mock out the GetTotalMemoryMB 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) 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) GetTotalMemoryMB ¶
func (mock *DeviceMock) GetTotalMemoryMB() (uint64, error)
GetTotalMemoryMB calls GetTotalMemoryMBFunc.
func (*DeviceMock) GetTotalMemoryMBCalls ¶
func (mock *DeviceMock) GetTotalMemoryMBCalls() []struct { }
GetTotalMemoryMBCalls gets all the calls that were made to GetTotalMemoryMB. Check the length with:
len(mockedDevice.GetTotalMemoryMBCalls())
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() (*uint, *uint, 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 ¶
NewManager is a factory method that creates a resource Manager based on the specified config.
func NewNVMLManager ¶
func NewNVMLManager() Manager
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.
type ManagerMock ¶
type ManagerMock struct { // GetCudaDriverVersionFunc mocks the GetCudaDriverVersion method. GetCudaDriverVersionFunc func() (*uint, *uint, 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() (*uint, *uint, 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() (*uint, *uint, 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())