From bbaf543537d0e18119d5b9f23392a823fc367b6c Mon Sep 17 00:00:00 2001 From: Evan Lezar <elezar@nvidia.com> Date: Thu, 18 Apr 2024 14:49:21 +0200 Subject: [PATCH] Update github.com/NVIDIA/go-nvlib to v0.3.0 Signed-off-by: Evan Lezar <elezar@nvidia.com> --- go.mod | 2 +- go.sum | 4 +- .../NVIDIA/go-nvlib/pkg/nvlib/device/api.go | 14 +- .../go-nvlib/pkg/nvlib/device/device.go | 46 +- .../go-nvlib/pkg/nvlib/device/identifier.go | 12 +- .../go-nvlib/pkg/nvlib/device/mig_device.go | 10 +- .../go-nvlib/pkg/nvlib/device/mig_profile.go | 26 +- .../NVIDIA/go-nvlib/pkg/nvlib/info/info.go | 8 +- .../NVIDIA/go-nvlib/pkg/nvlib/info/options.go | 6 +- .../github.com/NVIDIA/go-nvlib/pkg/nvml/ci.go | 44 - .../NVIDIA/go-nvlib/pkg/nvml/ci_mock.go | 104 -- .../NVIDIA/go-nvlib/pkg/nvml/consts.go | 163 --- .../NVIDIA/go-nvlib/pkg/nvml/device.go | 215 --- .../NVIDIA/go-nvlib/pkg/nvml/device_mock.go | 1237 ----------------- .../NVIDIA/go-nvlib/pkg/nvml/event_set.go | 39 - .../github.com/NVIDIA/go-nvlib/pkg/nvml/gi.go | 71 - .../NVIDIA/go-nvlib/pkg/nvml/gi_mock.go | 286 ---- .../NVIDIA/go-nvlib/pkg/nvml/nvml.go | 127 -- .../NVIDIA/go-nvlib/pkg/nvml/nvml_mock.go | 428 ------ .../NVIDIA/go-nvlib/pkg/nvml/options.go | 32 - .../NVIDIA/go-nvlib/pkg/nvml/return.go | 93 -- .../NVIDIA/go-nvlib/pkg/nvml/types.go | 162 --- .../NVIDIA/go-nvlib/pkg/nvpci/bytes/bytes.go | 14 +- .../NVIDIA/go-nvlib/pkg/nvpci/config.go | 20 +- .../NVIDIA/go-nvlib/pkg/nvpci/mlxpci.go | 18 +- .../NVIDIA/go-nvlib/pkg/nvpci/mmio/mmio.go | 6 +- .../NVIDIA/go-nvlib/pkg/nvpci/mmio/mock.go | 9 +- .../NVIDIA/go-nvlib/pkg/nvpci/mock.go | 8 +- .../NVIDIA/go-nvlib/pkg/nvpci/nvpci.go | 56 +- .../NVIDIA/go-nvlib/pkg/nvpci/resources.go | 10 +- .../NVIDIA/go-nvlib/pkg/pciids/pciids.go | 76 +- vendor/modules.txt | 3 +- 32 files changed, 175 insertions(+), 3174 deletions(-) delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci_mock.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device_mock.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/event_set.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi_mock.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml_mock.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/options.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/return.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go diff --git a/go.mod b/go.mod index 277bb628..c62e0d6d 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/NVIDIA/nvidia-container-toolkit go 1.20 require ( - github.com/NVIDIA/go-nvlib v0.2.0 + github.com/NVIDIA/go-nvlib v0.3.0 github.com/NVIDIA/go-nvml v0.12.0-4 github.com/fsnotify/fsnotify v1.7.0 github.com/opencontainers/runtime-spec v1.2.0 diff --git a/go.sum b/go.sum index 1ec1968b..5f4dd72c 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/NVIDIA/go-nvlib v0.2.0 h1:roq+SDstbP1fcy2XVH7wB2Gz2/Ud7Q+NGQYOcVITVrA= -github.com/NVIDIA/go-nvlib v0.2.0/go.mod h1:kFuLNTyD1tF6FbRFlk+/EdUW5BrkE+v1Y3A3/9zKSjA= +github.com/NVIDIA/go-nvlib v0.3.0 h1:vd7jSOthJTqzqIWZrv317xDr1+Mnjoy5X4N69W9YwQM= +github.com/NVIDIA/go-nvlib v0.3.0/go.mod h1:NasUuId9hYFvwzuOHCu9F2X6oTU2tG0JHTfbJYuDAbA= github.com/NVIDIA/go-nvml v0.12.0-4 h1:BvPjnjJr6qje0zov57Md7TwEA8i/12kZeUQIpyWzTEE= github.com/NVIDIA/go-nvml v0.12.0-4/go.mod h1:8Llmj+1Rr+9VGGwZuRer5N/aCjxGuR5nPb/9ebBiIEQ= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/api.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/api.go index 57db8598..11aa139d 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/api.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/api.go @@ -17,10 +17,10 @@ package device import ( - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" ) -// Interface provides the API to the 'device' package +// Interface provides the API to the 'device' package. type Interface interface { AssertValidMigProfileFormat(profile string) error GetDevices() ([]Device, error) @@ -46,7 +46,7 @@ type devicelib struct { var _ Interface = &devicelib{} -// New creates a new instance of the 'device' interface +// New creates a new instance of the 'device' interface. func New(opts ...Option) Interface { d := &devicelib{} for _, opt := range opts { @@ -68,21 +68,21 @@ func New(opts ...Option) Interface { return d } -// WithNvml provides an Option to set the NVML library used by the 'device' interface +// WithNvml provides an Option to set the NVML library used by the 'device' interface. func WithNvml(nvml nvml.Interface) Option { return func(d *devicelib) { d.nvml = nvml } } -// WithVerifySymbols provides an option to toggle whether to verify select symbols exist in dynamic libraries before calling them +// WithVerifySymbols provides an option to toggle whether to verify select symbols exist in dynamic libraries before calling them. func WithVerifySymbols(verify bool) Option { return func(d *devicelib) { d.verifySymbols = &verify } } -// WithSkippedDevices provides an Option to set devices to be skipped by model name +// WithSkippedDevices provides an Option to set devices to be skipped by model name. func WithSkippedDevices(names ...string) Option { return func(d *devicelib) { if d.skippedDevices == nil { @@ -94,5 +94,5 @@ func WithSkippedDevices(names ...string) Option { } } -// Option defines a function for passing options to the New() call +// Option defines a function for passing options to the New() call. type Option func(*devicelib) diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/device.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/device.go index 49734e80..10514591 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/device.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/device.go @@ -19,10 +19,10 @@ package device import ( "fmt" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" ) -// Device defines the set of extended functions associated with a device.Device +// Device defines the set of extended functions associated with a device.Device. type Device interface { nvml.Device GetArchitectureAsString() (string, error) @@ -44,12 +44,12 @@ type device struct { var _ Device = &device{} -// NewDevice builds a new Device from an nvml.Device +// NewDevice builds a new Device from an nvml.Device. func (d *devicelib) NewDevice(dev nvml.Device) (Device, error) { return d.newDevice(dev) } -// NewDeviceByUUID builds a new Device from a UUID +// NewDeviceByUUID builds a new Device from a UUID. func (d *devicelib) NewDeviceByUUID(uuid string) (Device, error) { dev, ret := d.nvml.DeviceGetHandleByUUID(uuid) if ret != nvml.SUCCESS { @@ -58,12 +58,12 @@ func (d *devicelib) NewDeviceByUUID(uuid string) (Device, error) { return d.newDevice(dev) } -// newDevice creates a device from an nvml.Device +// newDevice creates a device from an nvml.Device. func (d *devicelib) newDevice(dev nvml.Device) (*device, error) { return &device{dev, d, nil}, nil } -// GetArchitectureAsString returns the Device architecture as a string +// GetArchitectureAsString returns the Device architecture as a string. func (d *device) GetArchitectureAsString() (string, error) { arch, ret := d.GetArchitecture() if ret != nvml.SUCCESS { @@ -92,7 +92,7 @@ func (d *device) GetArchitectureAsString() (string, error) { return "", fmt.Errorf("error interpreting device architecture as string: %v", arch) } -// GetBrandAsString returns the Device architecture as a string +// GetBrandAsString returns the Device architecture as a string. func (d *device) GetBrandAsString() (string, error) { brand, ret := d.GetBrand() if ret != nvml.SUCCESS { @@ -140,7 +140,7 @@ func (d *device) GetBrandAsString() (string, error) { return "", fmt.Errorf("error interpreting device brand as string: %v", brand) } -// GetCudaComputeCapabilityAsString returns the Device's CUDA compute capability as a version string +// GetCudaComputeCapabilityAsString returns the Device's CUDA compute capability as a version string. func (d *device) GetCudaComputeCapabilityAsString() (string, error) { major, minor, ret := d.GetCudaComputeCapability() if ret != nvml.SUCCESS { @@ -149,7 +149,7 @@ func (d *device) GetCudaComputeCapabilityAsString() (string, error) { return fmt.Sprintf("%d.%d", major, minor), nil } -// 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) { if !d.lib.hasSymbol("nvmlDeviceGetMigMode") { return false, nil @@ -166,7 +166,7 @@ func (d *device) IsMigCapable() (bool, error) { return true, nil } -// IsMigEnabled checks if a device has MIG mode currently enabled on it +// IsMigEnabled checks if a device has MIG mode currently enabled on it. func (d *device) IsMigEnabled() (bool, error) { if !d.lib.hasSymbol("nvmlDeviceGetMigMode") { return false, nil @@ -183,7 +183,7 @@ func (d *device) IsMigEnabled() (bool, error) { return (mode == nvml.DEVICE_MIG_ENABLE), nil } -// VisitMigDevices walks a top-level device and invokes a callback function for each MIG device configured on it +// VisitMigDevices walks a top-level device and invokes a callback function for each MIG device configured on it. func (d *device) VisitMigDevices(visit func(int, MigDevice) error) error { capable, err := d.IsMigCapable() if err != nil { @@ -221,7 +221,7 @@ func (d *device) VisitMigDevices(visit func(int, MigDevice) error) error { return nil } -// VisitMigProfiles walks a top-level device and invokes a callback function for each unique MIG Profile that can be configured on it +// VisitMigProfiles walks a top-level device and invokes a callback function for each unique MIG Profile that can be configured on it. func (d *device) VisitMigProfiles(visit func(MigProfile) error) error { capable, err := d.IsMigCapable() if err != nil { @@ -283,7 +283,7 @@ func (d *device) VisitMigProfiles(visit func(MigProfile) error) error { return nil } -// GetMigDevices gets the set of MIG devices associated with a top-level device +// GetMigDevices gets the set of MIG devices associated with a top-level device. func (d *device) GetMigDevices() ([]MigDevice, error) { var migs []MigDevice err := d.VisitMigDevices(func(j int, m MigDevice) error { @@ -296,7 +296,7 @@ func (d *device) GetMigDevices() ([]MigDevice, error) { return migs, nil } -// GetMigProfiles gets the set of unique MIG profiles associated with a top-level device +// GetMigProfiles gets the set of unique MIG profiles associated with a top-level device. func (d *device) GetMigProfiles() ([]MigProfile, error) { // Return the cached list if available if d.migProfiles != nil { @@ -313,7 +313,7 @@ func (d *device) GetMigProfiles() ([]MigProfile, error) { return nil, err } - // And cache it before returning + // And cache it before returning. d.migProfiles = profiles return profiles, nil } @@ -332,7 +332,7 @@ func (d *device) isSkipped() (bool, error) { return false, nil } -// VisitDevices visits each top-level device and invokes a callback function for it +// VisitDevices visits each top-level device and invokes a callback function for it. func (d *devicelib) VisitDevices(visit func(int, Device) error) error { count, ret := d.nvml.DeviceGetCount() if ret != nvml.SUCCESS { @@ -365,7 +365,7 @@ func (d *devicelib) VisitDevices(visit func(int, Device) error) error { return nil } -// VisitMigDevices walks a top-level device and invokes a callback function for each MIG device configured on it +// VisitMigDevices walks a top-level device and invokes a callback function for each MIG device configured on it. func (d *devicelib) VisitMigDevices(visit func(int, Device, int, MigDevice) error) error { err := d.VisitDevices(func(i int, dev Device) error { err := dev.VisitMigDevices(func(j int, mig MigDevice) error { @@ -386,7 +386,7 @@ func (d *devicelib) VisitMigDevices(visit func(int, Device, int, MigDevice) erro return nil } -// VisitMigProfiles walks a top-level device and invokes a callback function for each unique MIG profile found on them +// VisitMigProfiles walks a top-level device and invokes a callback function for each unique MIG profile found on them. func (d *devicelib) VisitMigProfiles(visit func(MigProfile) error) error { visited := make(map[string]bool) err := d.VisitDevices(func(i int, dev Device) error { @@ -414,7 +414,7 @@ func (d *devicelib) VisitMigProfiles(visit func(MigProfile) error) error { return nil } -// GetDevices gets the set of all top-level devices +// GetDevices gets the set of all top-level devices. func (d *devicelib) GetDevices() ([]Device, error) { var devs []Device err := d.VisitDevices(func(i int, dev Device) error { @@ -427,7 +427,7 @@ func (d *devicelib) GetDevices() ([]Device, error) { return devs, nil } -// GetMigDevices gets the set of MIG devices across all top-level devices +// GetMigDevices gets the set of MIG devices across all top-level devices. func (d *devicelib) GetMigDevices() ([]MigDevice, error) { var migs []MigDevice err := d.VisitMigDevices(func(i int, dev Device, j int, m MigDevice) error { @@ -440,7 +440,7 @@ func (d *devicelib) GetMigDevices() ([]MigDevice, error) { return migs, nil } -// GetMigProfiles gets the set of unique MIG profiles across all top-level devices +// GetMigProfiles gets the set of unique MIG profiles across all top-level devices. func (d *devicelib) GetMigProfiles() ([]MigProfile, error) { // Return the cached list if available if d.migProfiles != nil { @@ -457,7 +457,7 @@ func (d *devicelib) GetMigProfiles() ([]MigProfile, error) { return nil, err } - // And cache it before returning + // And cache it before returning. d.migProfiles = profiles return profiles, nil } @@ -469,5 +469,5 @@ func (d *devicelib) hasSymbol(symbol string) bool { return true } - return d.nvml.Lookup(symbol) == nil + return d.nvml.Extensions().LookupSymbol(symbol) == nil } diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/identifier.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/identifier.go index 689de6d4..114e9cd5 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/identifier.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/identifier.go @@ -27,7 +27,7 @@ import ( // This includes a device index or UUID. type Identifier string -// IsGpuIndex checks if an identifier is a full GPU index +// IsGpuIndex checks if an identifier is a full GPU index. func (i Identifier) IsGpuIndex() bool { if _, err := strconv.ParseUint(string(i), 10, 0); err != nil { return false @@ -35,7 +35,7 @@ func (i Identifier) IsGpuIndex() bool { return true } -// IsMigIndex checks if an identifier is a MIG index +// IsMigIndex checks if an identifier is a MIG index. func (i Identifier) IsMigIndex() bool { split := strings.Split(string(i), ":") if len(split) != 2 { @@ -49,13 +49,13 @@ func (i Identifier) IsMigIndex() bool { return true } -// IsUUID checks if an identifier is a UUID +// IsUUID checks if an identifier is a UUID. func (i Identifier) IsUUID() bool { return i.IsGpuUUID() || i.IsMigUUID() } -// IsGpuUUID checks if an identifier is a GPU UUID -// A GPU UUID must be of the form GPU-b1028956-cfa2-0990-bf4a-5da9abb51763 +// IsGpuUUID checks if an identifier is a GPU UUID. +// A GPU UUID must be of the form GPU-b1028956-cfa2-0990-bf4a-5da9abb51763. func (i Identifier) IsGpuUUID() bool { if !strings.HasPrefix(string(i), "GPU-") { return false @@ -64,7 +64,7 @@ func (i Identifier) IsGpuUUID() bool { return err == nil } -// IsMigUUID checks if an identifier is a MIG UUID +// IsMigUUID checks if an identifier is a MIG UUID. // A MIG UUID can be of one of two forms: // - MIG-b1028956-cfa2-0990-bf4a-5da9abb51763 // - MIG-GPU-b1028956-cfa2-0990-bf4a-5da9abb51763/3/0 diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_device.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_device.go index bbe3bb6e..b02d4176 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_device.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_device.go @@ -19,10 +19,10 @@ package device import ( "fmt" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" ) -// MigDevice defines the set of extended functions associated with a MIG device +// MigDevice defines the set of extended functions associated with a MIG device. type MigDevice interface { nvml.Device GetProfile() (MigProfile, error) @@ -36,7 +36,7 @@ type migdevice struct { var _ MigDevice = &migdevice{} -// NewMigDevice builds a new MigDevice from an nvml.Device +// NewMigDevice builds a new MigDevice from an nvml.Device. func (d *devicelib) NewMigDevice(handle nvml.Device) (MigDevice, error) { isMig, ret := handle.IsMigDeviceHandle() if ret != nvml.SUCCESS { @@ -48,7 +48,7 @@ func (d *devicelib) NewMigDevice(handle nvml.Device) (MigDevice, error) { return &migdevice{handle, d, nil}, nil } -// NewMigDeviceByUUID builds a new MigDevice from a UUID +// NewMigDeviceByUUID builds a new MigDevice from a UUID. func (d *devicelib) NewMigDeviceByUUID(uuid string) (MigDevice, error) { dev, ret := d.nvml.DeviceGetHandleByUUID(uuid) if ret != nvml.SUCCESS { @@ -57,7 +57,7 @@ func (d *devicelib) NewMigDeviceByUUID(uuid string) (MigDevice, error) { return d.NewMigDevice(dev) } -// GetProfile returns the MIG profile associated with a MIG device +// GetProfile returns the MIG profile associated with a MIG device. func (m *migdevice) GetProfile() (MigProfile, error) { if m.profile != nil { return m.profile, nil diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_profile.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_profile.go index 6f27af61..c1f0190f 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_profile.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_profile.go @@ -23,7 +23,7 @@ import ( "strconv" "strings" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" ) const ( @@ -40,7 +40,7 @@ type MigProfile interface { Matches(profile string) bool } -// MigProfileInfo holds all info associated with a specific MIG profile +// MigProfileInfo holds all info associated with a specific MIG profile. type MigProfileInfo struct { C int G int @@ -119,13 +119,13 @@ func (d *devicelib) NewMigProfile(giProfileID, ciProfileID, ciEngProfileID int, return p, nil } -// AssertValidMigProfileFormat checks if the string is in the proper format to represent a MIG profile +// AssertValidMigProfileFormat checks if the string is in the proper format to represent a MIG profile. func (d *devicelib) AssertValidMigProfileFormat(profile string) error { _, _, _, _, err := parseMigProfile(profile) return err } -// ParseMigProfile converts a string representation of a MigProfile into an object +// ParseMigProfile converts a string representation of a MigProfile into an object. func (d *devicelib) ParseMigProfile(profile string) (MigProfile, error) { profiles, err := d.GetMigProfiles() if err != nil { @@ -141,7 +141,7 @@ func (d *devicelib) ParseMigProfile(profile string) (MigProfile, error) { return nil, fmt.Errorf("unable to parse profile string into a valid profile") } -// String returns the string representation of a Profile +// String returns the string representation of a Profile. func (p MigProfileInfo) String() string { var suffix string if len(p.Attributes) > 0 { @@ -153,12 +153,12 @@ func (p MigProfileInfo) String() string { return fmt.Sprintf("%dc.%dg.%dgb%s", p.C, p.G, p.GB, suffix) } -// GetInfo returns detailed info about a Profile +// GetInfo returns detailed info about a Profile. func (p MigProfileInfo) GetInfo() MigProfileInfo { return p } -// Equals checks if two Profiles are identical or not +// Equals checks if two Profiles are identical or not. func (p MigProfileInfo) Equals(other MigProfile) bool { o := other.GetInfo() if p.C != o.C { @@ -182,7 +182,7 @@ func (p MigProfileInfo) Equals(other MigProfile) bool { return true } -// Matches checks if a MigProfile matches the string passed in +// Matches checks if a MigProfile matches the string passed in. func (p MigProfileInfo) Matches(profile string) bool { c, g, gb, attrs, err := parseMigProfile(profile) if err != nil { @@ -211,26 +211,26 @@ func (p MigProfileInfo) Matches(profile string) bool { } func parseMigProfile(profile string) (int, int, int, []string, error) { - // If we are handed the empty string, we cannot parse it + // If we are handed the empty string, we cannot parse it. if profile == "" { return -1, -1, -1, nil, fmt.Errorf("profile is the empty string") } - // Split by + to separate out attributes + // Split by + to separate out attributes. split := strings.SplitN(profile, "+", 2) - // Check to make sure the c, g, and gb values match + // Check to make sure the c, g, and gb values match. c, g, gb, err := parseMigProfileFields(split[0]) if err != nil { return -1, -1, -1, nil, fmt.Errorf("cannot parse fields of '%v': %v", profile, err) } - // If we have no attributes we are done + // If we have no attributes we are done. if len(split) == 1 { return c, g, gb, nil, nil } - // Make sure we have the same set of attributes + // Make sure we have the same set of attributes. attrs, err := parseMigProfileAttributes(split[1]) if err != nil { return -1, -1, -1, nil, fmt.Errorf("cannot parse attributes of '%v': %v", profile, err) diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/info.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/info.go index 460e852c..677270c3 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/info.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/info.go @@ -25,7 +25,7 @@ import ( "github.com/NVIDIA/go-nvml/pkg/dl" ) -// Interface provides the API to the info package +// Interface provides the API to the info package. type Interface interface { HasDXCore() (bool, string) HasNvml() (bool, string) @@ -50,7 +50,7 @@ func (i *infolib) HasDXCore() (bool, string) { return true, "found DXCore library" } -// HasNvml returns true if NVML is detected on the system +// HasNvml returns true if NVML is detected on the system. func (i *infolib) HasNvml() (bool, string) { const ( libraryName = "libnvidia-ml.so.1" @@ -62,7 +62,7 @@ func (i *infolib) HasNvml() (bool, string) { return true, "found NVML library" } -// IsTegraSystem returns true if the system is detected as a Tegra-based system +// IsTegraSystem returns true if the system is detected as a Tegra-based system. func (i *infolib) IsTegraSystem() (bool, string) { tegraReleaseFile := filepath.Join(i.root, "/etc/nv_tegra_release") tegraFamilyFile := filepath.Join(i.root, "/sys/devices/soc0/family") @@ -87,7 +87,7 @@ 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 +// assertHasLibrary returns an error if the specified library cannot be loaded. func assertHasLibrary(libraryName string) error { const ( libraryLoadFlags = dl.RTLD_LAZY diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/options.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/options.go index 314efa67..ce72150c 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/options.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/options.go @@ -16,10 +16,10 @@ package info -// Option defines a function for passing options to the New() call +// Option defines a function for passing options to the New() call. type Option func(*infolib) -// New creates a new instance of the 'info' interface +// New creates a new instance of the 'info' interface. func New(opts ...Option) Interface { i := &infolib{} for _, opt := range opts { @@ -31,7 +31,7 @@ func New(opts ...Option) Interface { return i } -// WithRoot provides a Option to set the root of the 'info' interface +// WithRoot provides a Option to set the root of the 'info' interface. func WithRoot(root string) Option { return func(i *infolib) { i.root = root diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci.go deleted file mode 100644 index 6a9d798b..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -type nvmlComputeInstance nvml.ComputeInstance - -var _ ComputeInstance = (*nvmlComputeInstance)(nil) - -// GetInfo() returns info about a Compute Instance -func (ci nvmlComputeInstance) GetInfo() (ComputeInstanceInfo, Return) { - i, r := nvml.ComputeInstance(ci).GetInfo() - info := ComputeInstanceInfo{ - Device: nvmlDevice(i.Device), - GpuInstance: nvmlGpuInstance(i.GpuInstance), - Id: i.Id, - ProfileId: i.ProfileId, - Placement: ComputeInstancePlacement(i.Placement), - } - return info, Return(r) -} - -// Destroy() destroys a Compute Instance -func (ci nvmlComputeInstance) Destroy() Return { - r := nvml.ComputeInstance(ci).Destroy() - return Return(r) -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci_mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci_mock.go deleted file mode 100644 index e4e75a7a..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci_mock.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq - -package nvml - -import ( - "sync" -) - -// Ensure, that ComputeInstanceMock does implement ComputeInstance. -// If this is not the case, regenerate this file with moq. -var _ ComputeInstance = &ComputeInstanceMock{} - -// ComputeInstanceMock is a mock implementation of ComputeInstance. -// -// func TestSomethingThatUsesComputeInstance(t *testing.T) { -// -// // make and configure a mocked ComputeInstance -// mockedComputeInstance := &ComputeInstanceMock{ -// DestroyFunc: func() Return { -// panic("mock out the Destroy method") -// }, -// GetInfoFunc: func() (ComputeInstanceInfo, Return) { -// panic("mock out the GetInfo method") -// }, -// } -// -// // use mockedComputeInstance in code that requires ComputeInstance -// // and then make assertions. -// -// } -type ComputeInstanceMock struct { - // DestroyFunc mocks the Destroy method. - DestroyFunc func() Return - - // GetInfoFunc mocks the GetInfo method. - GetInfoFunc func() (ComputeInstanceInfo, Return) - - // calls tracks calls to the methods. - calls struct { - // Destroy holds details about calls to the Destroy method. - Destroy []struct { - } - // GetInfo holds details about calls to the GetInfo method. - GetInfo []struct { - } - } - lockDestroy sync.RWMutex - lockGetInfo sync.RWMutex -} - -// Destroy calls DestroyFunc. -func (mock *ComputeInstanceMock) Destroy() Return { - if mock.DestroyFunc == nil { - panic("ComputeInstanceMock.DestroyFunc: method is nil but ComputeInstance.Destroy was just called") - } - callInfo := struct { - }{} - mock.lockDestroy.Lock() - mock.calls.Destroy = append(mock.calls.Destroy, callInfo) - mock.lockDestroy.Unlock() - return mock.DestroyFunc() -} - -// DestroyCalls gets all the calls that were made to Destroy. -// Check the length with: -// -// len(mockedComputeInstance.DestroyCalls()) -func (mock *ComputeInstanceMock) DestroyCalls() []struct { -} { - var calls []struct { - } - mock.lockDestroy.RLock() - calls = mock.calls.Destroy - mock.lockDestroy.RUnlock() - return calls -} - -// GetInfo calls GetInfoFunc. -func (mock *ComputeInstanceMock) GetInfo() (ComputeInstanceInfo, Return) { - if mock.GetInfoFunc == nil { - panic("ComputeInstanceMock.GetInfoFunc: method is nil but ComputeInstance.GetInfo was just called") - } - callInfo := struct { - }{} - mock.lockGetInfo.Lock() - mock.calls.GetInfo = append(mock.calls.GetInfo, callInfo) - mock.lockGetInfo.Unlock() - return mock.GetInfoFunc() -} - -// GetInfoCalls gets all the calls that were made to GetInfo. -// Check the length with: -// -// len(mockedComputeInstance.GetInfoCalls()) -func (mock *ComputeInstanceMock) GetInfoCalls() []struct { -} { - var calls []struct { - } - mock.lockGetInfo.RLock() - calls = mock.calls.GetInfo - mock.lockGetInfo.RUnlock() - return calls -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go deleted file mode 100644 index cba00b98..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -// General untyped constants -const ( - NVLINK_MAX_LINKS = nvml.NVLINK_MAX_LINKS -) - -// Return constants -const ( - SUCCESS = Return(nvml.SUCCESS) - ERROR_UNINITIALIZED = Return(nvml.ERROR_UNINITIALIZED) - ERROR_INVALID_ARGUMENT = Return(nvml.ERROR_INVALID_ARGUMENT) - ERROR_NOT_SUPPORTED = Return(nvml.ERROR_NOT_SUPPORTED) - ERROR_NO_PERMISSION = Return(nvml.ERROR_NO_PERMISSION) - ERROR_ALREADY_INITIALIZED = Return(nvml.ERROR_ALREADY_INITIALIZED) - ERROR_NOT_FOUND = Return(nvml.ERROR_NOT_FOUND) - ERROR_INSUFFICIENT_SIZE = Return(nvml.ERROR_INSUFFICIENT_SIZE) - ERROR_INSUFFICIENT_POWER = Return(nvml.ERROR_INSUFFICIENT_POWER) - ERROR_DRIVER_NOT_LOADED = Return(nvml.ERROR_DRIVER_NOT_LOADED) - ERROR_TIMEOUT = Return(nvml.ERROR_TIMEOUT) - ERROR_IRQ_ISSUE = Return(nvml.ERROR_IRQ_ISSUE) - ERROR_LIBRARY_NOT_FOUND = Return(nvml.ERROR_LIBRARY_NOT_FOUND) - ERROR_FUNCTION_NOT_FOUND = Return(nvml.ERROR_FUNCTION_NOT_FOUND) - ERROR_CORRUPTED_INFOROM = Return(nvml.ERROR_CORRUPTED_INFOROM) - ERROR_GPU_IS_LOST = Return(nvml.ERROR_GPU_IS_LOST) - ERROR_RESET_REQUIRED = Return(nvml.ERROR_RESET_REQUIRED) - ERROR_OPERATING_SYSTEM = Return(nvml.ERROR_OPERATING_SYSTEM) - ERROR_LIB_RM_VERSION_MISMATCH = Return(nvml.ERROR_LIB_RM_VERSION_MISMATCH) - ERROR_IN_USE = Return(nvml.ERROR_IN_USE) - ERROR_MEMORY = Return(nvml.ERROR_MEMORY) - ERROR_NO_DATA = Return(nvml.ERROR_NO_DATA) - ERROR_VGPU_ECC_NOT_SUPPORTED = Return(nvml.ERROR_VGPU_ECC_NOT_SUPPORTED) - ERROR_INSUFFICIENT_RESOURCES = Return(nvml.ERROR_INSUFFICIENT_RESOURCES) - ERROR_UNKNOWN = Return(nvml.ERROR_UNKNOWN) -) - -// Device architecture constants -const ( - DEVICE_ARCH_KEPLER = nvml.DEVICE_ARCH_KEPLER - DEVICE_ARCH_MAXWELL = nvml.DEVICE_ARCH_MAXWELL - DEVICE_ARCH_PASCAL = nvml.DEVICE_ARCH_PASCAL - DEVICE_ARCH_VOLTA = nvml.DEVICE_ARCH_VOLTA - DEVICE_ARCH_TURING = nvml.DEVICE_ARCH_TURING - DEVICE_ARCH_AMPERE = nvml.DEVICE_ARCH_AMPERE - DEVICE_ARCH_ADA = nvml.DEVICE_ARCH_ADA - DEVICE_ARCH_HOPPER = nvml.DEVICE_ARCH_HOPPER - DEVICE_ARCH_UNKNOWN = nvml.DEVICE_ARCH_UNKNOWN -) - -// Device brand constants -const ( - BRAND_UNKNOWN = BrandType(nvml.BRAND_UNKNOWN) - BRAND_QUADRO = BrandType(nvml.BRAND_QUADRO) - BRAND_TESLA = BrandType(nvml.BRAND_TESLA) - BRAND_NVS = BrandType(nvml.BRAND_NVS) - BRAND_GRID = BrandType(nvml.BRAND_GRID) - BRAND_GEFORCE = BrandType(nvml.BRAND_GEFORCE) - BRAND_TITAN = BrandType(nvml.BRAND_TITAN) - BRAND_NVIDIA_VAPPS = BrandType(nvml.BRAND_NVIDIA_VAPPS) - BRAND_NVIDIA_VPC = BrandType(nvml.BRAND_NVIDIA_VPC) - BRAND_NVIDIA_VCS = BrandType(nvml.BRAND_NVIDIA_VCS) - BRAND_NVIDIA_VWS = BrandType(nvml.BRAND_NVIDIA_VWS) - BRAND_NVIDIA_CLOUD_GAMING = BrandType(nvml.BRAND_NVIDIA_CLOUD_GAMING) - BRAND_NVIDIA_VGAMING = BrandType(nvml.BRAND_NVIDIA_VGAMING) - BRAND_QUADRO_RTX = BrandType(nvml.BRAND_QUADRO_RTX) - BRAND_NVIDIA_RTX = BrandType(nvml.BRAND_NVIDIA_RTX) - BRAND_NVIDIA = BrandType(nvml.BRAND_NVIDIA) - BRAND_GEFORCE_RTX = BrandType(nvml.BRAND_GEFORCE_RTX) - BRAND_TITAN_RTX = BrandType(nvml.BRAND_TITAN_RTX) - BRAND_COUNT = BrandType(nvml.BRAND_COUNT) -) - -// MIG Mode constants -const ( - DEVICE_MIG_ENABLE = nvml.DEVICE_MIG_ENABLE - DEVICE_MIG_DISABLE = nvml.DEVICE_MIG_DISABLE -) - -// GPU Instance Profiles -const ( - GPU_INSTANCE_PROFILE_1_SLICE = nvml.GPU_INSTANCE_PROFILE_1_SLICE - GPU_INSTANCE_PROFILE_2_SLICE = nvml.GPU_INSTANCE_PROFILE_2_SLICE - GPU_INSTANCE_PROFILE_3_SLICE = nvml.GPU_INSTANCE_PROFILE_3_SLICE - GPU_INSTANCE_PROFILE_4_SLICE = nvml.GPU_INSTANCE_PROFILE_4_SLICE - GPU_INSTANCE_PROFILE_6_SLICE = nvml.GPU_INSTANCE_PROFILE_6_SLICE - GPU_INSTANCE_PROFILE_7_SLICE = nvml.GPU_INSTANCE_PROFILE_7_SLICE - GPU_INSTANCE_PROFILE_8_SLICE = nvml.GPU_INSTANCE_PROFILE_8_SLICE - GPU_INSTANCE_PROFILE_1_SLICE_REV1 = nvml.GPU_INSTANCE_PROFILE_1_SLICE_REV1 - GPU_INSTANCE_PROFILE_1_SLICE_REV2 = nvml.GPU_INSTANCE_PROFILE_1_SLICE_REV2 - GPU_INSTANCE_PROFILE_2_SLICE_REV1 = nvml.GPU_INSTANCE_PROFILE_2_SLICE_REV1 - GPU_INSTANCE_PROFILE_COUNT = nvml.GPU_INSTANCE_PROFILE_COUNT -) - -// Compute Instance Profiles -const ( - COMPUTE_INSTANCE_PROFILE_1_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_1_SLICE - COMPUTE_INSTANCE_PROFILE_2_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_2_SLICE - COMPUTE_INSTANCE_PROFILE_3_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_3_SLICE - COMPUTE_INSTANCE_PROFILE_4_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_4_SLICE - COMPUTE_INSTANCE_PROFILE_6_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_6_SLICE - COMPUTE_INSTANCE_PROFILE_7_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_7_SLICE - COMPUTE_INSTANCE_PROFILE_8_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_8_SLICE - COMPUTE_INSTANCE_PROFILE_1_SLICE_REV1 = nvml.COMPUTE_INSTANCE_PROFILE_1_SLICE_REV1 - COMPUTE_INSTANCE_PROFILE_COUNT = nvml.COMPUTE_INSTANCE_PROFILE_COUNT -) - -// Compute Instance Engine Profiles -const ( - COMPUTE_INSTANCE_ENGINE_PROFILE_SHARED = nvml.COMPUTE_INSTANCE_ENGINE_PROFILE_SHARED - COMPUTE_INSTANCE_ENGINE_PROFILE_COUNT = nvml.COMPUTE_INSTANCE_ENGINE_PROFILE_COUNT -) - -// Event Types -const ( - EventTypeXidCriticalError = nvml.EventTypeXidCriticalError - EventTypeSingleBitEccError = nvml.EventTypeSingleBitEccError - EventTypeDoubleBitEccError = nvml.EventTypeDoubleBitEccError -) - -// GPU Topology enumeration -const ( - TOPOLOGY_INTERNAL = GpuTopologyLevel(nvml.TOPOLOGY_INTERNAL) - TOPOLOGY_SINGLE = GpuTopologyLevel(nvml.TOPOLOGY_SINGLE) - TOPOLOGY_MULTIPLE = GpuTopologyLevel(nvml.TOPOLOGY_MULTIPLE) - TOPOLOGY_HOSTBRIDGE = GpuTopologyLevel(nvml.TOPOLOGY_HOSTBRIDGE) - TOPOLOGY_NODE = GpuTopologyLevel(nvml.TOPOLOGY_NODE) - TOPOLOGY_SYSTEM = GpuTopologyLevel(nvml.TOPOLOGY_SYSTEM) -) - -// Generic enable/disable constants -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) -) diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go deleted file mode 100644 index 777a9daa..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go +++ /dev/null @@ -1,215 +0,0 @@ -/** -# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -**/ - -package nvml - -import "github.com/NVIDIA/go-nvml/pkg/nvml" - -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() - return i, Return(r) -} - -// GetPciInfo returns the PCI info of a Device -func (d nvmlDevice) GetPciInfo() (PciInfo, Return) { - p, r := nvml.Device(d).GetPciInfo() - return PciInfo(p), Return(r) -} - -// GetMemoryInfo returns the memory info of a Device -func (d nvmlDevice) GetMemoryInfo() (Memory, Return) { - p, r := nvml.Device(d).GetMemoryInfo() - return Memory(p), Return(r) -} - -// GetUUID returns the UUID of a Device -func (d nvmlDevice) GetUUID() (string, Return) { - u, r := nvml.Device(d).GetUUID() - return u, Return(r) -} - -// GetMinorNumber returns the minor number of a Device -func (d nvmlDevice) GetMinorNumber() (int, Return) { - m, r := nvml.Device(d).GetMinorNumber() - return m, Return(r) -} - -// IsMigDeviceHandle returns whether a Device is a MIG device or not -func (d nvmlDevice) IsMigDeviceHandle() (bool, Return) { - b, r := nvml.Device(d).IsMigDeviceHandle() - return b, Return(r) -} - -// GetDeviceHandleFromMigDeviceHandle returns the parent Device of a MIG device -func (d nvmlDevice) GetDeviceHandleFromMigDeviceHandle() (Device, Return) { - p, r := nvml.Device(d).GetDeviceHandleFromMigDeviceHandle() - return nvmlDevice(p), Return(r) -} - -// SetMigMode sets the MIG mode of a Device -func (d nvmlDevice) SetMigMode(mode int) (Return, Return) { - r1, r2 := nvml.Device(d).SetMigMode(mode) - return Return(r1), Return(r2) -} - -// GetMigMode returns the MIG mode of a Device -func (d nvmlDevice) GetMigMode() (int, int, Return) { - s1, s2, r := nvml.Device(d).GetMigMode() - return s1, s2, Return(r) -} - -// GetGpuInstanceById returns the GPU Instance associated with a particular ID -func (d nvmlDevice) GetGpuInstanceById(id int) (GpuInstance, Return) { - gi, r := nvml.Device(d).GetGpuInstanceById(id) - return nvmlGpuInstance(gi), Return(r) -} - -// GetGpuInstanceProfileInfo returns the profile info of a GPU Instance -func (d nvmlDevice) GetGpuInstanceProfileInfo(profile int) (GpuInstanceProfileInfo, Return) { - p, r := nvml.Device(d).GetGpuInstanceProfileInfo(profile) - return GpuInstanceProfileInfo(p), Return(r) -} - -// GetGpuInstancePossiblePlacements returns the possible placements of a GPU Instance -func (d nvmlDevice) GetGpuInstancePossiblePlacements(info *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) { - nvmlPlacements, r := nvml.Device(d).GetGpuInstancePossiblePlacements((*nvml.GpuInstanceProfileInfo)(info)) - var placements []GpuInstancePlacement - for _, p := range nvmlPlacements { - placements = append(placements, GpuInstancePlacement(p)) - } - return placements, Return(r) -} - -// GetGpuInstances returns the set of GPU Instances associated with a Device -func (d nvmlDevice) GetGpuInstances(info *GpuInstanceProfileInfo) ([]GpuInstance, Return) { - nvmlGis, r := nvml.Device(d).GetGpuInstances((*nvml.GpuInstanceProfileInfo)(info)) - var gis []GpuInstance - for _, gi := range nvmlGis { - gis = append(gis, nvmlGpuInstance(gi)) - } - return gis, Return(r) -} - -// CreateGpuInstanceWithPlacement creates a GPU Instance with a specific placement -func (d nvmlDevice) CreateGpuInstanceWithPlacement(info *GpuInstanceProfileInfo, placement *GpuInstancePlacement) (GpuInstance, Return) { - gi, r := nvml.Device(d).CreateGpuInstanceWithPlacement((*nvml.GpuInstanceProfileInfo)(info), (*nvml.GpuInstancePlacement)(placement)) - return nvmlGpuInstance(gi), Return(r) -} - -// GetMaxMigDeviceCount returns the maximum number of MIG devices that can be created on a Device -func (d nvmlDevice) GetMaxMigDeviceCount() (int, Return) { - m, r := nvml.Device(d).GetMaxMigDeviceCount() - return m, Return(r) -} - -// GetMigDeviceHandleByIndex returns the handle to a MIG device given its index -func (d nvmlDevice) GetMigDeviceHandleByIndex(Index int) (Device, Return) { - h, r := nvml.Device(d).GetMigDeviceHandleByIndex(Index) - return nvmlDevice(h), Return(r) -} - -// GetGpuInstanceId returns the GPU Instance ID of a MIG device -func (d nvmlDevice) GetGpuInstanceId() (int, Return) { - gi, r := nvml.Device(d).GetGpuInstanceId() - return gi, Return(r) -} - -// GetComputeInstanceId returns the Compute Instance ID of a MIG device -func (d nvmlDevice) GetComputeInstanceId() (int, Return) { - ci, r := nvml.Device(d).GetComputeInstanceId() - return ci, Return(r) -} - -// GetCudaComputeCapability returns the compute capability major and minor versions for a device -func (d nvmlDevice) GetCudaComputeCapability() (int, int, Return) { - major, minor, r := nvml.Device(d).GetCudaComputeCapability() - return major, minor, Return(r) -} - -// GetAttributes returns the device attributes for a MIG device -func (d nvmlDevice) GetAttributes() (DeviceAttributes, Return) { - a, r := nvml.Device(d).GetAttributes() - return DeviceAttributes(a), Return(r) -} - -// GetName returns the product name of a Device -func (d nvmlDevice) GetName() (string, Return) { - n, r := nvml.Device(d).GetName() - return n, Return(r) -} - -// GetBrand returns the brand of a Device -func (d nvmlDevice) GetBrand() (BrandType, Return) { - b, r := nvml.Device(d).GetBrand() - return BrandType(b), Return(r) -} - -// GetArchitecture returns the architecture of a Device -func (d nvmlDevice) GetArchitecture() (DeviceArchitecture, Return) { - a, r := nvml.Device(d).GetArchitecture() - return DeviceArchitecture(a), Return(r) -} - -// RegisterEvents registers the specified event set and type with the device -func (d nvmlDevice) RegisterEvents(EventTypes uint64, Set EventSet) Return { - return Return(nvml.Device(d).RegisterEvents(EventTypes, nvml.EventSet(Set))) -} - -// GetSupportedEventTypes returns the events supported by the device -func (d nvmlDevice) GetSupportedEventTypes() (uint64, Return) { - e, r := nvml.Device(d).GetSupportedEventTypes() - return e, Return(r) -} - -// GetTopologyCommonAncestor retrieves the common ancestor for two devices. -func (d nvmlDevice) GetTopologyCommonAncestor(o Device) (GpuTopologyLevel, Return) { - other := o.nvmlDeviceHandle() - if other == nil { - return 0, ERROR_INVALID_ARGUMENT - } - - l, r := nvml.Device(d).GetTopologyCommonAncestor(*other) - return GpuTopologyLevel(l), Return(r) -} - -// GetNvLinkState retrieves the state of the device's NvLink for the link specified. -func (d nvmlDevice) GetNvLinkState(link int) (EnableState, Return) { - s, r := nvml.Device(d).GetNvLinkState(link) - return EnableState(s), Return(r) -} - -// GetNvLinkRemotePciInfo retrieves the PCI information for the remote node on a NvLink link. -// Note: pciSubSystemId is not filled in this function and is indeterminate. -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) -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device_mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device_mock.go deleted file mode 100644 index 84f14722..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device_mock.go +++ /dev/null @@ -1,1237 +0,0 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq - -package nvml - -import ( - "github.com/NVIDIA/go-nvml/pkg/nvml" - "sync" -) - -// Ensure, that DeviceMock does implement Device. -// If this is not the case, regenerate this file with moq. -var _ Device = &DeviceMock{} - -// DeviceMock is a mock implementation of Device. -// -// func TestSomethingThatUsesDevice(t *testing.T) { -// -// // make and configure a mocked Device -// mockedDevice := &DeviceMock{ -// CreateGpuInstanceWithPlacementFunc: func(gpuInstanceProfileInfo *GpuInstanceProfileInfo, gpuInstancePlacement *GpuInstancePlacement) (GpuInstance, Return) { -// panic("mock out the CreateGpuInstanceWithPlacement method") -// }, -// GetArchitectureFunc: func() (DeviceArchitecture, Return) { -// panic("mock out the GetArchitecture method") -// }, -// GetAttributesFunc: func() (DeviceAttributes, Return) { -// panic("mock out the GetAttributes method") -// }, -// GetBrandFunc: func() (BrandType, Return) { -// panic("mock out the GetBrand method") -// }, -// GetComputeInstanceIdFunc: func() (int, Return) { -// panic("mock out the GetComputeInstanceId method") -// }, -// GetCudaComputeCapabilityFunc: func() (int, int, Return) { -// panic("mock out the GetCudaComputeCapability method") -// }, -// GetDeviceHandleFromMigDeviceHandleFunc: func() (Device, Return) { -// panic("mock out the GetDeviceHandleFromMigDeviceHandle method") -// }, -// GetGpuInstanceByIdFunc: func(ID int) (GpuInstance, Return) { -// panic("mock out the GetGpuInstanceById method") -// }, -// GetGpuInstanceIdFunc: func() (int, Return) { -// panic("mock out the GetGpuInstanceId method") -// }, -// GetGpuInstancePossiblePlacementsFunc: func(gpuInstanceProfileInfo *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) { -// panic("mock out the GetGpuInstancePossiblePlacements method") -// }, -// GetGpuInstanceProfileInfoFunc: func(Profile int) (GpuInstanceProfileInfo, Return) { -// panic("mock out the GetGpuInstanceProfileInfo method") -// }, -// GetGpuInstancesFunc: func(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return) { -// panic("mock out the GetGpuInstances method") -// }, -// GetIndexFunc: func() (int, Return) { -// panic("mock out the GetIndex method") -// }, -// GetMaxMigDeviceCountFunc: func() (int, Return) { -// panic("mock out the GetMaxMigDeviceCount method") -// }, -// GetMemoryInfoFunc: func() (Memory, Return) { -// panic("mock out the GetMemoryInfo method") -// }, -// GetMigDeviceHandleByIndexFunc: func(Index int) (Device, Return) { -// panic("mock out the GetMigDeviceHandleByIndex method") -// }, -// GetMigModeFunc: func() (int, int, Return) { -// panic("mock out the GetMigMode method") -// }, -// GetMinorNumberFunc: func() (int, Return) { -// panic("mock out the GetMinorNumber method") -// }, -// GetNameFunc: func() (string, Return) { -// panic("mock out the GetName method") -// }, -// GetNvLinkRemotePciInfoFunc: func(n int) (PciInfo, Return) { -// panic("mock out the GetNvLinkRemotePciInfo method") -// }, -// GetNvLinkStateFunc: func(n int) (EnableState, Return) { -// panic("mock out the GetNvLinkState method") -// }, -// GetPciInfoFunc: func() (PciInfo, Return) { -// panic("mock out the GetPciInfo method") -// }, -// GetSupportedEventTypesFunc: func() (uint64, Return) { -// panic("mock out the GetSupportedEventTypes method") -// }, -// GetTopologyCommonAncestorFunc: func(device Device) (GpuTopologyLevel, Return) { -// panic("mock out the GetTopologyCommonAncestor method") -// }, -// GetUUIDFunc: func() (string, Return) { -// panic("mock out the GetUUID method") -// }, -// IsMigDeviceHandleFunc: func() (bool, Return) { -// panic("mock out the IsMigDeviceHandle method") -// }, -// 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 -// // and then make assertions. -// -// } -type DeviceMock struct { - // CreateGpuInstanceWithPlacementFunc mocks the CreateGpuInstanceWithPlacement method. - CreateGpuInstanceWithPlacementFunc func(gpuInstanceProfileInfo *GpuInstanceProfileInfo, gpuInstancePlacement *GpuInstancePlacement) (GpuInstance, Return) - - // GetArchitectureFunc mocks the GetArchitecture method. - GetArchitectureFunc func() (DeviceArchitecture, Return) - - // GetAttributesFunc mocks the GetAttributes method. - GetAttributesFunc func() (DeviceAttributes, Return) - - // GetBrandFunc mocks the GetBrand method. - GetBrandFunc func() (BrandType, Return) - - // GetComputeInstanceIdFunc mocks the GetComputeInstanceId method. - GetComputeInstanceIdFunc func() (int, Return) - - // GetCudaComputeCapabilityFunc mocks the GetCudaComputeCapability method. - GetCudaComputeCapabilityFunc func() (int, int, Return) - - // GetDeviceHandleFromMigDeviceHandleFunc mocks the GetDeviceHandleFromMigDeviceHandle method. - GetDeviceHandleFromMigDeviceHandleFunc func() (Device, Return) - - // GetGpuInstanceByIdFunc mocks the GetGpuInstanceById method. - GetGpuInstanceByIdFunc func(ID int) (GpuInstance, Return) - - // GetGpuInstanceIdFunc mocks the GetGpuInstanceId method. - GetGpuInstanceIdFunc func() (int, Return) - - // GetGpuInstancePossiblePlacementsFunc mocks the GetGpuInstancePossiblePlacements method. - GetGpuInstancePossiblePlacementsFunc func(gpuInstanceProfileInfo *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) - - // GetGpuInstanceProfileInfoFunc mocks the GetGpuInstanceProfileInfo method. - GetGpuInstanceProfileInfoFunc func(Profile int) (GpuInstanceProfileInfo, Return) - - // GetGpuInstancesFunc mocks the GetGpuInstances method. - GetGpuInstancesFunc func(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return) - - // GetIndexFunc mocks the GetIndex method. - GetIndexFunc func() (int, Return) - - // GetMaxMigDeviceCountFunc mocks the GetMaxMigDeviceCount method. - GetMaxMigDeviceCountFunc func() (int, Return) - - // GetMemoryInfoFunc mocks the GetMemoryInfo method. - GetMemoryInfoFunc func() (Memory, Return) - - // GetMigDeviceHandleByIndexFunc mocks the GetMigDeviceHandleByIndex method. - GetMigDeviceHandleByIndexFunc func(Index int) (Device, Return) - - // GetMigModeFunc mocks the GetMigMode method. - GetMigModeFunc func() (int, int, Return) - - // GetMinorNumberFunc mocks the GetMinorNumber method. - GetMinorNumberFunc func() (int, Return) - - // GetNameFunc mocks the GetName method. - GetNameFunc func() (string, Return) - - // GetNvLinkRemotePciInfoFunc mocks the GetNvLinkRemotePciInfo method. - GetNvLinkRemotePciInfoFunc func(n int) (PciInfo, Return) - - // GetNvLinkStateFunc mocks the GetNvLinkState method. - GetNvLinkStateFunc func(n int) (EnableState, Return) - - // GetPciInfoFunc mocks the GetPciInfo method. - GetPciInfoFunc func() (PciInfo, Return) - - // GetSupportedEventTypesFunc mocks the GetSupportedEventTypes method. - GetSupportedEventTypesFunc func() (uint64, Return) - - // GetTopologyCommonAncestorFunc mocks the GetTopologyCommonAncestor method. - GetTopologyCommonAncestorFunc func(device Device) (GpuTopologyLevel, Return) - - // GetUUIDFunc mocks the GetUUID method. - GetUUIDFunc func() (string, Return) - - // IsMigDeviceHandleFunc mocks the IsMigDeviceHandle method. - IsMigDeviceHandleFunc func() (bool, Return) - - // 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. - CreateGpuInstanceWithPlacement []struct { - // GpuInstanceProfileInfo is the gpuInstanceProfileInfo argument value. - GpuInstanceProfileInfo *GpuInstanceProfileInfo - // GpuInstancePlacement is the gpuInstancePlacement argument value. - GpuInstancePlacement *GpuInstancePlacement - } - // GetArchitecture holds details about calls to the GetArchitecture method. - GetArchitecture []struct { - } - // GetAttributes holds details about calls to the GetAttributes method. - GetAttributes []struct { - } - // GetBrand holds details about calls to the GetBrand method. - GetBrand []struct { - } - // GetComputeInstanceId holds details about calls to the GetComputeInstanceId method. - GetComputeInstanceId []struct { - } - // GetCudaComputeCapability holds details about calls to the GetCudaComputeCapability method. - GetCudaComputeCapability []struct { - } - // GetDeviceHandleFromMigDeviceHandle holds details about calls to the GetDeviceHandleFromMigDeviceHandle method. - GetDeviceHandleFromMigDeviceHandle []struct { - } - // GetGpuInstanceById holds details about calls to the GetGpuInstanceById method. - GetGpuInstanceById []struct { - // ID is the ID argument value. - ID int - } - // GetGpuInstanceId holds details about calls to the GetGpuInstanceId method. - GetGpuInstanceId []struct { - } - // GetGpuInstancePossiblePlacements holds details about calls to the GetGpuInstancePossiblePlacements method. - GetGpuInstancePossiblePlacements []struct { - // GpuInstanceProfileInfo is the gpuInstanceProfileInfo argument value. - GpuInstanceProfileInfo *GpuInstanceProfileInfo - } - // GetGpuInstanceProfileInfo holds details about calls to the GetGpuInstanceProfileInfo method. - GetGpuInstanceProfileInfo []struct { - // Profile is the Profile argument value. - Profile int - } - // GetGpuInstances holds details about calls to the GetGpuInstances method. - GetGpuInstances []struct { - // Info is the Info argument value. - Info *GpuInstanceProfileInfo - } - // GetIndex holds details about calls to the GetIndex method. - GetIndex []struct { - } - // GetMaxMigDeviceCount holds details about calls to the GetMaxMigDeviceCount method. - GetMaxMigDeviceCount []struct { - } - // GetMemoryInfo holds details about calls to the GetMemoryInfo method. - GetMemoryInfo []struct { - } - // GetMigDeviceHandleByIndex holds details about calls to the GetMigDeviceHandleByIndex method. - GetMigDeviceHandleByIndex []struct { - // Index is the Index argument value. - Index int - } - // GetMigMode holds details about calls to the GetMigMode method. - GetMigMode []struct { - } - // GetMinorNumber holds details about calls to the GetMinorNumber method. - GetMinorNumber []struct { - } - // GetName holds details about calls to the GetName method. - GetName []struct { - } - // GetNvLinkRemotePciInfo holds details about calls to the GetNvLinkRemotePciInfo method. - GetNvLinkRemotePciInfo []struct { - // N is the n argument value. - N int - } - // GetNvLinkState holds details about calls to the GetNvLinkState method. - GetNvLinkState []struct { - // N is the n argument value. - N int - } - // GetPciInfo holds details about calls to the GetPciInfo method. - GetPciInfo []struct { - } - // GetSupportedEventTypes holds details about calls to the GetSupportedEventTypes method. - GetSupportedEventTypes []struct { - } - // GetTopologyCommonAncestor holds details about calls to the GetTopologyCommonAncestor method. - GetTopologyCommonAncestor []struct { - // Device is the device argument value. - Device Device - } - // GetUUID holds details about calls to the GetUUID method. - GetUUID []struct { - } - // IsMigDeviceHandle holds details about calls to the IsMigDeviceHandle method. - IsMigDeviceHandle []struct { - } - // RegisterEvents holds details about calls to the RegisterEvents method. - RegisterEvents []struct { - // V is the v argument value. - V uint64 - // 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 - lockGetAttributes sync.RWMutex - lockGetBrand sync.RWMutex - lockGetComputeInstanceId sync.RWMutex - lockGetCudaComputeCapability sync.RWMutex - lockGetDeviceHandleFromMigDeviceHandle sync.RWMutex - lockGetGpuInstanceById sync.RWMutex - lockGetGpuInstanceId sync.RWMutex - lockGetGpuInstancePossiblePlacements sync.RWMutex - lockGetGpuInstanceProfileInfo sync.RWMutex - lockGetGpuInstances sync.RWMutex - lockGetIndex sync.RWMutex - lockGetMaxMigDeviceCount sync.RWMutex - lockGetMemoryInfo sync.RWMutex - lockGetMigDeviceHandleByIndex sync.RWMutex - lockGetMigMode sync.RWMutex - lockGetMinorNumber sync.RWMutex - lockGetName sync.RWMutex - lockGetNvLinkRemotePciInfo sync.RWMutex - lockGetNvLinkState sync.RWMutex - lockGetPciInfo sync.RWMutex - lockGetSupportedEventTypes sync.RWMutex - lockGetTopologyCommonAncestor sync.RWMutex - lockGetUUID sync.RWMutex - lockIsMigDeviceHandle sync.RWMutex - lockRegisterEvents sync.RWMutex - lockSetComputeMode sync.RWMutex - lockSetMigMode sync.RWMutex - locknvmlDeviceHandle sync.RWMutex -} - -// CreateGpuInstanceWithPlacement calls CreateGpuInstanceWithPlacementFunc. -func (mock *DeviceMock) CreateGpuInstanceWithPlacement(gpuInstanceProfileInfo *GpuInstanceProfileInfo, gpuInstancePlacement *GpuInstancePlacement) (GpuInstance, Return) { - if mock.CreateGpuInstanceWithPlacementFunc == nil { - panic("DeviceMock.CreateGpuInstanceWithPlacementFunc: method is nil but Device.CreateGpuInstanceWithPlacement was just called") - } - callInfo := struct { - GpuInstanceProfileInfo *GpuInstanceProfileInfo - GpuInstancePlacement *GpuInstancePlacement - }{ - GpuInstanceProfileInfo: gpuInstanceProfileInfo, - GpuInstancePlacement: gpuInstancePlacement, - } - mock.lockCreateGpuInstanceWithPlacement.Lock() - mock.calls.CreateGpuInstanceWithPlacement = append(mock.calls.CreateGpuInstanceWithPlacement, callInfo) - mock.lockCreateGpuInstanceWithPlacement.Unlock() - return mock.CreateGpuInstanceWithPlacementFunc(gpuInstanceProfileInfo, gpuInstancePlacement) -} - -// CreateGpuInstanceWithPlacementCalls gets all the calls that were made to CreateGpuInstanceWithPlacement. -// Check the length with: -// -// len(mockedDevice.CreateGpuInstanceWithPlacementCalls()) -func (mock *DeviceMock) CreateGpuInstanceWithPlacementCalls() []struct { - GpuInstanceProfileInfo *GpuInstanceProfileInfo - GpuInstancePlacement *GpuInstancePlacement -} { - var calls []struct { - GpuInstanceProfileInfo *GpuInstanceProfileInfo - GpuInstancePlacement *GpuInstancePlacement - } - mock.lockCreateGpuInstanceWithPlacement.RLock() - calls = mock.calls.CreateGpuInstanceWithPlacement - mock.lockCreateGpuInstanceWithPlacement.RUnlock() - return calls -} - -// GetArchitecture calls GetArchitectureFunc. -func (mock *DeviceMock) GetArchitecture() (DeviceArchitecture, Return) { - if mock.GetArchitectureFunc == nil { - panic("DeviceMock.GetArchitectureFunc: method is nil but Device.GetArchitecture was just called") - } - callInfo := struct { - }{} - mock.lockGetArchitecture.Lock() - mock.calls.GetArchitecture = append(mock.calls.GetArchitecture, callInfo) - mock.lockGetArchitecture.Unlock() - return mock.GetArchitectureFunc() -} - -// GetArchitectureCalls gets all the calls that were made to GetArchitecture. -// Check the length with: -// -// len(mockedDevice.GetArchitectureCalls()) -func (mock *DeviceMock) GetArchitectureCalls() []struct { -} { - var calls []struct { - } - mock.lockGetArchitecture.RLock() - calls = mock.calls.GetArchitecture - mock.lockGetArchitecture.RUnlock() - return calls -} - -// GetAttributes calls GetAttributesFunc. -func (mock *DeviceMock) GetAttributes() (DeviceAttributes, Return) { - if mock.GetAttributesFunc == nil { - panic("DeviceMock.GetAttributesFunc: method is nil but Device.GetAttributes was just called") - } - callInfo := struct { - }{} - mock.lockGetAttributes.Lock() - mock.calls.GetAttributes = append(mock.calls.GetAttributes, callInfo) - mock.lockGetAttributes.Unlock() - return mock.GetAttributesFunc() -} - -// GetAttributesCalls gets all the calls that were made to GetAttributes. -// Check the length with: -// -// len(mockedDevice.GetAttributesCalls()) -func (mock *DeviceMock) GetAttributesCalls() []struct { -} { - var calls []struct { - } - mock.lockGetAttributes.RLock() - calls = mock.calls.GetAttributes - mock.lockGetAttributes.RUnlock() - return calls -} - -// GetBrand calls GetBrandFunc. -func (mock *DeviceMock) GetBrand() (BrandType, Return) { - if mock.GetBrandFunc == nil { - panic("DeviceMock.GetBrandFunc: method is nil but Device.GetBrand was just called") - } - callInfo := struct { - }{} - mock.lockGetBrand.Lock() - mock.calls.GetBrand = append(mock.calls.GetBrand, callInfo) - mock.lockGetBrand.Unlock() - return mock.GetBrandFunc() -} - -// GetBrandCalls gets all the calls that were made to GetBrand. -// Check the length with: -// -// len(mockedDevice.GetBrandCalls()) -func (mock *DeviceMock) GetBrandCalls() []struct { -} { - var calls []struct { - } - mock.lockGetBrand.RLock() - calls = mock.calls.GetBrand - mock.lockGetBrand.RUnlock() - return calls -} - -// GetComputeInstanceId calls GetComputeInstanceIdFunc. -func (mock *DeviceMock) GetComputeInstanceId() (int, Return) { - if mock.GetComputeInstanceIdFunc == nil { - panic("DeviceMock.GetComputeInstanceIdFunc: method is nil but Device.GetComputeInstanceId was just called") - } - callInfo := struct { - }{} - mock.lockGetComputeInstanceId.Lock() - mock.calls.GetComputeInstanceId = append(mock.calls.GetComputeInstanceId, callInfo) - mock.lockGetComputeInstanceId.Unlock() - return mock.GetComputeInstanceIdFunc() -} - -// GetComputeInstanceIdCalls gets all the calls that were made to GetComputeInstanceId. -// Check the length with: -// -// len(mockedDevice.GetComputeInstanceIdCalls()) -func (mock *DeviceMock) GetComputeInstanceIdCalls() []struct { -} { - var calls []struct { - } - mock.lockGetComputeInstanceId.RLock() - calls = mock.calls.GetComputeInstanceId - mock.lockGetComputeInstanceId.RUnlock() - return calls -} - -// GetCudaComputeCapability calls GetCudaComputeCapabilityFunc. -func (mock *DeviceMock) GetCudaComputeCapability() (int, int, Return) { - if mock.GetCudaComputeCapabilityFunc == nil { - panic("DeviceMock.GetCudaComputeCapabilityFunc: method is nil but Device.GetCudaComputeCapability was just called") - } - callInfo := struct { - }{} - mock.lockGetCudaComputeCapability.Lock() - mock.calls.GetCudaComputeCapability = append(mock.calls.GetCudaComputeCapability, callInfo) - mock.lockGetCudaComputeCapability.Unlock() - return mock.GetCudaComputeCapabilityFunc() -} - -// GetCudaComputeCapabilityCalls gets all the calls that were made to GetCudaComputeCapability. -// Check the length with: -// -// len(mockedDevice.GetCudaComputeCapabilityCalls()) -func (mock *DeviceMock) GetCudaComputeCapabilityCalls() []struct { -} { - var calls []struct { - } - mock.lockGetCudaComputeCapability.RLock() - calls = mock.calls.GetCudaComputeCapability - mock.lockGetCudaComputeCapability.RUnlock() - return calls -} - -// GetDeviceHandleFromMigDeviceHandle calls GetDeviceHandleFromMigDeviceHandleFunc. -func (mock *DeviceMock) GetDeviceHandleFromMigDeviceHandle() (Device, Return) { - if mock.GetDeviceHandleFromMigDeviceHandleFunc == nil { - panic("DeviceMock.GetDeviceHandleFromMigDeviceHandleFunc: method is nil but Device.GetDeviceHandleFromMigDeviceHandle was just called") - } - callInfo := struct { - }{} - mock.lockGetDeviceHandleFromMigDeviceHandle.Lock() - mock.calls.GetDeviceHandleFromMigDeviceHandle = append(mock.calls.GetDeviceHandleFromMigDeviceHandle, callInfo) - mock.lockGetDeviceHandleFromMigDeviceHandle.Unlock() - return mock.GetDeviceHandleFromMigDeviceHandleFunc() -} - -// GetDeviceHandleFromMigDeviceHandleCalls gets all the calls that were made to GetDeviceHandleFromMigDeviceHandle. -// Check the length with: -// -// len(mockedDevice.GetDeviceHandleFromMigDeviceHandleCalls()) -func (mock *DeviceMock) GetDeviceHandleFromMigDeviceHandleCalls() []struct { -} { - var calls []struct { - } - mock.lockGetDeviceHandleFromMigDeviceHandle.RLock() - calls = mock.calls.GetDeviceHandleFromMigDeviceHandle - mock.lockGetDeviceHandleFromMigDeviceHandle.RUnlock() - return calls -} - -// GetGpuInstanceById calls GetGpuInstanceByIdFunc. -func (mock *DeviceMock) GetGpuInstanceById(ID int) (GpuInstance, Return) { - if mock.GetGpuInstanceByIdFunc == nil { - panic("DeviceMock.GetGpuInstanceByIdFunc: method is nil but Device.GetGpuInstanceById was just called") - } - callInfo := struct { - ID int - }{ - ID: ID, - } - mock.lockGetGpuInstanceById.Lock() - mock.calls.GetGpuInstanceById = append(mock.calls.GetGpuInstanceById, callInfo) - mock.lockGetGpuInstanceById.Unlock() - return mock.GetGpuInstanceByIdFunc(ID) -} - -// GetGpuInstanceByIdCalls gets all the calls that were made to GetGpuInstanceById. -// Check the length with: -// -// len(mockedDevice.GetGpuInstanceByIdCalls()) -func (mock *DeviceMock) GetGpuInstanceByIdCalls() []struct { - ID int -} { - var calls []struct { - ID int - } - mock.lockGetGpuInstanceById.RLock() - calls = mock.calls.GetGpuInstanceById - mock.lockGetGpuInstanceById.RUnlock() - return calls -} - -// GetGpuInstanceId calls GetGpuInstanceIdFunc. -func (mock *DeviceMock) GetGpuInstanceId() (int, Return) { - if mock.GetGpuInstanceIdFunc == nil { - panic("DeviceMock.GetGpuInstanceIdFunc: method is nil but Device.GetGpuInstanceId was just called") - } - callInfo := struct { - }{} - mock.lockGetGpuInstanceId.Lock() - mock.calls.GetGpuInstanceId = append(mock.calls.GetGpuInstanceId, callInfo) - mock.lockGetGpuInstanceId.Unlock() - return mock.GetGpuInstanceIdFunc() -} - -// GetGpuInstanceIdCalls gets all the calls that were made to GetGpuInstanceId. -// Check the length with: -// -// len(mockedDevice.GetGpuInstanceIdCalls()) -func (mock *DeviceMock) GetGpuInstanceIdCalls() []struct { -} { - var calls []struct { - } - mock.lockGetGpuInstanceId.RLock() - calls = mock.calls.GetGpuInstanceId - mock.lockGetGpuInstanceId.RUnlock() - return calls -} - -// GetGpuInstancePossiblePlacements calls GetGpuInstancePossiblePlacementsFunc. -func (mock *DeviceMock) GetGpuInstancePossiblePlacements(gpuInstanceProfileInfo *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) { - if mock.GetGpuInstancePossiblePlacementsFunc == nil { - panic("DeviceMock.GetGpuInstancePossiblePlacementsFunc: method is nil but Device.GetGpuInstancePossiblePlacements was just called") - } - callInfo := struct { - GpuInstanceProfileInfo *GpuInstanceProfileInfo - }{ - GpuInstanceProfileInfo: gpuInstanceProfileInfo, - } - mock.lockGetGpuInstancePossiblePlacements.Lock() - mock.calls.GetGpuInstancePossiblePlacements = append(mock.calls.GetGpuInstancePossiblePlacements, callInfo) - mock.lockGetGpuInstancePossiblePlacements.Unlock() - return mock.GetGpuInstancePossiblePlacementsFunc(gpuInstanceProfileInfo) -} - -// GetGpuInstancePossiblePlacementsCalls gets all the calls that were made to GetGpuInstancePossiblePlacements. -// Check the length with: -// -// len(mockedDevice.GetGpuInstancePossiblePlacementsCalls()) -func (mock *DeviceMock) GetGpuInstancePossiblePlacementsCalls() []struct { - GpuInstanceProfileInfo *GpuInstanceProfileInfo -} { - var calls []struct { - GpuInstanceProfileInfo *GpuInstanceProfileInfo - } - mock.lockGetGpuInstancePossiblePlacements.RLock() - calls = mock.calls.GetGpuInstancePossiblePlacements - mock.lockGetGpuInstancePossiblePlacements.RUnlock() - return calls -} - -// GetGpuInstanceProfileInfo calls GetGpuInstanceProfileInfoFunc. -func (mock *DeviceMock) GetGpuInstanceProfileInfo(Profile int) (GpuInstanceProfileInfo, Return) { - if mock.GetGpuInstanceProfileInfoFunc == nil { - panic("DeviceMock.GetGpuInstanceProfileInfoFunc: method is nil but Device.GetGpuInstanceProfileInfo was just called") - } - callInfo := struct { - Profile int - }{ - Profile: Profile, - } - mock.lockGetGpuInstanceProfileInfo.Lock() - mock.calls.GetGpuInstanceProfileInfo = append(mock.calls.GetGpuInstanceProfileInfo, callInfo) - mock.lockGetGpuInstanceProfileInfo.Unlock() - return mock.GetGpuInstanceProfileInfoFunc(Profile) -} - -// GetGpuInstanceProfileInfoCalls gets all the calls that were made to GetGpuInstanceProfileInfo. -// Check the length with: -// -// len(mockedDevice.GetGpuInstanceProfileInfoCalls()) -func (mock *DeviceMock) GetGpuInstanceProfileInfoCalls() []struct { - Profile int -} { - var calls []struct { - Profile int - } - mock.lockGetGpuInstanceProfileInfo.RLock() - calls = mock.calls.GetGpuInstanceProfileInfo - mock.lockGetGpuInstanceProfileInfo.RUnlock() - return calls -} - -// GetGpuInstances calls GetGpuInstancesFunc. -func (mock *DeviceMock) GetGpuInstances(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return) { - if mock.GetGpuInstancesFunc == nil { - panic("DeviceMock.GetGpuInstancesFunc: method is nil but Device.GetGpuInstances was just called") - } - callInfo := struct { - Info *GpuInstanceProfileInfo - }{ - Info: Info, - } - mock.lockGetGpuInstances.Lock() - mock.calls.GetGpuInstances = append(mock.calls.GetGpuInstances, callInfo) - mock.lockGetGpuInstances.Unlock() - return mock.GetGpuInstancesFunc(Info) -} - -// GetGpuInstancesCalls gets all the calls that were made to GetGpuInstances. -// Check the length with: -// -// len(mockedDevice.GetGpuInstancesCalls()) -func (mock *DeviceMock) GetGpuInstancesCalls() []struct { - Info *GpuInstanceProfileInfo -} { - var calls []struct { - Info *GpuInstanceProfileInfo - } - mock.lockGetGpuInstances.RLock() - calls = mock.calls.GetGpuInstances - mock.lockGetGpuInstances.RUnlock() - return calls -} - -// GetIndex calls GetIndexFunc. -func (mock *DeviceMock) GetIndex() (int, Return) { - if mock.GetIndexFunc == nil { - panic("DeviceMock.GetIndexFunc: method is nil but Device.GetIndex was just called") - } - callInfo := struct { - }{} - mock.lockGetIndex.Lock() - mock.calls.GetIndex = append(mock.calls.GetIndex, callInfo) - mock.lockGetIndex.Unlock() - return mock.GetIndexFunc() -} - -// GetIndexCalls gets all the calls that were made to GetIndex. -// Check the length with: -// -// len(mockedDevice.GetIndexCalls()) -func (mock *DeviceMock) GetIndexCalls() []struct { -} { - var calls []struct { - } - mock.lockGetIndex.RLock() - calls = mock.calls.GetIndex - mock.lockGetIndex.RUnlock() - return calls -} - -// GetMaxMigDeviceCount calls GetMaxMigDeviceCountFunc. -func (mock *DeviceMock) GetMaxMigDeviceCount() (int, Return) { - if mock.GetMaxMigDeviceCountFunc == nil { - panic("DeviceMock.GetMaxMigDeviceCountFunc: method is nil but Device.GetMaxMigDeviceCount was just called") - } - callInfo := struct { - }{} - mock.lockGetMaxMigDeviceCount.Lock() - mock.calls.GetMaxMigDeviceCount = append(mock.calls.GetMaxMigDeviceCount, callInfo) - mock.lockGetMaxMigDeviceCount.Unlock() - return mock.GetMaxMigDeviceCountFunc() -} - -// GetMaxMigDeviceCountCalls gets all the calls that were made to GetMaxMigDeviceCount. -// Check the length with: -// -// len(mockedDevice.GetMaxMigDeviceCountCalls()) -func (mock *DeviceMock) GetMaxMigDeviceCountCalls() []struct { -} { - var calls []struct { - } - mock.lockGetMaxMigDeviceCount.RLock() - calls = mock.calls.GetMaxMigDeviceCount - mock.lockGetMaxMigDeviceCount.RUnlock() - return calls -} - -// GetMemoryInfo calls GetMemoryInfoFunc. -func (mock *DeviceMock) GetMemoryInfo() (Memory, Return) { - if mock.GetMemoryInfoFunc == nil { - panic("DeviceMock.GetMemoryInfoFunc: method is nil but Device.GetMemoryInfo was just called") - } - callInfo := struct { - }{} - mock.lockGetMemoryInfo.Lock() - mock.calls.GetMemoryInfo = append(mock.calls.GetMemoryInfo, callInfo) - mock.lockGetMemoryInfo.Unlock() - return mock.GetMemoryInfoFunc() -} - -// GetMemoryInfoCalls gets all the calls that were made to GetMemoryInfo. -// Check the length with: -// -// len(mockedDevice.GetMemoryInfoCalls()) -func (mock *DeviceMock) GetMemoryInfoCalls() []struct { -} { - var calls []struct { - } - mock.lockGetMemoryInfo.RLock() - calls = mock.calls.GetMemoryInfo - mock.lockGetMemoryInfo.RUnlock() - return calls -} - -// GetMigDeviceHandleByIndex calls GetMigDeviceHandleByIndexFunc. -func (mock *DeviceMock) GetMigDeviceHandleByIndex(Index int) (Device, Return) { - if mock.GetMigDeviceHandleByIndexFunc == nil { - panic("DeviceMock.GetMigDeviceHandleByIndexFunc: method is nil but Device.GetMigDeviceHandleByIndex was just called") - } - callInfo := struct { - Index int - }{ - Index: Index, - } - mock.lockGetMigDeviceHandleByIndex.Lock() - mock.calls.GetMigDeviceHandleByIndex = append(mock.calls.GetMigDeviceHandleByIndex, callInfo) - mock.lockGetMigDeviceHandleByIndex.Unlock() - return mock.GetMigDeviceHandleByIndexFunc(Index) -} - -// GetMigDeviceHandleByIndexCalls gets all the calls that were made to GetMigDeviceHandleByIndex. -// Check the length with: -// -// len(mockedDevice.GetMigDeviceHandleByIndexCalls()) -func (mock *DeviceMock) GetMigDeviceHandleByIndexCalls() []struct { - Index int -} { - var calls []struct { - Index int - } - mock.lockGetMigDeviceHandleByIndex.RLock() - calls = mock.calls.GetMigDeviceHandleByIndex - mock.lockGetMigDeviceHandleByIndex.RUnlock() - return calls -} - -// GetMigMode calls GetMigModeFunc. -func (mock *DeviceMock) GetMigMode() (int, int, Return) { - if mock.GetMigModeFunc == nil { - panic("DeviceMock.GetMigModeFunc: method is nil but Device.GetMigMode was just called") - } - callInfo := struct { - }{} - mock.lockGetMigMode.Lock() - mock.calls.GetMigMode = append(mock.calls.GetMigMode, callInfo) - mock.lockGetMigMode.Unlock() - return mock.GetMigModeFunc() -} - -// GetMigModeCalls gets all the calls that were made to GetMigMode. -// Check the length with: -// -// len(mockedDevice.GetMigModeCalls()) -func (mock *DeviceMock) GetMigModeCalls() []struct { -} { - var calls []struct { - } - mock.lockGetMigMode.RLock() - calls = mock.calls.GetMigMode - mock.lockGetMigMode.RUnlock() - return calls -} - -// GetMinorNumber calls GetMinorNumberFunc. -func (mock *DeviceMock) GetMinorNumber() (int, Return) { - if mock.GetMinorNumberFunc == nil { - panic("DeviceMock.GetMinorNumberFunc: method is nil but Device.GetMinorNumber was just called") - } - callInfo := struct { - }{} - mock.lockGetMinorNumber.Lock() - mock.calls.GetMinorNumber = append(mock.calls.GetMinorNumber, callInfo) - mock.lockGetMinorNumber.Unlock() - return mock.GetMinorNumberFunc() -} - -// GetMinorNumberCalls gets all the calls that were made to GetMinorNumber. -// Check the length with: -// -// len(mockedDevice.GetMinorNumberCalls()) -func (mock *DeviceMock) GetMinorNumberCalls() []struct { -} { - var calls []struct { - } - mock.lockGetMinorNumber.RLock() - calls = mock.calls.GetMinorNumber - mock.lockGetMinorNumber.RUnlock() - return calls -} - -// GetName calls GetNameFunc. -func (mock *DeviceMock) GetName() (string, Return) { - if mock.GetNameFunc == nil { - panic("DeviceMock.GetNameFunc: method is nil but Device.GetName was just called") - } - callInfo := struct { - }{} - mock.lockGetName.Lock() - mock.calls.GetName = append(mock.calls.GetName, callInfo) - mock.lockGetName.Unlock() - return mock.GetNameFunc() -} - -// GetNameCalls gets all the calls that were made to GetName. -// Check the length with: -// -// len(mockedDevice.GetNameCalls()) -func (mock *DeviceMock) GetNameCalls() []struct { -} { - var calls []struct { - } - mock.lockGetName.RLock() - calls = mock.calls.GetName - mock.lockGetName.RUnlock() - return calls -} - -// GetNvLinkRemotePciInfo calls GetNvLinkRemotePciInfoFunc. -func (mock *DeviceMock) GetNvLinkRemotePciInfo(n int) (PciInfo, Return) { - if mock.GetNvLinkRemotePciInfoFunc == nil { - panic("DeviceMock.GetNvLinkRemotePciInfoFunc: method is nil but Device.GetNvLinkRemotePciInfo was just called") - } - callInfo := struct { - N int - }{ - N: n, - } - mock.lockGetNvLinkRemotePciInfo.Lock() - mock.calls.GetNvLinkRemotePciInfo = append(mock.calls.GetNvLinkRemotePciInfo, callInfo) - mock.lockGetNvLinkRemotePciInfo.Unlock() - return mock.GetNvLinkRemotePciInfoFunc(n) -} - -// GetNvLinkRemotePciInfoCalls gets all the calls that were made to GetNvLinkRemotePciInfo. -// Check the length with: -// -// len(mockedDevice.GetNvLinkRemotePciInfoCalls()) -func (mock *DeviceMock) GetNvLinkRemotePciInfoCalls() []struct { - N int -} { - var calls []struct { - N int - } - mock.lockGetNvLinkRemotePciInfo.RLock() - calls = mock.calls.GetNvLinkRemotePciInfo - mock.lockGetNvLinkRemotePciInfo.RUnlock() - return calls -} - -// GetNvLinkState calls GetNvLinkStateFunc. -func (mock *DeviceMock) GetNvLinkState(n int) (EnableState, Return) { - if mock.GetNvLinkStateFunc == nil { - panic("DeviceMock.GetNvLinkStateFunc: method is nil but Device.GetNvLinkState was just called") - } - callInfo := struct { - N int - }{ - N: n, - } - mock.lockGetNvLinkState.Lock() - mock.calls.GetNvLinkState = append(mock.calls.GetNvLinkState, callInfo) - mock.lockGetNvLinkState.Unlock() - return mock.GetNvLinkStateFunc(n) -} - -// GetNvLinkStateCalls gets all the calls that were made to GetNvLinkState. -// Check the length with: -// -// len(mockedDevice.GetNvLinkStateCalls()) -func (mock *DeviceMock) GetNvLinkStateCalls() []struct { - N int -} { - var calls []struct { - N int - } - mock.lockGetNvLinkState.RLock() - calls = mock.calls.GetNvLinkState - mock.lockGetNvLinkState.RUnlock() - return calls -} - -// GetPciInfo calls GetPciInfoFunc. -func (mock *DeviceMock) GetPciInfo() (PciInfo, Return) { - if mock.GetPciInfoFunc == nil { - panic("DeviceMock.GetPciInfoFunc: method is nil but Device.GetPciInfo was just called") - } - callInfo := struct { - }{} - mock.lockGetPciInfo.Lock() - mock.calls.GetPciInfo = append(mock.calls.GetPciInfo, callInfo) - mock.lockGetPciInfo.Unlock() - return mock.GetPciInfoFunc() -} - -// GetPciInfoCalls gets all the calls that were made to GetPciInfo. -// Check the length with: -// -// len(mockedDevice.GetPciInfoCalls()) -func (mock *DeviceMock) GetPciInfoCalls() []struct { -} { - var calls []struct { - } - mock.lockGetPciInfo.RLock() - calls = mock.calls.GetPciInfo - mock.lockGetPciInfo.RUnlock() - return calls -} - -// GetSupportedEventTypes calls GetSupportedEventTypesFunc. -func (mock *DeviceMock) GetSupportedEventTypes() (uint64, Return) { - if mock.GetSupportedEventTypesFunc == nil { - panic("DeviceMock.GetSupportedEventTypesFunc: method is nil but Device.GetSupportedEventTypes was just called") - } - callInfo := struct { - }{} - mock.lockGetSupportedEventTypes.Lock() - mock.calls.GetSupportedEventTypes = append(mock.calls.GetSupportedEventTypes, callInfo) - mock.lockGetSupportedEventTypes.Unlock() - return mock.GetSupportedEventTypesFunc() -} - -// GetSupportedEventTypesCalls gets all the calls that were made to GetSupportedEventTypes. -// Check the length with: -// -// len(mockedDevice.GetSupportedEventTypesCalls()) -func (mock *DeviceMock) GetSupportedEventTypesCalls() []struct { -} { - var calls []struct { - } - mock.lockGetSupportedEventTypes.RLock() - calls = mock.calls.GetSupportedEventTypes - mock.lockGetSupportedEventTypes.RUnlock() - return calls -} - -// GetTopologyCommonAncestor calls GetTopologyCommonAncestorFunc. -func (mock *DeviceMock) GetTopologyCommonAncestor(device Device) (GpuTopologyLevel, Return) { - if mock.GetTopologyCommonAncestorFunc == nil { - panic("DeviceMock.GetTopologyCommonAncestorFunc: method is nil but Device.GetTopologyCommonAncestor was just called") - } - callInfo := struct { - Device Device - }{ - Device: device, - } - mock.lockGetTopologyCommonAncestor.Lock() - mock.calls.GetTopologyCommonAncestor = append(mock.calls.GetTopologyCommonAncestor, callInfo) - mock.lockGetTopologyCommonAncestor.Unlock() - return mock.GetTopologyCommonAncestorFunc(device) -} - -// GetTopologyCommonAncestorCalls gets all the calls that were made to GetTopologyCommonAncestor. -// Check the length with: -// -// len(mockedDevice.GetTopologyCommonAncestorCalls()) -func (mock *DeviceMock) GetTopologyCommonAncestorCalls() []struct { - Device Device -} { - var calls []struct { - Device Device - } - mock.lockGetTopologyCommonAncestor.RLock() - calls = mock.calls.GetTopologyCommonAncestor - mock.lockGetTopologyCommonAncestor.RUnlock() - return calls -} - -// GetUUID calls GetUUIDFunc. -func (mock *DeviceMock) GetUUID() (string, Return) { - if mock.GetUUIDFunc == nil { - panic("DeviceMock.GetUUIDFunc: method is nil but Device.GetUUID was just called") - } - callInfo := struct { - }{} - mock.lockGetUUID.Lock() - mock.calls.GetUUID = append(mock.calls.GetUUID, callInfo) - mock.lockGetUUID.Unlock() - return mock.GetUUIDFunc() -} - -// GetUUIDCalls gets all the calls that were made to GetUUID. -// Check the length with: -// -// len(mockedDevice.GetUUIDCalls()) -func (mock *DeviceMock) GetUUIDCalls() []struct { -} { - var calls []struct { - } - mock.lockGetUUID.RLock() - calls = mock.calls.GetUUID - mock.lockGetUUID.RUnlock() - return calls -} - -// IsMigDeviceHandle calls IsMigDeviceHandleFunc. -func (mock *DeviceMock) IsMigDeviceHandle() (bool, Return) { - if mock.IsMigDeviceHandleFunc == nil { - panic("DeviceMock.IsMigDeviceHandleFunc: method is nil but Device.IsMigDeviceHandle was just called") - } - callInfo := struct { - }{} - mock.lockIsMigDeviceHandle.Lock() - mock.calls.IsMigDeviceHandle = append(mock.calls.IsMigDeviceHandle, callInfo) - mock.lockIsMigDeviceHandle.Unlock() - return mock.IsMigDeviceHandleFunc() -} - -// IsMigDeviceHandleCalls gets all the calls that were made to IsMigDeviceHandle. -// Check the length with: -// -// len(mockedDevice.IsMigDeviceHandleCalls()) -func (mock *DeviceMock) IsMigDeviceHandleCalls() []struct { -} { - var calls []struct { - } - mock.lockIsMigDeviceHandle.RLock() - calls = mock.calls.IsMigDeviceHandle - mock.lockIsMigDeviceHandle.RUnlock() - return calls -} - -// RegisterEvents calls RegisterEventsFunc. -func (mock *DeviceMock) RegisterEvents(v uint64, eventSet EventSet) Return { - if mock.RegisterEventsFunc == nil { - panic("DeviceMock.RegisterEventsFunc: method is nil but Device.RegisterEvents was just called") - } - callInfo := struct { - V uint64 - EventSet EventSet - }{ - V: v, - EventSet: eventSet, - } - mock.lockRegisterEvents.Lock() - mock.calls.RegisterEvents = append(mock.calls.RegisterEvents, callInfo) - mock.lockRegisterEvents.Unlock() - return mock.RegisterEventsFunc(v, eventSet) -} - -// RegisterEventsCalls gets all the calls that were made to RegisterEvents. -// Check the length with: -// -// len(mockedDevice.RegisterEventsCalls()) -func (mock *DeviceMock) RegisterEventsCalls() []struct { - V uint64 - EventSet EventSet -} { - var calls []struct { - V uint64 - EventSet EventSet - } - mock.lockRegisterEvents.RLock() - calls = mock.calls.RegisterEvents - mock.lockRegisterEvents.RUnlock() - 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 { - panic("DeviceMock.SetMigModeFunc: method is nil but Device.SetMigMode was just called") - } - callInfo := struct { - Mode int - }{ - Mode: Mode, - } - mock.lockSetMigMode.Lock() - mock.calls.SetMigMode = append(mock.calls.SetMigMode, callInfo) - mock.lockSetMigMode.Unlock() - return mock.SetMigModeFunc(Mode) -} - -// SetMigModeCalls gets all the calls that were made to SetMigMode. -// Check the length with: -// -// len(mockedDevice.SetMigModeCalls()) -func (mock *DeviceMock) SetMigModeCalls() []struct { - Mode int -} { - var calls []struct { - Mode int - } - mock.lockSetMigMode.RLock() - calls = mock.calls.SetMigMode - 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 -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/event_set.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/event_set.go deleted file mode 100644 index 2e0b9e2c..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/event_set.go +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -// Wait watches for an event with the specified timeout -func (e EventSet) Wait(Timeoutms uint32) (EventData, Return) { - d, r := nvml.EventSet(e).Wait(Timeoutms) - eventData := EventData{ - Device: nvmlDevice(d.Device), - EventType: d.EventType, - EventData: d.EventData, - GpuInstanceId: d.GpuInstanceId, - ComputeInstanceId: d.ComputeInstanceId, - } - return eventData, Return(r) -} - -// Free deletes the event set -func (e EventSet) Free() Return { - return Return(nvml.EventSet(e).Free()) -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi.go deleted file mode 100644 index bc4d3734..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi.go +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -type nvmlGpuInstance nvml.GpuInstance - -var _ GpuInstance = (*nvmlGpuInstance)(nil) - -// GetInfo returns info about a GPU Intsance -func (gi nvmlGpuInstance) GetInfo() (GpuInstanceInfo, Return) { - i, r := nvml.GpuInstance(gi).GetInfo() - info := GpuInstanceInfo{ - Device: nvmlDevice(i.Device), - Id: i.Id, - ProfileId: i.ProfileId, - Placement: GpuInstancePlacement(i.Placement), - } - return info, Return(r) -} - -// GetComputeInstanceById returns the Compute Instance associated with a particular ID. -func (gi nvmlGpuInstance) GetComputeInstanceById(id int) (ComputeInstance, Return) { - ci, r := nvml.GpuInstance(gi).GetComputeInstanceById(id) - return nvmlComputeInstance(ci), Return(r) -} - -// GetComputeInstanceProfileInfo returns info about a given Compute Instance profile -func (gi nvmlGpuInstance) GetComputeInstanceProfileInfo(profile int, engProfile int) (ComputeInstanceProfileInfo, Return) { - p, r := nvml.GpuInstance(gi).GetComputeInstanceProfileInfo(profile, engProfile) - return ComputeInstanceProfileInfo(p), Return(r) -} - -// CreateComputeInstance creates a Compute Instance within the GPU Instance -func (gi nvmlGpuInstance) CreateComputeInstance(info *ComputeInstanceProfileInfo) (ComputeInstance, Return) { - ci, r := nvml.GpuInstance(gi).CreateComputeInstance((*nvml.ComputeInstanceProfileInfo)(info)) - return nvmlComputeInstance(ci), Return(r) -} - -// GetComputeInstances returns the set of Compute Instances associated with a GPU Instance -func (gi nvmlGpuInstance) GetComputeInstances(info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) { - nvmlCis, r := nvml.GpuInstance(gi).GetComputeInstances((*nvml.ComputeInstanceProfileInfo)(info)) - var cis []ComputeInstance - for _, ci := range nvmlCis { - cis = append(cis, nvmlComputeInstance(ci)) - } - return cis, Return(r) -} - -// Destroy destroys a GPU Instance -func (gi nvmlGpuInstance) Destroy() Return { - r := nvml.GpuInstance(gi).Destroy() - return Return(r) -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi_mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi_mock.go deleted file mode 100644 index ac26cb2c..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi_mock.go +++ /dev/null @@ -1,286 +0,0 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq - -package nvml - -import ( - "sync" -) - -// Ensure, that GpuInstanceMock does implement GpuInstance. -// If this is not the case, regenerate this file with moq. -var _ GpuInstance = &GpuInstanceMock{} - -// GpuInstanceMock is a mock implementation of GpuInstance. -// -// func TestSomethingThatUsesGpuInstance(t *testing.T) { -// -// // make and configure a mocked GpuInstance -// mockedGpuInstance := &GpuInstanceMock{ -// CreateComputeInstanceFunc: func(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return) { -// panic("mock out the CreateComputeInstance method") -// }, -// DestroyFunc: func() Return { -// panic("mock out the Destroy method") -// }, -// GetComputeInstanceByIdFunc: func(ID int) (ComputeInstance, Return) { -// panic("mock out the GetComputeInstanceById method") -// }, -// GetComputeInstanceProfileInfoFunc: func(Profile int, EngProfile int) (ComputeInstanceProfileInfo, Return) { -// panic("mock out the GetComputeInstanceProfileInfo method") -// }, -// GetComputeInstancesFunc: func(Info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) { -// panic("mock out the GetComputeInstances method") -// }, -// GetInfoFunc: func() (GpuInstanceInfo, Return) { -// panic("mock out the GetInfo method") -// }, -// } -// -// // use mockedGpuInstance in code that requires GpuInstance -// // and then make assertions. -// -// } -type GpuInstanceMock struct { - // CreateComputeInstanceFunc mocks the CreateComputeInstance method. - CreateComputeInstanceFunc func(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return) - - // DestroyFunc mocks the Destroy method. - DestroyFunc func() Return - - // GetComputeInstanceByIdFunc mocks the GetComputeInstanceById method. - GetComputeInstanceByIdFunc func(ID int) (ComputeInstance, Return) - - // GetComputeInstanceProfileInfoFunc mocks the GetComputeInstanceProfileInfo method. - GetComputeInstanceProfileInfoFunc func(Profile int, EngProfile int) (ComputeInstanceProfileInfo, Return) - - // GetComputeInstancesFunc mocks the GetComputeInstances method. - GetComputeInstancesFunc func(Info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) - - // GetInfoFunc mocks the GetInfo method. - GetInfoFunc func() (GpuInstanceInfo, Return) - - // calls tracks calls to the methods. - calls struct { - // CreateComputeInstance holds details about calls to the CreateComputeInstance method. - CreateComputeInstance []struct { - // Info is the Info argument value. - Info *ComputeInstanceProfileInfo - } - // Destroy holds details about calls to the Destroy method. - Destroy []struct { - } - // GetComputeInstanceById holds details about calls to the GetComputeInstanceById method. - GetComputeInstanceById []struct { - // ID is the ID argument value. - ID int - } - // GetComputeInstanceProfileInfo holds details about calls to the GetComputeInstanceProfileInfo method. - GetComputeInstanceProfileInfo []struct { - // Profile is the Profile argument value. - Profile int - // EngProfile is the EngProfile argument value. - EngProfile int - } - // GetComputeInstances holds details about calls to the GetComputeInstances method. - GetComputeInstances []struct { - // Info is the Info argument value. - Info *ComputeInstanceProfileInfo - } - // GetInfo holds details about calls to the GetInfo method. - GetInfo []struct { - } - } - lockCreateComputeInstance sync.RWMutex - lockDestroy sync.RWMutex - lockGetComputeInstanceById sync.RWMutex - lockGetComputeInstanceProfileInfo sync.RWMutex - lockGetComputeInstances sync.RWMutex - lockGetInfo sync.RWMutex -} - -// CreateComputeInstance calls CreateComputeInstanceFunc. -func (mock *GpuInstanceMock) CreateComputeInstance(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return) { - if mock.CreateComputeInstanceFunc == nil { - panic("GpuInstanceMock.CreateComputeInstanceFunc: method is nil but GpuInstance.CreateComputeInstance was just called") - } - callInfo := struct { - Info *ComputeInstanceProfileInfo - }{ - Info: Info, - } - mock.lockCreateComputeInstance.Lock() - mock.calls.CreateComputeInstance = append(mock.calls.CreateComputeInstance, callInfo) - mock.lockCreateComputeInstance.Unlock() - return mock.CreateComputeInstanceFunc(Info) -} - -// CreateComputeInstanceCalls gets all the calls that were made to CreateComputeInstance. -// Check the length with: -// -// len(mockedGpuInstance.CreateComputeInstanceCalls()) -func (mock *GpuInstanceMock) CreateComputeInstanceCalls() []struct { - Info *ComputeInstanceProfileInfo -} { - var calls []struct { - Info *ComputeInstanceProfileInfo - } - mock.lockCreateComputeInstance.RLock() - calls = mock.calls.CreateComputeInstance - mock.lockCreateComputeInstance.RUnlock() - return calls -} - -// Destroy calls DestroyFunc. -func (mock *GpuInstanceMock) Destroy() Return { - if mock.DestroyFunc == nil { - panic("GpuInstanceMock.DestroyFunc: method is nil but GpuInstance.Destroy was just called") - } - callInfo := struct { - }{} - mock.lockDestroy.Lock() - mock.calls.Destroy = append(mock.calls.Destroy, callInfo) - mock.lockDestroy.Unlock() - return mock.DestroyFunc() -} - -// DestroyCalls gets all the calls that were made to Destroy. -// Check the length with: -// -// len(mockedGpuInstance.DestroyCalls()) -func (mock *GpuInstanceMock) DestroyCalls() []struct { -} { - var calls []struct { - } - mock.lockDestroy.RLock() - calls = mock.calls.Destroy - mock.lockDestroy.RUnlock() - return calls -} - -// GetComputeInstanceById calls GetComputeInstanceByIdFunc. -func (mock *GpuInstanceMock) GetComputeInstanceById(ID int) (ComputeInstance, Return) { - if mock.GetComputeInstanceByIdFunc == nil { - panic("GpuInstanceMock.GetComputeInstanceByIdFunc: method is nil but GpuInstance.GetComputeInstanceById was just called") - } - callInfo := struct { - ID int - }{ - ID: ID, - } - mock.lockGetComputeInstanceById.Lock() - mock.calls.GetComputeInstanceById = append(mock.calls.GetComputeInstanceById, callInfo) - mock.lockGetComputeInstanceById.Unlock() - return mock.GetComputeInstanceByIdFunc(ID) -} - -// GetComputeInstanceByIdCalls gets all the calls that were made to GetComputeInstanceById. -// Check the length with: -// -// len(mockedGpuInstance.GetComputeInstanceByIdCalls()) -func (mock *GpuInstanceMock) GetComputeInstanceByIdCalls() []struct { - ID int -} { - var calls []struct { - ID int - } - mock.lockGetComputeInstanceById.RLock() - calls = mock.calls.GetComputeInstanceById - mock.lockGetComputeInstanceById.RUnlock() - return calls -} - -// GetComputeInstanceProfileInfo calls GetComputeInstanceProfileInfoFunc. -func (mock *GpuInstanceMock) GetComputeInstanceProfileInfo(Profile int, EngProfile int) (ComputeInstanceProfileInfo, Return) { - if mock.GetComputeInstanceProfileInfoFunc == nil { - panic("GpuInstanceMock.GetComputeInstanceProfileInfoFunc: method is nil but GpuInstance.GetComputeInstanceProfileInfo was just called") - } - callInfo := struct { - Profile int - EngProfile int - }{ - Profile: Profile, - EngProfile: EngProfile, - } - mock.lockGetComputeInstanceProfileInfo.Lock() - mock.calls.GetComputeInstanceProfileInfo = append(mock.calls.GetComputeInstanceProfileInfo, callInfo) - mock.lockGetComputeInstanceProfileInfo.Unlock() - return mock.GetComputeInstanceProfileInfoFunc(Profile, EngProfile) -} - -// GetComputeInstanceProfileInfoCalls gets all the calls that were made to GetComputeInstanceProfileInfo. -// Check the length with: -// -// len(mockedGpuInstance.GetComputeInstanceProfileInfoCalls()) -func (mock *GpuInstanceMock) GetComputeInstanceProfileInfoCalls() []struct { - Profile int - EngProfile int -} { - var calls []struct { - Profile int - EngProfile int - } - mock.lockGetComputeInstanceProfileInfo.RLock() - calls = mock.calls.GetComputeInstanceProfileInfo - mock.lockGetComputeInstanceProfileInfo.RUnlock() - return calls -} - -// GetComputeInstances calls GetComputeInstancesFunc. -func (mock *GpuInstanceMock) GetComputeInstances(Info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) { - if mock.GetComputeInstancesFunc == nil { - panic("GpuInstanceMock.GetComputeInstancesFunc: method is nil but GpuInstance.GetComputeInstances was just called") - } - callInfo := struct { - Info *ComputeInstanceProfileInfo - }{ - Info: Info, - } - mock.lockGetComputeInstances.Lock() - mock.calls.GetComputeInstances = append(mock.calls.GetComputeInstances, callInfo) - mock.lockGetComputeInstances.Unlock() - return mock.GetComputeInstancesFunc(Info) -} - -// GetComputeInstancesCalls gets all the calls that were made to GetComputeInstances. -// Check the length with: -// -// len(mockedGpuInstance.GetComputeInstancesCalls()) -func (mock *GpuInstanceMock) GetComputeInstancesCalls() []struct { - Info *ComputeInstanceProfileInfo -} { - var calls []struct { - Info *ComputeInstanceProfileInfo - } - mock.lockGetComputeInstances.RLock() - calls = mock.calls.GetComputeInstances - mock.lockGetComputeInstances.RUnlock() - return calls -} - -// GetInfo calls GetInfoFunc. -func (mock *GpuInstanceMock) GetInfo() (GpuInstanceInfo, Return) { - if mock.GetInfoFunc == nil { - panic("GpuInstanceMock.GetInfoFunc: method is nil but GpuInstance.GetInfo was just called") - } - callInfo := struct { - }{} - mock.lockGetInfo.Lock() - mock.calls.GetInfo = append(mock.calls.GetInfo, callInfo) - mock.lockGetInfo.Unlock() - return mock.GetInfoFunc() -} - -// GetInfoCalls gets all the calls that were made to GetInfo. -// Check the length with: -// -// len(mockedGpuInstance.GetInfoCalls()) -func (mock *GpuInstanceMock) GetInfoCalls() []struct { -} { - var calls []struct { - } - mock.lockGetInfo.RLock() - calls = mock.calls.GetInfo - mock.lockGetInfo.RUnlock() - return calls -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml.go deleted file mode 100644 index fdd28de3..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml.go +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "sync" - - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -type nvmlLib struct { - sync.Mutex - refcount int -} - -var _ Interface = (*nvmlLib)(nil) - -// New creates a new instance of the NVML Interface -func New(opts ...Option) Interface { - o := &options{} - for _, opt := range opts { - opt(o) - } - - var nvmlOptions []nvml.LibraryOption - if o.libraryPath != "" { - nvmlOptions = append(nvmlOptions, nvml.WithLibraryPath(o.libraryPath)) - } - nvml.SetLibraryOptions(nvmlOptions...) - - return &nvmlLib{} -} - -// Lookup checks whether the specified symbol exists in the configured NVML library. -func (n *nvmlLib) Lookup(name string) error { - // TODO: For now we rely on the default NVML library and perform the lookups against this. - return nvml.GetLibrary().Lookup(name) -} - -// Init initializes an NVML Interface -func (n *nvmlLib) Init() Return { - ret := nvml.Init() - if ret != nvml.SUCCESS { - return Return(ret) - } - - n.Lock() - defer n.Unlock() - if n.refcount == 0 { - errorStringFunc = nvml.ErrorString - } - n.refcount++ - - return SUCCESS -} - -// Shutdown shuts down an NVML Interface -func (n *nvmlLib) Shutdown() Return { - ret := nvml.Shutdown() - if ret != nvml.SUCCESS { - return Return(ret) - } - - n.Lock() - defer n.Unlock() - n.refcount-- - if n.refcount == 0 { - errorStringFunc = defaultErrorStringFunc - } - - return SUCCESS -} - -// DeviceGetCount returns the total number of GPU Devices -func (n *nvmlLib) DeviceGetCount() (int, Return) { - c, r := nvml.DeviceGetCount() - return c, Return(r) -} - -// DeviceGetHandleByIndex returns a Device handle given its index -func (n *nvmlLib) DeviceGetHandleByIndex(index int) (Device, Return) { - d, r := nvml.DeviceGetHandleByIndex(index) - return nvmlDevice(d), Return(r) -} - -// DeviceGetHandleByUUID returns a Device handle given its UUID -func (n *nvmlLib) DeviceGetHandleByUUID(uuid string) (Device, Return) { - d, r := nvml.DeviceGetHandleByUUID(uuid) - return nvmlDevice(d), Return(r) -} - -// SystemGetDriverVersion returns the version of the installed NVIDIA driver -func (n *nvmlLib) SystemGetDriverVersion() (string, Return) { - v, r := nvml.SystemGetDriverVersion() - return v, Return(r) -} - -// SystemGetCudaDriverVersion returns the version of CUDA associated with the NVIDIA driver -func (n *nvmlLib) SystemGetCudaDriverVersion() (int, Return) { - v, r := nvml.SystemGetCudaDriverVersion() - return v, Return(r) -} - -// ErrorString returns the error string associated with a given return value -func (n *nvmlLib) ErrorString(ret Return) string { - return nvml.ErrorString(nvml.Return(ret)) -} - -// EventSetCreate creates an event set -func (n *nvmlLib) EventSetCreate() (EventSet, Return) { - e, r := nvml.EventSetCreate() - return EventSet(e), Return(r) -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml_mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml_mock.go deleted file mode 100644 index 00957f81..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml_mock.go +++ /dev/null @@ -1,428 +0,0 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq - -package nvml - -import ( - "sync" -) - -// Ensure, that InterfaceMock does implement Interface. -// If this is not the case, regenerate this file with moq. -var _ Interface = &InterfaceMock{} - -// InterfaceMock is a mock implementation of Interface. -// -// func TestSomethingThatUsesInterface(t *testing.T) { -// -// // make and configure a mocked Interface -// mockedInterface := &InterfaceMock{ -// DeviceGetCountFunc: func() (int, Return) { -// panic("mock out the DeviceGetCount method") -// }, -// DeviceGetHandleByIndexFunc: func(Index int) (Device, Return) { -// panic("mock out the DeviceGetHandleByIndex method") -// }, -// DeviceGetHandleByUUIDFunc: func(UUID string) (Device, Return) { -// panic("mock out the DeviceGetHandleByUUID method") -// }, -// ErrorStringFunc: func(r Return) string { -// panic("mock out the ErrorString method") -// }, -// EventSetCreateFunc: func() (EventSet, Return) { -// panic("mock out the EventSetCreate method") -// }, -// InitFunc: func() Return { -// panic("mock out the Init method") -// }, -// LookupFunc: func(s string) error { -// panic("mock out the Lookup method") -// }, -// ShutdownFunc: func() Return { -// panic("mock out the Shutdown method") -// }, -// SystemGetCudaDriverVersionFunc: func() (int, Return) { -// panic("mock out the SystemGetCudaDriverVersion method") -// }, -// SystemGetDriverVersionFunc: func() (string, Return) { -// panic("mock out the SystemGetDriverVersion method") -// }, -// } -// -// // use mockedInterface in code that requires Interface -// // and then make assertions. -// -// } -type InterfaceMock struct { - // DeviceGetCountFunc mocks the DeviceGetCount method. - DeviceGetCountFunc func() (int, Return) - - // DeviceGetHandleByIndexFunc mocks the DeviceGetHandleByIndex method. - DeviceGetHandleByIndexFunc func(Index int) (Device, Return) - - // DeviceGetHandleByUUIDFunc mocks the DeviceGetHandleByUUID method. - DeviceGetHandleByUUIDFunc func(UUID string) (Device, Return) - - // ErrorStringFunc mocks the ErrorString method. - ErrorStringFunc func(r Return) string - - // EventSetCreateFunc mocks the EventSetCreate method. - EventSetCreateFunc func() (EventSet, Return) - - // InitFunc mocks the Init method. - InitFunc func() Return - - // LookupFunc mocks the Lookup method. - LookupFunc func(s string) error - - // ShutdownFunc mocks the Shutdown method. - ShutdownFunc func() Return - - // SystemGetCudaDriverVersionFunc mocks the SystemGetCudaDriverVersion method. - SystemGetCudaDriverVersionFunc func() (int, Return) - - // SystemGetDriverVersionFunc mocks the SystemGetDriverVersion method. - SystemGetDriverVersionFunc func() (string, Return) - - // calls tracks calls to the methods. - calls struct { - // DeviceGetCount holds details about calls to the DeviceGetCount method. - DeviceGetCount []struct { - } - // DeviceGetHandleByIndex holds details about calls to the DeviceGetHandleByIndex method. - DeviceGetHandleByIndex []struct { - // Index is the Index argument value. - Index int - } - // DeviceGetHandleByUUID holds details about calls to the DeviceGetHandleByUUID method. - DeviceGetHandleByUUID []struct { - // UUID is the UUID argument value. - UUID string - } - // ErrorString holds details about calls to the ErrorString method. - ErrorString []struct { - // R is the r argument value. - R Return - } - // EventSetCreate holds details about calls to the EventSetCreate method. - EventSetCreate []struct { - } - // Init holds details about calls to the Init method. - Init []struct { - } - // Lookup holds details about calls to the Lookup method. - Lookup []struct { - // S is the s argument value. - S string - } - // Shutdown holds details about calls to the Shutdown method. - Shutdown []struct { - } - // SystemGetCudaDriverVersion holds details about calls to the SystemGetCudaDriverVersion method. - SystemGetCudaDriverVersion []struct { - } - // SystemGetDriverVersion holds details about calls to the SystemGetDriverVersion method. - SystemGetDriverVersion []struct { - } - } - lockDeviceGetCount sync.RWMutex - lockDeviceGetHandleByIndex sync.RWMutex - lockDeviceGetHandleByUUID sync.RWMutex - lockErrorString sync.RWMutex - lockEventSetCreate sync.RWMutex - lockInit sync.RWMutex - lockLookup sync.RWMutex - lockShutdown sync.RWMutex - lockSystemGetCudaDriverVersion sync.RWMutex - lockSystemGetDriverVersion sync.RWMutex -} - -// DeviceGetCount calls DeviceGetCountFunc. -func (mock *InterfaceMock) DeviceGetCount() (int, Return) { - if mock.DeviceGetCountFunc == nil { - panic("InterfaceMock.DeviceGetCountFunc: method is nil but Interface.DeviceGetCount was just called") - } - callInfo := struct { - }{} - mock.lockDeviceGetCount.Lock() - mock.calls.DeviceGetCount = append(mock.calls.DeviceGetCount, callInfo) - mock.lockDeviceGetCount.Unlock() - return mock.DeviceGetCountFunc() -} - -// DeviceGetCountCalls gets all the calls that were made to DeviceGetCount. -// Check the length with: -// -// len(mockedInterface.DeviceGetCountCalls()) -func (mock *InterfaceMock) DeviceGetCountCalls() []struct { -} { - var calls []struct { - } - mock.lockDeviceGetCount.RLock() - calls = mock.calls.DeviceGetCount - mock.lockDeviceGetCount.RUnlock() - return calls -} - -// DeviceGetHandleByIndex calls DeviceGetHandleByIndexFunc. -func (mock *InterfaceMock) DeviceGetHandleByIndex(Index int) (Device, Return) { - if mock.DeviceGetHandleByIndexFunc == nil { - panic("InterfaceMock.DeviceGetHandleByIndexFunc: method is nil but Interface.DeviceGetHandleByIndex was just called") - } - callInfo := struct { - Index int - }{ - Index: Index, - } - mock.lockDeviceGetHandleByIndex.Lock() - mock.calls.DeviceGetHandleByIndex = append(mock.calls.DeviceGetHandleByIndex, callInfo) - mock.lockDeviceGetHandleByIndex.Unlock() - return mock.DeviceGetHandleByIndexFunc(Index) -} - -// DeviceGetHandleByIndexCalls gets all the calls that were made to DeviceGetHandleByIndex. -// Check the length with: -// -// len(mockedInterface.DeviceGetHandleByIndexCalls()) -func (mock *InterfaceMock) DeviceGetHandleByIndexCalls() []struct { - Index int -} { - var calls []struct { - Index int - } - mock.lockDeviceGetHandleByIndex.RLock() - calls = mock.calls.DeviceGetHandleByIndex - mock.lockDeviceGetHandleByIndex.RUnlock() - return calls -} - -// DeviceGetHandleByUUID calls DeviceGetHandleByUUIDFunc. -func (mock *InterfaceMock) DeviceGetHandleByUUID(UUID string) (Device, Return) { - if mock.DeviceGetHandleByUUIDFunc == nil { - panic("InterfaceMock.DeviceGetHandleByUUIDFunc: method is nil but Interface.DeviceGetHandleByUUID was just called") - } - callInfo := struct { - UUID string - }{ - UUID: UUID, - } - mock.lockDeviceGetHandleByUUID.Lock() - mock.calls.DeviceGetHandleByUUID = append(mock.calls.DeviceGetHandleByUUID, callInfo) - mock.lockDeviceGetHandleByUUID.Unlock() - return mock.DeviceGetHandleByUUIDFunc(UUID) -} - -// DeviceGetHandleByUUIDCalls gets all the calls that were made to DeviceGetHandleByUUID. -// Check the length with: -// -// len(mockedInterface.DeviceGetHandleByUUIDCalls()) -func (mock *InterfaceMock) DeviceGetHandleByUUIDCalls() []struct { - UUID string -} { - var calls []struct { - UUID string - } - mock.lockDeviceGetHandleByUUID.RLock() - calls = mock.calls.DeviceGetHandleByUUID - mock.lockDeviceGetHandleByUUID.RUnlock() - return calls -} - -// ErrorString calls ErrorStringFunc. -func (mock *InterfaceMock) ErrorString(r Return) string { - if mock.ErrorStringFunc == nil { - panic("InterfaceMock.ErrorStringFunc: method is nil but Interface.ErrorString was just called") - } - callInfo := struct { - R Return - }{ - R: r, - } - mock.lockErrorString.Lock() - mock.calls.ErrorString = append(mock.calls.ErrorString, callInfo) - mock.lockErrorString.Unlock() - return mock.ErrorStringFunc(r) -} - -// ErrorStringCalls gets all the calls that were made to ErrorString. -// Check the length with: -// -// len(mockedInterface.ErrorStringCalls()) -func (mock *InterfaceMock) ErrorStringCalls() []struct { - R Return -} { - var calls []struct { - R Return - } - mock.lockErrorString.RLock() - calls = mock.calls.ErrorString - mock.lockErrorString.RUnlock() - return calls -} - -// EventSetCreate calls EventSetCreateFunc. -func (mock *InterfaceMock) EventSetCreate() (EventSet, Return) { - if mock.EventSetCreateFunc == nil { - panic("InterfaceMock.EventSetCreateFunc: method is nil but Interface.EventSetCreate was just called") - } - callInfo := struct { - }{} - mock.lockEventSetCreate.Lock() - mock.calls.EventSetCreate = append(mock.calls.EventSetCreate, callInfo) - mock.lockEventSetCreate.Unlock() - return mock.EventSetCreateFunc() -} - -// EventSetCreateCalls gets all the calls that were made to EventSetCreate. -// Check the length with: -// -// len(mockedInterface.EventSetCreateCalls()) -func (mock *InterfaceMock) EventSetCreateCalls() []struct { -} { - var calls []struct { - } - mock.lockEventSetCreate.RLock() - calls = mock.calls.EventSetCreate - mock.lockEventSetCreate.RUnlock() - return calls -} - -// Init calls InitFunc. -func (mock *InterfaceMock) Init() Return { - if mock.InitFunc == nil { - panic("InterfaceMock.InitFunc: method is nil but Interface.Init was just called") - } - callInfo := struct { - }{} - mock.lockInit.Lock() - mock.calls.Init = append(mock.calls.Init, callInfo) - mock.lockInit.Unlock() - return mock.InitFunc() -} - -// InitCalls gets all the calls that were made to Init. -// Check the length with: -// -// len(mockedInterface.InitCalls()) -func (mock *InterfaceMock) InitCalls() []struct { -} { - var calls []struct { - } - mock.lockInit.RLock() - calls = mock.calls.Init - mock.lockInit.RUnlock() - return calls -} - -// Lookup calls LookupFunc. -func (mock *InterfaceMock) Lookup(s string) error { - if mock.LookupFunc == nil { - panic("InterfaceMock.LookupFunc: method is nil but Interface.Lookup was just called") - } - callInfo := struct { - S string - }{ - S: s, - } - mock.lockLookup.Lock() - mock.calls.Lookup = append(mock.calls.Lookup, callInfo) - mock.lockLookup.Unlock() - return mock.LookupFunc(s) -} - -// LookupCalls gets all the calls that were made to Lookup. -// Check the length with: -// -// len(mockedInterface.LookupCalls()) -func (mock *InterfaceMock) LookupCalls() []struct { - S string -} { - var calls []struct { - S string - } - mock.lockLookup.RLock() - calls = mock.calls.Lookup - mock.lockLookup.RUnlock() - return calls -} - -// Shutdown calls ShutdownFunc. -func (mock *InterfaceMock) Shutdown() Return { - if mock.ShutdownFunc == nil { - panic("InterfaceMock.ShutdownFunc: method is nil but Interface.Shutdown was just called") - } - callInfo := struct { - }{} - mock.lockShutdown.Lock() - mock.calls.Shutdown = append(mock.calls.Shutdown, callInfo) - mock.lockShutdown.Unlock() - return mock.ShutdownFunc() -} - -// ShutdownCalls gets all the calls that were made to Shutdown. -// Check the length with: -// -// len(mockedInterface.ShutdownCalls()) -func (mock *InterfaceMock) ShutdownCalls() []struct { -} { - var calls []struct { - } - mock.lockShutdown.RLock() - calls = mock.calls.Shutdown - mock.lockShutdown.RUnlock() - return calls -} - -// SystemGetCudaDriverVersion calls SystemGetCudaDriverVersionFunc. -func (mock *InterfaceMock) SystemGetCudaDriverVersion() (int, Return) { - if mock.SystemGetCudaDriverVersionFunc == nil { - panic("InterfaceMock.SystemGetCudaDriverVersionFunc: method is nil but Interface.SystemGetCudaDriverVersion was just called") - } - callInfo := struct { - }{} - mock.lockSystemGetCudaDriverVersion.Lock() - mock.calls.SystemGetCudaDriverVersion = append(mock.calls.SystemGetCudaDriverVersion, callInfo) - mock.lockSystemGetCudaDriverVersion.Unlock() - return mock.SystemGetCudaDriverVersionFunc() -} - -// SystemGetCudaDriverVersionCalls gets all the calls that were made to SystemGetCudaDriverVersion. -// Check the length with: -// -// len(mockedInterface.SystemGetCudaDriverVersionCalls()) -func (mock *InterfaceMock) SystemGetCudaDriverVersionCalls() []struct { -} { - var calls []struct { - } - mock.lockSystemGetCudaDriverVersion.RLock() - calls = mock.calls.SystemGetCudaDriverVersion - mock.lockSystemGetCudaDriverVersion.RUnlock() - return calls -} - -// SystemGetDriverVersion calls SystemGetDriverVersionFunc. -func (mock *InterfaceMock) SystemGetDriverVersion() (string, Return) { - if mock.SystemGetDriverVersionFunc == nil { - panic("InterfaceMock.SystemGetDriverVersionFunc: method is nil but Interface.SystemGetDriverVersion was just called") - } - callInfo := struct { - }{} - mock.lockSystemGetDriverVersion.Lock() - mock.calls.SystemGetDriverVersion = append(mock.calls.SystemGetDriverVersion, callInfo) - mock.lockSystemGetDriverVersion.Unlock() - return mock.SystemGetDriverVersionFunc() -} - -// SystemGetDriverVersionCalls gets all the calls that were made to SystemGetDriverVersion. -// Check the length with: -// -// len(mockedInterface.SystemGetDriverVersionCalls()) -func (mock *InterfaceMock) SystemGetDriverVersionCalls() []struct { -} { - var calls []struct { - } - mock.lockSystemGetDriverVersion.RLock() - calls = mock.calls.SystemGetDriverVersion - mock.lockSystemGetDriverVersion.RUnlock() - return calls -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/options.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/options.go deleted file mode 100644 index d34bb237..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/options.go +++ /dev/null @@ -1,32 +0,0 @@ -/** -# Copyright 2023 NVIDIA CORPORATION -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -**/ - -package nvml - -// options represents the options that could be passed to the nvml contructor. -type options struct { - libraryPath string -} - -// Option represents a functional option to control behaviour. -type Option func(*options) - -// WithLibraryPath sets the NVML library name to use. -func WithLibraryPath(libraryPath string) Option { - return func(o *options) { - o.libraryPath = libraryPath - } -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/return.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/return.go deleted file mode 100644 index 64cc1e19..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/return.go +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "fmt" - - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -// String returns the string representation of a Return -func (r Return) String() string { - return errorStringFunc(nvml.Return(r)) -} - -// Error returns the string representation of a Return -func (r Return) Error() string { - return errorStringFunc(nvml.Return(r)) -} - -// Assigned to nvml.ErrorString if the system nvml library is in use -var errorStringFunc = defaultErrorStringFunc - -var defaultErrorStringFunc = func(r nvml.Return) string { - switch Return(r) { - case SUCCESS: - return "SUCCESS" - case ERROR_UNINITIALIZED: - return "ERROR_UNINITIALIZED" - case ERROR_INVALID_ARGUMENT: - return "ERROR_INVALID_ARGUMENT" - case ERROR_NOT_SUPPORTED: - return "ERROR_NOT_SUPPORTED" - case ERROR_NO_PERMISSION: - return "ERROR_NO_PERMISSION" - case ERROR_ALREADY_INITIALIZED: - return "ERROR_ALREADY_INITIALIZED" - case ERROR_NOT_FOUND: - return "ERROR_NOT_FOUND" - case ERROR_INSUFFICIENT_SIZE: - return "ERROR_INSUFFICIENT_SIZE" - case ERROR_INSUFFICIENT_POWER: - return "ERROR_INSUFFICIENT_POWER" - case ERROR_DRIVER_NOT_LOADED: - return "ERROR_DRIVER_NOT_LOADED" - case ERROR_TIMEOUT: - return "ERROR_TIMEOUT" - case ERROR_IRQ_ISSUE: - return "ERROR_IRQ_ISSUE" - case ERROR_LIBRARY_NOT_FOUND: - return "ERROR_LIBRARY_NOT_FOUND" - case ERROR_FUNCTION_NOT_FOUND: - return "ERROR_FUNCTION_NOT_FOUND" - case ERROR_CORRUPTED_INFOROM: - return "ERROR_CORRUPTED_INFOROM" - case ERROR_GPU_IS_LOST: - return "ERROR_GPU_IS_LOST" - case ERROR_RESET_REQUIRED: - return "ERROR_RESET_REQUIRED" - case ERROR_OPERATING_SYSTEM: - return "ERROR_OPERATING_SYSTEM" - case ERROR_LIB_RM_VERSION_MISMATCH: - return "ERROR_LIB_RM_VERSION_MISMATCH" - case ERROR_IN_USE: - return "ERROR_IN_USE" - case ERROR_MEMORY: - return "ERROR_MEMORY" - case ERROR_NO_DATA: - return "ERROR_NO_DATA" - case ERROR_VGPU_ECC_NOT_SUPPORTED: - return "ERROR_VGPU_ECC_NOT_SUPPORTED" - case ERROR_INSUFFICIENT_RESOURCES: - return "ERROR_INSUFFICIENT_RESOURCES" - case ERROR_UNKNOWN: - return "ERROR_UNKNOWN" - default: - return fmt.Sprintf("Unknown return value: %d", r) - } -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go deleted file mode 100644 index d5150972..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -// Interface defines the functions implemented by an NVML library -// -//go:generate moq -out nvml_mock.go . Interface -type Interface interface { - DeviceGetCount() (int, Return) - DeviceGetHandleByIndex(Index int) (Device, Return) - DeviceGetHandleByUUID(UUID string) (Device, Return) - ErrorString(r Return) string - EventSetCreate() (EventSet, Return) - Init() Return - Lookup(string) error - Shutdown() Return - SystemGetCudaDriverVersion() (int, Return) - SystemGetDriverVersion() (string, Return) -} - -// Device defines the functions implemented by an NVML device -// -//go:generate moq -out device_mock.go . Device -type Device interface { - CreateGpuInstanceWithPlacement(*GpuInstanceProfileInfo, *GpuInstancePlacement) (GpuInstance, Return) - GetArchitecture() (DeviceArchitecture, Return) - GetAttributes() (DeviceAttributes, Return) - GetBrand() (BrandType, Return) - GetComputeInstanceId() (int, Return) - GetCudaComputeCapability() (int, int, Return) - GetDeviceHandleFromMigDeviceHandle() (Device, Return) - GetGpuInstanceById(ID int) (GpuInstance, Return) - GetGpuInstanceId() (int, Return) - GetGpuInstancePossiblePlacements(*GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) - GetGpuInstanceProfileInfo(Profile int) (GpuInstanceProfileInfo, Return) - GetGpuInstances(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return) - GetIndex() (int, Return) - GetMaxMigDeviceCount() (int, Return) - GetMemoryInfo() (Memory, Return) - GetMigDeviceHandleByIndex(Index int) (Device, Return) - GetMigMode() (int, int, Return) - GetMinorNumber() (int, Return) - GetName() (string, Return) - GetNvLinkRemotePciInfo(int) (PciInfo, Return) - GetNvLinkState(int) (EnableState, Return) - GetPciInfo() (PciInfo, Return) - GetSupportedEventTypes() (uint64, Return) - GetTopologyCommonAncestor(Device) (GpuTopologyLevel, Return) - 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 -// -//go:generate moq -out gi_mock.go . GpuInstance -type GpuInstance interface { - CreateComputeInstance(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return) - Destroy() Return - GetComputeInstanceById(ID int) (ComputeInstance, Return) - GetComputeInstanceProfileInfo(Profile int, EngProfile int) (ComputeInstanceProfileInfo, Return) - GetComputeInstances(Info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) - GetInfo() (GpuInstanceInfo, Return) -} - -// ComputeInstance defines the functions implemented by a ComputeInstance -// -//go:generate moq -out ci_mock.go . ComputeInstance -type ComputeInstance interface { - Destroy() Return - GetInfo() (ComputeInstanceInfo, Return) -} - -// GpuInstanceInfo holds info about a GPU Instance -type GpuInstanceInfo struct { - Device Device - Id uint32 - ProfileId uint32 - Placement GpuInstancePlacement -} - -// ComputeInstanceInfo holds info about a Compute Instance -type ComputeInstanceInfo struct { - Device Device - GpuInstance GpuInstance - Id uint32 - ProfileId uint32 - Placement ComputeInstancePlacement -} - -// EventData defines NVML event Data -type EventData struct { - Device Device - EventType uint64 - EventData uint64 - GpuInstanceId uint32 - ComputeInstanceId uint32 -} - -// EventSet defines NVML event Data -type EventSet nvml.EventSet - -// Return defines an NVML return type -type Return nvml.Return - -// Memory holds info about GPU device memory -type Memory nvml.Memory - -// PciInfo holds info about the PCI connections of a GPU dvice -type PciInfo nvml.PciInfo - -// GpuInstanceProfileInfo holds info about a GPU Instance Profile -type GpuInstanceProfileInfo nvml.GpuInstanceProfileInfo - -// GpuInstancePlacement holds placement info about a GPU Instance -type GpuInstancePlacement nvml.GpuInstancePlacement - -// ComputeInstanceProfileInfo holds info about a Compute Instance Profile -type ComputeInstanceProfileInfo nvml.ComputeInstanceProfileInfo - -// ComputeInstancePlacement holds placement info about a Compute Instance -type ComputeInstancePlacement nvml.ComputeInstancePlacement - -// DeviceAttributes stores information about MIG devices -type DeviceAttributes nvml.DeviceAttributes - -// DeviceArchitecture represents the hardware architecture of a GPU device -type DeviceArchitecture nvml.DeviceArchitecture - -// BrandType represents the brand of a GPU device -type BrandType nvml.BrandType - -// GpuTopologyLevel represents level relationships within a system between two GPUs -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 diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes/bytes.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes/bytes.go index 7788a1fb..04fb4aa9 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes/bytes.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes/bytes.go @@ -21,12 +21,12 @@ import ( "unsafe" ) -// Raw returns just the bytes without any assumptions about layout +// Raw returns just the bytes without any assumptions about layout. type Raw interface { Raw() *[]byte } -// Reader used to read various data sizes in the byte array +// Reader used to read various data sizes in the byte array. type Reader interface { Read8(pos int) uint8 Read16(pos int) uint16 @@ -35,7 +35,7 @@ type Reader interface { Len() int } -// Writer used to write various sizes of data in the byte array +// Writer used to write various sizes of data in the byte array. type Writer interface { Write8(pos int, value uint8) Write16(pos int, value uint16) @@ -44,7 +44,7 @@ type Writer interface { Len() int } -// Bytes object for manipulating arbitrary byte arrays +// Bytes object for manipulating arbitrary byte arrays. type Bytes interface { Raw Reader @@ -70,12 +70,12 @@ func init() { } } -// New raw bytearray +// New raw bytearray. func New(data *[]byte) Bytes { return (*native)(data) } -// NewLittleEndian little endian ordering of bytes +// NewLittleEndian little endian ordering of bytes. func NewLittleEndian(data *[]byte) Bytes { if nativeByteOrder == binary.LittleEndian { return (*native)(data) @@ -84,7 +84,7 @@ func NewLittleEndian(data *[]byte) Bytes { return (*swapbo)(data) } -// NewBigEndian big endian ordering of bytes +// NewBigEndian big endian ordering of bytes. func NewBigEndian(data *[]byte) Bytes { if nativeByteOrder == binary.BigEndian { return (*native)(data) diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/config.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/config.go index e25e72f6..397c8650 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/config.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/config.go @@ -24,24 +24,24 @@ import ( ) const ( - // PCICfgSpaceStandardSize represents the size in bytes of the standard config space + // PCICfgSpaceStandardSize represents the size in bytes of the standard config space. PCICfgSpaceStandardSize = 256 - // PCICfgSpaceExtendedSize represents the size in bytes of the extended config space + // PCICfgSpaceExtendedSize represents the size in bytes of the extended config space. PCICfgSpaceExtendedSize = 4096 - // PCICapabilityListPointer represents offset for the capability list pointer + // PCICapabilityListPointer represents offset for the capability list pointer. PCICapabilityListPointer = 0x34 - // PCIStatusCapabilityList represents the status register bit which indicates capability list support + // PCIStatusCapabilityList represents the status register bit which indicates capability list support. PCIStatusCapabilityList = 0x10 - // PCIStatusBytePosition represents the position of the status register + // PCIStatusBytePosition represents the position of the status register. PCIStatusBytePosition = 0x06 ) -// ConfigSpace PCI configuration space (standard extended) file path +// ConfigSpace PCI configuration space (standard extended) file path. type ConfigSpace struct { Path string } -// ConfigSpaceIO Interface for reading and writing raw and preconfigured values +// ConfigSpaceIO Interface for reading and writing raw and preconfigured values. type ConfigSpaceIO interface { bytes.Bytes GetVendorID() uint16 @@ -53,18 +53,18 @@ type configSpaceIO struct { bytes.Bytes } -// PCIStandardCapability standard PCI config space +// PCIStandardCapability standard PCI config space. type PCIStandardCapability struct { bytes.Bytes } -// PCIExtendedCapability extended PCI config space +// PCIExtendedCapability extended PCI config space. type PCIExtendedCapability struct { bytes.Bytes Version uint8 } -// PCICapabilities combines the standard and extended config space +// PCICapabilities combines the standard and extended config space. type PCICapabilities struct { Standard map[uint8]*PCIStandardCapability Extended map[uint16]*PCIExtendedCapability diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mlxpci.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mlxpci.go index 62937d7f..ddf7d19f 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mlxpci.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mlxpci.go @@ -22,15 +22,15 @@ import ( ) const ( - // PCIMellanoxVendorID represents PCI vendor id for Mellanox + // PCIMellanoxVendorID represents PCI vendor id for Mellanox. PCIMellanoxVendorID uint16 = 0x15b3 - // PCINetworkControllerClass represents the PCI class for network controllers + // PCINetworkControllerClass represents the PCI class for network controllers. PCINetworkControllerClass uint32 = 0x020000 - // PCIBridgeClass represents the PCI class for network controllers + // PCIBridgeClass represents the PCI class for network controllers. PCIBridgeClass uint32 = 0x060400 ) -// GetNetworkControllers returns all Mellanox Network Controller PCI devices on the system +// GetNetworkControllers returns all Mellanox Network Controller PCI devices on the system. func (p *nvpci) GetNetworkControllers() ([]*NvidiaPCIDevice, error) { devices, err := p.GetAllDevices() if err != nil { @@ -47,7 +47,7 @@ func (p *nvpci) GetNetworkControllers() ([]*NvidiaPCIDevice, error) { return filtered, nil } -// GetPciBridges retrieves all Mellanox PCI(e) Bridges +// GetPciBridges retrieves all Mellanox PCI(e) Bridges. func (p *nvpci) GetPciBridges() ([]*NvidiaPCIDevice, error) { devices, err := p.GetAllDevices() if err != nil { @@ -64,17 +64,17 @@ func (p *nvpci) GetPciBridges() ([]*NvidiaPCIDevice, error) { return filtered, nil } -// IsNetworkController if class == 0x300 +// IsNetworkController if class == 0x300. func (d *NvidiaPCIDevice) IsNetworkController() bool { return d.Class == PCINetworkControllerClass } -// IsPciBridge if class == 0x0604 +// IsPciBridge if class == 0x0604. func (d *NvidiaPCIDevice) IsPciBridge() bool { return d.Class == PCIBridgeClass } -// IsDPU returns if a device is a DPU +// IsDPU returns if a device is a DPU. func (d *NvidiaPCIDevice) IsDPU() bool { if !strings.Contains(d.DeviceName, "BlueField") { return false @@ -87,7 +87,7 @@ func (d *NvidiaPCIDevice) IsDPU() bool { return false } -// GetDPUs returns all Mellanox DPU devices on the system +// GetDPUs returns all Mellanox DPU devices on the system. func (p *nvpci) GetDPUs() ([]*NvidiaPCIDevice, error) { devices, err := p.GetNetworkControllers() if err != nil { diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mmio.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mmio.go index 1535fa04..88dd7ddf 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mmio.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mmio.go @@ -25,7 +25,7 @@ import ( "github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes" ) -// Mmio memory map a region +// Mmio memory map a region. type Mmio interface { bytes.Raw bytes.Reader @@ -84,12 +84,12 @@ func open(path string, offset int, size int, flags int) (Mmio, error) { return &mmio{bytes.New(&mmap)}, nil } -// OpenRO open region readonly +// OpenRO open region readonly. func OpenRO(path string, offset int, size int) (Mmio, error) { return open(path, offset, size, os.O_RDONLY) } -// OpenRW open region read write +// OpenRW open region read write. func OpenRW(path string, offset int, size int) (Mmio, error) { return open(path, offset, size, os.O_RDWR) } diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mock.go index 57151b3f..da3074c1 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mock.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mock.go @@ -48,18 +48,21 @@ func mockOpen(source *[]byte, offset int, size int, rw bool) (Mmio, error) { return m, nil } -// MockOpenRO open read only +// MockOpenRO open read only. func MockOpenRO(source *[]byte, offset int, size int) (Mmio, error) { return mockOpen(source, offset, size, false) } -// MockOpenRW open read write +// MockOpenRW open read write. func MockOpenRW(source *[]byte, offset int, size int) (Mmio, error) { return mockOpen(source, offset, size, true) } func (m *mockMmio) Close() error { - m = &mockMmio{} + m.Bytes = nil + m.source = nil + m.offset = 0 + m.rw = false return nil } diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mock.go index e4227121..7c1b69dd 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mock.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mock.go @@ -24,14 +24,14 @@ import ( "github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes" ) -// MockNvpci mock pci device +// MockNvpci mock pci device. type MockNvpci struct { *nvpci } var _ Interface = (*MockNvpci)(nil) -// NewMockNvpci create new mock PCI and remove old devices +// NewMockNvpci create new mock PCI and remove old devices. func NewMockNvpci() (mock *MockNvpci, rerr error) { rootDir, err := os.MkdirTemp(os.TempDir(), "") if err != nil { @@ -50,12 +50,12 @@ func NewMockNvpci() (mock *MockNvpci, rerr error) { return mock, nil } -// Cleanup remove the mocked PCI devices root folder +// Cleanup remove the mocked PCI devices root folder. func (m *MockNvpci) Cleanup() { os.RemoveAll(m.pciDevicesRoot) } -// AddMockA100 Create an A100 like GPU mock device +// AddMockA100 Create an A100 like GPU mock device. func (m *MockNvpci) AddMockA100(address string, numaNode int) error { deviceDir := filepath.Join(m.pciDevicesRoot, address) err := os.MkdirAll(deviceDir, 0755) diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go index 5210ff50..6d83a577 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go @@ -29,23 +29,23 @@ import ( ) const ( - // PCIDevicesRoot represents base path for all pci devices under sysfs + // PCIDevicesRoot represents base path for all pci devices under sysfs. PCIDevicesRoot = "/sys/bus/pci/devices" - // PCINvidiaVendorID represents PCI vendor id for NVIDIA + // PCINvidiaVendorID represents PCI vendor id for NVIDIA. PCINvidiaVendorID uint16 = 0x10de - // PCIVgaControllerClass represents the PCI class for VGA Controllers + // PCIVgaControllerClass represents the PCI class for VGA Controllers. PCIVgaControllerClass uint32 = 0x030000 - // PCI3dControllerClass represents the PCI class for 3D Graphics accellerators + // PCI3dControllerClass represents the PCI class for 3D Graphics accellerators. PCI3dControllerClass uint32 = 0x030200 - // PCINvSwitchClass represents the PCI class for NVSwitches + // PCINvSwitchClass represents the PCI class for NVSwitches. PCINvSwitchClass uint32 = 0x068000 - // UnknownDeviceString is the device name to set for devices not found in the PCI database + // UnknownDeviceString is the device name to set for devices not found in the PCI database. UnknownDeviceString = "UNKNOWN_DEVICE" - // UnknownClassString is the class name to set for devices not found in the PCI database + // UnknownClassString is the class name to set for devices not found in the PCI database. UnknownClassString = "UNKNOWN_CLASS" ) -// Interface allows us to get a list of all NVIDIA PCI devices +// Interface allows us to get a list of all NVIDIA PCI devices. type Interface interface { GetAllDevices() ([]*NvidiaPCIDevice, error) Get3DControllers() ([]*NvidiaPCIDevice, error) @@ -59,10 +59,10 @@ type Interface interface { GetDPUs() ([]*NvidiaPCIDevice, error) } -// MemoryResources a more human readable handle +// MemoryResources a more human readable handle. type MemoryResources map[int]*MemoryResource -// ResourceInterface exposes some higher level functions of resources +// ResourceInterface exposes some higher level functions of resources. type ResourceInterface interface { GetTotalAddressableMemory(bool) (uint64, uint64) } @@ -76,7 +76,7 @@ type nvpci struct { var _ Interface = (*nvpci)(nil) var _ ResourceInterface = (*MemoryResources)(nil) -// NvidiaPCIDevice represents a PCI device for an NVIDIA product +// NvidiaPCIDevice represents a PCI device for an NVIDIA product. type NvidiaPCIDevice struct { Path string Address string @@ -93,34 +93,34 @@ type NvidiaPCIDevice struct { IsVF bool } -// IsVGAController if class == 0x300 +// IsVGAController if class == 0x300. func (d *NvidiaPCIDevice) IsVGAController() bool { return d.Class == PCIVgaControllerClass } -// Is3DController if class == 0x302 +// Is3DController if class == 0x302. func (d *NvidiaPCIDevice) Is3DController() bool { return d.Class == PCI3dControllerClass } -// IsNVSwitch if class == 0x068 +// IsNVSwitch if class == 0x068. func (d *NvidiaPCIDevice) IsNVSwitch() bool { return d.Class == PCINvSwitchClass } -// IsGPU either VGA for older cards or 3D for newer +// IsGPU either VGA for older cards or 3D for newer. func (d *NvidiaPCIDevice) IsGPU() bool { return d.IsVGAController() || d.Is3DController() } // IsResetAvailable some devices can be reset without rebooting, -// check if applicable +// check if applicable. func (d *NvidiaPCIDevice) IsResetAvailable() bool { _, err := os.Stat(path.Join(d.Path, "reset")) return err == nil } -// Reset perform a reset to apply a new configuration at HW level +// Reset perform a reset to apply a new configuration at HW level. func (d *NvidiaPCIDevice) Reset() error { err := os.WriteFile(path.Join(d.Path, "reset"), []byte("1"), 0) if err != nil { @@ -129,7 +129,7 @@ func (d *NvidiaPCIDevice) Reset() error { return nil } -// New interface that allows us to get a list of all NVIDIA PCI devices +// New interface that allows us to get a list of all NVIDIA PCI devices. func New(opts ...Option) Interface { n := &nvpci{} for _, opt := range opts { @@ -144,10 +144,10 @@ func New(opts ...Option) Interface { return n } -// Option defines a function for passing options to the New() call +// Option defines a function for passing options to the New() call. type Option func(*nvpci) -// WithLogger provides an Option to set the logger for the library +// WithLogger provides an Option to set the logger for the library. func WithLogger(logger logger) Option { return func(n *nvpci) { n.logger = logger @@ -170,7 +170,7 @@ func WithPCIDatabasePath(path string) Option { } } -// GetAllDevices returns all Nvidia PCI devices on the system +// GetAllDevices returns all Nvidia PCI devices on the system. func (p *nvpci) GetAllDevices() ([]*NvidiaPCIDevice, error) { deviceDirs, err := os.ReadDir(p.pciDevicesRoot) if err != nil { @@ -204,7 +204,7 @@ func (p *nvpci) GetAllDevices() ([]*NvidiaPCIDevice, error) { return nvdevices, nil } -// GetGPUByPciBusID constructs an NvidiaPCIDevice for the specified address (PCI Bus ID) +// GetGPUByPciBusID constructs an NvidiaPCIDevice for the specified address (PCI Bus ID). func (p *nvpci) GetGPUByPciBusID(address string) (*NvidiaPCIDevice, error) { devicePath := filepath.Join(p.pciDevicesRoot, address) @@ -265,7 +265,7 @@ func (p *nvpci) GetGPUByPciBusID(address string) (*NvidiaPCIDevice, error) { return nil, fmt.Errorf("unable to detect iommu_group for %s: %v", address, err) } - // device is a virtual function (VF) if "physfn" symlink exists + // device is a virtual function (VF) if "physfn" symlink exists. var isVF bool _, err = filepath.EvalSymlinks(path.Join(devicePath, "physfn")) if err == nil { @@ -347,7 +347,7 @@ func (p *nvpci) GetGPUByPciBusID(address string) (*NvidiaPCIDevice, error) { return nvdevice, nil } -// Get3DControllers returns all NVIDIA 3D Controller PCI devices on the system +// Get3DControllers returns all NVIDIA 3D Controller PCI devices on the system. func (p *nvpci) Get3DControllers() ([]*NvidiaPCIDevice, error) { devices, err := p.GetAllDevices() if err != nil { @@ -364,7 +364,7 @@ func (p *nvpci) Get3DControllers() ([]*NvidiaPCIDevice, error) { return filtered, nil } -// GetVGAControllers returns all NVIDIA VGA Controller PCI devices on the system +// GetVGAControllers returns all NVIDIA VGA Controller PCI devices on the system. func (p *nvpci) GetVGAControllers() ([]*NvidiaPCIDevice, error) { devices, err := p.GetAllDevices() if err != nil { @@ -381,7 +381,7 @@ func (p *nvpci) GetVGAControllers() ([]*NvidiaPCIDevice, error) { return filtered, nil } -// GetNVSwitches returns all NVIDIA NVSwitch PCI devices on the system +// GetNVSwitches returns all NVIDIA NVSwitch PCI devices on the system. func (p *nvpci) GetNVSwitches() ([]*NvidiaPCIDevice, error) { devices, err := p.GetAllDevices() if err != nil { @@ -398,7 +398,7 @@ func (p *nvpci) GetNVSwitches() ([]*NvidiaPCIDevice, error) { return filtered, nil } -// GetGPUs returns all NVIDIA GPU devices on the system +// GetGPUs returns all NVIDIA GPU devices on the system. func (p *nvpci) GetGPUs() ([]*NvidiaPCIDevice, error) { devices, err := p.GetAllDevices() if err != nil { @@ -415,7 +415,7 @@ func (p *nvpci) GetGPUs() ([]*NvidiaPCIDevice, error) { return filtered, nil } -// GetGPUByIndex returns an NVIDIA GPU device at a particular index +// GetGPUByIndex returns an NVIDIA GPU device at a particular index. func (p *nvpci) GetGPUByIndex(i int) (*NvidiaPCIDevice, error) { gpus, err := p.GetGPUs() if err != nil { diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/resources.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/resources.go index 6c6e53ee..b3b7d315 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/resources.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/resources.go @@ -29,7 +29,7 @@ const ( pmcBigEndian = 0x01000001 ) -// MemoryResource represents a mmio region +// MemoryResource represents a mmio region. type MemoryResource struct { Start uintptr End uintptr @@ -37,7 +37,7 @@ type MemoryResource struct { Path string } -// OpenRW read write mmio region +// OpenRW read write mmio region. func (mr *MemoryResource) OpenRW() (mmio.Mmio, error) { rw, err := mmio.OpenRW(mr.Path, 0, int(mr.End-mr.Start+1)) if err != nil { @@ -52,7 +52,7 @@ func (mr *MemoryResource) OpenRW() (mmio.Mmio, error) { return nil, fmt.Errorf("unknown endianness for mmio: %v", err) } -// OpenRO read only mmio region +// OpenRO read only mmio region. func (mr *MemoryResource) OpenRO() (mmio.Mmio, error) { ro, err := mmio.OpenRO(mr.Path, 0, int(mr.End-mr.Start+1)) if err != nil { @@ -67,7 +67,7 @@ func (mr *MemoryResource) OpenRO() (mmio.Mmio, error) { return nil, fmt.Errorf("unknown endianness for mmio: %v", err) } -// From Bit Twiddling Hacks, great resource for all low level bit manipulations +// From Bit Twiddling Hacks, great resource for all low level bit manipulations. func calcNextPowerOf2(n uint64) uint64 { n-- n |= n >> 1 @@ -83,7 +83,7 @@ func calcNextPowerOf2(n uint64) uint64 { // GetTotalAddressableMemory will accumulate the 32bit and 64bit memory windows // of each BAR and round the value if needed to the next power of 2; first -// return value is the accumulated 32bit addresable memory size the second one +// return value is the accumulated 32bit addressable memory size the second one // is the accumulated 64bit addressable memory size in bytes. These values are // needed to configure virtualized environments. func (mrs MemoryResources) GetTotalAddressableMemory(roundUp bool) (uint64, uint64) { diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/pciids/pciids.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/pciids/pciids.go index 5f25c004..343df08d 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/pciids/pciids.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/pciids/pciids.go @@ -11,42 +11,42 @@ import ( "strings" ) -// token what the Lexer retruns +// token what the Lexer retruns. type token int const ( - // ILLEGAL a token which the Lexer does not understand + // ILLEGAL a token which the Lexer does not understand. ILLEGAL token = iota - // EOF end of file + // EOF end of file. EOF - // WS whitespace + // WS whitespace. WS - // NEWLINE '\n' + // NEWLINE '\n'. NEWLINE - // COMMENT '# something' + // COMMENT '# something'. COMMENT - // VENDOR PCI vendor + // VENDOR PCI vendor. VENDOR - // SUBVENDOR PCI subvendor + // SUBVENDOR PCI subvendor. SUBVENDOR - // DEVICE PCI device + // DEVICE PCI device. DEVICE - // CLASS PCI class + // CLASS PCI class. CLASS - // SUBCLASS PCI subclass + // SUBCLASS PCI subclass. SUBCLASS - // PROGIF PCI programming interface + // PROGIF PCI programming interface. PROGIF ) -// literal values from the Lexer +// literal values from the Lexer. type literal struct { ID string name string SubName string } -// scanner a lexical scanner +// scanner a lexical scanner. type scanner struct { r *bufio.Reader isVendor bool @@ -58,7 +58,7 @@ func newScanner(r io.Reader) *scanner { } // Since the pci.ids is line base we're consuming a whole line rather then only -// a single rune/char +// a single rune/char. func (s *scanner) readline() []byte { ln, err := s.r.ReadBytes('\n') if err == io.EOF { @@ -107,7 +107,7 @@ func isSubVendor(ln []byte) bool { return isLeadingTwoTabs(ln) } func isDevice(ln []byte) bool { return isLeadingOneTab(ln) } func isNewline(ln []byte) bool { return (ln[0] == '\n') } -// List of known device classes, subclasses and programming interfaces +// List of known device classes, subclasses and programming interfaces. func isClass(ln []byte) bool { return (ln[0] == 'C') } func isProgIf(ln []byte) bool { return isLeadingTwoTabs(ln) } func isSubClass(ln []byte) bool { return isLeadingOneTab(ln) } @@ -162,7 +162,7 @@ func (s *scanner) scan() (tok token, lit literal) { return ILLEGAL, literal{ID: string(line)} } -// parser reads the tokens returned by the Lexer and constructs the AST +// parser reads the tokens returned by the Lexer and constructs the AST. type parser struct { s *scanner buf struct { @@ -173,7 +173,7 @@ type parser struct { } // Various locations of pci.ids for different distributions. These may be more -// up to date then the embedded pci.ids db +// up to date then the embedded pci.ids db. var defaultPCIdbPaths = []string{ "/usr/share/misc/pci.ids", // Ubuntu "/usr/local/share/pci.ids", // RHEL like with manual update @@ -202,7 +202,7 @@ func NewDB(opts ...Option) Interface { return newParser(pcidbs).parse() } -// Option defines a function for passing options to the NewDB() call +// Option defines a function for passing options to the NewDB() call. type Option func(*pcidb) // WithFilePath provides an Option to set the file path @@ -216,7 +216,7 @@ func WithFilePath(path string) Option { } // newParser will attempt to read the db pci.ids from well known places or fall -// back to an internal db +// back to an internal db. func newParser(pcidbs []string) *parser { for _, db := range pcidbs { @@ -229,7 +229,7 @@ func newParser(pcidbs []string) *parser { } // We're using go embed above to have the byte array // correctly initialized with the internal shipped db - // if we cannot find an up to date in the filesystem + // if we cannot find an up to date in the filesystem. return newParserFromReader(bufio.NewReader(bytes.NewReader(defaultPCIdb))) } @@ -252,13 +252,13 @@ func (p *parser) unscan() { p.buf.n = 1 } var _ Interface = (*pcidb)(nil) -// Interface returns textual description of specific attributes of PCI devices +// Interface returns textual description of specific attributes of PCI devices. type Interface interface { GetDeviceName(uint16, uint16) (string, error) GetClassName(uint32) (string, error) } -// GetDeviceName return the textual description of the PCI device +// GetDeviceName return the textual description of the PCI device. func (d *pcidb) GetDeviceName(vendorID uint16, deviceID uint16) (string, error) { vendor, ok := d.vendors[vendorID] if !ok { @@ -273,7 +273,7 @@ func (d *pcidb) GetDeviceName(vendorID uint16, deviceID uint16) (string, error) return device.name, nil } -// GetClassName resturn the textual description of the PCI device class +// GetClassName resturn the textual description of the PCI device class. func (d *pcidb) GetClassName(classID uint32) (string, error) { class, ok := d.classes[classID] if !ok { @@ -282,53 +282,53 @@ func (d *pcidb) GetClassName(classID uint32) (string, error) { return class.name, nil } -// pcidb The complete set of PCI vendors and PCI classes +// pcidb The complete set of PCI vendors and PCI classes. type pcidb struct { vendors map[uint16]vendor classes map[uint32]class path string } -// vendor PCI vendors/devices/subVendors/SubDevices +// vendor PCI vendors/devices/subVendors/SubDevices. type vendor struct { name string devices map[uint16]device } -// subVendor PCI subVendor +// subVendor PCI subVendor. type subVendor struct { SubDevices map[uint16]SubDevice } -// SubDevice PCI SubDevice +// SubDevice PCI SubDevice. type SubDevice struct { name string } -// device PCI device +// device PCI device. type device struct { name string subVendors map[uint16]subVendor } -// class PCI classes/subClasses/Programming Interfaces +// class PCI classes/subClasses/Programming Interfaces. type class struct { name string subClasses map[uint32]subClass } -// subClass PCI subClass +// subClass PCI subClass. type subClass struct { name string progIfs map[uint8]progIf } -// progIf PCI Programming Interface +// progIf PCI Programming Interface. type progIf struct { name string } -// parse parses a PCI IDS entry +// parse parses a PCI IDS entry. func (p *parser) parse() Interface { db := &pcidb{ @@ -336,7 +336,7 @@ func (p *parser) parse() Interface { classes: map[uint32]class{}, } - // Used for housekeeping, breadcrumb for aggregated types + // Used for housekeeping, breadcrumb for aggregated types. var hkVendor vendor var hkDevice device @@ -349,8 +349,8 @@ func (p *parser) parse() Interface { for { tok, lit := p.scan() - // We're ignoring COMMENT, NEWLINE - // An EOF will break the loop + // We're ignoring COMMENT, NEWLINE. + // An EOF will break the loop. if tok == EOF { break } @@ -408,10 +408,10 @@ func (p *parser) parse() Interface { } hkSubClass = hkClass.subClasses[uint32(id)] - // Clear the last detected sub class + // Clear the last detected sub class. hkFullID = hkFullID & 0xFFFF0000 hkFullID = hkFullID | uint32(id)<<8 - // Clear the last detected prog iface + // Clear the last detected prog iface. hkFullID = hkFullID & 0xFFFFFF00 hkFullName[1] = fmt.Sprintf("%s (%02x)", lit.name, id) diff --git a/vendor/modules.txt b/vendor/modules.txt index 922ccea4..35d09407 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,8 +1,7 @@ -# github.com/NVIDIA/go-nvlib v0.2.0 +# github.com/NVIDIA/go-nvlib v0.3.0 ## explicit; go 1.20 github.com/NVIDIA/go-nvlib/pkg/nvlib/device github.com/NVIDIA/go-nvlib/pkg/nvlib/info -github.com/NVIDIA/go-nvlib/pkg/nvml github.com/NVIDIA/go-nvlib/pkg/nvpci github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio