mirror of
https://github.com/clearml/go-nvlib
synced 2025-06-16 19:29:16 +00:00
Merge branch 'add-nvml-wrapper' into 'main'
Add an interface based wrapper around go-nvml for better mocking See merge request nvidia/cloud-native/go-nvlib!14
This commit is contained in:
commit
ad3fa31634
5
Makefile
5
Makefile
@ -25,7 +25,7 @@ endif
|
|||||||
IMAGE_TAG ?= $(GOLANG_VERSION)
|
IMAGE_TAG ?= $(GOLANG_VERSION)
|
||||||
BUILDIMAGE ?= $(IMAGE):$(IMAGE_TAG)-devel
|
BUILDIMAGE ?= $(IMAGE):$(IMAGE_TAG)-devel
|
||||||
|
|
||||||
TARGETS := binary build all check fmt assert-fmt lint vet test
|
TARGETS := binary build all check fmt assert-fmt generate lint vet test
|
||||||
DOCKER_TARGETS := $(patsubst %, docker-%, $(TARGETS))
|
DOCKER_TARGETS := $(patsubst %, docker-%, $(TARGETS))
|
||||||
.PHONY: $(TARGETS) $(DOCKER_TARGETS)
|
.PHONY: $(TARGETS) $(DOCKER_TARGETS)
|
||||||
|
|
||||||
@ -54,6 +54,9 @@ assert-fmt:
|
|||||||
rm fmt.out; \
|
rm fmt.out; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
generate:
|
||||||
|
go generate $(MODULE)/...
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
# We use `go list -f '{{.Dir}}' $(MODULE)/...` to skip the `vendor` folder.
|
# We use `go list -f '{{.Dir}}' $(MODULE)/...` to skip the `vendor` folder.
|
||||||
go list -f '{{.Dir}}' $(MODULE)/... | xargs golint -set_exit_status
|
go list -f '{{.Dir}}' $(MODULE)/... | xargs golint -set_exit_status
|
||||||
|
@ -15,3 +15,4 @@ ARG GOLANG_VERSION=1.16
|
|||||||
FROM golang:${GOLANG_VERSION}
|
FROM golang:${GOLANG_VERSION}
|
||||||
|
|
||||||
RUN go get -u golang.org/x/lint/golint
|
RUN go get -u golang.org/x/lint/golint
|
||||||
|
RUN go install github.com/matryer/moq@latest
|
||||||
|
44
pkg/nvml/ci.go
Normal file
44
pkg/nvml/ci.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* 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)
|
||||||
|
}
|
102
pkg/nvml/ci_mock.go
Normal file
102
pkg/nvml/ci_mock.go
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
// 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
|
||||||
|
}
|
87
pkg/nvml/consts.go
Normal file
87
pkg/nvml/consts.go
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
)
|
||||||
|
|
||||||
|
// 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_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_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
|
||||||
|
)
|
117
pkg/nvml/device.go
Normal file
117
pkg/nvml/device.go
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/**
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
}
|
598
pkg/nvml/device_mock.go
Normal file
598
pkg/nvml/device_mock.go
Normal file
@ -0,0 +1,598 @@
|
|||||||
|
// Code generated by moq; DO NOT EDIT.
|
||||||
|
// github.com/matryer/moq
|
||||||
|
|
||||||
|
package nvml
|
||||||
|
|
||||||
|
import (
|
||||||
|
"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{
|
||||||
|
// GetComputeInstanceIdFunc: func() (int, Return) {
|
||||||
|
// panic("mock out the GetComputeInstanceId method")
|
||||||
|
// },
|
||||||
|
// GetDeviceHandleFromMigDeviceHandleFunc: func() (Device, Return) {
|
||||||
|
// panic("mock out the GetDeviceHandleFromMigDeviceHandle method")
|
||||||
|
// },
|
||||||
|
// GetGpuInstanceIdFunc: func() (int, Return) {
|
||||||
|
// panic("mock out the GetGpuInstanceId 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")
|
||||||
|
// },
|
||||||
|
// GetPciInfoFunc: func() (PciInfo, Return) {
|
||||||
|
// panic("mock out the GetPciInfo method")
|
||||||
|
// },
|
||||||
|
// GetUUIDFunc: func() (string, Return) {
|
||||||
|
// panic("mock out the GetUUID method")
|
||||||
|
// },
|
||||||
|
// IsMigDeviceHandleFunc: func() (bool, Return) {
|
||||||
|
// panic("mock out the IsMigDeviceHandle method")
|
||||||
|
// },
|
||||||
|
// SetMigModeFunc: func(Mode int) (Return, Return) {
|
||||||
|
// panic("mock out the SetMigMode method")
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // use mockedDevice in code that requires Device
|
||||||
|
// // and then make assertions.
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
type DeviceMock struct {
|
||||||
|
// GetComputeInstanceIdFunc mocks the GetComputeInstanceId method.
|
||||||
|
GetComputeInstanceIdFunc func() (int, Return)
|
||||||
|
|
||||||
|
// GetDeviceHandleFromMigDeviceHandleFunc mocks the GetDeviceHandleFromMigDeviceHandle method.
|
||||||
|
GetDeviceHandleFromMigDeviceHandleFunc func() (Device, Return)
|
||||||
|
|
||||||
|
// GetGpuInstanceIdFunc mocks the GetGpuInstanceId method.
|
||||||
|
GetGpuInstanceIdFunc func() (int, 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)
|
||||||
|
|
||||||
|
// GetPciInfoFunc mocks the GetPciInfo method.
|
||||||
|
GetPciInfoFunc func() (PciInfo, Return)
|
||||||
|
|
||||||
|
// GetUUIDFunc mocks the GetUUID method.
|
||||||
|
GetUUIDFunc func() (string, Return)
|
||||||
|
|
||||||
|
// IsMigDeviceHandleFunc mocks the IsMigDeviceHandle method.
|
||||||
|
IsMigDeviceHandleFunc func() (bool, Return)
|
||||||
|
|
||||||
|
// SetMigModeFunc mocks the SetMigMode method.
|
||||||
|
SetMigModeFunc func(Mode int) (Return, Return)
|
||||||
|
|
||||||
|
// calls tracks calls to the methods.
|
||||||
|
calls struct {
|
||||||
|
// GetComputeInstanceId holds details about calls to the GetComputeInstanceId method.
|
||||||
|
GetComputeInstanceId []struct {
|
||||||
|
}
|
||||||
|
// GetDeviceHandleFromMigDeviceHandle holds details about calls to the GetDeviceHandleFromMigDeviceHandle method.
|
||||||
|
GetDeviceHandleFromMigDeviceHandle []struct {
|
||||||
|
}
|
||||||
|
// GetGpuInstanceId holds details about calls to the GetGpuInstanceId method.
|
||||||
|
GetGpuInstanceId []struct {
|
||||||
|
}
|
||||||
|
// 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 {
|
||||||
|
}
|
||||||
|
// GetPciInfo holds details about calls to the GetPciInfo method.
|
||||||
|
GetPciInfo []struct {
|
||||||
|
}
|
||||||
|
// GetUUID holds details about calls to the GetUUID method.
|
||||||
|
GetUUID []struct {
|
||||||
|
}
|
||||||
|
// IsMigDeviceHandle holds details about calls to the IsMigDeviceHandle method.
|
||||||
|
IsMigDeviceHandle []struct {
|
||||||
|
}
|
||||||
|
// SetMigMode holds details about calls to the SetMigMode method.
|
||||||
|
SetMigMode []struct {
|
||||||
|
// Mode is the Mode argument value.
|
||||||
|
Mode int
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lockGetComputeInstanceId sync.RWMutex
|
||||||
|
lockGetDeviceHandleFromMigDeviceHandle sync.RWMutex
|
||||||
|
lockGetGpuInstanceId 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
|
||||||
|
lockGetPciInfo sync.RWMutex
|
||||||
|
lockGetUUID sync.RWMutex
|
||||||
|
lockIsMigDeviceHandle sync.RWMutex
|
||||||
|
lockSetMigMode sync.RWMutex
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
65
pkg/nvml/gi.go
Normal file
65
pkg/nvml/gi.go
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
}
|
237
pkg/nvml/gi_mock.go
Normal file
237
pkg/nvml/gi_mock.go
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
// 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")
|
||||||
|
// },
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
}
|
||||||
|
// 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
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
98
pkg/nvml/nvml.go
Normal file
98
pkg/nvml/nvml.go
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* 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() Interface {
|
||||||
|
return &nvmlLib{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 += 1
|
||||||
|
|
||||||
|
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 -= 1
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorString returns the error string associated with a given return value
|
||||||
|
func (n *nvmlLib) ErrorString(ret Return) string {
|
||||||
|
return nvml.ErrorString(nvml.Return(ret))
|
||||||
|
}
|
303
pkg/nvml/nvml_mock.go
Normal file
303
pkg/nvml/nvml_mock.go
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
// 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")
|
||||||
|
// },
|
||||||
|
// InitFunc: func() Return {
|
||||||
|
// panic("mock out the Init method")
|
||||||
|
// },
|
||||||
|
// ShutdownFunc: func() Return {
|
||||||
|
// panic("mock out the Shutdown 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
|
||||||
|
|
||||||
|
// InitFunc mocks the Init method.
|
||||||
|
InitFunc func() Return
|
||||||
|
|
||||||
|
// ShutdownFunc mocks the Shutdown method.
|
||||||
|
ShutdownFunc func() 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
|
||||||
|
}
|
||||||
|
// Init holds details about calls to the Init method.
|
||||||
|
Init []struct {
|
||||||
|
}
|
||||||
|
// Shutdown holds details about calls to the Shutdown method.
|
||||||
|
Shutdown []struct {
|
||||||
|
}
|
||||||
|
// SystemGetDriverVersion holds details about calls to the SystemGetDriverVersion method.
|
||||||
|
SystemGetDriverVersion []struct {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lockDeviceGetCount sync.RWMutex
|
||||||
|
lockDeviceGetHandleByIndex sync.RWMutex
|
||||||
|
lockDeviceGetHandleByUUID sync.RWMutex
|
||||||
|
lockErrorString sync.RWMutex
|
||||||
|
lockInit sync.RWMutex
|
||||||
|
lockShutdown 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
93
pkg/nvml/return.go
Normal file
93
pkg/nvml/return.go
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* 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)
|
||||||
|
}
|
||||||
|
}
|
47
pkg/nvml/return_test.go
Normal file
47
pkg/nvml/return_test.go
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestReturnErrorString(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
in Return
|
||||||
|
out string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
SUCCESS,
|
||||||
|
"SUCCESS",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Return(1024),
|
||||||
|
"Unknown return value: 1024",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(fmt.Sprintf("%d", tc.in), func(t *testing.T) {
|
||||||
|
out := tc.in.Error()
|
||||||
|
require.Equal(t, out, tc.out)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
108
pkg/nvml/types.go
Normal file
108
pkg/nvml/types.go
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:generate moq -out nvml_mock.go . Interface
|
||||||
|
// Interface defines the functions implemented by an NVML library
|
||||||
|
type Interface interface {
|
||||||
|
Init() Return
|
||||||
|
Shutdown() Return
|
||||||
|
DeviceGetCount() (int, Return)
|
||||||
|
DeviceGetHandleByIndex(Index int) (Device, Return)
|
||||||
|
DeviceGetHandleByUUID(UUID string) (Device, Return)
|
||||||
|
SystemGetDriverVersion() (string, Return)
|
||||||
|
ErrorString(r Return) string
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:generate moq -out device_mock.go . Device
|
||||||
|
// Device defines the functions implemented by an NVML device
|
||||||
|
type Device interface {
|
||||||
|
GetIndex() (int, Return)
|
||||||
|
GetPciInfo() (PciInfo, Return)
|
||||||
|
GetMemoryInfo() (Memory, Return)
|
||||||
|
GetUUID() (string, Return)
|
||||||
|
GetMinorNumber() (int, Return)
|
||||||
|
IsMigDeviceHandle() (bool, Return)
|
||||||
|
GetDeviceHandleFromMigDeviceHandle() (Device, Return)
|
||||||
|
SetMigMode(Mode int) (Return, Return)
|
||||||
|
GetMigMode() (int, int, Return)
|
||||||
|
GetGpuInstanceProfileInfo(Profile int) (GpuInstanceProfileInfo, Return)
|
||||||
|
GetGpuInstances(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return)
|
||||||
|
GetMaxMigDeviceCount() (int, Return)
|
||||||
|
GetMigDeviceHandleByIndex(Index int) (Device, Return)
|
||||||
|
GetGpuInstanceId() (int, Return)
|
||||||
|
GetComputeInstanceId() (int, Return)
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:generate moq -out gi_mock.go . GpuInstance
|
||||||
|
// GpuInstance defines the functions implemented by a GpuInstance
|
||||||
|
type GpuInstance interface {
|
||||||
|
GetInfo() (GpuInstanceInfo, Return)
|
||||||
|
GetComputeInstanceProfileInfo(Profile int, EngProfile int) (ComputeInstanceProfileInfo, Return)
|
||||||
|
CreateComputeInstance(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return)
|
||||||
|
GetComputeInstances(Info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return)
|
||||||
|
Destroy() Return
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:generate moq -out ci_mock.go . ComputeInstance
|
||||||
|
// ComputeInstance defines the functions implemented by a ComputeInstance
|
||||||
|
type ComputeInstance interface {
|
||||||
|
GetInfo() (ComputeInstanceInfo, Return)
|
||||||
|
Destroy() 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
64
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/cgo_helpers.go
generated
vendored
Normal file
64
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/cgo_helpers.go
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
// Copyright (c) 2020, 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 (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
var cgoAllocsUnknown = new(struct{})
|
||||||
|
|
||||||
|
type stringHeader struct {
|
||||||
|
Data unsafe.Pointer
|
||||||
|
Len int
|
||||||
|
}
|
||||||
|
|
||||||
|
func clen(n []byte) int {
|
||||||
|
for i := 0; i < len(n); i++ {
|
||||||
|
if n[i] == 0 {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len(n)
|
||||||
|
}
|
||||||
|
|
||||||
|
func uint32SliceToIntSlice(s []uint32) []int {
|
||||||
|
ret := make([]int, len(s))
|
||||||
|
for i := range s {
|
||||||
|
ret[i] = int(s[i])
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// packPCharString creates a Go string backed by *C.char and avoids copying.
|
||||||
|
func packPCharString(p *C.char) (raw string) {
|
||||||
|
if p != nil && *p != 0 {
|
||||||
|
h := (*stringHeader)(unsafe.Pointer(&raw))
|
||||||
|
h.Data = unsafe.Pointer(p)
|
||||||
|
for *p != 0 {
|
||||||
|
p = (*C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + 1)) // p++
|
||||||
|
}
|
||||||
|
h.Len = int(uintptr(unsafe.Pointer(p)) - uintptr(h.Data))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// unpackPCharString represents the data from Go string as *C.char and avoids copying.
|
||||||
|
func unpackPCharString(str string) (*C.char, *struct{}) {
|
||||||
|
h := (*stringHeader)(unsafe.Pointer(&str))
|
||||||
|
return (*C.char)(h.Data), cgoAllocsUnknown
|
||||||
|
}
|
23
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/cgo_helpers.h
generated
vendored
Normal file
23
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/cgo_helpers.h
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (c) 2020, 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.
|
||||||
|
|
||||||
|
// WARNING: THIS FILE WAS AUTOMATICALLY GENERATED.
|
||||||
|
// Code generated by https://git.io/c-for-go. DO NOT EDIT.
|
||||||
|
|
||||||
|
#include "nvml.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define __CGOGEN 1
|
||||||
|
|
1139
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/const.go
generated
vendored
Normal file
1139
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/const.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
27
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/const_gen.go
generated
vendored
Normal file
27
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/const_gen.go
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (c) 2021, 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 (
|
||||||
|
"reflect"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SYSTEM_PROCESS_NAME_BUFFER_SIZE = 256
|
||||||
|
)
|
||||||
|
|
||||||
|
func STRUCT_VERSION(data interface{}, version uint32) uint32 {
|
||||||
|
return uint32(uint32(reflect.Indirect(reflect.ValueOf(data)).Type().Size()) | (version << uint32(24)))
|
||||||
|
}
|
2288
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/device.go
generated
vendored
Normal file
2288
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/device.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
21
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/doc.go
generated
vendored
Normal file
21
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/doc.go
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// Copyright (c) 2020, 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.
|
||||||
|
|
||||||
|
// WARNING: THIS FILE WAS AUTOMATICALLY GENERATED.
|
||||||
|
// Code generated by https://git.io/c-for-go. DO NOT EDIT.
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package NVML bindings
|
||||||
|
*/
|
||||||
|
package nvml
|
42
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/event_set.go
generated
vendored
Normal file
42
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/event_set.go
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (c) 2020, 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
|
||||||
|
|
||||||
|
// nvml.EventSetCreate()
|
||||||
|
func EventSetCreate() (EventSet, Return) {
|
||||||
|
var Set EventSet
|
||||||
|
ret := nvmlEventSetCreate(&Set)
|
||||||
|
return Set, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.EventSetWait()
|
||||||
|
func EventSetWait(Set EventSet, Timeoutms uint32) (EventData, Return) {
|
||||||
|
var Data EventData
|
||||||
|
ret := nvmlEventSetWait(Set, &Data, Timeoutms)
|
||||||
|
return Data, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Set EventSet) Wait(Timeoutms uint32) (EventData, Return) {
|
||||||
|
return EventSetWait(Set, Timeoutms)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.EventSetFree()
|
||||||
|
func EventSetFree(Set EventSet) Return {
|
||||||
|
return nvmlEventSetFree(Set)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Set EventSet) Free() Return {
|
||||||
|
return EventSetFree(Set)
|
||||||
|
}
|
226
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/init.go
generated
vendored
Normal file
226
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/init.go
generated
vendored
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
// Copyright (c) 2020, 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/dl"
|
||||||
|
)
|
||||||
|
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
const (
|
||||||
|
nvmlLibraryName = "libnvidia-ml.so.1"
|
||||||
|
nvmlLibraryLoadFlags = dl.RTLD_LAZY | dl.RTLD_GLOBAL
|
||||||
|
)
|
||||||
|
|
||||||
|
var nvml *dl.DynamicLibrary
|
||||||
|
|
||||||
|
// nvml.Init()
|
||||||
|
func Init() Return {
|
||||||
|
lib := dl.New(nvmlLibraryName, nvmlLibraryLoadFlags)
|
||||||
|
if lib == nil {
|
||||||
|
panic(fmt.Sprintf("error instantiating DynamicLibrary for %s", nvmlLibraryName))
|
||||||
|
}
|
||||||
|
|
||||||
|
err := lib.Open()
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Sprintf("error opening %s: %v", nvmlLibraryName, err))
|
||||||
|
}
|
||||||
|
|
||||||
|
nvml = lib
|
||||||
|
updateVersionedSymbols()
|
||||||
|
|
||||||
|
return nvmlInit()
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.InitWithFlags()
|
||||||
|
func InitWithFlags(Flags uint32) Return {
|
||||||
|
lib := dl.New(nvmlLibraryName, nvmlLibraryLoadFlags)
|
||||||
|
if lib == nil {
|
||||||
|
panic(fmt.Sprintf("error instantiating DynamicLibrary for %s", nvmlLibraryName))
|
||||||
|
}
|
||||||
|
|
||||||
|
err := lib.Open()
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Sprintf("error opening %s: %v", nvmlLibraryName, err))
|
||||||
|
}
|
||||||
|
|
||||||
|
nvml = lib
|
||||||
|
|
||||||
|
return nvmlInitWithFlags(Flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.Shutdown()
|
||||||
|
func Shutdown() Return {
|
||||||
|
ret := nvmlShutdown()
|
||||||
|
if ret != SUCCESS {
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
err := nvml.Close()
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Sprintf("error closing %s: %v", nvmlLibraryName, err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default all versioned APIs to v1 (to infer the types)
|
||||||
|
var nvmlInit = nvmlInit_v1
|
||||||
|
var nvmlDeviceGetPciInfo = nvmlDeviceGetPciInfo_v1
|
||||||
|
var nvmlDeviceGetCount = nvmlDeviceGetCount_v1
|
||||||
|
var nvmlDeviceGetHandleByIndex = nvmlDeviceGetHandleByIndex_v1
|
||||||
|
var nvmlDeviceGetHandleByPciBusId = nvmlDeviceGetHandleByPciBusId_v1
|
||||||
|
var nvmlDeviceGetNvLinkRemotePciInfo = nvmlDeviceGetNvLinkRemotePciInfo_v1
|
||||||
|
var nvmlDeviceRemoveGpu = nvmlDeviceRemoveGpu_v1
|
||||||
|
var nvmlDeviceGetGridLicensableFeatures = nvmlDeviceGetGridLicensableFeatures_v1
|
||||||
|
var nvmlEventSetWait = nvmlEventSetWait_v1
|
||||||
|
var nvmlDeviceGetAttributes = nvmlDeviceGetAttributes_v1
|
||||||
|
var nvmlComputeInstanceGetInfo = nvmlComputeInstanceGetInfo_v1
|
||||||
|
var DeviceGetComputeRunningProcesses = deviceGetComputeRunningProcesses_v1
|
||||||
|
var DeviceGetGraphicsRunningProcesses = deviceGetGraphicsRunningProcesses_v1
|
||||||
|
var DeviceGetMPSComputeRunningProcesses = deviceGetMPSComputeRunningProcesses_v1
|
||||||
|
var GetBlacklistDeviceCount = GetExcludedDeviceCount
|
||||||
|
var GetBlacklistDeviceInfoByIndex = GetExcludedDeviceInfoByIndex
|
||||||
|
var nvmlDeviceGetGpuInstancePossiblePlacements = nvmlDeviceGetGpuInstancePossiblePlacements_v1
|
||||||
|
var nvmlVgpuInstanceGetLicenseInfo = nvmlVgpuInstanceGetLicenseInfo_v1
|
||||||
|
|
||||||
|
type BlacklistDeviceInfo = ExcludedDeviceInfo
|
||||||
|
type ProcessInfo_v1Slice []ProcessInfo_v1
|
||||||
|
type ProcessInfo_v2Slice []ProcessInfo_v2
|
||||||
|
|
||||||
|
func (pis ProcessInfo_v1Slice) ToProcessInfoSlice() []ProcessInfo {
|
||||||
|
var newInfos []ProcessInfo
|
||||||
|
for _, pi := range pis {
|
||||||
|
info := ProcessInfo{
|
||||||
|
Pid: pi.Pid,
|
||||||
|
UsedGpuMemory: pi.UsedGpuMemory,
|
||||||
|
GpuInstanceId: 0xFFFFFFFF, // GPU instance ID is invalid in v1
|
||||||
|
ComputeInstanceId: 0xFFFFFFFF, // Compute instance ID is invalid in v1
|
||||||
|
}
|
||||||
|
newInfos = append(newInfos, info)
|
||||||
|
}
|
||||||
|
return newInfos
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pis ProcessInfo_v2Slice) ToProcessInfoSlice() []ProcessInfo {
|
||||||
|
var newInfos []ProcessInfo
|
||||||
|
for _, pi := range pis {
|
||||||
|
info := ProcessInfo{
|
||||||
|
Pid: pi.Pid,
|
||||||
|
UsedGpuMemory: pi.UsedGpuMemory,
|
||||||
|
GpuInstanceId: pi.GpuInstanceId,
|
||||||
|
ComputeInstanceId: pi.ComputeInstanceId,
|
||||||
|
}
|
||||||
|
newInfos = append(newInfos, info)
|
||||||
|
}
|
||||||
|
return newInfos
|
||||||
|
}
|
||||||
|
|
||||||
|
// updateVersionedSymbols()
|
||||||
|
func updateVersionedSymbols() {
|
||||||
|
err := nvml.Lookup("nvmlInit_v2")
|
||||||
|
if err == nil {
|
||||||
|
nvmlInit = nvmlInit_v2
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetPciInfo_v2")
|
||||||
|
if err == nil {
|
||||||
|
nvmlDeviceGetPciInfo = nvmlDeviceGetPciInfo_v2
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetPciInfo_v3")
|
||||||
|
if err == nil {
|
||||||
|
nvmlDeviceGetPciInfo = nvmlDeviceGetPciInfo_v3
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetCount_v2")
|
||||||
|
if err == nil {
|
||||||
|
nvmlDeviceGetCount = nvmlDeviceGetCount_v2
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetHandleByIndex_v2")
|
||||||
|
if err == nil {
|
||||||
|
nvmlDeviceGetHandleByIndex = nvmlDeviceGetHandleByIndex_v2
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetHandleByPciBusId_v2")
|
||||||
|
if err == nil {
|
||||||
|
nvmlDeviceGetHandleByPciBusId = nvmlDeviceGetHandleByPciBusId_v2
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetNvLinkRemotePciInfo_v2")
|
||||||
|
if err == nil {
|
||||||
|
nvmlDeviceGetNvLinkRemotePciInfo = nvmlDeviceGetNvLinkRemotePciInfo_v2
|
||||||
|
}
|
||||||
|
// Unable to overwrite nvmlDeviceRemoveGpu() because the v2 function takes
|
||||||
|
// a different set of parameters than the v1 function.
|
||||||
|
//err = nvml.Lookup("nvmlDeviceRemoveGpu_v2")
|
||||||
|
//if err == nil {
|
||||||
|
// nvmlDeviceRemoveGpu = nvmlDeviceRemoveGpu_v2
|
||||||
|
//}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetGridLicensableFeatures_v2")
|
||||||
|
if err == nil {
|
||||||
|
nvmlDeviceGetGridLicensableFeatures = nvmlDeviceGetGridLicensableFeatures_v2
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetGridLicensableFeatures_v3")
|
||||||
|
if err == nil {
|
||||||
|
nvmlDeviceGetGridLicensableFeatures = nvmlDeviceGetGridLicensableFeatures_v3
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetGridLicensableFeatures_v4")
|
||||||
|
if err == nil {
|
||||||
|
nvmlDeviceGetGridLicensableFeatures = nvmlDeviceGetGridLicensableFeatures_v4
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlEventSetWait_v2")
|
||||||
|
if err == nil {
|
||||||
|
nvmlEventSetWait = nvmlEventSetWait_v2
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetAttributes_v2")
|
||||||
|
if err == nil {
|
||||||
|
nvmlDeviceGetAttributes = nvmlDeviceGetAttributes_v2
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlComputeInstanceGetInfo_v2")
|
||||||
|
if err == nil {
|
||||||
|
nvmlComputeInstanceGetInfo = nvmlComputeInstanceGetInfo_v2
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetComputeRunningProcesses_v2")
|
||||||
|
if err == nil {
|
||||||
|
DeviceGetComputeRunningProcesses = deviceGetComputeRunningProcesses_v2
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetComputeRunningProcesses_v3")
|
||||||
|
if err == nil {
|
||||||
|
DeviceGetComputeRunningProcesses = deviceGetComputeRunningProcesses_v3
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetGraphicsRunningProcesses_v2")
|
||||||
|
if err == nil {
|
||||||
|
DeviceGetGraphicsRunningProcesses = deviceGetGraphicsRunningProcesses_v2
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetGraphicsRunningProcesses_v3")
|
||||||
|
if err == nil {
|
||||||
|
DeviceGetGraphicsRunningProcesses = deviceGetGraphicsRunningProcesses_v3
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetMPSComputeRunningProcesses_v2")
|
||||||
|
if err == nil {
|
||||||
|
DeviceGetMPSComputeRunningProcesses = deviceGetMPSComputeRunningProcesses_v2
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetMPSComputeRunningProcesses_v3")
|
||||||
|
if err == nil {
|
||||||
|
DeviceGetMPSComputeRunningProcesses = deviceGetMPSComputeRunningProcesses_v3
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlDeviceGetGpuInstancePossiblePlacements_v2")
|
||||||
|
if err == nil {
|
||||||
|
nvmlDeviceGetGpuInstancePossiblePlacements = nvmlDeviceGetGpuInstancePossiblePlacements_v2
|
||||||
|
}
|
||||||
|
err = nvml.Lookup("nvmlVgpuInstanceGetLicenseInfo_v2")
|
||||||
|
if err == nil {
|
||||||
|
nvmlVgpuInstanceGetLicenseInfo = nvmlVgpuInstanceGetLicenseInfo_v2
|
||||||
|
}
|
||||||
|
}
|
2583
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/nvml.go
generated
vendored
Normal file
2583
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/nvml.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8459
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/nvml.h
generated
vendored
Normal file
8459
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/nvml.h
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
20
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/return.go
generated
vendored
Normal file
20
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/return.go
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (c) 2020, 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
|
||||||
|
|
||||||
|
// nvml.ErrorString()
|
||||||
|
func ErrorString(Result Return) string {
|
||||||
|
return nvmlErrorString(Result)
|
||||||
|
}
|
81
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/system.go
generated
vendored
Normal file
81
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/system.go
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
// Copyright (c) 2020, 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
|
||||||
|
|
||||||
|
// nvml.SystemGetDriverVersion()
|
||||||
|
func SystemGetDriverVersion() (string, Return) {
|
||||||
|
Version := make([]byte, SYSTEM_DRIVER_VERSION_BUFFER_SIZE)
|
||||||
|
ret := nvmlSystemGetDriverVersion(&Version[0], SYSTEM_DRIVER_VERSION_BUFFER_SIZE)
|
||||||
|
return string(Version[:clen(Version)]), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.SystemGetNVMLVersion()
|
||||||
|
func SystemGetNVMLVersion() (string, Return) {
|
||||||
|
Version := make([]byte, SYSTEM_NVML_VERSION_BUFFER_SIZE)
|
||||||
|
ret := nvmlSystemGetNVMLVersion(&Version[0], SYSTEM_NVML_VERSION_BUFFER_SIZE)
|
||||||
|
return string(Version[:clen(Version)]), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.SystemGetCudaDriverVersion()
|
||||||
|
func SystemGetCudaDriverVersion() (int, Return) {
|
||||||
|
var CudaDriverVersion int32
|
||||||
|
ret := nvmlSystemGetCudaDriverVersion(&CudaDriverVersion)
|
||||||
|
return int(CudaDriverVersion), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.SystemGetCudaDriverVersion_v2()
|
||||||
|
func SystemGetCudaDriverVersion_v2() (int, Return) {
|
||||||
|
var CudaDriverVersion int32
|
||||||
|
ret := nvmlSystemGetCudaDriverVersion_v2(&CudaDriverVersion)
|
||||||
|
return int(CudaDriverVersion), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.SystemGetProcessName()
|
||||||
|
func SystemGetProcessName(Pid int) (string, Return) {
|
||||||
|
Name := make([]byte, SYSTEM_PROCESS_NAME_BUFFER_SIZE)
|
||||||
|
ret := nvmlSystemGetProcessName(uint32(Pid), &Name[0], SYSTEM_PROCESS_NAME_BUFFER_SIZE)
|
||||||
|
return string(Name[:clen(Name)]), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.SystemGetHicVersion()
|
||||||
|
func SystemGetHicVersion() ([]HwbcEntry, Return) {
|
||||||
|
var HwbcCount uint32 = 1 // Will be reduced upon returning
|
||||||
|
for {
|
||||||
|
HwbcEntries := make([]HwbcEntry, HwbcCount)
|
||||||
|
ret := nvmlSystemGetHicVersion(&HwbcCount, &HwbcEntries[0])
|
||||||
|
if ret == SUCCESS {
|
||||||
|
return HwbcEntries[:HwbcCount], ret
|
||||||
|
}
|
||||||
|
if ret != ERROR_INSUFFICIENT_SIZE {
|
||||||
|
return nil, ret
|
||||||
|
}
|
||||||
|
HwbcCount *= 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.SystemGetTopologyGpuSet()
|
||||||
|
func SystemGetTopologyGpuSet(CpuNumber int) ([]Device, Return) {
|
||||||
|
var Count uint32
|
||||||
|
ret := nvmlSystemGetTopologyGpuSet(uint32(CpuNumber), &Count, nil)
|
||||||
|
if ret != SUCCESS {
|
||||||
|
return nil, ret
|
||||||
|
}
|
||||||
|
if Count == 0 {
|
||||||
|
return []Device{}, ret
|
||||||
|
}
|
||||||
|
DeviceArray := make([]Device, Count)
|
||||||
|
ret = nvmlSystemGetTopologyGpuSet(uint32(CpuNumber), &Count, &DeviceArray[0])
|
||||||
|
return DeviceArray, ret
|
||||||
|
}
|
445
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/types_gen.go
generated
vendored
Normal file
445
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/types_gen.go
generated
vendored
Normal file
@ -0,0 +1,445 @@
|
|||||||
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
|
// cgo -godefs types.go
|
||||||
|
|
||||||
|
package nvml
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
type Device struct {
|
||||||
|
Handle *_Ctype_struct_nvmlDevice_st
|
||||||
|
}
|
||||||
|
|
||||||
|
type PciInfo struct {
|
||||||
|
BusIdLegacy [16]int8
|
||||||
|
Domain uint32
|
||||||
|
Bus uint32
|
||||||
|
Device uint32
|
||||||
|
PciDeviceId uint32
|
||||||
|
PciSubSystemId uint32
|
||||||
|
BusId [32]int8
|
||||||
|
}
|
||||||
|
|
||||||
|
type EccErrorCounts struct {
|
||||||
|
L1Cache uint64
|
||||||
|
L2Cache uint64
|
||||||
|
DeviceMemory uint64
|
||||||
|
RegisterFile uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type Utilization struct {
|
||||||
|
Gpu uint32
|
||||||
|
Memory uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type Memory struct {
|
||||||
|
Total uint64
|
||||||
|
Free uint64
|
||||||
|
Used uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type Memory_v2 struct {
|
||||||
|
Version uint32
|
||||||
|
Total uint64
|
||||||
|
Reserved uint64
|
||||||
|
Free uint64
|
||||||
|
Used uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type BAR1Memory struct {
|
||||||
|
Bar1Total uint64
|
||||||
|
Bar1Free uint64
|
||||||
|
Bar1Used uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProcessInfo_v1 struct {
|
||||||
|
Pid uint32
|
||||||
|
UsedGpuMemory uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProcessInfo_v2 struct {
|
||||||
|
Pid uint32
|
||||||
|
UsedGpuMemory uint64
|
||||||
|
GpuInstanceId uint32
|
||||||
|
ComputeInstanceId uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProcessInfo struct {
|
||||||
|
Pid uint32
|
||||||
|
UsedGpuMemory uint64
|
||||||
|
GpuInstanceId uint32
|
||||||
|
ComputeInstanceId uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeviceAttributes struct {
|
||||||
|
MultiprocessorCount uint32
|
||||||
|
SharedCopyEngineCount uint32
|
||||||
|
SharedDecoderCount uint32
|
||||||
|
SharedEncoderCount uint32
|
||||||
|
SharedJpegCount uint32
|
||||||
|
SharedOfaCount uint32
|
||||||
|
GpuInstanceSliceCount uint32
|
||||||
|
ComputeInstanceSliceCount uint32
|
||||||
|
MemorySizeMB uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type RowRemapperHistogramValues struct {
|
||||||
|
Max uint32
|
||||||
|
High uint32
|
||||||
|
Partial uint32
|
||||||
|
Low uint32
|
||||||
|
None uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type NvLinkUtilizationControl struct {
|
||||||
|
Units uint32
|
||||||
|
Pktfilter uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type BridgeChipInfo struct {
|
||||||
|
Type uint32
|
||||||
|
FwVersion uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type BridgeChipHierarchy struct {
|
||||||
|
BridgeCount uint8
|
||||||
|
BridgeChipInfo [128]BridgeChipInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
const sizeofValue = unsafe.Sizeof([8]byte{})
|
||||||
|
|
||||||
|
type Value [sizeofValue]byte
|
||||||
|
|
||||||
|
type Sample struct {
|
||||||
|
TimeStamp uint64
|
||||||
|
SampleValue [8]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type ViolationTime struct {
|
||||||
|
ReferenceTime uint64
|
||||||
|
ViolationTime uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClkMonFaultInfo struct {
|
||||||
|
ClkApiDomain uint32
|
||||||
|
ClkDomainFaultMask uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClkMonStatus struct {
|
||||||
|
BGlobalStatus uint32
|
||||||
|
ClkMonListSize uint32
|
||||||
|
ClkMonList [32]ClkMonFaultInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type VgpuTypeId uint32
|
||||||
|
|
||||||
|
type VgpuInstance uint32
|
||||||
|
|
||||||
|
type VgpuInstanceUtilizationSample struct {
|
||||||
|
VgpuInstance uint32
|
||||||
|
TimeStamp uint64
|
||||||
|
SmUtil [8]byte
|
||||||
|
MemUtil [8]byte
|
||||||
|
EncUtil [8]byte
|
||||||
|
DecUtil [8]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type VgpuProcessUtilizationSample struct {
|
||||||
|
VgpuInstance uint32
|
||||||
|
Pid uint32
|
||||||
|
ProcessName [64]int8
|
||||||
|
TimeStamp uint64
|
||||||
|
SmUtil uint32
|
||||||
|
MemUtil uint32
|
||||||
|
EncUtil uint32
|
||||||
|
DecUtil uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type VgpuLicenseExpiry struct {
|
||||||
|
Year uint32
|
||||||
|
Month uint16
|
||||||
|
Day uint16
|
||||||
|
Hour uint16
|
||||||
|
Min uint16
|
||||||
|
Sec uint16
|
||||||
|
Status uint8
|
||||||
|
Pad_cgo_0 [1]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type VgpuLicenseInfo struct {
|
||||||
|
IsLicensed uint8
|
||||||
|
LicenseExpiry VgpuLicenseExpiry
|
||||||
|
CurrentState uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProcessUtilizationSample struct {
|
||||||
|
Pid uint32
|
||||||
|
TimeStamp uint64
|
||||||
|
SmUtil uint32
|
||||||
|
MemUtil uint32
|
||||||
|
EncUtil uint32
|
||||||
|
DecUtil uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type GridLicenseExpiry struct {
|
||||||
|
Year uint32
|
||||||
|
Month uint16
|
||||||
|
Day uint16
|
||||||
|
Hour uint16
|
||||||
|
Min uint16
|
||||||
|
Sec uint16
|
||||||
|
Status uint8
|
||||||
|
Pad_cgo_0 [1]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type GridLicensableFeature struct {
|
||||||
|
FeatureCode uint32
|
||||||
|
FeatureState uint32
|
||||||
|
LicenseInfo [128]int8
|
||||||
|
ProductName [128]int8
|
||||||
|
FeatureEnabled uint32
|
||||||
|
LicenseExpiry GridLicenseExpiry
|
||||||
|
}
|
||||||
|
|
||||||
|
type GridLicensableFeatures struct {
|
||||||
|
IsGridLicenseSupported int32
|
||||||
|
LicensableFeaturesCount uint32
|
||||||
|
GridLicensableFeatures [3]GridLicensableFeature
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeviceArchitecture uint32
|
||||||
|
|
||||||
|
type BusType uint32
|
||||||
|
|
||||||
|
type PowerSource uint32
|
||||||
|
|
||||||
|
type FieldValue struct {
|
||||||
|
FieldId uint32
|
||||||
|
ScopeId uint32
|
||||||
|
Timestamp int64
|
||||||
|
LatencyUsec int64
|
||||||
|
ValueType uint32
|
||||||
|
NvmlReturn uint32
|
||||||
|
Value [8]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type Unit struct {
|
||||||
|
Handle *_Ctype_struct_nvmlUnit_st
|
||||||
|
}
|
||||||
|
|
||||||
|
type HwbcEntry struct {
|
||||||
|
HwbcId uint32
|
||||||
|
FirmwareVersion [32]int8
|
||||||
|
}
|
||||||
|
|
||||||
|
type LedState struct {
|
||||||
|
Cause [256]int8
|
||||||
|
Color uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type UnitInfo struct {
|
||||||
|
Name [96]int8
|
||||||
|
Id [96]int8
|
||||||
|
Serial [96]int8
|
||||||
|
FirmwareVersion [96]int8
|
||||||
|
}
|
||||||
|
|
||||||
|
type PSUInfo struct {
|
||||||
|
State [256]int8
|
||||||
|
Current uint32
|
||||||
|
Voltage uint32
|
||||||
|
Power uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type UnitFanInfo struct {
|
||||||
|
Speed uint32
|
||||||
|
State uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type UnitFanSpeeds struct {
|
||||||
|
Fans [24]UnitFanInfo
|
||||||
|
Count uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type EventSet struct {
|
||||||
|
Handle *_Ctype_struct_nvmlEventSet_st
|
||||||
|
}
|
||||||
|
|
||||||
|
type EventData struct {
|
||||||
|
Device Device
|
||||||
|
EventType uint64
|
||||||
|
EventData uint64
|
||||||
|
GpuInstanceId uint32
|
||||||
|
ComputeInstanceId uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type AccountingStats struct {
|
||||||
|
GpuUtilization uint32
|
||||||
|
MemoryUtilization uint32
|
||||||
|
MaxMemoryUsage uint64
|
||||||
|
Time uint64
|
||||||
|
StartTime uint64
|
||||||
|
IsRunning uint32
|
||||||
|
Reserved [5]uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type EncoderSessionInfo struct {
|
||||||
|
SessionId uint32
|
||||||
|
Pid uint32
|
||||||
|
VgpuInstance uint32
|
||||||
|
CodecType uint32
|
||||||
|
HResolution uint32
|
||||||
|
VResolution uint32
|
||||||
|
AverageFps uint32
|
||||||
|
AverageLatency uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type FBCStats struct {
|
||||||
|
SessionsCount uint32
|
||||||
|
AverageFPS uint32
|
||||||
|
AverageLatency uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type FBCSessionInfo struct {
|
||||||
|
SessionId uint32
|
||||||
|
Pid uint32
|
||||||
|
VgpuInstance uint32
|
||||||
|
DisplayOrdinal uint32
|
||||||
|
SessionType uint32
|
||||||
|
SessionFlags uint32
|
||||||
|
HMaxResolution uint32
|
||||||
|
VMaxResolution uint32
|
||||||
|
HResolution uint32
|
||||||
|
VResolution uint32
|
||||||
|
AverageFPS uint32
|
||||||
|
AverageLatency uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type AffinityScope uint32
|
||||||
|
|
||||||
|
type VgpuVersion struct {
|
||||||
|
MinVersion uint32
|
||||||
|
MaxVersion uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type nvmlVgpuMetadata struct {
|
||||||
|
Version uint32
|
||||||
|
Revision uint32
|
||||||
|
GuestInfoState uint32
|
||||||
|
GuestDriverVersion [80]int8
|
||||||
|
HostDriverVersion [80]int8
|
||||||
|
Reserved [6]uint32
|
||||||
|
VgpuVirtualizationCaps uint32
|
||||||
|
GuestVgpuVersion uint32
|
||||||
|
OpaqueDataSize uint32
|
||||||
|
OpaqueData [4]int8
|
||||||
|
}
|
||||||
|
|
||||||
|
type nvmlVgpuPgpuMetadata struct {
|
||||||
|
Version uint32
|
||||||
|
Revision uint32
|
||||||
|
HostDriverVersion [80]int8
|
||||||
|
PgpuVirtualizationCaps uint32
|
||||||
|
Reserved [5]uint32
|
||||||
|
HostSupportedVgpuRange VgpuVersion
|
||||||
|
OpaqueDataSize uint32
|
||||||
|
OpaqueData [4]int8
|
||||||
|
}
|
||||||
|
|
||||||
|
type VgpuPgpuCompatibility struct {
|
||||||
|
VgpuVmCompatibility uint32
|
||||||
|
CompatibilityLimitCode uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type ExcludedDeviceInfo struct {
|
||||||
|
PciInfo PciInfo
|
||||||
|
Uuid [80]int8
|
||||||
|
}
|
||||||
|
|
||||||
|
type GpuInstancePlacement struct {
|
||||||
|
Start uint32
|
||||||
|
Size uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type GpuInstanceProfileInfo struct {
|
||||||
|
Id uint32
|
||||||
|
IsP2pSupported uint32
|
||||||
|
SliceCount uint32
|
||||||
|
InstanceCount uint32
|
||||||
|
MultiprocessorCount uint32
|
||||||
|
CopyEngineCount uint32
|
||||||
|
DecoderCount uint32
|
||||||
|
EncoderCount uint32
|
||||||
|
JpegCount uint32
|
||||||
|
OfaCount uint32
|
||||||
|
MemorySizeMB uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type GpuInstanceProfileInfo_v2 struct {
|
||||||
|
Version uint32
|
||||||
|
Id uint32
|
||||||
|
IsP2pSupported uint32
|
||||||
|
SliceCount uint32
|
||||||
|
InstanceCount uint32
|
||||||
|
MultiprocessorCount uint32
|
||||||
|
CopyEngineCount uint32
|
||||||
|
DecoderCount uint32
|
||||||
|
EncoderCount uint32
|
||||||
|
JpegCount uint32
|
||||||
|
OfaCount uint32
|
||||||
|
MemorySizeMB uint64
|
||||||
|
Name [96]int8
|
||||||
|
}
|
||||||
|
|
||||||
|
type GpuInstanceInfo struct {
|
||||||
|
Device Device
|
||||||
|
Id uint32
|
||||||
|
ProfileId uint32
|
||||||
|
Placement GpuInstancePlacement
|
||||||
|
}
|
||||||
|
|
||||||
|
type GpuInstance struct {
|
||||||
|
Handle *_Ctype_struct_nvmlGpuInstance_st
|
||||||
|
}
|
||||||
|
|
||||||
|
type ComputeInstancePlacement struct {
|
||||||
|
Start uint32
|
||||||
|
Size uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type ComputeInstanceProfileInfo struct {
|
||||||
|
Id uint32
|
||||||
|
SliceCount uint32
|
||||||
|
InstanceCount uint32
|
||||||
|
MultiprocessorCount uint32
|
||||||
|
SharedCopyEngineCount uint32
|
||||||
|
SharedDecoderCount uint32
|
||||||
|
SharedEncoderCount uint32
|
||||||
|
SharedJpegCount uint32
|
||||||
|
SharedOfaCount uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type ComputeInstanceProfileInfo_v2 struct {
|
||||||
|
Version uint32
|
||||||
|
Id uint32
|
||||||
|
SliceCount uint32
|
||||||
|
InstanceCount uint32
|
||||||
|
MultiprocessorCount uint32
|
||||||
|
SharedCopyEngineCount uint32
|
||||||
|
SharedDecoderCount uint32
|
||||||
|
SharedEncoderCount uint32
|
||||||
|
SharedJpegCount uint32
|
||||||
|
SharedOfaCount uint32
|
||||||
|
Name [96]int8
|
||||||
|
}
|
||||||
|
|
||||||
|
type ComputeInstanceInfo struct {
|
||||||
|
Device Device
|
||||||
|
GpuInstance GpuInstance
|
||||||
|
Id uint32
|
||||||
|
ProfileId uint32
|
||||||
|
Placement ComputeInstancePlacement
|
||||||
|
}
|
||||||
|
|
||||||
|
type ComputeInstance struct {
|
||||||
|
Handle *_Ctype_struct_nvmlComputeInstance_st
|
||||||
|
}
|
113
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/unit.go
generated
vendored
Normal file
113
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/unit.go
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
// Copyright (c) 2020, 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
|
||||||
|
|
||||||
|
// nvml.UnitGetCount()
|
||||||
|
func UnitGetCount() (int, Return) {
|
||||||
|
var UnitCount uint32
|
||||||
|
ret := nvmlUnitGetCount(&UnitCount)
|
||||||
|
return int(UnitCount), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.UnitGetHandleByIndex()
|
||||||
|
func UnitGetHandleByIndex(Index int) (Unit, Return) {
|
||||||
|
var Unit Unit
|
||||||
|
ret := nvmlUnitGetHandleByIndex(uint32(Index), &Unit)
|
||||||
|
return Unit, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.UnitGetUnitInfo()
|
||||||
|
func UnitGetUnitInfo(Unit Unit) (UnitInfo, Return) {
|
||||||
|
var Info UnitInfo
|
||||||
|
ret := nvmlUnitGetUnitInfo(Unit, &Info)
|
||||||
|
return Info, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Unit Unit) GetUnitInfo() (UnitInfo, Return) {
|
||||||
|
return UnitGetUnitInfo(Unit)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.UnitGetLedState()
|
||||||
|
func UnitGetLedState(Unit Unit) (LedState, Return) {
|
||||||
|
var State LedState
|
||||||
|
ret := nvmlUnitGetLedState(Unit, &State)
|
||||||
|
return State, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Unit Unit) GetLedState() (LedState, Return) {
|
||||||
|
return UnitGetLedState(Unit)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.UnitGetPsuInfo()
|
||||||
|
func UnitGetPsuInfo(Unit Unit) (PSUInfo, Return) {
|
||||||
|
var Psu PSUInfo
|
||||||
|
ret := nvmlUnitGetPsuInfo(Unit, &Psu)
|
||||||
|
return Psu, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Unit Unit) GetPsuInfo() (PSUInfo, Return) {
|
||||||
|
return UnitGetPsuInfo(Unit)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.UnitGetTemperature()
|
||||||
|
func UnitGetTemperature(Unit Unit, Type int) (uint32, Return) {
|
||||||
|
var Temp uint32
|
||||||
|
ret := nvmlUnitGetTemperature(Unit, uint32(Type), &Temp)
|
||||||
|
return Temp, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Unit Unit) GetTemperature(Type int) (uint32, Return) {
|
||||||
|
return UnitGetTemperature(Unit, Type)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.UnitGetFanSpeedInfo()
|
||||||
|
func UnitGetFanSpeedInfo(Unit Unit) (UnitFanSpeeds, Return) {
|
||||||
|
var FanSpeeds UnitFanSpeeds
|
||||||
|
ret := nvmlUnitGetFanSpeedInfo(Unit, &FanSpeeds)
|
||||||
|
return FanSpeeds, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Unit Unit) GetFanSpeedInfo() (UnitFanSpeeds, Return) {
|
||||||
|
return UnitGetFanSpeedInfo(Unit)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.UnitGetDevices()
|
||||||
|
func UnitGetDevices(Unit Unit) ([]Device, Return) {
|
||||||
|
var DeviceCount uint32 = 1 // Will be reduced upon returning
|
||||||
|
for {
|
||||||
|
Devices := make([]Device, DeviceCount)
|
||||||
|
ret := nvmlUnitGetDevices(Unit, &DeviceCount, &Devices[0])
|
||||||
|
if ret == SUCCESS {
|
||||||
|
return Devices[:DeviceCount], ret
|
||||||
|
}
|
||||||
|
if ret != ERROR_INSUFFICIENT_SIZE {
|
||||||
|
return nil, ret
|
||||||
|
}
|
||||||
|
DeviceCount *= 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Unit Unit) GetDevices() ([]Device, Return) {
|
||||||
|
return UnitGetDevices(Unit)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.UnitSetLedState()
|
||||||
|
func UnitSetLedState(Unit Unit, Color LedColor) Return {
|
||||||
|
return nvmlUnitSetLedState(Unit, Color)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Unit Unit) SetLedState(Color LedColor) Return {
|
||||||
|
return UnitSetLedState(Unit, Color)
|
||||||
|
}
|
462
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/vgpu.go
generated
vendored
Normal file
462
vendor/github.com/NVIDIA/go-nvml/pkg/nvml/vgpu.go
generated
vendored
Normal file
@ -0,0 +1,462 @@
|
|||||||
|
// Copyright (c) 2020, 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 (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// nvml.VgpuMetadata
|
||||||
|
type VgpuMetadata struct {
|
||||||
|
nvmlVgpuMetadata
|
||||||
|
OpaqueData []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuPgpuMetadata
|
||||||
|
type VgpuPgpuMetadata struct {
|
||||||
|
nvmlVgpuPgpuMetadata
|
||||||
|
OpaqueData []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuTypeGetClass()
|
||||||
|
func VgpuTypeGetClass(VgpuTypeId VgpuTypeId) (string, Return) {
|
||||||
|
var Size uint32 = DEVICE_NAME_BUFFER_SIZE
|
||||||
|
VgpuTypeClass := make([]byte, DEVICE_NAME_BUFFER_SIZE)
|
||||||
|
ret := nvmlVgpuTypeGetClass(VgpuTypeId, &VgpuTypeClass[0], &Size)
|
||||||
|
return string(VgpuTypeClass[:clen(VgpuTypeClass)]), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuTypeId VgpuTypeId) GetClass() (string, Return) {
|
||||||
|
return VgpuTypeGetClass(VgpuTypeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuTypeGetName()
|
||||||
|
func VgpuTypeGetName(VgpuTypeId VgpuTypeId) (string, Return) {
|
||||||
|
var Size uint32 = DEVICE_NAME_BUFFER_SIZE
|
||||||
|
VgpuTypeName := make([]byte, DEVICE_NAME_BUFFER_SIZE)
|
||||||
|
ret := nvmlVgpuTypeGetName(VgpuTypeId, &VgpuTypeName[0], &Size)
|
||||||
|
return string(VgpuTypeName[:clen(VgpuTypeName)]), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuTypeId VgpuTypeId) GetName() (string, Return) {
|
||||||
|
return VgpuTypeGetName(VgpuTypeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuTypeGetGpuInstanceProfileId()
|
||||||
|
func VgpuTypeGetGpuInstanceProfileId(VgpuTypeId VgpuTypeId) (uint32, Return) {
|
||||||
|
var Size uint32
|
||||||
|
ret := nvmlVgpuTypeGetGpuInstanceProfileId(VgpuTypeId, &Size)
|
||||||
|
return Size, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuTypeId VgpuTypeId) GetGpuInstanceProfileId() (uint32, Return) {
|
||||||
|
return VgpuTypeGetGpuInstanceProfileId(VgpuTypeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuTypeGetDeviceID()
|
||||||
|
func VgpuTypeGetDeviceID(VgpuTypeId VgpuTypeId) (uint64, uint64, Return) {
|
||||||
|
var DeviceID, SubsystemID uint64
|
||||||
|
ret := nvmlVgpuTypeGetDeviceID(VgpuTypeId, &DeviceID, &SubsystemID)
|
||||||
|
return DeviceID, SubsystemID, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuTypeId VgpuTypeId) GetDeviceID() (uint64, uint64, Return) {
|
||||||
|
return VgpuTypeGetDeviceID(VgpuTypeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuTypeGetFramebufferSize()
|
||||||
|
func VgpuTypeGetFramebufferSize(VgpuTypeId VgpuTypeId) (uint64, Return) {
|
||||||
|
var FbSize uint64
|
||||||
|
ret := nvmlVgpuTypeGetFramebufferSize(VgpuTypeId, &FbSize)
|
||||||
|
return FbSize, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuTypeId VgpuTypeId) GetFramebufferSize() (uint64, Return) {
|
||||||
|
return VgpuTypeGetFramebufferSize(VgpuTypeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuTypeGetNumDisplayHeads()
|
||||||
|
func VgpuTypeGetNumDisplayHeads(VgpuTypeId VgpuTypeId) (int, Return) {
|
||||||
|
var NumDisplayHeads uint32
|
||||||
|
ret := nvmlVgpuTypeGetNumDisplayHeads(VgpuTypeId, &NumDisplayHeads)
|
||||||
|
return int(NumDisplayHeads), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuTypeId VgpuTypeId) GetNumDisplayHeads() (int, Return) {
|
||||||
|
return VgpuTypeGetNumDisplayHeads(VgpuTypeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuTypeGetResolution()
|
||||||
|
func VgpuTypeGetResolution(VgpuTypeId VgpuTypeId, DisplayIndex int) (uint32, uint32, Return) {
|
||||||
|
var Xdim, Ydim uint32
|
||||||
|
ret := nvmlVgpuTypeGetResolution(VgpuTypeId, uint32(DisplayIndex), &Xdim, &Ydim)
|
||||||
|
return Xdim, Ydim, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuTypeId VgpuTypeId) GetResolution(DisplayIndex int) (uint32, uint32, Return) {
|
||||||
|
return VgpuTypeGetResolution(VgpuTypeId, DisplayIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuTypeGetLicense()
|
||||||
|
func VgpuTypeGetLicense(VgpuTypeId VgpuTypeId) (string, Return) {
|
||||||
|
VgpuTypeLicenseString := make([]byte, GRID_LICENSE_BUFFER_SIZE)
|
||||||
|
ret := nvmlVgpuTypeGetLicense(VgpuTypeId, &VgpuTypeLicenseString[0], GRID_LICENSE_BUFFER_SIZE)
|
||||||
|
return string(VgpuTypeLicenseString[:clen(VgpuTypeLicenseString)]), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuTypeId VgpuTypeId) GetLicense() (string, Return) {
|
||||||
|
return VgpuTypeGetLicense(VgpuTypeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuTypeGetFrameRateLimit()
|
||||||
|
func VgpuTypeGetFrameRateLimit(VgpuTypeId VgpuTypeId) (uint32, Return) {
|
||||||
|
var FrameRateLimit uint32
|
||||||
|
ret := nvmlVgpuTypeGetFrameRateLimit(VgpuTypeId, &FrameRateLimit)
|
||||||
|
return FrameRateLimit, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuTypeId VgpuTypeId) GetFrameRateLimit() (uint32, Return) {
|
||||||
|
return VgpuTypeGetFrameRateLimit(VgpuTypeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuTypeGetMaxInstances()
|
||||||
|
func VgpuTypeGetMaxInstances(Device Device, VgpuTypeId VgpuTypeId) (int, Return) {
|
||||||
|
var VgpuInstanceCount uint32
|
||||||
|
ret := nvmlVgpuTypeGetMaxInstances(Device, VgpuTypeId, &VgpuInstanceCount)
|
||||||
|
return int(VgpuInstanceCount), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Device Device) VgpuTypeGetMaxInstances(VgpuTypeId VgpuTypeId) (int, Return) {
|
||||||
|
return VgpuTypeGetMaxInstances(Device, VgpuTypeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuTypeId VgpuTypeId) GetMaxInstances(Device Device) (int, Return) {
|
||||||
|
return VgpuTypeGetMaxInstances(Device, VgpuTypeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuTypeGetMaxInstancesPerVm()
|
||||||
|
func VgpuTypeGetMaxInstancesPerVm(VgpuTypeId VgpuTypeId) (int, Return) {
|
||||||
|
var VgpuInstanceCountPerVm uint32
|
||||||
|
ret := nvmlVgpuTypeGetMaxInstancesPerVm(VgpuTypeId, &VgpuInstanceCountPerVm)
|
||||||
|
return int(VgpuInstanceCountPerVm), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuTypeId VgpuTypeId) GetMaxInstancesPerVm() (int, Return) {
|
||||||
|
return VgpuTypeGetMaxInstancesPerVm(VgpuTypeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetVmID()
|
||||||
|
func VgpuInstanceGetVmID(VgpuInstance VgpuInstance) (string, VgpuVmIdType, Return) {
|
||||||
|
var VmIdType VgpuVmIdType
|
||||||
|
VmId := make([]byte, DEVICE_UUID_BUFFER_SIZE)
|
||||||
|
ret := nvmlVgpuInstanceGetVmID(VgpuInstance, &VmId[0], DEVICE_UUID_BUFFER_SIZE, &VmIdType)
|
||||||
|
return string(VmId[:clen(VmId)]), VmIdType, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetVmID() (string, VgpuVmIdType, Return) {
|
||||||
|
return VgpuInstanceGetVmID(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetUUID()
|
||||||
|
func VgpuInstanceGetUUID(VgpuInstance VgpuInstance) (string, Return) {
|
||||||
|
Uuid := make([]byte, DEVICE_UUID_BUFFER_SIZE)
|
||||||
|
ret := nvmlVgpuInstanceGetUUID(VgpuInstance, &Uuid[0], DEVICE_UUID_BUFFER_SIZE)
|
||||||
|
return string(Uuid[:clen(Uuid)]), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetUUID() (string, Return) {
|
||||||
|
return VgpuInstanceGetUUID(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetVmDriverVersion()
|
||||||
|
func VgpuInstanceGetVmDriverVersion(VgpuInstance VgpuInstance) (string, Return) {
|
||||||
|
Version := make([]byte, SYSTEM_DRIVER_VERSION_BUFFER_SIZE)
|
||||||
|
ret := nvmlVgpuInstanceGetVmDriverVersion(VgpuInstance, &Version[0], SYSTEM_DRIVER_VERSION_BUFFER_SIZE)
|
||||||
|
return string(Version[:clen(Version)]), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetVmDriverVersion() (string, Return) {
|
||||||
|
return VgpuInstanceGetVmDriverVersion(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetFbUsage()
|
||||||
|
func VgpuInstanceGetFbUsage(VgpuInstance VgpuInstance) (uint64, Return) {
|
||||||
|
var FbUsage uint64
|
||||||
|
ret := nvmlVgpuInstanceGetFbUsage(VgpuInstance, &FbUsage)
|
||||||
|
return FbUsage, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetFbUsage() (uint64, Return) {
|
||||||
|
return VgpuInstanceGetFbUsage(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetLicenseInfo()
|
||||||
|
func VgpuInstanceGetLicenseInfo(VgpuInstance VgpuInstance) (VgpuLicenseInfo, Return) {
|
||||||
|
var LicenseInfo VgpuLicenseInfo
|
||||||
|
ret := nvmlVgpuInstanceGetLicenseInfo(VgpuInstance, &LicenseInfo)
|
||||||
|
return LicenseInfo, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetLicenseInfo() (VgpuLicenseInfo, Return) {
|
||||||
|
return VgpuInstanceGetLicenseInfo(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetLicenseStatus()
|
||||||
|
func VgpuInstanceGetLicenseStatus(VgpuInstance VgpuInstance) (int, Return) {
|
||||||
|
var Licensed uint32
|
||||||
|
ret := nvmlVgpuInstanceGetLicenseStatus(VgpuInstance, &Licensed)
|
||||||
|
return int(Licensed), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetLicenseStatus() (int, Return) {
|
||||||
|
return VgpuInstanceGetLicenseStatus(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetType()
|
||||||
|
func VgpuInstanceGetType(VgpuInstance VgpuInstance) (VgpuTypeId, Return) {
|
||||||
|
var VgpuTypeId VgpuTypeId
|
||||||
|
ret := nvmlVgpuInstanceGetType(VgpuInstance, &VgpuTypeId)
|
||||||
|
return VgpuTypeId, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetType() (VgpuTypeId, Return) {
|
||||||
|
return VgpuInstanceGetType(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetFrameRateLimit()
|
||||||
|
func VgpuInstanceGetFrameRateLimit(VgpuInstance VgpuInstance) (uint32, Return) {
|
||||||
|
var FrameRateLimit uint32
|
||||||
|
ret := nvmlVgpuInstanceGetFrameRateLimit(VgpuInstance, &FrameRateLimit)
|
||||||
|
return FrameRateLimit, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetFrameRateLimit() (uint32, Return) {
|
||||||
|
return VgpuInstanceGetFrameRateLimit(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetEccMode()
|
||||||
|
func VgpuInstanceGetEccMode(VgpuInstance VgpuInstance) (EnableState, Return) {
|
||||||
|
var EccMode EnableState
|
||||||
|
ret := nvmlVgpuInstanceGetEccMode(VgpuInstance, &EccMode)
|
||||||
|
return EccMode, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetEccMode() (EnableState, Return) {
|
||||||
|
return VgpuInstanceGetEccMode(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetEncoderCapacity()
|
||||||
|
func VgpuInstanceGetEncoderCapacity(VgpuInstance VgpuInstance) (int, Return) {
|
||||||
|
var EncoderCapacity uint32
|
||||||
|
ret := nvmlVgpuInstanceGetEncoderCapacity(VgpuInstance, &EncoderCapacity)
|
||||||
|
return int(EncoderCapacity), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetEncoderCapacity() (int, Return) {
|
||||||
|
return VgpuInstanceGetEncoderCapacity(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceSetEncoderCapacity()
|
||||||
|
func VgpuInstanceSetEncoderCapacity(VgpuInstance VgpuInstance, EncoderCapacity int) Return {
|
||||||
|
return nvmlVgpuInstanceSetEncoderCapacity(VgpuInstance, uint32(EncoderCapacity))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) SetEncoderCapacity(EncoderCapacity int) Return {
|
||||||
|
return VgpuInstanceSetEncoderCapacity(VgpuInstance, EncoderCapacity)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetEncoderStats()
|
||||||
|
func VgpuInstanceGetEncoderStats(VgpuInstance VgpuInstance) (int, uint32, uint32, Return) {
|
||||||
|
var SessionCount, AverageFps, AverageLatency uint32
|
||||||
|
ret := nvmlVgpuInstanceGetEncoderStats(VgpuInstance, &SessionCount, &AverageFps, &AverageLatency)
|
||||||
|
return int(SessionCount), AverageFps, AverageLatency, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetEncoderStats() (int, uint32, uint32, Return) {
|
||||||
|
return VgpuInstanceGetEncoderStats(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetEncoderSessions()
|
||||||
|
func VgpuInstanceGetEncoderSessions(VgpuInstance VgpuInstance) (int, EncoderSessionInfo, Return) {
|
||||||
|
var SessionCount uint32
|
||||||
|
var SessionInfo EncoderSessionInfo
|
||||||
|
ret := nvmlVgpuInstanceGetEncoderSessions(VgpuInstance, &SessionCount, &SessionInfo)
|
||||||
|
return int(SessionCount), SessionInfo, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetEncoderSessions() (int, EncoderSessionInfo, Return) {
|
||||||
|
return VgpuInstanceGetEncoderSessions(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetFBCStats()
|
||||||
|
func VgpuInstanceGetFBCStats(VgpuInstance VgpuInstance) (FBCStats, Return) {
|
||||||
|
var FbcStats FBCStats
|
||||||
|
ret := nvmlVgpuInstanceGetFBCStats(VgpuInstance, &FbcStats)
|
||||||
|
return FbcStats, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetFBCStats() (FBCStats, Return) {
|
||||||
|
return VgpuInstanceGetFBCStats(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetFBCSessions()
|
||||||
|
func VgpuInstanceGetFBCSessions(VgpuInstance VgpuInstance) (int, FBCSessionInfo, Return) {
|
||||||
|
var SessionCount uint32
|
||||||
|
var SessionInfo FBCSessionInfo
|
||||||
|
ret := nvmlVgpuInstanceGetFBCSessions(VgpuInstance, &SessionCount, &SessionInfo)
|
||||||
|
return int(SessionCount), SessionInfo, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetFBCSessions() (int, FBCSessionInfo, Return) {
|
||||||
|
return VgpuInstanceGetFBCSessions(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetGpuInstanceId()
|
||||||
|
func VgpuInstanceGetGpuInstanceId(VgpuInstance VgpuInstance) (int, Return) {
|
||||||
|
var gpuInstanceId uint32
|
||||||
|
ret := nvmlVgpuInstanceGetGpuInstanceId(VgpuInstance, &gpuInstanceId)
|
||||||
|
return int(gpuInstanceId), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetGpuInstanceId() (int, Return) {
|
||||||
|
return VgpuInstanceGetGpuInstanceId(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetGpuPciId()
|
||||||
|
func VgpuInstanceGetGpuPciId(VgpuInstance VgpuInstance) (string, Return) {
|
||||||
|
var Length uint32 = 1 // Will be reduced upon returning
|
||||||
|
for {
|
||||||
|
VgpuPciId := make([]byte, Length)
|
||||||
|
ret := nvmlVgpuInstanceGetGpuPciId(VgpuInstance, &VgpuPciId[0], &Length)
|
||||||
|
if ret == SUCCESS {
|
||||||
|
return string(VgpuPciId[:clen(VgpuPciId)]), ret
|
||||||
|
}
|
||||||
|
if ret != ERROR_INSUFFICIENT_SIZE {
|
||||||
|
return "", ret
|
||||||
|
}
|
||||||
|
Length *= 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetGpuPciId() (string, Return) {
|
||||||
|
return VgpuInstanceGetGpuPciId(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetMetadata()
|
||||||
|
func VgpuInstanceGetMetadata(VgpuInstance VgpuInstance) (VgpuMetadata, Return) {
|
||||||
|
var VgpuMetadata VgpuMetadata
|
||||||
|
OpaqueDataSize := unsafe.Sizeof(VgpuMetadata.nvmlVgpuMetadata.OpaqueData)
|
||||||
|
VgpuMetadataSize := unsafe.Sizeof(VgpuMetadata.nvmlVgpuMetadata) - OpaqueDataSize
|
||||||
|
for {
|
||||||
|
BufferSize := uint32(VgpuMetadataSize + OpaqueDataSize)
|
||||||
|
Buffer := make([]byte, BufferSize)
|
||||||
|
nvmlVgpuMetadataPtr := (*nvmlVgpuMetadata)(unsafe.Pointer(&Buffer[0]))
|
||||||
|
ret := nvmlVgpuInstanceGetMetadata(VgpuInstance, nvmlVgpuMetadataPtr, &BufferSize)
|
||||||
|
if ret == SUCCESS {
|
||||||
|
VgpuMetadata.nvmlVgpuMetadata = *nvmlVgpuMetadataPtr
|
||||||
|
VgpuMetadata.OpaqueData = Buffer[VgpuMetadataSize:BufferSize]
|
||||||
|
return VgpuMetadata, ret
|
||||||
|
}
|
||||||
|
if ret != ERROR_INSUFFICIENT_SIZE {
|
||||||
|
return VgpuMetadata, ret
|
||||||
|
}
|
||||||
|
OpaqueDataSize = 2 * OpaqueDataSize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetMetadata() (VgpuMetadata, Return) {
|
||||||
|
return VgpuInstanceGetMetadata(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetAccountingMode()
|
||||||
|
func VgpuInstanceGetAccountingMode(VgpuInstance VgpuInstance) (EnableState, Return) {
|
||||||
|
var Mode EnableState
|
||||||
|
ret := nvmlVgpuInstanceGetAccountingMode(VgpuInstance, &Mode)
|
||||||
|
return Mode, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetAccountingMode() (EnableState, Return) {
|
||||||
|
return VgpuInstanceGetAccountingMode(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetAccountingPids()
|
||||||
|
func VgpuInstanceGetAccountingPids(VgpuInstance VgpuInstance) ([]int, Return) {
|
||||||
|
var Count uint32 = 1 // Will be reduced upon returning
|
||||||
|
for {
|
||||||
|
Pids := make([]uint32, Count)
|
||||||
|
ret := nvmlVgpuInstanceGetAccountingPids(VgpuInstance, &Count, &Pids[0])
|
||||||
|
if ret == SUCCESS {
|
||||||
|
return uint32SliceToIntSlice(Pids[:Count]), ret
|
||||||
|
}
|
||||||
|
if ret != ERROR_INSUFFICIENT_SIZE {
|
||||||
|
return nil, ret
|
||||||
|
}
|
||||||
|
Count *= 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetAccountingPids() ([]int, Return) {
|
||||||
|
return VgpuInstanceGetAccountingPids(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetAccountingStats()
|
||||||
|
func VgpuInstanceGetAccountingStats(VgpuInstance VgpuInstance, Pid int) (AccountingStats, Return) {
|
||||||
|
var Stats AccountingStats
|
||||||
|
ret := nvmlVgpuInstanceGetAccountingStats(VgpuInstance, uint32(Pid), &Stats)
|
||||||
|
return Stats, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetAccountingStats(Pid int) (AccountingStats, Return) {
|
||||||
|
return VgpuInstanceGetAccountingStats(VgpuInstance, Pid)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.GetVgpuCompatibility()
|
||||||
|
func GetVgpuCompatibility(nvmlVgpuMetadata *nvmlVgpuMetadata, PgpuMetadata *nvmlVgpuPgpuMetadata) (VgpuPgpuCompatibility, Return) {
|
||||||
|
var CompatibilityInfo VgpuPgpuCompatibility
|
||||||
|
ret := nvmlGetVgpuCompatibility(nvmlVgpuMetadata, PgpuMetadata, &CompatibilityInfo)
|
||||||
|
return CompatibilityInfo, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.GetVgpuVersion()
|
||||||
|
func GetVgpuVersion() (VgpuVersion, VgpuVersion, Return) {
|
||||||
|
var Supported, Current VgpuVersion
|
||||||
|
ret := nvmlGetVgpuVersion(&Supported, &Current)
|
||||||
|
return Supported, Current, ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.SetVgpuVersion()
|
||||||
|
func SetVgpuVersion(VgpuVersion *VgpuVersion) Return {
|
||||||
|
return SetVgpuVersion(VgpuVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceClearAccountingPids()
|
||||||
|
func VgpuInstanceClearAccountingPids(VgpuInstance VgpuInstance) Return {
|
||||||
|
return nvmlVgpuInstanceClearAccountingPids(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) ClearAccountingPids() Return {
|
||||||
|
return VgpuInstanceClearAccountingPids(VgpuInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
// nvml.VgpuInstanceGetMdevUUID()
|
||||||
|
func VgpuInstanceGetMdevUUID(VgpuInstance VgpuInstance) (string, Return) {
|
||||||
|
MdevUuid := make([]byte, DEVICE_UUID_BUFFER_SIZE)
|
||||||
|
ret := nvmlVgpuInstanceGetMdevUUID(VgpuInstance, &MdevUuid[0], DEVICE_UUID_BUFFER_SIZE)
|
||||||
|
return string(MdevUuid[:clen(MdevUuid)]), ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (VgpuInstance VgpuInstance) GetMdevUUID() (string, Return) {
|
||||||
|
return VgpuInstanceGetMdevUUID(VgpuInstance)
|
||||||
|
}
|
1
vendor/modules.txt
vendored
1
vendor/modules.txt
vendored
@ -1,6 +1,7 @@
|
|||||||
# github.com/NVIDIA/go-nvml v0.11.6-0.0.20220614115128-31f8b89eb740
|
# github.com/NVIDIA/go-nvml v0.11.6-0.0.20220614115128-31f8b89eb740
|
||||||
## explicit
|
## explicit
|
||||||
github.com/NVIDIA/go-nvml/pkg/dl
|
github.com/NVIDIA/go-nvml/pkg/dl
|
||||||
|
github.com/NVIDIA/go-nvml/pkg/nvml
|
||||||
# github.com/davecgh/go-spew v1.1.0
|
# github.com/davecgh/go-spew v1.1.0
|
||||||
github.com/davecgh/go-spew/spew
|
github.com/davecgh/go-spew/spew
|
||||||
# github.com/pmezard/go-difflib v1.0.0
|
# github.com/pmezard/go-difflib v1.0.0
|
||||||
|
Loading…
Reference in New Issue
Block a user