mirror of
https://github.com/clearml/go-nvlib
synced 2025-01-31 02:47:02 +00:00
Remove WithSelecteDeviceClasses option
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
655eb9795c
commit
1fc1eee392
@ -18,11 +18,9 @@ package device
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/NVIDIA/go-nvml/pkg/dl"
|
"github.com/NVIDIA/go-nvml/pkg/dl"
|
||||||
"gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvml"
|
"gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvml"
|
||||||
"gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvpci"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Device defines the set of extended functions associated with a device.Device
|
// Device defines the set of extended functions associated with a device.Device
|
||||||
@ -41,15 +39,6 @@ type device struct {
|
|||||||
lib *devicelib
|
lib *devicelib
|
||||||
}
|
}
|
||||||
|
|
||||||
// Class represents the PCI class for a device
|
|
||||||
type Class uint32
|
|
||||||
|
|
||||||
// Define constants for common device classes
|
|
||||||
const (
|
|
||||||
ClassCompute = Class(nvpci.PCI3dControllerClass)
|
|
||||||
ClassDisplay = Class(nvpci.PCIVgaControllerClass)
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ Device = &device{}
|
var _ Device = &device{}
|
||||||
|
|
||||||
// NewDevice builds a new Device from an nvml.Device
|
// NewDevice builds a new Device from an nvml.Device
|
||||||
@ -62,16 +51,6 @@ func (d *devicelib) newDevice(dev nvml.Device) (*device, error) {
|
|||||||
return &device{dev, d}, nil
|
return &device{dev, d}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// classIsSelected checks whether the specified class has been selected when constructing the devicelib
|
|
||||||
func (d *devicelib) classIsSelected(c Class) bool {
|
|
||||||
if d.selectedDeviceClasses == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
_, exists := d.selectedDeviceClasses[c]
|
|
||||||
|
|
||||||
return exists
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsMigCapable checks if a device is capable of having MIG paprtitions created on it
|
// IsMigCapable checks if a device is capable of having MIG paprtitions created on it
|
||||||
func (d *device) IsMigCapable() (bool, error) {
|
func (d *device) IsMigCapable() (bool, error) {
|
||||||
err := nvmlLookupSymbol("nvmlDeviceGetMigMode")
|
err := nvmlLookupSymbol("nvmlDeviceGetMigMode")
|
||||||
@ -209,35 +188,6 @@ func (d *device) GetMigProfiles() ([]MigProfile, error) {
|
|||||||
return profiles, nil
|
return profiles, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getClass returns the PCI device class for the device
|
|
||||||
func (d *device) getClass() (Class, error) {
|
|
||||||
info, ret := d.GetPciInfo()
|
|
||||||
if ret != nvml.SUCCESS {
|
|
||||||
return 0, fmt.Errorf("failed to get PCI info: %v", ret)
|
|
||||||
}
|
|
||||||
|
|
||||||
// We convert the BusId to a string
|
|
||||||
var bytes []byte
|
|
||||||
for _, b := range info.BusId {
|
|
||||||
if byte(b) == '\x00' {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
bytes = append(bytes, byte(b))
|
|
||||||
}
|
|
||||||
id := strings.ToLower(string(bytes))
|
|
||||||
|
|
||||||
if id != "0000" {
|
|
||||||
id = strings.TrimPrefix(id, "0000")
|
|
||||||
}
|
|
||||||
|
|
||||||
device, err := nvpci.New().GetGPUByPciBusID(id)
|
|
||||||
if err != nil {
|
|
||||||
return 0, fmt.Errorf("failed to construct PCI device: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return Class(device.Class), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// isSkipped checks whether the device should be skipped.
|
// isSkipped checks whether the device should be skipped.
|
||||||
func (d *device) isSkipped() (bool, error) {
|
func (d *device) isSkipped() (bool, error) {
|
||||||
name, ret := d.GetName()
|
name, ret := d.GetName()
|
||||||
|
Loading…
Reference in New Issue
Block a user