From 87c2155ed99fdc6593e038d6edd6a6a1380acb3d Mon Sep 17 00:00:00 2001 From: Kevin Klues Date: Fri, 15 Mar 2024 13:09:15 +0000 Subject: [PATCH] Update to latest go-nvml and go-nvlib Signed-off-by: Kevin Klues --- go.mod | 6 +- go.sum | 12 +- .../go-nvlib/pkg/nvlib/device/identifier.go | 94 ++++++++++++++++ .../NVIDIA/go-nvlib/pkg/nvml/consts.go | 9 ++ .../NVIDIA/go-nvlib/pkg/nvml/device.go | 17 ++- .../NVIDIA/go-nvlib/pkg/nvml/device_mock.go | 82 ++++++++++++++ .../NVIDIA/go-nvlib/pkg/nvml/types.go | 6 + .../github.com/NVIDIA/go-nvml/pkg/nvml/lib.go | 24 ++-- .../NVIDIA/go-nvml/pkg/nvml/refcount.go | 31 ++++++ .../NVIDIA/go-nvml/pkg/nvml/return.go | 77 ++++++++++++- vendor/github.com/google/uuid/.travis.yml | 9 -- vendor/github.com/google/uuid/CHANGELOG.md | 41 +++++++ vendor/github.com/google/uuid/CONTRIBUTING.md | 16 +++ vendor/github.com/google/uuid/README.md | 10 +- vendor/github.com/google/uuid/hash.go | 6 + vendor/github.com/google/uuid/node_js.go | 2 +- vendor/github.com/google/uuid/time.go | 21 +++- vendor/github.com/google/uuid/uuid.go | 89 +++++++++++++-- vendor/github.com/google/uuid/version6.go | 56 ++++++++++ vendor/github.com/google/uuid/version7.go | 104 ++++++++++++++++++ vendor/modules.txt | 8 +- 21 files changed, 663 insertions(+), 57 deletions(-) create mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/identifier.go create mode 100644 vendor/github.com/NVIDIA/go-nvml/pkg/nvml/refcount.go delete mode 100644 vendor/github.com/google/uuid/.travis.yml create mode 100644 vendor/github.com/google/uuid/CHANGELOG.md create mode 100644 vendor/github.com/google/uuid/version6.go create mode 100644 vendor/github.com/google/uuid/version7.go diff --git a/go.mod b/go.mod index c49799d6..0c830c37 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/NVIDIA/k8s-dra-driver go 1.22 require ( - github.com/NVIDIA/go-nvlib v0.0.0-20231116150931-9fd385bace0d - github.com/NVIDIA/go-nvml v0.12.0-2 + github.com/NVIDIA/go-nvlib v0.2.0 + github.com/NVIDIA/go-nvml v0.12.0-3 github.com/NVIDIA/nvidia-container-toolkit v1.14.4-0.20231120225202-039d7fd32429 github.com/prometheus/client_golang v1.19.0 github.com/sirupsen/logrus v1.9.3 @@ -44,7 +44,7 @@ require ( github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/imdario/mergo v0.3.6 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect diff --git a/go.sum b/go.sum index 04519f33..984de944 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ -github.com/NVIDIA/go-nvlib v0.0.0-20231116150931-9fd385bace0d h1:XxRHS7eNkZVcPpZZmUcoT4oO8FEcoYKn06sooQh5niU= -github.com/NVIDIA/go-nvlib v0.0.0-20231116150931-9fd385bace0d/go.mod h1:HPFNPAYqQeoos58MKUboWsdZMu71EzSQrbmd+QBRD40= -github.com/NVIDIA/go-nvml v0.12.0-2 h1:Sg239yy7jmopu/cuvYauoMj9fOpcGMngxVxxS1EBXeY= -github.com/NVIDIA/go-nvml v0.12.0-2/go.mod h1:7ruy85eOM73muOc/I37euONSwEyFqZsv5ED9AogD4G0= +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-nvml v0.12.0-3 h1:QwfjYxEqIQVRhl8327g2Y3ZvKResPydpGSKtCIIK9jE= +github.com/NVIDIA/go-nvml v0.12.0-3/go.mod h1:SOufGc5Wql+cxrIZ8RyJwVKDYxfbs4WPkHXqadcbfvA= github.com/NVIDIA/nvidia-container-toolkit v1.14.4-0.20231120225202-039d7fd32429 h1:+iGAHhhsREKFiJb1A+txLMVi3oPAoNC2kH8AtQsbzRc= github.com/NVIDIA/nvidia-container-toolkit v1.14.4-0.20231120225202-039d7fd32429/go.mod h1:yd+UnaIUSX3vjLVfewaDQ+R7XrgG38+hMZZXrygK3w0= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= @@ -56,8 +56,9 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -140,7 +141,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI= 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 new file mode 100644 index 00000000..689de6d4 --- /dev/null +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/identifier.go @@ -0,0 +1,94 @@ +/* + * Copyright (c) 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 device + +import ( + "strconv" + "strings" + + "github.com/google/uuid" +) + +// Identifier can be used to refer to a GPU or MIG device. +// This includes a device index or UUID. +type Identifier string + +// 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 + } + return true +} + +// IsMigIndex checks if an identifier is a MIG index +func (i Identifier) IsMigIndex() bool { + split := strings.Split(string(i), ":") + if len(split) != 2 { + return false + } + for _, s := range split { + if !Identifier(s).IsGpuIndex() { + return false + } + } + return true +} + +// 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 +func (i Identifier) IsGpuUUID() bool { + if !strings.HasPrefix(string(i), "GPU-") { + return false + } + _, err := uuid.Parse(strings.TrimPrefix(string(i), "GPU-")) + return err == nil +} + +// 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 +func (i Identifier) IsMigUUID() bool { + if !strings.HasPrefix(string(i), "MIG-") { + return false + } + suffix := strings.TrimPrefix(string(i), "MIG-") + _, err := uuid.Parse(suffix) + if err == nil { + return true + } + split := strings.Split(suffix, "/") + if len(split) != 3 { + return false + } + if !Identifier(split[0]).IsGpuUUID() { + return false + } + for _, s := range split[1:] { + _, err := strconv.ParseUint(s, 10, 0) + if err != nil { + return false + } + } + return true +} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go index d6a7ee36..cba00b98 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go @@ -152,3 +152,12 @@ const ( FEATURE_DISABLED = EnableState(nvml.FEATURE_DISABLED) FEATURE_ENABLED = EnableState(nvml.FEATURE_ENABLED) ) + +// Compute mode constants +const ( + COMPUTEMODE_DEFAULT = ComputeMode(nvml.COMPUTEMODE_DEFAULT) + COMPUTEMODE_EXCLUSIVE_THREAD = ComputeMode(nvml.COMPUTEMODE_EXCLUSIVE_THREAD) + COMPUTEMODE_PROHIBITED = ComputeMode(nvml.COMPUTEMODE_PROHIBITED) + COMPUTEMODE_EXCLUSIVE_PROCESS = ComputeMode(nvml.COMPUTEMODE_EXCLUSIVE_PROCESS) + COMPUTEMODE_COUNT = ComputeMode(nvml.COMPUTEMODE_COUNT) +) diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go index 3901bb74..777a9daa 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go @@ -22,6 +22,11 @@ type nvmlDevice nvml.Device var _ Device = (*nvmlDevice)(nil) +// nvmlDeviceHandle returns a pointer to the underlying device. +func (d nvmlDevice) nvmlDeviceHandle() *nvml.Device { + return (*nvml.Device)(&d) +} + // GetIndex returns the index of a Device func (d nvmlDevice) GetIndex() (int, Return) { i, r := nvml.Device(d).GetIndex() @@ -181,12 +186,12 @@ func (d nvmlDevice) GetSupportedEventTypes() (uint64, Return) { // GetTopologyCommonAncestor retrieves the common ancestor for two devices. func (d nvmlDevice) GetTopologyCommonAncestor(o Device) (GpuTopologyLevel, Return) { - other, ok := o.(nvmlDevice) - if !ok { + other := o.nvmlDeviceHandle() + if other == nil { return 0, ERROR_INVALID_ARGUMENT } - l, r := nvml.Device(d).GetTopologyCommonAncestor(nvml.Device(other)) + l, r := nvml.Device(d).GetTopologyCommonAncestor(*other) return GpuTopologyLevel(l), Return(r) } @@ -202,3 +207,9 @@ func (d nvmlDevice) GetNvLinkRemotePciInfo(link int) (PciInfo, Return) { p, r := nvml.Device(d).GetNvLinkRemotePciInfo(link) return PciInfo(p), Return(r) } + +// SetComputeMode sets the compute mode for the device. +func (d nvmlDevice) SetComputeMode(mode ComputeMode) Return { + r := nvml.Device(d).SetComputeMode(nvml.ComputeMode(mode)) + return Return(r) +} 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 index 17dfe259..84f14722 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device_mock.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device_mock.go @@ -4,6 +4,7 @@ package nvml import ( + "github.com/NVIDIA/go-nvml/pkg/nvml" "sync" ) @@ -98,9 +99,15 @@ var _ Device = &DeviceMock{} // RegisterEventsFunc: func(v uint64, eventSet EventSet) Return { // panic("mock out the RegisterEvents method") // }, +// SetComputeModeFunc: func(computeMode ComputeMode) Return { +// panic("mock out the SetComputeMode method") +// }, // SetMigModeFunc: func(Mode int) (Return, Return) { // panic("mock out the SetMigMode method") // }, +// nvmlDeviceHandleFunc: func() *nvml.Device { +// panic("mock out the nvmlDeviceHandle method") +// }, // } // // // use mockedDevice in code that requires Device @@ -189,9 +196,15 @@ type DeviceMock struct { // RegisterEventsFunc mocks the RegisterEvents method. RegisterEventsFunc func(v uint64, eventSet EventSet) Return + // SetComputeModeFunc mocks the SetComputeMode method. + SetComputeModeFunc func(computeMode ComputeMode) Return + // SetMigModeFunc mocks the SetMigMode method. SetMigModeFunc func(Mode int) (Return, Return) + // nvmlDeviceHandleFunc mocks the nvmlDeviceHandle method. + nvmlDeviceHandleFunc func() *nvml.Device + // calls tracks calls to the methods. calls struct { // CreateGpuInstanceWithPlacement holds details about calls to the CreateGpuInstanceWithPlacement method. @@ -299,11 +312,19 @@ type DeviceMock struct { // EventSet is the eventSet argument value. EventSet EventSet } + // SetComputeMode holds details about calls to the SetComputeMode method. + SetComputeMode []struct { + // ComputeMode is the computeMode argument value. + ComputeMode ComputeMode + } // SetMigMode holds details about calls to the SetMigMode method. SetMigMode []struct { // Mode is the Mode argument value. Mode int } + // nvmlDeviceHandle holds details about calls to the nvmlDeviceHandle method. + nvmlDeviceHandle []struct { + } } lockCreateGpuInstanceWithPlacement sync.RWMutex lockGetArchitecture sync.RWMutex @@ -332,7 +353,9 @@ type DeviceMock struct { lockGetUUID sync.RWMutex lockIsMigDeviceHandle sync.RWMutex lockRegisterEvents sync.RWMutex + lockSetComputeMode sync.RWMutex lockSetMigMode sync.RWMutex + locknvmlDeviceHandle sync.RWMutex } // CreateGpuInstanceWithPlacement calls CreateGpuInstanceWithPlacementFunc. @@ -1122,6 +1145,38 @@ func (mock *DeviceMock) RegisterEventsCalls() []struct { return calls } +// SetComputeMode calls SetComputeModeFunc. +func (mock *DeviceMock) SetComputeMode(computeMode ComputeMode) Return { + if mock.SetComputeModeFunc == nil { + panic("DeviceMock.SetComputeModeFunc: method is nil but Device.SetComputeMode was just called") + } + callInfo := struct { + ComputeMode ComputeMode + }{ + ComputeMode: computeMode, + } + mock.lockSetComputeMode.Lock() + mock.calls.SetComputeMode = append(mock.calls.SetComputeMode, callInfo) + mock.lockSetComputeMode.Unlock() + return mock.SetComputeModeFunc(computeMode) +} + +// SetComputeModeCalls gets all the calls that were made to SetComputeMode. +// Check the length with: +// +// len(mockedDevice.SetComputeModeCalls()) +func (mock *DeviceMock) SetComputeModeCalls() []struct { + ComputeMode ComputeMode +} { + var calls []struct { + ComputeMode ComputeMode + } + mock.lockSetComputeMode.RLock() + calls = mock.calls.SetComputeMode + mock.lockSetComputeMode.RUnlock() + return calls +} + // SetMigMode calls SetMigModeFunc. func (mock *DeviceMock) SetMigMode(Mode int) (Return, Return) { if mock.SetMigModeFunc == nil { @@ -1153,3 +1208,30 @@ func (mock *DeviceMock) SetMigModeCalls() []struct { mock.lockSetMigMode.RUnlock() return calls } + +// nvmlDeviceHandle calls nvmlDeviceHandleFunc. +func (mock *DeviceMock) nvmlDeviceHandle() *nvml.Device { + if mock.nvmlDeviceHandleFunc == nil { + panic("DeviceMock.nvmlDeviceHandleFunc: method is nil but Device.nvmlDeviceHandle was just called") + } + callInfo := struct { + }{} + mock.locknvmlDeviceHandle.Lock() + mock.calls.nvmlDeviceHandle = append(mock.calls.nvmlDeviceHandle, callInfo) + mock.locknvmlDeviceHandle.Unlock() + return mock.nvmlDeviceHandleFunc() +} + +// nvmlDeviceHandleCalls gets all the calls that were made to nvmlDeviceHandle. +// Check the length with: +// +// len(mockedDevice.nvmlDeviceHandleCalls()) +func (mock *DeviceMock) nvmlDeviceHandleCalls() []struct { +} { + var calls []struct { + } + mock.locknvmlDeviceHandle.RLock() + calls = mock.calls.nvmlDeviceHandle + mock.locknvmlDeviceHandle.RUnlock() + return calls +} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go index ecbe4e67..d5150972 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go @@ -67,7 +67,10 @@ type Device interface { GetUUID() (string, Return) IsMigDeviceHandle() (bool, Return) RegisterEvents(uint64, EventSet) Return + SetComputeMode(ComputeMode) Return SetMigMode(Mode int) (Return, Return) + // nvmlDeviceHandle returns a pointer to the underlying NVML device. + nvmlDeviceHandle() *nvml.Device } // GpuInstance defines the functions implemented by a GpuInstance @@ -154,3 +157,6 @@ type GpuTopologyLevel nvml.GpuTopologyLevel // EnableState represents a generic enable/disable enum type EnableState nvml.EnableState + +// ComputeMode represents the compute mode for a device +type ComputeMode nvml.ComputeMode diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/lib.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/lib.go index 4d5eb8e0..be4b3fb7 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/lib.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/lib.go @@ -38,9 +38,10 @@ var errLibraryAlreadyLoaded = errors.New("library already loaded") // This includes a reference to the underlying DynamicLibrary type library struct { sync.Mutex - path string - flags int - dl dynamicLibrary + path string + flags int + refcount refcount + dl dynamicLibrary } // libnvml is a global instance of the nvml library. @@ -77,16 +78,17 @@ var newDynamicLibrary = func(path string, flags int) dynamicLibrary { // load initializes the library and updates the versioned symbols. // Multiple calls to an already loaded library will return without error. -func (l *library) load() error { +func (l *library) load() (rerr error) { l.Lock() defer l.Unlock() - if l.dl != nil { + + defer func() { l.refcount.IncOnNoError(rerr) }() + if l.refcount > 0 { return nil } dl := newDynamicLibrary(l.path, l.flags) - err := dl.Open() - if err != nil { + if err := dl.Open(); err != nil { return fmt.Errorf("error opening %s: %w", l.path, err) } @@ -99,16 +101,16 @@ func (l *library) load() error { // close the underlying library and ensure that the global pointer to the // library is set to nil to ensure that subsequent calls to open will reinitialize it. // Multiple calls to an already closed nvml library will return without error. -func (l *library) close() error { +func (l *library) close() (rerr error) { l.Lock() defer l.Unlock() - if l.dl == nil { + defer func() { l.refcount.DecOnNoError(rerr) }() + if l.refcount != 1 { return nil } - err := l.dl.Close() - if err != nil { + if err := l.dl.Close(); err != nil { return fmt.Errorf("error closing %s: %w", l.path, err) } diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/refcount.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/refcount.go new file mode 100644 index 00000000..4d1e212e --- /dev/null +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/refcount.go @@ -0,0 +1,31 @@ +/** +# Copyright 2024 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 + +type refcount int + +func (r *refcount) IncOnNoError(err error) { + if err == nil { + (*r)++ + } +} + +func (r *refcount) DecOnNoError(err error) { + if err == nil && (*r) > 0 { + (*r)-- + } +} diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/return.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/return.go index fdf11918..0a0cceee 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/return.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/return.go @@ -14,7 +14,80 @@ package nvml +import ( + "fmt" +) + // nvml.ErrorString() -func ErrorString(Result Return) string { - return nvmlErrorString(Result) +func ErrorString(r Return) string { + if err := GetLibrary().Lookup("nvmlErrorString"); err != nil { + return fallbackErrorStringFunc(r) + } + return nvmlErrorString(r) +} + +// fallbackErrorStringFunc provides a basic nvmlErrorString implementation. +// This allows the nvml.ErrorString function to be used even if the NVML library +// is not loaded. +var fallbackErrorStringFunc = func(r Return) string { + switch 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_FREQ_NOT_SUPPORTED: + return "ERROR_FREQ_NOT_SUPPORTED" + case ERROR_ARGUMENT_VERSION_MISMATCH: + return "ERROR_ARGUMENT_VERSION_MISMATCH" + case ERROR_DEPRECATED: + return "ERROR_DEPRECATED" + case ERROR_UNKNOWN: + return "ERROR_UNKNOWN" + default: + return fmt.Sprintf("unknown return value: %d", r) + } } diff --git a/vendor/github.com/google/uuid/.travis.yml b/vendor/github.com/google/uuid/.travis.yml deleted file mode 100644 index d8156a60..00000000 --- a/vendor/github.com/google/uuid/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: go - -go: - - 1.4.3 - - 1.5.3 - - tip - -script: - - go test -v ./... diff --git a/vendor/github.com/google/uuid/CHANGELOG.md b/vendor/github.com/google/uuid/CHANGELOG.md new file mode 100644 index 00000000..7ec5ac7e --- /dev/null +++ b/vendor/github.com/google/uuid/CHANGELOG.md @@ -0,0 +1,41 @@ +# Changelog + +## [1.6.0](https://github.com/google/uuid/compare/v1.5.0...v1.6.0) (2024-01-16) + + +### Features + +* add Max UUID constant ([#149](https://github.com/google/uuid/issues/149)) ([c58770e](https://github.com/google/uuid/commit/c58770eb495f55fe2ced6284f93c5158a62e53e3)) + + +### Bug Fixes + +* fix typo in version 7 uuid documentation ([#153](https://github.com/google/uuid/issues/153)) ([016b199](https://github.com/google/uuid/commit/016b199544692f745ffc8867b914129ecb47ef06)) +* Monotonicity in UUIDv7 ([#150](https://github.com/google/uuid/issues/150)) ([a2b2b32](https://github.com/google/uuid/commit/a2b2b32373ff0b1a312b7fdf6d38a977099698a6)) + +## [1.5.0](https://github.com/google/uuid/compare/v1.4.0...v1.5.0) (2023-12-12) + + +### Features + +* Validate UUID without creating new UUID ([#141](https://github.com/google/uuid/issues/141)) ([9ee7366](https://github.com/google/uuid/commit/9ee7366e66c9ad96bab89139418a713dc584ae29)) + +## [1.4.0](https://github.com/google/uuid/compare/v1.3.1...v1.4.0) (2023-10-26) + + +### Features + +* UUIDs slice type with Strings() convenience method ([#133](https://github.com/google/uuid/issues/133)) ([cd5fbbd](https://github.com/google/uuid/commit/cd5fbbdd02f3e3467ac18940e07e062be1f864b4)) + +### Fixes + +* Clarify that Parse's job is to parse but not necessarily validate strings. (Documents current behavior) + +## [1.3.1](https://github.com/google/uuid/compare/v1.3.0...v1.3.1) (2023-08-18) + + +### Bug Fixes + +* Use .EqualFold() to parse urn prefixed UUIDs ([#118](https://github.com/google/uuid/issues/118)) ([574e687](https://github.com/google/uuid/commit/574e6874943741fb99d41764c705173ada5293f0)) + +## Changelog diff --git a/vendor/github.com/google/uuid/CONTRIBUTING.md b/vendor/github.com/google/uuid/CONTRIBUTING.md index 04fdf09f..a502fdc5 100644 --- a/vendor/github.com/google/uuid/CONTRIBUTING.md +++ b/vendor/github.com/google/uuid/CONTRIBUTING.md @@ -2,6 +2,22 @@ We definitely welcome patches and contribution to this project! +### Tips + +Commits must be formatted according to the [Conventional Commits Specification](https://www.conventionalcommits.org). + +Always try to include a test case! If it is not possible or not necessary, +please explain why in the pull request description. + +### Releasing + +Commits that would precipitate a SemVer change, as described in the Conventional +Commits Specification, will trigger [`release-please`](https://github.com/google-github-actions/release-please-action) +to create a release candidate pull request. Once submitted, `release-please` +will create a release. + +For tips on how to work with `release-please`, see its documentation. + ### Legal requirements In order to protect both you and ourselves, you will need to sign the diff --git a/vendor/github.com/google/uuid/README.md b/vendor/github.com/google/uuid/README.md index f765a46f..3e9a6188 100644 --- a/vendor/github.com/google/uuid/README.md +++ b/vendor/github.com/google/uuid/README.md @@ -1,6 +1,6 @@ -# uuid ![build status](https://travis-ci.org/google/uuid.svg?branch=master) +# uuid The uuid package generates and inspects UUIDs based on -[RFC 4122](http://tools.ietf.org/html/rfc4122) +[RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122) and DCE 1.1: Authentication and Security Services. This package is based on the github.com/pborman/uuid package (previously named @@ -9,10 +9,12 @@ a UUID is a 16 byte array rather than a byte slice. One loss due to this change is the ability to represent an invalid UUID (vs a NIL UUID). ###### Install -`go get github.com/google/uuid` +```sh +go get github.com/google/uuid +``` ###### Documentation -[![GoDoc](https://godoc.org/github.com/google/uuid?status.svg)](http://godoc.org/github.com/google/uuid) +[![Go Reference](https://pkg.go.dev/badge/github.com/google/uuid.svg)](https://pkg.go.dev/github.com/google/uuid) Full `go doc` style documentation for the package can be viewed online without installing this package by using the GoDoc site here: diff --git a/vendor/github.com/google/uuid/hash.go b/vendor/github.com/google/uuid/hash.go index b404f4be..dc60082d 100644 --- a/vendor/github.com/google/uuid/hash.go +++ b/vendor/github.com/google/uuid/hash.go @@ -17,6 +17,12 @@ var ( NameSpaceOID = Must(Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8")) NameSpaceX500 = Must(Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8")) Nil UUID // empty UUID, all zeros + + // The Max UUID is special form of UUID that is specified to have all 128 bits set to 1. + Max = UUID{ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + } ) // NewHash returns a new UUID derived from the hash of space concatenated with diff --git a/vendor/github.com/google/uuid/node_js.go b/vendor/github.com/google/uuid/node_js.go index 24b78edc..b2a0bc87 100644 --- a/vendor/github.com/google/uuid/node_js.go +++ b/vendor/github.com/google/uuid/node_js.go @@ -7,6 +7,6 @@ package uuid // getHardwareInterface returns nil values for the JS version of the code. -// This remvoves the "net" dependency, because it is not used in the browser. +// This removes the "net" dependency, because it is not used in the browser. // Using the "net" library inflates the size of the transpiled JS code by 673k bytes. func getHardwareInterface(name string) (string, []byte) { return "", nil } diff --git a/vendor/github.com/google/uuid/time.go b/vendor/github.com/google/uuid/time.go index e6ef06cd..c3511292 100644 --- a/vendor/github.com/google/uuid/time.go +++ b/vendor/github.com/google/uuid/time.go @@ -108,12 +108,23 @@ func setClockSequence(seq int) { } // Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in -// uuid. The time is only defined for version 1 and 2 UUIDs. +// uuid. The time is only defined for version 1, 2, 6 and 7 UUIDs. func (uuid UUID) Time() Time { - time := int64(binary.BigEndian.Uint32(uuid[0:4])) - time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32 - time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48 - return Time(time) + var t Time + switch uuid.Version() { + case 6: + time := binary.BigEndian.Uint64(uuid[:8]) // Ignore uuid[6] version b0110 + t = Time(time) + case 7: + time := binary.BigEndian.Uint64(uuid[:8]) + t = Time((time>>16)*10000 + g1582ns100) + default: // forward compatible + time := int64(binary.BigEndian.Uint32(uuid[0:4])) + time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32 + time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48 + t = Time(time) + } + return t } // ClockSequence returns the clock sequence encoded in uuid. diff --git a/vendor/github.com/google/uuid/uuid.go b/vendor/github.com/google/uuid/uuid.go index a57207ae..5232b486 100644 --- a/vendor/github.com/google/uuid/uuid.go +++ b/vendor/github.com/google/uuid/uuid.go @@ -56,11 +56,15 @@ func IsInvalidLengthError(err error) bool { return ok } -// Parse decodes s into a UUID or returns an error. Both the standard UUID -// forms of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and -// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded as well as the -// Microsoft encoding {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} and the raw hex -// encoding: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. +// Parse decodes s into a UUID or returns an error if it cannot be parsed. Both +// the standard UUID forms defined in RFC 4122 +// (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and +// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) are decoded. In addition, +// Parse accepts non-standard strings such as the raw hex encoding +// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx and 38 byte "Microsoft style" encodings, +// e.g. {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}. Only the middle 36 bytes are +// examined in the latter case. Parse should not be used to validate strings as +// it parses non-standard encodings as indicated above. func Parse(s string) (UUID, error) { var uuid UUID switch len(s) { @@ -69,7 +73,7 @@ func Parse(s string) (UUID, error) { // urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx case 36 + 9: - if strings.ToLower(s[:9]) != "urn:uuid:" { + if !strings.EqualFold(s[:9], "urn:uuid:") { return uuid, fmt.Errorf("invalid urn prefix: %q", s[:9]) } s = s[9:] @@ -101,7 +105,8 @@ func Parse(s string) (UUID, error) { 9, 11, 14, 16, 19, 21, - 24, 26, 28, 30, 32, 34} { + 24, 26, 28, 30, 32, 34, + } { v, ok := xtob(s[x], s[x+1]) if !ok { return uuid, errors.New("invalid UUID format") @@ -117,7 +122,7 @@ func ParseBytes(b []byte) (UUID, error) { switch len(b) { case 36: // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx case 36 + 9: // urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - if !bytes.Equal(bytes.ToLower(b[:9]), []byte("urn:uuid:")) { + if !bytes.EqualFold(b[:9], []byte("urn:uuid:")) { return uuid, fmt.Errorf("invalid urn prefix: %q", b[:9]) } b = b[9:] @@ -145,7 +150,8 @@ func ParseBytes(b []byte) (UUID, error) { 9, 11, 14, 16, 19, 21, - 24, 26, 28, 30, 32, 34} { + 24, 26, 28, 30, 32, 34, + } { v, ok := xtob(b[x], b[x+1]) if !ok { return uuid, errors.New("invalid UUID format") @@ -180,6 +186,59 @@ func Must(uuid UUID, err error) UUID { return uuid } +// Validate returns an error if s is not a properly formatted UUID in one of the following formats: +// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx +// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx +// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +// {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} +// It returns an error if the format is invalid, otherwise nil. +func Validate(s string) error { + switch len(s) { + // Standard UUID format + case 36: + + // UUID with "urn:uuid:" prefix + case 36 + 9: + if !strings.EqualFold(s[:9], "urn:uuid:") { + return fmt.Errorf("invalid urn prefix: %q", s[:9]) + } + s = s[9:] + + // UUID enclosed in braces + case 36 + 2: + if s[0] != '{' || s[len(s)-1] != '}' { + return fmt.Errorf("invalid bracketed UUID format") + } + s = s[1 : len(s)-1] + + // UUID without hyphens + case 32: + for i := 0; i < len(s); i += 2 { + _, ok := xtob(s[i], s[i+1]) + if !ok { + return errors.New("invalid UUID format") + } + } + + default: + return invalidLengthError{len(s)} + } + + // Check for standard UUID format + if len(s) == 36 { + if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' { + return errors.New("invalid UUID format") + } + for _, x := range []int{0, 2, 4, 6, 9, 11, 14, 16, 19, 21, 24, 26, 28, 30, 32, 34} { + if _, ok := xtob(s[x], s[x+1]); !ok { + return errors.New("invalid UUID format") + } + } + } + + return nil +} + // String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx // , or "" if uuid is invalid. func (uuid UUID) String() string { @@ -292,3 +351,15 @@ func DisableRandPool() { poolMu.Lock() poolPos = randPoolSize } + +// UUIDs is a slice of UUID types. +type UUIDs []UUID + +// Strings returns a string slice containing the string form of each UUID in uuids. +func (uuids UUIDs) Strings() []string { + var uuidStrs = make([]string, len(uuids)) + for i, uuid := range uuids { + uuidStrs[i] = uuid.String() + } + return uuidStrs +} diff --git a/vendor/github.com/google/uuid/version6.go b/vendor/github.com/google/uuid/version6.go new file mode 100644 index 00000000..339a959a --- /dev/null +++ b/vendor/github.com/google/uuid/version6.go @@ -0,0 +1,56 @@ +// Copyright 2023 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import "encoding/binary" + +// UUID version 6 is a field-compatible version of UUIDv1, reordered for improved DB locality. +// It is expected that UUIDv6 will primarily be used in contexts where there are existing v1 UUIDs. +// Systems that do not involve legacy UUIDv1 SHOULD consider using UUIDv7 instead. +// +// see https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-03#uuidv6 +// +// NewV6 returns a Version 6 UUID based on the current NodeID and clock +// sequence, and the current time. If the NodeID has not been set by SetNodeID +// or SetNodeInterface then it will be set automatically. If the NodeID cannot +// be set NewV6 set NodeID is random bits automatically . If clock sequence has not been set by +// SetClockSequence then it will be set automatically. If GetTime fails to +// return the current NewV6 returns Nil and an error. +func NewV6() (UUID, error) { + var uuid UUID + now, seq, err := GetTime() + if err != nil { + return uuid, err + } + + /* + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | time_high | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | time_mid | time_low_and_version | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |clk_seq_hi_res | clk_seq_low | node (0-1) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | node (2-5) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + + binary.BigEndian.PutUint64(uuid[0:], uint64(now)) + binary.BigEndian.PutUint16(uuid[8:], seq) + + uuid[6] = 0x60 | (uuid[6] & 0x0F) + uuid[8] = 0x80 | (uuid[8] & 0x3F) + + nodeMu.Lock() + if nodeID == zeroID { + setNodeInterface("") + } + copy(uuid[10:], nodeID[:]) + nodeMu.Unlock() + + return uuid, nil +} diff --git a/vendor/github.com/google/uuid/version7.go b/vendor/github.com/google/uuid/version7.go new file mode 100644 index 00000000..3167b643 --- /dev/null +++ b/vendor/github.com/google/uuid/version7.go @@ -0,0 +1,104 @@ +// Copyright 2023 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "io" +) + +// UUID version 7 features a time-ordered value field derived from the widely +// implemented and well known Unix Epoch timestamp source, +// the number of milliseconds seconds since midnight 1 Jan 1970 UTC, leap seconds excluded. +// As well as improved entropy characteristics over versions 1 or 6. +// +// see https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-03#name-uuid-version-7 +// +// Implementations SHOULD utilize UUID version 7 over UUID version 1 and 6 if possible. +// +// NewV7 returns a Version 7 UUID based on the current time(Unix Epoch). +// Uses the randomness pool if it was enabled with EnableRandPool. +// On error, NewV7 returns Nil and an error +func NewV7() (UUID, error) { + uuid, err := NewRandom() + if err != nil { + return uuid, err + } + makeV7(uuid[:]) + return uuid, nil +} + +// NewV7FromReader returns a Version 7 UUID based on the current time(Unix Epoch). +// it use NewRandomFromReader fill random bits. +// On error, NewV7FromReader returns Nil and an error. +func NewV7FromReader(r io.Reader) (UUID, error) { + uuid, err := NewRandomFromReader(r) + if err != nil { + return uuid, err + } + + makeV7(uuid[:]) + return uuid, nil +} + +// makeV7 fill 48 bits time (uuid[0] - uuid[5]), set version b0111 (uuid[6]) +// uuid[8] already has the right version number (Variant is 10) +// see function NewV7 and NewV7FromReader +func makeV7(uuid []byte) { + /* + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | unix_ts_ms | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | unix_ts_ms | ver | rand_a (12 bit seq) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |var| rand_b | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | rand_b | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + _ = uuid[15] // bounds check + + t, s := getV7Time() + + uuid[0] = byte(t >> 40) + uuid[1] = byte(t >> 32) + uuid[2] = byte(t >> 24) + uuid[3] = byte(t >> 16) + uuid[4] = byte(t >> 8) + uuid[5] = byte(t) + + uuid[6] = 0x70 | (0x0F & byte(s>>8)) + uuid[7] = byte(s) +} + +// lastV7time is the last time we returned stored as: +// +// 52 bits of time in milliseconds since epoch +// 12 bits of (fractional nanoseconds) >> 8 +var lastV7time int64 + +const nanoPerMilli = 1000000 + +// getV7Time returns the time in milliseconds and nanoseconds / 256. +// The returned (milli << 12 + seq) is guarenteed to be greater than +// (milli << 12 + seq) returned by any previous call to getV7Time. +func getV7Time() (milli, seq int64) { + timeMu.Lock() + defer timeMu.Unlock() + + nano := timeNow().UnixNano() + milli = nano / nanoPerMilli + // Sequence number is between 0 and 3906 (nanoPerMilli>>8) + seq = (nano - milli*nanoPerMilli) >> 8 + now := milli<<12 + seq + if now <= lastV7time { + now = lastV7time + 1 + milli = now >> 12 + seq = now & 0xfff + } + lastV7time = now + return milli, seq +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 253ec56b..cb45cdf2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,10 +1,10 @@ -# github.com/NVIDIA/go-nvlib v0.0.0-20231116150931-9fd385bace0d +# github.com/NVIDIA/go-nvlib v0.2.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-nvml v0.12.0-2 -## explicit; go 1.15 +# github.com/NVIDIA/go-nvml v0.12.0-3 +## explicit; go 1.20 github.com/NVIDIA/go-nvml/pkg/dl github.com/NVIDIA/go-nvml/pkg/nvml # github.com/NVIDIA/nvidia-container-toolkit v1.14.4-0.20231120225202-039d7fd32429 @@ -104,7 +104,7 @@ github.com/google/go-cmp/cmp/internal/value ## explicit; go 1.12 github.com/google/gofuzz github.com/google/gofuzz/bytesource -# github.com/google/uuid v1.3.0 +# github.com/google/uuid v1.6.0 ## explicit github.com/google/uuid # github.com/imdario/mergo v0.3.6