From b5d54e7e2a509a5f47b8d8fd9049661e6f3eaceb Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Mon, 15 Jul 2024 20:14:46 +0200 Subject: [PATCH] Bump go-nvml, go-nvlib, nvidia-container-toolkit Signed-off-by: Evan Lezar --- go.mod | 13 +- go.sum | 20 +- .../NVIDIA/go-nvlib/pkg/nvlib/device/api.go | 30 +- .../go-nvlib/pkg/nvlib/device/device.go | 77 +- .../go-nvlib/pkg/nvlib/device/identifier.go | 12 +- .../go-nvlib/pkg/nvlib/device/mig_device.go | 12 +- .../go-nvlib/pkg/nvlib/device/mig_profile.go | 26 +- .../NVIDIA/go-nvlib/pkg/nvlib/info/api.go | 41 + .../NVIDIA/go-nvlib/pkg/nvlib/info/builder.go | 78 + .../NVIDIA/go-nvlib/pkg/nvlib/info/info.go | 102 - .../{nvml/options.go => nvlib/info/logger.go} | 22 +- .../NVIDIA/go-nvlib/pkg/nvlib/info/options.go | 61 +- .../pkg/nvlib/info/property-extractor.go | 143 + .../pkg/nvlib/info/property-extractor_mock.go | 215 + .../go-nvlib/pkg/nvlib/info/resolver.go | 64 + .../NVIDIA/go-nvlib/pkg/nvlib/info/root.go | 86 + .../github.com/NVIDIA/go-nvlib/pkg/nvml/ci.go | 44 - .../NVIDIA/go-nvlib/pkg/nvml/ci_mock.go | 104 - .../NVIDIA/go-nvlib/pkg/nvml/consts.go | 163 - .../NVIDIA/go-nvlib/pkg/nvml/device.go | 215 - .../NVIDIA/go-nvlib/pkg/nvml/device_mock.go | 1237 ------ .../NVIDIA/go-nvlib/pkg/nvml/event_set.go | 39 - .../github.com/NVIDIA/go-nvlib/pkg/nvml/gi.go | 71 - .../NVIDIA/go-nvlib/pkg/nvml/gi_mock.go | 286 -- .../NVIDIA/go-nvlib/pkg/nvml/nvml.go | 127 - .../NVIDIA/go-nvlib/pkg/nvml/nvml_mock.go | 428 -- .../NVIDIA/go-nvlib/pkg/nvml/return.go | 93 - .../NVIDIA/go-nvlib/pkg/nvml/types.go | 162 - .../NVIDIA/go-nvlib/pkg/nvpci/bytes/bytes.go | 14 +- .../NVIDIA/go-nvlib/pkg/nvpci/config.go | 20 +- .../NVIDIA/go-nvlib/pkg/nvpci/mlxpci.go | 18 +- .../NVIDIA/go-nvlib/pkg/nvpci/mmio/mmio.go | 6 +- .../NVIDIA/go-nvlib/pkg/nvpci/mmio/mock.go | 9 +- .../NVIDIA/go-nvlib/pkg/nvpci/mock.go | 138 +- .../NVIDIA/go-nvlib/pkg/nvpci/nvpci.go | 175 +- .../NVIDIA/go-nvlib/pkg/nvpci/resources.go | 10 +- .../NVIDIA/go-nvlib/pkg/pciids/pciids.go | 76 +- .../github.com/NVIDIA/go-nvml/pkg/nvml/api.go | 45 +- .../{cgo_helpers.go => cgo_helpers_static.go} | 11 + .../NVIDIA/go-nvml/pkg/nvml/const.go | 206 +- .../nvml/{const_gen.go => const_static.go} | 0 .../NVIDIA/go-nvml/pkg/nvml/device.go | 3175 ++++++++------- .../NVIDIA/go-nvml/pkg/nvml/event_set.go | 55 +- .../github.com/NVIDIA/go-nvml/pkg/nvml/gpm.go | 153 +- .../NVIDIA/go-nvml/pkg/nvml/init.go | 16 +- .../github.com/NVIDIA/go-nvml/pkg/nvml/lib.go | 166 +- .../NVIDIA/go-nvml/pkg/nvml/nvml.go | 2345 ++++++----- .../github.com/NVIDIA/go-nvml/pkg/nvml/nvml.h | 3590 ++++++++++++----- .../NVIDIA/go-nvml/pkg/nvml/return.go | 24 +- .../NVIDIA/go-nvml/pkg/nvml/system.go | 99 +- .../NVIDIA/go-nvml/pkg/nvml/types_gen.go | 369 +- .../NVIDIA/go-nvml/pkg/nvml/unit.go | 98 +- .../NVIDIA/go-nvml/pkg/nvml/vgpu.go | 488 +-- .../go-nvml/pkg/nvml/zz_generated.api.go | 1007 +++++ .../internal/discover/graphics.go | 339 +- .../internal/discover/hooks.go | 27 +- .../internal/discover/ldconfig.go | 22 +- .../discover/mounts-to-container-path.go | 81 + .../internal/logger/api.go | 1 + .../internal/logger/lib.go | 3 + .../internal/lookup/root/root.go | 23 + .../internal/oci/runtime.go | 5 +- .../internal/oci/runtime_low_level.go | 7 +- .../internal/oci/runtime_mock.go | 42 +- .../internal/oci/runtime_modifier.go | 16 +- .../internal/oci/runtime_path.go | 5 + .../internal/oci/runtime_syscall_exec.go | 4 + .../internal/oci/spec.go | 2 +- .../platform-support/dgpu/by-path-hooks.go | 117 + .../internal/platform-support/dgpu/dgpu.go | 57 + .../internal/platform-support/dgpu/nvml.go | 168 + .../internal/platform-support/dgpu/options.go | 50 + .../platform-support/tegra/symlinks.go | 12 +- .../internal/platform-support/tegra/tegra.go | 10 +- .../pkg/nvcdi/common-nvml.go | 4 +- .../pkg/nvcdi/driver-nvml.go | 14 +- .../pkg/nvcdi/driver-wsl.go | 22 +- .../pkg/nvcdi/full-gpu-nvml.go | 165 +- .../pkg/nvcdi/lib-csv.go | 2 +- .../pkg/nvcdi/lib-nvml.go | 33 +- .../pkg/nvcdi/lib-wsl.go | 2 +- .../nvidia-container-toolkit/pkg/nvcdi/lib.go | 69 +- .../pkg/nvcdi/management.go | 4 +- .../pkg/nvcdi/mig-device-nvml.go | 74 +- .../pkg/nvcdi/namer.go | 2 +- .../pkg/nvcdi/namer_nvml_mock.go | 2 +- .../pkg/nvcdi/options.go | 19 +- .../pkg/nvcdi/spec/api.go | 2 + .../pkg/nvcdi/spec/builder.go | 39 +- .../pkg/nvcdi/spec/set-minimum-version.go | 35 + .../pkg/nvcdi/spec/spec.go | 13 +- .../workarounds-device-folder-permissions.go | 22 +- vendor/modules.txt | 14 +- 93 files changed, 9980 insertions(+), 7832 deletions(-) create mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/api.go create mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/builder.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/info.go rename vendor/github.com/NVIDIA/go-nvlib/pkg/{nvml/options.go => nvlib/info/logger.go} (56%) create mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/property-extractor.go create mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/property-extractor_mock.go create mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/resolver.go create mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/root.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci_mock.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device_mock.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/event_set.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi_mock.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml_mock.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/return.go delete mode 100644 vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go rename vendor/github.com/NVIDIA/go-nvml/pkg/nvml/{cgo_helpers.go => cgo_helpers_static.go} (89%) rename vendor/github.com/NVIDIA/go-nvml/pkg/nvml/{const_gen.go => const_static.go} (100%) create mode 100644 vendor/github.com/NVIDIA/go-nvml/pkg/nvml/zz_generated.api.go create mode 100644 vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/mounts-to-container-path.go create mode 100644 vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/by-path-hooks.go create mode 100644 vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/dgpu.go create mode 100644 vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/nvml.go create mode 100644 vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/options.go create mode 100644 vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/set-minimum-version.go diff --git a/go.mod b/go.mod index 6502f2c6..97474340 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,12 @@ module github.com/NVIDIA/k8s-kata-manager -go 1.21 +go 1.22.0 + toolchain go1.22.5 require ( - github.com/NVIDIA/go-nvlib v0.2.0 - github.com/NVIDIA/nvidia-container-toolkit v1.15.0 + github.com/NVIDIA/go-nvlib v0.6.0 + github.com/NVIDIA/nvidia-container-toolkit v1.16.0 github.com/opencontainers/image-spec v1.1.0 github.com/pelletier/go-toml v1.9.5 github.com/sirupsen/logrus v1.9.3 @@ -23,7 +24,7 @@ require ( require ( github.com/BurntSushi/toml v1.3.2 // indirect - github.com/NVIDIA/go-nvml v0.12.0-3 // indirect + github.com/NVIDIA/go-nvml v0.12.4-0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect @@ -49,8 +50,8 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect - github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect - golang.org/x/mod v0.17.0 // indirect + github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect + golang.org/x/mod v0.19.0 // indirect golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.10.0 // indirect golang.org/x/sync v0.6.0 // indirect diff --git a/go.sum b/go.sum index a02985ac..0f694548 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,11 @@ github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/NVIDIA/go-nvlib v0.2.0 h1:roq+SDstbP1fcy2XVH7wB2Gz2/Ud7Q+NGQYOcVITVrA= -github.com/NVIDIA/go-nvlib v0.2.0/go.mod h1:kFuLNTyD1tF6FbRFlk+/EdUW5BrkE+v1Y3A3/9zKSjA= -github.com/NVIDIA/go-nvml v0.12.0-3 h1:QwfjYxEqIQVRhl8327g2Y3ZvKResPydpGSKtCIIK9jE= -github.com/NVIDIA/go-nvml v0.12.0-3/go.mod h1:SOufGc5Wql+cxrIZ8RyJwVKDYxfbs4WPkHXqadcbfvA= -github.com/NVIDIA/nvidia-container-toolkit v1.15.0 h1:YmYZUKJzhz/lJSVH6k1mk5IUCHpt8HwRtwMrtBoCzhQ= -github.com/NVIDIA/nvidia-container-toolkit v1.15.0/go.mod h1:SUwxfwi+dl1LtVlpAnJEolxuZfCtAVmOKRGWhJYsiJI= +github.com/NVIDIA/go-nvlib v0.6.0 h1:zAMBzCYT9xeyRQo0tb7HJbStkzajD6e5joyaQqJ2OGU= +github.com/NVIDIA/go-nvlib v0.6.0/go.mod h1:9UrsLGx/q1OrENygXjOuM5Ey5KCtiZhbvBlbUIxtGWY= +github.com/NVIDIA/go-nvml v0.12.4-0 h1:4tkbB3pT1O77JGr0gQ6uD8FrsUPqP1A/EOEm2wI1TUg= +github.com/NVIDIA/go-nvml v0.12.4-0/go.mod h1:8Llmj+1Rr+9VGGwZuRer5N/aCjxGuR5nPb/9ebBiIEQ= +github.com/NVIDIA/nvidia-container-toolkit v1.16.0 h1:NZyKfW0s8nfghoBSJJUth7OZB5ZzRGYbn3RaiTDYdHM= +github.com/NVIDIA/nvidia-container-toolkit v1.16.0/go.mod h1:jJXYvHEdqqpDcRXvolaiFCBsgLxvCwmJWSBZM3zQPY8= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= @@ -127,8 +127,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw= -github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -136,8 +136,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/api.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/api.go index 57db8598..c2a6517d 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/api.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/api.go @@ -17,10 +17,10 @@ package device import ( - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" ) -// Interface provides the API to the 'device' package +// Interface provides the API to the 'device' package. type Interface interface { AssertValidMigProfileFormat(profile string) error GetDevices() ([]Device, error) @@ -38,7 +38,7 @@ type Interface interface { } type devicelib struct { - nvml nvml.Interface + nvmllib nvml.Interface skippedDevices map[string]struct{} verifySymbols *bool migProfiles []MigProfile @@ -46,15 +46,14 @@ type devicelib struct { var _ Interface = &devicelib{} -// New creates a new instance of the 'device' interface -func New(opts ...Option) Interface { - d := &devicelib{} +// New creates a new instance of the 'device' interface. +func New(nvmllib nvml.Interface, opts ...Option) Interface { + d := &devicelib{ + nvmllib: nvmllib, + } for _, opt := range opts { opt(d) } - if d.nvml == nil { - d.nvml = nvml.New() - } if d.verifySymbols == nil { verify := true d.verifySymbols = &verify @@ -68,21 +67,14 @@ func New(opts ...Option) Interface { return d } -// WithNvml provides an Option to set the NVML library used by the 'device' interface -func WithNvml(nvml nvml.Interface) Option { - return func(d *devicelib) { - d.nvml = nvml - } -} - -// WithVerifySymbols provides an option to toggle whether to verify select symbols exist in dynamic libraries before calling them +// WithVerifySymbols provides an option to toggle whether to verify select symbols exist in dynamic libraries before calling them. func WithVerifySymbols(verify bool) Option { return func(d *devicelib) { d.verifySymbols = &verify } } -// WithSkippedDevices provides an Option to set devices to be skipped by model name +// WithSkippedDevices provides an Option to set devices to be skipped by model name. func WithSkippedDevices(names ...string) Option { return func(d *devicelib) { if d.skippedDevices == nil { @@ -94,5 +86,5 @@ func WithSkippedDevices(names ...string) Option { } } -// Option defines a function for passing options to the New() call +// Option defines a function for passing options to the New() call. type Option func(*devicelib) diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/device.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/device.go index 49734e80..5b21fc13 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/device.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/device.go @@ -18,11 +18,12 @@ package device import ( "fmt" + "strings" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" ) -// Device defines the set of extended functions associated with a device.Device +// Device defines the set of extended functions associated with a device.Device. type Device interface { nvml.Device GetArchitectureAsString() (string, error) @@ -30,6 +31,7 @@ type Device interface { GetCudaComputeCapabilityAsString() (string, error) GetMigDevices() ([]MigDevice, error) GetMigProfiles() ([]MigProfile, error) + GetPCIBusID() (string, error) IsMigCapable() (bool, error) IsMigEnabled() (bool, error) VisitMigDevices(func(j int, m MigDevice) error) error @@ -44,26 +46,26 @@ type device struct { var _ Device = &device{} -// NewDevice builds a new Device from an nvml.Device +// NewDevice builds a new Device from an nvml.Device. func (d *devicelib) NewDevice(dev nvml.Device) (Device, error) { return d.newDevice(dev) } -// NewDeviceByUUID builds a new Device from a UUID +// NewDeviceByUUID builds a new Device from a UUID. func (d *devicelib) NewDeviceByUUID(uuid string) (Device, error) { - dev, ret := d.nvml.DeviceGetHandleByUUID(uuid) + dev, ret := d.nvmllib.DeviceGetHandleByUUID(uuid) if ret != nvml.SUCCESS { return nil, fmt.Errorf("error getting device handle for uuid '%v': %v", uuid, ret) } return d.newDevice(dev) } -// newDevice creates a device from an nvml.Device +// newDevice creates a device from an nvml.Device. func (d *devicelib) newDevice(dev nvml.Device) (*device, error) { return &device{dev, d, nil}, nil } -// GetArchitectureAsString returns the Device architecture as a string +// GetArchitectureAsString returns the Device architecture as a string. func (d *device) GetArchitectureAsString() (string, error) { arch, ret := d.GetArchitecture() if ret != nvml.SUCCESS { @@ -92,7 +94,7 @@ func (d *device) GetArchitectureAsString() (string, error) { return "", fmt.Errorf("error interpreting device architecture as string: %v", arch) } -// GetBrandAsString returns the Device architecture as a string +// GetBrandAsString returns the Device architecture as a string. func (d *device) GetBrandAsString() (string, error) { brand, ret := d.GetBrand() if ret != nvml.SUCCESS { @@ -140,7 +142,30 @@ func (d *device) GetBrandAsString() (string, error) { return "", fmt.Errorf("error interpreting device brand as string: %v", brand) } -// GetCudaComputeCapabilityAsString returns the Device's CUDA compute capability as a version string +// GetPCIBusID returns the string representation of the bus ID. +func (d *device) GetPCIBusID() (string, error) { + info, ret := d.GetPciInfo() + if ret != nvml.SUCCESS { + return "", fmt.Errorf("error getting PCI info: %w", ret) + } + + var bytes []byte + for _, b := range info.BusId { + if byte(b) == '\x00' { + break + } + bytes = append(bytes, byte(b)) + } + id := strings.ToLower(string(bytes)) + + if id != "0000" { + id = strings.TrimPrefix(id, "0000") + } + + return id, nil +} + +// GetCudaComputeCapabilityAsString returns the Device's CUDA compute capability as a version string. func (d *device) GetCudaComputeCapabilityAsString() (string, error) { major, minor, ret := d.GetCudaComputeCapability() if ret != nvml.SUCCESS { @@ -149,7 +174,7 @@ func (d *device) GetCudaComputeCapabilityAsString() (string, error) { return fmt.Sprintf("%d.%d", major, minor), nil } -// IsMigCapable checks if a device is capable of having MIG paprtitions created on it +// IsMigCapable checks if a device is capable of having MIG paprtitions created on it. func (d *device) IsMigCapable() (bool, error) { if !d.lib.hasSymbol("nvmlDeviceGetMigMode") { return false, nil @@ -166,7 +191,7 @@ func (d *device) IsMigCapable() (bool, error) { return true, nil } -// IsMigEnabled checks if a device has MIG mode currently enabled on it +// IsMigEnabled checks if a device has MIG mode currently enabled on it. func (d *device) IsMigEnabled() (bool, error) { if !d.lib.hasSymbol("nvmlDeviceGetMigMode") { return false, nil @@ -183,7 +208,7 @@ func (d *device) IsMigEnabled() (bool, error) { return (mode == nvml.DEVICE_MIG_ENABLE), nil } -// VisitMigDevices walks a top-level device and invokes a callback function for each MIG device configured on it +// VisitMigDevices walks a top-level device and invokes a callback function for each MIG device configured on it. func (d *device) VisitMigDevices(visit func(int, MigDevice) error) error { capable, err := d.IsMigCapable() if err != nil { @@ -221,7 +246,7 @@ func (d *device) VisitMigDevices(visit func(int, MigDevice) error) error { return nil } -// VisitMigProfiles walks a top-level device and invokes a callback function for each unique MIG Profile that can be configured on it +// VisitMigProfiles walks a top-level device and invokes a callback function for each unique MIG Profile that can be configured on it. func (d *device) VisitMigProfiles(visit func(MigProfile) error) error { capable, err := d.IsMigCapable() if err != nil { @@ -283,7 +308,7 @@ func (d *device) VisitMigProfiles(visit func(MigProfile) error) error { return nil } -// GetMigDevices gets the set of MIG devices associated with a top-level device +// GetMigDevices gets the set of MIG devices associated with a top-level device. func (d *device) GetMigDevices() ([]MigDevice, error) { var migs []MigDevice err := d.VisitMigDevices(func(j int, m MigDevice) error { @@ -296,7 +321,7 @@ func (d *device) GetMigDevices() ([]MigDevice, error) { return migs, nil } -// GetMigProfiles gets the set of unique MIG profiles associated with a top-level device +// GetMigProfiles gets the set of unique MIG profiles associated with a top-level device. func (d *device) GetMigProfiles() ([]MigProfile, error) { // Return the cached list if available if d.migProfiles != nil { @@ -313,7 +338,7 @@ func (d *device) GetMigProfiles() ([]MigProfile, error) { return nil, err } - // And cache it before returning + // And cache it before returning. d.migProfiles = profiles return profiles, nil } @@ -332,15 +357,15 @@ func (d *device) isSkipped() (bool, error) { return false, nil } -// VisitDevices visits each top-level device and invokes a callback function for it +// VisitDevices visits each top-level device and invokes a callback function for it. func (d *devicelib) VisitDevices(visit func(int, Device) error) error { - count, ret := d.nvml.DeviceGetCount() + count, ret := d.nvmllib.DeviceGetCount() if ret != nvml.SUCCESS { return fmt.Errorf("error getting device count: %v", ret) } for i := 0; i < count; i++ { - device, ret := d.nvml.DeviceGetHandleByIndex(i) + device, ret := d.nvmllib.DeviceGetHandleByIndex(i) if ret != nvml.SUCCESS { return fmt.Errorf("error getting device handle for index '%v': %v", i, ret) } @@ -365,7 +390,7 @@ func (d *devicelib) VisitDevices(visit func(int, Device) error) error { return nil } -// VisitMigDevices walks a top-level device and invokes a callback function for each MIG device configured on it +// VisitMigDevices walks a top-level device and invokes a callback function for each MIG device configured on it. func (d *devicelib) VisitMigDevices(visit func(int, Device, int, MigDevice) error) error { err := d.VisitDevices(func(i int, dev Device) error { err := dev.VisitMigDevices(func(j int, mig MigDevice) error { @@ -386,7 +411,7 @@ func (d *devicelib) VisitMigDevices(visit func(int, Device, int, MigDevice) erro return nil } -// VisitMigProfiles walks a top-level device and invokes a callback function for each unique MIG profile found on them +// VisitMigProfiles walks a top-level device and invokes a callback function for each unique MIG profile found on them. func (d *devicelib) VisitMigProfiles(visit func(MigProfile) error) error { visited := make(map[string]bool) err := d.VisitDevices(func(i int, dev Device) error { @@ -414,7 +439,7 @@ func (d *devicelib) VisitMigProfiles(visit func(MigProfile) error) error { return nil } -// GetDevices gets the set of all top-level devices +// GetDevices gets the set of all top-level devices. func (d *devicelib) GetDevices() ([]Device, error) { var devs []Device err := d.VisitDevices(func(i int, dev Device) error { @@ -427,7 +452,7 @@ func (d *devicelib) GetDevices() ([]Device, error) { return devs, nil } -// GetMigDevices gets the set of MIG devices across all top-level devices +// GetMigDevices gets the set of MIG devices across all top-level devices. func (d *devicelib) GetMigDevices() ([]MigDevice, error) { var migs []MigDevice err := d.VisitMigDevices(func(i int, dev Device, j int, m MigDevice) error { @@ -440,7 +465,7 @@ func (d *devicelib) GetMigDevices() ([]MigDevice, error) { return migs, nil } -// GetMigProfiles gets the set of unique MIG profiles across all top-level devices +// GetMigProfiles gets the set of unique MIG profiles across all top-level devices. func (d *devicelib) GetMigProfiles() ([]MigProfile, error) { // Return the cached list if available if d.migProfiles != nil { @@ -457,7 +482,7 @@ func (d *devicelib) GetMigProfiles() ([]MigProfile, error) { return nil, err } - // And cache it before returning + // And cache it before returning. d.migProfiles = profiles return profiles, nil } @@ -469,5 +494,5 @@ func (d *devicelib) hasSymbol(symbol string) bool { return true } - return d.nvml.Lookup(symbol) == nil + return d.nvmllib.Extensions().LookupSymbol(symbol) == nil } diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/identifier.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/identifier.go index 689de6d4..114e9cd5 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/identifier.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/identifier.go @@ -27,7 +27,7 @@ import ( // This includes a device index or UUID. type Identifier string -// IsGpuIndex checks if an identifier is a full GPU index +// IsGpuIndex checks if an identifier is a full GPU index. func (i Identifier) IsGpuIndex() bool { if _, err := strconv.ParseUint(string(i), 10, 0); err != nil { return false @@ -35,7 +35,7 @@ func (i Identifier) IsGpuIndex() bool { return true } -// IsMigIndex checks if an identifier is a MIG index +// IsMigIndex checks if an identifier is a MIG index. func (i Identifier) IsMigIndex() bool { split := strings.Split(string(i), ":") if len(split) != 2 { @@ -49,13 +49,13 @@ func (i Identifier) IsMigIndex() bool { return true } -// IsUUID checks if an identifier is a UUID +// IsUUID checks if an identifier is a UUID. func (i Identifier) IsUUID() bool { return i.IsGpuUUID() || i.IsMigUUID() } -// IsGpuUUID checks if an identifier is a GPU UUID -// A GPU UUID must be of the form GPU-b1028956-cfa2-0990-bf4a-5da9abb51763 +// IsGpuUUID checks if an identifier is a GPU UUID. +// A GPU UUID must be of the form GPU-b1028956-cfa2-0990-bf4a-5da9abb51763. func (i Identifier) IsGpuUUID() bool { if !strings.HasPrefix(string(i), "GPU-") { return false @@ -64,7 +64,7 @@ func (i Identifier) IsGpuUUID() bool { return err == nil } -// IsMigUUID checks if an identifier is a MIG UUID +// IsMigUUID checks if an identifier is a MIG UUID. // A MIG UUID can be of one of two forms: // - MIG-b1028956-cfa2-0990-bf4a-5da9abb51763 // - MIG-GPU-b1028956-cfa2-0990-bf4a-5da9abb51763/3/0 diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_device.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_device.go index bbe3bb6e..7145a06b 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_device.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_device.go @@ -19,10 +19,10 @@ package device import ( "fmt" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" ) -// MigDevice defines the set of extended functions associated with a MIG device +// MigDevice defines the set of extended functions associated with a MIG device. type MigDevice interface { nvml.Device GetProfile() (MigProfile, error) @@ -36,7 +36,7 @@ type migdevice struct { var _ MigDevice = &migdevice{} -// NewMigDevice builds a new MigDevice from an nvml.Device +// NewMigDevice builds a new MigDevice from an nvml.Device. func (d *devicelib) NewMigDevice(handle nvml.Device) (MigDevice, error) { isMig, ret := handle.IsMigDeviceHandle() if ret != nvml.SUCCESS { @@ -48,16 +48,16 @@ func (d *devicelib) NewMigDevice(handle nvml.Device) (MigDevice, error) { return &migdevice{handle, d, nil}, nil } -// NewMigDeviceByUUID builds a new MigDevice from a UUID +// NewMigDeviceByUUID builds a new MigDevice from a UUID. func (d *devicelib) NewMigDeviceByUUID(uuid string) (MigDevice, error) { - dev, ret := d.nvml.DeviceGetHandleByUUID(uuid) + dev, ret := d.nvmllib.DeviceGetHandleByUUID(uuid) if ret != nvml.SUCCESS { return nil, fmt.Errorf("error getting device handle for uuid '%v': %v", uuid, ret) } return d.NewMigDevice(dev) } -// GetProfile returns the MIG profile associated with a MIG device +// GetProfile returns the MIG profile associated with a MIG device. func (m *migdevice) GetProfile() (MigProfile, error) { if m.profile != nil { return m.profile, nil diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_profile.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_profile.go index 6f27af61..c1f0190f 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_profile.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/device/mig_profile.go @@ -23,7 +23,7 @@ import ( "strconv" "strings" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" ) const ( @@ -40,7 +40,7 @@ type MigProfile interface { Matches(profile string) bool } -// MigProfileInfo holds all info associated with a specific MIG profile +// MigProfileInfo holds all info associated with a specific MIG profile. type MigProfileInfo struct { C int G int @@ -119,13 +119,13 @@ func (d *devicelib) NewMigProfile(giProfileID, ciProfileID, ciEngProfileID int, return p, nil } -// AssertValidMigProfileFormat checks if the string is in the proper format to represent a MIG profile +// AssertValidMigProfileFormat checks if the string is in the proper format to represent a MIG profile. func (d *devicelib) AssertValidMigProfileFormat(profile string) error { _, _, _, _, err := parseMigProfile(profile) return err } -// ParseMigProfile converts a string representation of a MigProfile into an object +// ParseMigProfile converts a string representation of a MigProfile into an object. func (d *devicelib) ParseMigProfile(profile string) (MigProfile, error) { profiles, err := d.GetMigProfiles() if err != nil { @@ -141,7 +141,7 @@ func (d *devicelib) ParseMigProfile(profile string) (MigProfile, error) { return nil, fmt.Errorf("unable to parse profile string into a valid profile") } -// String returns the string representation of a Profile +// String returns the string representation of a Profile. func (p MigProfileInfo) String() string { var suffix string if len(p.Attributes) > 0 { @@ -153,12 +153,12 @@ func (p MigProfileInfo) String() string { return fmt.Sprintf("%dc.%dg.%dgb%s", p.C, p.G, p.GB, suffix) } -// GetInfo returns detailed info about a Profile +// GetInfo returns detailed info about a Profile. func (p MigProfileInfo) GetInfo() MigProfileInfo { return p } -// Equals checks if two Profiles are identical or not +// Equals checks if two Profiles are identical or not. func (p MigProfileInfo) Equals(other MigProfile) bool { o := other.GetInfo() if p.C != o.C { @@ -182,7 +182,7 @@ func (p MigProfileInfo) Equals(other MigProfile) bool { return true } -// Matches checks if a MigProfile matches the string passed in +// Matches checks if a MigProfile matches the string passed in. func (p MigProfileInfo) Matches(profile string) bool { c, g, gb, attrs, err := parseMigProfile(profile) if err != nil { @@ -211,26 +211,26 @@ func (p MigProfileInfo) Matches(profile string) bool { } func parseMigProfile(profile string) (int, int, int, []string, error) { - // If we are handed the empty string, we cannot parse it + // If we are handed the empty string, we cannot parse it. if profile == "" { return -1, -1, -1, nil, fmt.Errorf("profile is the empty string") } - // Split by + to separate out attributes + // Split by + to separate out attributes. split := strings.SplitN(profile, "+", 2) - // Check to make sure the c, g, and gb values match + // Check to make sure the c, g, and gb values match. c, g, gb, err := parseMigProfileFields(split[0]) if err != nil { return -1, -1, -1, nil, fmt.Errorf("cannot parse fields of '%v': %v", profile, err) } - // If we have no attributes we are done + // If we have no attributes we are done. if len(split) == 1 { return c, g, gb, nil, nil } - // Make sure we have the same set of attributes + // Make sure we have the same set of attributes. attrs, err := parseMigProfileAttributes(split[1]) if err != nil { return -1, -1, -1, nil, fmt.Errorf("cannot parse attributes of '%v': %v", profile, err) diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/api.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/api.go new file mode 100644 index 00000000..1c62d636 --- /dev/null +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/api.go @@ -0,0 +1,41 @@ +/** +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package info + +// Interface provides the API to the info package. +type Interface interface { + PlatformResolver + PropertyExtractor +} + +// PlatformResolver defines a function to resolve the current platform. +type PlatformResolver interface { + ResolvePlatform() Platform +} + +// PropertyExtractor provides a set of functions to query capabilities of the +// system. +// +//go:generate moq -rm -out property-extractor_mock.go . PropertyExtractor +type PropertyExtractor interface { + HasDXCore() (bool, string) + HasNvml() (bool, string) + HasTegraFiles() (bool, string) + // Deprecated: Use HasTegraFiles instead. + IsTegraSystem() (bool, string) + UsesOnlyNVGPUModule() (bool, string) +} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/builder.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/builder.go new file mode 100644 index 00000000..61684407 --- /dev/null +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/builder.go @@ -0,0 +1,78 @@ +/** +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package info + +import ( + "github.com/NVIDIA/go-nvml/pkg/nvml" + + "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" +) + +type infolib struct { + PropertyExtractor + PlatformResolver +} + +type options struct { + logger basicLogger + root root + nvmllib nvml.Interface + devicelib device.Interface + + platform Platform + propertyExtractor PropertyExtractor +} + +// New creates a new instance of the 'info' interface. +func New(opts ...Option) Interface { + o := &options{} + for _, opt := range opts { + opt(o) + } + if o.logger == nil { + o.logger = &nullLogger{} + } + if o.root == "" { + o.root = "/" + } + if o.nvmllib == nil { + o.nvmllib = nvml.New( + nvml.WithLibraryPath(o.root.tryResolveLibrary("libnvidia-ml.so.1")), + ) + } + if o.devicelib == nil { + o.devicelib = device.New(o.nvmllib) + } + if o.platform == "" { + o.platform = PlatformAuto + } + if o.propertyExtractor == nil { + o.propertyExtractor = &propertyExtractor{ + root: o.root, + nvmllib: o.nvmllib, + devicelib: o.devicelib, + } + } + return &infolib{ + PlatformResolver: &platformResolver{ + logger: o.logger, + platform: o.platform, + propertyExtractor: o.propertyExtractor, + }, + PropertyExtractor: o.propertyExtractor, + } +} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/info.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/info.go deleted file mode 100644 index 460e852c..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/info.go +++ /dev/null @@ -1,102 +0,0 @@ -/** -# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -**/ - -package info - -import ( - "fmt" - "os" - "path/filepath" - "strings" - - "github.com/NVIDIA/go-nvml/pkg/dl" -) - -// Interface provides the API to the info package -type Interface interface { - HasDXCore() (bool, string) - HasNvml() (bool, string) - IsTegraSystem() (bool, string) -} - -type infolib struct { - root string -} - -var _ Interface = &infolib{} - -// HasDXCore returns true if DXCore is detected on the system. -func (i *infolib) HasDXCore() (bool, string) { - const ( - libraryName = "libdxcore.so" - ) - if err := assertHasLibrary(libraryName); err != nil { - return false, fmt.Sprintf("could not load DXCore library: %v", err) - } - - return true, "found DXCore library" -} - -// HasNvml returns true if NVML is detected on the system -func (i *infolib) HasNvml() (bool, string) { - const ( - libraryName = "libnvidia-ml.so.1" - ) - if err := assertHasLibrary(libraryName); err != nil { - return false, fmt.Sprintf("could not load NVML library: %v", err) - } - - return true, "found NVML library" -} - -// IsTegraSystem returns true if the system is detected as a Tegra-based system -func (i *infolib) IsTegraSystem() (bool, string) { - tegraReleaseFile := filepath.Join(i.root, "/etc/nv_tegra_release") - tegraFamilyFile := filepath.Join(i.root, "/sys/devices/soc0/family") - - if info, err := os.Stat(tegraReleaseFile); err == nil && !info.IsDir() { - return true, fmt.Sprintf("%v found", tegraReleaseFile) - } - - if info, err := os.Stat(tegraFamilyFile); err != nil || info.IsDir() { - return false, fmt.Sprintf("%v file not found", tegraFamilyFile) - } - - contents, err := os.ReadFile(tegraFamilyFile) - if err != nil { - return false, fmt.Sprintf("could not read %v", tegraFamilyFile) - } - - if strings.HasPrefix(strings.ToLower(string(contents)), "tegra") { - return true, fmt.Sprintf("%v has 'tegra' prefix", tegraFamilyFile) - } - - return false, fmt.Sprintf("%v has no 'tegra' prefix", tegraFamilyFile) -} - -// assertHasLibrary returns an error if the specified library cannot be loaded -func assertHasLibrary(libraryName string) error { - const ( - libraryLoadFlags = dl.RTLD_LAZY - ) - lib := dl.New(libraryName, libraryLoadFlags) - if err := lib.Open(); err != nil { - return err - } - defer lib.Close() - - return nil -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/options.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/logger.go similarity index 56% rename from vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/options.go rename to vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/logger.go index d34bb237..6a6f74ee 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/options.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/logger.go @@ -1,5 +1,5 @@ /** -# Copyright 2023 NVIDIA CORPORATION +# Copyright 2024 NVIDIA CORPORATION # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,19 +14,15 @@ # limitations under the License. **/ -package nvml +package info -// options represents the options that could be passed to the nvml contructor. -type options struct { - libraryPath string +type basicLogger interface { + Debugf(string, ...interface{}) + Infof(string, ...interface{}) } -// Option represents a functional option to control behaviour. -type Option func(*options) +type nullLogger struct{} -// WithLibraryPath sets the NVML library name to use. -func WithLibraryPath(libraryPath string) Option { - return func(o *options) { - o.libraryPath = libraryPath - } -} +func (n *nullLogger) Debugf(string, ...interface{}) {} + +func (n *nullLogger) Infof(string, ...interface{}) {} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/options.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/options.go index 314efa67..e05c2bf7 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/options.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/options.go @@ -16,24 +16,55 @@ package info -// Option defines a function for passing options to the New() call -type Option func(*infolib) - -// New creates a new instance of the 'info' interface -func New(opts ...Option) Interface { - i := &infolib{} - for _, opt := range opts { - opt(i) +import ( + "github.com/NVIDIA/go-nvml/pkg/nvml" + + "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" +) + +// Option defines a function for passing options to the New() call. +type Option func(*options) + +// WithDeviceLib sets the device library for the library. +func WithDeviceLib(devicelib device.Interface) Option { + return func(i *options) { + i.devicelib = devicelib + } +} + +// WithLogger sets the logger for the library. +func WithLogger(logger basicLogger) Option { + return func(i *options) { + i.logger = logger + } +} + +// WithNvmlLib sets the nvml library for the library. +func WithNvmlLib(nvmllib nvml.Interface) Option { + return func(i *options) { + i.nvmllib = nvmllib } - if i.root == "" { - i.root = "/" +} + +// WithRoot provides a Option to set the root of the 'info' interface. +func WithRoot(r string) Option { + return func(i *options) { + i.root = root(r) + } +} + +// WithPropertyExtractor provides an Option to set the PropertyExtractor +// interface implementation. +// This is predominantly used for testing. +func WithPropertyExtractor(propertyExtractor PropertyExtractor) Option { + return func(i *options) { + i.propertyExtractor = propertyExtractor } - return i } -// WithRoot provides a Option to set the root of the 'info' interface -func WithRoot(root string) Option { - return func(i *infolib) { - i.root = root +// WithPlatform provides an option to set the platform explicitly. +func WithPlatform(platform Platform) Option { + return func(i *options) { + i.platform = platform } } diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/property-extractor.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/property-extractor.go new file mode 100644 index 00000000..5d5d97cd --- /dev/null +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/property-extractor.go @@ -0,0 +1,143 @@ +/** +# 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 info + +import ( + "fmt" + "os" + "strings" + + "github.com/NVIDIA/go-nvml/pkg/nvml" + + "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" +) + +type propertyExtractor struct { + root root + nvmllib nvml.Interface + devicelib device.Interface +} + +var _ PropertyExtractor = &propertyExtractor{} + +// HasDXCore returns true if DXCore is detected on the system. +func (i *propertyExtractor) HasDXCore() (bool, string) { + const ( + libraryName = "libdxcore.so" + ) + if err := i.root.assertHasLibrary(libraryName); err != nil { + return false, fmt.Sprintf("could not load DXCore library: %v", err) + } + + return true, "found DXCore library" +} + +// HasNvml returns true if NVML is detected on the system. +func (i *propertyExtractor) HasNvml() (bool, string) { + const ( + libraryName = "libnvidia-ml.so.1" + ) + if err := i.root.assertHasLibrary(libraryName); err != nil { + return false, fmt.Sprintf("could not load NVML library: %v", err) + } + + return true, "found NVML library" +} + +// IsTegraSystem returns true if the system is detected as a Tegra-based system. +// Deprecated: Use HasTegraFiles instead. +func (i *propertyExtractor) IsTegraSystem() (bool, string) { + return i.HasTegraFiles() +} + +// HasTegraFiles returns true if tegra-based files are detected on the system. +func (i *propertyExtractor) HasTegraFiles() (bool, string) { + tegraReleaseFile := i.root.join("/etc/nv_tegra_release") + tegraFamilyFile := i.root.join("/sys/devices/soc0/family") + + if info, err := os.Stat(tegraReleaseFile); err == nil && !info.IsDir() { + return true, fmt.Sprintf("%v found", tegraReleaseFile) + } + + if info, err := os.Stat(tegraFamilyFile); err != nil || info.IsDir() { + return false, fmt.Sprintf("%v file not found", tegraFamilyFile) + } + + contents, err := os.ReadFile(tegraFamilyFile) + if err != nil { + return false, fmt.Sprintf("could not read %v", tegraFamilyFile) + } + + if strings.HasPrefix(strings.ToLower(string(contents)), "tegra") { + return true, fmt.Sprintf("%v has 'tegra' prefix", tegraFamilyFile) + } + + return false, fmt.Sprintf("%v has no 'tegra' prefix", tegraFamilyFile) +} + +// UsesOnlyNVGPUModule checks whether the only the nvgpu module is used. +// This kernel module is used on Tegra-based systems when using the iGPU. +// Since some of these systems also support NVML, we use the device name +// reported by NVML to determine whether the system is an iGPU system. +// +// Devices that use the nvgpu module have their device names as: +// +// GPU 0: Orin (nvgpu) (UUID: 54d0709b-558d-5a59-9c65-0c5fc14a21a4) +// +// This function returns true if ALL devices use the nvgpu module. +func (i *propertyExtractor) UsesOnlyNVGPUModule() (uses bool, reason string) { + // We ensure that this function never panics + defer func() { + if err := recover(); err != nil { + uses = false + reason = fmt.Sprintf("panic: %v", err) + } + }() + + ret := i.nvmllib.Init() + if ret != nvml.SUCCESS { + return false, fmt.Sprintf("failed to initialize nvml: %v", ret) + } + defer func() { + _ = i.nvmllib.Shutdown() + }() + + var names []string + + err := i.devicelib.VisitDevices(func(i int, d device.Device) error { + name, ret := d.GetName() + if ret != nvml.SUCCESS { + return fmt.Errorf("device %v: %v", i, ret) + } + names = append(names, name) + return nil + }) + if err != nil { + return false, fmt.Sprintf("failed to get device names: %v", err) + } + + if len(names) == 0 { + return false, "no devices found" + } + + for _, name := range names { + if !strings.Contains(name, "(nvgpu)") { + return false, fmt.Sprintf("device %q does not use nvgpu module", name) + } + } + return true, "all devices use nvgpu module" +} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/property-extractor_mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/property-extractor_mock.go new file mode 100644 index 00000000..f2b057e6 --- /dev/null +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/property-extractor_mock.go @@ -0,0 +1,215 @@ +// Code generated by moq; DO NOT EDIT. +// github.com/matryer/moq + +package info + +import ( + "sync" +) + +// Ensure, that PropertyExtractorMock does implement PropertyExtractor. +// If this is not the case, regenerate this file with moq. +var _ PropertyExtractor = &PropertyExtractorMock{} + +// PropertyExtractorMock is a mock implementation of PropertyExtractor. +// +// func TestSomethingThatUsesPropertyExtractor(t *testing.T) { +// +// // make and configure a mocked PropertyExtractor +// mockedPropertyExtractor := &PropertyExtractorMock{ +// HasDXCoreFunc: func() (bool, string) { +// panic("mock out the HasDXCore method") +// }, +// HasNvmlFunc: func() (bool, string) { +// panic("mock out the HasNvml method") +// }, +// HasTegraFilesFunc: func() (bool, string) { +// panic("mock out the HasTegraFiles method") +// }, +// IsTegraSystemFunc: func() (bool, string) { +// panic("mock out the IsTegraSystem method") +// }, +// UsesOnlyNVGPUModuleFunc: func() (bool, string) { +// panic("mock out the UsesOnlyNVGPUModule method") +// }, +// } +// +// // use mockedPropertyExtractor in code that requires PropertyExtractor +// // and then make assertions. +// +// } +type PropertyExtractorMock struct { + // HasDXCoreFunc mocks the HasDXCore method. + HasDXCoreFunc func() (bool, string) + + // HasNvmlFunc mocks the HasNvml method. + HasNvmlFunc func() (bool, string) + + // HasTegraFilesFunc mocks the HasTegraFiles method. + HasTegraFilesFunc func() (bool, string) + + // IsTegraSystemFunc mocks the IsTegraSystem method. + IsTegraSystemFunc func() (bool, string) + + // UsesOnlyNVGPUModuleFunc mocks the UsesOnlyNVGPUModule method. + UsesOnlyNVGPUModuleFunc func() (bool, string) + + // calls tracks calls to the methods. + calls struct { + // HasDXCore holds details about calls to the HasDXCore method. + HasDXCore []struct { + } + // HasNvml holds details about calls to the HasNvml method. + HasNvml []struct { + } + // HasTegraFiles holds details about calls to the HasTegraFiles method. + HasTegraFiles []struct { + } + // IsTegraSystem holds details about calls to the IsTegraSystem method. + IsTegraSystem []struct { + } + // UsesOnlyNVGPUModule holds details about calls to the UsesOnlyNVGPUModule method. + UsesOnlyNVGPUModule []struct { + } + } + lockHasDXCore sync.RWMutex + lockHasNvml sync.RWMutex + lockHasTegraFiles sync.RWMutex + lockIsTegraSystem sync.RWMutex + lockUsesOnlyNVGPUModule sync.RWMutex +} + +// HasDXCore calls HasDXCoreFunc. +func (mock *PropertyExtractorMock) HasDXCore() (bool, string) { + if mock.HasDXCoreFunc == nil { + panic("PropertyExtractorMock.HasDXCoreFunc: method is nil but PropertyExtractor.HasDXCore was just called") + } + callInfo := struct { + }{} + mock.lockHasDXCore.Lock() + mock.calls.HasDXCore = append(mock.calls.HasDXCore, callInfo) + mock.lockHasDXCore.Unlock() + return mock.HasDXCoreFunc() +} + +// HasDXCoreCalls gets all the calls that were made to HasDXCore. +// Check the length with: +// +// len(mockedPropertyExtractor.HasDXCoreCalls()) +func (mock *PropertyExtractorMock) HasDXCoreCalls() []struct { +} { + var calls []struct { + } + mock.lockHasDXCore.RLock() + calls = mock.calls.HasDXCore + mock.lockHasDXCore.RUnlock() + return calls +} + +// HasNvml calls HasNvmlFunc. +func (mock *PropertyExtractorMock) HasNvml() (bool, string) { + if mock.HasNvmlFunc == nil { + panic("PropertyExtractorMock.HasNvmlFunc: method is nil but PropertyExtractor.HasNvml was just called") + } + callInfo := struct { + }{} + mock.lockHasNvml.Lock() + mock.calls.HasNvml = append(mock.calls.HasNvml, callInfo) + mock.lockHasNvml.Unlock() + return mock.HasNvmlFunc() +} + +// HasNvmlCalls gets all the calls that were made to HasNvml. +// Check the length with: +// +// len(mockedPropertyExtractor.HasNvmlCalls()) +func (mock *PropertyExtractorMock) HasNvmlCalls() []struct { +} { + var calls []struct { + } + mock.lockHasNvml.RLock() + calls = mock.calls.HasNvml + mock.lockHasNvml.RUnlock() + return calls +} + +// HasTegraFiles calls HasTegraFilesFunc. +func (mock *PropertyExtractorMock) HasTegraFiles() (bool, string) { + if mock.HasTegraFilesFunc == nil { + panic("PropertyExtractorMock.HasTegraFilesFunc: method is nil but PropertyExtractor.HasTegraFiles was just called") + } + callInfo := struct { + }{} + mock.lockHasTegraFiles.Lock() + mock.calls.HasTegraFiles = append(mock.calls.HasTegraFiles, callInfo) + mock.lockHasTegraFiles.Unlock() + return mock.HasTegraFilesFunc() +} + +// HasTegraFilesCalls gets all the calls that were made to HasTegraFiles. +// Check the length with: +// +// len(mockedPropertyExtractor.HasTegraFilesCalls()) +func (mock *PropertyExtractorMock) HasTegraFilesCalls() []struct { +} { + var calls []struct { + } + mock.lockHasTegraFiles.RLock() + calls = mock.calls.HasTegraFiles + mock.lockHasTegraFiles.RUnlock() + return calls +} + +// IsTegraSystem calls IsTegraSystemFunc. +func (mock *PropertyExtractorMock) IsTegraSystem() (bool, string) { + if mock.IsTegraSystemFunc == nil { + panic("PropertyExtractorMock.IsTegraSystemFunc: method is nil but PropertyExtractor.IsTegraSystem was just called") + } + callInfo := struct { + }{} + mock.lockIsTegraSystem.Lock() + mock.calls.IsTegraSystem = append(mock.calls.IsTegraSystem, callInfo) + mock.lockIsTegraSystem.Unlock() + return mock.IsTegraSystemFunc() +} + +// IsTegraSystemCalls gets all the calls that were made to IsTegraSystem. +// Check the length with: +// +// len(mockedPropertyExtractor.IsTegraSystemCalls()) +func (mock *PropertyExtractorMock) IsTegraSystemCalls() []struct { +} { + var calls []struct { + } + mock.lockIsTegraSystem.RLock() + calls = mock.calls.IsTegraSystem + mock.lockIsTegraSystem.RUnlock() + return calls +} + +// UsesOnlyNVGPUModule calls UsesOnlyNVGPUModuleFunc. +func (mock *PropertyExtractorMock) UsesOnlyNVGPUModule() (bool, string) { + if mock.UsesOnlyNVGPUModuleFunc == nil { + panic("PropertyExtractorMock.UsesOnlyNVGPUModuleFunc: method is nil but PropertyExtractor.UsesOnlyNVGPUModule was just called") + } + callInfo := struct { + }{} + mock.lockUsesOnlyNVGPUModule.Lock() + mock.calls.UsesOnlyNVGPUModule = append(mock.calls.UsesOnlyNVGPUModule, callInfo) + mock.lockUsesOnlyNVGPUModule.Unlock() + return mock.UsesOnlyNVGPUModuleFunc() +} + +// UsesOnlyNVGPUModuleCalls gets all the calls that were made to UsesOnlyNVGPUModule. +// Check the length with: +// +// len(mockedPropertyExtractor.UsesOnlyNVGPUModuleCalls()) +func (mock *PropertyExtractorMock) UsesOnlyNVGPUModuleCalls() []struct { +} { + var calls []struct { + } + mock.lockUsesOnlyNVGPUModule.RLock() + calls = mock.calls.UsesOnlyNVGPUModule + mock.lockUsesOnlyNVGPUModule.RUnlock() + return calls +} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/resolver.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/resolver.go new file mode 100644 index 00000000..1aeb04c0 --- /dev/null +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/resolver.go @@ -0,0 +1,64 @@ +/** +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package info + +// Platform represents a supported plaform. +type Platform string + +const ( + PlatformAuto = Platform("auto") + PlatformNVML = Platform("nvml") + PlatformTegra = Platform("tegra") + PlatformWSL = Platform("wsl") + PlatformUnknown = Platform("unknown") +) + +type platformResolver struct { + logger basicLogger + platform Platform + propertyExtractor PropertyExtractor +} + +func (p platformResolver) ResolvePlatform() Platform { + if p.platform != PlatformAuto { + p.logger.Infof("Using requested platform '%s'", p.platform) + return p.platform + } + + hasDXCore, reason := p.propertyExtractor.HasDXCore() + p.logger.Debugf("Is WSL-based system? %v: %v", hasDXCore, reason) + + hasTegraFiles, reason := p.propertyExtractor.HasTegraFiles() + p.logger.Debugf("Is Tegra-based system? %v: %v", hasTegraFiles, reason) + + hasNVML, reason := p.propertyExtractor.HasNvml() + p.logger.Debugf("Is NVML-based system? %v: %v", hasNVML, reason) + + usesOnlyNVGPUModule, reason := p.propertyExtractor.UsesOnlyNVGPUModule() + p.logger.Debugf("Uses nvgpu kernel module? %v: %v", usesOnlyNVGPUModule, reason) + + switch { + case hasDXCore: + return PlatformWSL + case (hasTegraFiles && !hasNVML), usesOnlyNVGPUModule: + return PlatformTegra + case hasNVML: + return PlatformNVML + default: + return PlatformUnknown + } +} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/root.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/root.go new file mode 100644 index 00000000..d38dc735 --- /dev/null +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvlib/info/root.go @@ -0,0 +1,86 @@ +/** +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package info + +import ( + "fmt" + "path/filepath" + + "github.com/NVIDIA/go-nvml/pkg/dl" +) + +// root represents a directory on the filesystem relative to which libraries +// such as the NVIDIA driver libraries can be found. +type root string + +func (r root) join(parts ...string) string { + return filepath.Join(append([]string{string(r)}, parts...)...) +} + +// assertHasLibrary returns an error if the specified library cannot be loaded. +func (r root) assertHasLibrary(libraryName string) error { + const ( + libraryLoadFlags = dl.RTLD_LAZY + ) + lib := dl.New(r.tryResolveLibrary(libraryName), libraryLoadFlags) + if err := lib.Open(); err != nil { + return err + } + defer lib.Close() + + return nil +} + +// tryResolveLibrary attempts to locate the specified library in the root. +// If the root is not specified, is "/", or the library cannot be found in the +// set of predefined paths, the input is returned as is. +func (r root) tryResolveLibrary(libraryName string) string { + if r == "" || r == "/" { + return libraryName + } + + librarySearchPaths := []string{ + "/usr/lib64", + "/usr/lib/x86_64-linux-gnu", + "/usr/lib/aarch64-linux-gnu", + "/lib64", + "/lib/x86_64-linux-gnu", + "/lib/aarch64-linux-gnu", + } + + for _, d := range librarySearchPaths { + l := r.join(d, libraryName) + resolved, err := resolveLink(l) + if err != nil { + continue + } + return resolved + } + + return libraryName +} + +// resolveLink finds the target of a symlink or the file itself in the +// case of a regular file. +// This is equivalent to running `readlink -f ${l}`. +func resolveLink(l string) (string, error) { + resolved, err := filepath.EvalSymlinks(l) + if err != nil { + return "", fmt.Errorf("error resolving link '%v': %w", l, err) + } + return resolved, nil +} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci.go deleted file mode 100644 index 6a9d798b..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -type nvmlComputeInstance nvml.ComputeInstance - -var _ ComputeInstance = (*nvmlComputeInstance)(nil) - -// GetInfo() returns info about a Compute Instance -func (ci nvmlComputeInstance) GetInfo() (ComputeInstanceInfo, Return) { - i, r := nvml.ComputeInstance(ci).GetInfo() - info := ComputeInstanceInfo{ - Device: nvmlDevice(i.Device), - GpuInstance: nvmlGpuInstance(i.GpuInstance), - Id: i.Id, - ProfileId: i.ProfileId, - Placement: ComputeInstancePlacement(i.Placement), - } - return info, Return(r) -} - -// Destroy() destroys a Compute Instance -func (ci nvmlComputeInstance) Destroy() Return { - r := nvml.ComputeInstance(ci).Destroy() - return Return(r) -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci_mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci_mock.go deleted file mode 100644 index e4e75a7a..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/ci_mock.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq - -package nvml - -import ( - "sync" -) - -// Ensure, that ComputeInstanceMock does implement ComputeInstance. -// If this is not the case, regenerate this file with moq. -var _ ComputeInstance = &ComputeInstanceMock{} - -// ComputeInstanceMock is a mock implementation of ComputeInstance. -// -// func TestSomethingThatUsesComputeInstance(t *testing.T) { -// -// // make and configure a mocked ComputeInstance -// mockedComputeInstance := &ComputeInstanceMock{ -// DestroyFunc: func() Return { -// panic("mock out the Destroy method") -// }, -// GetInfoFunc: func() (ComputeInstanceInfo, Return) { -// panic("mock out the GetInfo method") -// }, -// } -// -// // use mockedComputeInstance in code that requires ComputeInstance -// // and then make assertions. -// -// } -type ComputeInstanceMock struct { - // DestroyFunc mocks the Destroy method. - DestroyFunc func() Return - - // GetInfoFunc mocks the GetInfo method. - GetInfoFunc func() (ComputeInstanceInfo, Return) - - // calls tracks calls to the methods. - calls struct { - // Destroy holds details about calls to the Destroy method. - Destroy []struct { - } - // GetInfo holds details about calls to the GetInfo method. - GetInfo []struct { - } - } - lockDestroy sync.RWMutex - lockGetInfo sync.RWMutex -} - -// Destroy calls DestroyFunc. -func (mock *ComputeInstanceMock) Destroy() Return { - if mock.DestroyFunc == nil { - panic("ComputeInstanceMock.DestroyFunc: method is nil but ComputeInstance.Destroy was just called") - } - callInfo := struct { - }{} - mock.lockDestroy.Lock() - mock.calls.Destroy = append(mock.calls.Destroy, callInfo) - mock.lockDestroy.Unlock() - return mock.DestroyFunc() -} - -// DestroyCalls gets all the calls that were made to Destroy. -// Check the length with: -// -// len(mockedComputeInstance.DestroyCalls()) -func (mock *ComputeInstanceMock) DestroyCalls() []struct { -} { - var calls []struct { - } - mock.lockDestroy.RLock() - calls = mock.calls.Destroy - mock.lockDestroy.RUnlock() - return calls -} - -// GetInfo calls GetInfoFunc. -func (mock *ComputeInstanceMock) GetInfo() (ComputeInstanceInfo, Return) { - if mock.GetInfoFunc == nil { - panic("ComputeInstanceMock.GetInfoFunc: method is nil but ComputeInstance.GetInfo was just called") - } - callInfo := struct { - }{} - mock.lockGetInfo.Lock() - mock.calls.GetInfo = append(mock.calls.GetInfo, callInfo) - mock.lockGetInfo.Unlock() - return mock.GetInfoFunc() -} - -// GetInfoCalls gets all the calls that were made to GetInfo. -// Check the length with: -// -// len(mockedComputeInstance.GetInfoCalls()) -func (mock *ComputeInstanceMock) GetInfoCalls() []struct { -} { - var calls []struct { - } - mock.lockGetInfo.RLock() - calls = mock.calls.GetInfo - mock.lockGetInfo.RUnlock() - return calls -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go deleted file mode 100644 index cba00b98..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/consts.go +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -// General untyped constants -const ( - NVLINK_MAX_LINKS = nvml.NVLINK_MAX_LINKS -) - -// Return constants -const ( - SUCCESS = Return(nvml.SUCCESS) - ERROR_UNINITIALIZED = Return(nvml.ERROR_UNINITIALIZED) - ERROR_INVALID_ARGUMENT = Return(nvml.ERROR_INVALID_ARGUMENT) - ERROR_NOT_SUPPORTED = Return(nvml.ERROR_NOT_SUPPORTED) - ERROR_NO_PERMISSION = Return(nvml.ERROR_NO_PERMISSION) - ERROR_ALREADY_INITIALIZED = Return(nvml.ERROR_ALREADY_INITIALIZED) - ERROR_NOT_FOUND = Return(nvml.ERROR_NOT_FOUND) - ERROR_INSUFFICIENT_SIZE = Return(nvml.ERROR_INSUFFICIENT_SIZE) - ERROR_INSUFFICIENT_POWER = Return(nvml.ERROR_INSUFFICIENT_POWER) - ERROR_DRIVER_NOT_LOADED = Return(nvml.ERROR_DRIVER_NOT_LOADED) - ERROR_TIMEOUT = Return(nvml.ERROR_TIMEOUT) - ERROR_IRQ_ISSUE = Return(nvml.ERROR_IRQ_ISSUE) - ERROR_LIBRARY_NOT_FOUND = Return(nvml.ERROR_LIBRARY_NOT_FOUND) - ERROR_FUNCTION_NOT_FOUND = Return(nvml.ERROR_FUNCTION_NOT_FOUND) - ERROR_CORRUPTED_INFOROM = Return(nvml.ERROR_CORRUPTED_INFOROM) - ERROR_GPU_IS_LOST = Return(nvml.ERROR_GPU_IS_LOST) - ERROR_RESET_REQUIRED = Return(nvml.ERROR_RESET_REQUIRED) - ERROR_OPERATING_SYSTEM = Return(nvml.ERROR_OPERATING_SYSTEM) - ERROR_LIB_RM_VERSION_MISMATCH = Return(nvml.ERROR_LIB_RM_VERSION_MISMATCH) - ERROR_IN_USE = Return(nvml.ERROR_IN_USE) - ERROR_MEMORY = Return(nvml.ERROR_MEMORY) - ERROR_NO_DATA = Return(nvml.ERROR_NO_DATA) - ERROR_VGPU_ECC_NOT_SUPPORTED = Return(nvml.ERROR_VGPU_ECC_NOT_SUPPORTED) - ERROR_INSUFFICIENT_RESOURCES = Return(nvml.ERROR_INSUFFICIENT_RESOURCES) - ERROR_UNKNOWN = Return(nvml.ERROR_UNKNOWN) -) - -// Device architecture constants -const ( - DEVICE_ARCH_KEPLER = nvml.DEVICE_ARCH_KEPLER - DEVICE_ARCH_MAXWELL = nvml.DEVICE_ARCH_MAXWELL - DEVICE_ARCH_PASCAL = nvml.DEVICE_ARCH_PASCAL - DEVICE_ARCH_VOLTA = nvml.DEVICE_ARCH_VOLTA - DEVICE_ARCH_TURING = nvml.DEVICE_ARCH_TURING - DEVICE_ARCH_AMPERE = nvml.DEVICE_ARCH_AMPERE - DEVICE_ARCH_ADA = nvml.DEVICE_ARCH_ADA - DEVICE_ARCH_HOPPER = nvml.DEVICE_ARCH_HOPPER - DEVICE_ARCH_UNKNOWN = nvml.DEVICE_ARCH_UNKNOWN -) - -// Device brand constants -const ( - BRAND_UNKNOWN = BrandType(nvml.BRAND_UNKNOWN) - BRAND_QUADRO = BrandType(nvml.BRAND_QUADRO) - BRAND_TESLA = BrandType(nvml.BRAND_TESLA) - BRAND_NVS = BrandType(nvml.BRAND_NVS) - BRAND_GRID = BrandType(nvml.BRAND_GRID) - BRAND_GEFORCE = BrandType(nvml.BRAND_GEFORCE) - BRAND_TITAN = BrandType(nvml.BRAND_TITAN) - BRAND_NVIDIA_VAPPS = BrandType(nvml.BRAND_NVIDIA_VAPPS) - BRAND_NVIDIA_VPC = BrandType(nvml.BRAND_NVIDIA_VPC) - BRAND_NVIDIA_VCS = BrandType(nvml.BRAND_NVIDIA_VCS) - BRAND_NVIDIA_VWS = BrandType(nvml.BRAND_NVIDIA_VWS) - BRAND_NVIDIA_CLOUD_GAMING = BrandType(nvml.BRAND_NVIDIA_CLOUD_GAMING) - BRAND_NVIDIA_VGAMING = BrandType(nvml.BRAND_NVIDIA_VGAMING) - BRAND_QUADRO_RTX = BrandType(nvml.BRAND_QUADRO_RTX) - BRAND_NVIDIA_RTX = BrandType(nvml.BRAND_NVIDIA_RTX) - BRAND_NVIDIA = BrandType(nvml.BRAND_NVIDIA) - BRAND_GEFORCE_RTX = BrandType(nvml.BRAND_GEFORCE_RTX) - BRAND_TITAN_RTX = BrandType(nvml.BRAND_TITAN_RTX) - BRAND_COUNT = BrandType(nvml.BRAND_COUNT) -) - -// MIG Mode constants -const ( - DEVICE_MIG_ENABLE = nvml.DEVICE_MIG_ENABLE - DEVICE_MIG_DISABLE = nvml.DEVICE_MIG_DISABLE -) - -// GPU Instance Profiles -const ( - GPU_INSTANCE_PROFILE_1_SLICE = nvml.GPU_INSTANCE_PROFILE_1_SLICE - GPU_INSTANCE_PROFILE_2_SLICE = nvml.GPU_INSTANCE_PROFILE_2_SLICE - GPU_INSTANCE_PROFILE_3_SLICE = nvml.GPU_INSTANCE_PROFILE_3_SLICE - GPU_INSTANCE_PROFILE_4_SLICE = nvml.GPU_INSTANCE_PROFILE_4_SLICE - GPU_INSTANCE_PROFILE_6_SLICE = nvml.GPU_INSTANCE_PROFILE_6_SLICE - GPU_INSTANCE_PROFILE_7_SLICE = nvml.GPU_INSTANCE_PROFILE_7_SLICE - GPU_INSTANCE_PROFILE_8_SLICE = nvml.GPU_INSTANCE_PROFILE_8_SLICE - GPU_INSTANCE_PROFILE_1_SLICE_REV1 = nvml.GPU_INSTANCE_PROFILE_1_SLICE_REV1 - GPU_INSTANCE_PROFILE_1_SLICE_REV2 = nvml.GPU_INSTANCE_PROFILE_1_SLICE_REV2 - GPU_INSTANCE_PROFILE_2_SLICE_REV1 = nvml.GPU_INSTANCE_PROFILE_2_SLICE_REV1 - GPU_INSTANCE_PROFILE_COUNT = nvml.GPU_INSTANCE_PROFILE_COUNT -) - -// Compute Instance Profiles -const ( - COMPUTE_INSTANCE_PROFILE_1_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_1_SLICE - COMPUTE_INSTANCE_PROFILE_2_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_2_SLICE - COMPUTE_INSTANCE_PROFILE_3_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_3_SLICE - COMPUTE_INSTANCE_PROFILE_4_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_4_SLICE - COMPUTE_INSTANCE_PROFILE_6_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_6_SLICE - COMPUTE_INSTANCE_PROFILE_7_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_7_SLICE - COMPUTE_INSTANCE_PROFILE_8_SLICE = nvml.COMPUTE_INSTANCE_PROFILE_8_SLICE - COMPUTE_INSTANCE_PROFILE_1_SLICE_REV1 = nvml.COMPUTE_INSTANCE_PROFILE_1_SLICE_REV1 - COMPUTE_INSTANCE_PROFILE_COUNT = nvml.COMPUTE_INSTANCE_PROFILE_COUNT -) - -// Compute Instance Engine Profiles -const ( - COMPUTE_INSTANCE_ENGINE_PROFILE_SHARED = nvml.COMPUTE_INSTANCE_ENGINE_PROFILE_SHARED - COMPUTE_INSTANCE_ENGINE_PROFILE_COUNT = nvml.COMPUTE_INSTANCE_ENGINE_PROFILE_COUNT -) - -// Event Types -const ( - EventTypeXidCriticalError = nvml.EventTypeXidCriticalError - EventTypeSingleBitEccError = nvml.EventTypeSingleBitEccError - EventTypeDoubleBitEccError = nvml.EventTypeDoubleBitEccError -) - -// GPU Topology enumeration -const ( - TOPOLOGY_INTERNAL = GpuTopologyLevel(nvml.TOPOLOGY_INTERNAL) - TOPOLOGY_SINGLE = GpuTopologyLevel(nvml.TOPOLOGY_SINGLE) - TOPOLOGY_MULTIPLE = GpuTopologyLevel(nvml.TOPOLOGY_MULTIPLE) - TOPOLOGY_HOSTBRIDGE = GpuTopologyLevel(nvml.TOPOLOGY_HOSTBRIDGE) - TOPOLOGY_NODE = GpuTopologyLevel(nvml.TOPOLOGY_NODE) - TOPOLOGY_SYSTEM = GpuTopologyLevel(nvml.TOPOLOGY_SYSTEM) -) - -// Generic enable/disable constants -const ( - FEATURE_DISABLED = EnableState(nvml.FEATURE_DISABLED) - FEATURE_ENABLED = EnableState(nvml.FEATURE_ENABLED) -) - -// Compute mode constants -const ( - COMPUTEMODE_DEFAULT = ComputeMode(nvml.COMPUTEMODE_DEFAULT) - COMPUTEMODE_EXCLUSIVE_THREAD = ComputeMode(nvml.COMPUTEMODE_EXCLUSIVE_THREAD) - COMPUTEMODE_PROHIBITED = ComputeMode(nvml.COMPUTEMODE_PROHIBITED) - COMPUTEMODE_EXCLUSIVE_PROCESS = ComputeMode(nvml.COMPUTEMODE_EXCLUSIVE_PROCESS) - COMPUTEMODE_COUNT = ComputeMode(nvml.COMPUTEMODE_COUNT) -) diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go deleted file mode 100644 index 777a9daa..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device.go +++ /dev/null @@ -1,215 +0,0 @@ -/** -# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -**/ - -package nvml - -import "github.com/NVIDIA/go-nvml/pkg/nvml" - -type nvmlDevice nvml.Device - -var _ Device = (*nvmlDevice)(nil) - -// nvmlDeviceHandle returns a pointer to the underlying device. -func (d nvmlDevice) nvmlDeviceHandle() *nvml.Device { - return (*nvml.Device)(&d) -} - -// GetIndex returns the index of a Device -func (d nvmlDevice) GetIndex() (int, Return) { - i, r := nvml.Device(d).GetIndex() - return i, Return(r) -} - -// GetPciInfo returns the PCI info of a Device -func (d nvmlDevice) GetPciInfo() (PciInfo, Return) { - p, r := nvml.Device(d).GetPciInfo() - return PciInfo(p), Return(r) -} - -// GetMemoryInfo returns the memory info of a Device -func (d nvmlDevice) GetMemoryInfo() (Memory, Return) { - p, r := nvml.Device(d).GetMemoryInfo() - return Memory(p), Return(r) -} - -// GetUUID returns the UUID of a Device -func (d nvmlDevice) GetUUID() (string, Return) { - u, r := nvml.Device(d).GetUUID() - return u, Return(r) -} - -// GetMinorNumber returns the minor number of a Device -func (d nvmlDevice) GetMinorNumber() (int, Return) { - m, r := nvml.Device(d).GetMinorNumber() - return m, Return(r) -} - -// IsMigDeviceHandle returns whether a Device is a MIG device or not -func (d nvmlDevice) IsMigDeviceHandle() (bool, Return) { - b, r := nvml.Device(d).IsMigDeviceHandle() - return b, Return(r) -} - -// GetDeviceHandleFromMigDeviceHandle returns the parent Device of a MIG device -func (d nvmlDevice) GetDeviceHandleFromMigDeviceHandle() (Device, Return) { - p, r := nvml.Device(d).GetDeviceHandleFromMigDeviceHandle() - return nvmlDevice(p), Return(r) -} - -// SetMigMode sets the MIG mode of a Device -func (d nvmlDevice) SetMigMode(mode int) (Return, Return) { - r1, r2 := nvml.Device(d).SetMigMode(mode) - return Return(r1), Return(r2) -} - -// GetMigMode returns the MIG mode of a Device -func (d nvmlDevice) GetMigMode() (int, int, Return) { - s1, s2, r := nvml.Device(d).GetMigMode() - return s1, s2, Return(r) -} - -// GetGpuInstanceById returns the GPU Instance associated with a particular ID -func (d nvmlDevice) GetGpuInstanceById(id int) (GpuInstance, Return) { - gi, r := nvml.Device(d).GetGpuInstanceById(id) - return nvmlGpuInstance(gi), Return(r) -} - -// GetGpuInstanceProfileInfo returns the profile info of a GPU Instance -func (d nvmlDevice) GetGpuInstanceProfileInfo(profile int) (GpuInstanceProfileInfo, Return) { - p, r := nvml.Device(d).GetGpuInstanceProfileInfo(profile) - return GpuInstanceProfileInfo(p), Return(r) -} - -// GetGpuInstancePossiblePlacements returns the possible placements of a GPU Instance -func (d nvmlDevice) GetGpuInstancePossiblePlacements(info *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) { - nvmlPlacements, r := nvml.Device(d).GetGpuInstancePossiblePlacements((*nvml.GpuInstanceProfileInfo)(info)) - var placements []GpuInstancePlacement - for _, p := range nvmlPlacements { - placements = append(placements, GpuInstancePlacement(p)) - } - return placements, Return(r) -} - -// GetGpuInstances returns the set of GPU Instances associated with a Device -func (d nvmlDevice) GetGpuInstances(info *GpuInstanceProfileInfo) ([]GpuInstance, Return) { - nvmlGis, r := nvml.Device(d).GetGpuInstances((*nvml.GpuInstanceProfileInfo)(info)) - var gis []GpuInstance - for _, gi := range nvmlGis { - gis = append(gis, nvmlGpuInstance(gi)) - } - return gis, Return(r) -} - -// CreateGpuInstanceWithPlacement creates a GPU Instance with a specific placement -func (d nvmlDevice) CreateGpuInstanceWithPlacement(info *GpuInstanceProfileInfo, placement *GpuInstancePlacement) (GpuInstance, Return) { - gi, r := nvml.Device(d).CreateGpuInstanceWithPlacement((*nvml.GpuInstanceProfileInfo)(info), (*nvml.GpuInstancePlacement)(placement)) - return nvmlGpuInstance(gi), Return(r) -} - -// GetMaxMigDeviceCount returns the maximum number of MIG devices that can be created on a Device -func (d nvmlDevice) GetMaxMigDeviceCount() (int, Return) { - m, r := nvml.Device(d).GetMaxMigDeviceCount() - return m, Return(r) -} - -// GetMigDeviceHandleByIndex returns the handle to a MIG device given its index -func (d nvmlDevice) GetMigDeviceHandleByIndex(Index int) (Device, Return) { - h, r := nvml.Device(d).GetMigDeviceHandleByIndex(Index) - return nvmlDevice(h), Return(r) -} - -// GetGpuInstanceId returns the GPU Instance ID of a MIG device -func (d nvmlDevice) GetGpuInstanceId() (int, Return) { - gi, r := nvml.Device(d).GetGpuInstanceId() - return gi, Return(r) -} - -// GetComputeInstanceId returns the Compute Instance ID of a MIG device -func (d nvmlDevice) GetComputeInstanceId() (int, Return) { - ci, r := nvml.Device(d).GetComputeInstanceId() - return ci, Return(r) -} - -// GetCudaComputeCapability returns the compute capability major and minor versions for a device -func (d nvmlDevice) GetCudaComputeCapability() (int, int, Return) { - major, minor, r := nvml.Device(d).GetCudaComputeCapability() - return major, minor, Return(r) -} - -// GetAttributes returns the device attributes for a MIG device -func (d nvmlDevice) GetAttributes() (DeviceAttributes, Return) { - a, r := nvml.Device(d).GetAttributes() - return DeviceAttributes(a), Return(r) -} - -// GetName returns the product name of a Device -func (d nvmlDevice) GetName() (string, Return) { - n, r := nvml.Device(d).GetName() - return n, Return(r) -} - -// GetBrand returns the brand of a Device -func (d nvmlDevice) GetBrand() (BrandType, Return) { - b, r := nvml.Device(d).GetBrand() - return BrandType(b), Return(r) -} - -// GetArchitecture returns the architecture of a Device -func (d nvmlDevice) GetArchitecture() (DeviceArchitecture, Return) { - a, r := nvml.Device(d).GetArchitecture() - return DeviceArchitecture(a), Return(r) -} - -// RegisterEvents registers the specified event set and type with the device -func (d nvmlDevice) RegisterEvents(EventTypes uint64, Set EventSet) Return { - return Return(nvml.Device(d).RegisterEvents(EventTypes, nvml.EventSet(Set))) -} - -// GetSupportedEventTypes returns the events supported by the device -func (d nvmlDevice) GetSupportedEventTypes() (uint64, Return) { - e, r := nvml.Device(d).GetSupportedEventTypes() - return e, Return(r) -} - -// GetTopologyCommonAncestor retrieves the common ancestor for two devices. -func (d nvmlDevice) GetTopologyCommonAncestor(o Device) (GpuTopologyLevel, Return) { - other := o.nvmlDeviceHandle() - if other == nil { - return 0, ERROR_INVALID_ARGUMENT - } - - l, r := nvml.Device(d).GetTopologyCommonAncestor(*other) - return GpuTopologyLevel(l), Return(r) -} - -// GetNvLinkState retrieves the state of the device's NvLink for the link specified. -func (d nvmlDevice) GetNvLinkState(link int) (EnableState, Return) { - s, r := nvml.Device(d).GetNvLinkState(link) - return EnableState(s), Return(r) -} - -// GetNvLinkRemotePciInfo retrieves the PCI information for the remote node on a NvLink link. -// Note: pciSubSystemId is not filled in this function and is indeterminate. -func (d nvmlDevice) GetNvLinkRemotePciInfo(link int) (PciInfo, Return) { - p, r := nvml.Device(d).GetNvLinkRemotePciInfo(link) - return PciInfo(p), Return(r) -} - -// SetComputeMode sets the compute mode for the device. -func (d nvmlDevice) SetComputeMode(mode ComputeMode) Return { - r := nvml.Device(d).SetComputeMode(nvml.ComputeMode(mode)) - return Return(r) -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device_mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device_mock.go deleted file mode 100644 index 84f14722..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/device_mock.go +++ /dev/null @@ -1,1237 +0,0 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq - -package nvml - -import ( - "github.com/NVIDIA/go-nvml/pkg/nvml" - "sync" -) - -// Ensure, that DeviceMock does implement Device. -// If this is not the case, regenerate this file with moq. -var _ Device = &DeviceMock{} - -// DeviceMock is a mock implementation of Device. -// -// func TestSomethingThatUsesDevice(t *testing.T) { -// -// // make and configure a mocked Device -// mockedDevice := &DeviceMock{ -// CreateGpuInstanceWithPlacementFunc: func(gpuInstanceProfileInfo *GpuInstanceProfileInfo, gpuInstancePlacement *GpuInstancePlacement) (GpuInstance, Return) { -// panic("mock out the CreateGpuInstanceWithPlacement method") -// }, -// GetArchitectureFunc: func() (DeviceArchitecture, Return) { -// panic("mock out the GetArchitecture method") -// }, -// GetAttributesFunc: func() (DeviceAttributes, Return) { -// panic("mock out the GetAttributes method") -// }, -// GetBrandFunc: func() (BrandType, Return) { -// panic("mock out the GetBrand method") -// }, -// GetComputeInstanceIdFunc: func() (int, Return) { -// panic("mock out the GetComputeInstanceId method") -// }, -// GetCudaComputeCapabilityFunc: func() (int, int, Return) { -// panic("mock out the GetCudaComputeCapability method") -// }, -// GetDeviceHandleFromMigDeviceHandleFunc: func() (Device, Return) { -// panic("mock out the GetDeviceHandleFromMigDeviceHandle method") -// }, -// GetGpuInstanceByIdFunc: func(ID int) (GpuInstance, Return) { -// panic("mock out the GetGpuInstanceById method") -// }, -// GetGpuInstanceIdFunc: func() (int, Return) { -// panic("mock out the GetGpuInstanceId method") -// }, -// GetGpuInstancePossiblePlacementsFunc: func(gpuInstanceProfileInfo *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) { -// panic("mock out the GetGpuInstancePossiblePlacements method") -// }, -// GetGpuInstanceProfileInfoFunc: func(Profile int) (GpuInstanceProfileInfo, Return) { -// panic("mock out the GetGpuInstanceProfileInfo method") -// }, -// GetGpuInstancesFunc: func(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return) { -// panic("mock out the GetGpuInstances method") -// }, -// GetIndexFunc: func() (int, Return) { -// panic("mock out the GetIndex method") -// }, -// GetMaxMigDeviceCountFunc: func() (int, Return) { -// panic("mock out the GetMaxMigDeviceCount method") -// }, -// GetMemoryInfoFunc: func() (Memory, Return) { -// panic("mock out the GetMemoryInfo method") -// }, -// GetMigDeviceHandleByIndexFunc: func(Index int) (Device, Return) { -// panic("mock out the GetMigDeviceHandleByIndex method") -// }, -// GetMigModeFunc: func() (int, int, Return) { -// panic("mock out the GetMigMode method") -// }, -// GetMinorNumberFunc: func() (int, Return) { -// panic("mock out the GetMinorNumber method") -// }, -// GetNameFunc: func() (string, Return) { -// panic("mock out the GetName method") -// }, -// GetNvLinkRemotePciInfoFunc: func(n int) (PciInfo, Return) { -// panic("mock out the GetNvLinkRemotePciInfo method") -// }, -// GetNvLinkStateFunc: func(n int) (EnableState, Return) { -// panic("mock out the GetNvLinkState method") -// }, -// GetPciInfoFunc: func() (PciInfo, Return) { -// panic("mock out the GetPciInfo method") -// }, -// GetSupportedEventTypesFunc: func() (uint64, Return) { -// panic("mock out the GetSupportedEventTypes method") -// }, -// GetTopologyCommonAncestorFunc: func(device Device) (GpuTopologyLevel, Return) { -// panic("mock out the GetTopologyCommonAncestor method") -// }, -// GetUUIDFunc: func() (string, Return) { -// panic("mock out the GetUUID method") -// }, -// IsMigDeviceHandleFunc: func() (bool, Return) { -// panic("mock out the IsMigDeviceHandle method") -// }, -// RegisterEventsFunc: func(v uint64, eventSet EventSet) Return { -// panic("mock out the RegisterEvents method") -// }, -// SetComputeModeFunc: func(computeMode ComputeMode) Return { -// panic("mock out the SetComputeMode method") -// }, -// SetMigModeFunc: func(Mode int) (Return, Return) { -// panic("mock out the SetMigMode method") -// }, -// nvmlDeviceHandleFunc: func() *nvml.Device { -// panic("mock out the nvmlDeviceHandle method") -// }, -// } -// -// // use mockedDevice in code that requires Device -// // and then make assertions. -// -// } -type DeviceMock struct { - // CreateGpuInstanceWithPlacementFunc mocks the CreateGpuInstanceWithPlacement method. - CreateGpuInstanceWithPlacementFunc func(gpuInstanceProfileInfo *GpuInstanceProfileInfo, gpuInstancePlacement *GpuInstancePlacement) (GpuInstance, Return) - - // GetArchitectureFunc mocks the GetArchitecture method. - GetArchitectureFunc func() (DeviceArchitecture, Return) - - // GetAttributesFunc mocks the GetAttributes method. - GetAttributesFunc func() (DeviceAttributes, Return) - - // GetBrandFunc mocks the GetBrand method. - GetBrandFunc func() (BrandType, Return) - - // GetComputeInstanceIdFunc mocks the GetComputeInstanceId method. - GetComputeInstanceIdFunc func() (int, Return) - - // GetCudaComputeCapabilityFunc mocks the GetCudaComputeCapability method. - GetCudaComputeCapabilityFunc func() (int, int, Return) - - // GetDeviceHandleFromMigDeviceHandleFunc mocks the GetDeviceHandleFromMigDeviceHandle method. - GetDeviceHandleFromMigDeviceHandleFunc func() (Device, Return) - - // GetGpuInstanceByIdFunc mocks the GetGpuInstanceById method. - GetGpuInstanceByIdFunc func(ID int) (GpuInstance, Return) - - // GetGpuInstanceIdFunc mocks the GetGpuInstanceId method. - GetGpuInstanceIdFunc func() (int, Return) - - // GetGpuInstancePossiblePlacementsFunc mocks the GetGpuInstancePossiblePlacements method. - GetGpuInstancePossiblePlacementsFunc func(gpuInstanceProfileInfo *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) - - // GetGpuInstanceProfileInfoFunc mocks the GetGpuInstanceProfileInfo method. - GetGpuInstanceProfileInfoFunc func(Profile int) (GpuInstanceProfileInfo, Return) - - // GetGpuInstancesFunc mocks the GetGpuInstances method. - GetGpuInstancesFunc func(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return) - - // GetIndexFunc mocks the GetIndex method. - GetIndexFunc func() (int, Return) - - // GetMaxMigDeviceCountFunc mocks the GetMaxMigDeviceCount method. - GetMaxMigDeviceCountFunc func() (int, Return) - - // GetMemoryInfoFunc mocks the GetMemoryInfo method. - GetMemoryInfoFunc func() (Memory, Return) - - // GetMigDeviceHandleByIndexFunc mocks the GetMigDeviceHandleByIndex method. - GetMigDeviceHandleByIndexFunc func(Index int) (Device, Return) - - // GetMigModeFunc mocks the GetMigMode method. - GetMigModeFunc func() (int, int, Return) - - // GetMinorNumberFunc mocks the GetMinorNumber method. - GetMinorNumberFunc func() (int, Return) - - // GetNameFunc mocks the GetName method. - GetNameFunc func() (string, Return) - - // GetNvLinkRemotePciInfoFunc mocks the GetNvLinkRemotePciInfo method. - GetNvLinkRemotePciInfoFunc func(n int) (PciInfo, Return) - - // GetNvLinkStateFunc mocks the GetNvLinkState method. - GetNvLinkStateFunc func(n int) (EnableState, Return) - - // GetPciInfoFunc mocks the GetPciInfo method. - GetPciInfoFunc func() (PciInfo, Return) - - // GetSupportedEventTypesFunc mocks the GetSupportedEventTypes method. - GetSupportedEventTypesFunc func() (uint64, Return) - - // GetTopologyCommonAncestorFunc mocks the GetTopologyCommonAncestor method. - GetTopologyCommonAncestorFunc func(device Device) (GpuTopologyLevel, Return) - - // GetUUIDFunc mocks the GetUUID method. - GetUUIDFunc func() (string, Return) - - // IsMigDeviceHandleFunc mocks the IsMigDeviceHandle method. - IsMigDeviceHandleFunc func() (bool, Return) - - // RegisterEventsFunc mocks the RegisterEvents method. - RegisterEventsFunc func(v uint64, eventSet EventSet) Return - - // SetComputeModeFunc mocks the SetComputeMode method. - SetComputeModeFunc func(computeMode ComputeMode) Return - - // SetMigModeFunc mocks the SetMigMode method. - SetMigModeFunc func(Mode int) (Return, Return) - - // nvmlDeviceHandleFunc mocks the nvmlDeviceHandle method. - nvmlDeviceHandleFunc func() *nvml.Device - - // calls tracks calls to the methods. - calls struct { - // CreateGpuInstanceWithPlacement holds details about calls to the CreateGpuInstanceWithPlacement method. - CreateGpuInstanceWithPlacement []struct { - // GpuInstanceProfileInfo is the gpuInstanceProfileInfo argument value. - GpuInstanceProfileInfo *GpuInstanceProfileInfo - // GpuInstancePlacement is the gpuInstancePlacement argument value. - GpuInstancePlacement *GpuInstancePlacement - } - // GetArchitecture holds details about calls to the GetArchitecture method. - GetArchitecture []struct { - } - // GetAttributes holds details about calls to the GetAttributes method. - GetAttributes []struct { - } - // GetBrand holds details about calls to the GetBrand method. - GetBrand []struct { - } - // GetComputeInstanceId holds details about calls to the GetComputeInstanceId method. - GetComputeInstanceId []struct { - } - // GetCudaComputeCapability holds details about calls to the GetCudaComputeCapability method. - GetCudaComputeCapability []struct { - } - // GetDeviceHandleFromMigDeviceHandle holds details about calls to the GetDeviceHandleFromMigDeviceHandle method. - GetDeviceHandleFromMigDeviceHandle []struct { - } - // GetGpuInstanceById holds details about calls to the GetGpuInstanceById method. - GetGpuInstanceById []struct { - // ID is the ID argument value. - ID int - } - // GetGpuInstanceId holds details about calls to the GetGpuInstanceId method. - GetGpuInstanceId []struct { - } - // GetGpuInstancePossiblePlacements holds details about calls to the GetGpuInstancePossiblePlacements method. - GetGpuInstancePossiblePlacements []struct { - // GpuInstanceProfileInfo is the gpuInstanceProfileInfo argument value. - GpuInstanceProfileInfo *GpuInstanceProfileInfo - } - // GetGpuInstanceProfileInfo holds details about calls to the GetGpuInstanceProfileInfo method. - GetGpuInstanceProfileInfo []struct { - // Profile is the Profile argument value. - Profile int - } - // GetGpuInstances holds details about calls to the GetGpuInstances method. - GetGpuInstances []struct { - // Info is the Info argument value. - Info *GpuInstanceProfileInfo - } - // GetIndex holds details about calls to the GetIndex method. - GetIndex []struct { - } - // GetMaxMigDeviceCount holds details about calls to the GetMaxMigDeviceCount method. - GetMaxMigDeviceCount []struct { - } - // GetMemoryInfo holds details about calls to the GetMemoryInfo method. - GetMemoryInfo []struct { - } - // GetMigDeviceHandleByIndex holds details about calls to the GetMigDeviceHandleByIndex method. - GetMigDeviceHandleByIndex []struct { - // Index is the Index argument value. - Index int - } - // GetMigMode holds details about calls to the GetMigMode method. - GetMigMode []struct { - } - // GetMinorNumber holds details about calls to the GetMinorNumber method. - GetMinorNumber []struct { - } - // GetName holds details about calls to the GetName method. - GetName []struct { - } - // GetNvLinkRemotePciInfo holds details about calls to the GetNvLinkRemotePciInfo method. - GetNvLinkRemotePciInfo []struct { - // N is the n argument value. - N int - } - // GetNvLinkState holds details about calls to the GetNvLinkState method. - GetNvLinkState []struct { - // N is the n argument value. - N int - } - // GetPciInfo holds details about calls to the GetPciInfo method. - GetPciInfo []struct { - } - // GetSupportedEventTypes holds details about calls to the GetSupportedEventTypes method. - GetSupportedEventTypes []struct { - } - // GetTopologyCommonAncestor holds details about calls to the GetTopologyCommonAncestor method. - GetTopologyCommonAncestor []struct { - // Device is the device argument value. - Device Device - } - // GetUUID holds details about calls to the GetUUID method. - GetUUID []struct { - } - // IsMigDeviceHandle holds details about calls to the IsMigDeviceHandle method. - IsMigDeviceHandle []struct { - } - // RegisterEvents holds details about calls to the RegisterEvents method. - RegisterEvents []struct { - // V is the v argument value. - V uint64 - // EventSet is the eventSet argument value. - EventSet EventSet - } - // SetComputeMode holds details about calls to the SetComputeMode method. - SetComputeMode []struct { - // ComputeMode is the computeMode argument value. - ComputeMode ComputeMode - } - // SetMigMode holds details about calls to the SetMigMode method. - SetMigMode []struct { - // Mode is the Mode argument value. - Mode int - } - // nvmlDeviceHandle holds details about calls to the nvmlDeviceHandle method. - nvmlDeviceHandle []struct { - } - } - lockCreateGpuInstanceWithPlacement sync.RWMutex - lockGetArchitecture sync.RWMutex - lockGetAttributes sync.RWMutex - lockGetBrand sync.RWMutex - lockGetComputeInstanceId sync.RWMutex - lockGetCudaComputeCapability sync.RWMutex - lockGetDeviceHandleFromMigDeviceHandle sync.RWMutex - lockGetGpuInstanceById sync.RWMutex - lockGetGpuInstanceId sync.RWMutex - lockGetGpuInstancePossiblePlacements sync.RWMutex - lockGetGpuInstanceProfileInfo sync.RWMutex - lockGetGpuInstances sync.RWMutex - lockGetIndex sync.RWMutex - lockGetMaxMigDeviceCount sync.RWMutex - lockGetMemoryInfo sync.RWMutex - lockGetMigDeviceHandleByIndex sync.RWMutex - lockGetMigMode sync.RWMutex - lockGetMinorNumber sync.RWMutex - lockGetName sync.RWMutex - lockGetNvLinkRemotePciInfo sync.RWMutex - lockGetNvLinkState sync.RWMutex - lockGetPciInfo sync.RWMutex - lockGetSupportedEventTypes sync.RWMutex - lockGetTopologyCommonAncestor sync.RWMutex - lockGetUUID sync.RWMutex - lockIsMigDeviceHandle sync.RWMutex - lockRegisterEvents sync.RWMutex - lockSetComputeMode sync.RWMutex - lockSetMigMode sync.RWMutex - locknvmlDeviceHandle sync.RWMutex -} - -// CreateGpuInstanceWithPlacement calls CreateGpuInstanceWithPlacementFunc. -func (mock *DeviceMock) CreateGpuInstanceWithPlacement(gpuInstanceProfileInfo *GpuInstanceProfileInfo, gpuInstancePlacement *GpuInstancePlacement) (GpuInstance, Return) { - if mock.CreateGpuInstanceWithPlacementFunc == nil { - panic("DeviceMock.CreateGpuInstanceWithPlacementFunc: method is nil but Device.CreateGpuInstanceWithPlacement was just called") - } - callInfo := struct { - GpuInstanceProfileInfo *GpuInstanceProfileInfo - GpuInstancePlacement *GpuInstancePlacement - }{ - GpuInstanceProfileInfo: gpuInstanceProfileInfo, - GpuInstancePlacement: gpuInstancePlacement, - } - mock.lockCreateGpuInstanceWithPlacement.Lock() - mock.calls.CreateGpuInstanceWithPlacement = append(mock.calls.CreateGpuInstanceWithPlacement, callInfo) - mock.lockCreateGpuInstanceWithPlacement.Unlock() - return mock.CreateGpuInstanceWithPlacementFunc(gpuInstanceProfileInfo, gpuInstancePlacement) -} - -// CreateGpuInstanceWithPlacementCalls gets all the calls that were made to CreateGpuInstanceWithPlacement. -// Check the length with: -// -// len(mockedDevice.CreateGpuInstanceWithPlacementCalls()) -func (mock *DeviceMock) CreateGpuInstanceWithPlacementCalls() []struct { - GpuInstanceProfileInfo *GpuInstanceProfileInfo - GpuInstancePlacement *GpuInstancePlacement -} { - var calls []struct { - GpuInstanceProfileInfo *GpuInstanceProfileInfo - GpuInstancePlacement *GpuInstancePlacement - } - mock.lockCreateGpuInstanceWithPlacement.RLock() - calls = mock.calls.CreateGpuInstanceWithPlacement - mock.lockCreateGpuInstanceWithPlacement.RUnlock() - return calls -} - -// GetArchitecture calls GetArchitectureFunc. -func (mock *DeviceMock) GetArchitecture() (DeviceArchitecture, Return) { - if mock.GetArchitectureFunc == nil { - panic("DeviceMock.GetArchitectureFunc: method is nil but Device.GetArchitecture was just called") - } - callInfo := struct { - }{} - mock.lockGetArchitecture.Lock() - mock.calls.GetArchitecture = append(mock.calls.GetArchitecture, callInfo) - mock.lockGetArchitecture.Unlock() - return mock.GetArchitectureFunc() -} - -// GetArchitectureCalls gets all the calls that were made to GetArchitecture. -// Check the length with: -// -// len(mockedDevice.GetArchitectureCalls()) -func (mock *DeviceMock) GetArchitectureCalls() []struct { -} { - var calls []struct { - } - mock.lockGetArchitecture.RLock() - calls = mock.calls.GetArchitecture - mock.lockGetArchitecture.RUnlock() - return calls -} - -// GetAttributes calls GetAttributesFunc. -func (mock *DeviceMock) GetAttributes() (DeviceAttributes, Return) { - if mock.GetAttributesFunc == nil { - panic("DeviceMock.GetAttributesFunc: method is nil but Device.GetAttributes was just called") - } - callInfo := struct { - }{} - mock.lockGetAttributes.Lock() - mock.calls.GetAttributes = append(mock.calls.GetAttributes, callInfo) - mock.lockGetAttributes.Unlock() - return mock.GetAttributesFunc() -} - -// GetAttributesCalls gets all the calls that were made to GetAttributes. -// Check the length with: -// -// len(mockedDevice.GetAttributesCalls()) -func (mock *DeviceMock) GetAttributesCalls() []struct { -} { - var calls []struct { - } - mock.lockGetAttributes.RLock() - calls = mock.calls.GetAttributes - mock.lockGetAttributes.RUnlock() - return calls -} - -// GetBrand calls GetBrandFunc. -func (mock *DeviceMock) GetBrand() (BrandType, Return) { - if mock.GetBrandFunc == nil { - panic("DeviceMock.GetBrandFunc: method is nil but Device.GetBrand was just called") - } - callInfo := struct { - }{} - mock.lockGetBrand.Lock() - mock.calls.GetBrand = append(mock.calls.GetBrand, callInfo) - mock.lockGetBrand.Unlock() - return mock.GetBrandFunc() -} - -// GetBrandCalls gets all the calls that were made to GetBrand. -// Check the length with: -// -// len(mockedDevice.GetBrandCalls()) -func (mock *DeviceMock) GetBrandCalls() []struct { -} { - var calls []struct { - } - mock.lockGetBrand.RLock() - calls = mock.calls.GetBrand - mock.lockGetBrand.RUnlock() - return calls -} - -// GetComputeInstanceId calls GetComputeInstanceIdFunc. -func (mock *DeviceMock) GetComputeInstanceId() (int, Return) { - if mock.GetComputeInstanceIdFunc == nil { - panic("DeviceMock.GetComputeInstanceIdFunc: method is nil but Device.GetComputeInstanceId was just called") - } - callInfo := struct { - }{} - mock.lockGetComputeInstanceId.Lock() - mock.calls.GetComputeInstanceId = append(mock.calls.GetComputeInstanceId, callInfo) - mock.lockGetComputeInstanceId.Unlock() - return mock.GetComputeInstanceIdFunc() -} - -// GetComputeInstanceIdCalls gets all the calls that were made to GetComputeInstanceId. -// Check the length with: -// -// len(mockedDevice.GetComputeInstanceIdCalls()) -func (mock *DeviceMock) GetComputeInstanceIdCalls() []struct { -} { - var calls []struct { - } - mock.lockGetComputeInstanceId.RLock() - calls = mock.calls.GetComputeInstanceId - mock.lockGetComputeInstanceId.RUnlock() - return calls -} - -// GetCudaComputeCapability calls GetCudaComputeCapabilityFunc. -func (mock *DeviceMock) GetCudaComputeCapability() (int, int, Return) { - if mock.GetCudaComputeCapabilityFunc == nil { - panic("DeviceMock.GetCudaComputeCapabilityFunc: method is nil but Device.GetCudaComputeCapability was just called") - } - callInfo := struct { - }{} - mock.lockGetCudaComputeCapability.Lock() - mock.calls.GetCudaComputeCapability = append(mock.calls.GetCudaComputeCapability, callInfo) - mock.lockGetCudaComputeCapability.Unlock() - return mock.GetCudaComputeCapabilityFunc() -} - -// GetCudaComputeCapabilityCalls gets all the calls that were made to GetCudaComputeCapability. -// Check the length with: -// -// len(mockedDevice.GetCudaComputeCapabilityCalls()) -func (mock *DeviceMock) GetCudaComputeCapabilityCalls() []struct { -} { - var calls []struct { - } - mock.lockGetCudaComputeCapability.RLock() - calls = mock.calls.GetCudaComputeCapability - mock.lockGetCudaComputeCapability.RUnlock() - return calls -} - -// GetDeviceHandleFromMigDeviceHandle calls GetDeviceHandleFromMigDeviceHandleFunc. -func (mock *DeviceMock) GetDeviceHandleFromMigDeviceHandle() (Device, Return) { - if mock.GetDeviceHandleFromMigDeviceHandleFunc == nil { - panic("DeviceMock.GetDeviceHandleFromMigDeviceHandleFunc: method is nil but Device.GetDeviceHandleFromMigDeviceHandle was just called") - } - callInfo := struct { - }{} - mock.lockGetDeviceHandleFromMigDeviceHandle.Lock() - mock.calls.GetDeviceHandleFromMigDeviceHandle = append(mock.calls.GetDeviceHandleFromMigDeviceHandle, callInfo) - mock.lockGetDeviceHandleFromMigDeviceHandle.Unlock() - return mock.GetDeviceHandleFromMigDeviceHandleFunc() -} - -// GetDeviceHandleFromMigDeviceHandleCalls gets all the calls that were made to GetDeviceHandleFromMigDeviceHandle. -// Check the length with: -// -// len(mockedDevice.GetDeviceHandleFromMigDeviceHandleCalls()) -func (mock *DeviceMock) GetDeviceHandleFromMigDeviceHandleCalls() []struct { -} { - var calls []struct { - } - mock.lockGetDeviceHandleFromMigDeviceHandle.RLock() - calls = mock.calls.GetDeviceHandleFromMigDeviceHandle - mock.lockGetDeviceHandleFromMigDeviceHandle.RUnlock() - return calls -} - -// GetGpuInstanceById calls GetGpuInstanceByIdFunc. -func (mock *DeviceMock) GetGpuInstanceById(ID int) (GpuInstance, Return) { - if mock.GetGpuInstanceByIdFunc == nil { - panic("DeviceMock.GetGpuInstanceByIdFunc: method is nil but Device.GetGpuInstanceById was just called") - } - callInfo := struct { - ID int - }{ - ID: ID, - } - mock.lockGetGpuInstanceById.Lock() - mock.calls.GetGpuInstanceById = append(mock.calls.GetGpuInstanceById, callInfo) - mock.lockGetGpuInstanceById.Unlock() - return mock.GetGpuInstanceByIdFunc(ID) -} - -// GetGpuInstanceByIdCalls gets all the calls that were made to GetGpuInstanceById. -// Check the length with: -// -// len(mockedDevice.GetGpuInstanceByIdCalls()) -func (mock *DeviceMock) GetGpuInstanceByIdCalls() []struct { - ID int -} { - var calls []struct { - ID int - } - mock.lockGetGpuInstanceById.RLock() - calls = mock.calls.GetGpuInstanceById - mock.lockGetGpuInstanceById.RUnlock() - return calls -} - -// GetGpuInstanceId calls GetGpuInstanceIdFunc. -func (mock *DeviceMock) GetGpuInstanceId() (int, Return) { - if mock.GetGpuInstanceIdFunc == nil { - panic("DeviceMock.GetGpuInstanceIdFunc: method is nil but Device.GetGpuInstanceId was just called") - } - callInfo := struct { - }{} - mock.lockGetGpuInstanceId.Lock() - mock.calls.GetGpuInstanceId = append(mock.calls.GetGpuInstanceId, callInfo) - mock.lockGetGpuInstanceId.Unlock() - return mock.GetGpuInstanceIdFunc() -} - -// GetGpuInstanceIdCalls gets all the calls that were made to GetGpuInstanceId. -// Check the length with: -// -// len(mockedDevice.GetGpuInstanceIdCalls()) -func (mock *DeviceMock) GetGpuInstanceIdCalls() []struct { -} { - var calls []struct { - } - mock.lockGetGpuInstanceId.RLock() - calls = mock.calls.GetGpuInstanceId - mock.lockGetGpuInstanceId.RUnlock() - return calls -} - -// GetGpuInstancePossiblePlacements calls GetGpuInstancePossiblePlacementsFunc. -func (mock *DeviceMock) GetGpuInstancePossiblePlacements(gpuInstanceProfileInfo *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) { - if mock.GetGpuInstancePossiblePlacementsFunc == nil { - panic("DeviceMock.GetGpuInstancePossiblePlacementsFunc: method is nil but Device.GetGpuInstancePossiblePlacements was just called") - } - callInfo := struct { - GpuInstanceProfileInfo *GpuInstanceProfileInfo - }{ - GpuInstanceProfileInfo: gpuInstanceProfileInfo, - } - mock.lockGetGpuInstancePossiblePlacements.Lock() - mock.calls.GetGpuInstancePossiblePlacements = append(mock.calls.GetGpuInstancePossiblePlacements, callInfo) - mock.lockGetGpuInstancePossiblePlacements.Unlock() - return mock.GetGpuInstancePossiblePlacementsFunc(gpuInstanceProfileInfo) -} - -// GetGpuInstancePossiblePlacementsCalls gets all the calls that were made to GetGpuInstancePossiblePlacements. -// Check the length with: -// -// len(mockedDevice.GetGpuInstancePossiblePlacementsCalls()) -func (mock *DeviceMock) GetGpuInstancePossiblePlacementsCalls() []struct { - GpuInstanceProfileInfo *GpuInstanceProfileInfo -} { - var calls []struct { - GpuInstanceProfileInfo *GpuInstanceProfileInfo - } - mock.lockGetGpuInstancePossiblePlacements.RLock() - calls = mock.calls.GetGpuInstancePossiblePlacements - mock.lockGetGpuInstancePossiblePlacements.RUnlock() - return calls -} - -// GetGpuInstanceProfileInfo calls GetGpuInstanceProfileInfoFunc. -func (mock *DeviceMock) GetGpuInstanceProfileInfo(Profile int) (GpuInstanceProfileInfo, Return) { - if mock.GetGpuInstanceProfileInfoFunc == nil { - panic("DeviceMock.GetGpuInstanceProfileInfoFunc: method is nil but Device.GetGpuInstanceProfileInfo was just called") - } - callInfo := struct { - Profile int - }{ - Profile: Profile, - } - mock.lockGetGpuInstanceProfileInfo.Lock() - mock.calls.GetGpuInstanceProfileInfo = append(mock.calls.GetGpuInstanceProfileInfo, callInfo) - mock.lockGetGpuInstanceProfileInfo.Unlock() - return mock.GetGpuInstanceProfileInfoFunc(Profile) -} - -// GetGpuInstanceProfileInfoCalls gets all the calls that were made to GetGpuInstanceProfileInfo. -// Check the length with: -// -// len(mockedDevice.GetGpuInstanceProfileInfoCalls()) -func (mock *DeviceMock) GetGpuInstanceProfileInfoCalls() []struct { - Profile int -} { - var calls []struct { - Profile int - } - mock.lockGetGpuInstanceProfileInfo.RLock() - calls = mock.calls.GetGpuInstanceProfileInfo - mock.lockGetGpuInstanceProfileInfo.RUnlock() - return calls -} - -// GetGpuInstances calls GetGpuInstancesFunc. -func (mock *DeviceMock) GetGpuInstances(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return) { - if mock.GetGpuInstancesFunc == nil { - panic("DeviceMock.GetGpuInstancesFunc: method is nil but Device.GetGpuInstances was just called") - } - callInfo := struct { - Info *GpuInstanceProfileInfo - }{ - Info: Info, - } - mock.lockGetGpuInstances.Lock() - mock.calls.GetGpuInstances = append(mock.calls.GetGpuInstances, callInfo) - mock.lockGetGpuInstances.Unlock() - return mock.GetGpuInstancesFunc(Info) -} - -// GetGpuInstancesCalls gets all the calls that were made to GetGpuInstances. -// Check the length with: -// -// len(mockedDevice.GetGpuInstancesCalls()) -func (mock *DeviceMock) GetGpuInstancesCalls() []struct { - Info *GpuInstanceProfileInfo -} { - var calls []struct { - Info *GpuInstanceProfileInfo - } - mock.lockGetGpuInstances.RLock() - calls = mock.calls.GetGpuInstances - mock.lockGetGpuInstances.RUnlock() - return calls -} - -// GetIndex calls GetIndexFunc. -func (mock *DeviceMock) GetIndex() (int, Return) { - if mock.GetIndexFunc == nil { - panic("DeviceMock.GetIndexFunc: method is nil but Device.GetIndex was just called") - } - callInfo := struct { - }{} - mock.lockGetIndex.Lock() - mock.calls.GetIndex = append(mock.calls.GetIndex, callInfo) - mock.lockGetIndex.Unlock() - return mock.GetIndexFunc() -} - -// GetIndexCalls gets all the calls that were made to GetIndex. -// Check the length with: -// -// len(mockedDevice.GetIndexCalls()) -func (mock *DeviceMock) GetIndexCalls() []struct { -} { - var calls []struct { - } - mock.lockGetIndex.RLock() - calls = mock.calls.GetIndex - mock.lockGetIndex.RUnlock() - return calls -} - -// GetMaxMigDeviceCount calls GetMaxMigDeviceCountFunc. -func (mock *DeviceMock) GetMaxMigDeviceCount() (int, Return) { - if mock.GetMaxMigDeviceCountFunc == nil { - panic("DeviceMock.GetMaxMigDeviceCountFunc: method is nil but Device.GetMaxMigDeviceCount was just called") - } - callInfo := struct { - }{} - mock.lockGetMaxMigDeviceCount.Lock() - mock.calls.GetMaxMigDeviceCount = append(mock.calls.GetMaxMigDeviceCount, callInfo) - mock.lockGetMaxMigDeviceCount.Unlock() - return mock.GetMaxMigDeviceCountFunc() -} - -// GetMaxMigDeviceCountCalls gets all the calls that were made to GetMaxMigDeviceCount. -// Check the length with: -// -// len(mockedDevice.GetMaxMigDeviceCountCalls()) -func (mock *DeviceMock) GetMaxMigDeviceCountCalls() []struct { -} { - var calls []struct { - } - mock.lockGetMaxMigDeviceCount.RLock() - calls = mock.calls.GetMaxMigDeviceCount - mock.lockGetMaxMigDeviceCount.RUnlock() - return calls -} - -// GetMemoryInfo calls GetMemoryInfoFunc. -func (mock *DeviceMock) GetMemoryInfo() (Memory, Return) { - if mock.GetMemoryInfoFunc == nil { - panic("DeviceMock.GetMemoryInfoFunc: method is nil but Device.GetMemoryInfo was just called") - } - callInfo := struct { - }{} - mock.lockGetMemoryInfo.Lock() - mock.calls.GetMemoryInfo = append(mock.calls.GetMemoryInfo, callInfo) - mock.lockGetMemoryInfo.Unlock() - return mock.GetMemoryInfoFunc() -} - -// GetMemoryInfoCalls gets all the calls that were made to GetMemoryInfo. -// Check the length with: -// -// len(mockedDevice.GetMemoryInfoCalls()) -func (mock *DeviceMock) GetMemoryInfoCalls() []struct { -} { - var calls []struct { - } - mock.lockGetMemoryInfo.RLock() - calls = mock.calls.GetMemoryInfo - mock.lockGetMemoryInfo.RUnlock() - return calls -} - -// GetMigDeviceHandleByIndex calls GetMigDeviceHandleByIndexFunc. -func (mock *DeviceMock) GetMigDeviceHandleByIndex(Index int) (Device, Return) { - if mock.GetMigDeviceHandleByIndexFunc == nil { - panic("DeviceMock.GetMigDeviceHandleByIndexFunc: method is nil but Device.GetMigDeviceHandleByIndex was just called") - } - callInfo := struct { - Index int - }{ - Index: Index, - } - mock.lockGetMigDeviceHandleByIndex.Lock() - mock.calls.GetMigDeviceHandleByIndex = append(mock.calls.GetMigDeviceHandleByIndex, callInfo) - mock.lockGetMigDeviceHandleByIndex.Unlock() - return mock.GetMigDeviceHandleByIndexFunc(Index) -} - -// GetMigDeviceHandleByIndexCalls gets all the calls that were made to GetMigDeviceHandleByIndex. -// Check the length with: -// -// len(mockedDevice.GetMigDeviceHandleByIndexCalls()) -func (mock *DeviceMock) GetMigDeviceHandleByIndexCalls() []struct { - Index int -} { - var calls []struct { - Index int - } - mock.lockGetMigDeviceHandleByIndex.RLock() - calls = mock.calls.GetMigDeviceHandleByIndex - mock.lockGetMigDeviceHandleByIndex.RUnlock() - return calls -} - -// GetMigMode calls GetMigModeFunc. -func (mock *DeviceMock) GetMigMode() (int, int, Return) { - if mock.GetMigModeFunc == nil { - panic("DeviceMock.GetMigModeFunc: method is nil but Device.GetMigMode was just called") - } - callInfo := struct { - }{} - mock.lockGetMigMode.Lock() - mock.calls.GetMigMode = append(mock.calls.GetMigMode, callInfo) - mock.lockGetMigMode.Unlock() - return mock.GetMigModeFunc() -} - -// GetMigModeCalls gets all the calls that were made to GetMigMode. -// Check the length with: -// -// len(mockedDevice.GetMigModeCalls()) -func (mock *DeviceMock) GetMigModeCalls() []struct { -} { - var calls []struct { - } - mock.lockGetMigMode.RLock() - calls = mock.calls.GetMigMode - mock.lockGetMigMode.RUnlock() - return calls -} - -// GetMinorNumber calls GetMinorNumberFunc. -func (mock *DeviceMock) GetMinorNumber() (int, Return) { - if mock.GetMinorNumberFunc == nil { - panic("DeviceMock.GetMinorNumberFunc: method is nil but Device.GetMinorNumber was just called") - } - callInfo := struct { - }{} - mock.lockGetMinorNumber.Lock() - mock.calls.GetMinorNumber = append(mock.calls.GetMinorNumber, callInfo) - mock.lockGetMinorNumber.Unlock() - return mock.GetMinorNumberFunc() -} - -// GetMinorNumberCalls gets all the calls that were made to GetMinorNumber. -// Check the length with: -// -// len(mockedDevice.GetMinorNumberCalls()) -func (mock *DeviceMock) GetMinorNumberCalls() []struct { -} { - var calls []struct { - } - mock.lockGetMinorNumber.RLock() - calls = mock.calls.GetMinorNumber - mock.lockGetMinorNumber.RUnlock() - return calls -} - -// GetName calls GetNameFunc. -func (mock *DeviceMock) GetName() (string, Return) { - if mock.GetNameFunc == nil { - panic("DeviceMock.GetNameFunc: method is nil but Device.GetName was just called") - } - callInfo := struct { - }{} - mock.lockGetName.Lock() - mock.calls.GetName = append(mock.calls.GetName, callInfo) - mock.lockGetName.Unlock() - return mock.GetNameFunc() -} - -// GetNameCalls gets all the calls that were made to GetName. -// Check the length with: -// -// len(mockedDevice.GetNameCalls()) -func (mock *DeviceMock) GetNameCalls() []struct { -} { - var calls []struct { - } - mock.lockGetName.RLock() - calls = mock.calls.GetName - mock.lockGetName.RUnlock() - return calls -} - -// GetNvLinkRemotePciInfo calls GetNvLinkRemotePciInfoFunc. -func (mock *DeviceMock) GetNvLinkRemotePciInfo(n int) (PciInfo, Return) { - if mock.GetNvLinkRemotePciInfoFunc == nil { - panic("DeviceMock.GetNvLinkRemotePciInfoFunc: method is nil but Device.GetNvLinkRemotePciInfo was just called") - } - callInfo := struct { - N int - }{ - N: n, - } - mock.lockGetNvLinkRemotePciInfo.Lock() - mock.calls.GetNvLinkRemotePciInfo = append(mock.calls.GetNvLinkRemotePciInfo, callInfo) - mock.lockGetNvLinkRemotePciInfo.Unlock() - return mock.GetNvLinkRemotePciInfoFunc(n) -} - -// GetNvLinkRemotePciInfoCalls gets all the calls that were made to GetNvLinkRemotePciInfo. -// Check the length with: -// -// len(mockedDevice.GetNvLinkRemotePciInfoCalls()) -func (mock *DeviceMock) GetNvLinkRemotePciInfoCalls() []struct { - N int -} { - var calls []struct { - N int - } - mock.lockGetNvLinkRemotePciInfo.RLock() - calls = mock.calls.GetNvLinkRemotePciInfo - mock.lockGetNvLinkRemotePciInfo.RUnlock() - return calls -} - -// GetNvLinkState calls GetNvLinkStateFunc. -func (mock *DeviceMock) GetNvLinkState(n int) (EnableState, Return) { - if mock.GetNvLinkStateFunc == nil { - panic("DeviceMock.GetNvLinkStateFunc: method is nil but Device.GetNvLinkState was just called") - } - callInfo := struct { - N int - }{ - N: n, - } - mock.lockGetNvLinkState.Lock() - mock.calls.GetNvLinkState = append(mock.calls.GetNvLinkState, callInfo) - mock.lockGetNvLinkState.Unlock() - return mock.GetNvLinkStateFunc(n) -} - -// GetNvLinkStateCalls gets all the calls that were made to GetNvLinkState. -// Check the length with: -// -// len(mockedDevice.GetNvLinkStateCalls()) -func (mock *DeviceMock) GetNvLinkStateCalls() []struct { - N int -} { - var calls []struct { - N int - } - mock.lockGetNvLinkState.RLock() - calls = mock.calls.GetNvLinkState - mock.lockGetNvLinkState.RUnlock() - return calls -} - -// GetPciInfo calls GetPciInfoFunc. -func (mock *DeviceMock) GetPciInfo() (PciInfo, Return) { - if mock.GetPciInfoFunc == nil { - panic("DeviceMock.GetPciInfoFunc: method is nil but Device.GetPciInfo was just called") - } - callInfo := struct { - }{} - mock.lockGetPciInfo.Lock() - mock.calls.GetPciInfo = append(mock.calls.GetPciInfo, callInfo) - mock.lockGetPciInfo.Unlock() - return mock.GetPciInfoFunc() -} - -// GetPciInfoCalls gets all the calls that were made to GetPciInfo. -// Check the length with: -// -// len(mockedDevice.GetPciInfoCalls()) -func (mock *DeviceMock) GetPciInfoCalls() []struct { -} { - var calls []struct { - } - mock.lockGetPciInfo.RLock() - calls = mock.calls.GetPciInfo - mock.lockGetPciInfo.RUnlock() - return calls -} - -// GetSupportedEventTypes calls GetSupportedEventTypesFunc. -func (mock *DeviceMock) GetSupportedEventTypes() (uint64, Return) { - if mock.GetSupportedEventTypesFunc == nil { - panic("DeviceMock.GetSupportedEventTypesFunc: method is nil but Device.GetSupportedEventTypes was just called") - } - callInfo := struct { - }{} - mock.lockGetSupportedEventTypes.Lock() - mock.calls.GetSupportedEventTypes = append(mock.calls.GetSupportedEventTypes, callInfo) - mock.lockGetSupportedEventTypes.Unlock() - return mock.GetSupportedEventTypesFunc() -} - -// GetSupportedEventTypesCalls gets all the calls that were made to GetSupportedEventTypes. -// Check the length with: -// -// len(mockedDevice.GetSupportedEventTypesCalls()) -func (mock *DeviceMock) GetSupportedEventTypesCalls() []struct { -} { - var calls []struct { - } - mock.lockGetSupportedEventTypes.RLock() - calls = mock.calls.GetSupportedEventTypes - mock.lockGetSupportedEventTypes.RUnlock() - return calls -} - -// GetTopologyCommonAncestor calls GetTopologyCommonAncestorFunc. -func (mock *DeviceMock) GetTopologyCommonAncestor(device Device) (GpuTopologyLevel, Return) { - if mock.GetTopologyCommonAncestorFunc == nil { - panic("DeviceMock.GetTopologyCommonAncestorFunc: method is nil but Device.GetTopologyCommonAncestor was just called") - } - callInfo := struct { - Device Device - }{ - Device: device, - } - mock.lockGetTopologyCommonAncestor.Lock() - mock.calls.GetTopologyCommonAncestor = append(mock.calls.GetTopologyCommonAncestor, callInfo) - mock.lockGetTopologyCommonAncestor.Unlock() - return mock.GetTopologyCommonAncestorFunc(device) -} - -// GetTopologyCommonAncestorCalls gets all the calls that were made to GetTopologyCommonAncestor. -// Check the length with: -// -// len(mockedDevice.GetTopologyCommonAncestorCalls()) -func (mock *DeviceMock) GetTopologyCommonAncestorCalls() []struct { - Device Device -} { - var calls []struct { - Device Device - } - mock.lockGetTopologyCommonAncestor.RLock() - calls = mock.calls.GetTopologyCommonAncestor - mock.lockGetTopologyCommonAncestor.RUnlock() - return calls -} - -// GetUUID calls GetUUIDFunc. -func (mock *DeviceMock) GetUUID() (string, Return) { - if mock.GetUUIDFunc == nil { - panic("DeviceMock.GetUUIDFunc: method is nil but Device.GetUUID was just called") - } - callInfo := struct { - }{} - mock.lockGetUUID.Lock() - mock.calls.GetUUID = append(mock.calls.GetUUID, callInfo) - mock.lockGetUUID.Unlock() - return mock.GetUUIDFunc() -} - -// GetUUIDCalls gets all the calls that were made to GetUUID. -// Check the length with: -// -// len(mockedDevice.GetUUIDCalls()) -func (mock *DeviceMock) GetUUIDCalls() []struct { -} { - var calls []struct { - } - mock.lockGetUUID.RLock() - calls = mock.calls.GetUUID - mock.lockGetUUID.RUnlock() - return calls -} - -// IsMigDeviceHandle calls IsMigDeviceHandleFunc. -func (mock *DeviceMock) IsMigDeviceHandle() (bool, Return) { - if mock.IsMigDeviceHandleFunc == nil { - panic("DeviceMock.IsMigDeviceHandleFunc: method is nil but Device.IsMigDeviceHandle was just called") - } - callInfo := struct { - }{} - mock.lockIsMigDeviceHandle.Lock() - mock.calls.IsMigDeviceHandle = append(mock.calls.IsMigDeviceHandle, callInfo) - mock.lockIsMigDeviceHandle.Unlock() - return mock.IsMigDeviceHandleFunc() -} - -// IsMigDeviceHandleCalls gets all the calls that were made to IsMigDeviceHandle. -// Check the length with: -// -// len(mockedDevice.IsMigDeviceHandleCalls()) -func (mock *DeviceMock) IsMigDeviceHandleCalls() []struct { -} { - var calls []struct { - } - mock.lockIsMigDeviceHandle.RLock() - calls = mock.calls.IsMigDeviceHandle - mock.lockIsMigDeviceHandle.RUnlock() - return calls -} - -// RegisterEvents calls RegisterEventsFunc. -func (mock *DeviceMock) RegisterEvents(v uint64, eventSet EventSet) Return { - if mock.RegisterEventsFunc == nil { - panic("DeviceMock.RegisterEventsFunc: method is nil but Device.RegisterEvents was just called") - } - callInfo := struct { - V uint64 - EventSet EventSet - }{ - V: v, - EventSet: eventSet, - } - mock.lockRegisterEvents.Lock() - mock.calls.RegisterEvents = append(mock.calls.RegisterEvents, callInfo) - mock.lockRegisterEvents.Unlock() - return mock.RegisterEventsFunc(v, eventSet) -} - -// RegisterEventsCalls gets all the calls that were made to RegisterEvents. -// Check the length with: -// -// len(mockedDevice.RegisterEventsCalls()) -func (mock *DeviceMock) RegisterEventsCalls() []struct { - V uint64 - EventSet EventSet -} { - var calls []struct { - V uint64 - EventSet EventSet - } - mock.lockRegisterEvents.RLock() - calls = mock.calls.RegisterEvents - mock.lockRegisterEvents.RUnlock() - return calls -} - -// SetComputeMode calls SetComputeModeFunc. -func (mock *DeviceMock) SetComputeMode(computeMode ComputeMode) Return { - if mock.SetComputeModeFunc == nil { - panic("DeviceMock.SetComputeModeFunc: method is nil but Device.SetComputeMode was just called") - } - callInfo := struct { - ComputeMode ComputeMode - }{ - ComputeMode: computeMode, - } - mock.lockSetComputeMode.Lock() - mock.calls.SetComputeMode = append(mock.calls.SetComputeMode, callInfo) - mock.lockSetComputeMode.Unlock() - return mock.SetComputeModeFunc(computeMode) -} - -// SetComputeModeCalls gets all the calls that were made to SetComputeMode. -// Check the length with: -// -// len(mockedDevice.SetComputeModeCalls()) -func (mock *DeviceMock) SetComputeModeCalls() []struct { - ComputeMode ComputeMode -} { - var calls []struct { - ComputeMode ComputeMode - } - mock.lockSetComputeMode.RLock() - calls = mock.calls.SetComputeMode - mock.lockSetComputeMode.RUnlock() - return calls -} - -// SetMigMode calls SetMigModeFunc. -func (mock *DeviceMock) SetMigMode(Mode int) (Return, Return) { - if mock.SetMigModeFunc == nil { - panic("DeviceMock.SetMigModeFunc: method is nil but Device.SetMigMode was just called") - } - callInfo := struct { - Mode int - }{ - Mode: Mode, - } - mock.lockSetMigMode.Lock() - mock.calls.SetMigMode = append(mock.calls.SetMigMode, callInfo) - mock.lockSetMigMode.Unlock() - return mock.SetMigModeFunc(Mode) -} - -// SetMigModeCalls gets all the calls that were made to SetMigMode. -// Check the length with: -// -// len(mockedDevice.SetMigModeCalls()) -func (mock *DeviceMock) SetMigModeCalls() []struct { - Mode int -} { - var calls []struct { - Mode int - } - mock.lockSetMigMode.RLock() - calls = mock.calls.SetMigMode - mock.lockSetMigMode.RUnlock() - return calls -} - -// nvmlDeviceHandle calls nvmlDeviceHandleFunc. -func (mock *DeviceMock) nvmlDeviceHandle() *nvml.Device { - if mock.nvmlDeviceHandleFunc == nil { - panic("DeviceMock.nvmlDeviceHandleFunc: method is nil but Device.nvmlDeviceHandle was just called") - } - callInfo := struct { - }{} - mock.locknvmlDeviceHandle.Lock() - mock.calls.nvmlDeviceHandle = append(mock.calls.nvmlDeviceHandle, callInfo) - mock.locknvmlDeviceHandle.Unlock() - return mock.nvmlDeviceHandleFunc() -} - -// nvmlDeviceHandleCalls gets all the calls that were made to nvmlDeviceHandle. -// Check the length with: -// -// len(mockedDevice.nvmlDeviceHandleCalls()) -func (mock *DeviceMock) nvmlDeviceHandleCalls() []struct { -} { - var calls []struct { - } - mock.locknvmlDeviceHandle.RLock() - calls = mock.calls.nvmlDeviceHandle - mock.locknvmlDeviceHandle.RUnlock() - return calls -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/event_set.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/event_set.go deleted file mode 100644 index 2e0b9e2c..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/event_set.go +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -// Wait watches for an event with the specified timeout -func (e EventSet) Wait(Timeoutms uint32) (EventData, Return) { - d, r := nvml.EventSet(e).Wait(Timeoutms) - eventData := EventData{ - Device: nvmlDevice(d.Device), - EventType: d.EventType, - EventData: d.EventData, - GpuInstanceId: d.GpuInstanceId, - ComputeInstanceId: d.ComputeInstanceId, - } - return eventData, Return(r) -} - -// Free deletes the event set -func (e EventSet) Free() Return { - return Return(nvml.EventSet(e).Free()) -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi.go deleted file mode 100644 index bc4d3734..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi.go +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -type nvmlGpuInstance nvml.GpuInstance - -var _ GpuInstance = (*nvmlGpuInstance)(nil) - -// GetInfo returns info about a GPU Intsance -func (gi nvmlGpuInstance) GetInfo() (GpuInstanceInfo, Return) { - i, r := nvml.GpuInstance(gi).GetInfo() - info := GpuInstanceInfo{ - Device: nvmlDevice(i.Device), - Id: i.Id, - ProfileId: i.ProfileId, - Placement: GpuInstancePlacement(i.Placement), - } - return info, Return(r) -} - -// GetComputeInstanceById returns the Compute Instance associated with a particular ID. -func (gi nvmlGpuInstance) GetComputeInstanceById(id int) (ComputeInstance, Return) { - ci, r := nvml.GpuInstance(gi).GetComputeInstanceById(id) - return nvmlComputeInstance(ci), Return(r) -} - -// GetComputeInstanceProfileInfo returns info about a given Compute Instance profile -func (gi nvmlGpuInstance) GetComputeInstanceProfileInfo(profile int, engProfile int) (ComputeInstanceProfileInfo, Return) { - p, r := nvml.GpuInstance(gi).GetComputeInstanceProfileInfo(profile, engProfile) - return ComputeInstanceProfileInfo(p), Return(r) -} - -// CreateComputeInstance creates a Compute Instance within the GPU Instance -func (gi nvmlGpuInstance) CreateComputeInstance(info *ComputeInstanceProfileInfo) (ComputeInstance, Return) { - ci, r := nvml.GpuInstance(gi).CreateComputeInstance((*nvml.ComputeInstanceProfileInfo)(info)) - return nvmlComputeInstance(ci), Return(r) -} - -// GetComputeInstances returns the set of Compute Instances associated with a GPU Instance -func (gi nvmlGpuInstance) GetComputeInstances(info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) { - nvmlCis, r := nvml.GpuInstance(gi).GetComputeInstances((*nvml.ComputeInstanceProfileInfo)(info)) - var cis []ComputeInstance - for _, ci := range nvmlCis { - cis = append(cis, nvmlComputeInstance(ci)) - } - return cis, Return(r) -} - -// Destroy destroys a GPU Instance -func (gi nvmlGpuInstance) Destroy() Return { - r := nvml.GpuInstance(gi).Destroy() - return Return(r) -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi_mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi_mock.go deleted file mode 100644 index ac26cb2c..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/gi_mock.go +++ /dev/null @@ -1,286 +0,0 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq - -package nvml - -import ( - "sync" -) - -// Ensure, that GpuInstanceMock does implement GpuInstance. -// If this is not the case, regenerate this file with moq. -var _ GpuInstance = &GpuInstanceMock{} - -// GpuInstanceMock is a mock implementation of GpuInstance. -// -// func TestSomethingThatUsesGpuInstance(t *testing.T) { -// -// // make and configure a mocked GpuInstance -// mockedGpuInstance := &GpuInstanceMock{ -// CreateComputeInstanceFunc: func(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return) { -// panic("mock out the CreateComputeInstance method") -// }, -// DestroyFunc: func() Return { -// panic("mock out the Destroy method") -// }, -// GetComputeInstanceByIdFunc: func(ID int) (ComputeInstance, Return) { -// panic("mock out the GetComputeInstanceById method") -// }, -// GetComputeInstanceProfileInfoFunc: func(Profile int, EngProfile int) (ComputeInstanceProfileInfo, Return) { -// panic("mock out the GetComputeInstanceProfileInfo method") -// }, -// GetComputeInstancesFunc: func(Info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) { -// panic("mock out the GetComputeInstances method") -// }, -// GetInfoFunc: func() (GpuInstanceInfo, Return) { -// panic("mock out the GetInfo method") -// }, -// } -// -// // use mockedGpuInstance in code that requires GpuInstance -// // and then make assertions. -// -// } -type GpuInstanceMock struct { - // CreateComputeInstanceFunc mocks the CreateComputeInstance method. - CreateComputeInstanceFunc func(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return) - - // DestroyFunc mocks the Destroy method. - DestroyFunc func() Return - - // GetComputeInstanceByIdFunc mocks the GetComputeInstanceById method. - GetComputeInstanceByIdFunc func(ID int) (ComputeInstance, Return) - - // GetComputeInstanceProfileInfoFunc mocks the GetComputeInstanceProfileInfo method. - GetComputeInstanceProfileInfoFunc func(Profile int, EngProfile int) (ComputeInstanceProfileInfo, Return) - - // GetComputeInstancesFunc mocks the GetComputeInstances method. - GetComputeInstancesFunc func(Info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) - - // GetInfoFunc mocks the GetInfo method. - GetInfoFunc func() (GpuInstanceInfo, Return) - - // calls tracks calls to the methods. - calls struct { - // CreateComputeInstance holds details about calls to the CreateComputeInstance method. - CreateComputeInstance []struct { - // Info is the Info argument value. - Info *ComputeInstanceProfileInfo - } - // Destroy holds details about calls to the Destroy method. - Destroy []struct { - } - // GetComputeInstanceById holds details about calls to the GetComputeInstanceById method. - GetComputeInstanceById []struct { - // ID is the ID argument value. - ID int - } - // GetComputeInstanceProfileInfo holds details about calls to the GetComputeInstanceProfileInfo method. - GetComputeInstanceProfileInfo []struct { - // Profile is the Profile argument value. - Profile int - // EngProfile is the EngProfile argument value. - EngProfile int - } - // GetComputeInstances holds details about calls to the GetComputeInstances method. - GetComputeInstances []struct { - // Info is the Info argument value. - Info *ComputeInstanceProfileInfo - } - // GetInfo holds details about calls to the GetInfo method. - GetInfo []struct { - } - } - lockCreateComputeInstance sync.RWMutex - lockDestroy sync.RWMutex - lockGetComputeInstanceById sync.RWMutex - lockGetComputeInstanceProfileInfo sync.RWMutex - lockGetComputeInstances sync.RWMutex - lockGetInfo sync.RWMutex -} - -// CreateComputeInstance calls CreateComputeInstanceFunc. -func (mock *GpuInstanceMock) CreateComputeInstance(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return) { - if mock.CreateComputeInstanceFunc == nil { - panic("GpuInstanceMock.CreateComputeInstanceFunc: method is nil but GpuInstance.CreateComputeInstance was just called") - } - callInfo := struct { - Info *ComputeInstanceProfileInfo - }{ - Info: Info, - } - mock.lockCreateComputeInstance.Lock() - mock.calls.CreateComputeInstance = append(mock.calls.CreateComputeInstance, callInfo) - mock.lockCreateComputeInstance.Unlock() - return mock.CreateComputeInstanceFunc(Info) -} - -// CreateComputeInstanceCalls gets all the calls that were made to CreateComputeInstance. -// Check the length with: -// -// len(mockedGpuInstance.CreateComputeInstanceCalls()) -func (mock *GpuInstanceMock) CreateComputeInstanceCalls() []struct { - Info *ComputeInstanceProfileInfo -} { - var calls []struct { - Info *ComputeInstanceProfileInfo - } - mock.lockCreateComputeInstance.RLock() - calls = mock.calls.CreateComputeInstance - mock.lockCreateComputeInstance.RUnlock() - return calls -} - -// Destroy calls DestroyFunc. -func (mock *GpuInstanceMock) Destroy() Return { - if mock.DestroyFunc == nil { - panic("GpuInstanceMock.DestroyFunc: method is nil but GpuInstance.Destroy was just called") - } - callInfo := struct { - }{} - mock.lockDestroy.Lock() - mock.calls.Destroy = append(mock.calls.Destroy, callInfo) - mock.lockDestroy.Unlock() - return mock.DestroyFunc() -} - -// DestroyCalls gets all the calls that were made to Destroy. -// Check the length with: -// -// len(mockedGpuInstance.DestroyCalls()) -func (mock *GpuInstanceMock) DestroyCalls() []struct { -} { - var calls []struct { - } - mock.lockDestroy.RLock() - calls = mock.calls.Destroy - mock.lockDestroy.RUnlock() - return calls -} - -// GetComputeInstanceById calls GetComputeInstanceByIdFunc. -func (mock *GpuInstanceMock) GetComputeInstanceById(ID int) (ComputeInstance, Return) { - if mock.GetComputeInstanceByIdFunc == nil { - panic("GpuInstanceMock.GetComputeInstanceByIdFunc: method is nil but GpuInstance.GetComputeInstanceById was just called") - } - callInfo := struct { - ID int - }{ - ID: ID, - } - mock.lockGetComputeInstanceById.Lock() - mock.calls.GetComputeInstanceById = append(mock.calls.GetComputeInstanceById, callInfo) - mock.lockGetComputeInstanceById.Unlock() - return mock.GetComputeInstanceByIdFunc(ID) -} - -// GetComputeInstanceByIdCalls gets all the calls that were made to GetComputeInstanceById. -// Check the length with: -// -// len(mockedGpuInstance.GetComputeInstanceByIdCalls()) -func (mock *GpuInstanceMock) GetComputeInstanceByIdCalls() []struct { - ID int -} { - var calls []struct { - ID int - } - mock.lockGetComputeInstanceById.RLock() - calls = mock.calls.GetComputeInstanceById - mock.lockGetComputeInstanceById.RUnlock() - return calls -} - -// GetComputeInstanceProfileInfo calls GetComputeInstanceProfileInfoFunc. -func (mock *GpuInstanceMock) GetComputeInstanceProfileInfo(Profile int, EngProfile int) (ComputeInstanceProfileInfo, Return) { - if mock.GetComputeInstanceProfileInfoFunc == nil { - panic("GpuInstanceMock.GetComputeInstanceProfileInfoFunc: method is nil but GpuInstance.GetComputeInstanceProfileInfo was just called") - } - callInfo := struct { - Profile int - EngProfile int - }{ - Profile: Profile, - EngProfile: EngProfile, - } - mock.lockGetComputeInstanceProfileInfo.Lock() - mock.calls.GetComputeInstanceProfileInfo = append(mock.calls.GetComputeInstanceProfileInfo, callInfo) - mock.lockGetComputeInstanceProfileInfo.Unlock() - return mock.GetComputeInstanceProfileInfoFunc(Profile, EngProfile) -} - -// GetComputeInstanceProfileInfoCalls gets all the calls that were made to GetComputeInstanceProfileInfo. -// Check the length with: -// -// len(mockedGpuInstance.GetComputeInstanceProfileInfoCalls()) -func (mock *GpuInstanceMock) GetComputeInstanceProfileInfoCalls() []struct { - Profile int - EngProfile int -} { - var calls []struct { - Profile int - EngProfile int - } - mock.lockGetComputeInstanceProfileInfo.RLock() - calls = mock.calls.GetComputeInstanceProfileInfo - mock.lockGetComputeInstanceProfileInfo.RUnlock() - return calls -} - -// GetComputeInstances calls GetComputeInstancesFunc. -func (mock *GpuInstanceMock) GetComputeInstances(Info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) { - if mock.GetComputeInstancesFunc == nil { - panic("GpuInstanceMock.GetComputeInstancesFunc: method is nil but GpuInstance.GetComputeInstances was just called") - } - callInfo := struct { - Info *ComputeInstanceProfileInfo - }{ - Info: Info, - } - mock.lockGetComputeInstances.Lock() - mock.calls.GetComputeInstances = append(mock.calls.GetComputeInstances, callInfo) - mock.lockGetComputeInstances.Unlock() - return mock.GetComputeInstancesFunc(Info) -} - -// GetComputeInstancesCalls gets all the calls that were made to GetComputeInstances. -// Check the length with: -// -// len(mockedGpuInstance.GetComputeInstancesCalls()) -func (mock *GpuInstanceMock) GetComputeInstancesCalls() []struct { - Info *ComputeInstanceProfileInfo -} { - var calls []struct { - Info *ComputeInstanceProfileInfo - } - mock.lockGetComputeInstances.RLock() - calls = mock.calls.GetComputeInstances - mock.lockGetComputeInstances.RUnlock() - return calls -} - -// GetInfo calls GetInfoFunc. -func (mock *GpuInstanceMock) GetInfo() (GpuInstanceInfo, Return) { - if mock.GetInfoFunc == nil { - panic("GpuInstanceMock.GetInfoFunc: method is nil but GpuInstance.GetInfo was just called") - } - callInfo := struct { - }{} - mock.lockGetInfo.Lock() - mock.calls.GetInfo = append(mock.calls.GetInfo, callInfo) - mock.lockGetInfo.Unlock() - return mock.GetInfoFunc() -} - -// GetInfoCalls gets all the calls that were made to GetInfo. -// Check the length with: -// -// len(mockedGpuInstance.GetInfoCalls()) -func (mock *GpuInstanceMock) GetInfoCalls() []struct { -} { - var calls []struct { - } - mock.lockGetInfo.RLock() - calls = mock.calls.GetInfo - mock.lockGetInfo.RUnlock() - return calls -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml.go deleted file mode 100644 index fdd28de3..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml.go +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "sync" - - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -type nvmlLib struct { - sync.Mutex - refcount int -} - -var _ Interface = (*nvmlLib)(nil) - -// New creates a new instance of the NVML Interface -func New(opts ...Option) Interface { - o := &options{} - for _, opt := range opts { - opt(o) - } - - var nvmlOptions []nvml.LibraryOption - if o.libraryPath != "" { - nvmlOptions = append(nvmlOptions, nvml.WithLibraryPath(o.libraryPath)) - } - nvml.SetLibraryOptions(nvmlOptions...) - - return &nvmlLib{} -} - -// Lookup checks whether the specified symbol exists in the configured NVML library. -func (n *nvmlLib) Lookup(name string) error { - // TODO: For now we rely on the default NVML library and perform the lookups against this. - return nvml.GetLibrary().Lookup(name) -} - -// Init initializes an NVML Interface -func (n *nvmlLib) Init() Return { - ret := nvml.Init() - if ret != nvml.SUCCESS { - return Return(ret) - } - - n.Lock() - defer n.Unlock() - if n.refcount == 0 { - errorStringFunc = nvml.ErrorString - } - n.refcount++ - - return SUCCESS -} - -// Shutdown shuts down an NVML Interface -func (n *nvmlLib) Shutdown() Return { - ret := nvml.Shutdown() - if ret != nvml.SUCCESS { - return Return(ret) - } - - n.Lock() - defer n.Unlock() - n.refcount-- - if n.refcount == 0 { - errorStringFunc = defaultErrorStringFunc - } - - return SUCCESS -} - -// DeviceGetCount returns the total number of GPU Devices -func (n *nvmlLib) DeviceGetCount() (int, Return) { - c, r := nvml.DeviceGetCount() - return c, Return(r) -} - -// DeviceGetHandleByIndex returns a Device handle given its index -func (n *nvmlLib) DeviceGetHandleByIndex(index int) (Device, Return) { - d, r := nvml.DeviceGetHandleByIndex(index) - return nvmlDevice(d), Return(r) -} - -// DeviceGetHandleByUUID returns a Device handle given its UUID -func (n *nvmlLib) DeviceGetHandleByUUID(uuid string) (Device, Return) { - d, r := nvml.DeviceGetHandleByUUID(uuid) - return nvmlDevice(d), Return(r) -} - -// SystemGetDriverVersion returns the version of the installed NVIDIA driver -func (n *nvmlLib) SystemGetDriverVersion() (string, Return) { - v, r := nvml.SystemGetDriverVersion() - return v, Return(r) -} - -// SystemGetCudaDriverVersion returns the version of CUDA associated with the NVIDIA driver -func (n *nvmlLib) SystemGetCudaDriverVersion() (int, Return) { - v, r := nvml.SystemGetCudaDriverVersion() - return v, Return(r) -} - -// ErrorString returns the error string associated with a given return value -func (n *nvmlLib) ErrorString(ret Return) string { - return nvml.ErrorString(nvml.Return(ret)) -} - -// EventSetCreate creates an event set -func (n *nvmlLib) EventSetCreate() (EventSet, Return) { - e, r := nvml.EventSetCreate() - return EventSet(e), Return(r) -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml_mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml_mock.go deleted file mode 100644 index 00957f81..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/nvml_mock.go +++ /dev/null @@ -1,428 +0,0 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq - -package nvml - -import ( - "sync" -) - -// Ensure, that InterfaceMock does implement Interface. -// If this is not the case, regenerate this file with moq. -var _ Interface = &InterfaceMock{} - -// InterfaceMock is a mock implementation of Interface. -// -// func TestSomethingThatUsesInterface(t *testing.T) { -// -// // make and configure a mocked Interface -// mockedInterface := &InterfaceMock{ -// DeviceGetCountFunc: func() (int, Return) { -// panic("mock out the DeviceGetCount method") -// }, -// DeviceGetHandleByIndexFunc: func(Index int) (Device, Return) { -// panic("mock out the DeviceGetHandleByIndex method") -// }, -// DeviceGetHandleByUUIDFunc: func(UUID string) (Device, Return) { -// panic("mock out the DeviceGetHandleByUUID method") -// }, -// ErrorStringFunc: func(r Return) string { -// panic("mock out the ErrorString method") -// }, -// EventSetCreateFunc: func() (EventSet, Return) { -// panic("mock out the EventSetCreate method") -// }, -// InitFunc: func() Return { -// panic("mock out the Init method") -// }, -// LookupFunc: func(s string) error { -// panic("mock out the Lookup method") -// }, -// ShutdownFunc: func() Return { -// panic("mock out the Shutdown method") -// }, -// SystemGetCudaDriverVersionFunc: func() (int, Return) { -// panic("mock out the SystemGetCudaDriverVersion method") -// }, -// SystemGetDriverVersionFunc: func() (string, Return) { -// panic("mock out the SystemGetDriverVersion method") -// }, -// } -// -// // use mockedInterface in code that requires Interface -// // and then make assertions. -// -// } -type InterfaceMock struct { - // DeviceGetCountFunc mocks the DeviceGetCount method. - DeviceGetCountFunc func() (int, Return) - - // DeviceGetHandleByIndexFunc mocks the DeviceGetHandleByIndex method. - DeviceGetHandleByIndexFunc func(Index int) (Device, Return) - - // DeviceGetHandleByUUIDFunc mocks the DeviceGetHandleByUUID method. - DeviceGetHandleByUUIDFunc func(UUID string) (Device, Return) - - // ErrorStringFunc mocks the ErrorString method. - ErrorStringFunc func(r Return) string - - // EventSetCreateFunc mocks the EventSetCreate method. - EventSetCreateFunc func() (EventSet, Return) - - // InitFunc mocks the Init method. - InitFunc func() Return - - // LookupFunc mocks the Lookup method. - LookupFunc func(s string) error - - // ShutdownFunc mocks the Shutdown method. - ShutdownFunc func() Return - - // SystemGetCudaDriverVersionFunc mocks the SystemGetCudaDriverVersion method. - SystemGetCudaDriverVersionFunc func() (int, Return) - - // SystemGetDriverVersionFunc mocks the SystemGetDriverVersion method. - SystemGetDriverVersionFunc func() (string, Return) - - // calls tracks calls to the methods. - calls struct { - // DeviceGetCount holds details about calls to the DeviceGetCount method. - DeviceGetCount []struct { - } - // DeviceGetHandleByIndex holds details about calls to the DeviceGetHandleByIndex method. - DeviceGetHandleByIndex []struct { - // Index is the Index argument value. - Index int - } - // DeviceGetHandleByUUID holds details about calls to the DeviceGetHandleByUUID method. - DeviceGetHandleByUUID []struct { - // UUID is the UUID argument value. - UUID string - } - // ErrorString holds details about calls to the ErrorString method. - ErrorString []struct { - // R is the r argument value. - R Return - } - // EventSetCreate holds details about calls to the EventSetCreate method. - EventSetCreate []struct { - } - // Init holds details about calls to the Init method. - Init []struct { - } - // Lookup holds details about calls to the Lookup method. - Lookup []struct { - // S is the s argument value. - S string - } - // Shutdown holds details about calls to the Shutdown method. - Shutdown []struct { - } - // SystemGetCudaDriverVersion holds details about calls to the SystemGetCudaDriverVersion method. - SystemGetCudaDriverVersion []struct { - } - // SystemGetDriverVersion holds details about calls to the SystemGetDriverVersion method. - SystemGetDriverVersion []struct { - } - } - lockDeviceGetCount sync.RWMutex - lockDeviceGetHandleByIndex sync.RWMutex - lockDeviceGetHandleByUUID sync.RWMutex - lockErrorString sync.RWMutex - lockEventSetCreate sync.RWMutex - lockInit sync.RWMutex - lockLookup sync.RWMutex - lockShutdown sync.RWMutex - lockSystemGetCudaDriverVersion sync.RWMutex - lockSystemGetDriverVersion sync.RWMutex -} - -// DeviceGetCount calls DeviceGetCountFunc. -func (mock *InterfaceMock) DeviceGetCount() (int, Return) { - if mock.DeviceGetCountFunc == nil { - panic("InterfaceMock.DeviceGetCountFunc: method is nil but Interface.DeviceGetCount was just called") - } - callInfo := struct { - }{} - mock.lockDeviceGetCount.Lock() - mock.calls.DeviceGetCount = append(mock.calls.DeviceGetCount, callInfo) - mock.lockDeviceGetCount.Unlock() - return mock.DeviceGetCountFunc() -} - -// DeviceGetCountCalls gets all the calls that were made to DeviceGetCount. -// Check the length with: -// -// len(mockedInterface.DeviceGetCountCalls()) -func (mock *InterfaceMock) DeviceGetCountCalls() []struct { -} { - var calls []struct { - } - mock.lockDeviceGetCount.RLock() - calls = mock.calls.DeviceGetCount - mock.lockDeviceGetCount.RUnlock() - return calls -} - -// DeviceGetHandleByIndex calls DeviceGetHandleByIndexFunc. -func (mock *InterfaceMock) DeviceGetHandleByIndex(Index int) (Device, Return) { - if mock.DeviceGetHandleByIndexFunc == nil { - panic("InterfaceMock.DeviceGetHandleByIndexFunc: method is nil but Interface.DeviceGetHandleByIndex was just called") - } - callInfo := struct { - Index int - }{ - Index: Index, - } - mock.lockDeviceGetHandleByIndex.Lock() - mock.calls.DeviceGetHandleByIndex = append(mock.calls.DeviceGetHandleByIndex, callInfo) - mock.lockDeviceGetHandleByIndex.Unlock() - return mock.DeviceGetHandleByIndexFunc(Index) -} - -// DeviceGetHandleByIndexCalls gets all the calls that were made to DeviceGetHandleByIndex. -// Check the length with: -// -// len(mockedInterface.DeviceGetHandleByIndexCalls()) -func (mock *InterfaceMock) DeviceGetHandleByIndexCalls() []struct { - Index int -} { - var calls []struct { - Index int - } - mock.lockDeviceGetHandleByIndex.RLock() - calls = mock.calls.DeviceGetHandleByIndex - mock.lockDeviceGetHandleByIndex.RUnlock() - return calls -} - -// DeviceGetHandleByUUID calls DeviceGetHandleByUUIDFunc. -func (mock *InterfaceMock) DeviceGetHandleByUUID(UUID string) (Device, Return) { - if mock.DeviceGetHandleByUUIDFunc == nil { - panic("InterfaceMock.DeviceGetHandleByUUIDFunc: method is nil but Interface.DeviceGetHandleByUUID was just called") - } - callInfo := struct { - UUID string - }{ - UUID: UUID, - } - mock.lockDeviceGetHandleByUUID.Lock() - mock.calls.DeviceGetHandleByUUID = append(mock.calls.DeviceGetHandleByUUID, callInfo) - mock.lockDeviceGetHandleByUUID.Unlock() - return mock.DeviceGetHandleByUUIDFunc(UUID) -} - -// DeviceGetHandleByUUIDCalls gets all the calls that were made to DeviceGetHandleByUUID. -// Check the length with: -// -// len(mockedInterface.DeviceGetHandleByUUIDCalls()) -func (mock *InterfaceMock) DeviceGetHandleByUUIDCalls() []struct { - UUID string -} { - var calls []struct { - UUID string - } - mock.lockDeviceGetHandleByUUID.RLock() - calls = mock.calls.DeviceGetHandleByUUID - mock.lockDeviceGetHandleByUUID.RUnlock() - return calls -} - -// ErrorString calls ErrorStringFunc. -func (mock *InterfaceMock) ErrorString(r Return) string { - if mock.ErrorStringFunc == nil { - panic("InterfaceMock.ErrorStringFunc: method is nil but Interface.ErrorString was just called") - } - callInfo := struct { - R Return - }{ - R: r, - } - mock.lockErrorString.Lock() - mock.calls.ErrorString = append(mock.calls.ErrorString, callInfo) - mock.lockErrorString.Unlock() - return mock.ErrorStringFunc(r) -} - -// ErrorStringCalls gets all the calls that were made to ErrorString. -// Check the length with: -// -// len(mockedInterface.ErrorStringCalls()) -func (mock *InterfaceMock) ErrorStringCalls() []struct { - R Return -} { - var calls []struct { - R Return - } - mock.lockErrorString.RLock() - calls = mock.calls.ErrorString - mock.lockErrorString.RUnlock() - return calls -} - -// EventSetCreate calls EventSetCreateFunc. -func (mock *InterfaceMock) EventSetCreate() (EventSet, Return) { - if mock.EventSetCreateFunc == nil { - panic("InterfaceMock.EventSetCreateFunc: method is nil but Interface.EventSetCreate was just called") - } - callInfo := struct { - }{} - mock.lockEventSetCreate.Lock() - mock.calls.EventSetCreate = append(mock.calls.EventSetCreate, callInfo) - mock.lockEventSetCreate.Unlock() - return mock.EventSetCreateFunc() -} - -// EventSetCreateCalls gets all the calls that were made to EventSetCreate. -// Check the length with: -// -// len(mockedInterface.EventSetCreateCalls()) -func (mock *InterfaceMock) EventSetCreateCalls() []struct { -} { - var calls []struct { - } - mock.lockEventSetCreate.RLock() - calls = mock.calls.EventSetCreate - mock.lockEventSetCreate.RUnlock() - return calls -} - -// Init calls InitFunc. -func (mock *InterfaceMock) Init() Return { - if mock.InitFunc == nil { - panic("InterfaceMock.InitFunc: method is nil but Interface.Init was just called") - } - callInfo := struct { - }{} - mock.lockInit.Lock() - mock.calls.Init = append(mock.calls.Init, callInfo) - mock.lockInit.Unlock() - return mock.InitFunc() -} - -// InitCalls gets all the calls that were made to Init. -// Check the length with: -// -// len(mockedInterface.InitCalls()) -func (mock *InterfaceMock) InitCalls() []struct { -} { - var calls []struct { - } - mock.lockInit.RLock() - calls = mock.calls.Init - mock.lockInit.RUnlock() - return calls -} - -// Lookup calls LookupFunc. -func (mock *InterfaceMock) Lookup(s string) error { - if mock.LookupFunc == nil { - panic("InterfaceMock.LookupFunc: method is nil but Interface.Lookup was just called") - } - callInfo := struct { - S string - }{ - S: s, - } - mock.lockLookup.Lock() - mock.calls.Lookup = append(mock.calls.Lookup, callInfo) - mock.lockLookup.Unlock() - return mock.LookupFunc(s) -} - -// LookupCalls gets all the calls that were made to Lookup. -// Check the length with: -// -// len(mockedInterface.LookupCalls()) -func (mock *InterfaceMock) LookupCalls() []struct { - S string -} { - var calls []struct { - S string - } - mock.lockLookup.RLock() - calls = mock.calls.Lookup - mock.lockLookup.RUnlock() - return calls -} - -// Shutdown calls ShutdownFunc. -func (mock *InterfaceMock) Shutdown() Return { - if mock.ShutdownFunc == nil { - panic("InterfaceMock.ShutdownFunc: method is nil but Interface.Shutdown was just called") - } - callInfo := struct { - }{} - mock.lockShutdown.Lock() - mock.calls.Shutdown = append(mock.calls.Shutdown, callInfo) - mock.lockShutdown.Unlock() - return mock.ShutdownFunc() -} - -// ShutdownCalls gets all the calls that were made to Shutdown. -// Check the length with: -// -// len(mockedInterface.ShutdownCalls()) -func (mock *InterfaceMock) ShutdownCalls() []struct { -} { - var calls []struct { - } - mock.lockShutdown.RLock() - calls = mock.calls.Shutdown - mock.lockShutdown.RUnlock() - return calls -} - -// SystemGetCudaDriverVersion calls SystemGetCudaDriverVersionFunc. -func (mock *InterfaceMock) SystemGetCudaDriverVersion() (int, Return) { - if mock.SystemGetCudaDriverVersionFunc == nil { - panic("InterfaceMock.SystemGetCudaDriverVersionFunc: method is nil but Interface.SystemGetCudaDriverVersion was just called") - } - callInfo := struct { - }{} - mock.lockSystemGetCudaDriverVersion.Lock() - mock.calls.SystemGetCudaDriverVersion = append(mock.calls.SystemGetCudaDriverVersion, callInfo) - mock.lockSystemGetCudaDriverVersion.Unlock() - return mock.SystemGetCudaDriverVersionFunc() -} - -// SystemGetCudaDriverVersionCalls gets all the calls that were made to SystemGetCudaDriverVersion. -// Check the length with: -// -// len(mockedInterface.SystemGetCudaDriverVersionCalls()) -func (mock *InterfaceMock) SystemGetCudaDriverVersionCalls() []struct { -} { - var calls []struct { - } - mock.lockSystemGetCudaDriverVersion.RLock() - calls = mock.calls.SystemGetCudaDriverVersion - mock.lockSystemGetCudaDriverVersion.RUnlock() - return calls -} - -// SystemGetDriverVersion calls SystemGetDriverVersionFunc. -func (mock *InterfaceMock) SystemGetDriverVersion() (string, Return) { - if mock.SystemGetDriverVersionFunc == nil { - panic("InterfaceMock.SystemGetDriverVersionFunc: method is nil but Interface.SystemGetDriverVersion was just called") - } - callInfo := struct { - }{} - mock.lockSystemGetDriverVersion.Lock() - mock.calls.SystemGetDriverVersion = append(mock.calls.SystemGetDriverVersion, callInfo) - mock.lockSystemGetDriverVersion.Unlock() - return mock.SystemGetDriverVersionFunc() -} - -// SystemGetDriverVersionCalls gets all the calls that were made to SystemGetDriverVersion. -// Check the length with: -// -// len(mockedInterface.SystemGetDriverVersionCalls()) -func (mock *InterfaceMock) SystemGetDriverVersionCalls() []struct { -} { - var calls []struct { - } - mock.lockSystemGetDriverVersion.RLock() - calls = mock.calls.SystemGetDriverVersion - mock.lockSystemGetDriverVersion.RUnlock() - return calls -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/return.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/return.go deleted file mode 100644 index 64cc1e19..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/return.go +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "fmt" - - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -// String returns the string representation of a Return -func (r Return) String() string { - return errorStringFunc(nvml.Return(r)) -} - -// Error returns the string representation of a Return -func (r Return) Error() string { - return errorStringFunc(nvml.Return(r)) -} - -// Assigned to nvml.ErrorString if the system nvml library is in use -var errorStringFunc = defaultErrorStringFunc - -var defaultErrorStringFunc = func(r nvml.Return) string { - switch Return(r) { - case SUCCESS: - return "SUCCESS" - case ERROR_UNINITIALIZED: - return "ERROR_UNINITIALIZED" - case ERROR_INVALID_ARGUMENT: - return "ERROR_INVALID_ARGUMENT" - case ERROR_NOT_SUPPORTED: - return "ERROR_NOT_SUPPORTED" - case ERROR_NO_PERMISSION: - return "ERROR_NO_PERMISSION" - case ERROR_ALREADY_INITIALIZED: - return "ERROR_ALREADY_INITIALIZED" - case ERROR_NOT_FOUND: - return "ERROR_NOT_FOUND" - case ERROR_INSUFFICIENT_SIZE: - return "ERROR_INSUFFICIENT_SIZE" - case ERROR_INSUFFICIENT_POWER: - return "ERROR_INSUFFICIENT_POWER" - case ERROR_DRIVER_NOT_LOADED: - return "ERROR_DRIVER_NOT_LOADED" - case ERROR_TIMEOUT: - return "ERROR_TIMEOUT" - case ERROR_IRQ_ISSUE: - return "ERROR_IRQ_ISSUE" - case ERROR_LIBRARY_NOT_FOUND: - return "ERROR_LIBRARY_NOT_FOUND" - case ERROR_FUNCTION_NOT_FOUND: - return "ERROR_FUNCTION_NOT_FOUND" - case ERROR_CORRUPTED_INFOROM: - return "ERROR_CORRUPTED_INFOROM" - case ERROR_GPU_IS_LOST: - return "ERROR_GPU_IS_LOST" - case ERROR_RESET_REQUIRED: - return "ERROR_RESET_REQUIRED" - case ERROR_OPERATING_SYSTEM: - return "ERROR_OPERATING_SYSTEM" - case ERROR_LIB_RM_VERSION_MISMATCH: - return "ERROR_LIB_RM_VERSION_MISMATCH" - case ERROR_IN_USE: - return "ERROR_IN_USE" - case ERROR_MEMORY: - return "ERROR_MEMORY" - case ERROR_NO_DATA: - return "ERROR_NO_DATA" - case ERROR_VGPU_ECC_NOT_SUPPORTED: - return "ERROR_VGPU_ECC_NOT_SUPPORTED" - case ERROR_INSUFFICIENT_RESOURCES: - return "ERROR_INSUFFICIENT_RESOURCES" - case ERROR_UNKNOWN: - return "ERROR_UNKNOWN" - default: - return fmt.Sprintf("Unknown return value: %d", r) - } -} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go deleted file mode 100644 index d5150972..00000000 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvml/types.go +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package nvml - -import ( - "github.com/NVIDIA/go-nvml/pkg/nvml" -) - -// Interface defines the functions implemented by an NVML library -// -//go:generate moq -out nvml_mock.go . Interface -type Interface interface { - DeviceGetCount() (int, Return) - DeviceGetHandleByIndex(Index int) (Device, Return) - DeviceGetHandleByUUID(UUID string) (Device, Return) - ErrorString(r Return) string - EventSetCreate() (EventSet, Return) - Init() Return - Lookup(string) error - Shutdown() Return - SystemGetCudaDriverVersion() (int, Return) - SystemGetDriverVersion() (string, Return) -} - -// Device defines the functions implemented by an NVML device -// -//go:generate moq -out device_mock.go . Device -type Device interface { - CreateGpuInstanceWithPlacement(*GpuInstanceProfileInfo, *GpuInstancePlacement) (GpuInstance, Return) - GetArchitecture() (DeviceArchitecture, Return) - GetAttributes() (DeviceAttributes, Return) - GetBrand() (BrandType, Return) - GetComputeInstanceId() (int, Return) - GetCudaComputeCapability() (int, int, Return) - GetDeviceHandleFromMigDeviceHandle() (Device, Return) - GetGpuInstanceById(ID int) (GpuInstance, Return) - GetGpuInstanceId() (int, Return) - GetGpuInstancePossiblePlacements(*GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) - GetGpuInstanceProfileInfo(Profile int) (GpuInstanceProfileInfo, Return) - GetGpuInstances(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return) - GetIndex() (int, Return) - GetMaxMigDeviceCount() (int, Return) - GetMemoryInfo() (Memory, Return) - GetMigDeviceHandleByIndex(Index int) (Device, Return) - GetMigMode() (int, int, Return) - GetMinorNumber() (int, Return) - GetName() (string, Return) - GetNvLinkRemotePciInfo(int) (PciInfo, Return) - GetNvLinkState(int) (EnableState, Return) - GetPciInfo() (PciInfo, Return) - GetSupportedEventTypes() (uint64, Return) - GetTopologyCommonAncestor(Device) (GpuTopologyLevel, Return) - GetUUID() (string, Return) - IsMigDeviceHandle() (bool, Return) - RegisterEvents(uint64, EventSet) Return - SetComputeMode(ComputeMode) Return - SetMigMode(Mode int) (Return, Return) - // nvmlDeviceHandle returns a pointer to the underlying NVML device. - nvmlDeviceHandle() *nvml.Device -} - -// GpuInstance defines the functions implemented by a GpuInstance -// -//go:generate moq -out gi_mock.go . GpuInstance -type GpuInstance interface { - CreateComputeInstance(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return) - Destroy() Return - GetComputeInstanceById(ID int) (ComputeInstance, Return) - GetComputeInstanceProfileInfo(Profile int, EngProfile int) (ComputeInstanceProfileInfo, Return) - GetComputeInstances(Info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) - GetInfo() (GpuInstanceInfo, Return) -} - -// ComputeInstance defines the functions implemented by a ComputeInstance -// -//go:generate moq -out ci_mock.go . ComputeInstance -type ComputeInstance interface { - Destroy() Return - GetInfo() (ComputeInstanceInfo, Return) -} - -// GpuInstanceInfo holds info about a GPU Instance -type GpuInstanceInfo struct { - Device Device - Id uint32 - ProfileId uint32 - Placement GpuInstancePlacement -} - -// ComputeInstanceInfo holds info about a Compute Instance -type ComputeInstanceInfo struct { - Device Device - GpuInstance GpuInstance - Id uint32 - ProfileId uint32 - Placement ComputeInstancePlacement -} - -// EventData defines NVML event Data -type EventData struct { - Device Device - EventType uint64 - EventData uint64 - GpuInstanceId uint32 - ComputeInstanceId uint32 -} - -// EventSet defines NVML event Data -type EventSet nvml.EventSet - -// Return defines an NVML return type -type Return nvml.Return - -// Memory holds info about GPU device memory -type Memory nvml.Memory - -// PciInfo holds info about the PCI connections of a GPU dvice -type PciInfo nvml.PciInfo - -// GpuInstanceProfileInfo holds info about a GPU Instance Profile -type GpuInstanceProfileInfo nvml.GpuInstanceProfileInfo - -// GpuInstancePlacement holds placement info about a GPU Instance -type GpuInstancePlacement nvml.GpuInstancePlacement - -// ComputeInstanceProfileInfo holds info about a Compute Instance Profile -type ComputeInstanceProfileInfo nvml.ComputeInstanceProfileInfo - -// ComputeInstancePlacement holds placement info about a Compute Instance -type ComputeInstancePlacement nvml.ComputeInstancePlacement - -// DeviceAttributes stores information about MIG devices -type DeviceAttributes nvml.DeviceAttributes - -// DeviceArchitecture represents the hardware architecture of a GPU device -type DeviceArchitecture nvml.DeviceArchitecture - -// BrandType represents the brand of a GPU device -type BrandType nvml.BrandType - -// GpuTopologyLevel represents level relationships within a system between two GPUs -type GpuTopologyLevel nvml.GpuTopologyLevel - -// EnableState represents a generic enable/disable enum -type EnableState nvml.EnableState - -// ComputeMode represents the compute mode for a device -type ComputeMode nvml.ComputeMode diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes/bytes.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes/bytes.go index 7788a1fb..04fb4aa9 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes/bytes.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes/bytes.go @@ -21,12 +21,12 @@ import ( "unsafe" ) -// Raw returns just the bytes without any assumptions about layout +// Raw returns just the bytes without any assumptions about layout. type Raw interface { Raw() *[]byte } -// Reader used to read various data sizes in the byte array +// Reader used to read various data sizes in the byte array. type Reader interface { Read8(pos int) uint8 Read16(pos int) uint16 @@ -35,7 +35,7 @@ type Reader interface { Len() int } -// Writer used to write various sizes of data in the byte array +// Writer used to write various sizes of data in the byte array. type Writer interface { Write8(pos int, value uint8) Write16(pos int, value uint16) @@ -44,7 +44,7 @@ type Writer interface { Len() int } -// Bytes object for manipulating arbitrary byte arrays +// Bytes object for manipulating arbitrary byte arrays. type Bytes interface { Raw Reader @@ -70,12 +70,12 @@ func init() { } } -// New raw bytearray +// New raw bytearray. func New(data *[]byte) Bytes { return (*native)(data) } -// NewLittleEndian little endian ordering of bytes +// NewLittleEndian little endian ordering of bytes. func NewLittleEndian(data *[]byte) Bytes { if nativeByteOrder == binary.LittleEndian { return (*native)(data) @@ -84,7 +84,7 @@ func NewLittleEndian(data *[]byte) Bytes { return (*swapbo)(data) } -// NewBigEndian big endian ordering of bytes +// NewBigEndian big endian ordering of bytes. func NewBigEndian(data *[]byte) Bytes { if nativeByteOrder == binary.BigEndian { return (*native)(data) diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/config.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/config.go index e25e72f6..397c8650 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/config.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/config.go @@ -24,24 +24,24 @@ import ( ) const ( - // PCICfgSpaceStandardSize represents the size in bytes of the standard config space + // PCICfgSpaceStandardSize represents the size in bytes of the standard config space. PCICfgSpaceStandardSize = 256 - // PCICfgSpaceExtendedSize represents the size in bytes of the extended config space + // PCICfgSpaceExtendedSize represents the size in bytes of the extended config space. PCICfgSpaceExtendedSize = 4096 - // PCICapabilityListPointer represents offset for the capability list pointer + // PCICapabilityListPointer represents offset for the capability list pointer. PCICapabilityListPointer = 0x34 - // PCIStatusCapabilityList represents the status register bit which indicates capability list support + // PCIStatusCapabilityList represents the status register bit which indicates capability list support. PCIStatusCapabilityList = 0x10 - // PCIStatusBytePosition represents the position of the status register + // PCIStatusBytePosition represents the position of the status register. PCIStatusBytePosition = 0x06 ) -// ConfigSpace PCI configuration space (standard extended) file path +// ConfigSpace PCI configuration space (standard extended) file path. type ConfigSpace struct { Path string } -// ConfigSpaceIO Interface for reading and writing raw and preconfigured values +// ConfigSpaceIO Interface for reading and writing raw and preconfigured values. type ConfigSpaceIO interface { bytes.Bytes GetVendorID() uint16 @@ -53,18 +53,18 @@ type configSpaceIO struct { bytes.Bytes } -// PCIStandardCapability standard PCI config space +// PCIStandardCapability standard PCI config space. type PCIStandardCapability struct { bytes.Bytes } -// PCIExtendedCapability extended PCI config space +// PCIExtendedCapability extended PCI config space. type PCIExtendedCapability struct { bytes.Bytes Version uint8 } -// PCICapabilities combines the standard and extended config space +// PCICapabilities combines the standard and extended config space. type PCICapabilities struct { Standard map[uint8]*PCIStandardCapability Extended map[uint16]*PCIExtendedCapability diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mlxpci.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mlxpci.go index 62937d7f..ddf7d19f 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mlxpci.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mlxpci.go @@ -22,15 +22,15 @@ import ( ) const ( - // PCIMellanoxVendorID represents PCI vendor id for Mellanox + // PCIMellanoxVendorID represents PCI vendor id for Mellanox. PCIMellanoxVendorID uint16 = 0x15b3 - // PCINetworkControllerClass represents the PCI class for network controllers + // PCINetworkControllerClass represents the PCI class for network controllers. PCINetworkControllerClass uint32 = 0x020000 - // PCIBridgeClass represents the PCI class for network controllers + // PCIBridgeClass represents the PCI class for network controllers. PCIBridgeClass uint32 = 0x060400 ) -// GetNetworkControllers returns all Mellanox Network Controller PCI devices on the system +// GetNetworkControllers returns all Mellanox Network Controller PCI devices on the system. func (p *nvpci) GetNetworkControllers() ([]*NvidiaPCIDevice, error) { devices, err := p.GetAllDevices() if err != nil { @@ -47,7 +47,7 @@ func (p *nvpci) GetNetworkControllers() ([]*NvidiaPCIDevice, error) { return filtered, nil } -// GetPciBridges retrieves all Mellanox PCI(e) Bridges +// GetPciBridges retrieves all Mellanox PCI(e) Bridges. func (p *nvpci) GetPciBridges() ([]*NvidiaPCIDevice, error) { devices, err := p.GetAllDevices() if err != nil { @@ -64,17 +64,17 @@ func (p *nvpci) GetPciBridges() ([]*NvidiaPCIDevice, error) { return filtered, nil } -// IsNetworkController if class == 0x300 +// IsNetworkController if class == 0x300. func (d *NvidiaPCIDevice) IsNetworkController() bool { return d.Class == PCINetworkControllerClass } -// IsPciBridge if class == 0x0604 +// IsPciBridge if class == 0x0604. func (d *NvidiaPCIDevice) IsPciBridge() bool { return d.Class == PCIBridgeClass } -// IsDPU returns if a device is a DPU +// IsDPU returns if a device is a DPU. func (d *NvidiaPCIDevice) IsDPU() bool { if !strings.Contains(d.DeviceName, "BlueField") { return false @@ -87,7 +87,7 @@ func (d *NvidiaPCIDevice) IsDPU() bool { return false } -// GetDPUs returns all Mellanox DPU devices on the system +// GetDPUs returns all Mellanox DPU devices on the system. func (p *nvpci) GetDPUs() ([]*NvidiaPCIDevice, error) { devices, err := p.GetNetworkControllers() if err != nil { diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mmio.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mmio.go index 1535fa04..88dd7ddf 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mmio.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mmio.go @@ -25,7 +25,7 @@ import ( "github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes" ) -// Mmio memory map a region +// Mmio memory map a region. type Mmio interface { bytes.Raw bytes.Reader @@ -84,12 +84,12 @@ func open(path string, offset int, size int, flags int) (Mmio, error) { return &mmio{bytes.New(&mmap)}, nil } -// OpenRO open region readonly +// OpenRO open region readonly. func OpenRO(path string, offset int, size int) (Mmio, error) { return open(path, offset, size, os.O_RDONLY) } -// OpenRW open region read write +// OpenRW open region read write. func OpenRW(path string, offset int, size int) (Mmio, error) { return open(path, offset, size, os.O_RDWR) } diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mock.go index 57151b3f..da3074c1 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mock.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio/mock.go @@ -48,18 +48,21 @@ func mockOpen(source *[]byte, offset int, size int, rw bool) (Mmio, error) { return m, nil } -// MockOpenRO open read only +// MockOpenRO open read only. func MockOpenRO(source *[]byte, offset int, size int) (Mmio, error) { return mockOpen(source, offset, size, false) } -// MockOpenRW open read write +// MockOpenRW open read write. func MockOpenRW(source *[]byte, offset int, size int) (Mmio, error) { return mockOpen(source, offset, size, true) } func (m *mockMmio) Close() error { - m = &mockMmio{} + m.Bytes = nil + m.source = nil + m.offset = 0 + m.rw = false return nil } diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mock.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mock.go index e4227121..9b3d6e2a 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mock.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/mock.go @@ -20,18 +20,20 @@ import ( "fmt" "os" "path/filepath" + "regexp" + "strconv" "github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes" ) -// MockNvpci mock pci device +// MockNvpci mock pci device. type MockNvpci struct { *nvpci } var _ Interface = (*MockNvpci)(nil) -// NewMockNvpci create new mock PCI and remove old devices +// NewMockNvpci create new mock PCI and remove old devices. func NewMockNvpci() (mock *MockNvpci, rerr error) { rootDir, err := os.MkdirTemp(os.TempDir(), "") if err != nil { @@ -50,69 +52,119 @@ func NewMockNvpci() (mock *MockNvpci, rerr error) { return mock, nil } -// Cleanup remove the mocked PCI devices root folder +// Cleanup remove the mocked PCI devices root folder. func (m *MockNvpci) Cleanup() { os.RemoveAll(m.pciDevicesRoot) } -// AddMockA100 Create an A100 like GPU mock device -func (m *MockNvpci) AddMockA100(address string, numaNode int) error { +func validatePCIAddress(addr string) error { + r := regexp.MustCompile(`0{4}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9]`) + if !r.Match([]byte(addr)) { + return fmt.Errorf(`invalid PCI address should match 0{4}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9]: %s`, addr) + } + + return nil +} + +// AddMockA100 Create an A100 like GPU mock device. +func (m *MockNvpci) AddMockA100(address string, numaNode int, sriov *SriovInfo) error { + err := validatePCIAddress(address) + if err != nil { + return err + } + deviceDir := filepath.Join(m.pciDevicesRoot, address) - err := os.MkdirAll(deviceDir, 0755) + err = os.MkdirAll(deviceDir, 0755) if err != nil { return err } - vendor, err := os.Create(filepath.Join(deviceDir, "vendor")) + err = createNVIDIAgpuFiles(deviceDir) if err != nil { return err } - _, err = vendor.WriteString(fmt.Sprintf("0x%x", PCINvidiaVendorID)) + + iommuGroup := 20 + _, err = os.Create(filepath.Join(deviceDir, strconv.Itoa(iommuGroup))) + if err != nil { + return err + } + err = os.Symlink(filepath.Join(deviceDir, strconv.Itoa(iommuGroup)), filepath.Join(deviceDir, "iommu_group")) if err != nil { return err } - class, err := os.Create(filepath.Join(deviceDir, "class")) + numa, err := os.Create(filepath.Join(deviceDir, "numa_node")) if err != nil { return err } - _, err = class.WriteString(fmt.Sprintf("0x%x", PCI3dControllerClass)) + _, err = numa.WriteString(fmt.Sprintf("%v", numaNode)) if err != nil { return err } - device, err := os.Create(filepath.Join(deviceDir, "device")) + if sriov != nil && sriov.PhysicalFunction != nil { + totalVFs, err := os.Create(filepath.Join(deviceDir, "sriov_totalvfs")) + if err != nil { + return err + } + _, err = fmt.Fprintf(totalVFs, "%d", sriov.PhysicalFunction.TotalVFs) + if err != nil { + return err + } + + numVFs, err := os.Create(filepath.Join(deviceDir, "sriov_numvfs")) + if err != nil { + return err + } + _, err = fmt.Fprintf(numVFs, "%d", sriov.PhysicalFunction.NumVFs) + if err != nil { + return err + } + for i := 1; i <= int(sriov.PhysicalFunction.NumVFs); i++ { + err = m.createVf(address, i, iommuGroup, numaNode) + if err != nil { + return err + } + } + } + + return nil +} + +func createNVIDIAgpuFiles(deviceDir string) error { + vendor, err := os.Create(filepath.Join(deviceDir, "vendor")) if err != nil { return err } - _, err = device.WriteString("0x20bf") + _, err = vendor.WriteString(fmt.Sprintf("0x%x", PCINvidiaVendorID)) if err != nil { return err } - _, err = os.Create(filepath.Join(deviceDir, "nvidia")) + class, err := os.Create(filepath.Join(deviceDir, "class")) if err != nil { return err } - err = os.Symlink(filepath.Join(deviceDir, "nvidia"), filepath.Join(deviceDir, "driver")) + _, err = class.WriteString(fmt.Sprintf("0x%x", PCI3dControllerClass)) if err != nil { return err } - _, err = os.Create(filepath.Join(deviceDir, "20")) + device, err := os.Create(filepath.Join(deviceDir, "device")) if err != nil { return err } - err = os.Symlink(filepath.Join(deviceDir, "20"), filepath.Join(deviceDir, "iommu_group")) + _, err = device.WriteString("0x20bf") if err != nil { return err } - numa, err := os.Create(filepath.Join(deviceDir, "numa_node")) + _, err = os.Create(filepath.Join(deviceDir, "nvidia")) if err != nil { return err } - _, err = numa.WriteString(fmt.Sprintf("%v", numaNode)) + err = os.Symlink(filepath.Join(deviceDir, "nvidia"), filepath.Join(deviceDir, "driver")) if err != nil { return err } @@ -156,3 +208,53 @@ func (m *MockNvpci) AddMockA100(address string, numaNode int) error { return nil } + +func (m *MockNvpci) createVf(pfAddress string, id, iommu_group, numaNode int) error { + functionID := pfAddress[len(pfAddress)-1] + // we are verifying the last character of pfAddress is integer. + functionNumber, err := strconv.Atoi(string(functionID)) + if err != nil { + return fmt.Errorf("can't conver physical function pci address function number %s to integer: %v", string(functionID), err) + } + + vfFunctionNumber := functionNumber + id + vfAddress := pfAddress[:len(pfAddress)-1] + strconv.Itoa(vfFunctionNumber) + + deviceDir := filepath.Join(m.pciDevicesRoot, vfAddress) + err = os.MkdirAll(deviceDir, 0755) + if err != nil { + return err + } + + err = createNVIDIAgpuFiles(deviceDir) + if err != nil { + return err + } + + vfIommuGroup := strconv.Itoa(iommu_group + id) + + _, err = os.Create(filepath.Join(deviceDir, vfIommuGroup)) + if err != nil { + return err + } + err = os.Symlink(filepath.Join(deviceDir, vfIommuGroup), filepath.Join(deviceDir, "iommu_group")) + if err != nil { + return err + } + + numa, err := os.Create(filepath.Join(deviceDir, "numa_node")) + if err != nil { + return err + } + _, err = numa.WriteString(fmt.Sprintf("%v", numaNode)) + if err != nil { + return err + } + + err = os.Symlink(filepath.Join(m.pciDevicesRoot, pfAddress), filepath.Join(deviceDir, "physfn")) + if err != nil { + return err + } + + return nil +} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go index 5210ff50..6ff197b1 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/nvpci.go @@ -29,23 +29,23 @@ import ( ) const ( - // PCIDevicesRoot represents base path for all pci devices under sysfs + // PCIDevicesRoot represents base path for all pci devices under sysfs. PCIDevicesRoot = "/sys/bus/pci/devices" - // PCINvidiaVendorID represents PCI vendor id for NVIDIA + // PCINvidiaVendorID represents PCI vendor id for NVIDIA. PCINvidiaVendorID uint16 = 0x10de - // PCIVgaControllerClass represents the PCI class for VGA Controllers + // PCIVgaControllerClass represents the PCI class for VGA Controllers. PCIVgaControllerClass uint32 = 0x030000 - // PCI3dControllerClass represents the PCI class for 3D Graphics accellerators + // PCI3dControllerClass represents the PCI class for 3D Graphics accellerators. PCI3dControllerClass uint32 = 0x030200 - // PCINvSwitchClass represents the PCI class for NVSwitches + // PCINvSwitchClass represents the PCI class for NVSwitches. PCINvSwitchClass uint32 = 0x068000 - // UnknownDeviceString is the device name to set for devices not found in the PCI database + // UnknownDeviceString is the device name to set for devices not found in the PCI database. UnknownDeviceString = "UNKNOWN_DEVICE" - // UnknownClassString is the class name to set for devices not found in the PCI database + // UnknownClassString is the class name to set for devices not found in the PCI database. UnknownClassString = "UNKNOWN_CLASS" ) -// Interface allows us to get a list of all NVIDIA PCI devices +// Interface allows us to get a list of all NVIDIA PCI devices. type Interface interface { GetAllDevices() ([]*NvidiaPCIDevice, error) Get3DControllers() ([]*NvidiaPCIDevice, error) @@ -59,10 +59,10 @@ type Interface interface { GetDPUs() ([]*NvidiaPCIDevice, error) } -// MemoryResources a more human readable handle +// MemoryResources a more human readable handle. type MemoryResources map[int]*MemoryResource -// ResourceInterface exposes some higher level functions of resources +// ResourceInterface exposes some higher level functions of resources. type ResourceInterface interface { GetTotalAddressableMemory(bool) (uint64, uint64) } @@ -76,7 +76,33 @@ type nvpci struct { var _ Interface = (*nvpci)(nil) var _ ResourceInterface = (*MemoryResources)(nil) -// NvidiaPCIDevice represents a PCI device for an NVIDIA product +// SriovInfo indicates whether device is VF/PF for SRIOV capable devices. +// Only one should be set at any given time. +type SriovInfo struct { + PhysicalFunction *SriovPhysicalFunction + VirtualFunction *SriovVirtualFunction +} + +// SriovPhysicalFunction stores info about SRIOV physical function. +type SriovPhysicalFunction struct { + TotalVFs uint64 + NumVFs uint64 +} + +// SriovVirtualFunction keeps data about SRIOV virtual function. +type SriovVirtualFunction struct { + PhysicalFunction *NvidiaPCIDevice +} + +func (s *SriovInfo) IsPF() bool { + return s != nil && s.PhysicalFunction != nil +} + +func (s *SriovInfo) IsVF() bool { + return s != nil && s.VirtualFunction != nil +} + +// NvidiaPCIDevice represents a PCI device for an NVIDIA product. type NvidiaPCIDevice struct { Path string Address string @@ -90,37 +116,37 @@ type NvidiaPCIDevice struct { NumaNode int Config *ConfigSpace Resources MemoryResources - IsVF bool + SriovInfo SriovInfo } -// IsVGAController if class == 0x300 +// IsVGAController if class == 0x300. func (d *NvidiaPCIDevice) IsVGAController() bool { return d.Class == PCIVgaControllerClass } -// Is3DController if class == 0x302 +// Is3DController if class == 0x302. func (d *NvidiaPCIDevice) Is3DController() bool { return d.Class == PCI3dControllerClass } -// IsNVSwitch if class == 0x068 +// IsNVSwitch if class == 0x068. func (d *NvidiaPCIDevice) IsNVSwitch() bool { return d.Class == PCINvSwitchClass } -// IsGPU either VGA for older cards or 3D for newer +// IsGPU either VGA for older cards or 3D for newer. func (d *NvidiaPCIDevice) IsGPU() bool { return d.IsVGAController() || d.Is3DController() } // IsResetAvailable some devices can be reset without rebooting, -// check if applicable +// check if applicable. func (d *NvidiaPCIDevice) IsResetAvailable() bool { _, err := os.Stat(path.Join(d.Path, "reset")) return err == nil } -// Reset perform a reset to apply a new configuration at HW level +// Reset perform a reset to apply a new configuration at HW level. func (d *NvidiaPCIDevice) Reset() error { err := os.WriteFile(path.Join(d.Path, "reset"), []byte("1"), 0) if err != nil { @@ -129,7 +155,7 @@ func (d *NvidiaPCIDevice) Reset() error { return nil } -// New interface that allows us to get a list of all NVIDIA PCI devices +// New interface that allows us to get a list of all NVIDIA PCI devices. func New(opts ...Option) Interface { n := &nvpci{} for _, opt := range opts { @@ -144,10 +170,10 @@ func New(opts ...Option) Interface { return n } -// Option defines a function for passing options to the New() call +// Option defines a function for passing options to the New() call. type Option func(*nvpci) -// WithLogger provides an Option to set the logger for the library +// WithLogger provides an Option to set the logger for the library. func WithLogger(logger logger) Option { return func(n *nvpci) { n.logger = logger @@ -170,7 +196,7 @@ func WithPCIDatabasePath(path string) Option { } } -// GetAllDevices returns all Nvidia PCI devices on the system +// GetAllDevices returns all Nvidia PCI devices on the system. func (p *nvpci) GetAllDevices() ([]*NvidiaPCIDevice, error) { deviceDirs, err := os.ReadDir(p.pciDevicesRoot) if err != nil { @@ -178,9 +204,11 @@ func (p *nvpci) GetAllDevices() ([]*NvidiaPCIDevice, error) { } var nvdevices []*NvidiaPCIDevice + // Cache devices for each GetAllDevices invocation to speed things up. + cache := make(map[string]*NvidiaPCIDevice) for _, deviceDir := range deviceDirs { deviceAddress := deviceDir.Name() - nvdevice, err := p.GetGPUByPciBusID(deviceAddress) + nvdevice, err := p.getGPUByPciBusID(deviceAddress, cache) if err != nil { return nil, fmt.Errorf("error constructing NVIDIA PCI device %s: %v", deviceAddress, err) } @@ -204,8 +232,18 @@ func (p *nvpci) GetAllDevices() ([]*NvidiaPCIDevice, error) { return nvdevices, nil } -// GetGPUByPciBusID constructs an NvidiaPCIDevice for the specified address (PCI Bus ID) +// GetGPUByPciBusID constructs an NvidiaPCIDevice for the specified address (PCI Bus ID). func (p *nvpci) GetGPUByPciBusID(address string) (*NvidiaPCIDevice, error) { + // Pass nil as to force reading device information from sysfs. + return p.getGPUByPciBusID(address, nil) +} + +func (p *nvpci) getGPUByPciBusID(address string, cache map[string]*NvidiaPCIDevice) (*NvidiaPCIDevice, error) { + if cache != nil { + if pciDevice, exists := cache[address]; exists { + return pciDevice, nil + } + } devicePath := filepath.Join(p.pciDevicesRoot, address) vendor, err := os.ReadFile(path.Join(devicePath, "vendor")) @@ -265,16 +303,6 @@ func (p *nvpci) GetGPUByPciBusID(address string) (*NvidiaPCIDevice, error) { return nil, fmt.Errorf("unable to detect iommu_group for %s: %v", address, err) } - // device is a virtual function (VF) if "physfn" symlink exists - var isVF bool - _, err = filepath.EvalSymlinks(path.Join(devicePath, "physfn")) - if err == nil { - isVF = true - } - if err != nil && !os.IsNotExist(err) { - return nil, fmt.Errorf("unable to resolve %s: %v", path.Join(devicePath, "physfn"), err) - } - numa, err := os.ReadFile(path.Join(devicePath, "numa_node")) if err != nil { return nil, fmt.Errorf("unable to read PCI NUMA node for %s: %v", address, err) @@ -328,6 +356,28 @@ func (p *nvpci) GetGPUByPciBusID(address string) (*NvidiaPCIDevice, error) { className = UnknownClassString } + var sriovInfo SriovInfo + // Device is a virtual function (VF) if "physfn" symlink exists. + physFnAddress, err := filepath.EvalSymlinks(path.Join(devicePath, "physfn")) + if err == nil { + physFn, err := p.getGPUByPciBusID(filepath.Base(physFnAddress), cache) + if err != nil { + return nil, fmt.Errorf("unable to detect physfn for %s: %v", address, err) + } + sriovInfo = SriovInfo{ + VirtualFunction: &SriovVirtualFunction{ + PhysicalFunction: physFn, + }, + } + } else if os.IsNotExist(err) { + sriovInfo, err = p.getSriovInfoForPhysicalFunction(devicePath) + if err != nil { + return nil, fmt.Errorf("unable to read SRIOV physical function details for %s: %v", devicePath, err) + } + } else { + return nil, fmt.Errorf("unable to read %s: %v", path.Join(devicePath, "physfn"), err) + } + nvdevice := &NvidiaPCIDevice{ Path: devicePath, Address: address, @@ -339,15 +389,20 @@ func (p *nvpci) GetGPUByPciBusID(address string) (*NvidiaPCIDevice, error) { NumaNode: int(numaNode), Config: config, Resources: resources, - IsVF: isVF, DeviceName: deviceName, ClassName: className, + SriovInfo: sriovInfo, + } + + // Cache physical functions only as VF can't be a root device. + if cache != nil && sriovInfo.IsPF() { + cache[address] = nvdevice } return nvdevice, nil } -// Get3DControllers returns all NVIDIA 3D Controller PCI devices on the system +// Get3DControllers returns all NVIDIA 3D Controller PCI devices on the system. func (p *nvpci) Get3DControllers() ([]*NvidiaPCIDevice, error) { devices, err := p.GetAllDevices() if err != nil { @@ -364,7 +419,7 @@ func (p *nvpci) Get3DControllers() ([]*NvidiaPCIDevice, error) { return filtered, nil } -// GetVGAControllers returns all NVIDIA VGA Controller PCI devices on the system +// GetVGAControllers returns all NVIDIA VGA Controller PCI devices on the system. func (p *nvpci) GetVGAControllers() ([]*NvidiaPCIDevice, error) { devices, err := p.GetAllDevices() if err != nil { @@ -381,7 +436,7 @@ func (p *nvpci) GetVGAControllers() ([]*NvidiaPCIDevice, error) { return filtered, nil } -// GetNVSwitches returns all NVIDIA NVSwitch PCI devices on the system +// GetNVSwitches returns all NVIDIA NVSwitch PCI devices on the system. func (p *nvpci) GetNVSwitches() ([]*NvidiaPCIDevice, error) { devices, err := p.GetAllDevices() if err != nil { @@ -398,7 +453,7 @@ func (p *nvpci) GetNVSwitches() ([]*NvidiaPCIDevice, error) { return filtered, nil } -// GetGPUs returns all NVIDIA GPU devices on the system +// GetGPUs returns all NVIDIA GPU devices on the system. func (p *nvpci) GetGPUs() ([]*NvidiaPCIDevice, error) { devices, err := p.GetAllDevices() if err != nil { @@ -407,7 +462,7 @@ func (p *nvpci) GetGPUs() ([]*NvidiaPCIDevice, error) { var filtered []*NvidiaPCIDevice for _, d := range devices { - if d.IsGPU() && !d.IsVF { + if d.IsGPU() && !d.SriovInfo.IsVF() { filtered = append(filtered, d) } } @@ -415,7 +470,7 @@ func (p *nvpci) GetGPUs() ([]*NvidiaPCIDevice, error) { return filtered, nil } -// GetGPUByIndex returns an NVIDIA GPU device at a particular index +// GetGPUByIndex returns an NVIDIA GPU device at a particular index. func (p *nvpci) GetGPUByIndex(i int) (*NvidiaPCIDevice, error) { gpus, err := p.GetGPUs() if err != nil { @@ -428,3 +483,41 @@ func (p *nvpci) GetGPUByIndex(i int) (*NvidiaPCIDevice, error) { return gpus[i], nil } + +func (p *nvpci) getSriovInfoForPhysicalFunction(devicePath string) (sriovInfo SriovInfo, err error) { + totalVfsPath := filepath.Join(devicePath, "sriov_totalvfs") + numVfsPath := filepath.Join(devicePath, "sriov_numvfs") + + // No file for sriov_totalvfs exists? Not an SRIOV device, return nil + _, err = os.Stat(totalVfsPath) + if err != nil && os.IsNotExist(err) { + return sriovInfo, nil + } + sriovTotalVfs, err := os.ReadFile(totalVfsPath) + if err != nil { + return sriovInfo, fmt.Errorf("unable to read sriov_totalvfs: %v", err) + } + totalVfsStr := strings.TrimSpace(string(sriovTotalVfs)) + totalVfsInt, err := strconv.ParseUint(totalVfsStr, 10, 16) + if err != nil { + return sriovInfo, fmt.Errorf("unable to convert sriov_totalvfs to uint64: %v", err) + } + + sriovNumVfs, err := os.ReadFile(numVfsPath) + if err != nil { + return sriovInfo, fmt.Errorf("unable to read sriov_numvfs for: %v", err) + } + numVfsStr := strings.TrimSpace(string(sriovNumVfs)) + numVfsInt, err := strconv.ParseUint(numVfsStr, 10, 16) + if err != nil { + return sriovInfo, fmt.Errorf("unable to convert sriov_numvfs to uint64: %v", err) + } + + sriovInfo = SriovInfo{ + PhysicalFunction: &SriovPhysicalFunction{ + TotalVFs: totalVfsInt, + NumVFs: numVfsInt, + }, + } + return sriovInfo, nil +} diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/resources.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/resources.go index 6c6e53ee..b3b7d315 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/resources.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/nvpci/resources.go @@ -29,7 +29,7 @@ const ( pmcBigEndian = 0x01000001 ) -// MemoryResource represents a mmio region +// MemoryResource represents a mmio region. type MemoryResource struct { Start uintptr End uintptr @@ -37,7 +37,7 @@ type MemoryResource struct { Path string } -// OpenRW read write mmio region +// OpenRW read write mmio region. func (mr *MemoryResource) OpenRW() (mmio.Mmio, error) { rw, err := mmio.OpenRW(mr.Path, 0, int(mr.End-mr.Start+1)) if err != nil { @@ -52,7 +52,7 @@ func (mr *MemoryResource) OpenRW() (mmio.Mmio, error) { return nil, fmt.Errorf("unknown endianness for mmio: %v", err) } -// OpenRO read only mmio region +// OpenRO read only mmio region. func (mr *MemoryResource) OpenRO() (mmio.Mmio, error) { ro, err := mmio.OpenRO(mr.Path, 0, int(mr.End-mr.Start+1)) if err != nil { @@ -67,7 +67,7 @@ func (mr *MemoryResource) OpenRO() (mmio.Mmio, error) { return nil, fmt.Errorf("unknown endianness for mmio: %v", err) } -// From Bit Twiddling Hacks, great resource for all low level bit manipulations +// From Bit Twiddling Hacks, great resource for all low level bit manipulations. func calcNextPowerOf2(n uint64) uint64 { n-- n |= n >> 1 @@ -83,7 +83,7 @@ func calcNextPowerOf2(n uint64) uint64 { // GetTotalAddressableMemory will accumulate the 32bit and 64bit memory windows // of each BAR and round the value if needed to the next power of 2; first -// return value is the accumulated 32bit addresable memory size the second one +// return value is the accumulated 32bit addressable memory size the second one // is the accumulated 64bit addressable memory size in bytes. These values are // needed to configure virtualized environments. func (mrs MemoryResources) GetTotalAddressableMemory(roundUp bool) (uint64, uint64) { diff --git a/vendor/github.com/NVIDIA/go-nvlib/pkg/pciids/pciids.go b/vendor/github.com/NVIDIA/go-nvlib/pkg/pciids/pciids.go index 5f25c004..343df08d 100644 --- a/vendor/github.com/NVIDIA/go-nvlib/pkg/pciids/pciids.go +++ b/vendor/github.com/NVIDIA/go-nvlib/pkg/pciids/pciids.go @@ -11,42 +11,42 @@ import ( "strings" ) -// token what the Lexer retruns +// token what the Lexer retruns. type token int const ( - // ILLEGAL a token which the Lexer does not understand + // ILLEGAL a token which the Lexer does not understand. ILLEGAL token = iota - // EOF end of file + // EOF end of file. EOF - // WS whitespace + // WS whitespace. WS - // NEWLINE '\n' + // NEWLINE '\n'. NEWLINE - // COMMENT '# something' + // COMMENT '# something'. COMMENT - // VENDOR PCI vendor + // VENDOR PCI vendor. VENDOR - // SUBVENDOR PCI subvendor + // SUBVENDOR PCI subvendor. SUBVENDOR - // DEVICE PCI device + // DEVICE PCI device. DEVICE - // CLASS PCI class + // CLASS PCI class. CLASS - // SUBCLASS PCI subclass + // SUBCLASS PCI subclass. SUBCLASS - // PROGIF PCI programming interface + // PROGIF PCI programming interface. PROGIF ) -// literal values from the Lexer +// literal values from the Lexer. type literal struct { ID string name string SubName string } -// scanner a lexical scanner +// scanner a lexical scanner. type scanner struct { r *bufio.Reader isVendor bool @@ -58,7 +58,7 @@ func newScanner(r io.Reader) *scanner { } // Since the pci.ids is line base we're consuming a whole line rather then only -// a single rune/char +// a single rune/char. func (s *scanner) readline() []byte { ln, err := s.r.ReadBytes('\n') if err == io.EOF { @@ -107,7 +107,7 @@ func isSubVendor(ln []byte) bool { return isLeadingTwoTabs(ln) } func isDevice(ln []byte) bool { return isLeadingOneTab(ln) } func isNewline(ln []byte) bool { return (ln[0] == '\n') } -// List of known device classes, subclasses and programming interfaces +// List of known device classes, subclasses and programming interfaces. func isClass(ln []byte) bool { return (ln[0] == 'C') } func isProgIf(ln []byte) bool { return isLeadingTwoTabs(ln) } func isSubClass(ln []byte) bool { return isLeadingOneTab(ln) } @@ -162,7 +162,7 @@ func (s *scanner) scan() (tok token, lit literal) { return ILLEGAL, literal{ID: string(line)} } -// parser reads the tokens returned by the Lexer and constructs the AST +// parser reads the tokens returned by the Lexer and constructs the AST. type parser struct { s *scanner buf struct { @@ -173,7 +173,7 @@ type parser struct { } // Various locations of pci.ids for different distributions. These may be more -// up to date then the embedded pci.ids db +// up to date then the embedded pci.ids db. var defaultPCIdbPaths = []string{ "/usr/share/misc/pci.ids", // Ubuntu "/usr/local/share/pci.ids", // RHEL like with manual update @@ -202,7 +202,7 @@ func NewDB(opts ...Option) Interface { return newParser(pcidbs).parse() } -// Option defines a function for passing options to the NewDB() call +// Option defines a function for passing options to the NewDB() call. type Option func(*pcidb) // WithFilePath provides an Option to set the file path @@ -216,7 +216,7 @@ func WithFilePath(path string) Option { } // newParser will attempt to read the db pci.ids from well known places or fall -// back to an internal db +// back to an internal db. func newParser(pcidbs []string) *parser { for _, db := range pcidbs { @@ -229,7 +229,7 @@ func newParser(pcidbs []string) *parser { } // We're using go embed above to have the byte array // correctly initialized with the internal shipped db - // if we cannot find an up to date in the filesystem + // if we cannot find an up to date in the filesystem. return newParserFromReader(bufio.NewReader(bytes.NewReader(defaultPCIdb))) } @@ -252,13 +252,13 @@ func (p *parser) unscan() { p.buf.n = 1 } var _ Interface = (*pcidb)(nil) -// Interface returns textual description of specific attributes of PCI devices +// Interface returns textual description of specific attributes of PCI devices. type Interface interface { GetDeviceName(uint16, uint16) (string, error) GetClassName(uint32) (string, error) } -// GetDeviceName return the textual description of the PCI device +// GetDeviceName return the textual description of the PCI device. func (d *pcidb) GetDeviceName(vendorID uint16, deviceID uint16) (string, error) { vendor, ok := d.vendors[vendorID] if !ok { @@ -273,7 +273,7 @@ func (d *pcidb) GetDeviceName(vendorID uint16, deviceID uint16) (string, error) return device.name, nil } -// GetClassName resturn the textual description of the PCI device class +// GetClassName resturn the textual description of the PCI device class. func (d *pcidb) GetClassName(classID uint32) (string, error) { class, ok := d.classes[classID] if !ok { @@ -282,53 +282,53 @@ func (d *pcidb) GetClassName(classID uint32) (string, error) { return class.name, nil } -// pcidb The complete set of PCI vendors and PCI classes +// pcidb The complete set of PCI vendors and PCI classes. type pcidb struct { vendors map[uint16]vendor classes map[uint32]class path string } -// vendor PCI vendors/devices/subVendors/SubDevices +// vendor PCI vendors/devices/subVendors/SubDevices. type vendor struct { name string devices map[uint16]device } -// subVendor PCI subVendor +// subVendor PCI subVendor. type subVendor struct { SubDevices map[uint16]SubDevice } -// SubDevice PCI SubDevice +// SubDevice PCI SubDevice. type SubDevice struct { name string } -// device PCI device +// device PCI device. type device struct { name string subVendors map[uint16]subVendor } -// class PCI classes/subClasses/Programming Interfaces +// class PCI classes/subClasses/Programming Interfaces. type class struct { name string subClasses map[uint32]subClass } -// subClass PCI subClass +// subClass PCI subClass. type subClass struct { name string progIfs map[uint8]progIf } -// progIf PCI Programming Interface +// progIf PCI Programming Interface. type progIf struct { name string } -// parse parses a PCI IDS entry +// parse parses a PCI IDS entry. func (p *parser) parse() Interface { db := &pcidb{ @@ -336,7 +336,7 @@ func (p *parser) parse() Interface { classes: map[uint32]class{}, } - // Used for housekeeping, breadcrumb for aggregated types + // Used for housekeeping, breadcrumb for aggregated types. var hkVendor vendor var hkDevice device @@ -349,8 +349,8 @@ func (p *parser) parse() Interface { for { tok, lit := p.scan() - // We're ignoring COMMENT, NEWLINE - // An EOF will break the loop + // We're ignoring COMMENT, NEWLINE. + // An EOF will break the loop. if tok == EOF { break } @@ -408,10 +408,10 @@ func (p *parser) parse() Interface { } hkSubClass = hkClass.subClasses[uint32(id)] - // Clear the last detected sub class + // Clear the last detected sub class. hkFullID = hkFullID & 0xFFFF0000 hkFullID = hkFullID | uint32(id)<<8 - // Clear the last detected prog iface + // Clear the last detected prog iface. hkFullID = hkFullID & 0xFFFFFF00 hkFullName[1] = fmt.Sprintf("%s (%02x)", lit.name, id) diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/api.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/api.go index 4885e8e9..fdf27bda 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/api.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/api.go @@ -16,22 +16,41 @@ package nvml -// Library defines a set of functions defined on the underlying dynamic library. -type Library interface { - Lookup(string) error +// ExtendedInterface defines a set of extensions to the core NVML API. +// +// TODO: For now the list of methods in this interface need to be kept in sync +// with the list of excluded methods for the Interface type in +// gen/nvml/generateapi.go. In the future we should automate this. +// +//go:generate moq -out mock/extendedinterface.go -pkg mock . ExtendedInterface:ExtendedInterface +type ExtendedInterface interface { + LookupSymbol(string) error } -// dynamicLibrary is an interface for abstacting the underlying library. -// This also allows for mocking and testing. +// libraryOptions hold the paramaters than can be set by a LibraryOption +type libraryOptions struct { + path string + flags int +} + +// LibraryOption represents a functional option to configure the underlying NVML library +type LibraryOption func(*libraryOptions) -//go:generate moq -stub -out dynamicLibrary_mock.go . dynamicLibrary -type dynamicLibrary interface { - Lookup(string) error - Open() error - Close() error +// WithLibraryPath provides an option to set the library name to be used by the NVML library. +func WithLibraryPath(path string) LibraryOption { + return func(o *libraryOptions) { + o.path = path + } } -// Interface represents the interface for the NVML library. -type Interface interface { - GetLibrary() Library +// SetLibraryOptions applies the specified options to the NVML library. +// If this is called when a library is already loaded, an error is raised. +func SetLibraryOptions(opts ...LibraryOption) error { + libnvml.Lock() + defer libnvml.Unlock() + if libnvml.refcount != 0 { + return errLibraryAlreadyLoaded + } + libnvml.init(opts...) + return nil } diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/cgo_helpers.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/cgo_helpers_static.go similarity index 89% rename from vendor/github.com/NVIDIA/go-nvml/pkg/nvml/cgo_helpers.go rename to vendor/github.com/NVIDIA/go-nvml/pkg/nvml/cgo_helpers_static.go index b04f3663..1f30eaae 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/cgo_helpers.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/cgo_helpers_static.go @@ -44,6 +44,17 @@ func uint32SliceToIntSlice(s []uint32) []int { return ret } +func convertSlice[T any, I any](input []T) []I { + output := make([]I, len(input)) + for i, obj := range input { + switch v := any(obj).(type) { + case I: + output[i] = v + } + } + return output +} + // packPCharString creates a Go string backed by *C.char and avoids copying. func packPCharString(p *C.char) (raw string) { if p != nil && *p != 0 { diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/const.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/const.go index f4cecfbc..1ccb5016 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/const.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/const.go @@ -31,9 +31,9 @@ const ( // NO_UNVERSIONED_FUNC_DEFS as defined in go-nvml/:24 NO_UNVERSIONED_FUNC_DEFS = 1 // API_VERSION as defined in nvml/nvml.h - API_VERSION = 11 + API_VERSION = 12 // API_VERSION_STR as defined in nvml/nvml.h - API_VERSION_STR = "11" + API_VERSION_STR = "12" // VALUE_NOT_AVAILABLE as defined in nvml/nvml.h VALUE_NOT_AVAILABLE = -1 // DEVICE_PCI_BUS_ID_BUFFER_SIZE as defined in nvml/nvml.h @@ -78,6 +78,8 @@ const ( VGPU_NAME_BUFFER_SIZE = 64 // GRID_LICENSE_FEATURE_MAX_COUNT as defined in nvml/nvml.h GRID_LICENSE_FEATURE_MAX_COUNT = 3 + // INVALID_VGPU_PLACEMENT_ID as defined in nvml/nvml.h + INVALID_VGPU_PLACEMENT_ID = 65535 // VGPU_SCHEDULER_POLICY_UNKNOWN as defined in nvml/nvml.h VGPU_SCHEDULER_POLICY_UNKNOWN = 0 // VGPU_SCHEDULER_POLICY_BEST_EFFORT as defined in nvml/nvml.h @@ -90,6 +92,12 @@ const ( SUPPORTED_VGPU_SCHEDULER_POLICY_COUNT = 3 // SCHEDULER_SW_MAX_LOG_ENTRIES as defined in nvml/nvml.h SCHEDULER_SW_MAX_LOG_ENTRIES = 200 + // VGPU_SCHEDULER_ARR_DEFAULT as defined in nvml/nvml.h + VGPU_SCHEDULER_ARR_DEFAULT = 0 + // VGPU_SCHEDULER_ARR_DISABLE as defined in nvml/nvml.h + VGPU_SCHEDULER_ARR_DISABLE = 1 + // VGPU_SCHEDULER_ARR_ENABLE as defined in nvml/nvml.h + VGPU_SCHEDULER_ARR_ENABLE = 2 // GRID_LICENSE_STATE_UNKNOWN as defined in nvml/nvml.h GRID_LICENSE_STATE_UNKNOWN = 0 // GRID_LICENSE_STATE_UNINITIALIZED as defined in nvml/nvml.h @@ -140,6 +148,8 @@ const ( POWER_SOURCE_AC = 0 // POWER_SOURCE_BATTERY as defined in nvml/nvml.h POWER_SOURCE_BATTERY = 1 + // POWER_SOURCE_UNDERSIZED as defined in nvml/nvml.h + POWER_SOURCE_UNDERSIZED = 2 // PCIE_LINK_MAX_SPEED_INVALID as defined in nvml/nvml.h PCIE_LINK_MAX_SPEED_INVALID = 0 // PCIE_LINK_MAX_SPEED_2500MBPS as defined in nvml/nvml.h @@ -498,8 +508,64 @@ const ( FI_DEV_NVLINK_GET_POWER_THRESHOLD = 168 // FI_DEV_PCIE_L0_TO_RECOVERY_COUNTER as defined in nvml/nvml.h FI_DEV_PCIE_L0_TO_RECOVERY_COUNTER = 169 + // FI_DEV_C2C_LINK_COUNT as defined in nvml/nvml.h + FI_DEV_C2C_LINK_COUNT = 170 + // FI_DEV_C2C_LINK_GET_STATUS as defined in nvml/nvml.h + FI_DEV_C2C_LINK_GET_STATUS = 171 + // FI_DEV_C2C_LINK_GET_MAX_BW as defined in nvml/nvml.h + FI_DEV_C2C_LINK_GET_MAX_BW = 172 + // FI_DEV_PCIE_COUNT_CORRECTABLE_ERRORS as defined in nvml/nvml.h + FI_DEV_PCIE_COUNT_CORRECTABLE_ERRORS = 173 + // FI_DEV_PCIE_COUNT_NAKS_RECEIVED as defined in nvml/nvml.h + FI_DEV_PCIE_COUNT_NAKS_RECEIVED = 174 + // FI_DEV_PCIE_COUNT_RECEIVER_ERROR as defined in nvml/nvml.h + FI_DEV_PCIE_COUNT_RECEIVER_ERROR = 175 + // FI_DEV_PCIE_COUNT_BAD_TLP as defined in nvml/nvml.h + FI_DEV_PCIE_COUNT_BAD_TLP = 176 + // FI_DEV_PCIE_COUNT_NAKS_SENT as defined in nvml/nvml.h + FI_DEV_PCIE_COUNT_NAKS_SENT = 177 + // FI_DEV_PCIE_COUNT_BAD_DLLP as defined in nvml/nvml.h + FI_DEV_PCIE_COUNT_BAD_DLLP = 178 + // FI_DEV_PCIE_COUNT_NON_FATAL_ERROR as defined in nvml/nvml.h + FI_DEV_PCIE_COUNT_NON_FATAL_ERROR = 179 + // FI_DEV_PCIE_COUNT_FATAL_ERROR as defined in nvml/nvml.h + FI_DEV_PCIE_COUNT_FATAL_ERROR = 180 + // FI_DEV_PCIE_COUNT_UNSUPPORTED_REQ as defined in nvml/nvml.h + FI_DEV_PCIE_COUNT_UNSUPPORTED_REQ = 181 + // FI_DEV_PCIE_COUNT_LCRC_ERROR as defined in nvml/nvml.h + FI_DEV_PCIE_COUNT_LCRC_ERROR = 182 + // FI_DEV_PCIE_COUNT_LANE_ERROR as defined in nvml/nvml.h + FI_DEV_PCIE_COUNT_LANE_ERROR = 183 + // FI_DEV_IS_RESETLESS_MIG_SUPPORTED as defined in nvml/nvml.h + FI_DEV_IS_RESETLESS_MIG_SUPPORTED = 184 + // FI_DEV_POWER_AVERAGE as defined in nvml/nvml.h + FI_DEV_POWER_AVERAGE = 185 + // FI_DEV_POWER_INSTANT as defined in nvml/nvml.h + FI_DEV_POWER_INSTANT = 186 + // FI_DEV_POWER_MIN_LIMIT as defined in nvml/nvml.h + FI_DEV_POWER_MIN_LIMIT = 187 + // FI_DEV_POWER_MAX_LIMIT as defined in nvml/nvml.h + FI_DEV_POWER_MAX_LIMIT = 188 + // FI_DEV_POWER_DEFAULT_LIMIT as defined in nvml/nvml.h + FI_DEV_POWER_DEFAULT_LIMIT = 189 + // FI_DEV_POWER_CURRENT_LIMIT as defined in nvml/nvml.h + FI_DEV_POWER_CURRENT_LIMIT = 190 + // FI_DEV_ENERGY as defined in nvml/nvml.h + FI_DEV_ENERGY = 191 + // FI_DEV_POWER_REQUESTED_LIMIT as defined in nvml/nvml.h + FI_DEV_POWER_REQUESTED_LIMIT = 192 + // FI_DEV_TEMPERATURE_SHUTDOWN_TLIMIT as defined in nvml/nvml.h + FI_DEV_TEMPERATURE_SHUTDOWN_TLIMIT = 193 + // FI_DEV_TEMPERATURE_SLOWDOWN_TLIMIT as defined in nvml/nvml.h + FI_DEV_TEMPERATURE_SLOWDOWN_TLIMIT = 194 + // FI_DEV_TEMPERATURE_MEM_MAX_TLIMIT as defined in nvml/nvml.h + FI_DEV_TEMPERATURE_MEM_MAX_TLIMIT = 195 + // FI_DEV_TEMPERATURE_GPU_MAX_TLIMIT as defined in nvml/nvml.h + FI_DEV_TEMPERATURE_GPU_MAX_TLIMIT = 196 + // FI_DEV_IS_MIG_MODE_INDEPENDENT_MIG_QUERY_CAPABLE as defined in nvml/nvml.h + FI_DEV_IS_MIG_MODE_INDEPENDENT_MIG_QUERY_CAPABLE = 199 // FI_MAX as defined in nvml/nvml.h - FI_MAX = 170 + FI_MAX = 200 // EventTypeSingleBitEccError as defined in nvml/nvml.h EventTypeSingleBitEccError = 1 // EventTypeDoubleBitEccError as defined in nvml/nvml.h @@ -518,24 +584,40 @@ const ( EventTypeNone = 0 // EventTypeAll as defined in nvml/nvml.h EventTypeAll = 415 - // ClocksThrottleReasonGpuIdle as defined in nvml/nvml.h - ClocksThrottleReasonGpuIdle = 1 - // ClocksThrottleReasonApplicationsClocksSetting as defined in nvml/nvml.h - ClocksThrottleReasonApplicationsClocksSetting = 2 + // ClocksEventReasonGpuIdle as defined in nvml/nvml.h + ClocksEventReasonGpuIdle = 1 + // ClocksEventReasonApplicationsClocksSetting as defined in nvml/nvml.h + ClocksEventReasonApplicationsClocksSetting = 2 // ClocksThrottleReasonUserDefinedClocks as defined in nvml/nvml.h ClocksThrottleReasonUserDefinedClocks = 2 - // ClocksThrottleReasonSwPowerCap as defined in nvml/nvml.h - ClocksThrottleReasonSwPowerCap = 4 + // ClocksEventReasonSwPowerCap as defined in nvml/nvml.h + ClocksEventReasonSwPowerCap = 4 // ClocksThrottleReasonHwSlowdown as defined in nvml/nvml.h ClocksThrottleReasonHwSlowdown = 8 - // ClocksThrottleReasonSyncBoost as defined in nvml/nvml.h - ClocksThrottleReasonSyncBoost = 16 - // ClocksThrottleReasonSwThermalSlowdown as defined in nvml/nvml.h - ClocksThrottleReasonSwThermalSlowdown = 32 + // ClocksEventReasonSyncBoost as defined in nvml/nvml.h + ClocksEventReasonSyncBoost = 16 + // ClocksEventReasonSwThermalSlowdown as defined in nvml/nvml.h + ClocksEventReasonSwThermalSlowdown = 32 // ClocksThrottleReasonHwThermalSlowdown as defined in nvml/nvml.h ClocksThrottleReasonHwThermalSlowdown = 64 // ClocksThrottleReasonHwPowerBrakeSlowdown as defined in nvml/nvml.h ClocksThrottleReasonHwPowerBrakeSlowdown = 128 + // ClocksEventReasonDisplayClockSetting as defined in nvml/nvml.h + ClocksEventReasonDisplayClockSetting = 256 + // ClocksEventReasonNone as defined in nvml/nvml.h + ClocksEventReasonNone = 0 + // ClocksEventReasonAll as defined in nvml/nvml.h + ClocksEventReasonAll = 511 + // ClocksThrottleReasonGpuIdle as defined in nvml/nvml.h + ClocksThrottleReasonGpuIdle = 1 + // ClocksThrottleReasonApplicationsClocksSetting as defined in nvml/nvml.h + ClocksThrottleReasonApplicationsClocksSetting = 2 + // ClocksThrottleReasonSyncBoost as defined in nvml/nvml.h + ClocksThrottleReasonSyncBoost = 16 + // ClocksThrottleReasonSwPowerCap as defined in nvml/nvml.h + ClocksThrottleReasonSwPowerCap = 4 + // ClocksThrottleReasonSwThermalSlowdown as defined in nvml/nvml.h + ClocksThrottleReasonSwThermalSlowdown = 32 // ClocksThrottleReasonDisplayClockSetting as defined in nvml/nvml.h ClocksThrottleReasonDisplayClockSetting = 256 // ClocksThrottleReasonNone as defined in nvml/nvml.h @@ -552,6 +634,56 @@ const ( NVFBC_SESSION_FLAG_CAPTURE_WITH_WAIT_INFINITE = 8 // NVFBC_SESSION_FLAG_CAPTURE_WITH_WAIT_TIMEOUT as defined in nvml/nvml.h NVFBC_SESSION_FLAG_CAPTURE_WITH_WAIT_TIMEOUT = 16 + // CC_SYSTEM_CPU_CAPS_NONE as defined in nvml/nvml.h + CC_SYSTEM_CPU_CAPS_NONE = 0 + // CC_SYSTEM_CPU_CAPS_AMD_SEV as defined in nvml/nvml.h + CC_SYSTEM_CPU_CAPS_AMD_SEV = 1 + // CC_SYSTEM_CPU_CAPS_INTEL_TDX as defined in nvml/nvml.h + CC_SYSTEM_CPU_CAPS_INTEL_TDX = 2 + // CC_SYSTEM_GPUS_CC_NOT_CAPABLE as defined in nvml/nvml.h + CC_SYSTEM_GPUS_CC_NOT_CAPABLE = 0 + // CC_SYSTEM_GPUS_CC_CAPABLE as defined in nvml/nvml.h + CC_SYSTEM_GPUS_CC_CAPABLE = 1 + // CC_SYSTEM_DEVTOOLS_MODE_OFF as defined in nvml/nvml.h + CC_SYSTEM_DEVTOOLS_MODE_OFF = 0 + // CC_SYSTEM_DEVTOOLS_MODE_ON as defined in nvml/nvml.h + CC_SYSTEM_DEVTOOLS_MODE_ON = 1 + // CC_SYSTEM_ENVIRONMENT_UNAVAILABLE as defined in nvml/nvml.h + CC_SYSTEM_ENVIRONMENT_UNAVAILABLE = 0 + // CC_SYSTEM_ENVIRONMENT_SIM as defined in nvml/nvml.h + CC_SYSTEM_ENVIRONMENT_SIM = 1 + // CC_SYSTEM_ENVIRONMENT_PROD as defined in nvml/nvml.h + CC_SYSTEM_ENVIRONMENT_PROD = 2 + // CC_SYSTEM_FEATURE_DISABLED as defined in nvml/nvml.h + CC_SYSTEM_FEATURE_DISABLED = 0 + // CC_SYSTEM_FEATURE_ENABLED as defined in nvml/nvml.h + CC_SYSTEM_FEATURE_ENABLED = 1 + // CC_SYSTEM_MULTIGPU_NONE as defined in nvml/nvml.h + CC_SYSTEM_MULTIGPU_NONE = 0 + // CC_SYSTEM_MULTIGPU_PROTECTED_PCIE as defined in nvml/nvml.h + CC_SYSTEM_MULTIGPU_PROTECTED_PCIE = 1 + // CC_ACCEPTING_CLIENT_REQUESTS_FALSE as defined in nvml/nvml.h + CC_ACCEPTING_CLIENT_REQUESTS_FALSE = 0 + // CC_ACCEPTING_CLIENT_REQUESTS_TRUE as defined in nvml/nvml.h + CC_ACCEPTING_CLIENT_REQUESTS_TRUE = 1 + // GPU_CERT_CHAIN_SIZE as defined in nvml/nvml.h + GPU_CERT_CHAIN_SIZE = 4096 + // GPU_ATTESTATION_CERT_CHAIN_SIZE as defined in nvml/nvml.h + GPU_ATTESTATION_CERT_CHAIN_SIZE = 5120 + // CC_GPU_CEC_NONCE_SIZE as defined in nvml/nvml.h + CC_GPU_CEC_NONCE_SIZE = 32 + // CC_GPU_ATTESTATION_REPORT_SIZE as defined in nvml/nvml.h + CC_GPU_ATTESTATION_REPORT_SIZE = 8192 + // CC_GPU_CEC_ATTESTATION_REPORT_SIZE as defined in nvml/nvml.h + CC_GPU_CEC_ATTESTATION_REPORT_SIZE = 4096 + // CC_CEC_ATTESTATION_REPORT_NOT_PRESENT as defined in nvml/nvml.h + CC_CEC_ATTESTATION_REPORT_NOT_PRESENT = 0 + // CC_CEC_ATTESTATION_REPORT_PRESENT as defined in nvml/nvml.h + CC_CEC_ATTESTATION_REPORT_PRESENT = 1 + // CC_KEY_ROTATION_THRESHOLD_ATTACKER_ADVANTAGE_MIN as defined in nvml/nvml.h + CC_KEY_ROTATION_THRESHOLD_ATTACKER_ADVANTAGE_MIN = 50 + // CC_KEY_ROTATION_THRESHOLD_ATTACKER_ADVANTAGE_MAX as defined in nvml/nvml.h + CC_KEY_ROTATION_THRESHOLD_ATTACKER_ADVANTAGE_MAX = 75 // GPU_FABRIC_UUID_LEN as defined in nvml/nvml.h GPU_FABRIC_UUID_LEN = 16 // GPU_FABRIC_STATE_NOT_SUPPORTED as defined in nvml/nvml.h @@ -562,6 +694,22 @@ const ( GPU_FABRIC_STATE_IN_PROGRESS = 2 // GPU_FABRIC_STATE_COMPLETED as defined in nvml/nvml.h GPU_FABRIC_STATE_COMPLETED = 3 + // GPU_FABRIC_HEALTH_MASK_DEGRADED_BW_NOT_SUPPORTED as defined in nvml/nvml.h + GPU_FABRIC_HEALTH_MASK_DEGRADED_BW_NOT_SUPPORTED = 0 + // GPU_FABRIC_HEALTH_MASK_DEGRADED_BW_TRUE as defined in nvml/nvml.h + GPU_FABRIC_HEALTH_MASK_DEGRADED_BW_TRUE = 1 + // GPU_FABRIC_HEALTH_MASK_DEGRADED_BW_FALSE as defined in nvml/nvml.h + GPU_FABRIC_HEALTH_MASK_DEGRADED_BW_FALSE = 2 + // GPU_FABRIC_HEALTH_MASK_SHIFT_DEGRADED_BW as defined in nvml/nvml.h + GPU_FABRIC_HEALTH_MASK_SHIFT_DEGRADED_BW = 0 + // GPU_FABRIC_HEALTH_MASK_WIDTH_DEGRADED_BW as defined in nvml/nvml.h + GPU_FABRIC_HEALTH_MASK_WIDTH_DEGRADED_BW = 17 + // POWER_SCOPE_GPU as defined in nvml/nvml.h + POWER_SCOPE_GPU = 0 + // POWER_SCOPE_MODULE as defined in nvml/nvml.h + POWER_SCOPE_MODULE = 1 + // POWER_SCOPE_MEMORY as defined in nvml/nvml.h + POWER_SCOPE_MEMORY = 2 // INIT_FLAG_NO_GPUS as defined in nvml/nvml.h INIT_FLAG_NO_GPUS = 1 // INIT_FLAG_NO_ATTACH as defined in nvml/nvml.h @@ -616,6 +764,8 @@ const ( GPU_INSTANCE_PROFILE_1_SLICE_REV2 = 9 // GPU_INSTANCE_PROFILE_COUNT as defined in nvml/nvml.h GPU_INSTANCE_PROFILE_COUNT = 10 + // GPU_INTSTANCE_PROFILE_CAPS_P2P as defined in nvml/nvml.h + GPU_INTSTANCE_PROFILE_CAPS_P2P = 1 // COMPUTE_INSTANCE_PROFILE_1_SLICE as defined in nvml/nvml.h COMPUTE_INSTANCE_PROFILE_1_SLICE = 0 // COMPUTE_INSTANCE_PROFILE_2_SLICE as defined in nvml/nvml.h @@ -642,10 +792,6 @@ const ( GPM_METRICS_GET_VERSION = 1 // GPM_SUPPORT_VERSION as defined in nvml/nvml.h GPM_SUPPORT_VERSION = 1 - // COUNTER_COLLECTION_UNIT_STREAM_STATE_DISABLE as defined in nvml/nvml.h - COUNTER_COLLECTION_UNIT_STREAM_STATE_DISABLE = 0 - // COUNTER_COLLECTION_UNIT_STREAM_STATE_ENABLE as defined in nvml/nvml.h - COUNTER_COLLECTION_UNIT_STREAM_STATE_ENABLE = 1 // NVLINK_POWER_STATE_HIGH_SPEED as defined in nvml/nvml.h NVLINK_POWER_STATE_HIGH_SPEED = 0 // NVLINK_POWER_STATE_LOW as defined in nvml/nvml.h @@ -753,6 +899,7 @@ type GpuP2PStatus int32 const ( P2P_STATUS_OK GpuP2PStatus = iota P2P_STATUS_CHIPSET_NOT_SUPPORED GpuP2PStatus = 1 + P2P_STATUS_CHIPSET_NOT_SUPPORTED GpuP2PStatus = 1 P2P_STATUS_GPU_NOT_SUPPORTED GpuP2PStatus = 2 P2P_STATUS_IOH_TOPOLOGY_NOT_SUPPORTED GpuP2PStatus = 3 P2P_STATUS_DISABLED_BY_REGKEY GpuP2PStatus = 4 @@ -769,6 +916,7 @@ const ( P2P_CAPS_INDEX_WRITE GpuP2PCapsIndex = 1 P2P_CAPS_INDEX_NVLINK GpuP2PCapsIndex = 2 P2P_CAPS_INDEX_ATOMICS GpuP2PCapsIndex = 3 + P2P_CAPS_INDEX_PCI GpuP2PCapsIndex = 4 P2P_CAPS_INDEX_PROP GpuP2PCapsIndex = 4 P2P_CAPS_INDEX_UNKNOWN GpuP2PCapsIndex = 5 ) @@ -785,7 +933,10 @@ const ( DEC_UTILIZATION_SAMPLES SamplingType = 4 PROCESSOR_CLK_SAMPLES SamplingType = 5 MEMORY_CLK_SAMPLES SamplingType = 6 - SAMPLINGTYPE_COUNT SamplingType = 7 + MODULE_POWER_SAMPLES SamplingType = 7 + JPG_UTILIZATION_SAMPLES SamplingType = 8 + OFA_UTILIZATION_SAMPLES SamplingType = 9 + SAMPLINGTYPE_COUNT SamplingType = 10 ) // PcieUtilCounter as declared in nvml/nvml.h @@ -808,7 +959,8 @@ const ( VALUE_TYPE_UNSIGNED_LONG ValueType = 2 VALUE_TYPE_UNSIGNED_LONG_LONG ValueType = 3 VALUE_TYPE_SIGNED_LONG_LONG ValueType = 4 - VALUE_TYPE_COUNT ValueType = 5 + VALUE_TYPE_SIGNED_INT ValueType = 5 + VALUE_TYPE_COUNT ValueType = 6 ) // PerfPolicyType as declared in nvml/nvml.h @@ -1028,6 +1180,9 @@ const ( ERROR_FREQ_NOT_SUPPORTED Return = 24 ERROR_ARGUMENT_VERSION_MISMATCH Return = 25 ERROR_DEPRECATED Return = 26 + ERROR_NOT_READY Return = 27 + ERROR_GPU_NOT_FOUND Return = 28 + ERROR_INVALID_STATE Return = 29 ERROR_UNKNOWN Return = 999 ) @@ -1137,7 +1292,12 @@ const ( DEVICE_VGPU_CAP_FRACTIONAL_MULTI_VGPU DeviceVgpuCapability = iota DEVICE_VGPU_CAP_HETEROGENEOUS_TIMESLICE_PROFILES DeviceVgpuCapability = 1 DEVICE_VGPU_CAP_HETEROGENEOUS_TIMESLICE_SIZES DeviceVgpuCapability = 2 - DEVICE_VGPU_CAP_COUNT DeviceVgpuCapability = 3 + DEVICE_VGPU_CAP_READ_DEVICE_BUFFER_BW DeviceVgpuCapability = 3 + DEVICE_VGPU_CAP_WRITE_DEVICE_BUFFER_BW DeviceVgpuCapability = 4 + DEVICE_VGPU_CAP_DEVICE_STREAMING DeviceVgpuCapability = 5 + DEVICE_VGPU_CAP_MINI_QUARTER_GPU DeviceVgpuCapability = 6 + DEVICE_VGPU_CAP_COMPUTE_MEDIA_ENGINE_GPU DeviceVgpuCapability = 7 + DEVICE_VGPU_CAP_COUNT DeviceVgpuCapability = 8 ) // GpuUtilizationDomainId as declared in nvml/nvml.h @@ -1174,8 +1334,10 @@ type EncoderType int32 // EncoderType enumeration from nvml/nvml.h const ( - ENCODER_QUERY_H264 EncoderType = iota - ENCODER_QUERY_HEVC EncoderType = 1 + ENCODER_QUERY_H264 EncoderType = iota + ENCODER_QUERY_HEVC EncoderType = 1 + ENCODER_QUERY_AV1 EncoderType = 2 + ENCODER_QUERY_UNKNOWN EncoderType = 255 ) // FBCSessionType as declared in nvml/nvml.h diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/const_gen.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/const_static.go similarity index 100% rename from vendor/github.com/NVIDIA/go-nvml/pkg/nvml/const_gen.go rename to vendor/github.com/NVIDIA/go-nvml/pkg/nvml/const_static.go diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/device.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/device.go index 91a7baa9..ac778e5a 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/device.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/device.go @@ -15,2638 +15,3043 @@ package nvml import ( + "fmt" + "reflect" "unsafe" ) +// nvmlDeviceHandle attempts to convert a device d to an nvmlDevice. +// This is required for functions such as GetTopologyCommonAncestor which +// accept Device arguments that need to be passed to internal nvml* functions +// as nvmlDevice parameters. +func nvmlDeviceHandle(d Device) nvmlDevice { + var helper func(val reflect.Value) nvmlDevice + helper = func(val reflect.Value) nvmlDevice { + if val.Kind() == reflect.Interface { + val = val.Elem() + } + + if val.Kind() == reflect.Ptr { + val = val.Elem() + } + + if val.Type() == reflect.TypeOf(nvmlDevice{}) { + return val.Interface().(nvmlDevice) + } + + if val.Kind() != reflect.Struct { + panic(fmt.Errorf("unable to convert non-struct type %v to nvmlDevice", val.Kind())) + } + + for i := 0; i < val.Type().NumField(); i++ { + if !val.Type().Field(i).Anonymous { + continue + } + if !val.Field(i).Type().Implements(reflect.TypeOf((*Device)(nil)).Elem()) { + continue + } + return helper(val.Field(i)) + } + panic(fmt.Errorf("unable to convert %T to nvmlDevice", d)) + } + return helper(reflect.ValueOf(d)) +} + // EccBitType type EccBitType = MemoryErrorType +// GpuInstanceInfo includes an interface type for Device instead of nvmlDevice +type GpuInstanceInfo struct { + Device Device + Id uint32 + ProfileId uint32 + Placement GpuInstancePlacement +} + +func (g GpuInstanceInfo) convert() nvmlGpuInstanceInfo { + out := nvmlGpuInstanceInfo{ + Device: g.Device.(nvmlDevice), + Id: g.Id, + ProfileId: g.ProfileId, + Placement: g.Placement, + } + return out +} + +func (g nvmlGpuInstanceInfo) convert() GpuInstanceInfo { + out := GpuInstanceInfo{ + Device: g.Device, + Id: g.Id, + ProfileId: g.ProfileId, + Placement: g.Placement, + } + return out +} + +// ComputeInstanceInfo includes an interface type for Device instead of nvmlDevice +type ComputeInstanceInfo struct { + Device Device + GpuInstance GpuInstance + Id uint32 + ProfileId uint32 + Placement ComputeInstancePlacement +} + +func (c ComputeInstanceInfo) convert() nvmlComputeInstanceInfo { + out := nvmlComputeInstanceInfo{ + Device: c.Device.(nvmlDevice), + GpuInstance: c.GpuInstance.(nvmlGpuInstance), + Id: c.Id, + ProfileId: c.ProfileId, + Placement: c.Placement, + } + return out +} + +func (c nvmlComputeInstanceInfo) convert() ComputeInstanceInfo { + out := ComputeInstanceInfo{ + Device: c.Device, + GpuInstance: c.GpuInstance, + Id: c.Id, + ProfileId: c.ProfileId, + Placement: c.Placement, + } + return out +} + // nvml.DeviceGetCount() -func DeviceGetCount() (int, Return) { - var DeviceCount uint32 - ret := nvmlDeviceGetCount(&DeviceCount) - return int(DeviceCount), ret +func (l *library) DeviceGetCount() (int, Return) { + var deviceCount uint32 + ret := nvmlDeviceGetCount(&deviceCount) + return int(deviceCount), ret } // nvml.DeviceGetHandleByIndex() -func DeviceGetHandleByIndex(Index int) (Device, Return) { - var Device Device - ret := nvmlDeviceGetHandleByIndex(uint32(Index), &Device) - return Device, ret +func (l *library) DeviceGetHandleByIndex(index int) (Device, Return) { + var device nvmlDevice + ret := nvmlDeviceGetHandleByIndex(uint32(index), &device) + return device, ret } // nvml.DeviceGetHandleBySerial() -func DeviceGetHandleBySerial(Serial string) (Device, Return) { - var Device Device - ret := nvmlDeviceGetHandleBySerial(Serial+string(rune(0)), &Device) - return Device, ret +func (l *library) DeviceGetHandleBySerial(serial string) (Device, Return) { + var device nvmlDevice + ret := nvmlDeviceGetHandleBySerial(serial+string(rune(0)), &device) + return device, ret } // nvml.DeviceGetHandleByUUID() -func DeviceGetHandleByUUID(Uuid string) (Device, Return) { - var Device Device - ret := nvmlDeviceGetHandleByUUID(Uuid+string(rune(0)), &Device) - return Device, ret +func (l *library) DeviceGetHandleByUUID(uuid string) (Device, Return) { + var device nvmlDevice + ret := nvmlDeviceGetHandleByUUID(uuid+string(rune(0)), &device) + return device, ret } // nvml.DeviceGetHandleByPciBusId() -func DeviceGetHandleByPciBusId(PciBusId string) (Device, Return) { - var Device Device - ret := nvmlDeviceGetHandleByPciBusId(PciBusId+string(rune(0)), &Device) - return Device, ret +func (l *library) DeviceGetHandleByPciBusId(pciBusId string) (Device, Return) { + var device nvmlDevice + ret := nvmlDeviceGetHandleByPciBusId(pciBusId+string(rune(0)), &device) + return device, ret } // nvml.DeviceGetName() -func DeviceGetName(Device Device) (string, Return) { - Name := make([]byte, DEVICE_NAME_V2_BUFFER_SIZE) - ret := nvmlDeviceGetName(Device, &Name[0], DEVICE_NAME_V2_BUFFER_SIZE) - return string(Name[:clen(Name)]), ret +func (l *library) DeviceGetName(device Device) (string, Return) { + return device.GetName() } -func (Device Device) GetName() (string, Return) { - return DeviceGetName(Device) +func (device nvmlDevice) GetName() (string, Return) { + name := make([]byte, DEVICE_NAME_V2_BUFFER_SIZE) + ret := nvmlDeviceGetName(device, &name[0], DEVICE_NAME_V2_BUFFER_SIZE) + return string(name[:clen(name)]), ret } // nvml.DeviceGetBrand() -func DeviceGetBrand(Device Device) (BrandType, Return) { - var _type BrandType - ret := nvmlDeviceGetBrand(Device, &_type) - return _type, ret +func (l *library) DeviceGetBrand(device Device) (BrandType, Return) { + return device.GetBrand() } -func (Device Device) GetBrand() (BrandType, Return) { - return DeviceGetBrand(Device) +func (device nvmlDevice) GetBrand() (BrandType, Return) { + var brandType BrandType + ret := nvmlDeviceGetBrand(device, &brandType) + return brandType, ret } // nvml.DeviceGetIndex() -func DeviceGetIndex(Device Device) (int, Return) { - var Index uint32 - ret := nvmlDeviceGetIndex(Device, &Index) - return int(Index), ret +func (l *library) DeviceGetIndex(device Device) (int, Return) { + return device.GetIndex() } -func (Device Device) GetIndex() (int, Return) { - return DeviceGetIndex(Device) +func (device nvmlDevice) GetIndex() (int, Return) { + var index uint32 + ret := nvmlDeviceGetIndex(device, &index) + return int(index), ret } // nvml.DeviceGetSerial() -func DeviceGetSerial(Device Device) (string, Return) { - Serial := make([]byte, DEVICE_SERIAL_BUFFER_SIZE) - ret := nvmlDeviceGetSerial(Device, &Serial[0], DEVICE_SERIAL_BUFFER_SIZE) - return string(Serial[:clen(Serial)]), ret +func (l *library) DeviceGetSerial(device Device) (string, Return) { + return device.GetSerial() } -func (Device Device) GetSerial() (string, Return) { - return DeviceGetSerial(Device) +func (device nvmlDevice) GetSerial() (string, Return) { + serial := make([]byte, DEVICE_SERIAL_BUFFER_SIZE) + ret := nvmlDeviceGetSerial(device, &serial[0], DEVICE_SERIAL_BUFFER_SIZE) + return string(serial[:clen(serial)]), ret } // nvml.DeviceGetCpuAffinity() -func DeviceGetCpuAffinity(Device Device, NumCPUs int) ([]uint, Return) { - CpuSetSize := uint32((NumCPUs-1)/int(unsafe.Sizeof(uint(0))) + 1) - CpuSet := make([]uint, CpuSetSize) - ret := nvmlDeviceGetCpuAffinity(Device, CpuSetSize, &CpuSet[0]) - return CpuSet, ret +func (l *library) DeviceGetCpuAffinity(device Device, numCPUs int) ([]uint, Return) { + return device.GetCpuAffinity(numCPUs) } -func (Device Device) GetCpuAffinity(NumCPUs int) ([]uint, Return) { - return DeviceGetCpuAffinity(Device, NumCPUs) +func (device nvmlDevice) GetCpuAffinity(numCPUs int) ([]uint, Return) { + cpuSetSize := uint32((numCPUs-1)/int(unsafe.Sizeof(uint(0))) + 1) + cpuSet := make([]uint, cpuSetSize) + ret := nvmlDeviceGetCpuAffinity(device, cpuSetSize, &cpuSet[0]) + return cpuSet, ret } // nvml.DeviceSetCpuAffinity() -func DeviceSetCpuAffinity(Device Device) Return { - return nvmlDeviceSetCpuAffinity(Device) +func (l *library) DeviceSetCpuAffinity(device Device) Return { + return device.SetCpuAffinity() } -func (Device Device) SetCpuAffinity() Return { - return DeviceSetCpuAffinity(Device) +func (device nvmlDevice) SetCpuAffinity() Return { + return nvmlDeviceSetCpuAffinity(device) } // nvml.DeviceClearCpuAffinity() -func DeviceClearCpuAffinity(Device Device) Return { - return nvmlDeviceClearCpuAffinity(Device) +func (l *library) DeviceClearCpuAffinity(device Device) Return { + return device.ClearCpuAffinity() } -func (Device Device) ClearCpuAffinity() Return { - return DeviceClearCpuAffinity(Device) +func (device nvmlDevice) ClearCpuAffinity() Return { + return nvmlDeviceClearCpuAffinity(device) } // nvml.DeviceGetMemoryAffinity() -func DeviceGetMemoryAffinity(Device Device, NumNodes int, Scope AffinityScope) ([]uint, Return) { - NodeSetSize := uint32((NumNodes-1)/int(unsafe.Sizeof(uint(0))) + 1) - NodeSet := make([]uint, NodeSetSize) - ret := nvmlDeviceGetMemoryAffinity(Device, NodeSetSize, &NodeSet[0], Scope) - return NodeSet, ret +func (l *library) DeviceGetMemoryAffinity(device Device, numNodes int, scope AffinityScope) ([]uint, Return) { + return device.GetMemoryAffinity(numNodes, scope) } -func (Device Device) GetMemoryAffinity(NumNodes int, Scope AffinityScope) ([]uint, Return) { - return DeviceGetMemoryAffinity(Device, NumNodes, Scope) +func (device nvmlDevice) GetMemoryAffinity(numNodes int, scope AffinityScope) ([]uint, Return) { + nodeSetSize := uint32((numNodes-1)/int(unsafe.Sizeof(uint(0))) + 1) + nodeSet := make([]uint, nodeSetSize) + ret := nvmlDeviceGetMemoryAffinity(device, nodeSetSize, &nodeSet[0], scope) + return nodeSet, ret } // nvml.DeviceGetCpuAffinityWithinScope() -func DeviceGetCpuAffinityWithinScope(Device Device, NumCPUs int, Scope AffinityScope) ([]uint, Return) { - CpuSetSize := uint32((NumCPUs-1)/int(unsafe.Sizeof(uint(0))) + 1) - CpuSet := make([]uint, CpuSetSize) - ret := nvmlDeviceGetCpuAffinityWithinScope(Device, CpuSetSize, &CpuSet[0], Scope) - return CpuSet, ret +func (l *library) DeviceGetCpuAffinityWithinScope(device Device, numCPUs int, scope AffinityScope) ([]uint, Return) { + return device.GetCpuAffinityWithinScope(numCPUs, scope) } -func (Device Device) GetCpuAffinityWithinScope(NumCPUs int, Scope AffinityScope) ([]uint, Return) { - return DeviceGetCpuAffinityWithinScope(Device, NumCPUs, Scope) +func (device nvmlDevice) GetCpuAffinityWithinScope(numCPUs int, scope AffinityScope) ([]uint, Return) { + cpuSetSize := uint32((numCPUs-1)/int(unsafe.Sizeof(uint(0))) + 1) + cpuSet := make([]uint, cpuSetSize) + ret := nvmlDeviceGetCpuAffinityWithinScope(device, cpuSetSize, &cpuSet[0], scope) + return cpuSet, ret } // nvml.DeviceGetTopologyCommonAncestor() -func DeviceGetTopologyCommonAncestor(Device1 Device, Device2 Device) (GpuTopologyLevel, Return) { - var PathInfo GpuTopologyLevel - ret := nvmlDeviceGetTopologyCommonAncestor(Device1, Device2, &PathInfo) - return PathInfo, ret +func (l *library) DeviceGetTopologyCommonAncestor(device1 Device, device2 Device) (GpuTopologyLevel, Return) { + return device1.GetTopologyCommonAncestor(device2) } -func (Device1 Device) GetTopologyCommonAncestor(Device2 Device) (GpuTopologyLevel, Return) { - return DeviceGetTopologyCommonAncestor(Device1, Device2) +func (device1 nvmlDevice) GetTopologyCommonAncestor(device2 Device) (GpuTopologyLevel, Return) { + var pathInfo GpuTopologyLevel + ret := nvmlDeviceGetTopologyCommonAncestorStub(device1, nvmlDeviceHandle(device2), &pathInfo) + return pathInfo, ret } +// nvmlDeviceGetTopologyCommonAncestorStub allows us to override this for testing. +var nvmlDeviceGetTopologyCommonAncestorStub = nvmlDeviceGetTopologyCommonAncestor + // nvml.DeviceGetTopologyNearestGpus() -func DeviceGetTopologyNearestGpus(device Device, Level GpuTopologyLevel) ([]Device, Return) { - var Count uint32 - ret := nvmlDeviceGetTopologyNearestGpus(device, Level, &Count, nil) +func (l *library) DeviceGetTopologyNearestGpus(device Device, level GpuTopologyLevel) ([]Device, Return) { + return device.GetTopologyNearestGpus(level) +} + +func (device nvmlDevice) GetTopologyNearestGpus(level GpuTopologyLevel) ([]Device, Return) { + var count uint32 + ret := nvmlDeviceGetTopologyNearestGpus(device, level, &count, nil) if ret != SUCCESS { return nil, ret } - if Count == 0 { + if count == 0 { return []Device{}, ret } - DeviceArray := make([]Device, Count) - ret = nvmlDeviceGetTopologyNearestGpus(device, Level, &Count, &DeviceArray[0]) - return DeviceArray, ret -} - -func (Device Device) GetTopologyNearestGpus(Level GpuTopologyLevel) ([]Device, Return) { - return DeviceGetTopologyNearestGpus(Device, Level) + deviceArray := make([]nvmlDevice, count) + ret = nvmlDeviceGetTopologyNearestGpus(device, level, &count, &deviceArray[0]) + return convertSlice[nvmlDevice, Device](deviceArray), ret } // nvml.DeviceGetP2PStatus() -func DeviceGetP2PStatus(Device1 Device, Device2 Device, P2pIndex GpuP2PCapsIndex) (GpuP2PStatus, Return) { - var P2pStatus GpuP2PStatus - ret := nvmlDeviceGetP2PStatus(Device1, Device2, P2pIndex, &P2pStatus) - return P2pStatus, ret +func (l *library) DeviceGetP2PStatus(device1 Device, device2 Device, p2pIndex GpuP2PCapsIndex) (GpuP2PStatus, Return) { + return device1.GetP2PStatus(device2, p2pIndex) } -func (Device1 Device) GetP2PStatus(Device2 Device, P2pIndex GpuP2PCapsIndex) (GpuP2PStatus, Return) { - return DeviceGetP2PStatus(Device1, Device2, P2pIndex) +func (device1 nvmlDevice) GetP2PStatus(device2 Device, p2pIndex GpuP2PCapsIndex) (GpuP2PStatus, Return) { + var p2pStatus GpuP2PStatus + ret := nvmlDeviceGetP2PStatus(device1, nvmlDeviceHandle(device2), p2pIndex, &p2pStatus) + return p2pStatus, ret } // nvml.DeviceGetUUID() -func DeviceGetUUID(Device Device) (string, Return) { - Uuid := make([]byte, DEVICE_UUID_V2_BUFFER_SIZE) - ret := nvmlDeviceGetUUID(Device, &Uuid[0], DEVICE_UUID_V2_BUFFER_SIZE) - return string(Uuid[:clen(Uuid)]), ret +func (l *library) DeviceGetUUID(device Device) (string, Return) { + return device.GetUUID() } -func (Device Device) GetUUID() (string, Return) { - return DeviceGetUUID(Device) +func (device nvmlDevice) GetUUID() (string, Return) { + uuid := make([]byte, DEVICE_UUID_V2_BUFFER_SIZE) + ret := nvmlDeviceGetUUID(device, &uuid[0], DEVICE_UUID_V2_BUFFER_SIZE) + return string(uuid[:clen(uuid)]), ret } // nvml.DeviceGetMinorNumber() -func DeviceGetMinorNumber(Device Device) (int, Return) { - var MinorNumber uint32 - ret := nvmlDeviceGetMinorNumber(Device, &MinorNumber) - return int(MinorNumber), ret +func (l *library) DeviceGetMinorNumber(device Device) (int, Return) { + return device.GetMinorNumber() } -func (Device Device) GetMinorNumber() (int, Return) { - return DeviceGetMinorNumber(Device) +func (device nvmlDevice) GetMinorNumber() (int, Return) { + var minorNumber uint32 + ret := nvmlDeviceGetMinorNumber(device, &minorNumber) + return int(minorNumber), ret } // nvml.DeviceGetBoardPartNumber() -func DeviceGetBoardPartNumber(Device Device) (string, Return) { - PartNumber := make([]byte, DEVICE_PART_NUMBER_BUFFER_SIZE) - ret := nvmlDeviceGetBoardPartNumber(Device, &PartNumber[0], DEVICE_PART_NUMBER_BUFFER_SIZE) - return string(PartNumber[:clen(PartNumber)]), ret +func (l *library) DeviceGetBoardPartNumber(device Device) (string, Return) { + return device.GetBoardPartNumber() } -func (Device Device) GetBoardPartNumber() (string, Return) { - return DeviceGetBoardPartNumber(Device) +func (device nvmlDevice) GetBoardPartNumber() (string, Return) { + partNumber := make([]byte, DEVICE_PART_NUMBER_BUFFER_SIZE) + ret := nvmlDeviceGetBoardPartNumber(device, &partNumber[0], DEVICE_PART_NUMBER_BUFFER_SIZE) + return string(partNumber[:clen(partNumber)]), ret } // nvml.DeviceGetInforomVersion() -func DeviceGetInforomVersion(Device Device, Object InforomObject) (string, Return) { - Version := make([]byte, DEVICE_INFOROM_VERSION_BUFFER_SIZE) - ret := nvmlDeviceGetInforomVersion(Device, Object, &Version[0], DEVICE_INFOROM_VERSION_BUFFER_SIZE) - return string(Version[:clen(Version)]), ret +func (l *library) DeviceGetInforomVersion(device Device, object InforomObject) (string, Return) { + return device.GetInforomVersion(object) } -func (Device Device) GetInforomVersion(Object InforomObject) (string, Return) { - return DeviceGetInforomVersion(Device, Object) +func (device nvmlDevice) GetInforomVersion(object InforomObject) (string, Return) { + version := make([]byte, DEVICE_INFOROM_VERSION_BUFFER_SIZE) + ret := nvmlDeviceGetInforomVersion(device, object, &version[0], DEVICE_INFOROM_VERSION_BUFFER_SIZE) + return string(version[:clen(version)]), ret } // nvml.DeviceGetInforomImageVersion() -func DeviceGetInforomImageVersion(Device Device) (string, Return) { - Version := make([]byte, DEVICE_INFOROM_VERSION_BUFFER_SIZE) - ret := nvmlDeviceGetInforomImageVersion(Device, &Version[0], DEVICE_INFOROM_VERSION_BUFFER_SIZE) - return string(Version[:clen(Version)]), ret +func (l *library) DeviceGetInforomImageVersion(device Device) (string, Return) { + return device.GetInforomImageVersion() } -func (Device Device) GetInforomImageVersion() (string, Return) { - return DeviceGetInforomImageVersion(Device) +func (device nvmlDevice) GetInforomImageVersion() (string, Return) { + version := make([]byte, DEVICE_INFOROM_VERSION_BUFFER_SIZE) + ret := nvmlDeviceGetInforomImageVersion(device, &version[0], DEVICE_INFOROM_VERSION_BUFFER_SIZE) + return string(version[:clen(version)]), ret } // nvml.DeviceGetInforomConfigurationChecksum() -func DeviceGetInforomConfigurationChecksum(Device Device) (uint32, Return) { - var Checksum uint32 - ret := nvmlDeviceGetInforomConfigurationChecksum(Device, &Checksum) - return Checksum, ret +func (l *library) DeviceGetInforomConfigurationChecksum(device Device) (uint32, Return) { + return device.GetInforomConfigurationChecksum() } -func (Device Device) GetInforomConfigurationChecksum() (uint32, Return) { - return DeviceGetInforomConfigurationChecksum(Device) +func (device nvmlDevice) GetInforomConfigurationChecksum() (uint32, Return) { + var checksum uint32 + ret := nvmlDeviceGetInforomConfigurationChecksum(device, &checksum) + return checksum, ret } // nvml.DeviceValidateInforom() -func DeviceValidateInforom(Device Device) Return { - return nvmlDeviceValidateInforom(Device) +func (l *library) DeviceValidateInforom(device Device) Return { + return device.ValidateInforom() } -func (Device Device) ValidateInforom() Return { - return DeviceValidateInforom(Device) +func (device nvmlDevice) ValidateInforom() Return { + return nvmlDeviceValidateInforom(device) } // nvml.DeviceGetDisplayMode() -func DeviceGetDisplayMode(Device Device) (EnableState, Return) { - var Display EnableState - ret := nvmlDeviceGetDisplayMode(Device, &Display) - return Display, ret +func (l *library) DeviceGetDisplayMode(device Device) (EnableState, Return) { + return device.GetDisplayMode() } -func (Device Device) GetDisplayMode() (EnableState, Return) { - return DeviceGetDisplayMode(Device) +func (device nvmlDevice) GetDisplayMode() (EnableState, Return) { + var display EnableState + ret := nvmlDeviceGetDisplayMode(device, &display) + return display, ret } // nvml.DeviceGetDisplayActive() -func DeviceGetDisplayActive(Device Device) (EnableState, Return) { - var IsActive EnableState - ret := nvmlDeviceGetDisplayActive(Device, &IsActive) - return IsActive, ret +func (l *library) DeviceGetDisplayActive(device Device) (EnableState, Return) { + return device.GetDisplayActive() } -func (Device Device) GetDisplayActive() (EnableState, Return) { - return DeviceGetDisplayActive(Device) +func (device nvmlDevice) GetDisplayActive() (EnableState, Return) { + var isActive EnableState + ret := nvmlDeviceGetDisplayActive(device, &isActive) + return isActive, ret } // nvml.DeviceGetPersistenceMode() -func DeviceGetPersistenceMode(Device Device) (EnableState, Return) { - var Mode EnableState - ret := nvmlDeviceGetPersistenceMode(Device, &Mode) - return Mode, ret +func (l *library) DeviceGetPersistenceMode(device Device) (EnableState, Return) { + return device.GetPersistenceMode() } -func (Device Device) GetPersistenceMode() (EnableState, Return) { - return DeviceGetPersistenceMode(Device) +func (device nvmlDevice) GetPersistenceMode() (EnableState, Return) { + var mode EnableState + ret := nvmlDeviceGetPersistenceMode(device, &mode) + return mode, ret } // nvml.DeviceGetPciInfo() -func DeviceGetPciInfo(Device Device) (PciInfo, Return) { - var Pci PciInfo - ret := nvmlDeviceGetPciInfo(Device, &Pci) - return Pci, ret +func (l *library) DeviceGetPciInfo(device Device) (PciInfo, Return) { + return device.GetPciInfo() } -func (Device Device) GetPciInfo() (PciInfo, Return) { - return DeviceGetPciInfo(Device) +func (device nvmlDevice) GetPciInfo() (PciInfo, Return) { + var pci PciInfo + ret := nvmlDeviceGetPciInfo(device, &pci) + return pci, ret } // nvml.DeviceGetMaxPcieLinkGeneration() -func DeviceGetMaxPcieLinkGeneration(Device Device) (int, Return) { - var MaxLinkGen uint32 - ret := nvmlDeviceGetMaxPcieLinkGeneration(Device, &MaxLinkGen) - return int(MaxLinkGen), ret +func (l *library) DeviceGetMaxPcieLinkGeneration(device Device) (int, Return) { + return device.GetMaxPcieLinkGeneration() } -func (Device Device) GetMaxPcieLinkGeneration() (int, Return) { - return DeviceGetMaxPcieLinkGeneration(Device) +func (device nvmlDevice) GetMaxPcieLinkGeneration() (int, Return) { + var maxLinkGen uint32 + ret := nvmlDeviceGetMaxPcieLinkGeneration(device, &maxLinkGen) + return int(maxLinkGen), ret } // nvml.DeviceGetMaxPcieLinkWidth() -func DeviceGetMaxPcieLinkWidth(Device Device) (int, Return) { - var MaxLinkWidth uint32 - ret := nvmlDeviceGetMaxPcieLinkWidth(Device, &MaxLinkWidth) - return int(MaxLinkWidth), ret +func (l *library) DeviceGetMaxPcieLinkWidth(device Device) (int, Return) { + return device.GetMaxPcieLinkWidth() } -func (Device Device) GetMaxPcieLinkWidth() (int, Return) { - return DeviceGetMaxPcieLinkWidth(Device) +func (device nvmlDevice) GetMaxPcieLinkWidth() (int, Return) { + var maxLinkWidth uint32 + ret := nvmlDeviceGetMaxPcieLinkWidth(device, &maxLinkWidth) + return int(maxLinkWidth), ret } // nvml.DeviceGetCurrPcieLinkGeneration() -func DeviceGetCurrPcieLinkGeneration(Device Device) (int, Return) { - var CurrLinkGen uint32 - ret := nvmlDeviceGetCurrPcieLinkGeneration(Device, &CurrLinkGen) - return int(CurrLinkGen), ret +func (l *library) DeviceGetCurrPcieLinkGeneration(device Device) (int, Return) { + return device.GetCurrPcieLinkGeneration() } -func (Device Device) GetCurrPcieLinkGeneration() (int, Return) { - return DeviceGetCurrPcieLinkGeneration(Device) +func (device nvmlDevice) GetCurrPcieLinkGeneration() (int, Return) { + var currLinkGen uint32 + ret := nvmlDeviceGetCurrPcieLinkGeneration(device, &currLinkGen) + return int(currLinkGen), ret } // nvml.DeviceGetCurrPcieLinkWidth() -func DeviceGetCurrPcieLinkWidth(Device Device) (int, Return) { - var CurrLinkWidth uint32 - ret := nvmlDeviceGetCurrPcieLinkWidth(Device, &CurrLinkWidth) - return int(CurrLinkWidth), ret +func (l *library) DeviceGetCurrPcieLinkWidth(device Device) (int, Return) { + return device.GetCurrPcieLinkWidth() } -func (Device Device) GetCurrPcieLinkWidth() (int, Return) { - return DeviceGetCurrPcieLinkWidth(Device) +func (device nvmlDevice) GetCurrPcieLinkWidth() (int, Return) { + var currLinkWidth uint32 + ret := nvmlDeviceGetCurrPcieLinkWidth(device, &currLinkWidth) + return int(currLinkWidth), ret } // nvml.DeviceGetPcieThroughput() -func DeviceGetPcieThroughput(Device Device, Counter PcieUtilCounter) (uint32, Return) { - var Value uint32 - ret := nvmlDeviceGetPcieThroughput(Device, Counter, &Value) - return Value, ret +func (l *library) DeviceGetPcieThroughput(device Device, counter PcieUtilCounter) (uint32, Return) { + return device.GetPcieThroughput(counter) } -func (Device Device) GetPcieThroughput(Counter PcieUtilCounter) (uint32, Return) { - return DeviceGetPcieThroughput(Device, Counter) +func (device nvmlDevice) GetPcieThroughput(counter PcieUtilCounter) (uint32, Return) { + var value uint32 + ret := nvmlDeviceGetPcieThroughput(device, counter, &value) + return value, ret } // nvml.DeviceGetPcieReplayCounter() -func DeviceGetPcieReplayCounter(Device Device) (int, Return) { - var Value uint32 - ret := nvmlDeviceGetPcieReplayCounter(Device, &Value) - return int(Value), ret +func (l *library) DeviceGetPcieReplayCounter(device Device) (int, Return) { + return device.GetPcieReplayCounter() } -func (Device Device) GetPcieReplayCounter() (int, Return) { - return DeviceGetPcieReplayCounter(Device) +func (device nvmlDevice) GetPcieReplayCounter() (int, Return) { + var value uint32 + ret := nvmlDeviceGetPcieReplayCounter(device, &value) + return int(value), ret } // nvml.nvmlDeviceGetClockInfo() -func DeviceGetClockInfo(Device Device, _type ClockType) (uint32, Return) { - var Clock uint32 - ret := nvmlDeviceGetClockInfo(Device, _type, &Clock) - return Clock, ret +func (l *library) DeviceGetClockInfo(device Device, clockType ClockType) (uint32, Return) { + return device.GetClockInfo(clockType) } -func (Device Device) GetClockInfo(_type ClockType) (uint32, Return) { - return DeviceGetClockInfo(Device, _type) +func (device nvmlDevice) GetClockInfo(clockType ClockType) (uint32, Return) { + var clock uint32 + ret := nvmlDeviceGetClockInfo(device, clockType, &clock) + return clock, ret } // nvml.DeviceGetMaxClockInfo() -func DeviceGetMaxClockInfo(Device Device, _type ClockType) (uint32, Return) { - var Clock uint32 - ret := nvmlDeviceGetMaxClockInfo(Device, _type, &Clock) - return Clock, ret +func (l *library) DeviceGetMaxClockInfo(device Device, clockType ClockType) (uint32, Return) { + return device.GetMaxClockInfo(clockType) } -func (Device Device) GetMaxClockInfo(_type ClockType) (uint32, Return) { - return DeviceGetMaxClockInfo(Device, _type) +func (device nvmlDevice) GetMaxClockInfo(clockType ClockType) (uint32, Return) { + var clock uint32 + ret := nvmlDeviceGetMaxClockInfo(device, clockType, &clock) + return clock, ret } // nvml.DeviceGetApplicationsClock() -func DeviceGetApplicationsClock(Device Device, ClockType ClockType) (uint32, Return) { - var ClockMHz uint32 - ret := nvmlDeviceGetApplicationsClock(Device, ClockType, &ClockMHz) - return ClockMHz, ret +func (l *library) DeviceGetApplicationsClock(device Device, clockType ClockType) (uint32, Return) { + return device.GetApplicationsClock(clockType) } -func (Device Device) GetApplicationsClock(ClockType ClockType) (uint32, Return) { - return DeviceGetApplicationsClock(Device, ClockType) +func (device nvmlDevice) GetApplicationsClock(clockType ClockType) (uint32, Return) { + var clockMHz uint32 + ret := nvmlDeviceGetApplicationsClock(device, clockType, &clockMHz) + return clockMHz, ret } // nvml.DeviceGetDefaultApplicationsClock() -func DeviceGetDefaultApplicationsClock(Device Device, ClockType ClockType) (uint32, Return) { - var ClockMHz uint32 - ret := nvmlDeviceGetDefaultApplicationsClock(Device, ClockType, &ClockMHz) - return ClockMHz, ret +func (l *library) DeviceGetDefaultApplicationsClock(device Device, clockType ClockType) (uint32, Return) { + return device.GetDefaultApplicationsClock(clockType) } -func (Device Device) GetDefaultApplicationsClock(ClockType ClockType) (uint32, Return) { - return DeviceGetDefaultApplicationsClock(Device, ClockType) +func (device nvmlDevice) GetDefaultApplicationsClock(clockType ClockType) (uint32, Return) { + var clockMHz uint32 + ret := nvmlDeviceGetDefaultApplicationsClock(device, clockType, &clockMHz) + return clockMHz, ret } // nvml.DeviceResetApplicationsClocks() -func DeviceResetApplicationsClocks(Device Device) Return { - return nvmlDeviceResetApplicationsClocks(Device) +func (l *library) DeviceResetApplicationsClocks(device Device) Return { + return device.ResetApplicationsClocks() } -func (Device Device) ResetApplicationsClocks() Return { - return DeviceResetApplicationsClocks(Device) +func (device nvmlDevice) ResetApplicationsClocks() Return { + return nvmlDeviceResetApplicationsClocks(device) } // nvml.DeviceGetClock() -func DeviceGetClock(Device Device, ClockType ClockType, ClockId ClockId) (uint32, Return) { - var ClockMHz uint32 - ret := nvmlDeviceGetClock(Device, ClockType, ClockId, &ClockMHz) - return ClockMHz, ret +func (l *library) DeviceGetClock(device Device, clockType ClockType, clockId ClockId) (uint32, Return) { + return device.GetClock(clockType, clockId) } -func (Device Device) GetClock(ClockType ClockType, ClockId ClockId) (uint32, Return) { - return DeviceGetClock(Device, ClockType, ClockId) +func (device nvmlDevice) GetClock(clockType ClockType, clockId ClockId) (uint32, Return) { + var clockMHz uint32 + ret := nvmlDeviceGetClock(device, clockType, clockId, &clockMHz) + return clockMHz, ret } // nvml.DeviceGetMaxCustomerBoostClock() -func DeviceGetMaxCustomerBoostClock(Device Device, ClockType ClockType) (uint32, Return) { - var ClockMHz uint32 - ret := nvmlDeviceGetMaxCustomerBoostClock(Device, ClockType, &ClockMHz) - return ClockMHz, ret +func (l *library) DeviceGetMaxCustomerBoostClock(device Device, clockType ClockType) (uint32, Return) { + return device.GetMaxCustomerBoostClock(clockType) } -func (Device Device) GetMaxCustomerBoostClock(ClockType ClockType) (uint32, Return) { - return DeviceGetMaxCustomerBoostClock(Device, ClockType) +func (device nvmlDevice) GetMaxCustomerBoostClock(clockType ClockType) (uint32, Return) { + var clockMHz uint32 + ret := nvmlDeviceGetMaxCustomerBoostClock(device, clockType, &clockMHz) + return clockMHz, ret } // nvml.DeviceGetSupportedMemoryClocks() -func DeviceGetSupportedMemoryClocks(Device Device) (int, uint32, Return) { - var Count, ClocksMHz uint32 - ret := nvmlDeviceGetSupportedMemoryClocks(Device, &Count, &ClocksMHz) - return int(Count), ClocksMHz, ret +func (l *library) DeviceGetSupportedMemoryClocks(device Device) (int, uint32, Return) { + return device.GetSupportedMemoryClocks() } -func (Device Device) GetSupportedMemoryClocks() (int, uint32, Return) { - return DeviceGetSupportedMemoryClocks(Device) +func (device nvmlDevice) GetSupportedMemoryClocks() (int, uint32, Return) { + var count, clocksMHz uint32 + ret := nvmlDeviceGetSupportedMemoryClocks(device, &count, &clocksMHz) + return int(count), clocksMHz, ret } // nvml.DeviceGetSupportedGraphicsClocks() -func DeviceGetSupportedGraphicsClocks(Device Device, MemoryClockMHz int) (int, uint32, Return) { - var Count, ClocksMHz uint32 - ret := nvmlDeviceGetSupportedGraphicsClocks(Device, uint32(MemoryClockMHz), &Count, &ClocksMHz) - return int(Count), ClocksMHz, ret +func (l *library) DeviceGetSupportedGraphicsClocks(device Device, memoryClockMHz int) (int, uint32, Return) { + return device.GetSupportedGraphicsClocks(memoryClockMHz) } -func (Device Device) GetSupportedGraphicsClocks(MemoryClockMHz int) (int, uint32, Return) { - return DeviceGetSupportedGraphicsClocks(Device, MemoryClockMHz) +func (device nvmlDevice) GetSupportedGraphicsClocks(memoryClockMHz int) (int, uint32, Return) { + var count, clocksMHz uint32 + ret := nvmlDeviceGetSupportedGraphicsClocks(device, uint32(memoryClockMHz), &count, &clocksMHz) + return int(count), clocksMHz, ret } // nvml.DeviceGetAutoBoostedClocksEnabled() -func DeviceGetAutoBoostedClocksEnabled(Device Device) (EnableState, EnableState, Return) { - var IsEnabled, DefaultIsEnabled EnableState - ret := nvmlDeviceGetAutoBoostedClocksEnabled(Device, &IsEnabled, &DefaultIsEnabled) - return IsEnabled, DefaultIsEnabled, ret +func (l *library) DeviceGetAutoBoostedClocksEnabled(device Device) (EnableState, EnableState, Return) { + return device.GetAutoBoostedClocksEnabled() } -func (Device Device) GetAutoBoostedClocksEnabled() (EnableState, EnableState, Return) { - return DeviceGetAutoBoostedClocksEnabled(Device) +func (device nvmlDevice) GetAutoBoostedClocksEnabled() (EnableState, EnableState, Return) { + var isEnabled, defaultIsEnabled EnableState + ret := nvmlDeviceGetAutoBoostedClocksEnabled(device, &isEnabled, &defaultIsEnabled) + return isEnabled, defaultIsEnabled, ret } // nvml.DeviceSetAutoBoostedClocksEnabled() -func DeviceSetAutoBoostedClocksEnabled(Device Device, Enabled EnableState) Return { - return nvmlDeviceSetAutoBoostedClocksEnabled(Device, Enabled) +func (l *library) DeviceSetAutoBoostedClocksEnabled(device Device, enabled EnableState) Return { + return device.SetAutoBoostedClocksEnabled(enabled) } -func (Device Device) SetAutoBoostedClocksEnabled(Enabled EnableState) Return { - return DeviceSetAutoBoostedClocksEnabled(Device, Enabled) +func (device nvmlDevice) SetAutoBoostedClocksEnabled(enabled EnableState) Return { + return nvmlDeviceSetAutoBoostedClocksEnabled(device, enabled) } // nvml.DeviceSetDefaultAutoBoostedClocksEnabled() -func DeviceSetDefaultAutoBoostedClocksEnabled(Device Device, Enabled EnableState, Flags uint32) Return { - return nvmlDeviceSetDefaultAutoBoostedClocksEnabled(Device, Enabled, Flags) +func (l *library) DeviceSetDefaultAutoBoostedClocksEnabled(device Device, enabled EnableState, flags uint32) Return { + return device.SetDefaultAutoBoostedClocksEnabled(enabled, flags) } -func (Device Device) SetDefaultAutoBoostedClocksEnabled(Enabled EnableState, Flags uint32) Return { - return DeviceSetDefaultAutoBoostedClocksEnabled(Device, Enabled, Flags) +func (device nvmlDevice) SetDefaultAutoBoostedClocksEnabled(enabled EnableState, flags uint32) Return { + return nvmlDeviceSetDefaultAutoBoostedClocksEnabled(device, enabled, flags) } // nvml.DeviceGetFanSpeed() -func DeviceGetFanSpeed(Device Device) (uint32, Return) { - var Speed uint32 - ret := nvmlDeviceGetFanSpeed(Device, &Speed) - return Speed, ret +func (l *library) DeviceGetFanSpeed(device Device) (uint32, Return) { + return device.GetFanSpeed() } -func (Device Device) GetFanSpeed() (uint32, Return) { - return DeviceGetFanSpeed(Device) +func (device nvmlDevice) GetFanSpeed() (uint32, Return) { + var speed uint32 + ret := nvmlDeviceGetFanSpeed(device, &speed) + return speed, ret } // nvml.DeviceGetFanSpeed_v2() -func DeviceGetFanSpeed_v2(Device Device, Fan int) (uint32, Return) { - var Speed uint32 - ret := nvmlDeviceGetFanSpeed_v2(Device, uint32(Fan), &Speed) - return Speed, ret +func (l *library) DeviceGetFanSpeed_v2(device Device, fan int) (uint32, Return) { + return device.GetFanSpeed_v2(fan) } -func (Device Device) GetFanSpeed_v2(Fan int) (uint32, Return) { - return DeviceGetFanSpeed_v2(Device, Fan) +func (device nvmlDevice) GetFanSpeed_v2(fan int) (uint32, Return) { + var speed uint32 + ret := nvmlDeviceGetFanSpeed_v2(device, uint32(fan), &speed) + return speed, ret } // nvml.DeviceGetNumFans() -func DeviceGetNumFans(Device Device) (int, Return) { - var NumFans uint32 - ret := nvmlDeviceGetNumFans(Device, &NumFans) - return int(NumFans), ret +func (l *library) DeviceGetNumFans(device Device) (int, Return) { + return device.GetNumFans() } -func (Device Device) GetNumFans() (int, Return) { - return DeviceGetNumFans(Device) +func (device nvmlDevice) GetNumFans() (int, Return) { + var numFans uint32 + ret := nvmlDeviceGetNumFans(device, &numFans) + return int(numFans), ret } // nvml.DeviceGetTemperature() -func DeviceGetTemperature(Device Device, SensorType TemperatureSensors) (uint32, Return) { - var Temp uint32 - ret := nvmlDeviceGetTemperature(Device, SensorType, &Temp) - return Temp, ret +func (l *library) DeviceGetTemperature(device Device, sensorType TemperatureSensors) (uint32, Return) { + return device.GetTemperature(sensorType) } -func (Device Device) GetTemperature(SensorType TemperatureSensors) (uint32, Return) { - return DeviceGetTemperature(Device, SensorType) +func (device nvmlDevice) GetTemperature(sensorType TemperatureSensors) (uint32, Return) { + var temp uint32 + ret := nvmlDeviceGetTemperature(device, sensorType, &temp) + return temp, ret } // nvml.DeviceGetTemperatureThreshold() -func DeviceGetTemperatureThreshold(Device Device, ThresholdType TemperatureThresholds) (uint32, Return) { - var Temp uint32 - ret := nvmlDeviceGetTemperatureThreshold(Device, ThresholdType, &Temp) - return Temp, ret +func (l *library) DeviceGetTemperatureThreshold(device Device, thresholdType TemperatureThresholds) (uint32, Return) { + return device.GetTemperatureThreshold(thresholdType) } -func (Device Device) GetTemperatureThreshold(ThresholdType TemperatureThresholds) (uint32, Return) { - return DeviceGetTemperatureThreshold(Device, ThresholdType) +func (device nvmlDevice) GetTemperatureThreshold(thresholdType TemperatureThresholds) (uint32, Return) { + var temp uint32 + ret := nvmlDeviceGetTemperatureThreshold(device, thresholdType, &temp) + return temp, ret } // nvml.DeviceSetTemperatureThreshold() -func DeviceSetTemperatureThreshold(Device Device, ThresholdType TemperatureThresholds, Temp int) Return { - t := int32(Temp) - ret := nvmlDeviceSetTemperatureThreshold(Device, ThresholdType, &t) - return ret +func (l *library) DeviceSetTemperatureThreshold(device Device, thresholdType TemperatureThresholds, temp int) Return { + return device.SetTemperatureThreshold(thresholdType, temp) } -func (Device Device) SetTemperatureThreshold(ThresholdType TemperatureThresholds, Temp int) Return { - return DeviceSetTemperatureThreshold(Device, ThresholdType, Temp) +func (device nvmlDevice) SetTemperatureThreshold(thresholdType TemperatureThresholds, temp int) Return { + t := int32(temp) + ret := nvmlDeviceSetTemperatureThreshold(device, thresholdType, &t) + return ret } // nvml.DeviceGetPerformanceState() -func DeviceGetPerformanceState(Device Device) (Pstates, Return) { - var PState Pstates - ret := nvmlDeviceGetPerformanceState(Device, &PState) - return PState, ret +func (l *library) DeviceGetPerformanceState(device Device) (Pstates, Return) { + return device.GetPerformanceState() } -func (Device Device) GetPerformanceState() (Pstates, Return) { - return DeviceGetPerformanceState(Device) +func (device nvmlDevice) GetPerformanceState() (Pstates, Return) { + var pState Pstates + ret := nvmlDeviceGetPerformanceState(device, &pState) + return pState, ret } // nvml.DeviceGetCurrentClocksThrottleReasons() -func DeviceGetCurrentClocksThrottleReasons(Device Device) (uint64, Return) { - var ClocksThrottleReasons uint64 - ret := nvmlDeviceGetCurrentClocksThrottleReasons(Device, &ClocksThrottleReasons) - return ClocksThrottleReasons, ret +func (l *library) DeviceGetCurrentClocksThrottleReasons(device Device) (uint64, Return) { + return device.GetCurrentClocksThrottleReasons() } -func (Device Device) GetCurrentClocksThrottleReasons() (uint64, Return) { - return DeviceGetCurrentClocksThrottleReasons(Device) +func (device nvmlDevice) GetCurrentClocksThrottleReasons() (uint64, Return) { + var clocksThrottleReasons uint64 + ret := nvmlDeviceGetCurrentClocksThrottleReasons(device, &clocksThrottleReasons) + return clocksThrottleReasons, ret } // nvml.DeviceGetSupportedClocksThrottleReasons() -func DeviceGetSupportedClocksThrottleReasons(Device Device) (uint64, Return) { - var SupportedClocksThrottleReasons uint64 - ret := nvmlDeviceGetSupportedClocksThrottleReasons(Device, &SupportedClocksThrottleReasons) - return SupportedClocksThrottleReasons, ret +func (l *library) DeviceGetSupportedClocksThrottleReasons(device Device) (uint64, Return) { + return device.GetSupportedClocksThrottleReasons() } -func (Device Device) GetSupportedClocksThrottleReasons() (uint64, Return) { - return DeviceGetSupportedClocksThrottleReasons(Device) +func (device nvmlDevice) GetSupportedClocksThrottleReasons() (uint64, Return) { + var supportedClocksThrottleReasons uint64 + ret := nvmlDeviceGetSupportedClocksThrottleReasons(device, &supportedClocksThrottleReasons) + return supportedClocksThrottleReasons, ret } // nvml.DeviceGetPowerState() -func DeviceGetPowerState(Device Device) (Pstates, Return) { - var PState Pstates - ret := nvmlDeviceGetPowerState(Device, &PState) - return PState, ret +func (l *library) DeviceGetPowerState(device Device) (Pstates, Return) { + return device.GetPowerState() } -func (Device Device) GetPowerState() (Pstates, Return) { - return DeviceGetPowerState(Device) +func (device nvmlDevice) GetPowerState() (Pstates, Return) { + var pState Pstates + ret := nvmlDeviceGetPowerState(device, &pState) + return pState, ret } // nvml.DeviceGetPowerManagementMode() -func DeviceGetPowerManagementMode(Device Device) (EnableState, Return) { - var Mode EnableState - ret := nvmlDeviceGetPowerManagementMode(Device, &Mode) - return Mode, ret +func (l *library) DeviceGetPowerManagementMode(device Device) (EnableState, Return) { + return device.GetPowerManagementMode() } -func (Device Device) GetPowerManagementMode() (EnableState, Return) { - return DeviceGetPowerManagementMode(Device) +func (device nvmlDevice) GetPowerManagementMode() (EnableState, Return) { + var mode EnableState + ret := nvmlDeviceGetPowerManagementMode(device, &mode) + return mode, ret } // nvml.DeviceGetPowerManagementLimit() -func DeviceGetPowerManagementLimit(Device Device) (uint32, Return) { - var Limit uint32 - ret := nvmlDeviceGetPowerManagementLimit(Device, &Limit) - return Limit, ret +func (l *library) DeviceGetPowerManagementLimit(device Device) (uint32, Return) { + return device.GetPowerManagementLimit() } -func (Device Device) GetPowerManagementLimit() (uint32, Return) { - return DeviceGetPowerManagementLimit(Device) +func (device nvmlDevice) GetPowerManagementLimit() (uint32, Return) { + var limit uint32 + ret := nvmlDeviceGetPowerManagementLimit(device, &limit) + return limit, ret } // nvml.DeviceGetPowerManagementLimitConstraints() -func DeviceGetPowerManagementLimitConstraints(Device Device) (uint32, uint32, Return) { - var MinLimit, MaxLimit uint32 - ret := nvmlDeviceGetPowerManagementLimitConstraints(Device, &MinLimit, &MaxLimit) - return MinLimit, MaxLimit, ret +func (l *library) DeviceGetPowerManagementLimitConstraints(device Device) (uint32, uint32, Return) { + return device.GetPowerManagementLimitConstraints() } -func (Device Device) GetPowerManagementLimitConstraints() (uint32, uint32, Return) { - return DeviceGetPowerManagementLimitConstraints(Device) +func (device nvmlDevice) GetPowerManagementLimitConstraints() (uint32, uint32, Return) { + var minLimit, maxLimit uint32 + ret := nvmlDeviceGetPowerManagementLimitConstraints(device, &minLimit, &maxLimit) + return minLimit, maxLimit, ret } // nvml.DeviceGetPowerManagementDefaultLimit() -func DeviceGetPowerManagementDefaultLimit(Device Device) (uint32, Return) { - var DefaultLimit uint32 - ret := nvmlDeviceGetPowerManagementDefaultLimit(Device, &DefaultLimit) - return DefaultLimit, ret +func (l *library) DeviceGetPowerManagementDefaultLimit(device Device) (uint32, Return) { + return device.GetPowerManagementDefaultLimit() } -func (Device Device) GetPowerManagementDefaultLimit() (uint32, Return) { - return DeviceGetPowerManagementDefaultLimit(Device) +func (device nvmlDevice) GetPowerManagementDefaultLimit() (uint32, Return) { + var defaultLimit uint32 + ret := nvmlDeviceGetPowerManagementDefaultLimit(device, &defaultLimit) + return defaultLimit, ret } // nvml.DeviceGetPowerUsage() -func DeviceGetPowerUsage(Device Device) (uint32, Return) { - var Power uint32 - ret := nvmlDeviceGetPowerUsage(Device, &Power) - return Power, ret +func (l *library) DeviceGetPowerUsage(device Device) (uint32, Return) { + return device.GetPowerUsage() } -func (Device Device) GetPowerUsage() (uint32, Return) { - return DeviceGetPowerUsage(Device) +func (device nvmlDevice) GetPowerUsage() (uint32, Return) { + var power uint32 + ret := nvmlDeviceGetPowerUsage(device, &power) + return power, ret } // nvml.DeviceGetTotalEnergyConsumption() -func DeviceGetTotalEnergyConsumption(Device Device) (uint64, Return) { - var Energy uint64 - ret := nvmlDeviceGetTotalEnergyConsumption(Device, &Energy) - return Energy, ret +func (l *library) DeviceGetTotalEnergyConsumption(device Device) (uint64, Return) { + return device.GetTotalEnergyConsumption() } -func (Device Device) GetTotalEnergyConsumption() (uint64, Return) { - return DeviceGetTotalEnergyConsumption(Device) +func (device nvmlDevice) GetTotalEnergyConsumption() (uint64, Return) { + var energy uint64 + ret := nvmlDeviceGetTotalEnergyConsumption(device, &energy) + return energy, ret } // nvml.DeviceGetEnforcedPowerLimit() -func DeviceGetEnforcedPowerLimit(Device Device) (uint32, Return) { - var Limit uint32 - ret := nvmlDeviceGetEnforcedPowerLimit(Device, &Limit) - return Limit, ret +func (l *library) DeviceGetEnforcedPowerLimit(device Device) (uint32, Return) { + return device.GetEnforcedPowerLimit() } -func (Device Device) GetEnforcedPowerLimit() (uint32, Return) { - return DeviceGetEnforcedPowerLimit(Device) +func (device nvmlDevice) GetEnforcedPowerLimit() (uint32, Return) { + var limit uint32 + ret := nvmlDeviceGetEnforcedPowerLimit(device, &limit) + return limit, ret } // nvml.DeviceGetGpuOperationMode() -func DeviceGetGpuOperationMode(Device Device) (GpuOperationMode, GpuOperationMode, Return) { - var Current, Pending GpuOperationMode - ret := nvmlDeviceGetGpuOperationMode(Device, &Current, &Pending) - return Current, Pending, ret +func (l *library) DeviceGetGpuOperationMode(device Device) (GpuOperationMode, GpuOperationMode, Return) { + return device.GetGpuOperationMode() } -func (Device Device) GetGpuOperationMode() (GpuOperationMode, GpuOperationMode, Return) { - return DeviceGetGpuOperationMode(Device) +func (device nvmlDevice) GetGpuOperationMode() (GpuOperationMode, GpuOperationMode, Return) { + var current, pending GpuOperationMode + ret := nvmlDeviceGetGpuOperationMode(device, ¤t, &pending) + return current, pending, ret } // nvml.DeviceGetMemoryInfo() -func DeviceGetMemoryInfo(Device Device) (Memory, Return) { - var Memory Memory - ret := nvmlDeviceGetMemoryInfo(Device, &Memory) - return Memory, ret +func (l *library) DeviceGetMemoryInfo(device Device) (Memory, Return) { + return device.GetMemoryInfo() } -func (Device Device) GetMemoryInfo() (Memory, Return) { - return DeviceGetMemoryInfo(Device) +func (device nvmlDevice) GetMemoryInfo() (Memory, Return) { + var memory Memory + ret := nvmlDeviceGetMemoryInfo(device, &memory) + return memory, ret } // nvml.DeviceGetMemoryInfo_v2() -func DeviceGetMemoryInfo_v2(Device Device) (Memory_v2, Return) { - var Memory Memory_v2 - Memory.Version = STRUCT_VERSION(Memory, 2) - ret := nvmlDeviceGetMemoryInfo_v2(Device, &Memory) - return Memory, ret +func (l *library) DeviceGetMemoryInfo_v2(device Device) (Memory_v2, Return) { + return device.GetMemoryInfo_v2() } -func (Device Device) GetMemoryInfo_v2() (Memory_v2, Return) { - return DeviceGetMemoryInfo_v2(Device) +func (device nvmlDevice) GetMemoryInfo_v2() (Memory_v2, Return) { + var memory Memory_v2 + memory.Version = STRUCT_VERSION(memory, 2) + ret := nvmlDeviceGetMemoryInfo_v2(device, &memory) + return memory, ret } // nvml.DeviceGetComputeMode() -func DeviceGetComputeMode(Device Device) (ComputeMode, Return) { - var Mode ComputeMode - ret := nvmlDeviceGetComputeMode(Device, &Mode) - return Mode, ret +func (l *library) DeviceGetComputeMode(device Device) (ComputeMode, Return) { + return device.GetComputeMode() } -func (Device Device) GetComputeMode() (ComputeMode, Return) { - return DeviceGetComputeMode(Device) +func (device nvmlDevice) GetComputeMode() (ComputeMode, Return) { + var mode ComputeMode + ret := nvmlDeviceGetComputeMode(device, &mode) + return mode, ret } // nvml.DeviceGetCudaComputeCapability() -func DeviceGetCudaComputeCapability(Device Device) (int, int, Return) { - var Major, Minor int32 - ret := nvmlDeviceGetCudaComputeCapability(Device, &Major, &Minor) - return int(Major), int(Minor), ret +func (l *library) DeviceGetCudaComputeCapability(device Device) (int, int, Return) { + return device.GetCudaComputeCapability() } -func (Device Device) GetCudaComputeCapability() (int, int, Return) { - return DeviceGetCudaComputeCapability(Device) +func (device nvmlDevice) GetCudaComputeCapability() (int, int, Return) { + var major, minor int32 + ret := nvmlDeviceGetCudaComputeCapability(device, &major, &minor) + return int(major), int(minor), ret } // nvml.DeviceGetEccMode() -func DeviceGetEccMode(Device Device) (EnableState, EnableState, Return) { - var Current, Pending EnableState - ret := nvmlDeviceGetEccMode(Device, &Current, &Pending) - return Current, Pending, ret +func (l *library) DeviceGetEccMode(device Device) (EnableState, EnableState, Return) { + return device.GetEccMode() } -func (Device Device) GetEccMode() (EnableState, EnableState, Return) { - return DeviceGetEccMode(Device) +func (device nvmlDevice) GetEccMode() (EnableState, EnableState, Return) { + var current, pending EnableState + ret := nvmlDeviceGetEccMode(device, ¤t, &pending) + return current, pending, ret } // nvml.DeviceGetBoardId() -func DeviceGetBoardId(Device Device) (uint32, Return) { - var BoardId uint32 - ret := nvmlDeviceGetBoardId(Device, &BoardId) - return BoardId, ret +func (l *library) DeviceGetBoardId(device Device) (uint32, Return) { + return device.GetBoardId() } -func (Device Device) GetBoardId() (uint32, Return) { - return DeviceGetBoardId(Device) +func (device nvmlDevice) GetBoardId() (uint32, Return) { + var boardId uint32 + ret := nvmlDeviceGetBoardId(device, &boardId) + return boardId, ret } // nvml.DeviceGetMultiGpuBoard() -func DeviceGetMultiGpuBoard(Device Device) (int, Return) { - var MultiGpuBool uint32 - ret := nvmlDeviceGetMultiGpuBoard(Device, &MultiGpuBool) - return int(MultiGpuBool), ret +func (l *library) DeviceGetMultiGpuBoard(device Device) (int, Return) { + return device.GetMultiGpuBoard() } -func (Device Device) GetMultiGpuBoard() (int, Return) { - return DeviceGetMultiGpuBoard(Device) +func (device nvmlDevice) GetMultiGpuBoard() (int, Return) { + var multiGpuBool uint32 + ret := nvmlDeviceGetMultiGpuBoard(device, &multiGpuBool) + return int(multiGpuBool), ret } // nvml.DeviceGetTotalEccErrors() -func DeviceGetTotalEccErrors(Device Device, ErrorType MemoryErrorType, CounterType EccCounterType) (uint64, Return) { - var EccCounts uint64 - ret := nvmlDeviceGetTotalEccErrors(Device, ErrorType, CounterType, &EccCounts) - return EccCounts, ret +func (l *library) DeviceGetTotalEccErrors(device Device, errorType MemoryErrorType, counterType EccCounterType) (uint64, Return) { + return device.GetTotalEccErrors(errorType, counterType) } -func (Device Device) GetTotalEccErrors(ErrorType MemoryErrorType, CounterType EccCounterType) (uint64, Return) { - return DeviceGetTotalEccErrors(Device, ErrorType, CounterType) +func (device nvmlDevice) GetTotalEccErrors(errorType MemoryErrorType, counterType EccCounterType) (uint64, Return) { + var eccCounts uint64 + ret := nvmlDeviceGetTotalEccErrors(device, errorType, counterType, &eccCounts) + return eccCounts, ret } // nvml.DeviceGetDetailedEccErrors() -func DeviceGetDetailedEccErrors(Device Device, ErrorType MemoryErrorType, CounterType EccCounterType) (EccErrorCounts, Return) { - var EccCounts EccErrorCounts - ret := nvmlDeviceGetDetailedEccErrors(Device, ErrorType, CounterType, &EccCounts) - return EccCounts, ret +func (l *library) DeviceGetDetailedEccErrors(device Device, errorType MemoryErrorType, counterType EccCounterType) (EccErrorCounts, Return) { + return device.GetDetailedEccErrors(errorType, counterType) } -func (Device Device) GetDetailedEccErrors(ErrorType MemoryErrorType, CounterType EccCounterType) (EccErrorCounts, Return) { - return DeviceGetDetailedEccErrors(Device, ErrorType, CounterType) +func (device nvmlDevice) GetDetailedEccErrors(errorType MemoryErrorType, counterType EccCounterType) (EccErrorCounts, Return) { + var eccCounts EccErrorCounts + ret := nvmlDeviceGetDetailedEccErrors(device, errorType, counterType, &eccCounts) + return eccCounts, ret } // nvml.DeviceGetMemoryErrorCounter() -func DeviceGetMemoryErrorCounter(Device Device, ErrorType MemoryErrorType, CounterType EccCounterType, LocationType MemoryLocation) (uint64, Return) { - var Count uint64 - ret := nvmlDeviceGetMemoryErrorCounter(Device, ErrorType, CounterType, LocationType, &Count) - return Count, ret +func (l *library) DeviceGetMemoryErrorCounter(device Device, errorType MemoryErrorType, counterType EccCounterType, locationType MemoryLocation) (uint64, Return) { + return device.GetMemoryErrorCounter(errorType, counterType, locationType) } -func (Device Device) GetMemoryErrorCounter(ErrorType MemoryErrorType, CounterType EccCounterType, LocationType MemoryLocation) (uint64, Return) { - return DeviceGetMemoryErrorCounter(Device, ErrorType, CounterType, LocationType) +func (device nvmlDevice) GetMemoryErrorCounter(errorType MemoryErrorType, counterType EccCounterType, locationType MemoryLocation) (uint64, Return) { + var count uint64 + ret := nvmlDeviceGetMemoryErrorCounter(device, errorType, counterType, locationType, &count) + return count, ret } // nvml.DeviceGetUtilizationRates() -func DeviceGetUtilizationRates(Device Device) (Utilization, Return) { - var Utilization Utilization - ret := nvmlDeviceGetUtilizationRates(Device, &Utilization) - return Utilization, ret +func (l *library) DeviceGetUtilizationRates(device Device) (Utilization, Return) { + return device.GetUtilizationRates() } -func (Device Device) GetUtilizationRates() (Utilization, Return) { - return DeviceGetUtilizationRates(Device) +func (device nvmlDevice) GetUtilizationRates() (Utilization, Return) { + var utilization Utilization + ret := nvmlDeviceGetUtilizationRates(device, &utilization) + return utilization, ret } // nvml.DeviceGetEncoderUtilization() -func DeviceGetEncoderUtilization(Device Device) (uint32, uint32, Return) { - var Utilization, SamplingPeriodUs uint32 - ret := nvmlDeviceGetEncoderUtilization(Device, &Utilization, &SamplingPeriodUs) - return Utilization, SamplingPeriodUs, ret +func (l *library) DeviceGetEncoderUtilization(device Device) (uint32, uint32, Return) { + return device.GetEncoderUtilization() } -func (Device Device) GetEncoderUtilization() (uint32, uint32, Return) { - return DeviceGetEncoderUtilization(Device) +func (device nvmlDevice) GetEncoderUtilization() (uint32, uint32, Return) { + var utilization, samplingPeriodUs uint32 + ret := nvmlDeviceGetEncoderUtilization(device, &utilization, &samplingPeriodUs) + return utilization, samplingPeriodUs, ret } // nvml.DeviceGetEncoderCapacity() -func DeviceGetEncoderCapacity(Device Device, EncoderQueryType EncoderType) (int, Return) { - var EncoderCapacity uint32 - ret := nvmlDeviceGetEncoderCapacity(Device, EncoderQueryType, &EncoderCapacity) - return int(EncoderCapacity), ret +func (l *library) DeviceGetEncoderCapacity(device Device, encoderQueryType EncoderType) (int, Return) { + return device.GetEncoderCapacity(encoderQueryType) } -func (Device Device) GetEncoderCapacity(EncoderQueryType EncoderType) (int, Return) { - return DeviceGetEncoderCapacity(Device, EncoderQueryType) +func (device nvmlDevice) GetEncoderCapacity(encoderQueryType EncoderType) (int, Return) { + var encoderCapacity uint32 + ret := nvmlDeviceGetEncoderCapacity(device, encoderQueryType, &encoderCapacity) + return int(encoderCapacity), ret } // nvml.DeviceGetEncoderStats() -func DeviceGetEncoderStats(Device Device) (int, uint32, uint32, Return) { - var SessionCount, AverageFps, AverageLatency uint32 - ret := nvmlDeviceGetEncoderStats(Device, &SessionCount, &AverageFps, &AverageLatency) - return int(SessionCount), AverageFps, AverageLatency, ret +func (l *library) DeviceGetEncoderStats(device Device) (int, uint32, uint32, Return) { + return device.GetEncoderStats() } -func (Device Device) GetEncoderStats() (int, uint32, uint32, Return) { - return DeviceGetEncoderStats(Device) +func (device nvmlDevice) GetEncoderStats() (int, uint32, uint32, Return) { + var sessionCount, averageFps, averageLatency uint32 + ret := nvmlDeviceGetEncoderStats(device, &sessionCount, &averageFps, &averageLatency) + return int(sessionCount), averageFps, averageLatency, ret } // nvml.DeviceGetEncoderSessions() -func DeviceGetEncoderSessions(Device Device) ([]EncoderSessionInfo, Return) { - var SessionCount uint32 = 1 // Will be reduced upon returning +func (l *library) DeviceGetEncoderSessions(device Device) ([]EncoderSessionInfo, Return) { + return device.GetEncoderSessions() +} + +func (device nvmlDevice) GetEncoderSessions() ([]EncoderSessionInfo, Return) { + var sessionCount uint32 = 1 // Will be reduced upon returning for { - SessionInfos := make([]EncoderSessionInfo, SessionCount) - ret := nvmlDeviceGetEncoderSessions(Device, &SessionCount, &SessionInfos[0]) + sessionInfos := make([]EncoderSessionInfo, sessionCount) + ret := nvmlDeviceGetEncoderSessions(device, &sessionCount, &sessionInfos[0]) if ret == SUCCESS { - return SessionInfos[:SessionCount], ret + return sessionInfos[:sessionCount], ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - SessionCount *= 2 + sessionCount *= 2 } } -func (Device Device) GetEncoderSessions() ([]EncoderSessionInfo, Return) { - return DeviceGetEncoderSessions(Device) -} - // nvml.DeviceGetDecoderUtilization() -func DeviceGetDecoderUtilization(Device Device) (uint32, uint32, Return) { - var Utilization, SamplingPeriodUs uint32 - ret := nvmlDeviceGetDecoderUtilization(Device, &Utilization, &SamplingPeriodUs) - return Utilization, SamplingPeriodUs, ret +func (l *library) DeviceGetDecoderUtilization(device Device) (uint32, uint32, Return) { + return device.GetDecoderUtilization() } -func (Device Device) GetDecoderUtilization() (uint32, uint32, Return) { - return DeviceGetDecoderUtilization(Device) +func (device nvmlDevice) GetDecoderUtilization() (uint32, uint32, Return) { + var utilization, samplingPeriodUs uint32 + ret := nvmlDeviceGetDecoderUtilization(device, &utilization, &samplingPeriodUs) + return utilization, samplingPeriodUs, ret } // nvml.DeviceGetFBCStats() -func DeviceGetFBCStats(Device Device) (FBCStats, Return) { - var FbcStats FBCStats - ret := nvmlDeviceGetFBCStats(Device, &FbcStats) - return FbcStats, ret +func (l *library) DeviceGetFBCStats(device Device) (FBCStats, Return) { + return device.GetFBCStats() } -func (Device Device) GetFBCStats() (FBCStats, Return) { - return DeviceGetFBCStats(Device) +func (device nvmlDevice) GetFBCStats() (FBCStats, Return) { + var fbcStats FBCStats + ret := nvmlDeviceGetFBCStats(device, &fbcStats) + return fbcStats, ret } // nvml.DeviceGetFBCSessions() -func DeviceGetFBCSessions(Device Device) ([]FBCSessionInfo, Return) { - var SessionCount uint32 = 1 // Will be reduced upon returning +func (l *library) DeviceGetFBCSessions(device Device) ([]FBCSessionInfo, Return) { + return device.GetFBCSessions() +} + +func (device nvmlDevice) GetFBCSessions() ([]FBCSessionInfo, Return) { + var sessionCount uint32 = 1 // Will be reduced upon returning for { - SessionInfo := make([]FBCSessionInfo, SessionCount) - ret := nvmlDeviceGetFBCSessions(Device, &SessionCount, &SessionInfo[0]) + sessionInfo := make([]FBCSessionInfo, sessionCount) + ret := nvmlDeviceGetFBCSessions(device, &sessionCount, &sessionInfo[0]) if ret == SUCCESS { - return SessionInfo[:SessionCount], ret + return sessionInfo[:sessionCount], ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - SessionCount *= 2 + sessionCount *= 2 } } -func (Device Device) GetFBCSessions() ([]FBCSessionInfo, Return) { - return DeviceGetFBCSessions(Device) -} - // nvml.DeviceGetDriverModel() -func DeviceGetDriverModel(Device Device) (DriverModel, DriverModel, Return) { - var Current, Pending DriverModel - ret := nvmlDeviceGetDriverModel(Device, &Current, &Pending) - return Current, Pending, ret +func (l *library) DeviceGetDriverModel(device Device) (DriverModel, DriverModel, Return) { + return device.GetDriverModel() } -func (Device Device) GetDriverModel() (DriverModel, DriverModel, Return) { - return DeviceGetDriverModel(Device) +func (device nvmlDevice) GetDriverModel() (DriverModel, DriverModel, Return) { + var current, pending DriverModel + ret := nvmlDeviceGetDriverModel(device, ¤t, &pending) + return current, pending, ret } // nvml.DeviceGetVbiosVersion() -func DeviceGetVbiosVersion(Device Device) (string, Return) { - Version := make([]byte, DEVICE_VBIOS_VERSION_BUFFER_SIZE) - ret := nvmlDeviceGetVbiosVersion(Device, &Version[0], DEVICE_VBIOS_VERSION_BUFFER_SIZE) - return string(Version[:clen(Version)]), ret +func (l *library) DeviceGetVbiosVersion(device Device) (string, Return) { + return device.GetVbiosVersion() } -func (Device Device) GetVbiosVersion() (string, Return) { - return DeviceGetVbiosVersion(Device) +func (device nvmlDevice) GetVbiosVersion() (string, Return) { + version := make([]byte, DEVICE_VBIOS_VERSION_BUFFER_SIZE) + ret := nvmlDeviceGetVbiosVersion(device, &version[0], DEVICE_VBIOS_VERSION_BUFFER_SIZE) + return string(version[:clen(version)]), ret } // nvml.DeviceGetBridgeChipInfo() -func DeviceGetBridgeChipInfo(Device Device) (BridgeChipHierarchy, Return) { - var BridgeHierarchy BridgeChipHierarchy - ret := nvmlDeviceGetBridgeChipInfo(Device, &BridgeHierarchy) - return BridgeHierarchy, ret +func (l *library) DeviceGetBridgeChipInfo(device Device) (BridgeChipHierarchy, Return) { + return device.GetBridgeChipInfo() } -func (Device Device) GetBridgeChipInfo() (BridgeChipHierarchy, Return) { - return DeviceGetBridgeChipInfo(Device) +func (device nvmlDevice) GetBridgeChipInfo() (BridgeChipHierarchy, Return) { + var bridgeHierarchy BridgeChipHierarchy + ret := nvmlDeviceGetBridgeChipInfo(device, &bridgeHierarchy) + return bridgeHierarchy, ret } // nvml.DeviceGetComputeRunningProcesses() -func deviceGetComputeRunningProcesses_v1(Device Device) ([]ProcessInfo, Return) { - var InfoCount uint32 = 1 // Will be reduced upon returning +func deviceGetComputeRunningProcesses_v1(device nvmlDevice) ([]ProcessInfo, Return) { + var infoCount uint32 = 1 // Will be reduced upon returning for { - Infos := make([]ProcessInfo_v1, InfoCount) - ret := nvmlDeviceGetComputeRunningProcesses_v1(Device, &InfoCount, &Infos[0]) + infos := make([]ProcessInfo_v1, infoCount) + ret := nvmlDeviceGetComputeRunningProcesses_v1(device, &infoCount, &infos[0]) if ret == SUCCESS { - return ProcessInfo_v1Slice(Infos[:InfoCount]).ToProcessInfoSlice(), ret + return ProcessInfo_v1Slice(infos[:infoCount]).ToProcessInfoSlice(), ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - InfoCount *= 2 + infoCount *= 2 } } -func deviceGetComputeRunningProcesses_v2(Device Device) ([]ProcessInfo, Return) { - var InfoCount uint32 = 1 // Will be reduced upon returning +func deviceGetComputeRunningProcesses_v2(device nvmlDevice) ([]ProcessInfo, Return) { + var infoCount uint32 = 1 // Will be reduced upon returning for { - Infos := make([]ProcessInfo_v2, InfoCount) - ret := nvmlDeviceGetComputeRunningProcesses_v2(Device, &InfoCount, &Infos[0]) + infos := make([]ProcessInfo_v2, infoCount) + ret := nvmlDeviceGetComputeRunningProcesses_v2(device, &infoCount, &infos[0]) if ret == SUCCESS { - return ProcessInfo_v2Slice(Infos[:InfoCount]).ToProcessInfoSlice(), ret + return ProcessInfo_v2Slice(infos[:infoCount]).ToProcessInfoSlice(), ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - InfoCount *= 2 + infoCount *= 2 } } -func deviceGetComputeRunningProcesses_v3(Device Device) ([]ProcessInfo, Return) { - var InfoCount uint32 = 1 // Will be reduced upon returning +func deviceGetComputeRunningProcesses_v3(device nvmlDevice) ([]ProcessInfo, Return) { + var infoCount uint32 = 1 // Will be reduced upon returning for { - Infos := make([]ProcessInfo, InfoCount) - ret := nvmlDeviceGetComputeRunningProcesses_v3(Device, &InfoCount, &Infos[0]) + infos := make([]ProcessInfo, infoCount) + ret := nvmlDeviceGetComputeRunningProcesses_v3(device, &infoCount, &infos[0]) if ret == SUCCESS { - return Infos[:InfoCount], ret + return infos[:infoCount], ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - InfoCount *= 2 + infoCount *= 2 } } -func (Device Device) GetComputeRunningProcesses() ([]ProcessInfo, Return) { - return DeviceGetComputeRunningProcesses(Device) +func (l *library) DeviceGetComputeRunningProcesses(device Device) ([]ProcessInfo, Return) { + return device.GetComputeRunningProcesses() +} + +func (device nvmlDevice) GetComputeRunningProcesses() ([]ProcessInfo, Return) { + return deviceGetComputeRunningProcesses(device) } // nvml.DeviceGetGraphicsRunningProcesses() -func deviceGetGraphicsRunningProcesses_v1(Device Device) ([]ProcessInfo, Return) { - var InfoCount uint32 = 1 // Will be reduced upon returning +func deviceGetGraphicsRunningProcesses_v1(device nvmlDevice) ([]ProcessInfo, Return) { + var infoCount uint32 = 1 // Will be reduced upon returning for { - Infos := make([]ProcessInfo_v1, InfoCount) - ret := nvmlDeviceGetGraphicsRunningProcesses_v1(Device, &InfoCount, &Infos[0]) + infos := make([]ProcessInfo_v1, infoCount) + ret := nvmlDeviceGetGraphicsRunningProcesses_v1(device, &infoCount, &infos[0]) if ret == SUCCESS { - return ProcessInfo_v1Slice(Infos[:InfoCount]).ToProcessInfoSlice(), ret + return ProcessInfo_v1Slice(infos[:infoCount]).ToProcessInfoSlice(), ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - InfoCount *= 2 + infoCount *= 2 } } -func deviceGetGraphicsRunningProcesses_v2(Device Device) ([]ProcessInfo, Return) { - var InfoCount uint32 = 1 // Will be reduced upon returning +func deviceGetGraphicsRunningProcesses_v2(device nvmlDevice) ([]ProcessInfo, Return) { + var infoCount uint32 = 1 // Will be reduced upon returning for { - Infos := make([]ProcessInfo_v2, InfoCount) - ret := nvmlDeviceGetGraphicsRunningProcesses_v2(Device, &InfoCount, &Infos[0]) + infos := make([]ProcessInfo_v2, infoCount) + ret := nvmlDeviceGetGraphicsRunningProcesses_v2(device, &infoCount, &infos[0]) if ret == SUCCESS { - return ProcessInfo_v2Slice(Infos[:InfoCount]).ToProcessInfoSlice(), ret + return ProcessInfo_v2Slice(infos[:infoCount]).ToProcessInfoSlice(), ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - InfoCount *= 2 + infoCount *= 2 } } -func deviceGetGraphicsRunningProcesses_v3(Device Device) ([]ProcessInfo, Return) { - var InfoCount uint32 = 1 // Will be reduced upon returning +func deviceGetGraphicsRunningProcesses_v3(device nvmlDevice) ([]ProcessInfo, Return) { + var infoCount uint32 = 1 // Will be reduced upon returning for { - Infos := make([]ProcessInfo, InfoCount) - ret := nvmlDeviceGetGraphicsRunningProcesses_v3(Device, &InfoCount, &Infos[0]) + infos := make([]ProcessInfo, infoCount) + ret := nvmlDeviceGetGraphicsRunningProcesses_v3(device, &infoCount, &infos[0]) if ret == SUCCESS { - return Infos[:InfoCount], ret + return infos[:infoCount], ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - InfoCount *= 2 + infoCount *= 2 } } -func (Device Device) GetGraphicsRunningProcesses() ([]ProcessInfo, Return) { - return DeviceGetGraphicsRunningProcesses(Device) +func (l *library) DeviceGetGraphicsRunningProcesses(device Device) ([]ProcessInfo, Return) { + return device.GetGraphicsRunningProcesses() +} + +func (device nvmlDevice) GetGraphicsRunningProcesses() ([]ProcessInfo, Return) { + return deviceGetGraphicsRunningProcesses(device) } // nvml.DeviceGetMPSComputeRunningProcesses() -func deviceGetMPSComputeRunningProcesses_v1(Device Device) ([]ProcessInfo, Return) { - var InfoCount uint32 = 1 // Will be reduced upon returning +func deviceGetMPSComputeRunningProcesses_v1(device nvmlDevice) ([]ProcessInfo, Return) { + var infoCount uint32 = 1 // Will be reduced upon returning for { - Infos := make([]ProcessInfo_v1, InfoCount) - ret := nvmlDeviceGetMPSComputeRunningProcesses_v1(Device, &InfoCount, &Infos[0]) + infos := make([]ProcessInfo_v1, infoCount) + ret := nvmlDeviceGetMPSComputeRunningProcesses_v1(device, &infoCount, &infos[0]) if ret == SUCCESS { - return ProcessInfo_v1Slice(Infos[:InfoCount]).ToProcessInfoSlice(), ret + return ProcessInfo_v1Slice(infos[:infoCount]).ToProcessInfoSlice(), ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - InfoCount *= 2 + infoCount *= 2 } } -func deviceGetMPSComputeRunningProcesses_v2(Device Device) ([]ProcessInfo, Return) { - var InfoCount uint32 = 1 // Will be reduced upon returning +func deviceGetMPSComputeRunningProcesses_v2(device nvmlDevice) ([]ProcessInfo, Return) { + var infoCount uint32 = 1 // Will be reduced upon returning for { - Infos := make([]ProcessInfo_v2, InfoCount) - ret := nvmlDeviceGetMPSComputeRunningProcesses_v2(Device, &InfoCount, &Infos[0]) + infos := make([]ProcessInfo_v2, infoCount) + ret := nvmlDeviceGetMPSComputeRunningProcesses_v2(device, &infoCount, &infos[0]) if ret == SUCCESS { - return ProcessInfo_v2Slice(Infos[:InfoCount]).ToProcessInfoSlice(), ret + return ProcessInfo_v2Slice(infos[:infoCount]).ToProcessInfoSlice(), ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - InfoCount *= 2 + infoCount *= 2 } } -func deviceGetMPSComputeRunningProcesses_v3(Device Device) ([]ProcessInfo, Return) { - var InfoCount uint32 = 1 // Will be reduced upon returning +func deviceGetMPSComputeRunningProcesses_v3(device nvmlDevice) ([]ProcessInfo, Return) { + var infoCount uint32 = 1 // Will be reduced upon returning for { - Infos := make([]ProcessInfo, InfoCount) - ret := nvmlDeviceGetMPSComputeRunningProcesses_v3(Device, &InfoCount, &Infos[0]) + infos := make([]ProcessInfo, infoCount) + ret := nvmlDeviceGetMPSComputeRunningProcesses_v3(device, &infoCount, &infos[0]) if ret == SUCCESS { - return Infos[:InfoCount], ret + return infos[:infoCount], ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - InfoCount *= 2 + infoCount *= 2 } } -func (Device Device) GetMPSComputeRunningProcesses() ([]ProcessInfo, Return) { - return DeviceGetMPSComputeRunningProcesses(Device) +func (l *library) DeviceGetMPSComputeRunningProcesses(device Device) ([]ProcessInfo, Return) { + return device.GetMPSComputeRunningProcesses() +} + +func (device nvmlDevice) GetMPSComputeRunningProcesses() ([]ProcessInfo, Return) { + return deviceGetMPSComputeRunningProcesses(device) } // nvml.DeviceOnSameBoard() -func DeviceOnSameBoard(Device1 Device, Device2 Device) (int, Return) { - var OnSameBoard int32 - ret := nvmlDeviceOnSameBoard(Device1, Device2, &OnSameBoard) - return int(OnSameBoard), ret +func (l *library) DeviceOnSameBoard(device1 Device, device2 Device) (int, Return) { + return device1.OnSameBoard(device2) } -func (Device1 Device) OnSameBoard(Device2 Device) (int, Return) { - return DeviceOnSameBoard(Device1, Device2) +func (device1 nvmlDevice) OnSameBoard(device2 Device) (int, Return) { + var onSameBoard int32 + ret := nvmlDeviceOnSameBoard(device1, nvmlDeviceHandle(device2), &onSameBoard) + return int(onSameBoard), ret } // nvml.DeviceGetAPIRestriction() -func DeviceGetAPIRestriction(Device Device, ApiType RestrictedAPI) (EnableState, Return) { - var IsRestricted EnableState - ret := nvmlDeviceGetAPIRestriction(Device, ApiType, &IsRestricted) - return IsRestricted, ret +func (l *library) DeviceGetAPIRestriction(device Device, apiType RestrictedAPI) (EnableState, Return) { + return device.GetAPIRestriction(apiType) } -func (Device Device) GetAPIRestriction(ApiType RestrictedAPI) (EnableState, Return) { - return DeviceGetAPIRestriction(Device, ApiType) +func (device nvmlDevice) GetAPIRestriction(apiType RestrictedAPI) (EnableState, Return) { + var isRestricted EnableState + ret := nvmlDeviceGetAPIRestriction(device, apiType, &isRestricted) + return isRestricted, ret } // nvml.DeviceGetSamples() -func DeviceGetSamples(Device Device, _type SamplingType, LastSeenTimeStamp uint64) (ValueType, []Sample, Return) { - var SampleValType ValueType - var SampleCount uint32 - ret := nvmlDeviceGetSamples(Device, _type, LastSeenTimeStamp, &SampleValType, &SampleCount, nil) +func (l *library) DeviceGetSamples(device Device, samplingType SamplingType, lastSeenTimestamp uint64) (ValueType, []Sample, Return) { + return device.GetSamples(samplingType, lastSeenTimestamp) +} + +func (device nvmlDevice) GetSamples(samplingType SamplingType, lastSeenTimestamp uint64) (ValueType, []Sample, Return) { + var sampleValType ValueType + var sampleCount uint32 + ret := nvmlDeviceGetSamples(device, samplingType, lastSeenTimestamp, &sampleValType, &sampleCount, nil) if ret != SUCCESS { - return SampleValType, nil, ret + return sampleValType, nil, ret } - if SampleCount == 0 { - return SampleValType, []Sample{}, ret + if sampleCount == 0 { + return sampleValType, []Sample{}, ret } - Samples := make([]Sample, SampleCount) - ret = nvmlDeviceGetSamples(Device, _type, LastSeenTimeStamp, &SampleValType, &SampleCount, &Samples[0]) - return SampleValType, Samples, ret -} - -func (Device Device) GetSamples(_type SamplingType, LastSeenTimeStamp uint64) (ValueType, []Sample, Return) { - return DeviceGetSamples(Device, _type, LastSeenTimeStamp) + samples := make([]Sample, sampleCount) + ret = nvmlDeviceGetSamples(device, samplingType, lastSeenTimestamp, &sampleValType, &sampleCount, &samples[0]) + return sampleValType, samples, ret } // nvml.DeviceGetBAR1MemoryInfo() -func DeviceGetBAR1MemoryInfo(Device Device) (BAR1Memory, Return) { - var Bar1Memory BAR1Memory - ret := nvmlDeviceGetBAR1MemoryInfo(Device, &Bar1Memory) - return Bar1Memory, ret +func (l *library) DeviceGetBAR1MemoryInfo(device Device) (BAR1Memory, Return) { + return device.GetBAR1MemoryInfo() } -func (Device Device) GetBAR1MemoryInfo() (BAR1Memory, Return) { - return DeviceGetBAR1MemoryInfo(Device) +func (device nvmlDevice) GetBAR1MemoryInfo() (BAR1Memory, Return) { + var bar1Memory BAR1Memory + ret := nvmlDeviceGetBAR1MemoryInfo(device, &bar1Memory) + return bar1Memory, ret } // nvml.DeviceGetViolationStatus() -func DeviceGetViolationStatus(Device Device, PerfPolicyType PerfPolicyType) (ViolationTime, Return) { - var ViolTime ViolationTime - ret := nvmlDeviceGetViolationStatus(Device, PerfPolicyType, &ViolTime) - return ViolTime, ret +func (l *library) DeviceGetViolationStatus(device Device, perfPolicyType PerfPolicyType) (ViolationTime, Return) { + return device.GetViolationStatus(perfPolicyType) } -func (Device Device) GetViolationStatus(PerfPolicyType PerfPolicyType) (ViolationTime, Return) { - return DeviceGetViolationStatus(Device, PerfPolicyType) +func (device nvmlDevice) GetViolationStatus(perfPolicyType PerfPolicyType) (ViolationTime, Return) { + var violTime ViolationTime + ret := nvmlDeviceGetViolationStatus(device, perfPolicyType, &violTime) + return violTime, ret } // nvml.DeviceGetIrqNum() -func DeviceGetIrqNum(Device Device) (int, Return) { - var IrqNum uint32 - ret := nvmlDeviceGetIrqNum(Device, &IrqNum) - return int(IrqNum), ret +func (l *library) DeviceGetIrqNum(device Device) (int, Return) { + return device.GetIrqNum() } -func (Device Device) GetIrqNum() (int, Return) { - return DeviceGetIrqNum(Device) +func (device nvmlDevice) GetIrqNum() (int, Return) { + var irqNum uint32 + ret := nvmlDeviceGetIrqNum(device, &irqNum) + return int(irqNum), ret } // nvml.DeviceGetNumGpuCores() -func DeviceGetNumGpuCores(Device Device) (int, Return) { - var NumCores uint32 - ret := nvmlDeviceGetNumGpuCores(Device, &NumCores) - return int(NumCores), ret +func (l *library) DeviceGetNumGpuCores(device Device) (int, Return) { + return device.GetNumGpuCores() } -func (Device Device) GetNumGpuCores() (int, Return) { - return DeviceGetNumGpuCores(Device) +func (device nvmlDevice) GetNumGpuCores() (int, Return) { + var numCores uint32 + ret := nvmlDeviceGetNumGpuCores(device, &numCores) + return int(numCores), ret } // nvml.DeviceGetPowerSource() -func DeviceGetPowerSource(Device Device) (PowerSource, Return) { - var PowerSource PowerSource - ret := nvmlDeviceGetPowerSource(Device, &PowerSource) - return PowerSource, ret +func (l *library) DeviceGetPowerSource(device Device) (PowerSource, Return) { + return device.GetPowerSource() } -func (Device Device) GetPowerSource() (PowerSource, Return) { - return DeviceGetPowerSource(Device) +func (device nvmlDevice) GetPowerSource() (PowerSource, Return) { + var powerSource PowerSource + ret := nvmlDeviceGetPowerSource(device, &powerSource) + return powerSource, ret } // nvml.DeviceGetMemoryBusWidth() -func DeviceGetMemoryBusWidth(Device Device) (uint32, Return) { - var BusWidth uint32 - ret := nvmlDeviceGetMemoryBusWidth(Device, &BusWidth) - return BusWidth, ret +func (l *library) DeviceGetMemoryBusWidth(device Device) (uint32, Return) { + return device.GetMemoryBusWidth() } -func (Device Device) GetMemoryBusWidth() (uint32, Return) { - return DeviceGetMemoryBusWidth(Device) +func (device nvmlDevice) GetMemoryBusWidth() (uint32, Return) { + var busWidth uint32 + ret := nvmlDeviceGetMemoryBusWidth(device, &busWidth) + return busWidth, ret } // nvml.DeviceGetPcieLinkMaxSpeed() -func DeviceGetPcieLinkMaxSpeed(Device Device) (uint32, Return) { - var MaxSpeed uint32 - ret := nvmlDeviceGetPcieLinkMaxSpeed(Device, &MaxSpeed) - return MaxSpeed, ret +func (l *library) DeviceGetPcieLinkMaxSpeed(device Device) (uint32, Return) { + return device.GetPcieLinkMaxSpeed() } -func (Device Device) GetPcieLinkMaxSpeed() (uint32, Return) { - return DeviceGetPcieLinkMaxSpeed(Device) +func (device nvmlDevice) GetPcieLinkMaxSpeed() (uint32, Return) { + var maxSpeed uint32 + ret := nvmlDeviceGetPcieLinkMaxSpeed(device, &maxSpeed) + return maxSpeed, ret } // nvml.DeviceGetAdaptiveClockInfoStatus() -func DeviceGetAdaptiveClockInfoStatus(Device Device) (uint32, Return) { - var AdaptiveClockStatus uint32 - ret := nvmlDeviceGetAdaptiveClockInfoStatus(Device, &AdaptiveClockStatus) - return AdaptiveClockStatus, ret +func (l *library) DeviceGetAdaptiveClockInfoStatus(device Device) (uint32, Return) { + return device.GetAdaptiveClockInfoStatus() } -func (Device Device) GetAdaptiveClockInfoStatus() (uint32, Return) { - return DeviceGetAdaptiveClockInfoStatus(Device) +func (device nvmlDevice) GetAdaptiveClockInfoStatus() (uint32, Return) { + var adaptiveClockStatus uint32 + ret := nvmlDeviceGetAdaptiveClockInfoStatus(device, &adaptiveClockStatus) + return adaptiveClockStatus, ret } // nvml.DeviceGetAccountingMode() -func DeviceGetAccountingMode(Device Device) (EnableState, Return) { - var Mode EnableState - ret := nvmlDeviceGetAccountingMode(Device, &Mode) - return Mode, ret +func (l *library) DeviceGetAccountingMode(device Device) (EnableState, Return) { + return device.GetAccountingMode() } -func (Device Device) GetAccountingMode() (EnableState, Return) { - return DeviceGetAccountingMode(Device) +func (device nvmlDevice) GetAccountingMode() (EnableState, Return) { + var mode EnableState + ret := nvmlDeviceGetAccountingMode(device, &mode) + return mode, ret } // nvml.DeviceGetAccountingStats() -func DeviceGetAccountingStats(Device Device, Pid uint32) (AccountingStats, Return) { - var Stats AccountingStats - ret := nvmlDeviceGetAccountingStats(Device, Pid, &Stats) - return Stats, ret +func (l *library) DeviceGetAccountingStats(device Device, pid uint32) (AccountingStats, Return) { + return device.GetAccountingStats(pid) } -func (Device Device) GetAccountingStats(Pid uint32) (AccountingStats, Return) { - return DeviceGetAccountingStats(Device, Pid) +func (device nvmlDevice) GetAccountingStats(pid uint32) (AccountingStats, Return) { + var stats AccountingStats + ret := nvmlDeviceGetAccountingStats(device, pid, &stats) + return stats, ret } // nvml.DeviceGetAccountingPids() -func DeviceGetAccountingPids(Device Device) ([]int, Return) { - var Count uint32 = 1 // Will be reduced upon returning +func (l *library) DeviceGetAccountingPids(device Device) ([]int, Return) { + return device.GetAccountingPids() +} + +func (device nvmlDevice) GetAccountingPids() ([]int, Return) { + var count uint32 = 1 // Will be reduced upon returning for { - Pids := make([]uint32, Count) - ret := nvmlDeviceGetAccountingPids(Device, &Count, &Pids[0]) + pids := make([]uint32, count) + ret := nvmlDeviceGetAccountingPids(device, &count, &pids[0]) if ret == SUCCESS { - return uint32SliceToIntSlice(Pids[:Count]), ret + return uint32SliceToIntSlice(pids[:count]), ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - Count *= 2 + count *= 2 } } -func (Device Device) GetAccountingPids() ([]int, Return) { - return DeviceGetAccountingPids(Device) -} - // nvml.DeviceGetAccountingBufferSize() -func DeviceGetAccountingBufferSize(Device Device) (int, Return) { - var BufferSize uint32 - ret := nvmlDeviceGetAccountingBufferSize(Device, &BufferSize) - return int(BufferSize), ret +func (l *library) DeviceGetAccountingBufferSize(device Device) (int, Return) { + return device.GetAccountingBufferSize() } -func (Device Device) GetAccountingBufferSize() (int, Return) { - return DeviceGetAccountingBufferSize(Device) +func (device nvmlDevice) GetAccountingBufferSize() (int, Return) { + var bufferSize uint32 + ret := nvmlDeviceGetAccountingBufferSize(device, &bufferSize) + return int(bufferSize), ret } // nvml.DeviceGetRetiredPages() -func DeviceGetRetiredPages(Device Device, Cause PageRetirementCause) ([]uint64, Return) { - var PageCount uint32 = 1 // Will be reduced upon returning +func (l *library) DeviceGetRetiredPages(device Device, cause PageRetirementCause) ([]uint64, Return) { + return device.GetRetiredPages(cause) +} + +func (device nvmlDevice) GetRetiredPages(cause PageRetirementCause) ([]uint64, Return) { + var pageCount uint32 = 1 // Will be reduced upon returning for { - Addresses := make([]uint64, PageCount) - ret := nvmlDeviceGetRetiredPages(Device, Cause, &PageCount, &Addresses[0]) + addresses := make([]uint64, pageCount) + ret := nvmlDeviceGetRetiredPages(device, cause, &pageCount, &addresses[0]) if ret == SUCCESS { - return Addresses[:PageCount], ret + return addresses[:pageCount], ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - PageCount *= 2 + pageCount *= 2 } } -func (Device Device) GetRetiredPages(Cause PageRetirementCause) ([]uint64, Return) { - return DeviceGetRetiredPages(Device, Cause) +// nvml.DeviceGetRetiredPages_v2() +func (l *library) DeviceGetRetiredPages_v2(device Device, cause PageRetirementCause) ([]uint64, []uint64, Return) { + return device.GetRetiredPages_v2(cause) } -// nvml.DeviceGetRetiredPages_v2() -func DeviceGetRetiredPages_v2(Device Device, Cause PageRetirementCause) ([]uint64, []uint64, Return) { - var PageCount uint32 = 1 // Will be reduced upon returning +func (device nvmlDevice) GetRetiredPages_v2(cause PageRetirementCause) ([]uint64, []uint64, Return) { + var pageCount uint32 = 1 // Will be reduced upon returning for { - Addresses := make([]uint64, PageCount) - Timestamps := make([]uint64, PageCount) - ret := nvmlDeviceGetRetiredPages_v2(Device, Cause, &PageCount, &Addresses[0], &Timestamps[0]) + addresses := make([]uint64, pageCount) + timestamps := make([]uint64, pageCount) + ret := nvmlDeviceGetRetiredPages_v2(device, cause, &pageCount, &addresses[0], ×tamps[0]) if ret == SUCCESS { - return Addresses[:PageCount], Timestamps[:PageCount], ret + return addresses[:pageCount], timestamps[:pageCount], ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, nil, ret } - PageCount *= 2 + pageCount *= 2 } } -func (Device Device) GetRetiredPages_v2(Cause PageRetirementCause) ([]uint64, []uint64, Return) { - return DeviceGetRetiredPages_v2(Device, Cause) -} - // nvml.DeviceGetRetiredPagesPendingStatus() -func DeviceGetRetiredPagesPendingStatus(Device Device) (EnableState, Return) { - var IsPending EnableState - ret := nvmlDeviceGetRetiredPagesPendingStatus(Device, &IsPending) - return IsPending, ret +func (l *library) DeviceGetRetiredPagesPendingStatus(device Device) (EnableState, Return) { + return device.GetRetiredPagesPendingStatus() } -func (Device Device) GetRetiredPagesPendingStatus() (EnableState, Return) { - return DeviceGetRetiredPagesPendingStatus(Device) +func (device nvmlDevice) GetRetiredPagesPendingStatus() (EnableState, Return) { + var isPending EnableState + ret := nvmlDeviceGetRetiredPagesPendingStatus(device, &isPending) + return isPending, ret } // nvml.DeviceSetPersistenceMode() -func DeviceSetPersistenceMode(Device Device, Mode EnableState) Return { - return nvmlDeviceSetPersistenceMode(Device, Mode) +func (l *library) DeviceSetPersistenceMode(device Device, mode EnableState) Return { + return device.SetPersistenceMode(mode) } -func (Device Device) SetPersistenceMode(Mode EnableState) Return { - return DeviceSetPersistenceMode(Device, Mode) +func (device nvmlDevice) SetPersistenceMode(mode EnableState) Return { + return nvmlDeviceSetPersistenceMode(device, mode) } // nvml.DeviceSetComputeMode() -func DeviceSetComputeMode(Device Device, Mode ComputeMode) Return { - return nvmlDeviceSetComputeMode(Device, Mode) +func (l *library) DeviceSetComputeMode(device Device, mode ComputeMode) Return { + return device.SetComputeMode(mode) } -func (Device Device) SetComputeMode(Mode ComputeMode) Return { - return DeviceSetComputeMode(Device, Mode) +func (device nvmlDevice) SetComputeMode(mode ComputeMode) Return { + return nvmlDeviceSetComputeMode(device, mode) } // nvml.DeviceSetEccMode() -func DeviceSetEccMode(Device Device, Ecc EnableState) Return { - return nvmlDeviceSetEccMode(Device, Ecc) +func (l *library) DeviceSetEccMode(device Device, ecc EnableState) Return { + return device.SetEccMode(ecc) } -func (Device Device) SetEccMode(Ecc EnableState) Return { - return DeviceSetEccMode(Device, Ecc) +func (device nvmlDevice) SetEccMode(ecc EnableState) Return { + return nvmlDeviceSetEccMode(device, ecc) } // nvml.DeviceClearEccErrorCounts() -func DeviceClearEccErrorCounts(Device Device, CounterType EccCounterType) Return { - return nvmlDeviceClearEccErrorCounts(Device, CounterType) +func (l *library) DeviceClearEccErrorCounts(device Device, counterType EccCounterType) Return { + return device.ClearEccErrorCounts(counterType) } -func (Device Device) ClearEccErrorCounts(CounterType EccCounterType) Return { - return DeviceClearEccErrorCounts(Device, CounterType) +func (device nvmlDevice) ClearEccErrorCounts(counterType EccCounterType) Return { + return nvmlDeviceClearEccErrorCounts(device, counterType) } // nvml.DeviceSetDriverModel() -func DeviceSetDriverModel(Device Device, DriverModel DriverModel, Flags uint32) Return { - return nvmlDeviceSetDriverModel(Device, DriverModel, Flags) +func (l *library) DeviceSetDriverModel(device Device, driverModel DriverModel, flags uint32) Return { + return device.SetDriverModel(driverModel, flags) } -func (Device Device) SetDriverModel(DriverModel DriverModel, Flags uint32) Return { - return DeviceSetDriverModel(Device, DriverModel, Flags) +func (device nvmlDevice) SetDriverModel(driverModel DriverModel, flags uint32) Return { + return nvmlDeviceSetDriverModel(device, driverModel, flags) } // nvml.DeviceSetGpuLockedClocks() -func DeviceSetGpuLockedClocks(Device Device, MinGpuClockMHz uint32, MaxGpuClockMHz uint32) Return { - return nvmlDeviceSetGpuLockedClocks(Device, MinGpuClockMHz, MaxGpuClockMHz) +func (l *library) DeviceSetGpuLockedClocks(device Device, minGpuClockMHz uint32, maxGpuClockMHz uint32) Return { + return device.SetGpuLockedClocks(minGpuClockMHz, maxGpuClockMHz) } -func (Device Device) SetGpuLockedClocks(MinGpuClockMHz uint32, MaxGpuClockMHz uint32) Return { - return DeviceSetGpuLockedClocks(Device, MinGpuClockMHz, MaxGpuClockMHz) +func (device nvmlDevice) SetGpuLockedClocks(minGpuClockMHz uint32, maxGpuClockMHz uint32) Return { + return nvmlDeviceSetGpuLockedClocks(device, minGpuClockMHz, maxGpuClockMHz) } // nvml.DeviceResetGpuLockedClocks() -func DeviceResetGpuLockedClocks(Device Device) Return { - return nvmlDeviceResetGpuLockedClocks(Device) +func (l *library) DeviceResetGpuLockedClocks(device Device) Return { + return device.ResetGpuLockedClocks() } -func (Device Device) ResetGpuLockedClocks() Return { - return DeviceResetGpuLockedClocks(Device) +func (device nvmlDevice) ResetGpuLockedClocks() Return { + return nvmlDeviceResetGpuLockedClocks(device) } // nvmlDeviceSetMemoryLockedClocks() -func DeviceSetMemoryLockedClocks(Device Device, MinMemClockMHz uint32, MaxMemClockMHz uint32) Return { - return nvmlDeviceSetMemoryLockedClocks(Device, MinMemClockMHz, MaxMemClockMHz) +func (l *library) DeviceSetMemoryLockedClocks(device Device, minMemClockMHz uint32, maxMemClockMHz uint32) Return { + return device.SetMemoryLockedClocks(minMemClockMHz, maxMemClockMHz) } -func (Device Device) SetMemoryLockedClocks(NinMemClockMHz uint32, MaxMemClockMHz uint32) Return { - return DeviceSetMemoryLockedClocks(Device, NinMemClockMHz, MaxMemClockMHz) +func (device nvmlDevice) SetMemoryLockedClocks(minMemClockMHz uint32, maxMemClockMHz uint32) Return { + return nvmlDeviceSetMemoryLockedClocks(device, minMemClockMHz, maxMemClockMHz) } // nvmlDeviceResetMemoryLockedClocks() -func DeviceResetMemoryLockedClocks(Device Device) Return { - return nvmlDeviceResetMemoryLockedClocks(Device) +func (l *library) DeviceResetMemoryLockedClocks(device Device) Return { + return device.ResetMemoryLockedClocks() } -func (Device Device) ResetMemoryLockedClocks() Return { - return DeviceResetMemoryLockedClocks(Device) +func (device nvmlDevice) ResetMemoryLockedClocks() Return { + return nvmlDeviceResetMemoryLockedClocks(device) } // nvml.DeviceGetClkMonStatus() -func DeviceGetClkMonStatus(Device Device) (ClkMonStatus, Return) { - var Status ClkMonStatus - ret := nvmlDeviceGetClkMonStatus(Device, &Status) - return Status, ret +func (l *library) DeviceGetClkMonStatus(device Device) (ClkMonStatus, Return) { + return device.GetClkMonStatus() } -func (Device Device) GetClkMonStatus() (ClkMonStatus, Return) { - return DeviceGetClkMonStatus(Device) +func (device nvmlDevice) GetClkMonStatus() (ClkMonStatus, Return) { + var status ClkMonStatus + ret := nvmlDeviceGetClkMonStatus(device, &status) + return status, ret } // nvml.DeviceSetApplicationsClocks() -func DeviceSetApplicationsClocks(Device Device, MemClockMHz uint32, GraphicsClockMHz uint32) Return { - return nvmlDeviceSetApplicationsClocks(Device, MemClockMHz, GraphicsClockMHz) +func (l *library) DeviceSetApplicationsClocks(device Device, memClockMHz uint32, graphicsClockMHz uint32) Return { + return device.SetApplicationsClocks(memClockMHz, graphicsClockMHz) } -func (Device Device) SetApplicationsClocks(MemClockMHz uint32, GraphicsClockMHz uint32) Return { - return DeviceSetApplicationsClocks(Device, MemClockMHz, GraphicsClockMHz) +func (device nvmlDevice) SetApplicationsClocks(memClockMHz uint32, graphicsClockMHz uint32) Return { + return nvmlDeviceSetApplicationsClocks(device, memClockMHz, graphicsClockMHz) } // nvml.DeviceSetPowerManagementLimit() -func DeviceSetPowerManagementLimit(Device Device, Limit uint32) Return { - return nvmlDeviceSetPowerManagementLimit(Device, Limit) +func (l *library) DeviceSetPowerManagementLimit(device Device, limit uint32) Return { + return device.SetPowerManagementLimit(limit) } -func (Device Device) SetPowerManagementLimit(Limit uint32) Return { - return DeviceSetPowerManagementLimit(Device, Limit) +func (device nvmlDevice) SetPowerManagementLimit(limit uint32) Return { + return nvmlDeviceSetPowerManagementLimit(device, limit) } // nvml.DeviceSetGpuOperationMode() -func DeviceSetGpuOperationMode(Device Device, Mode GpuOperationMode) Return { - return nvmlDeviceSetGpuOperationMode(Device, Mode) +func (l *library) DeviceSetGpuOperationMode(device Device, mode GpuOperationMode) Return { + return device.SetGpuOperationMode(mode) } -func (Device Device) SetGpuOperationMode(Mode GpuOperationMode) Return { - return DeviceSetGpuOperationMode(Device, Mode) +func (device nvmlDevice) SetGpuOperationMode(mode GpuOperationMode) Return { + return nvmlDeviceSetGpuOperationMode(device, mode) } // nvml.DeviceSetAPIRestriction() -func DeviceSetAPIRestriction(Device Device, ApiType RestrictedAPI, IsRestricted EnableState) Return { - return nvmlDeviceSetAPIRestriction(Device, ApiType, IsRestricted) +func (l *library) DeviceSetAPIRestriction(device Device, apiType RestrictedAPI, isRestricted EnableState) Return { + return device.SetAPIRestriction(apiType, isRestricted) } -func (Device Device) SetAPIRestriction(ApiType RestrictedAPI, IsRestricted EnableState) Return { - return DeviceSetAPIRestriction(Device, ApiType, IsRestricted) +func (device nvmlDevice) SetAPIRestriction(apiType RestrictedAPI, isRestricted EnableState) Return { + return nvmlDeviceSetAPIRestriction(device, apiType, isRestricted) } // nvml.DeviceSetAccountingMode() -func DeviceSetAccountingMode(Device Device, Mode EnableState) Return { - return nvmlDeviceSetAccountingMode(Device, Mode) +func (l *library) DeviceSetAccountingMode(device Device, mode EnableState) Return { + return device.SetAccountingMode(mode) } -func (Device Device) SetAccountingMode(Mode EnableState) Return { - return DeviceSetAccountingMode(Device, Mode) +func (device nvmlDevice) SetAccountingMode(mode EnableState) Return { + return nvmlDeviceSetAccountingMode(device, mode) } // nvml.DeviceClearAccountingPids() -func DeviceClearAccountingPids(Device Device) Return { - return nvmlDeviceClearAccountingPids(Device) +func (l *library) DeviceClearAccountingPids(device Device) Return { + return device.ClearAccountingPids() } -func (Device Device) ClearAccountingPids() Return { - return DeviceClearAccountingPids(Device) +func (device nvmlDevice) ClearAccountingPids() Return { + return nvmlDeviceClearAccountingPids(device) } // nvml.DeviceGetNvLinkState() -func DeviceGetNvLinkState(Device Device, Link int) (EnableState, Return) { - var IsActive EnableState - ret := nvmlDeviceGetNvLinkState(Device, uint32(Link), &IsActive) - return IsActive, ret +func (l *library) DeviceGetNvLinkState(device Device, link int) (EnableState, Return) { + return device.GetNvLinkState(link) } -func (Device Device) GetNvLinkState(Link int) (EnableState, Return) { - return DeviceGetNvLinkState(Device, Link) +func (device nvmlDevice) GetNvLinkState(link int) (EnableState, Return) { + var isActive EnableState + ret := nvmlDeviceGetNvLinkState(device, uint32(link), &isActive) + return isActive, ret } // nvml.DeviceGetNvLinkVersion() -func DeviceGetNvLinkVersion(Device Device, Link int) (uint32, Return) { - var Version uint32 - ret := nvmlDeviceGetNvLinkVersion(Device, uint32(Link), &Version) - return Version, ret +func (l *library) DeviceGetNvLinkVersion(device Device, link int) (uint32, Return) { + return device.GetNvLinkVersion(link) } -func (Device Device) GetNvLinkVersion(Link int) (uint32, Return) { - return DeviceGetNvLinkVersion(Device, Link) +func (device nvmlDevice) GetNvLinkVersion(link int) (uint32, Return) { + var version uint32 + ret := nvmlDeviceGetNvLinkVersion(device, uint32(link), &version) + return version, ret } // nvml.DeviceGetNvLinkCapability() -func DeviceGetNvLinkCapability(Device Device, Link int, Capability NvLinkCapability) (uint32, Return) { - var CapResult uint32 - ret := nvmlDeviceGetNvLinkCapability(Device, uint32(Link), Capability, &CapResult) - return CapResult, ret +func (l *library) DeviceGetNvLinkCapability(device Device, link int, capability NvLinkCapability) (uint32, Return) { + return device.GetNvLinkCapability(link, capability) } -func (Device Device) GetNvLinkCapability(Link int, Capability NvLinkCapability) (uint32, Return) { - return DeviceGetNvLinkCapability(Device, Link, Capability) +func (device nvmlDevice) GetNvLinkCapability(link int, capability NvLinkCapability) (uint32, Return) { + var capResult uint32 + ret := nvmlDeviceGetNvLinkCapability(device, uint32(link), capability, &capResult) + return capResult, ret } // nvml.DeviceGetNvLinkRemotePciInfo() -func DeviceGetNvLinkRemotePciInfo(Device Device, Link int) (PciInfo, Return) { - var Pci PciInfo - ret := nvmlDeviceGetNvLinkRemotePciInfo(Device, uint32(Link), &Pci) - return Pci, ret +func (l *library) DeviceGetNvLinkRemotePciInfo(device Device, link int) (PciInfo, Return) { + return device.GetNvLinkRemotePciInfo(link) } -func (Device Device) GetNvLinkRemotePciInfo(Link int) (PciInfo, Return) { - return DeviceGetNvLinkRemotePciInfo(Device, Link) +func (device nvmlDevice) GetNvLinkRemotePciInfo(link int) (PciInfo, Return) { + var pci PciInfo + ret := nvmlDeviceGetNvLinkRemotePciInfo(device, uint32(link), &pci) + return pci, ret } // nvml.DeviceGetNvLinkErrorCounter() -func DeviceGetNvLinkErrorCounter(Device Device, Link int, Counter NvLinkErrorCounter) (uint64, Return) { - var CounterValue uint64 - ret := nvmlDeviceGetNvLinkErrorCounter(Device, uint32(Link), Counter, &CounterValue) - return CounterValue, ret +func (l *library) DeviceGetNvLinkErrorCounter(device Device, link int, counter NvLinkErrorCounter) (uint64, Return) { + return device.GetNvLinkErrorCounter(link, counter) } -func (Device Device) GetNvLinkErrorCounter(Link int, Counter NvLinkErrorCounter) (uint64, Return) { - return DeviceGetNvLinkErrorCounter(Device, Link, Counter) +func (device nvmlDevice) GetNvLinkErrorCounter(link int, counter NvLinkErrorCounter) (uint64, Return) { + var counterValue uint64 + ret := nvmlDeviceGetNvLinkErrorCounter(device, uint32(link), counter, &counterValue) + return counterValue, ret } // nvml.DeviceResetNvLinkErrorCounters() -func DeviceResetNvLinkErrorCounters(Device Device, Link int) Return { - return nvmlDeviceResetNvLinkErrorCounters(Device, uint32(Link)) +func (l *library) DeviceResetNvLinkErrorCounters(device Device, link int) Return { + return device.ResetNvLinkErrorCounters(link) } -func (Device Device) ResetNvLinkErrorCounters(Link int) Return { - return DeviceResetNvLinkErrorCounters(Device, Link) +func (device nvmlDevice) ResetNvLinkErrorCounters(link int) Return { + return nvmlDeviceResetNvLinkErrorCounters(device, uint32(link)) } // nvml.DeviceSetNvLinkUtilizationControl() -func DeviceSetNvLinkUtilizationControl(Device Device, Link int, Counter int, Control *NvLinkUtilizationControl, Reset bool) Return { - reset := uint32(0) - if Reset { - reset = 1 - } - return nvmlDeviceSetNvLinkUtilizationControl(Device, uint32(Link), uint32(Counter), Control, reset) +func (l *library) DeviceSetNvLinkUtilizationControl(device Device, link int, counter int, control *NvLinkUtilizationControl, reset bool) Return { + return device.SetNvLinkUtilizationControl(link, counter, control, reset) } -func (Device Device) SetNvLinkUtilizationControl(Link int, Counter int, Control *NvLinkUtilizationControl, Reset bool) Return { - return DeviceSetNvLinkUtilizationControl(Device, Link, Counter, Control, Reset) +func (device nvmlDevice) SetNvLinkUtilizationControl(link int, counter int, control *NvLinkUtilizationControl, reset bool) Return { + resetValue := uint32(0) + if reset { + resetValue = 1 + } + return nvmlDeviceSetNvLinkUtilizationControl(device, uint32(link), uint32(counter), control, resetValue) } // nvml.DeviceGetNvLinkUtilizationControl() -func DeviceGetNvLinkUtilizationControl(Device Device, Link int, Counter int) (NvLinkUtilizationControl, Return) { - var Control NvLinkUtilizationControl - ret := nvmlDeviceGetNvLinkUtilizationControl(Device, uint32(Link), uint32(Counter), &Control) - return Control, ret +func (l *library) DeviceGetNvLinkUtilizationControl(device Device, link int, counter int) (NvLinkUtilizationControl, Return) { + return device.GetNvLinkUtilizationControl(link, counter) } -func (Device Device) GetNvLinkUtilizationControl(Link int, Counter int) (NvLinkUtilizationControl, Return) { - return DeviceGetNvLinkUtilizationControl(Device, Link, Counter) +func (device nvmlDevice) GetNvLinkUtilizationControl(link int, counter int) (NvLinkUtilizationControl, Return) { + var control NvLinkUtilizationControl + ret := nvmlDeviceGetNvLinkUtilizationControl(device, uint32(link), uint32(counter), &control) + return control, ret } // nvml.DeviceGetNvLinkUtilizationCounter() -func DeviceGetNvLinkUtilizationCounter(Device Device, Link int, Counter int) (uint64, uint64, Return) { - var Rxcounter, Txcounter uint64 - ret := nvmlDeviceGetNvLinkUtilizationCounter(Device, uint32(Link), uint32(Counter), &Rxcounter, &Txcounter) - return Rxcounter, Txcounter, ret +func (l *library) DeviceGetNvLinkUtilizationCounter(device Device, link int, counter int) (uint64, uint64, Return) { + return device.GetNvLinkUtilizationCounter(link, counter) } -func (Device Device) GetNvLinkUtilizationCounter(Link int, Counter int) (uint64, uint64, Return) { - return DeviceGetNvLinkUtilizationCounter(Device, Link, Counter) +func (device nvmlDevice) GetNvLinkUtilizationCounter(link int, counter int) (uint64, uint64, Return) { + var rxCounter, txCounter uint64 + ret := nvmlDeviceGetNvLinkUtilizationCounter(device, uint32(link), uint32(counter), &rxCounter, &txCounter) + return rxCounter, txCounter, ret } // nvml.DeviceFreezeNvLinkUtilizationCounter() -func DeviceFreezeNvLinkUtilizationCounter(Device Device, Link int, Counter int, Freeze EnableState) Return { - return nvmlDeviceFreezeNvLinkUtilizationCounter(Device, uint32(Link), uint32(Counter), Freeze) +func (l *library) DeviceFreezeNvLinkUtilizationCounter(device Device, link int, counter int, freeze EnableState) Return { + return device.FreezeNvLinkUtilizationCounter(link, counter, freeze) } -func (Device Device) FreezeNvLinkUtilizationCounter(Link int, Counter int, Freeze EnableState) Return { - return DeviceFreezeNvLinkUtilizationCounter(Device, Link, Counter, Freeze) +func (device nvmlDevice) FreezeNvLinkUtilizationCounter(link int, counter int, freeze EnableState) Return { + return nvmlDeviceFreezeNvLinkUtilizationCounter(device, uint32(link), uint32(counter), freeze) } // nvml.DeviceResetNvLinkUtilizationCounter() -func DeviceResetNvLinkUtilizationCounter(Device Device, Link int, Counter int) Return { - return nvmlDeviceResetNvLinkUtilizationCounter(Device, uint32(Link), uint32(Counter)) +func (l *library) DeviceResetNvLinkUtilizationCounter(device Device, link int, counter int) Return { + return device.ResetNvLinkUtilizationCounter(link, counter) } -func (Device Device) ResetNvLinkUtilizationCounter(Link int, Counter int) Return { - return DeviceResetNvLinkUtilizationCounter(Device, Link, Counter) +func (device nvmlDevice) ResetNvLinkUtilizationCounter(link int, counter int) Return { + return nvmlDeviceResetNvLinkUtilizationCounter(device, uint32(link), uint32(counter)) } // nvml.DeviceGetNvLinkRemoteDeviceType() -func DeviceGetNvLinkRemoteDeviceType(Device Device, Link int) (IntNvLinkDeviceType, Return) { - var NvLinkDeviceType IntNvLinkDeviceType - ret := nvmlDeviceGetNvLinkRemoteDeviceType(Device, uint32(Link), &NvLinkDeviceType) - return NvLinkDeviceType, ret +func (l *library) DeviceGetNvLinkRemoteDeviceType(device Device, link int) (IntNvLinkDeviceType, Return) { + return device.GetNvLinkRemoteDeviceType(link) } -func (Device Device) GetNvLinkRemoteDeviceType(Link int) (IntNvLinkDeviceType, Return) { - return DeviceGetNvLinkRemoteDeviceType(Device, Link) +func (device nvmlDevice) GetNvLinkRemoteDeviceType(link int) (IntNvLinkDeviceType, Return) { + var nvLinkDeviceType IntNvLinkDeviceType + ret := nvmlDeviceGetNvLinkRemoteDeviceType(device, uint32(link), &nvLinkDeviceType) + return nvLinkDeviceType, ret } // nvml.DeviceRegisterEvents() -func DeviceRegisterEvents(Device Device, EventTypes uint64, Set EventSet) Return { - return nvmlDeviceRegisterEvents(Device, EventTypes, Set) +func (l *library) DeviceRegisterEvents(device Device, eventTypes uint64, set EventSet) Return { + return device.RegisterEvents(eventTypes, set) } -func (Device Device) RegisterEvents(EventTypes uint64, Set EventSet) Return { - return DeviceRegisterEvents(Device, EventTypes, Set) +func (device nvmlDevice) RegisterEvents(eventTypes uint64, set EventSet) Return { + return nvmlDeviceRegisterEvents(device, eventTypes, set.(nvmlEventSet)) } // nvmlDeviceGetSupportedEventTypes() -func DeviceGetSupportedEventTypes(Device Device) (uint64, Return) { - var EventTypes uint64 - ret := nvmlDeviceGetSupportedEventTypes(Device, &EventTypes) - return EventTypes, ret +func (l *library) DeviceGetSupportedEventTypes(device Device) (uint64, Return) { + return device.GetSupportedEventTypes() } -func (Device Device) GetSupportedEventTypes() (uint64, Return) { - return DeviceGetSupportedEventTypes(Device) +func (device nvmlDevice) GetSupportedEventTypes() (uint64, Return) { + var eventTypes uint64 + ret := nvmlDeviceGetSupportedEventTypes(device, &eventTypes) + return eventTypes, ret } // nvml.DeviceModifyDrainState() -func DeviceModifyDrainState(PciInfo *PciInfo, NewState EnableState) Return { - return nvmlDeviceModifyDrainState(PciInfo, NewState) +func (l *library) DeviceModifyDrainState(pciInfo *PciInfo, newState EnableState) Return { + return nvmlDeviceModifyDrainState(pciInfo, newState) } // nvml.DeviceQueryDrainState() -func DeviceQueryDrainState(PciInfo *PciInfo) (EnableState, Return) { - var CurrentState EnableState - ret := nvmlDeviceQueryDrainState(PciInfo, &CurrentState) - return CurrentState, ret +func (l *library) DeviceQueryDrainState(pciInfo *PciInfo) (EnableState, Return) { + var currentState EnableState + ret := nvmlDeviceQueryDrainState(pciInfo, ¤tState) + return currentState, ret } // nvml.DeviceRemoveGpu() -func DeviceRemoveGpu(PciInfo *PciInfo) Return { - return nvmlDeviceRemoveGpu(PciInfo) +func (l *library) DeviceRemoveGpu(pciInfo *PciInfo) Return { + return nvmlDeviceRemoveGpu(pciInfo) } // nvml.DeviceRemoveGpu_v2() -func DeviceRemoveGpu_v2(PciInfo *PciInfo, GpuState DetachGpuState, LinkState PcieLinkState) Return { - return nvmlDeviceRemoveGpu_v2(PciInfo, GpuState, LinkState) +func (l *library) DeviceRemoveGpu_v2(pciInfo *PciInfo, gpuState DetachGpuState, linkState PcieLinkState) Return { + return nvmlDeviceRemoveGpu_v2(pciInfo, gpuState, linkState) } // nvml.DeviceDiscoverGpus() -func DeviceDiscoverGpus() (PciInfo, Return) { - var PciInfo PciInfo - ret := nvmlDeviceDiscoverGpus(&PciInfo) - return PciInfo, ret +func (l *library) DeviceDiscoverGpus() (PciInfo, Return) { + var pciInfo PciInfo + ret := nvmlDeviceDiscoverGpus(&pciInfo) + return pciInfo, ret } // nvml.DeviceGetFieldValues() -func DeviceGetFieldValues(Device Device, Values []FieldValue) Return { - ValuesCount := len(Values) - return nvmlDeviceGetFieldValues(Device, int32(ValuesCount), &Values[0]) +func (l *library) DeviceGetFieldValues(device Device, values []FieldValue) Return { + return device.GetFieldValues(values) } -func (Device Device) GetFieldValues(Values []FieldValue) Return { - return DeviceGetFieldValues(Device, Values) +func (device nvmlDevice) GetFieldValues(values []FieldValue) Return { + valuesCount := len(values) + return nvmlDeviceGetFieldValues(device, int32(valuesCount), &values[0]) } // nvml.DeviceGetVirtualizationMode() -func DeviceGetVirtualizationMode(Device Device) (GpuVirtualizationMode, Return) { - var PVirtualMode GpuVirtualizationMode - ret := nvmlDeviceGetVirtualizationMode(Device, &PVirtualMode) - return PVirtualMode, ret +func (l *library) DeviceGetVirtualizationMode(device Device) (GpuVirtualizationMode, Return) { + return device.GetVirtualizationMode() } -func (Device Device) GetVirtualizationMode() (GpuVirtualizationMode, Return) { - return DeviceGetVirtualizationMode(Device) +func (device nvmlDevice) GetVirtualizationMode() (GpuVirtualizationMode, Return) { + var pVirtualMode GpuVirtualizationMode + ret := nvmlDeviceGetVirtualizationMode(device, &pVirtualMode) + return pVirtualMode, ret } // nvml.DeviceGetHostVgpuMode() -func DeviceGetHostVgpuMode(Device Device) (HostVgpuMode, Return) { - var PHostVgpuMode HostVgpuMode - ret := nvmlDeviceGetHostVgpuMode(Device, &PHostVgpuMode) - return PHostVgpuMode, ret +func (l *library) DeviceGetHostVgpuMode(device Device) (HostVgpuMode, Return) { + return device.GetHostVgpuMode() } -func (Device Device) GetHostVgpuMode() (HostVgpuMode, Return) { - return DeviceGetHostVgpuMode(Device) +func (device nvmlDevice) GetHostVgpuMode() (HostVgpuMode, Return) { + var pHostVgpuMode HostVgpuMode + ret := nvmlDeviceGetHostVgpuMode(device, &pHostVgpuMode) + return pHostVgpuMode, ret } // nvml.DeviceSetVirtualizationMode() -func DeviceSetVirtualizationMode(Device Device, VirtualMode GpuVirtualizationMode) Return { - return nvmlDeviceSetVirtualizationMode(Device, VirtualMode) +func (l *library) DeviceSetVirtualizationMode(device Device, virtualMode GpuVirtualizationMode) Return { + return device.SetVirtualizationMode(virtualMode) } -func (Device Device) SetVirtualizationMode(VirtualMode GpuVirtualizationMode) Return { - return DeviceSetVirtualizationMode(Device, VirtualMode) +func (device nvmlDevice) SetVirtualizationMode(virtualMode GpuVirtualizationMode) Return { + return nvmlDeviceSetVirtualizationMode(device, virtualMode) } // nvml.DeviceGetGridLicensableFeatures() -func DeviceGetGridLicensableFeatures(Device Device) (GridLicensableFeatures, Return) { - var PGridLicensableFeatures GridLicensableFeatures - ret := nvmlDeviceGetGridLicensableFeatures(Device, &PGridLicensableFeatures) - return PGridLicensableFeatures, ret +func (l *library) DeviceGetGridLicensableFeatures(device Device) (GridLicensableFeatures, Return) { + return device.GetGridLicensableFeatures() } -func (Device Device) GetGridLicensableFeatures() (GridLicensableFeatures, Return) { - return DeviceGetGridLicensableFeatures(Device) +func (device nvmlDevice) GetGridLicensableFeatures() (GridLicensableFeatures, Return) { + var pGridLicensableFeatures GridLicensableFeatures + ret := nvmlDeviceGetGridLicensableFeatures(device, &pGridLicensableFeatures) + return pGridLicensableFeatures, ret } // nvml.DeviceGetProcessUtilization() -func DeviceGetProcessUtilization(Device Device, LastSeenTimeStamp uint64) ([]ProcessUtilizationSample, Return) { - var ProcessSamplesCount uint32 - ret := nvmlDeviceGetProcessUtilization(Device, nil, &ProcessSamplesCount, LastSeenTimeStamp) +func (l *library) DeviceGetProcessUtilization(device Device, lastSeenTimestamp uint64) ([]ProcessUtilizationSample, Return) { + return device.GetProcessUtilization(lastSeenTimestamp) +} + +func (device nvmlDevice) GetProcessUtilization(lastSeenTimestamp uint64) ([]ProcessUtilizationSample, Return) { + var processSamplesCount uint32 + ret := nvmlDeviceGetProcessUtilization(device, nil, &processSamplesCount, lastSeenTimestamp) if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - if ProcessSamplesCount == 0 { + if processSamplesCount == 0 { return []ProcessUtilizationSample{}, ret } - Utilization := make([]ProcessUtilizationSample, ProcessSamplesCount) - ret = nvmlDeviceGetProcessUtilization(Device, &Utilization[0], &ProcessSamplesCount, LastSeenTimeStamp) - return Utilization[:ProcessSamplesCount], ret + utilization := make([]ProcessUtilizationSample, processSamplesCount) + ret = nvmlDeviceGetProcessUtilization(device, &utilization[0], &processSamplesCount, lastSeenTimestamp) + return utilization[:processSamplesCount], ret } -func (Device Device) GetProcessUtilization(LastSeenTimeStamp uint64) ([]ProcessUtilizationSample, Return) { - return DeviceGetProcessUtilization(Device, LastSeenTimeStamp) +// nvml.DeviceGetSupportedVgpus() +func (l *library) DeviceGetSupportedVgpus(device Device) ([]VgpuTypeId, Return) { + return device.GetSupportedVgpus() } -// nvml.DeviceGetSupportedVgpus() -func DeviceGetSupportedVgpus(Device Device) ([]VgpuTypeId, Return) { - var VgpuCount uint32 = 1 // Will be reduced upon returning +func (device nvmlDevice) GetSupportedVgpus() ([]VgpuTypeId, Return) { + var vgpuCount uint32 = 1 // Will be reduced upon returning for { - VgpuTypeIds := make([]VgpuTypeId, VgpuCount) - ret := nvmlDeviceGetSupportedVgpus(Device, &VgpuCount, &VgpuTypeIds[0]) + vgpuTypeIds := make([]nvmlVgpuTypeId, vgpuCount) + ret := nvmlDeviceGetSupportedVgpus(device, &vgpuCount, &vgpuTypeIds[0]) if ret == SUCCESS { - return VgpuTypeIds[:VgpuCount], ret + return convertSlice[nvmlVgpuTypeId, VgpuTypeId](vgpuTypeIds[:vgpuCount]), ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - VgpuCount *= 2 + vgpuCount *= 2 } } -func (Device Device) GetSupportedVgpus() ([]VgpuTypeId, Return) { - return DeviceGetSupportedVgpus(Device) +// nvml.DeviceGetCreatableVgpus() +func (l *library) DeviceGetCreatableVgpus(device Device) ([]VgpuTypeId, Return) { + return device.GetCreatableVgpus() } -// nvml.DeviceGetCreatableVgpus() -func DeviceGetCreatableVgpus(Device Device) ([]VgpuTypeId, Return) { - var VgpuCount uint32 = 1 // Will be reduced upon returning +func (device nvmlDevice) GetCreatableVgpus() ([]VgpuTypeId, Return) { + var vgpuCount uint32 = 1 // Will be reduced upon returning for { - VgpuTypeIds := make([]VgpuTypeId, VgpuCount) - ret := nvmlDeviceGetCreatableVgpus(Device, &VgpuCount, &VgpuTypeIds[0]) + vgpuTypeIds := make([]nvmlVgpuTypeId, vgpuCount) + ret := nvmlDeviceGetCreatableVgpus(device, &vgpuCount, &vgpuTypeIds[0]) if ret == SUCCESS { - return VgpuTypeIds[:VgpuCount], ret + return convertSlice[nvmlVgpuTypeId, VgpuTypeId](vgpuTypeIds[:vgpuCount]), ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - VgpuCount *= 2 + vgpuCount *= 2 } } -func (Device Device) GetCreatableVgpus() ([]VgpuTypeId, Return) { - return DeviceGetCreatableVgpus(Device) +// nvml.DeviceGetActiveVgpus() +func (l *library) DeviceGetActiveVgpus(device Device) ([]VgpuInstance, Return) { + return device.GetActiveVgpus() } -// nvml.DeviceGetActiveVgpus() -func DeviceGetActiveVgpus(Device Device) ([]VgpuInstance, Return) { - var VgpuCount uint32 = 1 // Will be reduced upon returning +func (device nvmlDevice) GetActiveVgpus() ([]VgpuInstance, Return) { + var vgpuCount uint32 = 1 // Will be reduced upon returning for { - VgpuInstances := make([]VgpuInstance, VgpuCount) - ret := nvmlDeviceGetActiveVgpus(Device, &VgpuCount, &VgpuInstances[0]) + vgpuInstances := make([]nvmlVgpuInstance, vgpuCount) + ret := nvmlDeviceGetActiveVgpus(device, &vgpuCount, &vgpuInstances[0]) if ret == SUCCESS { - return VgpuInstances[:VgpuCount], ret + return convertSlice[nvmlVgpuInstance, VgpuInstance](vgpuInstances[:vgpuCount]), ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - VgpuCount *= 2 + vgpuCount *= 2 } } -func (Device Device) GetActiveVgpus() ([]VgpuInstance, Return) { - return DeviceGetActiveVgpus(Device) +// nvml.DeviceGetVgpuMetadata() +func (l *library) DeviceGetVgpuMetadata(device Device) (VgpuPgpuMetadata, Return) { + return device.GetVgpuMetadata() } -// nvml.DeviceGetVgpuMetadata() -func DeviceGetVgpuMetadata(Device Device) (VgpuPgpuMetadata, Return) { - var VgpuPgpuMetadata VgpuPgpuMetadata - OpaqueDataSize := unsafe.Sizeof(VgpuPgpuMetadata.nvmlVgpuPgpuMetadata.OpaqueData) - VgpuPgpuMetadataSize := unsafe.Sizeof(VgpuPgpuMetadata.nvmlVgpuPgpuMetadata) - OpaqueDataSize +func (device nvmlDevice) GetVgpuMetadata() (VgpuPgpuMetadata, Return) { + var vgpuPgpuMetadata VgpuPgpuMetadata + opaqueDataSize := unsafe.Sizeof(vgpuPgpuMetadata.nvmlVgpuPgpuMetadata.OpaqueData) + vgpuPgpuMetadataSize := unsafe.Sizeof(vgpuPgpuMetadata.nvmlVgpuPgpuMetadata) - opaqueDataSize for { - BufferSize := uint32(VgpuPgpuMetadataSize + OpaqueDataSize) - Buffer := make([]byte, BufferSize) - nvmlVgpuPgpuMetadataPtr := (*nvmlVgpuPgpuMetadata)(unsafe.Pointer(&Buffer[0])) - ret := nvmlDeviceGetVgpuMetadata(Device, nvmlVgpuPgpuMetadataPtr, &BufferSize) + bufferSize := uint32(vgpuPgpuMetadataSize + opaqueDataSize) + buffer := make([]byte, bufferSize) + nvmlVgpuPgpuMetadataPtr := (*nvmlVgpuPgpuMetadata)(unsafe.Pointer(&buffer[0])) + ret := nvmlDeviceGetVgpuMetadata(device, nvmlVgpuPgpuMetadataPtr, &bufferSize) if ret == SUCCESS { - VgpuPgpuMetadata.nvmlVgpuPgpuMetadata = *nvmlVgpuPgpuMetadataPtr - VgpuPgpuMetadata.OpaqueData = Buffer[VgpuPgpuMetadataSize:BufferSize] - return VgpuPgpuMetadata, ret + vgpuPgpuMetadata.nvmlVgpuPgpuMetadata = *nvmlVgpuPgpuMetadataPtr + vgpuPgpuMetadata.OpaqueData = buffer[vgpuPgpuMetadataSize:bufferSize] + return vgpuPgpuMetadata, ret } if ret != ERROR_INSUFFICIENT_SIZE { - return VgpuPgpuMetadata, ret + return vgpuPgpuMetadata, ret } - OpaqueDataSize = 2 * OpaqueDataSize + opaqueDataSize = 2 * opaqueDataSize } } -func (Device Device) GetVgpuMetadata() (VgpuPgpuMetadata, Return) { - return DeviceGetVgpuMetadata(Device) +// nvml.DeviceGetPgpuMetadataString() +func (l *library) DeviceGetPgpuMetadataString(device Device) (string, Return) { + return device.GetPgpuMetadataString() } -// nvml.DeviceGetPgpuMetadataString() -func DeviceGetPgpuMetadataString(Device Device) (string, Return) { - var BufferSize uint32 = 1 // Will be reduced upon returning +func (device nvmlDevice) GetPgpuMetadataString() (string, Return) { + var bufferSize uint32 = 1 // Will be reduced upon returning for { - PgpuMetadata := make([]byte, BufferSize) - ret := nvmlDeviceGetPgpuMetadataString(Device, &PgpuMetadata[0], &BufferSize) + pgpuMetadata := make([]byte, bufferSize) + ret := nvmlDeviceGetPgpuMetadataString(device, &pgpuMetadata[0], &bufferSize) if ret == SUCCESS { - return string(PgpuMetadata[:clen(PgpuMetadata)]), ret + return string(pgpuMetadata[:clen(pgpuMetadata)]), ret } if ret != ERROR_INSUFFICIENT_SIZE { return "", ret } - BufferSize *= 2 + bufferSize *= 2 } } -func (Device Device) GetPgpuMetadataString() (string, Return) { - return DeviceGetPgpuMetadataString(Device) +// nvml.DeviceGetVgpuUtilization() +func (l *library) DeviceGetVgpuUtilization(device Device, lastSeenTimestamp uint64) (ValueType, []VgpuInstanceUtilizationSample, Return) { + return device.GetVgpuUtilization(lastSeenTimestamp) } -// nvml.DeviceGetVgpuUtilization() -func DeviceGetVgpuUtilization(Device Device, LastSeenTimeStamp uint64) (ValueType, []VgpuInstanceUtilizationSample, Return) { - var SampleValType ValueType - var VgpuInstanceSamplesCount uint32 = 1 // Will be reduced upon returning +func (device nvmlDevice) GetVgpuUtilization(lastSeenTimestamp uint64) (ValueType, []VgpuInstanceUtilizationSample, Return) { + var sampleValType ValueType + var vgpuInstanceSamplesCount uint32 = 1 // Will be reduced upon returning for { - UtilizationSamples := make([]VgpuInstanceUtilizationSample, VgpuInstanceSamplesCount) - ret := nvmlDeviceGetVgpuUtilization(Device, LastSeenTimeStamp, &SampleValType, &VgpuInstanceSamplesCount, &UtilizationSamples[0]) + utilizationSamples := make([]VgpuInstanceUtilizationSample, vgpuInstanceSamplesCount) + ret := nvmlDeviceGetVgpuUtilization(device, lastSeenTimestamp, &sampleValType, &vgpuInstanceSamplesCount, &utilizationSamples[0]) if ret == SUCCESS { - return SampleValType, UtilizationSamples[:VgpuInstanceSamplesCount], ret + return sampleValType, utilizationSamples[:vgpuInstanceSamplesCount], ret } if ret != ERROR_INSUFFICIENT_SIZE { - return SampleValType, nil, ret + return sampleValType, nil, ret } - VgpuInstanceSamplesCount *= 2 + vgpuInstanceSamplesCount *= 2 } } -func (Device Device) GetVgpuUtilization(LastSeenTimeStamp uint64) (ValueType, []VgpuInstanceUtilizationSample, Return) { - return DeviceGetVgpuUtilization(Device, LastSeenTimeStamp) -} - // nvml.DeviceGetAttributes() -func DeviceGetAttributes(Device Device) (DeviceAttributes, Return) { - var Attributes DeviceAttributes - ret := nvmlDeviceGetAttributes(Device, &Attributes) - return Attributes, ret +func (l *library) DeviceGetAttributes(device Device) (DeviceAttributes, Return) { + return device.GetAttributes() } -func (Device Device) GetAttributes() (DeviceAttributes, Return) { - return DeviceGetAttributes(Device) +func (device nvmlDevice) GetAttributes() (DeviceAttributes, Return) { + var attributes DeviceAttributes + ret := nvmlDeviceGetAttributes(device, &attributes) + return attributes, ret } // nvml.DeviceGetRemappedRows() -func DeviceGetRemappedRows(Device Device) (int, int, bool, bool, Return) { - var CorrRows, UncRows, IsPending, FailureOccured uint32 - ret := nvmlDeviceGetRemappedRows(Device, &CorrRows, &UncRows, &IsPending, &FailureOccured) - return int(CorrRows), int(UncRows), (IsPending != 0), (FailureOccured != 0), ret +func (l *library) DeviceGetRemappedRows(device Device) (int, int, bool, bool, Return) { + return device.GetRemappedRows() } -func (Device Device) GetRemappedRows() (int, int, bool, bool, Return) { - return DeviceGetRemappedRows(Device) +func (device nvmlDevice) GetRemappedRows() (int, int, bool, bool, Return) { + var corrRows, uncRows, isPending, failureOccured uint32 + ret := nvmlDeviceGetRemappedRows(device, &corrRows, &uncRows, &isPending, &failureOccured) + return int(corrRows), int(uncRows), (isPending != 0), (failureOccured != 0), ret } // nvml.DeviceGetRowRemapperHistogram() -func DeviceGetRowRemapperHistogram(Device Device) (RowRemapperHistogramValues, Return) { - var Values RowRemapperHistogramValues - ret := nvmlDeviceGetRowRemapperHistogram(Device, &Values) - return Values, ret +func (l *library) DeviceGetRowRemapperHistogram(device Device) (RowRemapperHistogramValues, Return) { + return device.GetRowRemapperHistogram() } -func (Device Device) GetRowRemapperHistogram() (RowRemapperHistogramValues, Return) { - return DeviceGetRowRemapperHistogram(Device) +func (device nvmlDevice) GetRowRemapperHistogram() (RowRemapperHistogramValues, Return) { + var values RowRemapperHistogramValues + ret := nvmlDeviceGetRowRemapperHistogram(device, &values) + return values, ret } // nvml.DeviceGetArchitecture() -func DeviceGetArchitecture(Device Device) (DeviceArchitecture, Return) { - var Arch DeviceArchitecture - ret := nvmlDeviceGetArchitecture(Device, &Arch) - return Arch, ret +func (l *library) DeviceGetArchitecture(device Device) (DeviceArchitecture, Return) { + return device.GetArchitecture() } -func (Device Device) GetArchitecture() (DeviceArchitecture, Return) { - return DeviceGetArchitecture(Device) +func (device nvmlDevice) GetArchitecture() (DeviceArchitecture, Return) { + var arch DeviceArchitecture + ret := nvmlDeviceGetArchitecture(device, &arch) + return arch, ret } // nvml.DeviceGetVgpuProcessUtilization() -func DeviceGetVgpuProcessUtilization(Device Device, LastSeenTimeStamp uint64) ([]VgpuProcessUtilizationSample, Return) { - var VgpuProcessSamplesCount uint32 = 1 // Will be reduced upon returning +func (l *library) DeviceGetVgpuProcessUtilization(device Device, lastSeenTimestamp uint64) ([]VgpuProcessUtilizationSample, Return) { + return device.GetVgpuProcessUtilization(lastSeenTimestamp) +} + +func (device nvmlDevice) GetVgpuProcessUtilization(lastSeenTimestamp uint64) ([]VgpuProcessUtilizationSample, Return) { + var vgpuProcessSamplesCount uint32 = 1 // Will be reduced upon returning for { - UtilizationSamples := make([]VgpuProcessUtilizationSample, VgpuProcessSamplesCount) - ret := nvmlDeviceGetVgpuProcessUtilization(Device, LastSeenTimeStamp, &VgpuProcessSamplesCount, &UtilizationSamples[0]) + utilizationSamples := make([]VgpuProcessUtilizationSample, vgpuProcessSamplesCount) + ret := nvmlDeviceGetVgpuProcessUtilization(device, lastSeenTimestamp, &vgpuProcessSamplesCount, &utilizationSamples[0]) if ret == SUCCESS { - return UtilizationSamples[:VgpuProcessSamplesCount], ret + return utilizationSamples[:vgpuProcessSamplesCount], ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - VgpuProcessSamplesCount *= 2 + vgpuProcessSamplesCount *= 2 } } -func (Device Device) GetVgpuProcessUtilization(LastSeenTimeStamp uint64) ([]VgpuProcessUtilizationSample, Return) { - return DeviceGetVgpuProcessUtilization(Device, LastSeenTimeStamp) -} - // nvml.GetExcludedDeviceCount() -func GetExcludedDeviceCount() (int, Return) { - var DeviceCount uint32 - ret := nvmlGetExcludedDeviceCount(&DeviceCount) - return int(DeviceCount), ret +func (l *library) GetExcludedDeviceCount() (int, Return) { + var deviceCount uint32 + ret := nvmlGetExcludedDeviceCount(&deviceCount) + return int(deviceCount), ret } // nvml.GetExcludedDeviceInfoByIndex() -func GetExcludedDeviceInfoByIndex(Index int) (ExcludedDeviceInfo, Return) { - var Info ExcludedDeviceInfo - ret := nvmlGetExcludedDeviceInfoByIndex(uint32(Index), &Info) - return Info, ret +func (l *library) GetExcludedDeviceInfoByIndex(index int) (ExcludedDeviceInfo, Return) { + var info ExcludedDeviceInfo + ret := nvmlGetExcludedDeviceInfoByIndex(uint32(index), &info) + return info, ret } // nvml.DeviceSetMigMode() -func DeviceSetMigMode(Device Device, Mode int) (Return, Return) { - var ActivationStatus Return - ret := nvmlDeviceSetMigMode(Device, uint32(Mode), &ActivationStatus) - return ActivationStatus, ret +func (l *library) DeviceSetMigMode(device Device, mode int) (Return, Return) { + return device.SetMigMode(mode) } -func (Device Device) SetMigMode(Mode int) (Return, Return) { - return DeviceSetMigMode(Device, Mode) +func (device nvmlDevice) SetMigMode(mode int) (Return, Return) { + var activationStatus Return + ret := nvmlDeviceSetMigMode(device, uint32(mode), &activationStatus) + return activationStatus, ret } // nvml.DeviceGetMigMode() -func DeviceGetMigMode(Device Device) (int, int, Return) { - var CurrentMode, PendingMode uint32 - ret := nvmlDeviceGetMigMode(Device, &CurrentMode, &PendingMode) - return int(CurrentMode), int(PendingMode), ret +func (l *library) DeviceGetMigMode(device Device) (int, int, Return) { + return device.GetMigMode() } -func (Device Device) GetMigMode() (int, int, Return) { - return DeviceGetMigMode(Device) +func (device nvmlDevice) GetMigMode() (int, int, Return) { + var currentMode, pendingMode uint32 + ret := nvmlDeviceGetMigMode(device, ¤tMode, &pendingMode) + return int(currentMode), int(pendingMode), ret } // nvml.DeviceGetGpuInstanceProfileInfo() -func DeviceGetGpuInstanceProfileInfo(Device Device, Profile int) (GpuInstanceProfileInfo, Return) { - var Info GpuInstanceProfileInfo - ret := nvmlDeviceGetGpuInstanceProfileInfo(Device, uint32(Profile), &Info) - return Info, ret +func (l *library) DeviceGetGpuInstanceProfileInfo(device Device, profile int) (GpuInstanceProfileInfo, Return) { + return device.GetGpuInstanceProfileInfo(profile) } -func (Device Device) GetGpuInstanceProfileInfo(Profile int) (GpuInstanceProfileInfo, Return) { - return DeviceGetGpuInstanceProfileInfo(Device, Profile) +func (device nvmlDevice) GetGpuInstanceProfileInfo(profile int) (GpuInstanceProfileInfo, Return) { + var info GpuInstanceProfileInfo + ret := nvmlDeviceGetGpuInstanceProfileInfo(device, uint32(profile), &info) + return info, ret } // nvml.DeviceGetGpuInstanceProfileInfoV() -type GpuInstanceProfileInfoV struct { - device Device +type GpuInstanceProfileInfoHandler struct { + device nvmlDevice profile int } -func (InfoV GpuInstanceProfileInfoV) V1() (GpuInstanceProfileInfo, Return) { - return DeviceGetGpuInstanceProfileInfo(InfoV.device, InfoV.profile) +func (handler GpuInstanceProfileInfoHandler) V1() (GpuInstanceProfileInfo, Return) { + return DeviceGetGpuInstanceProfileInfo(handler.device, handler.profile) } -func (InfoV GpuInstanceProfileInfoV) V2() (GpuInstanceProfileInfo_v2, Return) { - var Info GpuInstanceProfileInfo_v2 - Info.Version = STRUCT_VERSION(Info, 2) - ret := nvmlDeviceGetGpuInstanceProfileInfoV(InfoV.device, uint32(InfoV.profile), &Info) - return Info, ret +func (handler GpuInstanceProfileInfoHandler) V2() (GpuInstanceProfileInfo_v2, Return) { + var info GpuInstanceProfileInfo_v2 + info.Version = STRUCT_VERSION(info, 2) + ret := nvmlDeviceGetGpuInstanceProfileInfoV(handler.device, uint32(handler.profile), &info) + return info, ret } -func DeviceGetGpuInstanceProfileInfoV(Device Device, Profile int) GpuInstanceProfileInfoV { - return GpuInstanceProfileInfoV{Device, Profile} +func (l *library) DeviceGetGpuInstanceProfileInfoV(device Device, profile int) GpuInstanceProfileInfoHandler { + return device.GetGpuInstanceProfileInfoV(profile) } -func (Device Device) GetGpuInstanceProfileInfoV(Profile int) GpuInstanceProfileInfoV { - return DeviceGetGpuInstanceProfileInfoV(Device, Profile) +func (device nvmlDevice) GetGpuInstanceProfileInfoV(profile int) GpuInstanceProfileInfoHandler { + return GpuInstanceProfileInfoHandler{device, profile} } // nvml.DeviceGetGpuInstancePossiblePlacements() -func DeviceGetGpuInstancePossiblePlacements(Device Device, Info *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) { - if Info == nil { +func (l *library) DeviceGetGpuInstancePossiblePlacements(device Device, info *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) { + return device.GetGpuInstancePossiblePlacements(info) +} + +func (device nvmlDevice) GetGpuInstancePossiblePlacements(info *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) { + if info == nil { return nil, ERROR_INVALID_ARGUMENT } - var Count uint32 - ret := nvmlDeviceGetGpuInstancePossiblePlacements(Device, Info.Id, nil, &Count) + var count uint32 + ret := nvmlDeviceGetGpuInstancePossiblePlacements(device, info.Id, nil, &count) if ret != SUCCESS { return nil, ret } - if Count == 0 { + if count == 0 { return []GpuInstancePlacement{}, ret } - Placements := make([]GpuInstancePlacement, Count) - ret = nvmlDeviceGetGpuInstancePossiblePlacements(Device, Info.Id, &Placements[0], &Count) - return Placements[:Count], ret + placements := make([]GpuInstancePlacement, count) + ret = nvmlDeviceGetGpuInstancePossiblePlacements(device, info.Id, &placements[0], &count) + return placements[:count], ret } -func (Device Device) GetGpuInstancePossiblePlacements(Info *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) { - return DeviceGetGpuInstancePossiblePlacements(Device, Info) +// nvml.DeviceGetGpuInstanceRemainingCapacity() +func (l *library) DeviceGetGpuInstanceRemainingCapacity(device Device, info *GpuInstanceProfileInfo) (int, Return) { + return device.GetGpuInstanceRemainingCapacity(info) } -// nvml.DeviceGetGpuInstanceRemainingCapacity() -func DeviceGetGpuInstanceRemainingCapacity(Device Device, Info *GpuInstanceProfileInfo) (int, Return) { - if Info == nil { +func (device nvmlDevice) GetGpuInstanceRemainingCapacity(info *GpuInstanceProfileInfo) (int, Return) { + if info == nil { return 0, ERROR_INVALID_ARGUMENT } - var Count uint32 - ret := nvmlDeviceGetGpuInstanceRemainingCapacity(Device, Info.Id, &Count) - return int(Count), ret -} - -func (Device Device) GetGpuInstanceRemainingCapacity(Info *GpuInstanceProfileInfo) (int, Return) { - return DeviceGetGpuInstanceRemainingCapacity(Device, Info) + var count uint32 + ret := nvmlDeviceGetGpuInstanceRemainingCapacity(device, info.Id, &count) + return int(count), ret } // nvml.DeviceCreateGpuInstance() -func DeviceCreateGpuInstance(Device Device, Info *GpuInstanceProfileInfo) (GpuInstance, Return) { - if Info == nil { - return GpuInstance{}, ERROR_INVALID_ARGUMENT - } - var GpuInstance GpuInstance - ret := nvmlDeviceCreateGpuInstance(Device, Info.Id, &GpuInstance) - return GpuInstance, ret +func (l *library) DeviceCreateGpuInstance(device Device, info *GpuInstanceProfileInfo) (GpuInstance, Return) { + return device.CreateGpuInstance(info) } -func (Device Device) CreateGpuInstance(Info *GpuInstanceProfileInfo) (GpuInstance, Return) { - return DeviceCreateGpuInstance(Device, Info) +func (device nvmlDevice) CreateGpuInstance(info *GpuInstanceProfileInfo) (GpuInstance, Return) { + if info == nil { + return nil, ERROR_INVALID_ARGUMENT + } + var gpuInstance nvmlGpuInstance + ret := nvmlDeviceCreateGpuInstance(device, info.Id, &gpuInstance) + return gpuInstance, ret } // nvml.DeviceCreateGpuInstanceWithPlacement() -func DeviceCreateGpuInstanceWithPlacement(Device Device, Info *GpuInstanceProfileInfo, Placement *GpuInstancePlacement) (GpuInstance, Return) { - if Info == nil { - return GpuInstance{}, ERROR_INVALID_ARGUMENT - } - var GpuInstance GpuInstance - ret := nvmlDeviceCreateGpuInstanceWithPlacement(Device, Info.Id, Placement, &GpuInstance) - return GpuInstance, ret +func (l *library) DeviceCreateGpuInstanceWithPlacement(device Device, info *GpuInstanceProfileInfo, placement *GpuInstancePlacement) (GpuInstance, Return) { + return device.CreateGpuInstanceWithPlacement(info, placement) } -func (Device Device) CreateGpuInstanceWithPlacement(Info *GpuInstanceProfileInfo, Placement *GpuInstancePlacement) (GpuInstance, Return) { - return DeviceCreateGpuInstanceWithPlacement(Device, Info, Placement) +func (device nvmlDevice) CreateGpuInstanceWithPlacement(info *GpuInstanceProfileInfo, placement *GpuInstancePlacement) (GpuInstance, Return) { + if info == nil { + return nil, ERROR_INVALID_ARGUMENT + } + var gpuInstance nvmlGpuInstance + ret := nvmlDeviceCreateGpuInstanceWithPlacement(device, info.Id, placement, &gpuInstance) + return gpuInstance, ret } // nvml.GpuInstanceDestroy() -func GpuInstanceDestroy(GpuInstance GpuInstance) Return { - return nvmlGpuInstanceDestroy(GpuInstance) +func (l *library) GpuInstanceDestroy(gpuInstance GpuInstance) Return { + return gpuInstance.Destroy() } -func (GpuInstance GpuInstance) Destroy() Return { - return GpuInstanceDestroy(GpuInstance) +func (gpuInstance nvmlGpuInstance) Destroy() Return { + return nvmlGpuInstanceDestroy(gpuInstance) } // nvml.DeviceGetGpuInstances() -func DeviceGetGpuInstances(Device Device, Info *GpuInstanceProfileInfo) ([]GpuInstance, Return) { - if Info == nil { - return nil, ERROR_INVALID_ARGUMENT - } - var Count uint32 = Info.InstanceCount - GpuInstances := make([]GpuInstance, Count) - ret := nvmlDeviceGetGpuInstances(Device, Info.Id, &GpuInstances[0], &Count) - return GpuInstances[:Count], ret +func (l *library) DeviceGetGpuInstances(device Device, info *GpuInstanceProfileInfo) ([]GpuInstance, Return) { + return device.GetGpuInstances(info) } -func (Device Device) GetGpuInstances(Info *GpuInstanceProfileInfo) ([]GpuInstance, Return) { - return DeviceGetGpuInstances(Device, Info) +func (device nvmlDevice) GetGpuInstances(info *GpuInstanceProfileInfo) ([]GpuInstance, Return) { + if info == nil { + return nil, ERROR_INVALID_ARGUMENT + } + var count uint32 = info.InstanceCount + gpuInstances := make([]nvmlGpuInstance, count) + ret := nvmlDeviceGetGpuInstances(device, info.Id, &gpuInstances[0], &count) + return convertSlice[nvmlGpuInstance, GpuInstance](gpuInstances[:count]), ret } // nvml.DeviceGetGpuInstanceById() -func DeviceGetGpuInstanceById(Device Device, Id int) (GpuInstance, Return) { - var GpuInstance GpuInstance - ret := nvmlDeviceGetGpuInstanceById(Device, uint32(Id), &GpuInstance) - return GpuInstance, ret +func (l *library) DeviceGetGpuInstanceById(device Device, id int) (GpuInstance, Return) { + return device.GetGpuInstanceById(id) } -func (Device Device) GetGpuInstanceById(Id int) (GpuInstance, Return) { - return DeviceGetGpuInstanceById(Device, Id) +func (device nvmlDevice) GetGpuInstanceById(id int) (GpuInstance, Return) { + var gpuInstance nvmlGpuInstance + ret := nvmlDeviceGetGpuInstanceById(device, uint32(id), &gpuInstance) + return gpuInstance, ret } // nvml.GpuInstanceGetInfo() -func GpuInstanceGetInfo(GpuInstance GpuInstance) (GpuInstanceInfo, Return) { - var Info GpuInstanceInfo - ret := nvmlGpuInstanceGetInfo(GpuInstance, &Info) - return Info, ret +func (l *library) GpuInstanceGetInfo(gpuInstance GpuInstance) (GpuInstanceInfo, Return) { + return gpuInstance.GetInfo() } -func (GpuInstance GpuInstance) GetInfo() (GpuInstanceInfo, Return) { - return GpuInstanceGetInfo(GpuInstance) +func (gpuInstance nvmlGpuInstance) GetInfo() (GpuInstanceInfo, Return) { + var info nvmlGpuInstanceInfo + ret := nvmlGpuInstanceGetInfo(gpuInstance, &info) + return info.convert(), ret } // nvml.GpuInstanceGetComputeInstanceProfileInfo() -func GpuInstanceGetComputeInstanceProfileInfo(GpuInstance GpuInstance, Profile int, EngProfile int) (ComputeInstanceProfileInfo, Return) { - var Info ComputeInstanceProfileInfo - ret := nvmlGpuInstanceGetComputeInstanceProfileInfo(GpuInstance, uint32(Profile), uint32(EngProfile), &Info) - return Info, ret +func (l *library) GpuInstanceGetComputeInstanceProfileInfo(gpuInstance GpuInstance, profile int, engProfile int) (ComputeInstanceProfileInfo, Return) { + return gpuInstance.GetComputeInstanceProfileInfo(profile, engProfile) } -func (GpuInstance GpuInstance) GetComputeInstanceProfileInfo(Profile int, EngProfile int) (ComputeInstanceProfileInfo, Return) { - return GpuInstanceGetComputeInstanceProfileInfo(GpuInstance, Profile, EngProfile) +func (gpuInstance nvmlGpuInstance) GetComputeInstanceProfileInfo(profile int, engProfile int) (ComputeInstanceProfileInfo, Return) { + var info ComputeInstanceProfileInfo + ret := nvmlGpuInstanceGetComputeInstanceProfileInfo(gpuInstance, uint32(profile), uint32(engProfile), &info) + return info, ret } // nvml.GpuInstanceGetComputeInstanceProfileInfoV() -type ComputeInstanceProfileInfoV struct { - gpuInstance GpuInstance +type ComputeInstanceProfileInfoHandler struct { + gpuInstance nvmlGpuInstance profile int engProfile int } -func (InfoV ComputeInstanceProfileInfoV) V1() (ComputeInstanceProfileInfo, Return) { - return GpuInstanceGetComputeInstanceProfileInfo(InfoV.gpuInstance, InfoV.profile, InfoV.engProfile) +func (handler ComputeInstanceProfileInfoHandler) V1() (ComputeInstanceProfileInfo, Return) { + return GpuInstanceGetComputeInstanceProfileInfo(handler.gpuInstance, handler.profile, handler.engProfile) } -func (InfoV ComputeInstanceProfileInfoV) V2() (ComputeInstanceProfileInfo_v2, Return) { - var Info ComputeInstanceProfileInfo_v2 - Info.Version = STRUCT_VERSION(Info, 2) - ret := nvmlGpuInstanceGetComputeInstanceProfileInfoV(InfoV.gpuInstance, uint32(InfoV.profile), uint32(InfoV.engProfile), &Info) - return Info, ret +func (handler ComputeInstanceProfileInfoHandler) V2() (ComputeInstanceProfileInfo_v2, Return) { + var info ComputeInstanceProfileInfo_v2 + info.Version = STRUCT_VERSION(info, 2) + ret := nvmlGpuInstanceGetComputeInstanceProfileInfoV(handler.gpuInstance, uint32(handler.profile), uint32(handler.engProfile), &info) + return info, ret } -func GpuInstanceGetComputeInstanceProfileInfoV(GpuInstance GpuInstance, Profile int, EngProfile int) ComputeInstanceProfileInfoV { - return ComputeInstanceProfileInfoV{GpuInstance, Profile, EngProfile} +func (l *library) GpuInstanceGetComputeInstanceProfileInfoV(gpuInstance GpuInstance, profile int, engProfile int) ComputeInstanceProfileInfoHandler { + return gpuInstance.GetComputeInstanceProfileInfoV(profile, engProfile) } -func (GpuInstance GpuInstance) GetComputeInstanceProfileInfoV(Profile int, EngProfile int) ComputeInstanceProfileInfoV { - return GpuInstanceGetComputeInstanceProfileInfoV(GpuInstance, Profile, EngProfile) +func (gpuInstance nvmlGpuInstance) GetComputeInstanceProfileInfoV(profile int, engProfile int) ComputeInstanceProfileInfoHandler { + return ComputeInstanceProfileInfoHandler{gpuInstance, profile, engProfile} } // nvml.GpuInstanceGetComputeInstanceRemainingCapacity() -func GpuInstanceGetComputeInstanceRemainingCapacity(GpuInstance GpuInstance, Info *ComputeInstanceProfileInfo) (int, Return) { - if Info == nil { - return 0, ERROR_INVALID_ARGUMENT - } - var Count uint32 - ret := nvmlGpuInstanceGetComputeInstanceRemainingCapacity(GpuInstance, Info.Id, &Count) - return int(Count), ret +func (l *library) GpuInstanceGetComputeInstanceRemainingCapacity(gpuInstance GpuInstance, info *ComputeInstanceProfileInfo) (int, Return) { + return gpuInstance.GetComputeInstanceRemainingCapacity(info) } -func (GpuInstance GpuInstance) GetComputeInstanceRemainingCapacity(Info *ComputeInstanceProfileInfo) (int, Return) { - return GpuInstanceGetComputeInstanceRemainingCapacity(GpuInstance, Info) +func (gpuInstance nvmlGpuInstance) GetComputeInstanceRemainingCapacity(info *ComputeInstanceProfileInfo) (int, Return) { + if info == nil { + return 0, ERROR_INVALID_ARGUMENT + } + var count uint32 + ret := nvmlGpuInstanceGetComputeInstanceRemainingCapacity(gpuInstance, info.Id, &count) + return int(count), ret } // nvml.GpuInstanceCreateComputeInstance() -func GpuInstanceCreateComputeInstance(GpuInstance GpuInstance, Info *ComputeInstanceProfileInfo) (ComputeInstance, Return) { - if Info == nil { - return ComputeInstance{}, ERROR_INVALID_ARGUMENT - } - var ComputeInstance ComputeInstance - ret := nvmlGpuInstanceCreateComputeInstance(GpuInstance, Info.Id, &ComputeInstance) - return ComputeInstance, ret +func (l *library) GpuInstanceCreateComputeInstance(gpuInstance GpuInstance, info *ComputeInstanceProfileInfo) (ComputeInstance, Return) { + return gpuInstance.CreateComputeInstance(info) } -func (GpuInstance GpuInstance) CreateComputeInstance(Info *ComputeInstanceProfileInfo) (ComputeInstance, Return) { - return GpuInstanceCreateComputeInstance(GpuInstance, Info) +func (gpuInstance nvmlGpuInstance) CreateComputeInstance(info *ComputeInstanceProfileInfo) (ComputeInstance, Return) { + if info == nil { + return nil, ERROR_INVALID_ARGUMENT + } + var computeInstance nvmlComputeInstance + ret := nvmlGpuInstanceCreateComputeInstance(gpuInstance, info.Id, &computeInstance) + return computeInstance, ret } // nvml.ComputeInstanceDestroy() -func ComputeInstanceDestroy(ComputeInstance ComputeInstance) Return { - return nvmlComputeInstanceDestroy(ComputeInstance) +func (l *library) ComputeInstanceDestroy(computeInstance ComputeInstance) Return { + return computeInstance.Destroy() } -func (ComputeInstance ComputeInstance) Destroy() Return { - return ComputeInstanceDestroy(ComputeInstance) +func (computeInstance nvmlComputeInstance) Destroy() Return { + return nvmlComputeInstanceDestroy(computeInstance) } // nvml.GpuInstanceGetComputeInstances() -func GpuInstanceGetComputeInstances(GpuInstance GpuInstance, Info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) { - if Info == nil { - return nil, ERROR_INVALID_ARGUMENT - } - var Count uint32 = Info.InstanceCount - ComputeInstances := make([]ComputeInstance, Count) - ret := nvmlGpuInstanceGetComputeInstances(GpuInstance, Info.Id, &ComputeInstances[0], &Count) - return ComputeInstances[:Count], ret +func (l *library) GpuInstanceGetComputeInstances(gpuInstance GpuInstance, info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) { + return gpuInstance.GetComputeInstances(info) } -func (GpuInstance GpuInstance) GetComputeInstances(Info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) { - return GpuInstanceGetComputeInstances(GpuInstance, Info) +func (gpuInstance nvmlGpuInstance) GetComputeInstances(info *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) { + if info == nil { + return nil, ERROR_INVALID_ARGUMENT + } + var count uint32 = info.InstanceCount + computeInstances := make([]nvmlComputeInstance, count) + ret := nvmlGpuInstanceGetComputeInstances(gpuInstance, info.Id, &computeInstances[0], &count) + return convertSlice[nvmlComputeInstance, ComputeInstance](computeInstances[:count]), ret } // nvml.GpuInstanceGetComputeInstanceById() -func GpuInstanceGetComputeInstanceById(GpuInstance GpuInstance, Id int) (ComputeInstance, Return) { - var ComputeInstance ComputeInstance - ret := nvmlGpuInstanceGetComputeInstanceById(GpuInstance, uint32(Id), &ComputeInstance) - return ComputeInstance, ret +func (l *library) GpuInstanceGetComputeInstanceById(gpuInstance GpuInstance, id int) (ComputeInstance, Return) { + return gpuInstance.GetComputeInstanceById(id) } -func (GpuInstance GpuInstance) GetComputeInstanceById(Id int) (ComputeInstance, Return) { - return GpuInstanceGetComputeInstanceById(GpuInstance, Id) +func (gpuInstance nvmlGpuInstance) GetComputeInstanceById(id int) (ComputeInstance, Return) { + var computeInstance nvmlComputeInstance + ret := nvmlGpuInstanceGetComputeInstanceById(gpuInstance, uint32(id), &computeInstance) + return computeInstance, ret } // nvml.ComputeInstanceGetInfo() -func ComputeInstanceGetInfo(ComputeInstance ComputeInstance) (ComputeInstanceInfo, Return) { - var Info ComputeInstanceInfo - ret := nvmlComputeInstanceGetInfo(ComputeInstance, &Info) - return Info, ret +func (l *library) ComputeInstanceGetInfo(computeInstance ComputeInstance) (ComputeInstanceInfo, Return) { + return computeInstance.GetInfo() } -func (ComputeInstance ComputeInstance) GetInfo() (ComputeInstanceInfo, Return) { - return ComputeInstanceGetInfo(ComputeInstance) +func (computeInstance nvmlComputeInstance) GetInfo() (ComputeInstanceInfo, Return) { + var info nvmlComputeInstanceInfo + ret := nvmlComputeInstanceGetInfo(computeInstance, &info) + return info.convert(), ret } // nvml.DeviceIsMigDeviceHandle() -func DeviceIsMigDeviceHandle(Device Device) (bool, Return) { - var IsMigDevice uint32 - ret := nvmlDeviceIsMigDeviceHandle(Device, &IsMigDevice) - return (IsMigDevice != 0), ret +func (l *library) DeviceIsMigDeviceHandle(device Device) (bool, Return) { + return device.IsMigDeviceHandle() } -func (Device Device) IsMigDeviceHandle() (bool, Return) { - return DeviceIsMigDeviceHandle(Device) +func (device nvmlDevice) IsMigDeviceHandle() (bool, Return) { + var isMigDevice uint32 + ret := nvmlDeviceIsMigDeviceHandle(device, &isMigDevice) + return (isMigDevice != 0), ret } // nvml DeviceGetGpuInstanceId() -func DeviceGetGpuInstanceId(Device Device) (int, Return) { - var Id uint32 - ret := nvmlDeviceGetGpuInstanceId(Device, &Id) - return int(Id), ret +func (l *library) DeviceGetGpuInstanceId(device Device) (int, Return) { + return device.GetGpuInstanceId() } -func (Device Device) GetGpuInstanceId() (int, Return) { - return DeviceGetGpuInstanceId(Device) +func (device nvmlDevice) GetGpuInstanceId() (int, Return) { + var id uint32 + ret := nvmlDeviceGetGpuInstanceId(device, &id) + return int(id), ret } // nvml.DeviceGetComputeInstanceId() -func DeviceGetComputeInstanceId(Device Device) (int, Return) { - var Id uint32 - ret := nvmlDeviceGetComputeInstanceId(Device, &Id) - return int(Id), ret +func (l *library) DeviceGetComputeInstanceId(device Device) (int, Return) { + return device.GetComputeInstanceId() } -func (Device Device) GetComputeInstanceId() (int, Return) { - return DeviceGetComputeInstanceId(Device) +func (device nvmlDevice) GetComputeInstanceId() (int, Return) { + var id uint32 + ret := nvmlDeviceGetComputeInstanceId(device, &id) + return int(id), ret } // nvml.DeviceGetMaxMigDeviceCount() -func DeviceGetMaxMigDeviceCount(Device Device) (int, Return) { - var Count uint32 - ret := nvmlDeviceGetMaxMigDeviceCount(Device, &Count) - return int(Count), ret +func (l *library) DeviceGetMaxMigDeviceCount(device Device) (int, Return) { + return device.GetMaxMigDeviceCount() } -func (Device Device) GetMaxMigDeviceCount() (int, Return) { - return DeviceGetMaxMigDeviceCount(Device) +func (device nvmlDevice) GetMaxMigDeviceCount() (int, Return) { + var count uint32 + ret := nvmlDeviceGetMaxMigDeviceCount(device, &count) + return int(count), ret } // nvml.DeviceGetMigDeviceHandleByIndex() -func DeviceGetMigDeviceHandleByIndex(device Device, Index int) (Device, Return) { - var MigDevice Device - ret := nvmlDeviceGetMigDeviceHandleByIndex(device, uint32(Index), &MigDevice) - return MigDevice, ret +func (l *library) DeviceGetMigDeviceHandleByIndex(device Device, index int) (Device, Return) { + return device.GetMigDeviceHandleByIndex(index) } -func (Device Device) GetMigDeviceHandleByIndex(Index int) (Device, Return) { - return DeviceGetMigDeviceHandleByIndex(Device, Index) +func (device nvmlDevice) GetMigDeviceHandleByIndex(index int) (Device, Return) { + var migDevice nvmlDevice + ret := nvmlDeviceGetMigDeviceHandleByIndex(device, uint32(index), &migDevice) + return migDevice, ret } // nvml.DeviceGetDeviceHandleFromMigDeviceHandle() -func DeviceGetDeviceHandleFromMigDeviceHandle(MigDevice Device) (Device, Return) { - var Device Device - ret := nvmlDeviceGetDeviceHandleFromMigDeviceHandle(MigDevice, &Device) - return Device, ret +func (l *library) DeviceGetDeviceHandleFromMigDeviceHandle(migdevice Device) (Device, Return) { + return migdevice.GetDeviceHandleFromMigDeviceHandle() } -func (MigDevice Device) GetDeviceHandleFromMigDeviceHandle() (Device, Return) { - return DeviceGetDeviceHandleFromMigDeviceHandle(MigDevice) +func (migDevice nvmlDevice) GetDeviceHandleFromMigDeviceHandle() (Device, Return) { + var device nvmlDevice + ret := nvmlDeviceGetDeviceHandleFromMigDeviceHandle(migDevice, &device) + return device, ret } // nvml.DeviceGetBusType() -func DeviceGetBusType(Device Device) (BusType, Return) { - var Type BusType - ret := nvmlDeviceGetBusType(Device, &Type) - return Type, ret +func (l *library) DeviceGetBusType(device Device) (BusType, Return) { + return device.GetBusType() } -func (Device Device) GetBusType() (BusType, Return) { - return DeviceGetBusType(Device) +func (device nvmlDevice) GetBusType() (BusType, Return) { + var busType BusType + ret := nvmlDeviceGetBusType(device, &busType) + return busType, ret } // nvml.DeviceSetDefaultFanSpeed_v2() -func DeviceSetDefaultFanSpeed_v2(Device Device, Fan int) Return { - return nvmlDeviceSetDefaultFanSpeed_v2(Device, uint32(Fan)) +func (l *library) DeviceSetDefaultFanSpeed_v2(device Device, fan int) Return { + return device.SetDefaultFanSpeed_v2(fan) } -func (Device Device) SetDefaultFanSpeed_v2(Fan int) Return { - return DeviceSetDefaultFanSpeed_v2(Device, Fan) +func (device nvmlDevice) SetDefaultFanSpeed_v2(fan int) Return { + return nvmlDeviceSetDefaultFanSpeed_v2(device, uint32(fan)) } // nvml.DeviceGetMinMaxFanSpeed() -func DeviceGetMinMaxFanSpeed(Device Device) (int, int, Return) { - var MinSpeed, MaxSpeed uint32 - ret := nvmlDeviceGetMinMaxFanSpeed(Device, &MinSpeed, &MaxSpeed) - return int(MinSpeed), int(MaxSpeed), ret +func (l *library) DeviceGetMinMaxFanSpeed(device Device) (int, int, Return) { + return device.GetMinMaxFanSpeed() } -func (Device Device) GetMinMaxFanSpeed() (int, int, Return) { - return DeviceGetMinMaxFanSpeed(Device) +func (device nvmlDevice) GetMinMaxFanSpeed() (int, int, Return) { + var minSpeed, maxSpeed uint32 + ret := nvmlDeviceGetMinMaxFanSpeed(device, &minSpeed, &maxSpeed) + return int(minSpeed), int(maxSpeed), ret } // nvml.DeviceGetThermalSettings() -func DeviceGetThermalSettings(Device Device, SensorIndex uint32) (GpuThermalSettings, Return) { - var PThermalSettings GpuThermalSettings - ret := nvmlDeviceGetThermalSettings(Device, SensorIndex, &PThermalSettings) - return PThermalSettings, ret +func (l *library) DeviceGetThermalSettings(device Device, sensorIndex uint32) (GpuThermalSettings, Return) { + return device.GetThermalSettings(sensorIndex) } -func (Device Device) GetThermalSettings(SensorIndex uint32) (GpuThermalSettings, Return) { - return DeviceGetThermalSettings(Device, SensorIndex) +func (device nvmlDevice) GetThermalSettings(sensorIndex uint32) (GpuThermalSettings, Return) { + var pThermalSettings GpuThermalSettings + ret := nvmlDeviceGetThermalSettings(device, sensorIndex, &pThermalSettings) + return pThermalSettings, ret } // nvml.DeviceGetDefaultEccMode() -func DeviceGetDefaultEccMode(Device Device) (EnableState, Return) { - var DefaultMode EnableState - ret := nvmlDeviceGetDefaultEccMode(Device, &DefaultMode) - return DefaultMode, ret +func (l *library) DeviceGetDefaultEccMode(device Device) (EnableState, Return) { + return device.GetDefaultEccMode() } -func (Device Device) GetDefaultEccMode() (EnableState, Return) { - return DeviceGetDefaultEccMode(Device) +func (device nvmlDevice) GetDefaultEccMode() (EnableState, Return) { + var defaultMode EnableState + ret := nvmlDeviceGetDefaultEccMode(device, &defaultMode) + return defaultMode, ret } // nvml.DeviceGetPcieSpeed() -func DeviceGetPcieSpeed(Device Device) (int, Return) { - var PcieSpeed uint32 - ret := nvmlDeviceGetPcieSpeed(Device, &PcieSpeed) - return int(PcieSpeed), ret +func (l *library) DeviceGetPcieSpeed(device Device) (int, Return) { + return device.GetPcieSpeed() } -func (Device Device) GetPcieSpeed() (int, Return) { - return DeviceGetPcieSpeed(Device) +func (device nvmlDevice) GetPcieSpeed() (int, Return) { + var pcieSpeed uint32 + ret := nvmlDeviceGetPcieSpeed(device, &pcieSpeed) + return int(pcieSpeed), ret } // nvml.DeviceGetGspFirmwareVersion() -func DeviceGetGspFirmwareVersion(Device Device) (string, Return) { - Version := make([]byte, GSP_FIRMWARE_VERSION_BUF_SIZE) - ret := nvmlDeviceGetGspFirmwareVersion(Device, &Version[0]) - return string(Version[:clen(Version)]), ret +func (l *library) DeviceGetGspFirmwareVersion(device Device) (string, Return) { + return device.GetGspFirmwareVersion() } -func (Device Device) GetGspFirmwareVersion() (string, Return) { - return DeviceGetGspFirmwareVersion(Device) +func (device nvmlDevice) GetGspFirmwareVersion() (string, Return) { + version := make([]byte, GSP_FIRMWARE_VERSION_BUF_SIZE) + ret := nvmlDeviceGetGspFirmwareVersion(device, &version[0]) + return string(version[:clen(version)]), ret } // nvml.DeviceGetGspFirmwareMode() -func DeviceGetGspFirmwareMode(Device Device) (bool, bool, Return) { - var IsEnabled, DefaultMode uint32 - ret := nvmlDeviceGetGspFirmwareMode(Device, &IsEnabled, &DefaultMode) - return (IsEnabled != 0), (DefaultMode != 0), ret +func (l *library) DeviceGetGspFirmwareMode(device Device) (bool, bool, Return) { + return device.GetGspFirmwareMode() } -func (Device Device) GetGspFirmwareMode() (bool, bool, Return) { - return DeviceGetGspFirmwareMode(Device) +func (device nvmlDevice) GetGspFirmwareMode() (bool, bool, Return) { + var isEnabled, defaultMode uint32 + ret := nvmlDeviceGetGspFirmwareMode(device, &isEnabled, &defaultMode) + return (isEnabled != 0), (defaultMode != 0), ret } // nvml.DeviceGetDynamicPstatesInfo() -func DeviceGetDynamicPstatesInfo(Device Device) (GpuDynamicPstatesInfo, Return) { - var PDynamicPstatesInfo GpuDynamicPstatesInfo - ret := nvmlDeviceGetDynamicPstatesInfo(Device, &PDynamicPstatesInfo) - return PDynamicPstatesInfo, ret +func (l *library) DeviceGetDynamicPstatesInfo(device Device) (GpuDynamicPstatesInfo, Return) { + return device.GetDynamicPstatesInfo() } -func (Device Device) GetDynamicPstatesInfo() (GpuDynamicPstatesInfo, Return) { - return DeviceGetDynamicPstatesInfo(Device) +func (device nvmlDevice) GetDynamicPstatesInfo() (GpuDynamicPstatesInfo, Return) { + var pDynamicPstatesInfo GpuDynamicPstatesInfo + ret := nvmlDeviceGetDynamicPstatesInfo(device, &pDynamicPstatesInfo) + return pDynamicPstatesInfo, ret } // nvml.DeviceSetFanSpeed_v2() -func DeviceSetFanSpeed_v2(Device Device, Fan int, Speed int) Return { - return nvmlDeviceSetFanSpeed_v2(Device, uint32(Fan), uint32(Speed)) +func (l *library) DeviceSetFanSpeed_v2(device Device, fan int, speed int) Return { + return device.SetFanSpeed_v2(fan, speed) } -func (Device Device) SetFanSpeed_v2(Fan int, Speed int) Return { - return DeviceSetFanSpeed_v2(Device, Fan, Speed) +func (device nvmlDevice) SetFanSpeed_v2(fan int, speed int) Return { + return nvmlDeviceSetFanSpeed_v2(device, uint32(fan), uint32(speed)) } // nvml.DeviceGetGpcClkVfOffset() -func DeviceGetGpcClkVfOffset(Device Device) (int, Return) { - var Offset int32 - ret := nvmlDeviceGetGpcClkVfOffset(Device, &Offset) - return int(Offset), ret +func (l *library) DeviceGetGpcClkVfOffset(device Device) (int, Return) { + return device.GetGpcClkVfOffset() } -func (Device Device) GetGpcClkVfOffset() (int, Return) { - return DeviceGetGpcClkVfOffset(Device) +func (device nvmlDevice) GetGpcClkVfOffset() (int, Return) { + var offset int32 + ret := nvmlDeviceGetGpcClkVfOffset(device, &offset) + return int(offset), ret } // nvml.DeviceSetGpcClkVfOffset() -func DeviceSetGpcClkVfOffset(Device Device, Offset int) Return { - return nvmlDeviceSetGpcClkVfOffset(Device, int32(Offset)) +func (l *library) DeviceSetGpcClkVfOffset(device Device, offset int) Return { + return device.SetGpcClkVfOffset(offset) } -func (Device Device) SetGpcClkVfOffset(Offset int) Return { - return DeviceSetGpcClkVfOffset(Device, Offset) +func (device nvmlDevice) SetGpcClkVfOffset(offset int) Return { + return nvmlDeviceSetGpcClkVfOffset(device, int32(offset)) } // nvml.DeviceGetMinMaxClockOfPState() -func DeviceGetMinMaxClockOfPState(Device Device, _type ClockType, Pstate Pstates) (uint32, uint32, Return) { - var MinClockMHz, MaxClockMHz uint32 - ret := nvmlDeviceGetMinMaxClockOfPState(Device, _type, Pstate, &MinClockMHz, &MaxClockMHz) - return MinClockMHz, MaxClockMHz, ret +func (l *library) DeviceGetMinMaxClockOfPState(device Device, clockType ClockType, pstate Pstates) (uint32, uint32, Return) { + return device.GetMinMaxClockOfPState(clockType, pstate) } -func (Device Device) GetMinMaxClockOfPState(_type ClockType, Pstate Pstates) (uint32, uint32, Return) { - return DeviceGetMinMaxClockOfPState(Device, _type, Pstate) +func (device nvmlDevice) GetMinMaxClockOfPState(clockType ClockType, pstate Pstates) (uint32, uint32, Return) { + var minClockMHz, maxClockMHz uint32 + ret := nvmlDeviceGetMinMaxClockOfPState(device, clockType, pstate, &minClockMHz, &maxClockMHz) + return minClockMHz, maxClockMHz, ret } // nvml.DeviceGetSupportedPerformanceStates() -func DeviceGetSupportedPerformanceStates(Device Device) ([]Pstates, Return) { - Pstates := make([]Pstates, MAX_GPU_PERF_PSTATES) - ret := nvmlDeviceGetSupportedPerformanceStates(Device, &Pstates[0], MAX_GPU_PERF_PSTATES) +func (l *library) DeviceGetSupportedPerformanceStates(device Device) ([]Pstates, Return) { + return device.GetSupportedPerformanceStates() +} + +func (device nvmlDevice) GetSupportedPerformanceStates() ([]Pstates, Return) { + pstates := make([]Pstates, MAX_GPU_PERF_PSTATES) + ret := nvmlDeviceGetSupportedPerformanceStates(device, &pstates[0], MAX_GPU_PERF_PSTATES) for i := 0; i < MAX_GPU_PERF_PSTATES; i++ { - if Pstates[i] == PSTATE_UNKNOWN { - return Pstates[0:i], ret + if pstates[i] == PSTATE_UNKNOWN { + return pstates[0:i], ret } } - return Pstates, ret -} - -func (Device Device) GetSupportedPerformanceStates() ([]Pstates, Return) { - return DeviceGetSupportedPerformanceStates(Device) + return pstates, ret } // nvml.DeviceGetTargetFanSpeed() -func DeviceGetTargetFanSpeed(Device Device, Fan int) (int, Return) { - var TargetSpeed uint32 - ret := nvmlDeviceGetTargetFanSpeed(Device, uint32(Fan), &TargetSpeed) - return int(TargetSpeed), ret +func (l *library) DeviceGetTargetFanSpeed(device Device, fan int) (int, Return) { + return device.GetTargetFanSpeed(fan) } -func (Device Device) GetTargetFanSpeed(Fan int) (int, Return) { - return DeviceGetTargetFanSpeed(Device, Fan) +func (device nvmlDevice) GetTargetFanSpeed(fan int) (int, Return) { + var targetSpeed uint32 + ret := nvmlDeviceGetTargetFanSpeed(device, uint32(fan), &targetSpeed) + return int(targetSpeed), ret } // nvml.DeviceGetMemClkVfOffset() -func DeviceGetMemClkVfOffset(Device Device) (int, Return) { - var Offset int32 - ret := nvmlDeviceGetMemClkVfOffset(Device, &Offset) - return int(Offset), ret +func (l *library) DeviceGetMemClkVfOffset(device Device) (int, Return) { + return device.GetMemClkVfOffset() } -func (Device Device) GetMemClkVfOffset() (int, Return) { - return DeviceGetMemClkVfOffset(Device) +func (device nvmlDevice) GetMemClkVfOffset() (int, Return) { + var offset int32 + ret := nvmlDeviceGetMemClkVfOffset(device, &offset) + return int(offset), ret } // nvml.DeviceSetMemClkVfOffset() -func DeviceSetMemClkVfOffset(Device Device, Offset int) Return { - return nvmlDeviceSetMemClkVfOffset(Device, int32(Offset)) +func (l *library) DeviceSetMemClkVfOffset(device Device, offset int) Return { + return device.SetMemClkVfOffset(offset) } -func (Device Device) SetMemClkVfOffset(Offset int) Return { - return DeviceSetMemClkVfOffset(Device, Offset) +func (device nvmlDevice) SetMemClkVfOffset(offset int) Return { + return nvmlDeviceSetMemClkVfOffset(device, int32(offset)) } // nvml.DeviceGetGpcClkMinMaxVfOffset() -func DeviceGetGpcClkMinMaxVfOffset(Device Device) (int, int, Return) { - var MinOffset, MaxOffset int32 - ret := nvmlDeviceGetGpcClkMinMaxVfOffset(Device, &MinOffset, &MaxOffset) - return int(MinOffset), int(MaxOffset), ret +func (l *library) DeviceGetGpcClkMinMaxVfOffset(device Device) (int, int, Return) { + return device.GetGpcClkMinMaxVfOffset() } -func (Device Device) GetGpcClkMinMaxVfOffset() (int, int, Return) { - return DeviceGetGpcClkMinMaxVfOffset(Device) +func (device nvmlDevice) GetGpcClkMinMaxVfOffset() (int, int, Return) { + var minOffset, maxOffset int32 + ret := nvmlDeviceGetGpcClkMinMaxVfOffset(device, &minOffset, &maxOffset) + return int(minOffset), int(maxOffset), ret } // nvml.DeviceGetMemClkMinMaxVfOffset() -func DeviceGetMemClkMinMaxVfOffset(Device Device) (int, int, Return) { - var MinOffset, MaxOffset int32 - ret := nvmlDeviceGetMemClkMinMaxVfOffset(Device, &MinOffset, &MaxOffset) - return int(MinOffset), int(MaxOffset), ret +func (l *library) DeviceGetMemClkMinMaxVfOffset(device Device) (int, int, Return) { + return device.GetMemClkMinMaxVfOffset() } -func (Device Device) GetMemClkMinMaxVfOffset() (int, int, Return) { - return DeviceGetMemClkMinMaxVfOffset(Device) +func (device nvmlDevice) GetMemClkMinMaxVfOffset() (int, int, Return) { + var minOffset, maxOffset int32 + ret := nvmlDeviceGetMemClkMinMaxVfOffset(device, &minOffset, &maxOffset) + return int(minOffset), int(maxOffset), ret } // nvml.DeviceGetGpuMaxPcieLinkGeneration() -func DeviceGetGpuMaxPcieLinkGeneration(Device Device) (int, Return) { - var MaxLinkGenDevice uint32 - ret := nvmlDeviceGetGpuMaxPcieLinkGeneration(Device, &MaxLinkGenDevice) - return int(MaxLinkGenDevice), ret +func (l *library) DeviceGetGpuMaxPcieLinkGeneration(device Device) (int, Return) { + return device.GetGpuMaxPcieLinkGeneration() } -func (Device Device) GetGpuMaxPcieLinkGeneration() (int, Return) { - return DeviceGetGpuMaxPcieLinkGeneration(Device) +func (device nvmlDevice) GetGpuMaxPcieLinkGeneration() (int, Return) { + var maxLinkGenDevice uint32 + ret := nvmlDeviceGetGpuMaxPcieLinkGeneration(device, &maxLinkGenDevice) + return int(maxLinkGenDevice), ret } // nvml.DeviceGetFanControlPolicy_v2() -func DeviceGetFanControlPolicy_v2(Device Device, Fan int) (FanControlPolicy, Return) { - var Policy FanControlPolicy - ret := nvmlDeviceGetFanControlPolicy_v2(Device, uint32(Fan), &Policy) - return Policy, ret +func (l *library) DeviceGetFanControlPolicy_v2(device Device, fan int) (FanControlPolicy, Return) { + return device.GetFanControlPolicy_v2(fan) } -func (Device Device) GetFanControlPolicy_v2(Fan int) (FanControlPolicy, Return) { - return DeviceGetFanControlPolicy_v2(Device, Fan) +func (device nvmlDevice) GetFanControlPolicy_v2(fan int) (FanControlPolicy, Return) { + var policy FanControlPolicy + ret := nvmlDeviceGetFanControlPolicy_v2(device, uint32(fan), &policy) + return policy, ret } // nvml.DeviceSetFanControlPolicy() -func DeviceSetFanControlPolicy(Device Device, Fan int, Policy FanControlPolicy) Return { - return nvmlDeviceSetFanControlPolicy(Device, uint32(Fan), Policy) +func (l *library) DeviceSetFanControlPolicy(device Device, fan int, policy FanControlPolicy) Return { + return device.SetFanControlPolicy(fan, policy) } -func (Device Device) SetFanControlPolicy(Fan int, Policy FanControlPolicy) Return { - return DeviceSetFanControlPolicy(Device, Fan, Policy) +func (device nvmlDevice) SetFanControlPolicy(fan int, policy FanControlPolicy) Return { + return nvmlDeviceSetFanControlPolicy(device, uint32(fan), policy) } // nvml.DeviceClearFieldValues() -func DeviceClearFieldValues(Device Device, Values []FieldValue) Return { - ValuesCount := len(Values) - return nvmlDeviceClearFieldValues(Device, int32(ValuesCount), &Values[0]) +func (l *library) DeviceClearFieldValues(device Device, values []FieldValue) Return { + return device.ClearFieldValues(values) } -func (Device Device) ClearFieldValues(Values []FieldValue) Return { - return DeviceClearFieldValues(Device, Values) +func (device nvmlDevice) ClearFieldValues(values []FieldValue) Return { + valuesCount := len(values) + return nvmlDeviceClearFieldValues(device, int32(valuesCount), &values[0]) } // nvml.DeviceGetVgpuCapabilities() -func DeviceGetVgpuCapabilities(Device Device, Capability DeviceVgpuCapability) (bool, Return) { - var CapResult uint32 - ret := nvmlDeviceGetVgpuCapabilities(Device, Capability, &CapResult) - return (CapResult != 0), ret +func (l *library) DeviceGetVgpuCapabilities(device Device, capability DeviceVgpuCapability) (bool, Return) { + return device.GetVgpuCapabilities(capability) } -func (Device Device) GetVgpuCapabilities(Capability DeviceVgpuCapability) (bool, Return) { - return DeviceGetVgpuCapabilities(Device, Capability) +func (device nvmlDevice) GetVgpuCapabilities(capability DeviceVgpuCapability) (bool, Return) { + var capResult uint32 + ret := nvmlDeviceGetVgpuCapabilities(device, capability, &capResult) + return (capResult != 0), ret } // nvml.DeviceGetVgpuSchedulerLog() -func DeviceGetVgpuSchedulerLog(Device Device) (VgpuSchedulerLog, Return) { - var PSchedulerLog VgpuSchedulerLog - ret := nvmlDeviceGetVgpuSchedulerLog(Device, &PSchedulerLog) - return PSchedulerLog, ret +func (l *library) DeviceGetVgpuSchedulerLog(device Device) (VgpuSchedulerLog, Return) { + return device.GetVgpuSchedulerLog() } -func (Device Device) GetVgpuSchedulerLog() (VgpuSchedulerLog, Return) { - return DeviceGetVgpuSchedulerLog(Device) +func (device nvmlDevice) GetVgpuSchedulerLog() (VgpuSchedulerLog, Return) { + var pSchedulerLog VgpuSchedulerLog + ret := nvmlDeviceGetVgpuSchedulerLog(device, &pSchedulerLog) + return pSchedulerLog, ret } // nvml.DeviceGetVgpuSchedulerState() -func DeviceGetVgpuSchedulerState(Device Device) (VgpuSchedulerGetState, Return) { - var PSchedulerState VgpuSchedulerGetState - ret := nvmlDeviceGetVgpuSchedulerState(Device, &PSchedulerState) - return PSchedulerState, ret +func (l *library) DeviceGetVgpuSchedulerState(device Device) (VgpuSchedulerGetState, Return) { + return device.GetVgpuSchedulerState() } -func (Device Device) GetVgpuSchedulerState() (VgpuSchedulerGetState, Return) { - return DeviceGetVgpuSchedulerState(Device) +func (device nvmlDevice) GetVgpuSchedulerState() (VgpuSchedulerGetState, Return) { + var pSchedulerState VgpuSchedulerGetState + ret := nvmlDeviceGetVgpuSchedulerState(device, &pSchedulerState) + return pSchedulerState, ret } // nvml.DeviceSetVgpuSchedulerState() -func DeviceSetVgpuSchedulerState(Device Device, PSchedulerState *VgpuSchedulerSetState) Return { - return nvmlDeviceSetVgpuSchedulerState(Device, PSchedulerState) +func (l *library) DeviceSetVgpuSchedulerState(device Device, pSchedulerState *VgpuSchedulerSetState) Return { + return device.SetVgpuSchedulerState(pSchedulerState) } -func (Device Device) SetVgpuSchedulerState(PSchedulerState *VgpuSchedulerSetState) Return { - return DeviceSetVgpuSchedulerState(Device, PSchedulerState) +func (device nvmlDevice) SetVgpuSchedulerState(pSchedulerState *VgpuSchedulerSetState) Return { + return nvmlDeviceSetVgpuSchedulerState(device, pSchedulerState) } // nvml.DeviceGetVgpuSchedulerCapabilities() -func DeviceGetVgpuSchedulerCapabilities(Device Device) (VgpuSchedulerCapabilities, Return) { - var PCapabilities VgpuSchedulerCapabilities - ret := nvmlDeviceGetVgpuSchedulerCapabilities(Device, &PCapabilities) - return PCapabilities, ret +func (l *library) DeviceGetVgpuSchedulerCapabilities(device Device) (VgpuSchedulerCapabilities, Return) { + return device.GetVgpuSchedulerCapabilities() } -func (Device Device) GetVgpuSchedulerCapabilities() (VgpuSchedulerCapabilities, Return) { - return DeviceGetVgpuSchedulerCapabilities(Device) +func (device nvmlDevice) GetVgpuSchedulerCapabilities() (VgpuSchedulerCapabilities, Return) { + var pCapabilities VgpuSchedulerCapabilities + ret := nvmlDeviceGetVgpuSchedulerCapabilities(device, &pCapabilities) + return pCapabilities, ret } // nvml.GpuInstanceGetComputeInstancePossiblePlacements() -func GpuInstanceGetComputeInstancePossiblePlacements(GpuInstance GpuInstance, Info *ComputeInstanceProfileInfo) ([]ComputeInstancePlacement, Return) { - var Count uint32 - ret := nvmlGpuInstanceGetComputeInstancePossiblePlacements(GpuInstance, Info.Id, nil, &Count) +func (l *library) GpuInstanceGetComputeInstancePossiblePlacements(gpuInstance GpuInstance, info *ComputeInstanceProfileInfo) ([]ComputeInstancePlacement, Return) { + return gpuInstance.GetComputeInstancePossiblePlacements(info) +} + +func (gpuInstance nvmlGpuInstance) GetComputeInstancePossiblePlacements(info *ComputeInstanceProfileInfo) ([]ComputeInstancePlacement, Return) { + var count uint32 + ret := nvmlGpuInstanceGetComputeInstancePossiblePlacements(gpuInstance, info.Id, nil, &count) if ret != SUCCESS { return nil, ret } - if Count == 0 { + if count == 0 { return []ComputeInstancePlacement{}, ret } - PlacementArray := make([]ComputeInstancePlacement, Count) - ret = nvmlGpuInstanceGetComputeInstancePossiblePlacements(GpuInstance, Info.Id, &PlacementArray[0], &Count) - return PlacementArray, ret -} - -func (GpuInstance GpuInstance) GetComputeInstancePossiblePlacements(Info *ComputeInstanceProfileInfo) ([]ComputeInstancePlacement, Return) { - return GpuInstanceGetComputeInstancePossiblePlacements(GpuInstance, Info) + placementArray := make([]ComputeInstancePlacement, count) + ret = nvmlGpuInstanceGetComputeInstancePossiblePlacements(gpuInstance, info.Id, &placementArray[0], &count) + return placementArray, ret } // nvml.GpuInstanceCreateComputeInstanceWithPlacement() -func GpuInstanceCreateComputeInstanceWithPlacement(GpuInstance GpuInstance, Info *ComputeInstanceProfileInfo, Placement *ComputeInstancePlacement, ComputeInstance *ComputeInstance) Return { - return nvmlGpuInstanceCreateComputeInstanceWithPlacement(GpuInstance, Info.Id, Placement, ComputeInstance) +func (l *library) GpuInstanceCreateComputeInstanceWithPlacement(gpuInstance GpuInstance, info *ComputeInstanceProfileInfo, placement *ComputeInstancePlacement) (ComputeInstance, Return) { + return gpuInstance.CreateComputeInstanceWithPlacement(info, placement) } -func (GpuInstance GpuInstance) CreateComputeInstanceWithPlacement(Info *ComputeInstanceProfileInfo, Placement *ComputeInstancePlacement, ComputeInstance *ComputeInstance) Return { - return GpuInstanceCreateComputeInstanceWithPlacement(GpuInstance, Info, Placement, ComputeInstance) +func (gpuInstance nvmlGpuInstance) CreateComputeInstanceWithPlacement(info *ComputeInstanceProfileInfo, placement *ComputeInstancePlacement) (ComputeInstance, Return) { + var computeInstance nvmlComputeInstance + ret := nvmlGpuInstanceCreateComputeInstanceWithPlacement(gpuInstance, info.Id, placement, &computeInstance) + return computeInstance, ret } // nvml.DeviceGetGpuFabricInfo() -func DeviceGetGpuFabricInfo(Device Device) (GpuFabricInfo, Return) { - var GpuFabricInfo GpuFabricInfo - ret := nvmlDeviceGetGpuFabricInfo(Device, &GpuFabricInfo) - return GpuFabricInfo, ret +func (l *library) DeviceGetGpuFabricInfo(device Device) (GpuFabricInfo, Return) { + return device.GetGpuFabricInfo() +} + +func (device nvmlDevice) GetGpuFabricInfo() (GpuFabricInfo, Return) { + var gpuFabricInfo GpuFabricInfo + ret := nvmlDeviceGetGpuFabricInfo(device, &gpuFabricInfo) + return gpuFabricInfo, ret } -func (Device Device) GetGpuFabricInfo() (GpuFabricInfo, Return) { - return DeviceGetGpuFabricInfo(Device) +// nvml.DeviceSetNvLinkDeviceLowPowerThreshold() +func (l *library) DeviceSetNvLinkDeviceLowPowerThreshold(device Device, info *NvLinkPowerThres) Return { + return device.SetNvLinkDeviceLowPowerThreshold(info) } -// nvml.DeviceCcuGetStreamState() -func DeviceCcuGetStreamState(Device Device) (int, Return) { - var State uint32 - ret := nvmlDeviceCcuGetStreamState(Device, &State) - return int(State), ret +func (device nvmlDevice) SetNvLinkDeviceLowPowerThreshold(info *NvLinkPowerThres) Return { + return nvmlDeviceSetNvLinkDeviceLowPowerThreshold(device, info) } -func (Device Device) CcuGetStreamState() (int, Return) { - return DeviceCcuGetStreamState(Device) +// nvml.DeviceGetModuleId() +func (l *library) DeviceGetModuleId(device Device) (int, Return) { + return device.GetModuleId() } -// nvml.DeviceCcuSetStreamState() -func DeviceCcuSetStreamState(Device Device, State int) Return { - return nvmlDeviceCcuSetStreamState(Device, uint32(State)) +func (device nvmlDevice) GetModuleId() (int, Return) { + var moduleID uint32 + ret := nvmlDeviceGetModuleId(device, &moduleID) + return int(moduleID), ret } -func (Device Device) CcuSetStreamState(State int) Return { - return DeviceCcuSetStreamState(Device, State) +// nvml.DeviceGetCurrentClocksEventReasons() +func (l *library) DeviceGetCurrentClocksEventReasons(device Device) (uint64, Return) { + return device.GetCurrentClocksEventReasons() } -// nvml.DeviceSetNvLinkDeviceLowPowerThreshold() -func DeviceSetNvLinkDeviceLowPowerThreshold(Device Device, Info *NvLinkPowerThres) Return { - return nvmlDeviceSetNvLinkDeviceLowPowerThreshold(Device, Info) +func (device nvmlDevice) GetCurrentClocksEventReasons() (uint64, Return) { + var clocksEventReasons uint64 + ret := nvmlDeviceGetCurrentClocksEventReasons(device, &clocksEventReasons) + return clocksEventReasons, ret +} + +// nvml.DeviceGetSupportedClocksEventReasons() +func (l *library) DeviceGetSupportedClocksEventReasons(device Device) (uint64, Return) { + return device.GetSupportedClocksEventReasons() +} + +func (device nvmlDevice) GetSupportedClocksEventReasons() (uint64, Return) { + var supportedClocksEventReasons uint64 + ret := nvmlDeviceGetSupportedClocksEventReasons(device, &supportedClocksEventReasons) + return supportedClocksEventReasons, ret +} + +// nvml.DeviceGetJpgUtilization() +func (l *library) DeviceGetJpgUtilization(device Device) (uint32, uint32, Return) { + return device.GetJpgUtilization() +} + +func (device nvmlDevice) GetJpgUtilization() (uint32, uint32, Return) { + var utilization, samplingPeriodUs uint32 + ret := nvmlDeviceGetJpgUtilization(device, &utilization, &samplingPeriodUs) + return utilization, samplingPeriodUs, ret +} + +// nvml.DeviceGetOfaUtilization() +func (l *library) DeviceGetOfaUtilization(device Device) (uint32, uint32, Return) { + return device.GetOfaUtilization() +} + +func (device nvmlDevice) GetOfaUtilization() (uint32, uint32, Return) { + var utilization, samplingPeriodUs uint32 + ret := nvmlDeviceGetOfaUtilization(device, &utilization, &samplingPeriodUs) + return utilization, samplingPeriodUs, ret +} + +// nvml.DeviceGetRunningProcessDetailList() +func (l *library) DeviceGetRunningProcessDetailList(device Device) (ProcessDetailList, Return) { + return device.GetRunningProcessDetailList() +} + +func (device nvmlDevice) GetRunningProcessDetailList() (ProcessDetailList, Return) { + var plist ProcessDetailList + ret := nvmlDeviceGetRunningProcessDetailList(device, &plist) + return plist, ret +} + +// nvml.DeviceGetConfComputeMemSizeInfo() +func (l *library) DeviceGetConfComputeMemSizeInfo(device Device) (ConfComputeMemSizeInfo, Return) { + return device.GetConfComputeMemSizeInfo() +} + +func (device nvmlDevice) GetConfComputeMemSizeInfo() (ConfComputeMemSizeInfo, Return) { + var memInfo ConfComputeMemSizeInfo + ret := nvmlDeviceGetConfComputeMemSizeInfo(device, &memInfo) + return memInfo, ret +} + +// nvml.DeviceGetConfComputeProtectedMemoryUsage() +func (l *library) DeviceGetConfComputeProtectedMemoryUsage(device Device) (Memory, Return) { + return device.GetConfComputeProtectedMemoryUsage() +} + +func (device nvmlDevice) GetConfComputeProtectedMemoryUsage() (Memory, Return) { + var memory Memory + ret := nvmlDeviceGetConfComputeProtectedMemoryUsage(device, &memory) + return memory, ret +} + +// nvml.DeviceGetConfComputeGpuCertificate() +func (l *library) DeviceGetConfComputeGpuCertificate(device Device) (ConfComputeGpuCertificate, Return) { + return device.GetConfComputeGpuCertificate() +} + +func (device nvmlDevice) GetConfComputeGpuCertificate() (ConfComputeGpuCertificate, Return) { + var gpuCert ConfComputeGpuCertificate + ret := nvmlDeviceGetConfComputeGpuCertificate(device, &gpuCert) + return gpuCert, ret +} + +// nvml.DeviceGetConfComputeGpuAttestationReport() +func (l *library) DeviceGetConfComputeGpuAttestationReport(device Device) (ConfComputeGpuAttestationReport, Return) { + return device.GetConfComputeGpuAttestationReport() +} + +func (device nvmlDevice) GetConfComputeGpuAttestationReport() (ConfComputeGpuAttestationReport, Return) { + var gpuAtstReport ConfComputeGpuAttestationReport + ret := nvmlDeviceGetConfComputeGpuAttestationReport(device, &gpuAtstReport) + return gpuAtstReport, ret +} + +// nvml.DeviceSetConfComputeUnprotectedMemSize() +func (l *library) DeviceSetConfComputeUnprotectedMemSize(device Device, sizeKiB uint64) Return { + return device.SetConfComputeUnprotectedMemSize(sizeKiB) +} + +func (device nvmlDevice) SetConfComputeUnprotectedMemSize(sizeKiB uint64) Return { + return nvmlDeviceSetConfComputeUnprotectedMemSize(device, sizeKiB) +} + +// nvml.DeviceSetPowerManagementLimit_v2() +func (l *library) DeviceSetPowerManagementLimit_v2(device Device, powerValue *PowerValue_v2) Return { + return device.SetPowerManagementLimit_v2(powerValue) +} + +func (device nvmlDevice) SetPowerManagementLimit_v2(powerValue *PowerValue_v2) Return { + return nvmlDeviceSetPowerManagementLimit_v2(device, powerValue) +} + +// nvml.DeviceGetC2cModeInfoV() +type C2cModeInfoHandler struct { + device nvmlDevice +} + +func (handler C2cModeInfoHandler) V1() (C2cModeInfo_v1, Return) { + var c2cModeInfo C2cModeInfo_v1 + ret := nvmlDeviceGetC2cModeInfoV(handler.device, &c2cModeInfo) + return c2cModeInfo, ret +} + +func (l *library) DeviceGetC2cModeInfoV(device Device) C2cModeInfoHandler { + return device.GetC2cModeInfoV() +} + +func (device nvmlDevice) GetC2cModeInfoV() C2cModeInfoHandler { + return C2cModeInfoHandler{device} +} + +// nvml.DeviceGetLastBBXFlushTime() +func (l *library) DeviceGetLastBBXFlushTime(device Device) (uint64, uint, Return) { + return device.GetLastBBXFlushTime() +} + +func (device nvmlDevice) GetLastBBXFlushTime() (uint64, uint, Return) { + var timestamp uint64 + var durationUs uint + ret := nvmlDeviceGetLastBBXFlushTime(device, ×tamp, &durationUs) + return timestamp, durationUs, ret +} + +// nvml.DeviceGetNumaNodeId() +func (l *library) DeviceGetNumaNodeId(device Device) (int, Return) { + return device.GetNumaNodeId() +} + +func (device nvmlDevice) GetNumaNodeId() (int, Return) { + var node uint32 + ret := nvmlDeviceGetNumaNodeId(device, &node) + return int(node), ret +} + +// nvml.DeviceGetPciInfoExt() +func (l *library) DeviceGetPciInfoExt(device Device) (PciInfoExt, Return) { + return device.GetPciInfoExt() +} + +func (device nvmlDevice) GetPciInfoExt() (PciInfoExt, Return) { + var pciInfo PciInfoExt + ret := nvmlDeviceGetPciInfoExt(device, &pciInfo) + return pciInfo, ret +} + +// nvml.DeviceGetGpuFabricInfoV() +type GpuFabricInfoHandler struct { + device nvmlDevice +} + +func (handler GpuFabricInfoHandler) V1() (GpuFabricInfo, Return) { + return handler.device.GetGpuFabricInfo() +} + +func (handler GpuFabricInfoHandler) V2() (GpuFabricInfo_v2, Return) { + var info GpuFabricInfoV + info.Version = STRUCT_VERSION(info, 2) + ret := nvmlDeviceGetGpuFabricInfoV(handler.device, &info) + return GpuFabricInfo_v2(info), ret +} + +func (l *library) DeviceGetGpuFabricInfoV(device Device) GpuFabricInfoHandler { + return device.GetGpuFabricInfoV() +} + +func (device nvmlDevice) GetGpuFabricInfoV() GpuFabricInfoHandler { + return GpuFabricInfoHandler{device} +} + +// nvml.DeviceGetProcessesUtilizationInfo() +func (l *library) DeviceGetProcessesUtilizationInfo(device Device) (ProcessesUtilizationInfo, Return) { + return device.GetProcessesUtilizationInfo() +} + +func (device nvmlDevice) GetProcessesUtilizationInfo() (ProcessesUtilizationInfo, Return) { + var processesUtilInfo ProcessesUtilizationInfo + ret := nvmlDeviceGetProcessesUtilizationInfo(device, &processesUtilInfo) + return processesUtilInfo, ret +} + +// nvml.DeviceGetVgpuHeterogeneousMode() +func (l *library) DeviceGetVgpuHeterogeneousMode(device Device) (VgpuHeterogeneousMode, Return) { + return device.GetVgpuHeterogeneousMode() +} + +func (device nvmlDevice) GetVgpuHeterogeneousMode() (VgpuHeterogeneousMode, Return) { + var heterogeneousMode VgpuHeterogeneousMode + ret := nvmlDeviceGetVgpuHeterogeneousMode(device, &heterogeneousMode) + return heterogeneousMode, ret +} + +// nvml.DeviceSetVgpuHeterogeneousMode() +func (l *library) DeviceSetVgpuHeterogeneousMode(device Device, heterogeneousMode VgpuHeterogeneousMode) Return { + return device.SetVgpuHeterogeneousMode(heterogeneousMode) +} + +func (device nvmlDevice) SetVgpuHeterogeneousMode(heterogeneousMode VgpuHeterogeneousMode) Return { + ret := nvmlDeviceSetVgpuHeterogeneousMode(device, &heterogeneousMode) + return ret +} + +// nvml.DeviceGetVgpuTypeSupportedPlacements() +func (l *library) DeviceGetVgpuTypeSupportedPlacements(device Device, vgpuTypeId VgpuTypeId) (VgpuPlacementList, Return) { + return device.GetVgpuTypeSupportedPlacements(vgpuTypeId) +} + +func (device nvmlDevice) GetVgpuTypeSupportedPlacements(vgpuTypeId VgpuTypeId) (VgpuPlacementList, Return) { + return vgpuTypeId.GetSupportedPlacements(device) +} + +func (vgpuTypeId nvmlVgpuTypeId) GetSupportedPlacements(device Device) (VgpuPlacementList, Return) { + var placementList VgpuPlacementList + ret := nvmlDeviceGetVgpuTypeSupportedPlacements(nvmlDeviceHandle(device), vgpuTypeId, &placementList) + return placementList, ret +} + +// nvml.DeviceGetVgpuTypeCreatablePlacements() +func (l *library) DeviceGetVgpuTypeCreatablePlacements(device Device, vgpuTypeId VgpuTypeId) (VgpuPlacementList, Return) { + return device.GetVgpuTypeCreatablePlacements(vgpuTypeId) +} + +func (device nvmlDevice) GetVgpuTypeCreatablePlacements(vgpuTypeId VgpuTypeId) (VgpuPlacementList, Return) { + return vgpuTypeId.GetCreatablePlacements(device) +} + +func (vgpuTypeId nvmlVgpuTypeId) GetCreatablePlacements(device Device) (VgpuPlacementList, Return) { + var placementList VgpuPlacementList + ret := nvmlDeviceGetVgpuTypeCreatablePlacements(nvmlDeviceHandle(device), vgpuTypeId, &placementList) + return placementList, ret +} + +// nvml.DeviceSetVgpuCapabilities() +func (l *library) DeviceSetVgpuCapabilities(device Device, capability DeviceVgpuCapability, state EnableState) Return { + return device.SetVgpuCapabilities(capability, state) +} + +func (device nvmlDevice) SetVgpuCapabilities(capability DeviceVgpuCapability, state EnableState) Return { + ret := nvmlDeviceSetVgpuCapabilities(device, capability, state) + return ret +} + +// nvml.DeviceGetVgpuInstancesUtilizationInfo() +func (l *library) DeviceGetVgpuInstancesUtilizationInfo(device Device) (VgpuInstancesUtilizationInfo, Return) { + return device.GetVgpuInstancesUtilizationInfo() +} + +func (device nvmlDevice) GetVgpuInstancesUtilizationInfo() (VgpuInstancesUtilizationInfo, Return) { + var vgpuUtilInfo VgpuInstancesUtilizationInfo + ret := nvmlDeviceGetVgpuInstancesUtilizationInfo(device, &vgpuUtilInfo) + return vgpuUtilInfo, ret +} + +// nvml.DeviceGetVgpuProcessesUtilizationInfo() +func (l *library) DeviceGetVgpuProcessesUtilizationInfo(device Device) (VgpuProcessesUtilizationInfo, Return) { + return device.GetVgpuProcessesUtilizationInfo() +} + +func (device nvmlDevice) GetVgpuProcessesUtilizationInfo() (VgpuProcessesUtilizationInfo, Return) { + var vgpuProcUtilInfo VgpuProcessesUtilizationInfo + ret := nvmlDeviceGetVgpuProcessesUtilizationInfo(device, &vgpuProcUtilInfo) + return vgpuProcUtilInfo, ret +} + +// nvml.DeviceGetSramEccErrorStatus() +func (l *library) DeviceGetSramEccErrorStatus(device Device) (EccSramErrorStatus, Return) { + return device.GetSramEccErrorStatus() } -func (Device Device) SetNvLinkDeviceLowPowerThreshold(Info *NvLinkPowerThres) Return { - return DeviceSetNvLinkDeviceLowPowerThreshold(Device, Info) +func (device nvmlDevice) GetSramEccErrorStatus() (EccSramErrorStatus, Return) { + var status EccSramErrorStatus + ret := nvmlDeviceGetSramEccErrorStatus(device, &status) + return status, ret } diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/event_set.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/event_set.go index c6315f5e..933b4dea 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/event_set.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/event_set.go @@ -14,29 +14,60 @@ package nvml +// EventData includes an interface type for Device instead of nvmlDevice +type EventData struct { + Device Device + EventType uint64 + EventData uint64 + GpuInstanceId uint32 + ComputeInstanceId uint32 +} + +func (e EventData) convert() nvmlEventData { + out := nvmlEventData{ + Device: e.Device.(nvmlDevice), + EventType: e.EventType, + EventData: e.EventData, + GpuInstanceId: e.GpuInstanceId, + ComputeInstanceId: e.ComputeInstanceId, + } + return out +} + +func (e nvmlEventData) convert() EventData { + out := EventData{ + Device: e.Device, + EventType: e.EventType, + EventData: e.EventData, + GpuInstanceId: e.GpuInstanceId, + ComputeInstanceId: e.ComputeInstanceId, + } + return out +} + // nvml.EventSetCreate() -func EventSetCreate() (EventSet, Return) { - var Set EventSet +func (l *library) EventSetCreate() (EventSet, Return) { + var Set nvmlEventSet 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 (l *library) EventSetWait(set EventSet, timeoutms uint32) (EventData, Return) { + return set.Wait(timeoutms) } -func (Set EventSet) Wait(Timeoutms uint32) (EventData, Return) { - return EventSetWait(Set, Timeoutms) +func (set nvmlEventSet) Wait(timeoutms uint32) (EventData, Return) { + var data nvmlEventData + ret := nvmlEventSetWait(set, &data, timeoutms) + return data.convert(), ret } // nvml.EventSetFree() -func EventSetFree(Set EventSet) Return { - return nvmlEventSetFree(Set) +func (l *library) EventSetFree(set EventSet) Return { + return set.Free() } -func (Set EventSet) Free() Return { - return EventSetFree(Set) +func (set nvmlEventSet) Free() Return { + return nvmlEventSetFree(set) } diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/gpm.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/gpm.go index c46c5d78..7f8995cc 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/gpm.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/gpm.go @@ -14,80 +14,159 @@ package nvml +// GpmMetricsGetType includes interface types for GpmSample instead of nvmlGpmSample +type GpmMetricsGetType struct { + Version uint32 + NumMetrics uint32 + Sample1 GpmSample + Sample2 GpmSample + Metrics [98]GpmMetric +} + +func (g *GpmMetricsGetType) convert() *nvmlGpmMetricsGetType { + out := &nvmlGpmMetricsGetType{ + Version: g.Version, + NumMetrics: g.NumMetrics, + Sample1: g.Sample1.(nvmlGpmSample), + Sample2: g.Sample2.(nvmlGpmSample), + } + for i := range g.Metrics { + out.Metrics[i] = g.Metrics[i] + } + return out +} + +func (g *nvmlGpmMetricsGetType) convert() *GpmMetricsGetType { + out := &GpmMetricsGetType{ + Version: g.Version, + NumMetrics: g.NumMetrics, + Sample1: g.Sample1, + Sample2: g.Sample2, + } + for i := range g.Metrics { + out.Metrics[i] = g.Metrics[i] + } + return out +} + // nvml.GpmMetricsGet() type GpmMetricsGetVType struct { metricsGet *GpmMetricsGetType } -func GpmMetricsGetV(MetricsGet *GpmMetricsGetType) GpmMetricsGetVType { - return GpmMetricsGetVType{MetricsGet} +func (l *library) GpmMetricsGetV(metricsGet *GpmMetricsGetType) GpmMetricsGetVType { + return GpmMetricsGetVType{metricsGet} +} + +// nvmlGpmMetricsGetStub is a stub function that can be overridden for testing. +var nvmlGpmMetricsGetStub = nvmlGpmMetricsGet + +func (metricsGetV GpmMetricsGetVType) V1() Return { + metricsGetV.metricsGet.Version = 1 + return gpmMetricsGet(metricsGetV.metricsGet) } -func (MetricsGetV GpmMetricsGetVType) V1() Return { - MetricsGetV.metricsGet.Version = 1 - return nvmlGpmMetricsGet(MetricsGetV.metricsGet) +func (l *library) GpmMetricsGet(metricsGet *GpmMetricsGetType) Return { + metricsGet.Version = GPM_METRICS_GET_VERSION + return gpmMetricsGet(metricsGet) } -func GpmMetricsGet(MetricsGet *GpmMetricsGetType) Return { - MetricsGet.Version = GPM_METRICS_GET_VERSION - return nvmlGpmMetricsGet(MetricsGet) +func gpmMetricsGet(metricsGet *GpmMetricsGetType) Return { + nvmlMetricsGet := metricsGet.convert() + ret := nvmlGpmMetricsGetStub(nvmlMetricsGet) + *metricsGet = *nvmlMetricsGet.convert() + return ret } // nvml.GpmSampleFree() -func GpmSampleFree(GpmSample GpmSample) Return { - return nvmlGpmSampleFree(GpmSample) +func (l *library) GpmSampleFree(gpmSample GpmSample) Return { + return gpmSample.Free() +} + +func (gpmSample nvmlGpmSample) Free() Return { + return nvmlGpmSampleFree(gpmSample) } // nvml.GpmSampleAlloc() -func GpmSampleAlloc(GpmSample *GpmSample) Return { - return nvmlGpmSampleAlloc(GpmSample) +func (l *library) GpmSampleAlloc() (GpmSample, Return) { + var gpmSample nvmlGpmSample + ret := nvmlGpmSampleAlloc(&gpmSample) + return gpmSample, ret } // nvml.GpmSampleGet() -func GpmSampleGet(Device Device, GpmSample GpmSample) Return { - return nvmlGpmSampleGet(Device, GpmSample) +func (l *library) GpmSampleGet(device Device, gpmSample GpmSample) Return { + return gpmSample.Get(device) } -func (Device Device) GpmSampleGet(GpmSample GpmSample) Return { - return GpmSampleGet(Device, GpmSample) +func (device nvmlDevice) GpmSampleGet(gpmSample GpmSample) Return { + return gpmSample.Get(device) +} + +func (gpmSample nvmlGpmSample) Get(device Device) Return { + return nvmlGpmSampleGet(nvmlDeviceHandle(device), gpmSample) } // nvml.GpmQueryDeviceSupport() type GpmSupportV struct { - device Device + device nvmlDevice } -func GpmQueryDeviceSupportV(Device Device) GpmSupportV { - return GpmSupportV{Device} +func (l *library) GpmQueryDeviceSupportV(device Device) GpmSupportV { + return device.GpmQueryDeviceSupportV() } -func (Device Device) GpmQueryDeviceSupportV() GpmSupportV { - return GpmSupportV{Device} +func (device nvmlDevice) GpmQueryDeviceSupportV() GpmSupportV { + return GpmSupportV{device} } -func (GpmSupportV GpmSupportV) V1() (GpmSupport, Return) { - var GpmSupport GpmSupport - GpmSupport.Version = 1 - ret := nvmlGpmQueryDeviceSupport(GpmSupportV.device, &GpmSupport) - return GpmSupport, ret +func (gpmSupportV GpmSupportV) V1() (GpmSupport, Return) { + var gpmSupport GpmSupport + gpmSupport.Version = 1 + ret := nvmlGpmQueryDeviceSupport(gpmSupportV.device, &gpmSupport) + return gpmSupport, ret } -func GpmQueryDeviceSupport(Device Device) (GpmSupport, Return) { - var GpmSupport GpmSupport - GpmSupport.Version = GPM_SUPPORT_VERSION - ret := nvmlGpmQueryDeviceSupport(Device, &GpmSupport) - return GpmSupport, ret +func (l *library) GpmQueryDeviceSupport(device Device) (GpmSupport, Return) { + return device.GpmQueryDeviceSupport() } -func (Device Device) GpmQueryDeviceSupport() (GpmSupport, Return) { - return GpmQueryDeviceSupport(Device) +func (device nvmlDevice) GpmQueryDeviceSupport() (GpmSupport, Return) { + var gpmSupport GpmSupport + gpmSupport.Version = GPM_SUPPORT_VERSION + ret := nvmlGpmQueryDeviceSupport(device, &gpmSupport) + return gpmSupport, ret } // nvml.GpmMigSampleGet() -func GpmMigSampleGet(Device Device, GpuInstanceId int, GpmSample GpmSample) Return { - return nvmlGpmMigSampleGet(Device, uint32(GpuInstanceId), GpmSample) +func (l *library) GpmMigSampleGet(device Device, gpuInstanceId int, gpmSample GpmSample) Return { + return gpmSample.MigGet(device, gpuInstanceId) +} + +func (device nvmlDevice) GpmMigSampleGet(gpuInstanceId int, gpmSample GpmSample) Return { + return gpmSample.MigGet(device, gpuInstanceId) +} + +func (gpmSample nvmlGpmSample) MigGet(device Device, gpuInstanceId int) Return { + return nvmlGpmMigSampleGet(nvmlDeviceHandle(device), uint32(gpuInstanceId), gpmSample) +} + +// nvml.GpmQueryIfStreamingEnabled() +func (l *library) GpmQueryIfStreamingEnabled(device Device) (uint32, Return) { + return device.GpmQueryIfStreamingEnabled() +} + +func (device nvmlDevice) GpmQueryIfStreamingEnabled() (uint32, Return) { + var state uint32 + ret := nvmlGpmQueryIfStreamingEnabled(device, &state) + return state, ret +} + +// nvml.GpmSetStreamingEnabled() +func (l *library) GpmSetStreamingEnabled(device Device, state uint32) Return { + return device.GpmSetStreamingEnabled(state) } -func (Device Device) GpmMigSampleGet(GpuInstanceId int, GpmSample GpmSample) Return { - return GpmMigSampleGet(Device, GpuInstanceId, GpmSample) +func (device nvmlDevice) GpmSetStreamingEnabled(state uint32) Return { + return nvmlGpmSetStreamingEnabled(device, state) } diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/init.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/init.go index e2bc943b..06e64441 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/init.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/init.go @@ -17,31 +17,31 @@ package nvml import "C" // nvml.Init() -func Init() Return { - if err := libnvml.load(); err != nil { +func (l *library) Init() Return { + if err := l.load(); err != nil { return ERROR_LIBRARY_NOT_FOUND } return nvmlInit() } // nvml.InitWithFlags() -func InitWithFlags(Flags uint32) Return { - if err := libnvml.load(); err != nil { +func (l *library) InitWithFlags(flags uint32) Return { + if err := l.load(); err != nil { return ERROR_LIBRARY_NOT_FOUND } - return nvmlInitWithFlags(Flags) + return nvmlInitWithFlags(flags) } // nvml.Shutdown() -func Shutdown() Return { +func (l *library) Shutdown() Return { ret := nvmlShutdown() if ret != SUCCESS { return ret } - err := libnvml.close() + err := l.close() if err != nil { - panic(err) + return ERROR_UNKNOWN } return ret diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/lib.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/lib.go index be4b3fb7..bc4c3de5 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/lib.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/lib.go @@ -34,48 +34,70 @@ const ( var errLibraryNotLoaded = errors.New("library not loaded") var errLibraryAlreadyLoaded = errors.New("library already loaded") +// dynamicLibrary is an interface for abstacting the underlying library. +// This also allows for mocking and testing. + +//go:generate moq -stub -out dynamicLibrary_mock.go . dynamicLibrary +type dynamicLibrary interface { + Lookup(string) error + Open() error + Close() error +} + // library represents an nvml library. // This includes a reference to the underlying DynamicLibrary type library struct { sync.Mutex path string - flags int refcount refcount dl dynamicLibrary } +var _ Interface = (*library)(nil) + // libnvml is a global instance of the nvml library. -var libnvml = library{ - path: defaultNvmlLibraryName, - flags: defaultNvmlLibraryLoadFlags, -} +var libnvml = newLibrary() -var _ Interface = (*library)(nil) +func New(opts ...LibraryOption) Interface { + return newLibrary(opts...) +} -// GetLibrary returns a the library as a Library interface. -func (l *library) GetLibrary() Library { +func newLibrary(opts ...LibraryOption) *library { + l := &library{} + l.init(opts...) return l } -// GetLibrary returns a representation of the underlying library that implements the Library interface. -func GetLibrary() Library { - return libnvml.GetLibrary() +func (l *library) init(opts ...LibraryOption) { + o := libraryOptions{} + for _, opt := range opts { + opt(&o) + } + + if o.path == "" { + o.path = defaultNvmlLibraryName + } + if o.flags == 0 { + o.flags = defaultNvmlLibraryLoadFlags + } + + l.path = o.path + l.dl = dl.New(o.path, o.flags) } -// Lookup checks whether the specified library symbol exists in the library. +func (l *library) Extensions() ExtendedInterface { + return l +} + +// LookupSymbol checks whether the specified library symbol exists in the library. // Note that this requires that the library be loaded. -func (l *library) Lookup(name string) error { - if l == nil || l.dl == nil { +func (l *library) LookupSymbol(name string) error { + if l == nil || l.refcount == 0 { return fmt.Errorf("error looking up %s: %w", name, errLibraryNotLoaded) } return l.dl.Lookup(name) } -// newDynamicLibrary is a function variable that can be overridden for testing. -var newDynamicLibrary = func(path string, flags int) dynamicLibrary { - return dl.New(path, flags) -} - // load initializes the library and updates the versioned symbols. // Multiple calls to an already loaded library will return without error. func (l *library) load() (rerr error) { @@ -87,12 +109,14 @@ func (l *library) load() (rerr error) { return nil } - dl := newDynamicLibrary(l.path, l.flags) - if err := dl.Open(); err != nil { + if err := l.dl.Open(); err != nil { return fmt.Errorf("error opening %s: %w", l.path, err) } - l.dl = dl + // Update the errorStringFunc to point to nvml.ErrorString + errorStringFunc = nvmlErrorString + + // Update all versioned symbols l.updateVersionedSymbols() return nil @@ -114,7 +138,8 @@ func (l *library) close() (rerr error) { return fmt.Errorf("error closing %s: %w", l.path, err) } - l.dl = nil + // Update the errorStringFunc to point to defaultErrorStringFunc + errorStringFunc = defaultErrorStringFunc return nil } @@ -131,9 +156,9 @@ 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 deviceGetComputeRunningProcesses = deviceGetComputeRunningProcesses_v1 +var deviceGetGraphicsRunningProcesses = deviceGetGraphicsRunningProcesses_v1 +var deviceGetMPSComputeRunningProcesses = deviceGetMPSComputeRunningProcesses_v1 var GetBlacklistDeviceCount = GetExcludedDeviceCount var GetBlacklistDeviceInfoByIndex = GetExcludedDeviceInfoByIndex var nvmlDeviceGetGpuInstancePossiblePlacements = nvmlDeviceGetGpuInstancePossiblePlacements_v1 @@ -173,127 +198,94 @@ func (pis ProcessInfo_v2Slice) ToProcessInfoSlice() []ProcessInfo { // When new versioned symbols are added, these would have to be initialized above and have // corresponding checks and subsequent assignments added below. func (l *library) updateVersionedSymbols() { - err := l.Lookup("nvmlInit_v2") + err := l.dl.Lookup("nvmlInit_v2") if err == nil { nvmlInit = nvmlInit_v2 } - err = l.Lookup("nvmlDeviceGetPciInfo_v2") + err = l.dl.Lookup("nvmlDeviceGetPciInfo_v2") if err == nil { nvmlDeviceGetPciInfo = nvmlDeviceGetPciInfo_v2 } - err = l.Lookup("nvmlDeviceGetPciInfo_v3") + err = l.dl.Lookup("nvmlDeviceGetPciInfo_v3") if err == nil { nvmlDeviceGetPciInfo = nvmlDeviceGetPciInfo_v3 } - err = l.Lookup("nvmlDeviceGetCount_v2") + err = l.dl.Lookup("nvmlDeviceGetCount_v2") if err == nil { nvmlDeviceGetCount = nvmlDeviceGetCount_v2 } - err = l.Lookup("nvmlDeviceGetHandleByIndex_v2") + err = l.dl.Lookup("nvmlDeviceGetHandleByIndex_v2") if err == nil { nvmlDeviceGetHandleByIndex = nvmlDeviceGetHandleByIndex_v2 } - err = l.Lookup("nvmlDeviceGetHandleByPciBusId_v2") + err = l.dl.Lookup("nvmlDeviceGetHandleByPciBusId_v2") if err == nil { nvmlDeviceGetHandleByPciBusId = nvmlDeviceGetHandleByPciBusId_v2 } - err = l.Lookup("nvmlDeviceGetNvLinkRemotePciInfo_v2") + err = l.dl.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 = l.Lookup("nvmlDeviceRemoveGpu_v2") + //err = l.dl.Lookup("nvmlDeviceRemoveGpu_v2") //if err == nil { // nvmlDeviceRemoveGpu = nvmlDeviceRemoveGpu_v2 //} - err = l.Lookup("nvmlDeviceGetGridLicensableFeatures_v2") + err = l.dl.Lookup("nvmlDeviceGetGridLicensableFeatures_v2") if err == nil { nvmlDeviceGetGridLicensableFeatures = nvmlDeviceGetGridLicensableFeatures_v2 } - err = l.Lookup("nvmlDeviceGetGridLicensableFeatures_v3") + err = l.dl.Lookup("nvmlDeviceGetGridLicensableFeatures_v3") if err == nil { nvmlDeviceGetGridLicensableFeatures = nvmlDeviceGetGridLicensableFeatures_v3 } - err = l.Lookup("nvmlDeviceGetGridLicensableFeatures_v4") + err = l.dl.Lookup("nvmlDeviceGetGridLicensableFeatures_v4") if err == nil { nvmlDeviceGetGridLicensableFeatures = nvmlDeviceGetGridLicensableFeatures_v4 } - err = l.Lookup("nvmlEventSetWait_v2") + err = l.dl.Lookup("nvmlEventSetWait_v2") if err == nil { nvmlEventSetWait = nvmlEventSetWait_v2 } - err = l.Lookup("nvmlDeviceGetAttributes_v2") + err = l.dl.Lookup("nvmlDeviceGetAttributes_v2") if err == nil { nvmlDeviceGetAttributes = nvmlDeviceGetAttributes_v2 } - err = l.Lookup("nvmlComputeInstanceGetInfo_v2") + err = l.dl.Lookup("nvmlComputeInstanceGetInfo_v2") if err == nil { nvmlComputeInstanceGetInfo = nvmlComputeInstanceGetInfo_v2 } - err = l.Lookup("nvmlDeviceGetComputeRunningProcesses_v2") + err = l.dl.Lookup("nvmlDeviceGetComputeRunningProcesses_v2") if err == nil { - DeviceGetComputeRunningProcesses = deviceGetComputeRunningProcesses_v2 + deviceGetComputeRunningProcesses = deviceGetComputeRunningProcesses_v2 } - err = l.Lookup("nvmlDeviceGetComputeRunningProcesses_v3") + err = l.dl.Lookup("nvmlDeviceGetComputeRunningProcesses_v3") if err == nil { - DeviceGetComputeRunningProcesses = deviceGetComputeRunningProcesses_v3 + deviceGetComputeRunningProcesses = deviceGetComputeRunningProcesses_v3 } - err = l.Lookup("nvmlDeviceGetGraphicsRunningProcesses_v2") + err = l.dl.Lookup("nvmlDeviceGetGraphicsRunningProcesses_v2") if err == nil { - DeviceGetGraphicsRunningProcesses = deviceGetGraphicsRunningProcesses_v2 + deviceGetGraphicsRunningProcesses = deviceGetGraphicsRunningProcesses_v2 } - err = l.Lookup("nvmlDeviceGetGraphicsRunningProcesses_v3") + err = l.dl.Lookup("nvmlDeviceGetGraphicsRunningProcesses_v3") if err == nil { - DeviceGetGraphicsRunningProcesses = deviceGetGraphicsRunningProcesses_v3 + deviceGetGraphicsRunningProcesses = deviceGetGraphicsRunningProcesses_v3 } - err = l.Lookup("nvmlDeviceGetMPSComputeRunningProcesses_v2") + err = l.dl.Lookup("nvmlDeviceGetMPSComputeRunningProcesses_v2") if err == nil { - DeviceGetMPSComputeRunningProcesses = deviceGetMPSComputeRunningProcesses_v2 + deviceGetMPSComputeRunningProcesses = deviceGetMPSComputeRunningProcesses_v2 } - err = l.Lookup("nvmlDeviceGetMPSComputeRunningProcesses_v3") + err = l.dl.Lookup("nvmlDeviceGetMPSComputeRunningProcesses_v3") if err == nil { - DeviceGetMPSComputeRunningProcesses = deviceGetMPSComputeRunningProcesses_v3 + deviceGetMPSComputeRunningProcesses = deviceGetMPSComputeRunningProcesses_v3 } - err = l.Lookup("nvmlDeviceGetGpuInstancePossiblePlacements_v2") + err = l.dl.Lookup("nvmlDeviceGetGpuInstancePossiblePlacements_v2") if err == nil { nvmlDeviceGetGpuInstancePossiblePlacements = nvmlDeviceGetGpuInstancePossiblePlacements_v2 } - err = l.Lookup("nvmlVgpuInstanceGetLicenseInfo_v2") + err = l.dl.Lookup("nvmlVgpuInstanceGetLicenseInfo_v2") if err == nil { nvmlVgpuInstanceGetLicenseInfo = nvmlVgpuInstanceGetLicenseInfo_v2 } } - -// LibraryOption represents a functional option to configure the underlying NVML library -type LibraryOption func(*library) - -// WithLibraryPath provides an option to set the library name to be used by the NVML library. -func WithLibraryPath(path string) LibraryOption { - return func(l *library) { - l.path = path - } -} - -// SetLibraryOptions applies the specified options to the NVML library. -// If this is called when a library is already loaded, and error is raised. -func SetLibraryOptions(opts ...LibraryOption) error { - libnvml.Lock() - defer libnvml.Unlock() - if libnvml.dl != nil { - return errLibraryAlreadyLoaded - } - - for _, opt := range opts { - opt(&libnvml) - } - - if libnvml.path == "" { - libnvml.path = defaultNvmlLibraryName - } - if libnvml.flags == 0 { - libnvml.flags = defaultNvmlLibraryLoadFlags - } - - return nil -} diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/nvml.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/nvml.go index 9bd6965d..6ba290c5 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/nvml.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/nvml.go @@ -102,6 +102,25 @@ func nvmlSystemGetProcessName(Pid uint32, Name *byte, Length uint32) Return { return __v } +// nvmlSystemGetHicVersion function as declared in nvml/nvml.h +func nvmlSystemGetHicVersion(HwbcCount *uint32, HwbcEntries *HwbcEntry) Return { + cHwbcCount, _ := (*C.uint)(unsafe.Pointer(HwbcCount)), cgoAllocsUnknown + cHwbcEntries, _ := (*C.nvmlHwbcEntry_t)(unsafe.Pointer(HwbcEntries)), cgoAllocsUnknown + __ret := C.nvmlSystemGetHicVersion(cHwbcCount, cHwbcEntries) + __v := (Return)(__ret) + return __v +} + +// nvmlSystemGetTopologyGpuSet function as declared in nvml/nvml.h +func nvmlSystemGetTopologyGpuSet(CpuNumber uint32, Count *uint32, DeviceArray *nvmlDevice) Return { + cCpuNumber, _ := (C.uint)(CpuNumber), cgoAllocsUnknown + cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown + cDeviceArray, _ := (*C.nvmlDevice_t)(unsafe.Pointer(DeviceArray)), cgoAllocsUnknown + __ret := C.nvmlSystemGetTopologyGpuSet(cCpuNumber, cCount, cDeviceArray) + __v := (Return)(__ret) + return __v +} + // nvmlUnitGetCount function as declared in nvml/nvml.h func nvmlUnitGetCount(UnitCount *uint32) Return { cUnitCount, _ := (*C.uint)(unsafe.Pointer(UnitCount)), cgoAllocsUnknown @@ -111,75 +130,66 @@ func nvmlUnitGetCount(UnitCount *uint32) Return { } // nvmlUnitGetHandleByIndex function as declared in nvml/nvml.h -func nvmlUnitGetHandleByIndex(Index uint32, Unit *Unit) Return { +func nvmlUnitGetHandleByIndex(Index uint32, nvmlUnit *nvmlUnit) Return { cIndex, _ := (C.uint)(Index), cgoAllocsUnknown - cUnit, _ := (*C.nvmlUnit_t)(unsafe.Pointer(Unit)), cgoAllocsUnknown - __ret := C.nvmlUnitGetHandleByIndex(cIndex, cUnit) + cnvmlUnit, _ := (*C.nvmlUnit_t)(unsafe.Pointer(nvmlUnit)), cgoAllocsUnknown + __ret := C.nvmlUnitGetHandleByIndex(cIndex, cnvmlUnit) __v := (Return)(__ret) return __v } // nvmlUnitGetUnitInfo function as declared in nvml/nvml.h -func nvmlUnitGetUnitInfo(Unit Unit, Info *UnitInfo) Return { - cUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&Unit)), cgoAllocsUnknown +func nvmlUnitGetUnitInfo(nvmlUnit nvmlUnit, Info *UnitInfo) Return { + cnvmlUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&nvmlUnit)), cgoAllocsUnknown cInfo, _ := (*C.nvmlUnitInfo_t)(unsafe.Pointer(Info)), cgoAllocsUnknown - __ret := C.nvmlUnitGetUnitInfo(cUnit, cInfo) + __ret := C.nvmlUnitGetUnitInfo(cnvmlUnit, cInfo) __v := (Return)(__ret) return __v } // nvmlUnitGetLedState function as declared in nvml/nvml.h -func nvmlUnitGetLedState(Unit Unit, State *LedState) Return { - cUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&Unit)), cgoAllocsUnknown +func nvmlUnitGetLedState(nvmlUnit nvmlUnit, State *LedState) Return { + cnvmlUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&nvmlUnit)), cgoAllocsUnknown cState, _ := (*C.nvmlLedState_t)(unsafe.Pointer(State)), cgoAllocsUnknown - __ret := C.nvmlUnitGetLedState(cUnit, cState) + __ret := C.nvmlUnitGetLedState(cnvmlUnit, cState) __v := (Return)(__ret) return __v } // nvmlUnitGetPsuInfo function as declared in nvml/nvml.h -func nvmlUnitGetPsuInfo(Unit Unit, Psu *PSUInfo) Return { - cUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&Unit)), cgoAllocsUnknown +func nvmlUnitGetPsuInfo(nvmlUnit nvmlUnit, Psu *PSUInfo) Return { + cnvmlUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&nvmlUnit)), cgoAllocsUnknown cPsu, _ := (*C.nvmlPSUInfo_t)(unsafe.Pointer(Psu)), cgoAllocsUnknown - __ret := C.nvmlUnitGetPsuInfo(cUnit, cPsu) + __ret := C.nvmlUnitGetPsuInfo(cnvmlUnit, cPsu) __v := (Return)(__ret) return __v } // nvmlUnitGetTemperature function as declared in nvml/nvml.h -func nvmlUnitGetTemperature(Unit Unit, _type uint32, Temp *uint32) Return { - cUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&Unit)), cgoAllocsUnknown +func nvmlUnitGetTemperature(nvmlUnit nvmlUnit, _type uint32, Temp *uint32) Return { + cnvmlUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&nvmlUnit)), cgoAllocsUnknown c_type, _ := (C.uint)(_type), cgoAllocsUnknown cTemp, _ := (*C.uint)(unsafe.Pointer(Temp)), cgoAllocsUnknown - __ret := C.nvmlUnitGetTemperature(cUnit, c_type, cTemp) + __ret := C.nvmlUnitGetTemperature(cnvmlUnit, c_type, cTemp) __v := (Return)(__ret) return __v } // nvmlUnitGetFanSpeedInfo function as declared in nvml/nvml.h -func nvmlUnitGetFanSpeedInfo(Unit Unit, FanSpeeds *UnitFanSpeeds) Return { - cUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&Unit)), cgoAllocsUnknown +func nvmlUnitGetFanSpeedInfo(nvmlUnit nvmlUnit, FanSpeeds *UnitFanSpeeds) Return { + cnvmlUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&nvmlUnit)), cgoAllocsUnknown cFanSpeeds, _ := (*C.nvmlUnitFanSpeeds_t)(unsafe.Pointer(FanSpeeds)), cgoAllocsUnknown - __ret := C.nvmlUnitGetFanSpeedInfo(cUnit, cFanSpeeds) + __ret := C.nvmlUnitGetFanSpeedInfo(cnvmlUnit, cFanSpeeds) __v := (Return)(__ret) return __v } // nvmlUnitGetDevices function as declared in nvml/nvml.h -func nvmlUnitGetDevices(Unit Unit, DeviceCount *uint32, Devices *Device) Return { - cUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&Unit)), cgoAllocsUnknown +func nvmlUnitGetDevices(nvmlUnit nvmlUnit, DeviceCount *uint32, Devices *nvmlDevice) Return { + cnvmlUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&nvmlUnit)), cgoAllocsUnknown cDeviceCount, _ := (*C.uint)(unsafe.Pointer(DeviceCount)), cgoAllocsUnknown cDevices, _ := (*C.nvmlDevice_t)(unsafe.Pointer(Devices)), cgoAllocsUnknown - __ret := C.nvmlUnitGetDevices(cUnit, cDeviceCount, cDevices) - __v := (Return)(__ret) - return __v -} - -// nvmlSystemGetHicVersion function as declared in nvml/nvml.h -func nvmlSystemGetHicVersion(HwbcCount *uint32, HwbcEntries *HwbcEntry) Return { - cHwbcCount, _ := (*C.uint)(unsafe.Pointer(HwbcCount)), cgoAllocsUnknown - cHwbcEntries, _ := (*C.nvmlHwbcEntry_t)(unsafe.Pointer(HwbcEntries)), cgoAllocsUnknown - __ret := C.nvmlSystemGetHicVersion(cHwbcCount, cHwbcEntries) + __ret := C.nvmlUnitGetDevices(cnvmlUnit, cDeviceCount, cDevices) __v := (Return)(__ret) return __v } @@ -193,138 +203,165 @@ func nvmlDeviceGetCount_v2(DeviceCount *uint32) Return { } // nvmlDeviceGetAttributes_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetAttributes_v2(Device Device, Attributes *DeviceAttributes) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetAttributes_v2(nvmlDevice nvmlDevice, Attributes *DeviceAttributes) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cAttributes, _ := (*C.nvmlDeviceAttributes_t)(unsafe.Pointer(Attributes)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetAttributes_v2(cDevice, cAttributes) + __ret := C.nvmlDeviceGetAttributes_v2(cnvmlDevice, cAttributes) __v := (Return)(__ret) return __v } // nvmlDeviceGetHandleByIndex_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetHandleByIndex_v2(Index uint32, Device *Device) Return { +func nvmlDeviceGetHandleByIndex_v2(Index uint32, nvmlDevice *nvmlDevice) Return { cIndex, _ := (C.uint)(Index), cgoAllocsUnknown - cDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetHandleByIndex_v2(cIndex, cDevice) + cnvmlDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetHandleByIndex_v2(cIndex, cnvmlDevice) __v := (Return)(__ret) return __v } // nvmlDeviceGetHandleBySerial function as declared in nvml/nvml.h -func nvmlDeviceGetHandleBySerial(Serial string, Device *Device) Return { +func nvmlDeviceGetHandleBySerial(Serial string, nvmlDevice *nvmlDevice) Return { cSerial, _ := unpackPCharString(Serial) - cDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetHandleBySerial(cSerial, cDevice) + cnvmlDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetHandleBySerial(cSerial, cnvmlDevice) __v := (Return)(__ret) return __v } // nvmlDeviceGetHandleByUUID function as declared in nvml/nvml.h -func nvmlDeviceGetHandleByUUID(Uuid string, Device *Device) Return { +func nvmlDeviceGetHandleByUUID(Uuid string, nvmlDevice *nvmlDevice) Return { cUuid, _ := unpackPCharString(Uuid) - cDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetHandleByUUID(cUuid, cDevice) + cnvmlDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetHandleByUUID(cUuid, cnvmlDevice) __v := (Return)(__ret) return __v } // nvmlDeviceGetHandleByPciBusId_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetHandleByPciBusId_v2(PciBusId string, Device *Device) Return { +func nvmlDeviceGetHandleByPciBusId_v2(PciBusId string, nvmlDevice *nvmlDevice) Return { cPciBusId, _ := unpackPCharString(PciBusId) - cDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetHandleByPciBusId_v2(cPciBusId, cDevice) + cnvmlDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetHandleByPciBusId_v2(cPciBusId, cnvmlDevice) __v := (Return)(__ret) return __v } // nvmlDeviceGetName function as declared in nvml/nvml.h -func nvmlDeviceGetName(Device Device, Name *byte, Length uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetName(nvmlDevice nvmlDevice, Name *byte, Length uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cName, _ := (*C.char)(unsafe.Pointer(Name)), cgoAllocsUnknown cLength, _ := (C.uint)(Length), cgoAllocsUnknown - __ret := C.nvmlDeviceGetName(cDevice, cName, cLength) + __ret := C.nvmlDeviceGetName(cnvmlDevice, cName, cLength) __v := (Return)(__ret) return __v } // nvmlDeviceGetBrand function as declared in nvml/nvml.h -func nvmlDeviceGetBrand(Device Device, _type *BrandType) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetBrand(nvmlDevice nvmlDevice, _type *BrandType) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown c_type, _ := (*C.nvmlBrandType_t)(unsafe.Pointer(_type)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetBrand(cDevice, c_type) + __ret := C.nvmlDeviceGetBrand(cnvmlDevice, c_type) __v := (Return)(__ret) return __v } // nvmlDeviceGetIndex function as declared in nvml/nvml.h -func nvmlDeviceGetIndex(Device Device, Index *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetIndex(nvmlDevice nvmlDevice, Index *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cIndex, _ := (*C.uint)(unsafe.Pointer(Index)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetIndex(cDevice, cIndex) + __ret := C.nvmlDeviceGetIndex(cnvmlDevice, cIndex) __v := (Return)(__ret) return __v } // nvmlDeviceGetSerial function as declared in nvml/nvml.h -func nvmlDeviceGetSerial(Device Device, Serial *byte, Length uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetSerial(nvmlDevice nvmlDevice, Serial *byte, Length uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cSerial, _ := (*C.char)(unsafe.Pointer(Serial)), cgoAllocsUnknown cLength, _ := (C.uint)(Length), cgoAllocsUnknown - __ret := C.nvmlDeviceGetSerial(cDevice, cSerial, cLength) + __ret := C.nvmlDeviceGetSerial(cnvmlDevice, cSerial, cLength) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetModuleId function as declared in nvml/nvml.h +func nvmlDeviceGetModuleId(nvmlDevice nvmlDevice, ModuleId *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cModuleId, _ := (*C.uint)(unsafe.Pointer(ModuleId)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetModuleId(cnvmlDevice, cModuleId) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetC2cModeInfoV function as declared in nvml/nvml.h +func nvmlDeviceGetC2cModeInfoV(nvmlDevice nvmlDevice, C2cModeInfo *C2cModeInfo_v1) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cC2cModeInfo, _ := (*C.nvmlC2cModeInfo_v1_t)(unsafe.Pointer(C2cModeInfo)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetC2cModeInfoV(cnvmlDevice, cC2cModeInfo) __v := (Return)(__ret) return __v } // nvmlDeviceGetMemoryAffinity function as declared in nvml/nvml.h -func nvmlDeviceGetMemoryAffinity(Device Device, NodeSetSize uint32, NodeSet *uint, Scope AffinityScope) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMemoryAffinity(nvmlDevice nvmlDevice, NodeSetSize uint32, NodeSet *uint, Scope AffinityScope) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cNodeSetSize, _ := (C.uint)(NodeSetSize), cgoAllocsUnknown cNodeSet, _ := (*C.ulong)(unsafe.Pointer(NodeSet)), cgoAllocsUnknown cScope, _ := (C.nvmlAffinityScope_t)(Scope), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMemoryAffinity(cDevice, cNodeSetSize, cNodeSet, cScope) + __ret := C.nvmlDeviceGetMemoryAffinity(cnvmlDevice, cNodeSetSize, cNodeSet, cScope) __v := (Return)(__ret) return __v } // nvmlDeviceGetCpuAffinityWithinScope function as declared in nvml/nvml.h -func nvmlDeviceGetCpuAffinityWithinScope(Device Device, CpuSetSize uint32, CpuSet *uint, Scope AffinityScope) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetCpuAffinityWithinScope(nvmlDevice nvmlDevice, CpuSetSize uint32, CpuSet *uint, Scope AffinityScope) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCpuSetSize, _ := (C.uint)(CpuSetSize), cgoAllocsUnknown cCpuSet, _ := (*C.ulong)(unsafe.Pointer(CpuSet)), cgoAllocsUnknown cScope, _ := (C.nvmlAffinityScope_t)(Scope), cgoAllocsUnknown - __ret := C.nvmlDeviceGetCpuAffinityWithinScope(cDevice, cCpuSetSize, cCpuSet, cScope) + __ret := C.nvmlDeviceGetCpuAffinityWithinScope(cnvmlDevice, cCpuSetSize, cCpuSet, cScope) __v := (Return)(__ret) return __v } // nvmlDeviceGetCpuAffinity function as declared in nvml/nvml.h -func nvmlDeviceGetCpuAffinity(Device Device, CpuSetSize uint32, CpuSet *uint) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetCpuAffinity(nvmlDevice nvmlDevice, CpuSetSize uint32, CpuSet *uint) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCpuSetSize, _ := (C.uint)(CpuSetSize), cgoAllocsUnknown cCpuSet, _ := (*C.ulong)(unsafe.Pointer(CpuSet)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetCpuAffinity(cDevice, cCpuSetSize, cCpuSet) + __ret := C.nvmlDeviceGetCpuAffinity(cnvmlDevice, cCpuSetSize, cCpuSet) __v := (Return)(__ret) return __v } // nvmlDeviceSetCpuAffinity function as declared in nvml/nvml.h -func nvmlDeviceSetCpuAffinity(Device Device) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceSetCpuAffinity(cDevice) +func nvmlDeviceSetCpuAffinity(nvmlDevice nvmlDevice) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceSetCpuAffinity(cnvmlDevice) __v := (Return)(__ret) return __v } // nvmlDeviceClearCpuAffinity function as declared in nvml/nvml.h -func nvmlDeviceClearCpuAffinity(Device Device) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceClearCpuAffinity(cDevice) +func nvmlDeviceClearCpuAffinity(nvmlDevice nvmlDevice) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceClearCpuAffinity(cnvmlDevice) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetNumaNodeId function as declared in nvml/nvml.h +func nvmlDeviceGetNumaNodeId(nvmlDevice nvmlDevice, Node *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cNode, _ := (*C.uint)(unsafe.Pointer(Node)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetNumaNodeId(cnvmlDevice, cNode) __v := (Return)(__ret) return __v } // nvmlDeviceGetTopologyCommonAncestor function as declared in nvml/nvml.h -func nvmlDeviceGetTopologyCommonAncestor(Device1 Device, Device2 Device, PathInfo *GpuTopologyLevel) Return { +func nvmlDeviceGetTopologyCommonAncestor(Device1 nvmlDevice, Device2 nvmlDevice, PathInfo *GpuTopologyLevel) Return { cDevice1, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device1)), cgoAllocsUnknown cDevice2, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device2)), cgoAllocsUnknown cPathInfo, _ := (*C.nvmlGpuTopologyLevel_t)(unsafe.Pointer(PathInfo)), cgoAllocsUnknown @@ -334,28 +371,18 @@ func nvmlDeviceGetTopologyCommonAncestor(Device1 Device, Device2 Device, PathInf } // nvmlDeviceGetTopologyNearestGpus function as declared in nvml/nvml.h -func nvmlDeviceGetTopologyNearestGpus(Device Device, Level GpuTopologyLevel, Count *uint32, DeviceArray *Device) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetTopologyNearestGpus(nvmlDevice nvmlDevice, Level GpuTopologyLevel, Count *uint32, DeviceArray *nvmlDevice) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLevel, _ := (C.nvmlGpuTopologyLevel_t)(Level), cgoAllocsUnknown cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown cDeviceArray, _ := (*C.nvmlDevice_t)(unsafe.Pointer(DeviceArray)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetTopologyNearestGpus(cDevice, cLevel, cCount, cDeviceArray) - __v := (Return)(__ret) - return __v -} - -// nvmlSystemGetTopologyGpuSet function as declared in nvml/nvml.h -func nvmlSystemGetTopologyGpuSet(CpuNumber uint32, Count *uint32, DeviceArray *Device) Return { - cCpuNumber, _ := (C.uint)(CpuNumber), cgoAllocsUnknown - cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown - cDeviceArray, _ := (*C.nvmlDevice_t)(unsafe.Pointer(DeviceArray)), cgoAllocsUnknown - __ret := C.nvmlSystemGetTopologyGpuSet(cCpuNumber, cCount, cDeviceArray) + __ret := C.nvmlDeviceGetTopologyNearestGpus(cnvmlDevice, cLevel, cCount, cDeviceArray) __v := (Return)(__ret) return __v } // nvmlDeviceGetP2PStatus function as declared in nvml/nvml.h -func nvmlDeviceGetP2PStatus(Device1 Device, Device2 Device, P2pIndex GpuP2PCapsIndex, P2pStatus *GpuP2PStatus) Return { +func nvmlDeviceGetP2PStatus(Device1 nvmlDevice, Device2 nvmlDevice, P2pIndex GpuP2PCapsIndex, P2pStatus *GpuP2PStatus) Return { cDevice1, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device1)), cgoAllocsUnknown cDevice2, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device2)), cgoAllocsUnknown cP2pIndex, _ := (C.nvmlGpuP2PCapsIndex_t)(P2pIndex), cgoAllocsUnknown @@ -366,776 +393,845 @@ func nvmlDeviceGetP2PStatus(Device1 Device, Device2 Device, P2pIndex GpuP2PCapsI } // nvmlDeviceGetUUID function as declared in nvml/nvml.h -func nvmlDeviceGetUUID(Device Device, Uuid *byte, Length uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetUUID(nvmlDevice nvmlDevice, Uuid *byte, Length uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cUuid, _ := (*C.char)(unsafe.Pointer(Uuid)), cgoAllocsUnknown cLength, _ := (C.uint)(Length), cgoAllocsUnknown - __ret := C.nvmlDeviceGetUUID(cDevice, cUuid, cLength) - __v := (Return)(__ret) - return __v -} - -// nvmlVgpuInstanceGetMdevUUID function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetMdevUUID(VgpuInstance VgpuInstance, MdevUuid *byte, Size uint32) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown - cMdevUuid, _ := (*C.char)(unsafe.Pointer(MdevUuid)), cgoAllocsUnknown - cSize, _ := (C.uint)(Size), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetMdevUUID(cVgpuInstance, cMdevUuid, cSize) + __ret := C.nvmlDeviceGetUUID(cnvmlDevice, cUuid, cLength) __v := (Return)(__ret) return __v } // nvmlDeviceGetMinorNumber function as declared in nvml/nvml.h -func nvmlDeviceGetMinorNumber(Device Device, MinorNumber *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMinorNumber(nvmlDevice nvmlDevice, MinorNumber *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMinorNumber, _ := (*C.uint)(unsafe.Pointer(MinorNumber)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMinorNumber(cDevice, cMinorNumber) + __ret := C.nvmlDeviceGetMinorNumber(cnvmlDevice, cMinorNumber) __v := (Return)(__ret) return __v } // nvmlDeviceGetBoardPartNumber function as declared in nvml/nvml.h -func nvmlDeviceGetBoardPartNumber(Device Device, PartNumber *byte, Length uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetBoardPartNumber(nvmlDevice nvmlDevice, PartNumber *byte, Length uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPartNumber, _ := (*C.char)(unsafe.Pointer(PartNumber)), cgoAllocsUnknown cLength, _ := (C.uint)(Length), cgoAllocsUnknown - __ret := C.nvmlDeviceGetBoardPartNumber(cDevice, cPartNumber, cLength) + __ret := C.nvmlDeviceGetBoardPartNumber(cnvmlDevice, cPartNumber, cLength) __v := (Return)(__ret) return __v } // nvmlDeviceGetInforomVersion function as declared in nvml/nvml.h -func nvmlDeviceGetInforomVersion(Device Device, Object InforomObject, Version *byte, Length uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetInforomVersion(nvmlDevice nvmlDevice, Object InforomObject, Version *byte, Length uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cObject, _ := (C.nvmlInforomObject_t)(Object), cgoAllocsUnknown cVersion, _ := (*C.char)(unsafe.Pointer(Version)), cgoAllocsUnknown cLength, _ := (C.uint)(Length), cgoAllocsUnknown - __ret := C.nvmlDeviceGetInforomVersion(cDevice, cObject, cVersion, cLength) + __ret := C.nvmlDeviceGetInforomVersion(cnvmlDevice, cObject, cVersion, cLength) __v := (Return)(__ret) return __v } // nvmlDeviceGetInforomImageVersion function as declared in nvml/nvml.h -func nvmlDeviceGetInforomImageVersion(Device Device, Version *byte, Length uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetInforomImageVersion(nvmlDevice nvmlDevice, Version *byte, Length uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cVersion, _ := (*C.char)(unsafe.Pointer(Version)), cgoAllocsUnknown cLength, _ := (C.uint)(Length), cgoAllocsUnknown - __ret := C.nvmlDeviceGetInforomImageVersion(cDevice, cVersion, cLength) + __ret := C.nvmlDeviceGetInforomImageVersion(cnvmlDevice, cVersion, cLength) __v := (Return)(__ret) return __v } // nvmlDeviceGetInforomConfigurationChecksum function as declared in nvml/nvml.h -func nvmlDeviceGetInforomConfigurationChecksum(Device Device, Checksum *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetInforomConfigurationChecksum(nvmlDevice nvmlDevice, Checksum *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cChecksum, _ := (*C.uint)(unsafe.Pointer(Checksum)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetInforomConfigurationChecksum(cDevice, cChecksum) + __ret := C.nvmlDeviceGetInforomConfigurationChecksum(cnvmlDevice, cChecksum) __v := (Return)(__ret) return __v } // nvmlDeviceValidateInforom function as declared in nvml/nvml.h -func nvmlDeviceValidateInforom(Device Device) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceValidateInforom(cDevice) +func nvmlDeviceValidateInforom(nvmlDevice nvmlDevice) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceValidateInforom(cnvmlDevice) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetLastBBXFlushTime function as declared in nvml/nvml.h +func nvmlDeviceGetLastBBXFlushTime(nvmlDevice nvmlDevice, Timestamp *uint64, DurationUs *uint) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cTimestamp, _ := (*C.ulonglong)(unsafe.Pointer(Timestamp)), cgoAllocsUnknown + cDurationUs, _ := (*C.ulong)(unsafe.Pointer(DurationUs)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetLastBBXFlushTime(cnvmlDevice, cTimestamp, cDurationUs) __v := (Return)(__ret) return __v } // nvmlDeviceGetDisplayMode function as declared in nvml/nvml.h -func nvmlDeviceGetDisplayMode(Device Device, Display *EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetDisplayMode(nvmlDevice nvmlDevice, Display *EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cDisplay, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(Display)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetDisplayMode(cDevice, cDisplay) + __ret := C.nvmlDeviceGetDisplayMode(cnvmlDevice, cDisplay) __v := (Return)(__ret) return __v } // nvmlDeviceGetDisplayActive function as declared in nvml/nvml.h -func nvmlDeviceGetDisplayActive(Device Device, IsActive *EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetDisplayActive(nvmlDevice nvmlDevice, IsActive *EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cIsActive, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(IsActive)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetDisplayActive(cDevice, cIsActive) + __ret := C.nvmlDeviceGetDisplayActive(cnvmlDevice, cIsActive) __v := (Return)(__ret) return __v } // nvmlDeviceGetPersistenceMode function as declared in nvml/nvml.h -func nvmlDeviceGetPersistenceMode(Device Device, Mode *EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPersistenceMode(nvmlDevice nvmlDevice, Mode *EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMode, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(Mode)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPersistenceMode(cDevice, cMode) + __ret := C.nvmlDeviceGetPersistenceMode(cnvmlDevice, cMode) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetPciInfoExt function as declared in nvml/nvml.h +func nvmlDeviceGetPciInfoExt(nvmlDevice nvmlDevice, Pci *PciInfoExt) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cPci, _ := (*C.nvmlPciInfoExt_t)(unsafe.Pointer(Pci)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetPciInfoExt(cnvmlDevice, cPci) __v := (Return)(__ret) return __v } // nvmlDeviceGetPciInfo_v3 function as declared in nvml/nvml.h -func nvmlDeviceGetPciInfo_v3(Device Device, Pci *PciInfo) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPciInfo_v3(nvmlDevice nvmlDevice, Pci *PciInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPci, _ := (*C.nvmlPciInfo_t)(unsafe.Pointer(Pci)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPciInfo_v3(cDevice, cPci) + __ret := C.nvmlDeviceGetPciInfo_v3(cnvmlDevice, cPci) __v := (Return)(__ret) return __v } // nvmlDeviceGetMaxPcieLinkGeneration function as declared in nvml/nvml.h -func nvmlDeviceGetMaxPcieLinkGeneration(Device Device, MaxLinkGen *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMaxPcieLinkGeneration(nvmlDevice nvmlDevice, MaxLinkGen *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMaxLinkGen, _ := (*C.uint)(unsafe.Pointer(MaxLinkGen)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMaxPcieLinkGeneration(cDevice, cMaxLinkGen) + __ret := C.nvmlDeviceGetMaxPcieLinkGeneration(cnvmlDevice, cMaxLinkGen) __v := (Return)(__ret) return __v } // nvmlDeviceGetGpuMaxPcieLinkGeneration function as declared in nvml/nvml.h -func nvmlDeviceGetGpuMaxPcieLinkGeneration(Device Device, MaxLinkGenDevice *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGpuMaxPcieLinkGeneration(nvmlDevice nvmlDevice, MaxLinkGenDevice *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMaxLinkGenDevice, _ := (*C.uint)(unsafe.Pointer(MaxLinkGenDevice)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGpuMaxPcieLinkGeneration(cDevice, cMaxLinkGenDevice) + __ret := C.nvmlDeviceGetGpuMaxPcieLinkGeneration(cnvmlDevice, cMaxLinkGenDevice) __v := (Return)(__ret) return __v } // nvmlDeviceGetMaxPcieLinkWidth function as declared in nvml/nvml.h -func nvmlDeviceGetMaxPcieLinkWidth(Device Device, MaxLinkWidth *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMaxPcieLinkWidth(nvmlDevice nvmlDevice, MaxLinkWidth *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMaxLinkWidth, _ := (*C.uint)(unsafe.Pointer(MaxLinkWidth)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMaxPcieLinkWidth(cDevice, cMaxLinkWidth) + __ret := C.nvmlDeviceGetMaxPcieLinkWidth(cnvmlDevice, cMaxLinkWidth) __v := (Return)(__ret) return __v } // nvmlDeviceGetCurrPcieLinkGeneration function as declared in nvml/nvml.h -func nvmlDeviceGetCurrPcieLinkGeneration(Device Device, CurrLinkGen *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetCurrPcieLinkGeneration(nvmlDevice nvmlDevice, CurrLinkGen *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCurrLinkGen, _ := (*C.uint)(unsafe.Pointer(CurrLinkGen)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetCurrPcieLinkGeneration(cDevice, cCurrLinkGen) + __ret := C.nvmlDeviceGetCurrPcieLinkGeneration(cnvmlDevice, cCurrLinkGen) __v := (Return)(__ret) return __v } // nvmlDeviceGetCurrPcieLinkWidth function as declared in nvml/nvml.h -func nvmlDeviceGetCurrPcieLinkWidth(Device Device, CurrLinkWidth *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetCurrPcieLinkWidth(nvmlDevice nvmlDevice, CurrLinkWidth *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCurrLinkWidth, _ := (*C.uint)(unsafe.Pointer(CurrLinkWidth)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetCurrPcieLinkWidth(cDevice, cCurrLinkWidth) + __ret := C.nvmlDeviceGetCurrPcieLinkWidth(cnvmlDevice, cCurrLinkWidth) __v := (Return)(__ret) return __v } // nvmlDeviceGetPcieThroughput function as declared in nvml/nvml.h -func nvmlDeviceGetPcieThroughput(Device Device, Counter PcieUtilCounter, Value *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPcieThroughput(nvmlDevice nvmlDevice, Counter PcieUtilCounter, Value *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCounter, _ := (C.nvmlPcieUtilCounter_t)(Counter), cgoAllocsUnknown cValue, _ := (*C.uint)(unsafe.Pointer(Value)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPcieThroughput(cDevice, cCounter, cValue) + __ret := C.nvmlDeviceGetPcieThroughput(cnvmlDevice, cCounter, cValue) __v := (Return)(__ret) return __v } // nvmlDeviceGetPcieReplayCounter function as declared in nvml/nvml.h -func nvmlDeviceGetPcieReplayCounter(Device Device, Value *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPcieReplayCounter(nvmlDevice nvmlDevice, Value *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cValue, _ := (*C.uint)(unsafe.Pointer(Value)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPcieReplayCounter(cDevice, cValue) + __ret := C.nvmlDeviceGetPcieReplayCounter(cnvmlDevice, cValue) __v := (Return)(__ret) return __v } // nvmlDeviceGetClockInfo function as declared in nvml/nvml.h -func nvmlDeviceGetClockInfo(Device Device, _type ClockType, Clock *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetClockInfo(nvmlDevice nvmlDevice, _type ClockType, Clock *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown c_type, _ := (C.nvmlClockType_t)(_type), cgoAllocsUnknown cClock, _ := (*C.uint)(unsafe.Pointer(Clock)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetClockInfo(cDevice, c_type, cClock) + __ret := C.nvmlDeviceGetClockInfo(cnvmlDevice, c_type, cClock) __v := (Return)(__ret) return __v } // nvmlDeviceGetMaxClockInfo function as declared in nvml/nvml.h -func nvmlDeviceGetMaxClockInfo(Device Device, _type ClockType, Clock *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMaxClockInfo(nvmlDevice nvmlDevice, _type ClockType, Clock *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown c_type, _ := (C.nvmlClockType_t)(_type), cgoAllocsUnknown cClock, _ := (*C.uint)(unsafe.Pointer(Clock)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMaxClockInfo(cDevice, c_type, cClock) + __ret := C.nvmlDeviceGetMaxClockInfo(cnvmlDevice, c_type, cClock) __v := (Return)(__ret) return __v } -// nvmlDeviceGetApplicationsClock function as declared in nvml/nvml.h -func nvmlDeviceGetApplicationsClock(Device Device, ClockType ClockType, ClockMHz *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cClockType, _ := (C.nvmlClockType_t)(ClockType), cgoAllocsUnknown - cClockMHz, _ := (*C.uint)(unsafe.Pointer(ClockMHz)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetApplicationsClock(cDevice, cClockType, cClockMHz) +// nvmlDeviceGetGpcClkVfOffset function as declared in nvml/nvml.h +func nvmlDeviceGetGpcClkVfOffset(nvmlDevice nvmlDevice, Offset *int32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cOffset, _ := (*C.int)(unsafe.Pointer(Offset)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetGpcClkVfOffset(cnvmlDevice, cOffset) __v := (Return)(__ret) return __v } -// nvmlDeviceGetDefaultApplicationsClock function as declared in nvml/nvml.h -func nvmlDeviceGetDefaultApplicationsClock(Device Device, ClockType ClockType, ClockMHz *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +// nvmlDeviceGetApplicationsClock function as declared in nvml/nvml.h +func nvmlDeviceGetApplicationsClock(nvmlDevice nvmlDevice, ClockType ClockType, ClockMHz *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cClockType, _ := (C.nvmlClockType_t)(ClockType), cgoAllocsUnknown cClockMHz, _ := (*C.uint)(unsafe.Pointer(ClockMHz)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetDefaultApplicationsClock(cDevice, cClockType, cClockMHz) + __ret := C.nvmlDeviceGetApplicationsClock(cnvmlDevice, cClockType, cClockMHz) __v := (Return)(__ret) return __v } -// nvmlDeviceResetApplicationsClocks function as declared in nvml/nvml.h -func nvmlDeviceResetApplicationsClocks(Device Device) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceResetApplicationsClocks(cDevice) +// nvmlDeviceGetDefaultApplicationsClock function as declared in nvml/nvml.h +func nvmlDeviceGetDefaultApplicationsClock(nvmlDevice nvmlDevice, ClockType ClockType, ClockMHz *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cClockType, _ := (C.nvmlClockType_t)(ClockType), cgoAllocsUnknown + cClockMHz, _ := (*C.uint)(unsafe.Pointer(ClockMHz)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetDefaultApplicationsClock(cnvmlDevice, cClockType, cClockMHz) __v := (Return)(__ret) return __v } // nvmlDeviceGetClock function as declared in nvml/nvml.h -func nvmlDeviceGetClock(Device Device, ClockType ClockType, ClockId ClockId, ClockMHz *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetClock(nvmlDevice nvmlDevice, ClockType ClockType, ClockId ClockId, ClockMHz *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cClockType, _ := (C.nvmlClockType_t)(ClockType), cgoAllocsUnknown cClockId, _ := (C.nvmlClockId_t)(ClockId), cgoAllocsUnknown cClockMHz, _ := (*C.uint)(unsafe.Pointer(ClockMHz)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetClock(cDevice, cClockType, cClockId, cClockMHz) + __ret := C.nvmlDeviceGetClock(cnvmlDevice, cClockType, cClockId, cClockMHz) __v := (Return)(__ret) return __v } // nvmlDeviceGetMaxCustomerBoostClock function as declared in nvml/nvml.h -func nvmlDeviceGetMaxCustomerBoostClock(Device Device, ClockType ClockType, ClockMHz *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMaxCustomerBoostClock(nvmlDevice nvmlDevice, ClockType ClockType, ClockMHz *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cClockType, _ := (C.nvmlClockType_t)(ClockType), cgoAllocsUnknown cClockMHz, _ := (*C.uint)(unsafe.Pointer(ClockMHz)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMaxCustomerBoostClock(cDevice, cClockType, cClockMHz) + __ret := C.nvmlDeviceGetMaxCustomerBoostClock(cnvmlDevice, cClockType, cClockMHz) __v := (Return)(__ret) return __v } // nvmlDeviceGetSupportedMemoryClocks function as declared in nvml/nvml.h -func nvmlDeviceGetSupportedMemoryClocks(Device Device, Count *uint32, ClocksMHz *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetSupportedMemoryClocks(nvmlDevice nvmlDevice, Count *uint32, ClocksMHz *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown cClocksMHz, _ := (*C.uint)(unsafe.Pointer(ClocksMHz)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetSupportedMemoryClocks(cDevice, cCount, cClocksMHz) + __ret := C.nvmlDeviceGetSupportedMemoryClocks(cnvmlDevice, cCount, cClocksMHz) __v := (Return)(__ret) return __v } // nvmlDeviceGetSupportedGraphicsClocks function as declared in nvml/nvml.h -func nvmlDeviceGetSupportedGraphicsClocks(Device Device, MemoryClockMHz uint32, Count *uint32, ClocksMHz *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetSupportedGraphicsClocks(nvmlDevice nvmlDevice, MemoryClockMHz uint32, Count *uint32, ClocksMHz *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMemoryClockMHz, _ := (C.uint)(MemoryClockMHz), cgoAllocsUnknown cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown cClocksMHz, _ := (*C.uint)(unsafe.Pointer(ClocksMHz)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetSupportedGraphicsClocks(cDevice, cMemoryClockMHz, cCount, cClocksMHz) + __ret := C.nvmlDeviceGetSupportedGraphicsClocks(cnvmlDevice, cMemoryClockMHz, cCount, cClocksMHz) __v := (Return)(__ret) return __v } // nvmlDeviceGetAutoBoostedClocksEnabled function as declared in nvml/nvml.h -func nvmlDeviceGetAutoBoostedClocksEnabled(Device Device, IsEnabled *EnableState, DefaultIsEnabled *EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetAutoBoostedClocksEnabled(nvmlDevice nvmlDevice, IsEnabled *EnableState, DefaultIsEnabled *EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cIsEnabled, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(IsEnabled)), cgoAllocsUnknown cDefaultIsEnabled, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(DefaultIsEnabled)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetAutoBoostedClocksEnabled(cDevice, cIsEnabled, cDefaultIsEnabled) - __v := (Return)(__ret) - return __v -} - -// nvmlDeviceSetAutoBoostedClocksEnabled function as declared in nvml/nvml.h -func nvmlDeviceSetAutoBoostedClocksEnabled(Device Device, Enabled EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cEnabled, _ := (C.nvmlEnableState_t)(Enabled), cgoAllocsUnknown - __ret := C.nvmlDeviceSetAutoBoostedClocksEnabled(cDevice, cEnabled) - __v := (Return)(__ret) - return __v -} - -// nvmlDeviceSetDefaultAutoBoostedClocksEnabled function as declared in nvml/nvml.h -func nvmlDeviceSetDefaultAutoBoostedClocksEnabled(Device Device, Enabled EnableState, Flags uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cEnabled, _ := (C.nvmlEnableState_t)(Enabled), cgoAllocsUnknown - cFlags, _ := (C.uint)(Flags), cgoAllocsUnknown - __ret := C.nvmlDeviceSetDefaultAutoBoostedClocksEnabled(cDevice, cEnabled, cFlags) + __ret := C.nvmlDeviceGetAutoBoostedClocksEnabled(cnvmlDevice, cIsEnabled, cDefaultIsEnabled) __v := (Return)(__ret) return __v } // nvmlDeviceGetFanSpeed function as declared in nvml/nvml.h -func nvmlDeviceGetFanSpeed(Device Device, Speed *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetFanSpeed(nvmlDevice nvmlDevice, Speed *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cSpeed, _ := (*C.uint)(unsafe.Pointer(Speed)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetFanSpeed(cDevice, cSpeed) + __ret := C.nvmlDeviceGetFanSpeed(cnvmlDevice, cSpeed) __v := (Return)(__ret) return __v } // nvmlDeviceGetFanSpeed_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetFanSpeed_v2(Device Device, Fan uint32, Speed *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetFanSpeed_v2(nvmlDevice nvmlDevice, Fan uint32, Speed *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cFan, _ := (C.uint)(Fan), cgoAllocsUnknown cSpeed, _ := (*C.uint)(unsafe.Pointer(Speed)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetFanSpeed_v2(cDevice, cFan, cSpeed) + __ret := C.nvmlDeviceGetFanSpeed_v2(cnvmlDevice, cFan, cSpeed) __v := (Return)(__ret) return __v } // nvmlDeviceGetTargetFanSpeed function as declared in nvml/nvml.h -func nvmlDeviceGetTargetFanSpeed(Device Device, Fan uint32, TargetSpeed *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetTargetFanSpeed(nvmlDevice nvmlDevice, Fan uint32, TargetSpeed *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cFan, _ := (C.uint)(Fan), cgoAllocsUnknown cTargetSpeed, _ := (*C.uint)(unsafe.Pointer(TargetSpeed)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetTargetFanSpeed(cDevice, cFan, cTargetSpeed) - __v := (Return)(__ret) - return __v -} - -// nvmlDeviceSetDefaultFanSpeed_v2 function as declared in nvml/nvml.h -func nvmlDeviceSetDefaultFanSpeed_v2(Device Device, Fan uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cFan, _ := (C.uint)(Fan), cgoAllocsUnknown - __ret := C.nvmlDeviceSetDefaultFanSpeed_v2(cDevice, cFan) + __ret := C.nvmlDeviceGetTargetFanSpeed(cnvmlDevice, cFan, cTargetSpeed) __v := (Return)(__ret) return __v } // nvmlDeviceGetMinMaxFanSpeed function as declared in nvml/nvml.h -func nvmlDeviceGetMinMaxFanSpeed(Device Device, MinSpeed *uint32, MaxSpeed *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMinMaxFanSpeed(nvmlDevice nvmlDevice, MinSpeed *uint32, MaxSpeed *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMinSpeed, _ := (*C.uint)(unsafe.Pointer(MinSpeed)), cgoAllocsUnknown cMaxSpeed, _ := (*C.uint)(unsafe.Pointer(MaxSpeed)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMinMaxFanSpeed(cDevice, cMinSpeed, cMaxSpeed) + __ret := C.nvmlDeviceGetMinMaxFanSpeed(cnvmlDevice, cMinSpeed, cMaxSpeed) __v := (Return)(__ret) return __v } // nvmlDeviceGetFanControlPolicy_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetFanControlPolicy_v2(Device Device, Fan uint32, Policy *FanControlPolicy) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetFanControlPolicy_v2(nvmlDevice nvmlDevice, Fan uint32, Policy *FanControlPolicy) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cFan, _ := (C.uint)(Fan), cgoAllocsUnknown cPolicy, _ := (*C.nvmlFanControlPolicy_t)(unsafe.Pointer(Policy)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetFanControlPolicy_v2(cDevice, cFan, cPolicy) - __v := (Return)(__ret) - return __v -} - -// nvmlDeviceSetFanControlPolicy function as declared in nvml/nvml.h -func nvmlDeviceSetFanControlPolicy(Device Device, Fan uint32, Policy FanControlPolicy) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cFan, _ := (C.uint)(Fan), cgoAllocsUnknown - cPolicy, _ := (C.nvmlFanControlPolicy_t)(Policy), cgoAllocsUnknown - __ret := C.nvmlDeviceSetFanControlPolicy(cDevice, cFan, cPolicy) + __ret := C.nvmlDeviceGetFanControlPolicy_v2(cnvmlDevice, cFan, cPolicy) __v := (Return)(__ret) return __v } // nvmlDeviceGetNumFans function as declared in nvml/nvml.h -func nvmlDeviceGetNumFans(Device Device, NumFans *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetNumFans(nvmlDevice nvmlDevice, NumFans *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cNumFans, _ := (*C.uint)(unsafe.Pointer(NumFans)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetNumFans(cDevice, cNumFans) + __ret := C.nvmlDeviceGetNumFans(cnvmlDevice, cNumFans) __v := (Return)(__ret) return __v } // nvmlDeviceGetTemperature function as declared in nvml/nvml.h -func nvmlDeviceGetTemperature(Device Device, SensorType TemperatureSensors, Temp *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetTemperature(nvmlDevice nvmlDevice, SensorType TemperatureSensors, Temp *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cSensorType, _ := (C.nvmlTemperatureSensors_t)(SensorType), cgoAllocsUnknown cTemp, _ := (*C.uint)(unsafe.Pointer(Temp)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetTemperature(cDevice, cSensorType, cTemp) + __ret := C.nvmlDeviceGetTemperature(cnvmlDevice, cSensorType, cTemp) __v := (Return)(__ret) return __v } // nvmlDeviceGetTemperatureThreshold function as declared in nvml/nvml.h -func nvmlDeviceGetTemperatureThreshold(Device Device, ThresholdType TemperatureThresholds, Temp *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetTemperatureThreshold(nvmlDevice nvmlDevice, ThresholdType TemperatureThresholds, Temp *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cThresholdType, _ := (C.nvmlTemperatureThresholds_t)(ThresholdType), cgoAllocsUnknown cTemp, _ := (*C.uint)(unsafe.Pointer(Temp)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetTemperatureThreshold(cDevice, cThresholdType, cTemp) - __v := (Return)(__ret) - return __v -} - -// nvmlDeviceSetTemperatureThreshold function as declared in nvml/nvml.h -func nvmlDeviceSetTemperatureThreshold(Device Device, ThresholdType TemperatureThresholds, Temp *int32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cThresholdType, _ := (C.nvmlTemperatureThresholds_t)(ThresholdType), cgoAllocsUnknown - cTemp, _ := (*C.int)(unsafe.Pointer(Temp)), cgoAllocsUnknown - __ret := C.nvmlDeviceSetTemperatureThreshold(cDevice, cThresholdType, cTemp) + __ret := C.nvmlDeviceGetTemperatureThreshold(cnvmlDevice, cThresholdType, cTemp) __v := (Return)(__ret) return __v } // nvmlDeviceGetThermalSettings function as declared in nvml/nvml.h -func nvmlDeviceGetThermalSettings(Device Device, SensorIndex uint32, PThermalSettings *GpuThermalSettings) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetThermalSettings(nvmlDevice nvmlDevice, SensorIndex uint32, PThermalSettings *GpuThermalSettings) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cSensorIndex, _ := (C.uint)(SensorIndex), cgoAllocsUnknown cPThermalSettings, _ := (*C.nvmlGpuThermalSettings_t)(unsafe.Pointer(PThermalSettings)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetThermalSettings(cDevice, cSensorIndex, cPThermalSettings) + __ret := C.nvmlDeviceGetThermalSettings(cnvmlDevice, cSensorIndex, cPThermalSettings) __v := (Return)(__ret) return __v } // nvmlDeviceGetPerformanceState function as declared in nvml/nvml.h -func nvmlDeviceGetPerformanceState(Device Device, PState *Pstates) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPerformanceState(nvmlDevice nvmlDevice, PState *Pstates) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPState, _ := (*C.nvmlPstates_t)(unsafe.Pointer(PState)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPerformanceState(cDevice, cPState) + __ret := C.nvmlDeviceGetPerformanceState(cnvmlDevice, cPState) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetCurrentClocksEventReasons function as declared in nvml/nvml.h +func nvmlDeviceGetCurrentClocksEventReasons(nvmlDevice nvmlDevice, ClocksEventReasons *uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cClocksEventReasons, _ := (*C.ulonglong)(unsafe.Pointer(ClocksEventReasons)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetCurrentClocksEventReasons(cnvmlDevice, cClocksEventReasons) __v := (Return)(__ret) return __v } // nvmlDeviceGetCurrentClocksThrottleReasons function as declared in nvml/nvml.h -func nvmlDeviceGetCurrentClocksThrottleReasons(Device Device, ClocksThrottleReasons *uint64) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetCurrentClocksThrottleReasons(nvmlDevice nvmlDevice, ClocksThrottleReasons *uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cClocksThrottleReasons, _ := (*C.ulonglong)(unsafe.Pointer(ClocksThrottleReasons)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetCurrentClocksThrottleReasons(cDevice, cClocksThrottleReasons) + __ret := C.nvmlDeviceGetCurrentClocksThrottleReasons(cnvmlDevice, cClocksThrottleReasons) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetSupportedClocksEventReasons function as declared in nvml/nvml.h +func nvmlDeviceGetSupportedClocksEventReasons(nvmlDevice nvmlDevice, SupportedClocksEventReasons *uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cSupportedClocksEventReasons, _ := (*C.ulonglong)(unsafe.Pointer(SupportedClocksEventReasons)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetSupportedClocksEventReasons(cnvmlDevice, cSupportedClocksEventReasons) __v := (Return)(__ret) return __v } // nvmlDeviceGetSupportedClocksThrottleReasons function as declared in nvml/nvml.h -func nvmlDeviceGetSupportedClocksThrottleReasons(Device Device, SupportedClocksThrottleReasons *uint64) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetSupportedClocksThrottleReasons(nvmlDevice nvmlDevice, SupportedClocksThrottleReasons *uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cSupportedClocksThrottleReasons, _ := (*C.ulonglong)(unsafe.Pointer(SupportedClocksThrottleReasons)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetSupportedClocksThrottleReasons(cDevice, cSupportedClocksThrottleReasons) + __ret := C.nvmlDeviceGetSupportedClocksThrottleReasons(cnvmlDevice, cSupportedClocksThrottleReasons) __v := (Return)(__ret) return __v } // nvmlDeviceGetPowerState function as declared in nvml/nvml.h -func nvmlDeviceGetPowerState(Device Device, PState *Pstates) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPowerState(nvmlDevice nvmlDevice, PState *Pstates) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPState, _ := (*C.nvmlPstates_t)(unsafe.Pointer(PState)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPowerState(cDevice, cPState) + __ret := C.nvmlDeviceGetPowerState(cnvmlDevice, cPState) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetDynamicPstatesInfo function as declared in nvml/nvml.h +func nvmlDeviceGetDynamicPstatesInfo(nvmlDevice nvmlDevice, PDynamicPstatesInfo *GpuDynamicPstatesInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cPDynamicPstatesInfo, _ := (*C.nvmlGpuDynamicPstatesInfo_t)(unsafe.Pointer(PDynamicPstatesInfo)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetDynamicPstatesInfo(cnvmlDevice, cPDynamicPstatesInfo) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetMemClkVfOffset function as declared in nvml/nvml.h +func nvmlDeviceGetMemClkVfOffset(nvmlDevice nvmlDevice, Offset *int32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cOffset, _ := (*C.int)(unsafe.Pointer(Offset)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetMemClkVfOffset(cnvmlDevice, cOffset) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetMinMaxClockOfPState function as declared in nvml/nvml.h +func nvmlDeviceGetMinMaxClockOfPState(nvmlDevice nvmlDevice, _type ClockType, Pstate Pstates, MinClockMHz *uint32, MaxClockMHz *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + c_type, _ := (C.nvmlClockType_t)(_type), cgoAllocsUnknown + cPstate, _ := (C.nvmlPstates_t)(Pstate), cgoAllocsUnknown + cMinClockMHz, _ := (*C.uint)(unsafe.Pointer(MinClockMHz)), cgoAllocsUnknown + cMaxClockMHz, _ := (*C.uint)(unsafe.Pointer(MaxClockMHz)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetMinMaxClockOfPState(cnvmlDevice, c_type, cPstate, cMinClockMHz, cMaxClockMHz) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetSupportedPerformanceStates function as declared in nvml/nvml.h +func nvmlDeviceGetSupportedPerformanceStates(nvmlDevice nvmlDevice, Pstates *Pstates, Size uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cPstates, _ := (*C.nvmlPstates_t)(unsafe.Pointer(Pstates)), cgoAllocsUnknown + cSize, _ := (C.uint)(Size), cgoAllocsUnknown + __ret := C.nvmlDeviceGetSupportedPerformanceStates(cnvmlDevice, cPstates, cSize) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetGpcClkMinMaxVfOffset function as declared in nvml/nvml.h +func nvmlDeviceGetGpcClkMinMaxVfOffset(nvmlDevice nvmlDevice, MinOffset *int32, MaxOffset *int32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cMinOffset, _ := (*C.int)(unsafe.Pointer(MinOffset)), cgoAllocsUnknown + cMaxOffset, _ := (*C.int)(unsafe.Pointer(MaxOffset)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetGpcClkMinMaxVfOffset(cnvmlDevice, cMinOffset, cMaxOffset) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetMemClkMinMaxVfOffset function as declared in nvml/nvml.h +func nvmlDeviceGetMemClkMinMaxVfOffset(nvmlDevice nvmlDevice, MinOffset *int32, MaxOffset *int32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cMinOffset, _ := (*C.int)(unsafe.Pointer(MinOffset)), cgoAllocsUnknown + cMaxOffset, _ := (*C.int)(unsafe.Pointer(MaxOffset)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetMemClkMinMaxVfOffset(cnvmlDevice, cMinOffset, cMaxOffset) __v := (Return)(__ret) return __v } // nvmlDeviceGetPowerManagementMode function as declared in nvml/nvml.h -func nvmlDeviceGetPowerManagementMode(Device Device, Mode *EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPowerManagementMode(nvmlDevice nvmlDevice, Mode *EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMode, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(Mode)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPowerManagementMode(cDevice, cMode) + __ret := C.nvmlDeviceGetPowerManagementMode(cnvmlDevice, cMode) __v := (Return)(__ret) return __v } // nvmlDeviceGetPowerManagementLimit function as declared in nvml/nvml.h -func nvmlDeviceGetPowerManagementLimit(Device Device, Limit *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPowerManagementLimit(nvmlDevice nvmlDevice, Limit *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLimit, _ := (*C.uint)(unsafe.Pointer(Limit)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPowerManagementLimit(cDevice, cLimit) + __ret := C.nvmlDeviceGetPowerManagementLimit(cnvmlDevice, cLimit) __v := (Return)(__ret) return __v } // nvmlDeviceGetPowerManagementLimitConstraints function as declared in nvml/nvml.h -func nvmlDeviceGetPowerManagementLimitConstraints(Device Device, MinLimit *uint32, MaxLimit *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPowerManagementLimitConstraints(nvmlDevice nvmlDevice, MinLimit *uint32, MaxLimit *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMinLimit, _ := (*C.uint)(unsafe.Pointer(MinLimit)), cgoAllocsUnknown cMaxLimit, _ := (*C.uint)(unsafe.Pointer(MaxLimit)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPowerManagementLimitConstraints(cDevice, cMinLimit, cMaxLimit) + __ret := C.nvmlDeviceGetPowerManagementLimitConstraints(cnvmlDevice, cMinLimit, cMaxLimit) __v := (Return)(__ret) return __v } // nvmlDeviceGetPowerManagementDefaultLimit function as declared in nvml/nvml.h -func nvmlDeviceGetPowerManagementDefaultLimit(Device Device, DefaultLimit *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPowerManagementDefaultLimit(nvmlDevice nvmlDevice, DefaultLimit *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cDefaultLimit, _ := (*C.uint)(unsafe.Pointer(DefaultLimit)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPowerManagementDefaultLimit(cDevice, cDefaultLimit) + __ret := C.nvmlDeviceGetPowerManagementDefaultLimit(cnvmlDevice, cDefaultLimit) __v := (Return)(__ret) return __v } // nvmlDeviceGetPowerUsage function as declared in nvml/nvml.h -func nvmlDeviceGetPowerUsage(Device Device, Power *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPowerUsage(nvmlDevice nvmlDevice, Power *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPower, _ := (*C.uint)(unsafe.Pointer(Power)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPowerUsage(cDevice, cPower) + __ret := C.nvmlDeviceGetPowerUsage(cnvmlDevice, cPower) __v := (Return)(__ret) return __v } // nvmlDeviceGetTotalEnergyConsumption function as declared in nvml/nvml.h -func nvmlDeviceGetTotalEnergyConsumption(Device Device, Energy *uint64) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetTotalEnergyConsumption(nvmlDevice nvmlDevice, Energy *uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cEnergy, _ := (*C.ulonglong)(unsafe.Pointer(Energy)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetTotalEnergyConsumption(cDevice, cEnergy) + __ret := C.nvmlDeviceGetTotalEnergyConsumption(cnvmlDevice, cEnergy) __v := (Return)(__ret) return __v } // nvmlDeviceGetEnforcedPowerLimit function as declared in nvml/nvml.h -func nvmlDeviceGetEnforcedPowerLimit(Device Device, Limit *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetEnforcedPowerLimit(nvmlDevice nvmlDevice, Limit *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLimit, _ := (*C.uint)(unsafe.Pointer(Limit)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetEnforcedPowerLimit(cDevice, cLimit) + __ret := C.nvmlDeviceGetEnforcedPowerLimit(cnvmlDevice, cLimit) __v := (Return)(__ret) return __v } // nvmlDeviceGetGpuOperationMode function as declared in nvml/nvml.h -func nvmlDeviceGetGpuOperationMode(Device Device, Current *GpuOperationMode, Pending *GpuOperationMode) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGpuOperationMode(nvmlDevice nvmlDevice, Current *GpuOperationMode, Pending *GpuOperationMode) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCurrent, _ := (*C.nvmlGpuOperationMode_t)(unsafe.Pointer(Current)), cgoAllocsUnknown cPending, _ := (*C.nvmlGpuOperationMode_t)(unsafe.Pointer(Pending)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGpuOperationMode(cDevice, cCurrent, cPending) + __ret := C.nvmlDeviceGetGpuOperationMode(cnvmlDevice, cCurrent, cPending) __v := (Return)(__ret) return __v } // nvmlDeviceGetMemoryInfo function as declared in nvml/nvml.h -func nvmlDeviceGetMemoryInfo(Device Device, Memory *Memory) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMemoryInfo(nvmlDevice nvmlDevice, Memory *Memory) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMemory, _ := (*C.nvmlMemory_t)(unsafe.Pointer(Memory)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMemoryInfo(cDevice, cMemory) + __ret := C.nvmlDeviceGetMemoryInfo(cnvmlDevice, cMemory) __v := (Return)(__ret) return __v } // nvmlDeviceGetMemoryInfo_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetMemoryInfo_v2(Device Device, Memory *Memory_v2) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMemoryInfo_v2(nvmlDevice nvmlDevice, Memory *Memory_v2) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMemory, _ := (*C.nvmlMemory_v2_t)(unsafe.Pointer(Memory)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMemoryInfo_v2(cDevice, cMemory) + __ret := C.nvmlDeviceGetMemoryInfo_v2(cnvmlDevice, cMemory) __v := (Return)(__ret) return __v } // nvmlDeviceGetComputeMode function as declared in nvml/nvml.h -func nvmlDeviceGetComputeMode(Device Device, Mode *ComputeMode) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetComputeMode(nvmlDevice nvmlDevice, Mode *ComputeMode) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMode, _ := (*C.nvmlComputeMode_t)(unsafe.Pointer(Mode)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetComputeMode(cDevice, cMode) + __ret := C.nvmlDeviceGetComputeMode(cnvmlDevice, cMode) __v := (Return)(__ret) return __v } // nvmlDeviceGetCudaComputeCapability function as declared in nvml/nvml.h -func nvmlDeviceGetCudaComputeCapability(Device Device, Major *int32, Minor *int32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetCudaComputeCapability(nvmlDevice nvmlDevice, Major *int32, Minor *int32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMajor, _ := (*C.int)(unsafe.Pointer(Major)), cgoAllocsUnknown cMinor, _ := (*C.int)(unsafe.Pointer(Minor)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetCudaComputeCapability(cDevice, cMajor, cMinor) + __ret := C.nvmlDeviceGetCudaComputeCapability(cnvmlDevice, cMajor, cMinor) __v := (Return)(__ret) return __v } // nvmlDeviceGetEccMode function as declared in nvml/nvml.h -func nvmlDeviceGetEccMode(Device Device, Current *EnableState, Pending *EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetEccMode(nvmlDevice nvmlDevice, Current *EnableState, Pending *EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCurrent, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(Current)), cgoAllocsUnknown cPending, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(Pending)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetEccMode(cDevice, cCurrent, cPending) + __ret := C.nvmlDeviceGetEccMode(cnvmlDevice, cCurrent, cPending) __v := (Return)(__ret) return __v } // nvmlDeviceGetDefaultEccMode function as declared in nvml/nvml.h -func nvmlDeviceGetDefaultEccMode(Device Device, DefaultMode *EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetDefaultEccMode(nvmlDevice nvmlDevice, DefaultMode *EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cDefaultMode, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(DefaultMode)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetDefaultEccMode(cDevice, cDefaultMode) + __ret := C.nvmlDeviceGetDefaultEccMode(cnvmlDevice, cDefaultMode) __v := (Return)(__ret) return __v } // nvmlDeviceGetBoardId function as declared in nvml/nvml.h -func nvmlDeviceGetBoardId(Device Device, BoardId *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetBoardId(nvmlDevice nvmlDevice, BoardId *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cBoardId, _ := (*C.uint)(unsafe.Pointer(BoardId)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetBoardId(cDevice, cBoardId) + __ret := C.nvmlDeviceGetBoardId(cnvmlDevice, cBoardId) __v := (Return)(__ret) return __v } // nvmlDeviceGetMultiGpuBoard function as declared in nvml/nvml.h -func nvmlDeviceGetMultiGpuBoard(Device Device, MultiGpuBool *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMultiGpuBoard(nvmlDevice nvmlDevice, MultiGpuBool *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMultiGpuBool, _ := (*C.uint)(unsafe.Pointer(MultiGpuBool)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMultiGpuBoard(cDevice, cMultiGpuBool) + __ret := C.nvmlDeviceGetMultiGpuBoard(cnvmlDevice, cMultiGpuBool) __v := (Return)(__ret) return __v } // nvmlDeviceGetTotalEccErrors function as declared in nvml/nvml.h -func nvmlDeviceGetTotalEccErrors(Device Device, ErrorType MemoryErrorType, CounterType EccCounterType, EccCounts *uint64) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetTotalEccErrors(nvmlDevice nvmlDevice, ErrorType MemoryErrorType, CounterType EccCounterType, EccCounts *uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cErrorType, _ := (C.nvmlMemoryErrorType_t)(ErrorType), cgoAllocsUnknown cCounterType, _ := (C.nvmlEccCounterType_t)(CounterType), cgoAllocsUnknown cEccCounts, _ := (*C.ulonglong)(unsafe.Pointer(EccCounts)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetTotalEccErrors(cDevice, cErrorType, cCounterType, cEccCounts) + __ret := C.nvmlDeviceGetTotalEccErrors(cnvmlDevice, cErrorType, cCounterType, cEccCounts) __v := (Return)(__ret) return __v } // nvmlDeviceGetDetailedEccErrors function as declared in nvml/nvml.h -func nvmlDeviceGetDetailedEccErrors(Device Device, ErrorType MemoryErrorType, CounterType EccCounterType, EccCounts *EccErrorCounts) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetDetailedEccErrors(nvmlDevice nvmlDevice, ErrorType MemoryErrorType, CounterType EccCounterType, EccCounts *EccErrorCounts) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cErrorType, _ := (C.nvmlMemoryErrorType_t)(ErrorType), cgoAllocsUnknown cCounterType, _ := (C.nvmlEccCounterType_t)(CounterType), cgoAllocsUnknown cEccCounts, _ := (*C.nvmlEccErrorCounts_t)(unsafe.Pointer(EccCounts)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetDetailedEccErrors(cDevice, cErrorType, cCounterType, cEccCounts) + __ret := C.nvmlDeviceGetDetailedEccErrors(cnvmlDevice, cErrorType, cCounterType, cEccCounts) __v := (Return)(__ret) return __v } // nvmlDeviceGetMemoryErrorCounter function as declared in nvml/nvml.h -func nvmlDeviceGetMemoryErrorCounter(Device Device, ErrorType MemoryErrorType, CounterType EccCounterType, LocationType MemoryLocation, Count *uint64) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMemoryErrorCounter(nvmlDevice nvmlDevice, ErrorType MemoryErrorType, CounterType EccCounterType, LocationType MemoryLocation, Count *uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cErrorType, _ := (C.nvmlMemoryErrorType_t)(ErrorType), cgoAllocsUnknown cCounterType, _ := (C.nvmlEccCounterType_t)(CounterType), cgoAllocsUnknown cLocationType, _ := (C.nvmlMemoryLocation_t)(LocationType), cgoAllocsUnknown cCount, _ := (*C.ulonglong)(unsafe.Pointer(Count)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMemoryErrorCounter(cDevice, cErrorType, cCounterType, cLocationType, cCount) + __ret := C.nvmlDeviceGetMemoryErrorCounter(cnvmlDevice, cErrorType, cCounterType, cLocationType, cCount) __v := (Return)(__ret) return __v } // nvmlDeviceGetUtilizationRates function as declared in nvml/nvml.h -func nvmlDeviceGetUtilizationRates(Device Device, Utilization *Utilization) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetUtilizationRates(nvmlDevice nvmlDevice, Utilization *Utilization) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cUtilization, _ := (*C.nvmlUtilization_t)(unsafe.Pointer(Utilization)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetUtilizationRates(cDevice, cUtilization) + __ret := C.nvmlDeviceGetUtilizationRates(cnvmlDevice, cUtilization) __v := (Return)(__ret) return __v } // nvmlDeviceGetEncoderUtilization function as declared in nvml/nvml.h -func nvmlDeviceGetEncoderUtilization(Device Device, Utilization *uint32, SamplingPeriodUs *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetEncoderUtilization(nvmlDevice nvmlDevice, Utilization *uint32, SamplingPeriodUs *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cUtilization, _ := (*C.uint)(unsafe.Pointer(Utilization)), cgoAllocsUnknown cSamplingPeriodUs, _ := (*C.uint)(unsafe.Pointer(SamplingPeriodUs)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetEncoderUtilization(cDevice, cUtilization, cSamplingPeriodUs) + __ret := C.nvmlDeviceGetEncoderUtilization(cnvmlDevice, cUtilization, cSamplingPeriodUs) __v := (Return)(__ret) return __v } // nvmlDeviceGetEncoderCapacity function as declared in nvml/nvml.h -func nvmlDeviceGetEncoderCapacity(Device Device, EncoderQueryType EncoderType, EncoderCapacity *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetEncoderCapacity(nvmlDevice nvmlDevice, EncoderQueryType EncoderType, EncoderCapacity *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cEncoderQueryType, _ := (C.nvmlEncoderType_t)(EncoderQueryType), cgoAllocsUnknown cEncoderCapacity, _ := (*C.uint)(unsafe.Pointer(EncoderCapacity)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetEncoderCapacity(cDevice, cEncoderQueryType, cEncoderCapacity) + __ret := C.nvmlDeviceGetEncoderCapacity(cnvmlDevice, cEncoderQueryType, cEncoderCapacity) __v := (Return)(__ret) return __v } // nvmlDeviceGetEncoderStats function as declared in nvml/nvml.h -func nvmlDeviceGetEncoderStats(Device Device, SessionCount *uint32, AverageFps *uint32, AverageLatency *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetEncoderStats(nvmlDevice nvmlDevice, SessionCount *uint32, AverageFps *uint32, AverageLatency *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cSessionCount, _ := (*C.uint)(unsafe.Pointer(SessionCount)), cgoAllocsUnknown cAverageFps, _ := (*C.uint)(unsafe.Pointer(AverageFps)), cgoAllocsUnknown cAverageLatency, _ := (*C.uint)(unsafe.Pointer(AverageLatency)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetEncoderStats(cDevice, cSessionCount, cAverageFps, cAverageLatency) + __ret := C.nvmlDeviceGetEncoderStats(cnvmlDevice, cSessionCount, cAverageFps, cAverageLatency) __v := (Return)(__ret) return __v } // nvmlDeviceGetEncoderSessions function as declared in nvml/nvml.h -func nvmlDeviceGetEncoderSessions(Device Device, SessionCount *uint32, SessionInfos *EncoderSessionInfo) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetEncoderSessions(nvmlDevice nvmlDevice, SessionCount *uint32, SessionInfos *EncoderSessionInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cSessionCount, _ := (*C.uint)(unsafe.Pointer(SessionCount)), cgoAllocsUnknown cSessionInfos, _ := (*C.nvmlEncoderSessionInfo_t)(unsafe.Pointer(SessionInfos)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetEncoderSessions(cDevice, cSessionCount, cSessionInfos) + __ret := C.nvmlDeviceGetEncoderSessions(cnvmlDevice, cSessionCount, cSessionInfos) __v := (Return)(__ret) return __v } // nvmlDeviceGetDecoderUtilization function as declared in nvml/nvml.h -func nvmlDeviceGetDecoderUtilization(Device Device, Utilization *uint32, SamplingPeriodUs *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetDecoderUtilization(nvmlDevice nvmlDevice, Utilization *uint32, SamplingPeriodUs *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cUtilization, _ := (*C.uint)(unsafe.Pointer(Utilization)), cgoAllocsUnknown + cSamplingPeriodUs, _ := (*C.uint)(unsafe.Pointer(SamplingPeriodUs)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetDecoderUtilization(cnvmlDevice, cUtilization, cSamplingPeriodUs) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetJpgUtilization function as declared in nvml/nvml.h +func nvmlDeviceGetJpgUtilization(nvmlDevice nvmlDevice, Utilization *uint32, SamplingPeriodUs *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cUtilization, _ := (*C.uint)(unsafe.Pointer(Utilization)), cgoAllocsUnknown cSamplingPeriodUs, _ := (*C.uint)(unsafe.Pointer(SamplingPeriodUs)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetDecoderUtilization(cDevice, cUtilization, cSamplingPeriodUs) + __ret := C.nvmlDeviceGetJpgUtilization(cnvmlDevice, cUtilization, cSamplingPeriodUs) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetOfaUtilization function as declared in nvml/nvml.h +func nvmlDeviceGetOfaUtilization(nvmlDevice nvmlDevice, Utilization *uint32, SamplingPeriodUs *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cUtilization, _ := (*C.uint)(unsafe.Pointer(Utilization)), cgoAllocsUnknown + cSamplingPeriodUs, _ := (*C.uint)(unsafe.Pointer(SamplingPeriodUs)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetOfaUtilization(cnvmlDevice, cUtilization, cSamplingPeriodUs) __v := (Return)(__ret) return __v } // nvmlDeviceGetFBCStats function as declared in nvml/nvml.h -func nvmlDeviceGetFBCStats(Device Device, FbcStats *FBCStats) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetFBCStats(nvmlDevice nvmlDevice, FbcStats *FBCStats) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cFbcStats, _ := (*C.nvmlFBCStats_t)(unsafe.Pointer(FbcStats)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetFBCStats(cDevice, cFbcStats) + __ret := C.nvmlDeviceGetFBCStats(cnvmlDevice, cFbcStats) __v := (Return)(__ret) return __v } // nvmlDeviceGetFBCSessions function as declared in nvml/nvml.h -func nvmlDeviceGetFBCSessions(Device Device, SessionCount *uint32, SessionInfo *FBCSessionInfo) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetFBCSessions(nvmlDevice nvmlDevice, SessionCount *uint32, SessionInfo *FBCSessionInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cSessionCount, _ := (*C.uint)(unsafe.Pointer(SessionCount)), cgoAllocsUnknown cSessionInfo, _ := (*C.nvmlFBCSessionInfo_t)(unsafe.Pointer(SessionInfo)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetFBCSessions(cDevice, cSessionCount, cSessionInfo) + __ret := C.nvmlDeviceGetFBCSessions(cnvmlDevice, cSessionCount, cSessionInfo) __v := (Return)(__ret) return __v } // nvmlDeviceGetDriverModel function as declared in nvml/nvml.h -func nvmlDeviceGetDriverModel(Device Device, Current *DriverModel, Pending *DriverModel) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetDriverModel(nvmlDevice nvmlDevice, Current *DriverModel, Pending *DriverModel) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCurrent, _ := (*C.nvmlDriverModel_t)(unsafe.Pointer(Current)), cgoAllocsUnknown cPending, _ := (*C.nvmlDriverModel_t)(unsafe.Pointer(Pending)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetDriverModel(cDevice, cCurrent, cPending) + __ret := C.nvmlDeviceGetDriverModel(cnvmlDevice, cCurrent, cPending) __v := (Return)(__ret) return __v } // nvmlDeviceGetVbiosVersion function as declared in nvml/nvml.h -func nvmlDeviceGetVbiosVersion(Device Device, Version *byte, Length uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetVbiosVersion(nvmlDevice nvmlDevice, Version *byte, Length uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cVersion, _ := (*C.char)(unsafe.Pointer(Version)), cgoAllocsUnknown cLength, _ := (C.uint)(Length), cgoAllocsUnknown - __ret := C.nvmlDeviceGetVbiosVersion(cDevice, cVersion, cLength) + __ret := C.nvmlDeviceGetVbiosVersion(cnvmlDevice, cVersion, cLength) __v := (Return)(__ret) return __v } // nvmlDeviceGetBridgeChipInfo function as declared in nvml/nvml.h -func nvmlDeviceGetBridgeChipInfo(Device Device, BridgeHierarchy *BridgeChipHierarchy) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetBridgeChipInfo(nvmlDevice nvmlDevice, BridgeHierarchy *BridgeChipHierarchy) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cBridgeHierarchy, _ := (*C.nvmlBridgeChipHierarchy_t)(unsafe.Pointer(BridgeHierarchy)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetBridgeChipInfo(cDevice, cBridgeHierarchy) + __ret := C.nvmlDeviceGetBridgeChipInfo(cnvmlDevice, cBridgeHierarchy) __v := (Return)(__ret) return __v } // nvmlDeviceGetComputeRunningProcesses_v3 function as declared in nvml/nvml.h -func nvmlDeviceGetComputeRunningProcesses_v3(Device Device, InfoCount *uint32, Infos *ProcessInfo) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetComputeRunningProcesses_v3(nvmlDevice nvmlDevice, InfoCount *uint32, Infos *ProcessInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cInfoCount, _ := (*C.uint)(unsafe.Pointer(InfoCount)), cgoAllocsUnknown cInfos, _ := (*C.nvmlProcessInfo_t)(unsafe.Pointer(Infos)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetComputeRunningProcesses_v3(cDevice, cInfoCount, cInfos) + __ret := C.nvmlDeviceGetComputeRunningProcesses_v3(cnvmlDevice, cInfoCount, cInfos) __v := (Return)(__ret) return __v } // nvmlDeviceGetGraphicsRunningProcesses_v3 function as declared in nvml/nvml.h -func nvmlDeviceGetGraphicsRunningProcesses_v3(Device Device, InfoCount *uint32, Infos *ProcessInfo) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGraphicsRunningProcesses_v3(nvmlDevice nvmlDevice, InfoCount *uint32, Infos *ProcessInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cInfoCount, _ := (*C.uint)(unsafe.Pointer(InfoCount)), cgoAllocsUnknown cInfos, _ := (*C.nvmlProcessInfo_t)(unsafe.Pointer(Infos)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGraphicsRunningProcesses_v3(cDevice, cInfoCount, cInfos) + __ret := C.nvmlDeviceGetGraphicsRunningProcesses_v3(cnvmlDevice, cInfoCount, cInfos) __v := (Return)(__ret) return __v } // nvmlDeviceGetMPSComputeRunningProcesses_v3 function as declared in nvml/nvml.h -func nvmlDeviceGetMPSComputeRunningProcesses_v3(Device Device, InfoCount *uint32, Infos *ProcessInfo) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMPSComputeRunningProcesses_v3(nvmlDevice nvmlDevice, InfoCount *uint32, Infos *ProcessInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cInfoCount, _ := (*C.uint)(unsafe.Pointer(InfoCount)), cgoAllocsUnknown cInfos, _ := (*C.nvmlProcessInfo_t)(unsafe.Pointer(Infos)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMPSComputeRunningProcesses_v3(cDevice, cInfoCount, cInfos) + __ret := C.nvmlDeviceGetMPSComputeRunningProcesses_v3(cnvmlDevice, cInfoCount, cInfos) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetRunningProcessDetailList function as declared in nvml/nvml.h +func nvmlDeviceGetRunningProcessDetailList(nvmlDevice nvmlDevice, Plist *ProcessDetailList) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cPlist, _ := (*C.nvmlProcessDetailList_t)(unsafe.Pointer(Plist)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetRunningProcessDetailList(cnvmlDevice, cPlist) __v := (Return)(__ret) return __v } // nvmlDeviceOnSameBoard function as declared in nvml/nvml.h -func nvmlDeviceOnSameBoard(Device1 Device, Device2 Device, OnSameBoard *int32) Return { +func nvmlDeviceOnSameBoard(Device1 nvmlDevice, Device2 nvmlDevice, OnSameBoard *int32) Return { cDevice1, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device1)), cgoAllocsUnknown cDevice2, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device2)), cgoAllocsUnknown cOnSameBoard, _ := (*C.int)(unsafe.Pointer(OnSameBoard)), cgoAllocsUnknown @@ -1145,494 +1241,745 @@ func nvmlDeviceOnSameBoard(Device1 Device, Device2 Device, OnSameBoard *int32) R } // nvmlDeviceGetAPIRestriction function as declared in nvml/nvml.h -func nvmlDeviceGetAPIRestriction(Device Device, ApiType RestrictedAPI, IsRestricted *EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetAPIRestriction(nvmlDevice nvmlDevice, ApiType RestrictedAPI, IsRestricted *EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cApiType, _ := (C.nvmlRestrictedAPI_t)(ApiType), cgoAllocsUnknown cIsRestricted, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(IsRestricted)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetAPIRestriction(cDevice, cApiType, cIsRestricted) + __ret := C.nvmlDeviceGetAPIRestriction(cnvmlDevice, cApiType, cIsRestricted) __v := (Return)(__ret) return __v } // nvmlDeviceGetSamples function as declared in nvml/nvml.h -func nvmlDeviceGetSamples(Device Device, _type SamplingType, LastSeenTimeStamp uint64, SampleValType *ValueType, SampleCount *uint32, Samples *Sample) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetSamples(nvmlDevice nvmlDevice, _type SamplingType, LastSeenTimeStamp uint64, SampleValType *ValueType, SampleCount *uint32, Samples *Sample) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown c_type, _ := (C.nvmlSamplingType_t)(_type), cgoAllocsUnknown cLastSeenTimeStamp, _ := (C.ulonglong)(LastSeenTimeStamp), cgoAllocsUnknown cSampleValType, _ := (*C.nvmlValueType_t)(unsafe.Pointer(SampleValType)), cgoAllocsUnknown cSampleCount, _ := (*C.uint)(unsafe.Pointer(SampleCount)), cgoAllocsUnknown cSamples, _ := (*C.nvmlSample_t)(unsafe.Pointer(Samples)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetSamples(cDevice, c_type, cLastSeenTimeStamp, cSampleValType, cSampleCount, cSamples) + __ret := C.nvmlDeviceGetSamples(cnvmlDevice, c_type, cLastSeenTimeStamp, cSampleValType, cSampleCount, cSamples) __v := (Return)(__ret) return __v } // nvmlDeviceGetBAR1MemoryInfo function as declared in nvml/nvml.h -func nvmlDeviceGetBAR1MemoryInfo(Device Device, Bar1Memory *BAR1Memory) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetBAR1MemoryInfo(nvmlDevice nvmlDevice, Bar1Memory *BAR1Memory) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cBar1Memory, _ := (*C.nvmlBAR1Memory_t)(unsafe.Pointer(Bar1Memory)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetBAR1MemoryInfo(cDevice, cBar1Memory) + __ret := C.nvmlDeviceGetBAR1MemoryInfo(cnvmlDevice, cBar1Memory) __v := (Return)(__ret) return __v } // nvmlDeviceGetViolationStatus function as declared in nvml/nvml.h -func nvmlDeviceGetViolationStatus(Device Device, PerfPolicyType PerfPolicyType, ViolTime *ViolationTime) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetViolationStatus(nvmlDevice nvmlDevice, PerfPolicyType PerfPolicyType, ViolTime *ViolationTime) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPerfPolicyType, _ := (C.nvmlPerfPolicyType_t)(PerfPolicyType), cgoAllocsUnknown cViolTime, _ := (*C.nvmlViolationTime_t)(unsafe.Pointer(ViolTime)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetViolationStatus(cDevice, cPerfPolicyType, cViolTime) + __ret := C.nvmlDeviceGetViolationStatus(cnvmlDevice, cPerfPolicyType, cViolTime) __v := (Return)(__ret) return __v } // nvmlDeviceGetIrqNum function as declared in nvml/nvml.h -func nvmlDeviceGetIrqNum(Device Device, IrqNum *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetIrqNum(nvmlDevice nvmlDevice, IrqNum *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cIrqNum, _ := (*C.uint)(unsafe.Pointer(IrqNum)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetIrqNum(cDevice, cIrqNum) + __ret := C.nvmlDeviceGetIrqNum(cnvmlDevice, cIrqNum) __v := (Return)(__ret) return __v } // nvmlDeviceGetNumGpuCores function as declared in nvml/nvml.h -func nvmlDeviceGetNumGpuCores(Device Device, NumCores *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetNumGpuCores(nvmlDevice nvmlDevice, NumCores *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cNumCores, _ := (*C.uint)(unsafe.Pointer(NumCores)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetNumGpuCores(cDevice, cNumCores) + __ret := C.nvmlDeviceGetNumGpuCores(cnvmlDevice, cNumCores) __v := (Return)(__ret) return __v } // nvmlDeviceGetPowerSource function as declared in nvml/nvml.h -func nvmlDeviceGetPowerSource(Device Device, PowerSource *PowerSource) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPowerSource(nvmlDevice nvmlDevice, PowerSource *PowerSource) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPowerSource, _ := (*C.nvmlPowerSource_t)(unsafe.Pointer(PowerSource)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPowerSource(cDevice, cPowerSource) + __ret := C.nvmlDeviceGetPowerSource(cnvmlDevice, cPowerSource) __v := (Return)(__ret) return __v } // nvmlDeviceGetMemoryBusWidth function as declared in nvml/nvml.h -func nvmlDeviceGetMemoryBusWidth(Device Device, BusWidth *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMemoryBusWidth(nvmlDevice nvmlDevice, BusWidth *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cBusWidth, _ := (*C.uint)(unsafe.Pointer(BusWidth)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMemoryBusWidth(cDevice, cBusWidth) + __ret := C.nvmlDeviceGetMemoryBusWidth(cnvmlDevice, cBusWidth) __v := (Return)(__ret) return __v } // nvmlDeviceGetPcieLinkMaxSpeed function as declared in nvml/nvml.h -func nvmlDeviceGetPcieLinkMaxSpeed(Device Device, MaxSpeed *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPcieLinkMaxSpeed(nvmlDevice nvmlDevice, MaxSpeed *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMaxSpeed, _ := (*C.uint)(unsafe.Pointer(MaxSpeed)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPcieLinkMaxSpeed(cDevice, cMaxSpeed) + __ret := C.nvmlDeviceGetPcieLinkMaxSpeed(cnvmlDevice, cMaxSpeed) __v := (Return)(__ret) return __v } // nvmlDeviceGetPcieSpeed function as declared in nvml/nvml.h -func nvmlDeviceGetPcieSpeed(Device Device, PcieSpeed *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPcieSpeed(nvmlDevice nvmlDevice, PcieSpeed *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPcieSpeed, _ := (*C.uint)(unsafe.Pointer(PcieSpeed)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPcieSpeed(cDevice, cPcieSpeed) + __ret := C.nvmlDeviceGetPcieSpeed(cnvmlDevice, cPcieSpeed) __v := (Return)(__ret) return __v } // nvmlDeviceGetAdaptiveClockInfoStatus function as declared in nvml/nvml.h -func nvmlDeviceGetAdaptiveClockInfoStatus(Device Device, AdaptiveClockStatus *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetAdaptiveClockInfoStatus(nvmlDevice nvmlDevice, AdaptiveClockStatus *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cAdaptiveClockStatus, _ := (*C.uint)(unsafe.Pointer(AdaptiveClockStatus)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetAdaptiveClockInfoStatus(cDevice, cAdaptiveClockStatus) + __ret := C.nvmlDeviceGetAdaptiveClockInfoStatus(cnvmlDevice, cAdaptiveClockStatus) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetBusType function as declared in nvml/nvml.h +func nvmlDeviceGetBusType(nvmlDevice nvmlDevice, _type *BusType) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + c_type, _ := (*C.nvmlBusType_t)(unsafe.Pointer(_type)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetBusType(cnvmlDevice, c_type) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetGpuFabricInfo function as declared in nvml/nvml.h +func nvmlDeviceGetGpuFabricInfo(nvmlDevice nvmlDevice, GpuFabricInfo *GpuFabricInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cGpuFabricInfo, _ := (*C.nvmlGpuFabricInfo_t)(unsafe.Pointer(GpuFabricInfo)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetGpuFabricInfo(cnvmlDevice, cGpuFabricInfo) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetGpuFabricInfoV function as declared in nvml/nvml.h +func nvmlDeviceGetGpuFabricInfoV(nvmlDevice nvmlDevice, GpuFabricInfo *GpuFabricInfoV) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cGpuFabricInfo, _ := (*C.nvmlGpuFabricInfoV_t)(unsafe.Pointer(GpuFabricInfo)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetGpuFabricInfoV(cnvmlDevice, cGpuFabricInfo) + __v := (Return)(__ret) + return __v +} + +// nvmlSystemGetConfComputeCapabilities function as declared in nvml/nvml.h +func nvmlSystemGetConfComputeCapabilities(Capabilities *ConfComputeSystemCaps) Return { + cCapabilities, _ := (*C.nvmlConfComputeSystemCaps_t)(unsafe.Pointer(Capabilities)), cgoAllocsUnknown + __ret := C.nvmlSystemGetConfComputeCapabilities(cCapabilities) + __v := (Return)(__ret) + return __v +} + +// nvmlSystemGetConfComputeState function as declared in nvml/nvml.h +func nvmlSystemGetConfComputeState(State *ConfComputeSystemState) Return { + cState, _ := (*C.nvmlConfComputeSystemState_t)(unsafe.Pointer(State)), cgoAllocsUnknown + __ret := C.nvmlSystemGetConfComputeState(cState) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetConfComputeMemSizeInfo function as declared in nvml/nvml.h +func nvmlDeviceGetConfComputeMemSizeInfo(nvmlDevice nvmlDevice, MemInfo *ConfComputeMemSizeInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cMemInfo, _ := (*C.nvmlConfComputeMemSizeInfo_t)(unsafe.Pointer(MemInfo)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetConfComputeMemSizeInfo(cnvmlDevice, cMemInfo) + __v := (Return)(__ret) + return __v +} + +// nvmlSystemGetConfComputeGpusReadyState function as declared in nvml/nvml.h +func nvmlSystemGetConfComputeGpusReadyState(IsAcceptingWork *uint32) Return { + cIsAcceptingWork, _ := (*C.uint)(unsafe.Pointer(IsAcceptingWork)), cgoAllocsUnknown + __ret := C.nvmlSystemGetConfComputeGpusReadyState(cIsAcceptingWork) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetConfComputeProtectedMemoryUsage function as declared in nvml/nvml.h +func nvmlDeviceGetConfComputeProtectedMemoryUsage(nvmlDevice nvmlDevice, Memory *Memory) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cMemory, _ := (*C.nvmlMemory_t)(unsafe.Pointer(Memory)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetConfComputeProtectedMemoryUsage(cnvmlDevice, cMemory) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetConfComputeGpuCertificate function as declared in nvml/nvml.h +func nvmlDeviceGetConfComputeGpuCertificate(nvmlDevice nvmlDevice, GpuCert *ConfComputeGpuCertificate) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cGpuCert, _ := (*C.nvmlConfComputeGpuCertificate_t)(unsafe.Pointer(GpuCert)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetConfComputeGpuCertificate(cnvmlDevice, cGpuCert) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetConfComputeGpuAttestationReport function as declared in nvml/nvml.h +func nvmlDeviceGetConfComputeGpuAttestationReport(nvmlDevice nvmlDevice, GpuAtstReport *ConfComputeGpuAttestationReport) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cGpuAtstReport, _ := (*C.nvmlConfComputeGpuAttestationReport_t)(unsafe.Pointer(GpuAtstReport)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetConfComputeGpuAttestationReport(cnvmlDevice, cGpuAtstReport) + __v := (Return)(__ret) + return __v +} + +// nvmlSystemGetConfComputeKeyRotationThresholdInfo function as declared in nvml/nvml.h +func nvmlSystemGetConfComputeKeyRotationThresholdInfo(PKeyRotationThrInfo *ConfComputeGetKeyRotationThresholdInfo) Return { + cPKeyRotationThrInfo, _ := (*C.nvmlConfComputeGetKeyRotationThresholdInfo_t)(unsafe.Pointer(PKeyRotationThrInfo)), cgoAllocsUnknown + __ret := C.nvmlSystemGetConfComputeKeyRotationThresholdInfo(cPKeyRotationThrInfo) + __v := (Return)(__ret) + return __v +} + +// nvmlSystemGetConfComputeSettings function as declared in nvml/nvml.h +func nvmlSystemGetConfComputeSettings(Settings *SystemConfComputeSettings) Return { + cSettings, _ := (*C.nvmlSystemConfComputeSettings_t)(unsafe.Pointer(Settings)), cgoAllocsUnknown + __ret := C.nvmlSystemGetConfComputeSettings(cSettings) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetGspFirmwareVersion function as declared in nvml/nvml.h +func nvmlDeviceGetGspFirmwareVersion(nvmlDevice nvmlDevice, Version *byte) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cVersion, _ := (*C.char)(unsafe.Pointer(Version)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetGspFirmwareVersion(cnvmlDevice, cVersion) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetGspFirmwareMode function as declared in nvml/nvml.h +func nvmlDeviceGetGspFirmwareMode(nvmlDevice nvmlDevice, IsEnabled *uint32, DefaultMode *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cIsEnabled, _ := (*C.uint)(unsafe.Pointer(IsEnabled)), cgoAllocsUnknown + cDefaultMode, _ := (*C.uint)(unsafe.Pointer(DefaultMode)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetGspFirmwareMode(cnvmlDevice, cIsEnabled, cDefaultMode) __v := (Return)(__ret) return __v } // nvmlDeviceGetAccountingMode function as declared in nvml/nvml.h -func nvmlDeviceGetAccountingMode(Device Device, Mode *EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetAccountingMode(nvmlDevice nvmlDevice, Mode *EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMode, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(Mode)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetAccountingMode(cDevice, cMode) + __ret := C.nvmlDeviceGetAccountingMode(cnvmlDevice, cMode) __v := (Return)(__ret) return __v } // nvmlDeviceGetAccountingStats function as declared in nvml/nvml.h -func nvmlDeviceGetAccountingStats(Device Device, Pid uint32, Stats *AccountingStats) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetAccountingStats(nvmlDevice nvmlDevice, Pid uint32, Stats *AccountingStats) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPid, _ := (C.uint)(Pid), cgoAllocsUnknown cStats, _ := (*C.nvmlAccountingStats_t)(unsafe.Pointer(Stats)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetAccountingStats(cDevice, cPid, cStats) + __ret := C.nvmlDeviceGetAccountingStats(cnvmlDevice, cPid, cStats) __v := (Return)(__ret) return __v } // nvmlDeviceGetAccountingPids function as declared in nvml/nvml.h -func nvmlDeviceGetAccountingPids(Device Device, Count *uint32, Pids *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetAccountingPids(nvmlDevice nvmlDevice, Count *uint32, Pids *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown cPids, _ := (*C.uint)(unsafe.Pointer(Pids)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetAccountingPids(cDevice, cCount, cPids) + __ret := C.nvmlDeviceGetAccountingPids(cnvmlDevice, cCount, cPids) __v := (Return)(__ret) return __v } // nvmlDeviceGetAccountingBufferSize function as declared in nvml/nvml.h -func nvmlDeviceGetAccountingBufferSize(Device Device, BufferSize *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetAccountingBufferSize(nvmlDevice nvmlDevice, BufferSize *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cBufferSize, _ := (*C.uint)(unsafe.Pointer(BufferSize)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetAccountingBufferSize(cDevice, cBufferSize) + __ret := C.nvmlDeviceGetAccountingBufferSize(cnvmlDevice, cBufferSize) __v := (Return)(__ret) return __v } // nvmlDeviceGetRetiredPages function as declared in nvml/nvml.h -func nvmlDeviceGetRetiredPages(Device Device, Cause PageRetirementCause, PageCount *uint32, Addresses *uint64) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetRetiredPages(nvmlDevice nvmlDevice, Cause PageRetirementCause, PageCount *uint32, Addresses *uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCause, _ := (C.nvmlPageRetirementCause_t)(Cause), cgoAllocsUnknown cPageCount, _ := (*C.uint)(unsafe.Pointer(PageCount)), cgoAllocsUnknown cAddresses, _ := (*C.ulonglong)(unsafe.Pointer(Addresses)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetRetiredPages(cDevice, cCause, cPageCount, cAddresses) + __ret := C.nvmlDeviceGetRetiredPages(cnvmlDevice, cCause, cPageCount, cAddresses) __v := (Return)(__ret) return __v } // nvmlDeviceGetRetiredPages_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetRetiredPages_v2(Device Device, Cause PageRetirementCause, PageCount *uint32, Addresses *uint64, Timestamps *uint64) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetRetiredPages_v2(nvmlDevice nvmlDevice, Cause PageRetirementCause, PageCount *uint32, Addresses *uint64, Timestamps *uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCause, _ := (C.nvmlPageRetirementCause_t)(Cause), cgoAllocsUnknown cPageCount, _ := (*C.uint)(unsafe.Pointer(PageCount)), cgoAllocsUnknown cAddresses, _ := (*C.ulonglong)(unsafe.Pointer(Addresses)), cgoAllocsUnknown cTimestamps, _ := (*C.ulonglong)(unsafe.Pointer(Timestamps)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetRetiredPages_v2(cDevice, cCause, cPageCount, cAddresses, cTimestamps) + __ret := C.nvmlDeviceGetRetiredPages_v2(cnvmlDevice, cCause, cPageCount, cAddresses, cTimestamps) __v := (Return)(__ret) return __v } // nvmlDeviceGetRetiredPagesPendingStatus function as declared in nvml/nvml.h -func nvmlDeviceGetRetiredPagesPendingStatus(Device Device, IsPending *EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetRetiredPagesPendingStatus(nvmlDevice nvmlDevice, IsPending *EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cIsPending, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(IsPending)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetRetiredPagesPendingStatus(cDevice, cIsPending) + __ret := C.nvmlDeviceGetRetiredPagesPendingStatus(cnvmlDevice, cIsPending) __v := (Return)(__ret) return __v } // nvmlDeviceGetRemappedRows function as declared in nvml/nvml.h -func nvmlDeviceGetRemappedRows(Device Device, CorrRows *uint32, UncRows *uint32, IsPending *uint32, FailureOccurred *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetRemappedRows(nvmlDevice nvmlDevice, CorrRows *uint32, UncRows *uint32, IsPending *uint32, FailureOccurred *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCorrRows, _ := (*C.uint)(unsafe.Pointer(CorrRows)), cgoAllocsUnknown cUncRows, _ := (*C.uint)(unsafe.Pointer(UncRows)), cgoAllocsUnknown cIsPending, _ := (*C.uint)(unsafe.Pointer(IsPending)), cgoAllocsUnknown cFailureOccurred, _ := (*C.uint)(unsafe.Pointer(FailureOccurred)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetRemappedRows(cDevice, cCorrRows, cUncRows, cIsPending, cFailureOccurred) + __ret := C.nvmlDeviceGetRemappedRows(cnvmlDevice, cCorrRows, cUncRows, cIsPending, cFailureOccurred) __v := (Return)(__ret) return __v } // nvmlDeviceGetRowRemapperHistogram function as declared in nvml/nvml.h -func nvmlDeviceGetRowRemapperHistogram(Device Device, Values *RowRemapperHistogramValues) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetRowRemapperHistogram(nvmlDevice nvmlDevice, Values *RowRemapperHistogramValues) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cValues, _ := (*C.nvmlRowRemapperHistogramValues_t)(unsafe.Pointer(Values)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetRowRemapperHistogram(cDevice, cValues) + __ret := C.nvmlDeviceGetRowRemapperHistogram(cnvmlDevice, cValues) __v := (Return)(__ret) return __v } // nvmlDeviceGetArchitecture function as declared in nvml/nvml.h -func nvmlDeviceGetArchitecture(Device Device, Arch *DeviceArchitecture) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetArchitecture(nvmlDevice nvmlDevice, Arch *DeviceArchitecture) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cArch, _ := (*C.nvmlDeviceArchitecture_t)(unsafe.Pointer(Arch)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetArchitecture(cDevice, cArch) + __ret := C.nvmlDeviceGetArchitecture(cnvmlDevice, cArch) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetClkMonStatus function as declared in nvml/nvml.h +func nvmlDeviceGetClkMonStatus(nvmlDevice nvmlDevice, Status *ClkMonStatus) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cStatus, _ := (*C.nvmlClkMonStatus_t)(unsafe.Pointer(Status)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetClkMonStatus(cnvmlDevice, cStatus) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetProcessUtilization function as declared in nvml/nvml.h +func nvmlDeviceGetProcessUtilization(nvmlDevice nvmlDevice, Utilization *ProcessUtilizationSample, ProcessSamplesCount *uint32, LastSeenTimeStamp uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cUtilization, _ := (*C.nvmlProcessUtilizationSample_t)(unsafe.Pointer(Utilization)), cgoAllocsUnknown + cProcessSamplesCount, _ := (*C.uint)(unsafe.Pointer(ProcessSamplesCount)), cgoAllocsUnknown + cLastSeenTimeStamp, _ := (C.ulonglong)(LastSeenTimeStamp), cgoAllocsUnknown + __ret := C.nvmlDeviceGetProcessUtilization(cnvmlDevice, cUtilization, cProcessSamplesCount, cLastSeenTimeStamp) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetProcessesUtilizationInfo function as declared in nvml/nvml.h +func nvmlDeviceGetProcessesUtilizationInfo(nvmlDevice nvmlDevice, ProcesesUtilInfo *ProcessesUtilizationInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cProcesesUtilInfo, _ := (*C.nvmlProcessesUtilizationInfo_t)(unsafe.Pointer(ProcesesUtilInfo)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetProcessesUtilizationInfo(cnvmlDevice, cProcesesUtilInfo) __v := (Return)(__ret) return __v } // nvmlUnitSetLedState function as declared in nvml/nvml.h -func nvmlUnitSetLedState(Unit Unit, Color LedColor) Return { - cUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&Unit)), cgoAllocsUnknown +func nvmlUnitSetLedState(nvmlUnit nvmlUnit, Color LedColor) Return { + cnvmlUnit, _ := *(*C.nvmlUnit_t)(unsafe.Pointer(&nvmlUnit)), cgoAllocsUnknown cColor, _ := (C.nvmlLedColor_t)(Color), cgoAllocsUnknown - __ret := C.nvmlUnitSetLedState(cUnit, cColor) + __ret := C.nvmlUnitSetLedState(cnvmlUnit, cColor) __v := (Return)(__ret) return __v } // nvmlDeviceSetPersistenceMode function as declared in nvml/nvml.h -func nvmlDeviceSetPersistenceMode(Device Device, Mode EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetPersistenceMode(nvmlDevice nvmlDevice, Mode EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMode, _ := (C.nvmlEnableState_t)(Mode), cgoAllocsUnknown - __ret := C.nvmlDeviceSetPersistenceMode(cDevice, cMode) + __ret := C.nvmlDeviceSetPersistenceMode(cnvmlDevice, cMode) __v := (Return)(__ret) return __v } // nvmlDeviceSetComputeMode function as declared in nvml/nvml.h -func nvmlDeviceSetComputeMode(Device Device, Mode ComputeMode) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetComputeMode(nvmlDevice nvmlDevice, Mode ComputeMode) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMode, _ := (C.nvmlComputeMode_t)(Mode), cgoAllocsUnknown - __ret := C.nvmlDeviceSetComputeMode(cDevice, cMode) + __ret := C.nvmlDeviceSetComputeMode(cnvmlDevice, cMode) __v := (Return)(__ret) return __v } // nvmlDeviceSetEccMode function as declared in nvml/nvml.h -func nvmlDeviceSetEccMode(Device Device, Ecc EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetEccMode(nvmlDevice nvmlDevice, Ecc EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cEcc, _ := (C.nvmlEnableState_t)(Ecc), cgoAllocsUnknown - __ret := C.nvmlDeviceSetEccMode(cDevice, cEcc) + __ret := C.nvmlDeviceSetEccMode(cnvmlDevice, cEcc) __v := (Return)(__ret) return __v } // nvmlDeviceClearEccErrorCounts function as declared in nvml/nvml.h -func nvmlDeviceClearEccErrorCounts(Device Device, CounterType EccCounterType) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceClearEccErrorCounts(nvmlDevice nvmlDevice, CounterType EccCounterType) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCounterType, _ := (C.nvmlEccCounterType_t)(CounterType), cgoAllocsUnknown - __ret := C.nvmlDeviceClearEccErrorCounts(cDevice, cCounterType) + __ret := C.nvmlDeviceClearEccErrorCounts(cnvmlDevice, cCounterType) __v := (Return)(__ret) return __v } // nvmlDeviceSetDriverModel function as declared in nvml/nvml.h -func nvmlDeviceSetDriverModel(Device Device, DriverModel DriverModel, Flags uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetDriverModel(nvmlDevice nvmlDevice, DriverModel DriverModel, Flags uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cDriverModel, _ := (C.nvmlDriverModel_t)(DriverModel), cgoAllocsUnknown cFlags, _ := (C.uint)(Flags), cgoAllocsUnknown - __ret := C.nvmlDeviceSetDriverModel(cDevice, cDriverModel, cFlags) + __ret := C.nvmlDeviceSetDriverModel(cnvmlDevice, cDriverModel, cFlags) __v := (Return)(__ret) return __v } // nvmlDeviceSetGpuLockedClocks function as declared in nvml/nvml.h -func nvmlDeviceSetGpuLockedClocks(Device Device, MinGpuClockMHz uint32, MaxGpuClockMHz uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetGpuLockedClocks(nvmlDevice nvmlDevice, MinGpuClockMHz uint32, MaxGpuClockMHz uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMinGpuClockMHz, _ := (C.uint)(MinGpuClockMHz), cgoAllocsUnknown cMaxGpuClockMHz, _ := (C.uint)(MaxGpuClockMHz), cgoAllocsUnknown - __ret := C.nvmlDeviceSetGpuLockedClocks(cDevice, cMinGpuClockMHz, cMaxGpuClockMHz) + __ret := C.nvmlDeviceSetGpuLockedClocks(cnvmlDevice, cMinGpuClockMHz, cMaxGpuClockMHz) __v := (Return)(__ret) return __v } // nvmlDeviceResetGpuLockedClocks function as declared in nvml/nvml.h -func nvmlDeviceResetGpuLockedClocks(Device Device) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceResetGpuLockedClocks(cDevice) +func nvmlDeviceResetGpuLockedClocks(nvmlDevice nvmlDevice) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceResetGpuLockedClocks(cnvmlDevice) __v := (Return)(__ret) return __v } // nvmlDeviceSetMemoryLockedClocks function as declared in nvml/nvml.h -func nvmlDeviceSetMemoryLockedClocks(Device Device, MinMemClockMHz uint32, MaxMemClockMHz uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetMemoryLockedClocks(nvmlDevice nvmlDevice, MinMemClockMHz uint32, MaxMemClockMHz uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMinMemClockMHz, _ := (C.uint)(MinMemClockMHz), cgoAllocsUnknown cMaxMemClockMHz, _ := (C.uint)(MaxMemClockMHz), cgoAllocsUnknown - __ret := C.nvmlDeviceSetMemoryLockedClocks(cDevice, cMinMemClockMHz, cMaxMemClockMHz) + __ret := C.nvmlDeviceSetMemoryLockedClocks(cnvmlDevice, cMinMemClockMHz, cMaxMemClockMHz) __v := (Return)(__ret) return __v } // nvmlDeviceResetMemoryLockedClocks function as declared in nvml/nvml.h -func nvmlDeviceResetMemoryLockedClocks(Device Device) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceResetMemoryLockedClocks(cDevice) +func nvmlDeviceResetMemoryLockedClocks(nvmlDevice nvmlDevice) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceResetMemoryLockedClocks(cnvmlDevice) __v := (Return)(__ret) return __v } // nvmlDeviceSetApplicationsClocks function as declared in nvml/nvml.h -func nvmlDeviceSetApplicationsClocks(Device Device, MemClockMHz uint32, GraphicsClockMHz uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetApplicationsClocks(nvmlDevice nvmlDevice, MemClockMHz uint32, GraphicsClockMHz uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMemClockMHz, _ := (C.uint)(MemClockMHz), cgoAllocsUnknown cGraphicsClockMHz, _ := (C.uint)(GraphicsClockMHz), cgoAllocsUnknown - __ret := C.nvmlDeviceSetApplicationsClocks(cDevice, cMemClockMHz, cGraphicsClockMHz) + __ret := C.nvmlDeviceSetApplicationsClocks(cnvmlDevice, cMemClockMHz, cGraphicsClockMHz) __v := (Return)(__ret) return __v } -// nvmlDeviceGetClkMonStatus function as declared in nvml/nvml.h -func nvmlDeviceGetClkMonStatus(Device Device, Status *ClkMonStatus) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cStatus, _ := (*C.nvmlClkMonStatus_t)(unsafe.Pointer(Status)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetClkMonStatus(cDevice, cStatus) +// nvmlDeviceResetApplicationsClocks function as declared in nvml/nvml.h +func nvmlDeviceResetApplicationsClocks(nvmlDevice nvmlDevice) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceResetApplicationsClocks(cnvmlDevice) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceSetAutoBoostedClocksEnabled function as declared in nvml/nvml.h +func nvmlDeviceSetAutoBoostedClocksEnabled(nvmlDevice nvmlDevice, Enabled EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cEnabled, _ := (C.nvmlEnableState_t)(Enabled), cgoAllocsUnknown + __ret := C.nvmlDeviceSetAutoBoostedClocksEnabled(cnvmlDevice, cEnabled) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceSetDefaultAutoBoostedClocksEnabled function as declared in nvml/nvml.h +func nvmlDeviceSetDefaultAutoBoostedClocksEnabled(nvmlDevice nvmlDevice, Enabled EnableState, Flags uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cEnabled, _ := (C.nvmlEnableState_t)(Enabled), cgoAllocsUnknown + cFlags, _ := (C.uint)(Flags), cgoAllocsUnknown + __ret := C.nvmlDeviceSetDefaultAutoBoostedClocksEnabled(cnvmlDevice, cEnabled, cFlags) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceSetDefaultFanSpeed_v2 function as declared in nvml/nvml.h +func nvmlDeviceSetDefaultFanSpeed_v2(nvmlDevice nvmlDevice, Fan uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cFan, _ := (C.uint)(Fan), cgoAllocsUnknown + __ret := C.nvmlDeviceSetDefaultFanSpeed_v2(cnvmlDevice, cFan) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceSetFanControlPolicy function as declared in nvml/nvml.h +func nvmlDeviceSetFanControlPolicy(nvmlDevice nvmlDevice, Fan uint32, Policy FanControlPolicy) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cFan, _ := (C.uint)(Fan), cgoAllocsUnknown + cPolicy, _ := (C.nvmlFanControlPolicy_t)(Policy), cgoAllocsUnknown + __ret := C.nvmlDeviceSetFanControlPolicy(cnvmlDevice, cFan, cPolicy) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceSetTemperatureThreshold function as declared in nvml/nvml.h +func nvmlDeviceSetTemperatureThreshold(nvmlDevice nvmlDevice, ThresholdType TemperatureThresholds, Temp *int32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cThresholdType, _ := (C.nvmlTemperatureThresholds_t)(ThresholdType), cgoAllocsUnknown + cTemp, _ := (*C.int)(unsafe.Pointer(Temp)), cgoAllocsUnknown + __ret := C.nvmlDeviceSetTemperatureThreshold(cnvmlDevice, cThresholdType, cTemp) __v := (Return)(__ret) return __v } // nvmlDeviceSetPowerManagementLimit function as declared in nvml/nvml.h -func nvmlDeviceSetPowerManagementLimit(Device Device, Limit uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetPowerManagementLimit(nvmlDevice nvmlDevice, Limit uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLimit, _ := (C.uint)(Limit), cgoAllocsUnknown - __ret := C.nvmlDeviceSetPowerManagementLimit(cDevice, cLimit) + __ret := C.nvmlDeviceSetPowerManagementLimit(cnvmlDevice, cLimit) __v := (Return)(__ret) return __v } // nvmlDeviceSetGpuOperationMode function as declared in nvml/nvml.h -func nvmlDeviceSetGpuOperationMode(Device Device, Mode GpuOperationMode) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetGpuOperationMode(nvmlDevice nvmlDevice, Mode GpuOperationMode) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMode, _ := (C.nvmlGpuOperationMode_t)(Mode), cgoAllocsUnknown - __ret := C.nvmlDeviceSetGpuOperationMode(cDevice, cMode) + __ret := C.nvmlDeviceSetGpuOperationMode(cnvmlDevice, cMode) __v := (Return)(__ret) return __v } // nvmlDeviceSetAPIRestriction function as declared in nvml/nvml.h -func nvmlDeviceSetAPIRestriction(Device Device, ApiType RestrictedAPI, IsRestricted EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetAPIRestriction(nvmlDevice nvmlDevice, ApiType RestrictedAPI, IsRestricted EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cApiType, _ := (C.nvmlRestrictedAPI_t)(ApiType), cgoAllocsUnknown cIsRestricted, _ := (C.nvmlEnableState_t)(IsRestricted), cgoAllocsUnknown - __ret := C.nvmlDeviceSetAPIRestriction(cDevice, cApiType, cIsRestricted) + __ret := C.nvmlDeviceSetAPIRestriction(cnvmlDevice, cApiType, cIsRestricted) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceSetFanSpeed_v2 function as declared in nvml/nvml.h +func nvmlDeviceSetFanSpeed_v2(nvmlDevice nvmlDevice, Fan uint32, Speed uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cFan, _ := (C.uint)(Fan), cgoAllocsUnknown + cSpeed, _ := (C.uint)(Speed), cgoAllocsUnknown + __ret := C.nvmlDeviceSetFanSpeed_v2(cnvmlDevice, cFan, cSpeed) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceSetGpcClkVfOffset function as declared in nvml/nvml.h +func nvmlDeviceSetGpcClkVfOffset(nvmlDevice nvmlDevice, Offset int32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cOffset, _ := (C.int)(Offset), cgoAllocsUnknown + __ret := C.nvmlDeviceSetGpcClkVfOffset(cnvmlDevice, cOffset) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceSetMemClkVfOffset function as declared in nvml/nvml.h +func nvmlDeviceSetMemClkVfOffset(nvmlDevice nvmlDevice, Offset int32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cOffset, _ := (C.int)(Offset), cgoAllocsUnknown + __ret := C.nvmlDeviceSetMemClkVfOffset(cnvmlDevice, cOffset) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceSetConfComputeUnprotectedMemSize function as declared in nvml/nvml.h +func nvmlDeviceSetConfComputeUnprotectedMemSize(nvmlDevice nvmlDevice, SizeKiB uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cSizeKiB, _ := (C.ulonglong)(SizeKiB), cgoAllocsUnknown + __ret := C.nvmlDeviceSetConfComputeUnprotectedMemSize(cnvmlDevice, cSizeKiB) + __v := (Return)(__ret) + return __v +} + +// nvmlSystemSetConfComputeGpusReadyState function as declared in nvml/nvml.h +func nvmlSystemSetConfComputeGpusReadyState(IsAcceptingWork uint32) Return { + cIsAcceptingWork, _ := (C.uint)(IsAcceptingWork), cgoAllocsUnknown + __ret := C.nvmlSystemSetConfComputeGpusReadyState(cIsAcceptingWork) + __v := (Return)(__ret) + return __v +} + +// nvmlSystemSetConfComputeKeyRotationThresholdInfo function as declared in nvml/nvml.h +func nvmlSystemSetConfComputeKeyRotationThresholdInfo(PKeyRotationThrInfo *ConfComputeSetKeyRotationThresholdInfo) Return { + cPKeyRotationThrInfo, _ := (*C.nvmlConfComputeSetKeyRotationThresholdInfo_t)(unsafe.Pointer(PKeyRotationThrInfo)), cgoAllocsUnknown + __ret := C.nvmlSystemSetConfComputeKeyRotationThresholdInfo(cPKeyRotationThrInfo) __v := (Return)(__ret) return __v } // nvmlDeviceSetAccountingMode function as declared in nvml/nvml.h -func nvmlDeviceSetAccountingMode(Device Device, Mode EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetAccountingMode(nvmlDevice nvmlDevice, Mode EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMode, _ := (C.nvmlEnableState_t)(Mode), cgoAllocsUnknown - __ret := C.nvmlDeviceSetAccountingMode(cDevice, cMode) + __ret := C.nvmlDeviceSetAccountingMode(cnvmlDevice, cMode) __v := (Return)(__ret) return __v } // nvmlDeviceClearAccountingPids function as declared in nvml/nvml.h -func nvmlDeviceClearAccountingPids(Device Device) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceClearAccountingPids(cDevice) +func nvmlDeviceClearAccountingPids(nvmlDevice nvmlDevice) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceClearAccountingPids(cnvmlDevice) __v := (Return)(__ret) return __v } // nvmlDeviceGetNvLinkState function as declared in nvml/nvml.h -func nvmlDeviceGetNvLinkState(Device Device, Link uint32, IsActive *EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetNvLinkState(nvmlDevice nvmlDevice, Link uint32, IsActive *EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLink, _ := (C.uint)(Link), cgoAllocsUnknown cIsActive, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(IsActive)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetNvLinkState(cDevice, cLink, cIsActive) + __ret := C.nvmlDeviceGetNvLinkState(cnvmlDevice, cLink, cIsActive) __v := (Return)(__ret) return __v } // nvmlDeviceGetNvLinkVersion function as declared in nvml/nvml.h -func nvmlDeviceGetNvLinkVersion(Device Device, Link uint32, Version *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetNvLinkVersion(nvmlDevice nvmlDevice, Link uint32, Version *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLink, _ := (C.uint)(Link), cgoAllocsUnknown cVersion, _ := (*C.uint)(unsafe.Pointer(Version)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetNvLinkVersion(cDevice, cLink, cVersion) + __ret := C.nvmlDeviceGetNvLinkVersion(cnvmlDevice, cLink, cVersion) __v := (Return)(__ret) return __v } // nvmlDeviceGetNvLinkCapability function as declared in nvml/nvml.h -func nvmlDeviceGetNvLinkCapability(Device Device, Link uint32, Capability NvLinkCapability, CapResult *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetNvLinkCapability(nvmlDevice nvmlDevice, Link uint32, Capability NvLinkCapability, CapResult *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLink, _ := (C.uint)(Link), cgoAllocsUnknown cCapability, _ := (C.nvmlNvLinkCapability_t)(Capability), cgoAllocsUnknown cCapResult, _ := (*C.uint)(unsafe.Pointer(CapResult)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetNvLinkCapability(cDevice, cLink, cCapability, cCapResult) + __ret := C.nvmlDeviceGetNvLinkCapability(cnvmlDevice, cLink, cCapability, cCapResult) __v := (Return)(__ret) return __v } // nvmlDeviceGetNvLinkRemotePciInfo_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetNvLinkRemotePciInfo_v2(Device Device, Link uint32, Pci *PciInfo) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetNvLinkRemotePciInfo_v2(nvmlDevice nvmlDevice, Link uint32, Pci *PciInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLink, _ := (C.uint)(Link), cgoAllocsUnknown cPci, _ := (*C.nvmlPciInfo_t)(unsafe.Pointer(Pci)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetNvLinkRemotePciInfo_v2(cDevice, cLink, cPci) + __ret := C.nvmlDeviceGetNvLinkRemotePciInfo_v2(cnvmlDevice, cLink, cPci) __v := (Return)(__ret) return __v } // nvmlDeviceGetNvLinkErrorCounter function as declared in nvml/nvml.h -func nvmlDeviceGetNvLinkErrorCounter(Device Device, Link uint32, Counter NvLinkErrorCounter, CounterValue *uint64) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetNvLinkErrorCounter(nvmlDevice nvmlDevice, Link uint32, Counter NvLinkErrorCounter, CounterValue *uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLink, _ := (C.uint)(Link), cgoAllocsUnknown cCounter, _ := (C.nvmlNvLinkErrorCounter_t)(Counter), cgoAllocsUnknown cCounterValue, _ := (*C.ulonglong)(unsafe.Pointer(CounterValue)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetNvLinkErrorCounter(cDevice, cLink, cCounter, cCounterValue) + __ret := C.nvmlDeviceGetNvLinkErrorCounter(cnvmlDevice, cLink, cCounter, cCounterValue) __v := (Return)(__ret) return __v } // nvmlDeviceResetNvLinkErrorCounters function as declared in nvml/nvml.h -func nvmlDeviceResetNvLinkErrorCounters(Device Device, Link uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceResetNvLinkErrorCounters(nvmlDevice nvmlDevice, Link uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLink, _ := (C.uint)(Link), cgoAllocsUnknown - __ret := C.nvmlDeviceResetNvLinkErrorCounters(cDevice, cLink) + __ret := C.nvmlDeviceResetNvLinkErrorCounters(cnvmlDevice, cLink) __v := (Return)(__ret) return __v } // nvmlDeviceSetNvLinkUtilizationControl function as declared in nvml/nvml.h -func nvmlDeviceSetNvLinkUtilizationControl(Device Device, Link uint32, Counter uint32, Control *NvLinkUtilizationControl, Reset uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetNvLinkUtilizationControl(nvmlDevice nvmlDevice, Link uint32, Counter uint32, Control *NvLinkUtilizationControl, Reset uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLink, _ := (C.uint)(Link), cgoAllocsUnknown cCounter, _ := (C.uint)(Counter), cgoAllocsUnknown cControl, _ := (*C.nvmlNvLinkUtilizationControl_t)(unsafe.Pointer(Control)), cgoAllocsUnknown cReset, _ := (C.uint)(Reset), cgoAllocsUnknown - __ret := C.nvmlDeviceSetNvLinkUtilizationControl(cDevice, cLink, cCounter, cControl, cReset) + __ret := C.nvmlDeviceSetNvLinkUtilizationControl(cnvmlDevice, cLink, cCounter, cControl, cReset) __v := (Return)(__ret) return __v } // nvmlDeviceGetNvLinkUtilizationControl function as declared in nvml/nvml.h -func nvmlDeviceGetNvLinkUtilizationControl(Device Device, Link uint32, Counter uint32, Control *NvLinkUtilizationControl) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetNvLinkUtilizationControl(nvmlDevice nvmlDevice, Link uint32, Counter uint32, Control *NvLinkUtilizationControl) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLink, _ := (C.uint)(Link), cgoAllocsUnknown cCounter, _ := (C.uint)(Counter), cgoAllocsUnknown cControl, _ := (*C.nvmlNvLinkUtilizationControl_t)(unsafe.Pointer(Control)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetNvLinkUtilizationControl(cDevice, cLink, cCounter, cControl) + __ret := C.nvmlDeviceGetNvLinkUtilizationControl(cnvmlDevice, cLink, cCounter, cControl) __v := (Return)(__ret) return __v } // nvmlDeviceGetNvLinkUtilizationCounter function as declared in nvml/nvml.h -func nvmlDeviceGetNvLinkUtilizationCounter(Device Device, Link uint32, Counter uint32, Rxcounter *uint64, Txcounter *uint64) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetNvLinkUtilizationCounter(nvmlDevice nvmlDevice, Link uint32, Counter uint32, Rxcounter *uint64, Txcounter *uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLink, _ := (C.uint)(Link), cgoAllocsUnknown cCounter, _ := (C.uint)(Counter), cgoAllocsUnknown cRxcounter, _ := (*C.ulonglong)(unsafe.Pointer(Rxcounter)), cgoAllocsUnknown cTxcounter, _ := (*C.ulonglong)(unsafe.Pointer(Txcounter)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetNvLinkUtilizationCounter(cDevice, cLink, cCounter, cRxcounter, cTxcounter) + __ret := C.nvmlDeviceGetNvLinkUtilizationCounter(cnvmlDevice, cLink, cCounter, cRxcounter, cTxcounter) __v := (Return)(__ret) return __v } // nvmlDeviceFreezeNvLinkUtilizationCounter function as declared in nvml/nvml.h -func nvmlDeviceFreezeNvLinkUtilizationCounter(Device Device, Link uint32, Counter uint32, Freeze EnableState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceFreezeNvLinkUtilizationCounter(nvmlDevice nvmlDevice, Link uint32, Counter uint32, Freeze EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLink, _ := (C.uint)(Link), cgoAllocsUnknown cCounter, _ := (C.uint)(Counter), cgoAllocsUnknown cFreeze, _ := (C.nvmlEnableState_t)(Freeze), cgoAllocsUnknown - __ret := C.nvmlDeviceFreezeNvLinkUtilizationCounter(cDevice, cLink, cCounter, cFreeze) + __ret := C.nvmlDeviceFreezeNvLinkUtilizationCounter(cnvmlDevice, cLink, cCounter, cFreeze) __v := (Return)(__ret) return __v } // nvmlDeviceResetNvLinkUtilizationCounter function as declared in nvml/nvml.h -func nvmlDeviceResetNvLinkUtilizationCounter(Device Device, Link uint32, Counter uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceResetNvLinkUtilizationCounter(nvmlDevice nvmlDevice, Link uint32, Counter uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLink, _ := (C.uint)(Link), cgoAllocsUnknown cCounter, _ := (C.uint)(Counter), cgoAllocsUnknown - __ret := C.nvmlDeviceResetNvLinkUtilizationCounter(cDevice, cLink, cCounter) + __ret := C.nvmlDeviceResetNvLinkUtilizationCounter(cnvmlDevice, cLink, cCounter) __v := (Return)(__ret) return __v } // nvmlDeviceGetNvLinkRemoteDeviceType function as declared in nvml/nvml.h -func nvmlDeviceGetNvLinkRemoteDeviceType(Device Device, Link uint32, PNvLinkDeviceType *IntNvLinkDeviceType) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetNvLinkRemoteDeviceType(nvmlDevice nvmlDevice, Link uint32, PNvLinkDeviceType *IntNvLinkDeviceType) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLink, _ := (C.uint)(Link), cgoAllocsUnknown cPNvLinkDeviceType, _ := (*C.nvmlIntNvLinkDeviceType_t)(unsafe.Pointer(PNvLinkDeviceType)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetNvLinkRemoteDeviceType(cDevice, cLink, cPNvLinkDeviceType) + __ret := C.nvmlDeviceGetNvLinkRemoteDeviceType(cnvmlDevice, cLink, cPNvLinkDeviceType) __v := (Return)(__ret) return __v } // nvmlEventSetCreate function as declared in nvml/nvml.h -func nvmlEventSetCreate(Set *EventSet) Return { +func nvmlEventSetCreate(Set *nvmlEventSet) Return { cSet, _ := (*C.nvmlEventSet_t)(unsafe.Pointer(Set)), cgoAllocsUnknown __ret := C.nvmlEventSetCreate(cSet) __v := (Return)(__ret) @@ -1640,26 +1987,26 @@ func nvmlEventSetCreate(Set *EventSet) Return { } // nvmlDeviceRegisterEvents function as declared in nvml/nvml.h -func nvmlDeviceRegisterEvents(Device Device, EventTypes uint64, Set EventSet) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceRegisterEvents(nvmlDevice nvmlDevice, EventTypes uint64, Set nvmlEventSet) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cEventTypes, _ := (C.ulonglong)(EventTypes), cgoAllocsUnknown cSet, _ := *(*C.nvmlEventSet_t)(unsafe.Pointer(&Set)), cgoAllocsUnknown - __ret := C.nvmlDeviceRegisterEvents(cDevice, cEventTypes, cSet) + __ret := C.nvmlDeviceRegisterEvents(cnvmlDevice, cEventTypes, cSet) __v := (Return)(__ret) return __v } // nvmlDeviceGetSupportedEventTypes function as declared in nvml/nvml.h -func nvmlDeviceGetSupportedEventTypes(Device Device, EventTypes *uint64) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetSupportedEventTypes(nvmlDevice nvmlDevice, EventTypes *uint64) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cEventTypes, _ := (*C.ulonglong)(unsafe.Pointer(EventTypes)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetSupportedEventTypes(cDevice, cEventTypes) + __ret := C.nvmlDeviceGetSupportedEventTypes(cnvmlDevice, cEventTypes) __v := (Return)(__ret) return __v } // nvmlEventSetWait_v2 function as declared in nvml/nvml.h -func nvmlEventSetWait_v2(Set EventSet, Data *EventData, Timeoutms uint32) Return { +func nvmlEventSetWait_v2(Set nvmlEventSet, Data *nvmlEventData, Timeoutms uint32) Return { cSet, _ := *(*C.nvmlEventSet_t)(unsafe.Pointer(&Set)), cgoAllocsUnknown cData, _ := (*C.nvmlEventData_t)(unsafe.Pointer(Data)), cgoAllocsUnknown cTimeoutms, _ := (C.uint)(Timeoutms), cgoAllocsUnknown @@ -1669,7 +2016,7 @@ func nvmlEventSetWait_v2(Set EventSet, Data *EventData, Timeoutms uint32) Return } // nvmlEventSetFree function as declared in nvml/nvml.h -func nvmlEventSetFree(Set EventSet) Return { +func nvmlEventSetFree(Set nvmlEventSet) Return { cSet, _ := *(*C.nvmlEventSet_t)(unsafe.Pointer(&Set)), cgoAllocsUnknown __ret := C.nvmlEventSetFree(cSet) __v := (Return)(__ret) @@ -1713,87 +2060,132 @@ func nvmlDeviceDiscoverGpus(PciInfo *PciInfo) Return { } // nvmlDeviceGetFieldValues function as declared in nvml/nvml.h -func nvmlDeviceGetFieldValues(Device Device, ValuesCount int32, Values *FieldValue) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetFieldValues(nvmlDevice nvmlDevice, ValuesCount int32, Values *FieldValue) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cValuesCount, _ := (C.int)(ValuesCount), cgoAllocsUnknown cValues, _ := (*C.nvmlFieldValue_t)(unsafe.Pointer(Values)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetFieldValues(cDevice, cValuesCount, cValues) + __ret := C.nvmlDeviceGetFieldValues(cnvmlDevice, cValuesCount, cValues) __v := (Return)(__ret) return __v } // nvmlDeviceClearFieldValues function as declared in nvml/nvml.h -func nvmlDeviceClearFieldValues(Device Device, ValuesCount int32, Values *FieldValue) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceClearFieldValues(nvmlDevice nvmlDevice, ValuesCount int32, Values *FieldValue) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cValuesCount, _ := (C.int)(ValuesCount), cgoAllocsUnknown cValues, _ := (*C.nvmlFieldValue_t)(unsafe.Pointer(Values)), cgoAllocsUnknown - __ret := C.nvmlDeviceClearFieldValues(cDevice, cValuesCount, cValues) + __ret := C.nvmlDeviceClearFieldValues(cnvmlDevice, cValuesCount, cValues) __v := (Return)(__ret) return __v } // nvmlDeviceGetVirtualizationMode function as declared in nvml/nvml.h -func nvmlDeviceGetVirtualizationMode(Device Device, PVirtualMode *GpuVirtualizationMode) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetVirtualizationMode(nvmlDevice nvmlDevice, PVirtualMode *GpuVirtualizationMode) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPVirtualMode, _ := (*C.nvmlGpuVirtualizationMode_t)(unsafe.Pointer(PVirtualMode)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetVirtualizationMode(cDevice, cPVirtualMode) + __ret := C.nvmlDeviceGetVirtualizationMode(cnvmlDevice, cPVirtualMode) __v := (Return)(__ret) return __v } // nvmlDeviceGetHostVgpuMode function as declared in nvml/nvml.h -func nvmlDeviceGetHostVgpuMode(Device Device, PHostVgpuMode *HostVgpuMode) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetHostVgpuMode(nvmlDevice nvmlDevice, PHostVgpuMode *HostVgpuMode) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPHostVgpuMode, _ := (*C.nvmlHostVgpuMode_t)(unsafe.Pointer(PHostVgpuMode)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetHostVgpuMode(cDevice, cPHostVgpuMode) + __ret := C.nvmlDeviceGetHostVgpuMode(cnvmlDevice, cPHostVgpuMode) __v := (Return)(__ret) return __v } // nvmlDeviceSetVirtualizationMode function as declared in nvml/nvml.h -func nvmlDeviceSetVirtualizationMode(Device Device, VirtualMode GpuVirtualizationMode) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetVirtualizationMode(nvmlDevice nvmlDevice, VirtualMode GpuVirtualizationMode) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cVirtualMode, _ := (C.nvmlGpuVirtualizationMode_t)(VirtualMode), cgoAllocsUnknown - __ret := C.nvmlDeviceSetVirtualizationMode(cDevice, cVirtualMode) + __ret := C.nvmlDeviceSetVirtualizationMode(cnvmlDevice, cVirtualMode) __v := (Return)(__ret) return __v } -// nvmlDeviceGetGridLicensableFeatures_v4 function as declared in nvml/nvml.h -func nvmlDeviceGetGridLicensableFeatures_v4(Device Device, PGridLicensableFeatures *GridLicensableFeatures) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cPGridLicensableFeatures, _ := (*C.nvmlGridLicensableFeatures_t)(unsafe.Pointer(PGridLicensableFeatures)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGridLicensableFeatures_v4(cDevice, cPGridLicensableFeatures) +// nvmlDeviceGetVgpuHeterogeneousMode function as declared in nvml/nvml.h +func nvmlDeviceGetVgpuHeterogeneousMode(nvmlDevice nvmlDevice, PHeterogeneousMode *VgpuHeterogeneousMode) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cPHeterogeneousMode, _ := (*C.nvmlVgpuHeterogeneousMode_t)(unsafe.Pointer(PHeterogeneousMode)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetVgpuHeterogeneousMode(cnvmlDevice, cPHeterogeneousMode) __v := (Return)(__ret) return __v } -// nvmlDeviceGetProcessUtilization function as declared in nvml/nvml.h -func nvmlDeviceGetProcessUtilization(Device Device, Utilization *ProcessUtilizationSample, ProcessSamplesCount *uint32, LastSeenTimeStamp uint64) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cUtilization, _ := (*C.nvmlProcessUtilizationSample_t)(unsafe.Pointer(Utilization)), cgoAllocsUnknown - cProcessSamplesCount, _ := (*C.uint)(unsafe.Pointer(ProcessSamplesCount)), cgoAllocsUnknown - cLastSeenTimeStamp, _ := (C.ulonglong)(LastSeenTimeStamp), cgoAllocsUnknown - __ret := C.nvmlDeviceGetProcessUtilization(cDevice, cUtilization, cProcessSamplesCount, cLastSeenTimeStamp) +// nvmlDeviceSetVgpuHeterogeneousMode function as declared in nvml/nvml.h +func nvmlDeviceSetVgpuHeterogeneousMode(nvmlDevice nvmlDevice, PHeterogeneousMode *VgpuHeterogeneousMode) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cPHeterogeneousMode, _ := (*C.nvmlVgpuHeterogeneousMode_t)(unsafe.Pointer(PHeterogeneousMode)), cgoAllocsUnknown + __ret := C.nvmlDeviceSetVgpuHeterogeneousMode(cnvmlDevice, cPHeterogeneousMode) __v := (Return)(__ret) return __v } -// nvmlDeviceGetGspFirmwareVersion function as declared in nvml/nvml.h -func nvmlDeviceGetGspFirmwareVersion(Device Device, Version *byte) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cVersion, _ := (*C.char)(unsafe.Pointer(Version)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGspFirmwareVersion(cDevice, cVersion) +// nvmlVgpuInstanceGetPlacementId function as declared in nvml/nvml.h +func nvmlVgpuInstanceGetPlacementId(nvmlVgpuInstance nvmlVgpuInstance, PPlacement *VgpuPlacementId) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown + cPPlacement, _ := (*C.nvmlVgpuPlacementId_t)(unsafe.Pointer(PPlacement)), cgoAllocsUnknown + __ret := C.nvmlVgpuInstanceGetPlacementId(cnvmlVgpuInstance, cPPlacement) __v := (Return)(__ret) return __v } -// nvmlDeviceGetGspFirmwareMode function as declared in nvml/nvml.h -func nvmlDeviceGetGspFirmwareMode(Device Device, IsEnabled *uint32, DefaultMode *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cIsEnabled, _ := (*C.uint)(unsafe.Pointer(IsEnabled)), cgoAllocsUnknown - cDefaultMode, _ := (*C.uint)(unsafe.Pointer(DefaultMode)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGspFirmwareMode(cDevice, cIsEnabled, cDefaultMode) +// nvmlDeviceGetVgpuTypeSupportedPlacements function as declared in nvml/nvml.h +func nvmlDeviceGetVgpuTypeSupportedPlacements(nvmlDevice nvmlDevice, nvmlVgpuTypeId nvmlVgpuTypeId, PPlacementList *VgpuPlacementList) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown + cPPlacementList, _ := (*C.nvmlVgpuPlacementList_t)(unsafe.Pointer(PPlacementList)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetVgpuTypeSupportedPlacements(cnvmlDevice, cnvmlVgpuTypeId, cPPlacementList) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetVgpuTypeCreatablePlacements function as declared in nvml/nvml.h +func nvmlDeviceGetVgpuTypeCreatablePlacements(nvmlDevice nvmlDevice, nvmlVgpuTypeId nvmlVgpuTypeId, PPlacementList *VgpuPlacementList) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown + cPPlacementList, _ := (*C.nvmlVgpuPlacementList_t)(unsafe.Pointer(PPlacementList)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetVgpuTypeCreatablePlacements(cnvmlDevice, cnvmlVgpuTypeId, cPPlacementList) + __v := (Return)(__ret) + return __v +} + +// nvmlVgpuTypeGetGspHeapSize function as declared in nvml/nvml.h +func nvmlVgpuTypeGetGspHeapSize(nvmlVgpuTypeId nvmlVgpuTypeId, GspHeapSize *uint64) Return { + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown + cGspHeapSize, _ := (*C.ulonglong)(unsafe.Pointer(GspHeapSize)), cgoAllocsUnknown + __ret := C.nvmlVgpuTypeGetGspHeapSize(cnvmlVgpuTypeId, cGspHeapSize) + __v := (Return)(__ret) + return __v +} + +// nvmlVgpuTypeGetFbReservation function as declared in nvml/nvml.h +func nvmlVgpuTypeGetFbReservation(nvmlVgpuTypeId nvmlVgpuTypeId, FbReservation *uint64) Return { + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown + cFbReservation, _ := (*C.ulonglong)(unsafe.Pointer(FbReservation)), cgoAllocsUnknown + __ret := C.nvmlVgpuTypeGetFbReservation(cnvmlVgpuTypeId, cFbReservation) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceSetVgpuCapabilities function as declared in nvml/nvml.h +func nvmlDeviceSetVgpuCapabilities(nvmlDevice nvmlDevice, Capability DeviceVgpuCapability, State EnableState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cCapability, _ := (C.nvmlDeviceVgpuCapability_t)(Capability), cgoAllocsUnknown + cState, _ := (C.nvmlEnableState_t)(State), cgoAllocsUnknown + __ret := C.nvmlDeviceSetVgpuCapabilities(cnvmlDevice, cCapability, cState) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetGridLicensableFeatures_v4 function as declared in nvml/nvml.h +func nvmlDeviceGetGridLicensableFeatures_v4(nvmlDevice nvmlDevice, PGridLicensableFeatures *GridLicensableFeatures) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cPGridLicensableFeatures, _ := (*C.nvmlGridLicensableFeatures_t)(unsafe.Pointer(PGridLicensableFeatures)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetGridLicensableFeatures_v4(cnvmlDevice, cPGridLicensableFeatures) __v := (Return)(__ret) return __v } @@ -1808,330 +2200,340 @@ func nvmlGetVgpuDriverCapabilities(Capability VgpuDriverCapability, CapResult *u } // nvmlDeviceGetVgpuCapabilities function as declared in nvml/nvml.h -func nvmlDeviceGetVgpuCapabilities(Device Device, Capability DeviceVgpuCapability, CapResult *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetVgpuCapabilities(nvmlDevice nvmlDevice, Capability DeviceVgpuCapability, CapResult *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCapability, _ := (C.nvmlDeviceVgpuCapability_t)(Capability), cgoAllocsUnknown cCapResult, _ := (*C.uint)(unsafe.Pointer(CapResult)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetVgpuCapabilities(cDevice, cCapability, cCapResult) + __ret := C.nvmlDeviceGetVgpuCapabilities(cnvmlDevice, cCapability, cCapResult) __v := (Return)(__ret) return __v } // nvmlDeviceGetSupportedVgpus function as declared in nvml/nvml.h -func nvmlDeviceGetSupportedVgpus(Device Device, VgpuCount *uint32, VgpuTypeIds *VgpuTypeId) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetSupportedVgpus(nvmlDevice nvmlDevice, VgpuCount *uint32, VgpuTypeIds *nvmlVgpuTypeId) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cVgpuCount, _ := (*C.uint)(unsafe.Pointer(VgpuCount)), cgoAllocsUnknown cVgpuTypeIds, _ := (*C.nvmlVgpuTypeId_t)(unsafe.Pointer(VgpuTypeIds)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetSupportedVgpus(cDevice, cVgpuCount, cVgpuTypeIds) + __ret := C.nvmlDeviceGetSupportedVgpus(cnvmlDevice, cVgpuCount, cVgpuTypeIds) __v := (Return)(__ret) return __v } // nvmlDeviceGetCreatableVgpus function as declared in nvml/nvml.h -func nvmlDeviceGetCreatableVgpus(Device Device, VgpuCount *uint32, VgpuTypeIds *VgpuTypeId) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetCreatableVgpus(nvmlDevice nvmlDevice, VgpuCount *uint32, VgpuTypeIds *nvmlVgpuTypeId) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cVgpuCount, _ := (*C.uint)(unsafe.Pointer(VgpuCount)), cgoAllocsUnknown cVgpuTypeIds, _ := (*C.nvmlVgpuTypeId_t)(unsafe.Pointer(VgpuTypeIds)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetCreatableVgpus(cDevice, cVgpuCount, cVgpuTypeIds) + __ret := C.nvmlDeviceGetCreatableVgpus(cnvmlDevice, cVgpuCount, cVgpuTypeIds) __v := (Return)(__ret) return __v } // nvmlVgpuTypeGetClass function as declared in nvml/nvml.h -func nvmlVgpuTypeGetClass(VgpuTypeId VgpuTypeId, VgpuTypeClass *byte, Size *uint32) Return { - cVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(VgpuTypeId), cgoAllocsUnknown +func nvmlVgpuTypeGetClass(nvmlVgpuTypeId nvmlVgpuTypeId, VgpuTypeClass *byte, Size *uint32) Return { + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown cVgpuTypeClass, _ := (*C.char)(unsafe.Pointer(VgpuTypeClass)), cgoAllocsUnknown cSize, _ := (*C.uint)(unsafe.Pointer(Size)), cgoAllocsUnknown - __ret := C.nvmlVgpuTypeGetClass(cVgpuTypeId, cVgpuTypeClass, cSize) + __ret := C.nvmlVgpuTypeGetClass(cnvmlVgpuTypeId, cVgpuTypeClass, cSize) __v := (Return)(__ret) return __v } // nvmlVgpuTypeGetName function as declared in nvml/nvml.h -func nvmlVgpuTypeGetName(VgpuTypeId VgpuTypeId, VgpuTypeName *byte, Size *uint32) Return { - cVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(VgpuTypeId), cgoAllocsUnknown +func nvmlVgpuTypeGetName(nvmlVgpuTypeId nvmlVgpuTypeId, VgpuTypeName *byte, Size *uint32) Return { + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown cVgpuTypeName, _ := (*C.char)(unsafe.Pointer(VgpuTypeName)), cgoAllocsUnknown cSize, _ := (*C.uint)(unsafe.Pointer(Size)), cgoAllocsUnknown - __ret := C.nvmlVgpuTypeGetName(cVgpuTypeId, cVgpuTypeName, cSize) + __ret := C.nvmlVgpuTypeGetName(cnvmlVgpuTypeId, cVgpuTypeName, cSize) __v := (Return)(__ret) return __v } // nvmlVgpuTypeGetGpuInstanceProfileId function as declared in nvml/nvml.h -func nvmlVgpuTypeGetGpuInstanceProfileId(VgpuTypeId VgpuTypeId, GpuInstanceProfileId *uint32) Return { - cVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(VgpuTypeId), cgoAllocsUnknown +func nvmlVgpuTypeGetGpuInstanceProfileId(nvmlVgpuTypeId nvmlVgpuTypeId, GpuInstanceProfileId *uint32) Return { + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown cGpuInstanceProfileId, _ := (*C.uint)(unsafe.Pointer(GpuInstanceProfileId)), cgoAllocsUnknown - __ret := C.nvmlVgpuTypeGetGpuInstanceProfileId(cVgpuTypeId, cGpuInstanceProfileId) + __ret := C.nvmlVgpuTypeGetGpuInstanceProfileId(cnvmlVgpuTypeId, cGpuInstanceProfileId) __v := (Return)(__ret) return __v } // nvmlVgpuTypeGetDeviceID function as declared in nvml/nvml.h -func nvmlVgpuTypeGetDeviceID(VgpuTypeId VgpuTypeId, DeviceID *uint64, SubsystemID *uint64) Return { - cVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(VgpuTypeId), cgoAllocsUnknown +func nvmlVgpuTypeGetDeviceID(nvmlVgpuTypeId nvmlVgpuTypeId, DeviceID *uint64, SubsystemID *uint64) Return { + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown cDeviceID, _ := (*C.ulonglong)(unsafe.Pointer(DeviceID)), cgoAllocsUnknown cSubsystemID, _ := (*C.ulonglong)(unsafe.Pointer(SubsystemID)), cgoAllocsUnknown - __ret := C.nvmlVgpuTypeGetDeviceID(cVgpuTypeId, cDeviceID, cSubsystemID) + __ret := C.nvmlVgpuTypeGetDeviceID(cnvmlVgpuTypeId, cDeviceID, cSubsystemID) __v := (Return)(__ret) return __v } // nvmlVgpuTypeGetFramebufferSize function as declared in nvml/nvml.h -func nvmlVgpuTypeGetFramebufferSize(VgpuTypeId VgpuTypeId, FbSize *uint64) Return { - cVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(VgpuTypeId), cgoAllocsUnknown +func nvmlVgpuTypeGetFramebufferSize(nvmlVgpuTypeId nvmlVgpuTypeId, FbSize *uint64) Return { + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown cFbSize, _ := (*C.ulonglong)(unsafe.Pointer(FbSize)), cgoAllocsUnknown - __ret := C.nvmlVgpuTypeGetFramebufferSize(cVgpuTypeId, cFbSize) + __ret := C.nvmlVgpuTypeGetFramebufferSize(cnvmlVgpuTypeId, cFbSize) __v := (Return)(__ret) return __v } // nvmlVgpuTypeGetNumDisplayHeads function as declared in nvml/nvml.h -func nvmlVgpuTypeGetNumDisplayHeads(VgpuTypeId VgpuTypeId, NumDisplayHeads *uint32) Return { - cVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(VgpuTypeId), cgoAllocsUnknown +func nvmlVgpuTypeGetNumDisplayHeads(nvmlVgpuTypeId nvmlVgpuTypeId, NumDisplayHeads *uint32) Return { + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown cNumDisplayHeads, _ := (*C.uint)(unsafe.Pointer(NumDisplayHeads)), cgoAllocsUnknown - __ret := C.nvmlVgpuTypeGetNumDisplayHeads(cVgpuTypeId, cNumDisplayHeads) + __ret := C.nvmlVgpuTypeGetNumDisplayHeads(cnvmlVgpuTypeId, cNumDisplayHeads) __v := (Return)(__ret) return __v } // nvmlVgpuTypeGetResolution function as declared in nvml/nvml.h -func nvmlVgpuTypeGetResolution(VgpuTypeId VgpuTypeId, DisplayIndex uint32, Xdim *uint32, Ydim *uint32) Return { - cVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(VgpuTypeId), cgoAllocsUnknown +func nvmlVgpuTypeGetResolution(nvmlVgpuTypeId nvmlVgpuTypeId, DisplayIndex uint32, Xdim *uint32, Ydim *uint32) Return { + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown cDisplayIndex, _ := (C.uint)(DisplayIndex), cgoAllocsUnknown cXdim, _ := (*C.uint)(unsafe.Pointer(Xdim)), cgoAllocsUnknown cYdim, _ := (*C.uint)(unsafe.Pointer(Ydim)), cgoAllocsUnknown - __ret := C.nvmlVgpuTypeGetResolution(cVgpuTypeId, cDisplayIndex, cXdim, cYdim) + __ret := C.nvmlVgpuTypeGetResolution(cnvmlVgpuTypeId, cDisplayIndex, cXdim, cYdim) __v := (Return)(__ret) return __v } // nvmlVgpuTypeGetLicense function as declared in nvml/nvml.h -func nvmlVgpuTypeGetLicense(VgpuTypeId VgpuTypeId, VgpuTypeLicenseString *byte, Size uint32) Return { - cVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(VgpuTypeId), cgoAllocsUnknown +func nvmlVgpuTypeGetLicense(nvmlVgpuTypeId nvmlVgpuTypeId, VgpuTypeLicenseString *byte, Size uint32) Return { + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown cVgpuTypeLicenseString, _ := (*C.char)(unsafe.Pointer(VgpuTypeLicenseString)), cgoAllocsUnknown cSize, _ := (C.uint)(Size), cgoAllocsUnknown - __ret := C.nvmlVgpuTypeGetLicense(cVgpuTypeId, cVgpuTypeLicenseString, cSize) + __ret := C.nvmlVgpuTypeGetLicense(cnvmlVgpuTypeId, cVgpuTypeLicenseString, cSize) __v := (Return)(__ret) return __v } // nvmlVgpuTypeGetFrameRateLimit function as declared in nvml/nvml.h -func nvmlVgpuTypeGetFrameRateLimit(VgpuTypeId VgpuTypeId, FrameRateLimit *uint32) Return { - cVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(VgpuTypeId), cgoAllocsUnknown +func nvmlVgpuTypeGetFrameRateLimit(nvmlVgpuTypeId nvmlVgpuTypeId, FrameRateLimit *uint32) Return { + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown cFrameRateLimit, _ := (*C.uint)(unsafe.Pointer(FrameRateLimit)), cgoAllocsUnknown - __ret := C.nvmlVgpuTypeGetFrameRateLimit(cVgpuTypeId, cFrameRateLimit) + __ret := C.nvmlVgpuTypeGetFrameRateLimit(cnvmlVgpuTypeId, cFrameRateLimit) __v := (Return)(__ret) return __v } // nvmlVgpuTypeGetMaxInstances function as declared in nvml/nvml.h -func nvmlVgpuTypeGetMaxInstances(Device Device, VgpuTypeId VgpuTypeId, VgpuInstanceCount *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(VgpuTypeId), cgoAllocsUnknown +func nvmlVgpuTypeGetMaxInstances(nvmlDevice nvmlDevice, nvmlVgpuTypeId nvmlVgpuTypeId, VgpuInstanceCount *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown cVgpuInstanceCount, _ := (*C.uint)(unsafe.Pointer(VgpuInstanceCount)), cgoAllocsUnknown - __ret := C.nvmlVgpuTypeGetMaxInstances(cDevice, cVgpuTypeId, cVgpuInstanceCount) + __ret := C.nvmlVgpuTypeGetMaxInstances(cnvmlDevice, cnvmlVgpuTypeId, cVgpuInstanceCount) __v := (Return)(__ret) return __v } // nvmlVgpuTypeGetMaxInstancesPerVm function as declared in nvml/nvml.h -func nvmlVgpuTypeGetMaxInstancesPerVm(VgpuTypeId VgpuTypeId, VgpuInstanceCountPerVm *uint32) Return { - cVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(VgpuTypeId), cgoAllocsUnknown +func nvmlVgpuTypeGetMaxInstancesPerVm(nvmlVgpuTypeId nvmlVgpuTypeId, VgpuInstanceCountPerVm *uint32) Return { + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown cVgpuInstanceCountPerVm, _ := (*C.uint)(unsafe.Pointer(VgpuInstanceCountPerVm)), cgoAllocsUnknown - __ret := C.nvmlVgpuTypeGetMaxInstancesPerVm(cVgpuTypeId, cVgpuInstanceCountPerVm) + __ret := C.nvmlVgpuTypeGetMaxInstancesPerVm(cnvmlVgpuTypeId, cVgpuInstanceCountPerVm) __v := (Return)(__ret) return __v } // nvmlDeviceGetActiveVgpus function as declared in nvml/nvml.h -func nvmlDeviceGetActiveVgpus(Device Device, VgpuCount *uint32, VgpuInstances *VgpuInstance) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetActiveVgpus(nvmlDevice nvmlDevice, VgpuCount *uint32, VgpuInstances *nvmlVgpuInstance) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cVgpuCount, _ := (*C.uint)(unsafe.Pointer(VgpuCount)), cgoAllocsUnknown cVgpuInstances, _ := (*C.nvmlVgpuInstance_t)(unsafe.Pointer(VgpuInstances)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetActiveVgpus(cDevice, cVgpuCount, cVgpuInstances) + __ret := C.nvmlDeviceGetActiveVgpus(cnvmlDevice, cVgpuCount, cVgpuInstances) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetVmID function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetVmID(VgpuInstance VgpuInstance, VmId *byte, Size uint32, VmIdType *VgpuVmIdType) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetVmID(nvmlVgpuInstance nvmlVgpuInstance, VmId *byte, Size uint32, VmIdType *VgpuVmIdType) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cVmId, _ := (*C.char)(unsafe.Pointer(VmId)), cgoAllocsUnknown cSize, _ := (C.uint)(Size), cgoAllocsUnknown cVmIdType, _ := (*C.nvmlVgpuVmIdType_t)(unsafe.Pointer(VmIdType)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetVmID(cVgpuInstance, cVmId, cSize, cVmIdType) + __ret := C.nvmlVgpuInstanceGetVmID(cnvmlVgpuInstance, cVmId, cSize, cVmIdType) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetUUID function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetUUID(VgpuInstance VgpuInstance, Uuid *byte, Size uint32) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetUUID(nvmlVgpuInstance nvmlVgpuInstance, Uuid *byte, Size uint32) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cUuid, _ := (*C.char)(unsafe.Pointer(Uuid)), cgoAllocsUnknown cSize, _ := (C.uint)(Size), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetUUID(cVgpuInstance, cUuid, cSize) + __ret := C.nvmlVgpuInstanceGetUUID(cnvmlVgpuInstance, cUuid, cSize) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetVmDriverVersion function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetVmDriverVersion(VgpuInstance VgpuInstance, Version *byte, Length uint32) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetVmDriverVersion(nvmlVgpuInstance nvmlVgpuInstance, Version *byte, Length uint32) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cVersion, _ := (*C.char)(unsafe.Pointer(Version)), cgoAllocsUnknown cLength, _ := (C.uint)(Length), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetVmDriverVersion(cVgpuInstance, cVersion, cLength) + __ret := C.nvmlVgpuInstanceGetVmDriverVersion(cnvmlVgpuInstance, cVersion, cLength) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetFbUsage function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetFbUsage(VgpuInstance VgpuInstance, FbUsage *uint64) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetFbUsage(nvmlVgpuInstance nvmlVgpuInstance, FbUsage *uint64) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cFbUsage, _ := (*C.ulonglong)(unsafe.Pointer(FbUsage)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetFbUsage(cVgpuInstance, cFbUsage) + __ret := C.nvmlVgpuInstanceGetFbUsage(cnvmlVgpuInstance, cFbUsage) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetLicenseStatus function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetLicenseStatus(VgpuInstance VgpuInstance, Licensed *uint32) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetLicenseStatus(nvmlVgpuInstance nvmlVgpuInstance, Licensed *uint32) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cLicensed, _ := (*C.uint)(unsafe.Pointer(Licensed)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetLicenseStatus(cVgpuInstance, cLicensed) + __ret := C.nvmlVgpuInstanceGetLicenseStatus(cnvmlVgpuInstance, cLicensed) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetType function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetType(VgpuInstance VgpuInstance, VgpuTypeId *VgpuTypeId) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown - cVgpuTypeId, _ := (*C.nvmlVgpuTypeId_t)(unsafe.Pointer(VgpuTypeId)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetType(cVgpuInstance, cVgpuTypeId) +func nvmlVgpuInstanceGetType(nvmlVgpuInstance nvmlVgpuInstance, nvmlVgpuTypeId *nvmlVgpuTypeId) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown + cnvmlVgpuTypeId, _ := (*C.nvmlVgpuTypeId_t)(unsafe.Pointer(nvmlVgpuTypeId)), cgoAllocsUnknown + __ret := C.nvmlVgpuInstanceGetType(cnvmlVgpuInstance, cnvmlVgpuTypeId) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetFrameRateLimit function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetFrameRateLimit(VgpuInstance VgpuInstance, FrameRateLimit *uint32) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetFrameRateLimit(nvmlVgpuInstance nvmlVgpuInstance, FrameRateLimit *uint32) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cFrameRateLimit, _ := (*C.uint)(unsafe.Pointer(FrameRateLimit)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetFrameRateLimit(cVgpuInstance, cFrameRateLimit) + __ret := C.nvmlVgpuInstanceGetFrameRateLimit(cnvmlVgpuInstance, cFrameRateLimit) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetEccMode function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetEccMode(VgpuInstance VgpuInstance, EccMode *EnableState) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetEccMode(nvmlVgpuInstance nvmlVgpuInstance, EccMode *EnableState) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cEccMode, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(EccMode)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetEccMode(cVgpuInstance, cEccMode) + __ret := C.nvmlVgpuInstanceGetEccMode(cnvmlVgpuInstance, cEccMode) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetEncoderCapacity function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetEncoderCapacity(VgpuInstance VgpuInstance, EncoderCapacity *uint32) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetEncoderCapacity(nvmlVgpuInstance nvmlVgpuInstance, EncoderCapacity *uint32) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cEncoderCapacity, _ := (*C.uint)(unsafe.Pointer(EncoderCapacity)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetEncoderCapacity(cVgpuInstance, cEncoderCapacity) + __ret := C.nvmlVgpuInstanceGetEncoderCapacity(cnvmlVgpuInstance, cEncoderCapacity) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceSetEncoderCapacity function as declared in nvml/nvml.h -func nvmlVgpuInstanceSetEncoderCapacity(VgpuInstance VgpuInstance, EncoderCapacity uint32) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceSetEncoderCapacity(nvmlVgpuInstance nvmlVgpuInstance, EncoderCapacity uint32) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cEncoderCapacity, _ := (C.uint)(EncoderCapacity), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceSetEncoderCapacity(cVgpuInstance, cEncoderCapacity) + __ret := C.nvmlVgpuInstanceSetEncoderCapacity(cnvmlVgpuInstance, cEncoderCapacity) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetEncoderStats function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetEncoderStats(VgpuInstance VgpuInstance, SessionCount *uint32, AverageFps *uint32, AverageLatency *uint32) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetEncoderStats(nvmlVgpuInstance nvmlVgpuInstance, SessionCount *uint32, AverageFps *uint32, AverageLatency *uint32) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cSessionCount, _ := (*C.uint)(unsafe.Pointer(SessionCount)), cgoAllocsUnknown cAverageFps, _ := (*C.uint)(unsafe.Pointer(AverageFps)), cgoAllocsUnknown cAverageLatency, _ := (*C.uint)(unsafe.Pointer(AverageLatency)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetEncoderStats(cVgpuInstance, cSessionCount, cAverageFps, cAverageLatency) + __ret := C.nvmlVgpuInstanceGetEncoderStats(cnvmlVgpuInstance, cSessionCount, cAverageFps, cAverageLatency) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetEncoderSessions function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetEncoderSessions(VgpuInstance VgpuInstance, SessionCount *uint32, SessionInfo *EncoderSessionInfo) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetEncoderSessions(nvmlVgpuInstance nvmlVgpuInstance, SessionCount *uint32, SessionInfo *EncoderSessionInfo) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cSessionCount, _ := (*C.uint)(unsafe.Pointer(SessionCount)), cgoAllocsUnknown cSessionInfo, _ := (*C.nvmlEncoderSessionInfo_t)(unsafe.Pointer(SessionInfo)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetEncoderSessions(cVgpuInstance, cSessionCount, cSessionInfo) + __ret := C.nvmlVgpuInstanceGetEncoderSessions(cnvmlVgpuInstance, cSessionCount, cSessionInfo) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetFBCStats function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetFBCStats(VgpuInstance VgpuInstance, FbcStats *FBCStats) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetFBCStats(nvmlVgpuInstance nvmlVgpuInstance, FbcStats *FBCStats) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cFbcStats, _ := (*C.nvmlFBCStats_t)(unsafe.Pointer(FbcStats)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetFBCStats(cVgpuInstance, cFbcStats) + __ret := C.nvmlVgpuInstanceGetFBCStats(cnvmlVgpuInstance, cFbcStats) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetFBCSessions function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetFBCSessions(VgpuInstance VgpuInstance, SessionCount *uint32, SessionInfo *FBCSessionInfo) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetFBCSessions(nvmlVgpuInstance nvmlVgpuInstance, SessionCount *uint32, SessionInfo *FBCSessionInfo) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cSessionCount, _ := (*C.uint)(unsafe.Pointer(SessionCount)), cgoAllocsUnknown cSessionInfo, _ := (*C.nvmlFBCSessionInfo_t)(unsafe.Pointer(SessionInfo)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetFBCSessions(cVgpuInstance, cSessionCount, cSessionInfo) + __ret := C.nvmlVgpuInstanceGetFBCSessions(cnvmlVgpuInstance, cSessionCount, cSessionInfo) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetGpuInstanceId function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetGpuInstanceId(VgpuInstance VgpuInstance, GpuInstanceId *uint32) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetGpuInstanceId(nvmlVgpuInstance nvmlVgpuInstance, GpuInstanceId *uint32) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cGpuInstanceId, _ := (*C.uint)(unsafe.Pointer(GpuInstanceId)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetGpuInstanceId(cVgpuInstance, cGpuInstanceId) + __ret := C.nvmlVgpuInstanceGetGpuInstanceId(cnvmlVgpuInstance, cGpuInstanceId) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetGpuPciId function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetGpuPciId(VgpuInstance VgpuInstance, VgpuPciId *byte, Length *uint32) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetGpuPciId(nvmlVgpuInstance nvmlVgpuInstance, VgpuPciId *byte, Length *uint32) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cVgpuPciId, _ := (*C.char)(unsafe.Pointer(VgpuPciId)), cgoAllocsUnknown cLength, _ := (*C.uint)(unsafe.Pointer(Length)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetGpuPciId(cVgpuInstance, cVgpuPciId, cLength) + __ret := C.nvmlVgpuInstanceGetGpuPciId(cnvmlVgpuInstance, cVgpuPciId, cLength) __v := (Return)(__ret) return __v } // nvmlVgpuTypeGetCapabilities function as declared in nvml/nvml.h -func nvmlVgpuTypeGetCapabilities(VgpuTypeId VgpuTypeId, Capability VgpuCapability, CapResult *uint32) Return { - cVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(VgpuTypeId), cgoAllocsUnknown +func nvmlVgpuTypeGetCapabilities(nvmlVgpuTypeId nvmlVgpuTypeId, Capability VgpuCapability, CapResult *uint32) Return { + cnvmlVgpuTypeId, _ := (C.nvmlVgpuTypeId_t)(nvmlVgpuTypeId), cgoAllocsUnknown cCapability, _ := (C.nvmlVgpuCapability_t)(Capability), cgoAllocsUnknown cCapResult, _ := (*C.uint)(unsafe.Pointer(CapResult)), cgoAllocsUnknown - __ret := C.nvmlVgpuTypeGetCapabilities(cVgpuTypeId, cCapability, cCapResult) + __ret := C.nvmlVgpuTypeGetCapabilities(cnvmlVgpuTypeId, cCapability, cCapResult) + __v := (Return)(__ret) + return __v +} + +// nvmlVgpuInstanceGetMdevUUID function as declared in nvml/nvml.h +func nvmlVgpuInstanceGetMdevUUID(nvmlVgpuInstance nvmlVgpuInstance, MdevUuid *byte, Size uint32) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown + cMdevUuid, _ := (*C.char)(unsafe.Pointer(MdevUuid)), cgoAllocsUnknown + cSize, _ := (C.uint)(Size), cgoAllocsUnknown + __ret := C.nvmlVgpuInstanceGetMdevUUID(cnvmlVgpuInstance, cMdevUuid, cSize) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetMetadata function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetMetadata(VgpuInstance VgpuInstance, nvmlVgpuMetadata *nvmlVgpuMetadata, BufferSize *uint32) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetMetadata(nvmlVgpuInstance nvmlVgpuInstance, nvmlVgpuMetadata *nvmlVgpuMetadata, BufferSize *uint32) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cnvmlVgpuMetadata, _ := (*C.nvmlVgpuMetadata_t)(unsafe.Pointer(nvmlVgpuMetadata)), cgoAllocsUnknown cBufferSize, _ := (*C.uint)(unsafe.Pointer(BufferSize)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetMetadata(cVgpuInstance, cnvmlVgpuMetadata, cBufferSize) + __ret := C.nvmlVgpuInstanceGetMetadata(cnvmlVgpuInstance, cnvmlVgpuMetadata, cBufferSize) __v := (Return)(__ret) return __v } // nvmlDeviceGetVgpuMetadata function as declared in nvml/nvml.h -func nvmlDeviceGetVgpuMetadata(Device Device, PgpuMetadata *nvmlVgpuPgpuMetadata, BufferSize *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetVgpuMetadata(nvmlDevice nvmlDevice, PgpuMetadata *nvmlVgpuPgpuMetadata, BufferSize *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPgpuMetadata, _ := (*C.nvmlVgpuPgpuMetadata_t)(unsafe.Pointer(PgpuMetadata)), cgoAllocsUnknown cBufferSize, _ := (*C.uint)(unsafe.Pointer(BufferSize)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetVgpuMetadata(cDevice, cPgpuMetadata, cBufferSize) + __ret := C.nvmlDeviceGetVgpuMetadata(cnvmlDevice, cPgpuMetadata, cBufferSize) __v := (Return)(__ret) return __v } @@ -2147,47 +2549,47 @@ func nvmlGetVgpuCompatibility(nvmlVgpuMetadata *nvmlVgpuMetadata, PgpuMetadata * } // nvmlDeviceGetPgpuMetadataString function as declared in nvml/nvml.h -func nvmlDeviceGetPgpuMetadataString(Device Device, PgpuMetadata *byte, BufferSize *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPgpuMetadataString(nvmlDevice nvmlDevice, PgpuMetadata *byte, BufferSize *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPgpuMetadata, _ := (*C.char)(unsafe.Pointer(PgpuMetadata)), cgoAllocsUnknown cBufferSize, _ := (*C.uint)(unsafe.Pointer(BufferSize)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPgpuMetadataString(cDevice, cPgpuMetadata, cBufferSize) + __ret := C.nvmlDeviceGetPgpuMetadataString(cnvmlDevice, cPgpuMetadata, cBufferSize) __v := (Return)(__ret) return __v } // nvmlDeviceGetVgpuSchedulerLog function as declared in nvml/nvml.h -func nvmlDeviceGetVgpuSchedulerLog(Device Device, PSchedulerLog *VgpuSchedulerLog) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetVgpuSchedulerLog(nvmlDevice nvmlDevice, PSchedulerLog *VgpuSchedulerLog) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPSchedulerLog, _ := (*C.nvmlVgpuSchedulerLog_t)(unsafe.Pointer(PSchedulerLog)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetVgpuSchedulerLog(cDevice, cPSchedulerLog) + __ret := C.nvmlDeviceGetVgpuSchedulerLog(cnvmlDevice, cPSchedulerLog) __v := (Return)(__ret) return __v } // nvmlDeviceGetVgpuSchedulerState function as declared in nvml/nvml.h -func nvmlDeviceGetVgpuSchedulerState(Device Device, PSchedulerState *VgpuSchedulerGetState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetVgpuSchedulerState(nvmlDevice nvmlDevice, PSchedulerState *VgpuSchedulerGetState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPSchedulerState, _ := (*C.nvmlVgpuSchedulerGetState_t)(unsafe.Pointer(PSchedulerState)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetVgpuSchedulerState(cDevice, cPSchedulerState) + __ret := C.nvmlDeviceGetVgpuSchedulerState(cnvmlDevice, cPSchedulerState) __v := (Return)(__ret) return __v } -// nvmlDeviceSetVgpuSchedulerState function as declared in nvml/nvml.h -func nvmlDeviceSetVgpuSchedulerState(Device Device, PSchedulerState *VgpuSchedulerSetState) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cPSchedulerState, _ := (*C.nvmlVgpuSchedulerSetState_t)(unsafe.Pointer(PSchedulerState)), cgoAllocsUnknown - __ret := C.nvmlDeviceSetVgpuSchedulerState(cDevice, cPSchedulerState) +// nvmlDeviceGetVgpuSchedulerCapabilities function as declared in nvml/nvml.h +func nvmlDeviceGetVgpuSchedulerCapabilities(nvmlDevice nvmlDevice, PCapabilities *VgpuSchedulerCapabilities) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cPCapabilities, _ := (*C.nvmlVgpuSchedulerCapabilities_t)(unsafe.Pointer(PCapabilities)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetVgpuSchedulerCapabilities(cnvmlDevice, cPCapabilities) __v := (Return)(__ret) return __v } -// nvmlDeviceGetVgpuSchedulerCapabilities function as declared in nvml/nvml.h -func nvmlDeviceGetVgpuSchedulerCapabilities(Device Device, PCapabilities *VgpuSchedulerCapabilities) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cPCapabilities, _ := (*C.nvmlVgpuSchedulerCapabilities_t)(unsafe.Pointer(PCapabilities)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetVgpuSchedulerCapabilities(cDevice, cPCapabilities) +// nvmlDeviceSetVgpuSchedulerState function as declared in nvml/nvml.h +func nvmlDeviceSetVgpuSchedulerState(nvmlDevice nvmlDevice, PSchedulerState *VgpuSchedulerSetState) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cPSchedulerState, _ := (*C.nvmlVgpuSchedulerSetState_t)(unsafe.Pointer(PSchedulerState)), cgoAllocsUnknown + __ret := C.nvmlDeviceSetVgpuSchedulerState(cnvmlDevice, cPSchedulerState) __v := (Return)(__ret) return __v } @@ -2210,70 +2612,88 @@ func nvmlSetVgpuVersion(VgpuVersion *VgpuVersion) Return { } // nvmlDeviceGetVgpuUtilization function as declared in nvml/nvml.h -func nvmlDeviceGetVgpuUtilization(Device Device, LastSeenTimeStamp uint64, SampleValType *ValueType, VgpuInstanceSamplesCount *uint32, UtilizationSamples *VgpuInstanceUtilizationSample) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetVgpuUtilization(nvmlDevice nvmlDevice, LastSeenTimeStamp uint64, SampleValType *ValueType, VgpuInstanceSamplesCount *uint32, UtilizationSamples *VgpuInstanceUtilizationSample) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLastSeenTimeStamp, _ := (C.ulonglong)(LastSeenTimeStamp), cgoAllocsUnknown cSampleValType, _ := (*C.nvmlValueType_t)(unsafe.Pointer(SampleValType)), cgoAllocsUnknown cVgpuInstanceSamplesCount, _ := (*C.uint)(unsafe.Pointer(VgpuInstanceSamplesCount)), cgoAllocsUnknown cUtilizationSamples, _ := (*C.nvmlVgpuInstanceUtilizationSample_t)(unsafe.Pointer(UtilizationSamples)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetVgpuUtilization(cDevice, cLastSeenTimeStamp, cSampleValType, cVgpuInstanceSamplesCount, cUtilizationSamples) + __ret := C.nvmlDeviceGetVgpuUtilization(cnvmlDevice, cLastSeenTimeStamp, cSampleValType, cVgpuInstanceSamplesCount, cUtilizationSamples) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetVgpuInstancesUtilizationInfo function as declared in nvml/nvml.h +func nvmlDeviceGetVgpuInstancesUtilizationInfo(nvmlDevice nvmlDevice, VgpuUtilInfo *VgpuInstancesUtilizationInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cVgpuUtilInfo, _ := (*C.nvmlVgpuInstancesUtilizationInfo_t)(unsafe.Pointer(VgpuUtilInfo)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetVgpuInstancesUtilizationInfo(cnvmlDevice, cVgpuUtilInfo) __v := (Return)(__ret) return __v } // nvmlDeviceGetVgpuProcessUtilization function as declared in nvml/nvml.h -func nvmlDeviceGetVgpuProcessUtilization(Device Device, LastSeenTimeStamp uint64, VgpuProcessSamplesCount *uint32, UtilizationSamples *VgpuProcessUtilizationSample) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetVgpuProcessUtilization(nvmlDevice nvmlDevice, LastSeenTimeStamp uint64, VgpuProcessSamplesCount *uint32, UtilizationSamples *VgpuProcessUtilizationSample) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLastSeenTimeStamp, _ := (C.ulonglong)(LastSeenTimeStamp), cgoAllocsUnknown cVgpuProcessSamplesCount, _ := (*C.uint)(unsafe.Pointer(VgpuProcessSamplesCount)), cgoAllocsUnknown cUtilizationSamples, _ := (*C.nvmlVgpuProcessUtilizationSample_t)(unsafe.Pointer(UtilizationSamples)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetVgpuProcessUtilization(cDevice, cLastSeenTimeStamp, cVgpuProcessSamplesCount, cUtilizationSamples) + __ret := C.nvmlDeviceGetVgpuProcessUtilization(cnvmlDevice, cLastSeenTimeStamp, cVgpuProcessSamplesCount, cUtilizationSamples) + __v := (Return)(__ret) + return __v +} + +// nvmlDeviceGetVgpuProcessesUtilizationInfo function as declared in nvml/nvml.h +func nvmlDeviceGetVgpuProcessesUtilizationInfo(nvmlDevice nvmlDevice, VgpuProcUtilInfo *VgpuProcessesUtilizationInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cVgpuProcUtilInfo, _ := (*C.nvmlVgpuProcessesUtilizationInfo_t)(unsafe.Pointer(VgpuProcUtilInfo)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetVgpuProcessesUtilizationInfo(cnvmlDevice, cVgpuProcUtilInfo) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetAccountingMode function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetAccountingMode(VgpuInstance VgpuInstance, Mode *EnableState) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetAccountingMode(nvmlVgpuInstance nvmlVgpuInstance, Mode *EnableState) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cMode, _ := (*C.nvmlEnableState_t)(unsafe.Pointer(Mode)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetAccountingMode(cVgpuInstance, cMode) + __ret := C.nvmlVgpuInstanceGetAccountingMode(cnvmlVgpuInstance, cMode) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetAccountingPids function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetAccountingPids(VgpuInstance VgpuInstance, Count *uint32, Pids *uint32) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetAccountingPids(nvmlVgpuInstance nvmlVgpuInstance, Count *uint32, Pids *uint32) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown cPids, _ := (*C.uint)(unsafe.Pointer(Pids)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetAccountingPids(cVgpuInstance, cCount, cPids) + __ret := C.nvmlVgpuInstanceGetAccountingPids(cnvmlVgpuInstance, cCount, cPids) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetAccountingStats function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetAccountingStats(VgpuInstance VgpuInstance, Pid uint32, Stats *AccountingStats) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetAccountingStats(nvmlVgpuInstance nvmlVgpuInstance, Pid uint32, Stats *AccountingStats) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cPid, _ := (C.uint)(Pid), cgoAllocsUnknown cStats, _ := (*C.nvmlAccountingStats_t)(unsafe.Pointer(Stats)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetAccountingStats(cVgpuInstance, cPid, cStats) + __ret := C.nvmlVgpuInstanceGetAccountingStats(cnvmlVgpuInstance, cPid, cStats) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceClearAccountingPids function as declared in nvml/nvml.h -func nvmlVgpuInstanceClearAccountingPids(VgpuInstance VgpuInstance) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceClearAccountingPids(cVgpuInstance) +func nvmlVgpuInstanceClearAccountingPids(nvmlVgpuInstance nvmlVgpuInstance) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown + __ret := C.nvmlVgpuInstanceClearAccountingPids(cnvmlVgpuInstance) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetLicenseInfo_v2 function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetLicenseInfo_v2(VgpuInstance VgpuInstance, LicenseInfo *VgpuLicenseInfo) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetLicenseInfo_v2(nvmlVgpuInstance nvmlVgpuInstance, LicenseInfo *VgpuLicenseInfo) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cLicenseInfo, _ := (*C.nvmlVgpuLicenseInfo_t)(unsafe.Pointer(LicenseInfo)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetLicenseInfo_v2(cVgpuInstance, cLicenseInfo) + __ret := C.nvmlVgpuInstanceGetLicenseInfo_v2(cnvmlVgpuInstance, cLicenseInfo) __v := (Return)(__ret) return __v } @@ -2296,472 +2716,391 @@ func nvmlGetExcludedDeviceInfoByIndex(Index uint32, Info *ExcludedDeviceInfo) Re } // nvmlDeviceSetMigMode function as declared in nvml/nvml.h -func nvmlDeviceSetMigMode(Device Device, Mode uint32, ActivationStatus *Return) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceSetMigMode(nvmlDevice nvmlDevice, Mode uint32, ActivationStatus *Return) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cMode, _ := (C.uint)(Mode), cgoAllocsUnknown cActivationStatus, _ := (*C.nvmlReturn_t)(unsafe.Pointer(ActivationStatus)), cgoAllocsUnknown - __ret := C.nvmlDeviceSetMigMode(cDevice, cMode, cActivationStatus) + __ret := C.nvmlDeviceSetMigMode(cnvmlDevice, cMode, cActivationStatus) __v := (Return)(__ret) return __v } // nvmlDeviceGetMigMode function as declared in nvml/nvml.h -func nvmlDeviceGetMigMode(Device Device, CurrentMode *uint32, PendingMode *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMigMode(nvmlDevice nvmlDevice, CurrentMode *uint32, PendingMode *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCurrentMode, _ := (*C.uint)(unsafe.Pointer(CurrentMode)), cgoAllocsUnknown cPendingMode, _ := (*C.uint)(unsafe.Pointer(PendingMode)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMigMode(cDevice, cCurrentMode, cPendingMode) + __ret := C.nvmlDeviceGetMigMode(cnvmlDevice, cCurrentMode, cPendingMode) __v := (Return)(__ret) return __v } // nvmlDeviceGetGpuInstanceProfileInfo function as declared in nvml/nvml.h -func nvmlDeviceGetGpuInstanceProfileInfo(Device Device, Profile uint32, Info *GpuInstanceProfileInfo) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGpuInstanceProfileInfo(nvmlDevice nvmlDevice, Profile uint32, Info *GpuInstanceProfileInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cProfile, _ := (C.uint)(Profile), cgoAllocsUnknown cInfo, _ := (*C.nvmlGpuInstanceProfileInfo_t)(unsafe.Pointer(Info)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGpuInstanceProfileInfo(cDevice, cProfile, cInfo) + __ret := C.nvmlDeviceGetGpuInstanceProfileInfo(cnvmlDevice, cProfile, cInfo) __v := (Return)(__ret) return __v } // nvmlDeviceGetGpuInstanceProfileInfoV function as declared in nvml/nvml.h -func nvmlDeviceGetGpuInstanceProfileInfoV(Device Device, Profile uint32, Info *GpuInstanceProfileInfo_v2) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGpuInstanceProfileInfoV(nvmlDevice nvmlDevice, Profile uint32, Info *GpuInstanceProfileInfo_v2) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cProfile, _ := (C.uint)(Profile), cgoAllocsUnknown cInfo, _ := (*C.nvmlGpuInstanceProfileInfo_v2_t)(unsafe.Pointer(Info)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGpuInstanceProfileInfoV(cDevice, cProfile, cInfo) + __ret := C.nvmlDeviceGetGpuInstanceProfileInfoV(cnvmlDevice, cProfile, cInfo) __v := (Return)(__ret) return __v } // nvmlDeviceGetGpuInstancePossiblePlacements_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetGpuInstancePossiblePlacements_v2(Device Device, ProfileId uint32, Placements *GpuInstancePlacement, Count *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGpuInstancePossiblePlacements_v2(nvmlDevice nvmlDevice, ProfileId uint32, Placements *GpuInstancePlacement, Count *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cProfileId, _ := (C.uint)(ProfileId), cgoAllocsUnknown cPlacements, _ := (*C.nvmlGpuInstancePlacement_t)(unsafe.Pointer(Placements)), cgoAllocsUnknown cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGpuInstancePossiblePlacements_v2(cDevice, cProfileId, cPlacements, cCount) + __ret := C.nvmlDeviceGetGpuInstancePossiblePlacements_v2(cnvmlDevice, cProfileId, cPlacements, cCount) __v := (Return)(__ret) return __v } // nvmlDeviceGetGpuInstanceRemainingCapacity function as declared in nvml/nvml.h -func nvmlDeviceGetGpuInstanceRemainingCapacity(Device Device, ProfileId uint32, Count *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGpuInstanceRemainingCapacity(nvmlDevice nvmlDevice, ProfileId uint32, Count *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cProfileId, _ := (C.uint)(ProfileId), cgoAllocsUnknown cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGpuInstanceRemainingCapacity(cDevice, cProfileId, cCount) + __ret := C.nvmlDeviceGetGpuInstanceRemainingCapacity(cnvmlDevice, cProfileId, cCount) __v := (Return)(__ret) return __v } // nvmlDeviceCreateGpuInstance function as declared in nvml/nvml.h -func nvmlDeviceCreateGpuInstance(Device Device, ProfileId uint32, GpuInstance *GpuInstance) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceCreateGpuInstance(nvmlDevice nvmlDevice, ProfileId uint32, nvmlGpuInstance *nvmlGpuInstance) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cProfileId, _ := (C.uint)(ProfileId), cgoAllocsUnknown - cGpuInstance, _ := (*C.nvmlGpuInstance_t)(unsafe.Pointer(GpuInstance)), cgoAllocsUnknown - __ret := C.nvmlDeviceCreateGpuInstance(cDevice, cProfileId, cGpuInstance) + cnvmlGpuInstance, _ := (*C.nvmlGpuInstance_t)(unsafe.Pointer(nvmlGpuInstance)), cgoAllocsUnknown + __ret := C.nvmlDeviceCreateGpuInstance(cnvmlDevice, cProfileId, cnvmlGpuInstance) __v := (Return)(__ret) return __v } // nvmlDeviceCreateGpuInstanceWithPlacement function as declared in nvml/nvml.h -func nvmlDeviceCreateGpuInstanceWithPlacement(Device Device, ProfileId uint32, Placement *GpuInstancePlacement, GpuInstance *GpuInstance) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceCreateGpuInstanceWithPlacement(nvmlDevice nvmlDevice, ProfileId uint32, Placement *GpuInstancePlacement, nvmlGpuInstance *nvmlGpuInstance) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cProfileId, _ := (C.uint)(ProfileId), cgoAllocsUnknown cPlacement, _ := (*C.nvmlGpuInstancePlacement_t)(unsafe.Pointer(Placement)), cgoAllocsUnknown - cGpuInstance, _ := (*C.nvmlGpuInstance_t)(unsafe.Pointer(GpuInstance)), cgoAllocsUnknown - __ret := C.nvmlDeviceCreateGpuInstanceWithPlacement(cDevice, cProfileId, cPlacement, cGpuInstance) + cnvmlGpuInstance, _ := (*C.nvmlGpuInstance_t)(unsafe.Pointer(nvmlGpuInstance)), cgoAllocsUnknown + __ret := C.nvmlDeviceCreateGpuInstanceWithPlacement(cnvmlDevice, cProfileId, cPlacement, cnvmlGpuInstance) __v := (Return)(__ret) return __v } // nvmlGpuInstanceDestroy function as declared in nvml/nvml.h -func nvmlGpuInstanceDestroy(GpuInstance GpuInstance) Return { - cGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&GpuInstance)), cgoAllocsUnknown - __ret := C.nvmlGpuInstanceDestroy(cGpuInstance) +func nvmlGpuInstanceDestroy(nvmlGpuInstance nvmlGpuInstance) Return { + cnvmlGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&nvmlGpuInstance)), cgoAllocsUnknown + __ret := C.nvmlGpuInstanceDestroy(cnvmlGpuInstance) __v := (Return)(__ret) return __v } // nvmlDeviceGetGpuInstances function as declared in nvml/nvml.h -func nvmlDeviceGetGpuInstances(Device Device, ProfileId uint32, GpuInstances *GpuInstance, Count *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGpuInstances(nvmlDevice nvmlDevice, ProfileId uint32, GpuInstances *nvmlGpuInstance, Count *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cProfileId, _ := (C.uint)(ProfileId), cgoAllocsUnknown cGpuInstances, _ := (*C.nvmlGpuInstance_t)(unsafe.Pointer(GpuInstances)), cgoAllocsUnknown cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGpuInstances(cDevice, cProfileId, cGpuInstances, cCount) + __ret := C.nvmlDeviceGetGpuInstances(cnvmlDevice, cProfileId, cGpuInstances, cCount) __v := (Return)(__ret) return __v } // nvmlDeviceGetGpuInstanceById function as declared in nvml/nvml.h -func nvmlDeviceGetGpuInstanceById(Device Device, Id uint32, GpuInstance *GpuInstance) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGpuInstanceById(nvmlDevice nvmlDevice, Id uint32, nvmlGpuInstance *nvmlGpuInstance) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cId, _ := (C.uint)(Id), cgoAllocsUnknown - cGpuInstance, _ := (*C.nvmlGpuInstance_t)(unsafe.Pointer(GpuInstance)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGpuInstanceById(cDevice, cId, cGpuInstance) + cnvmlGpuInstance, _ := (*C.nvmlGpuInstance_t)(unsafe.Pointer(nvmlGpuInstance)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetGpuInstanceById(cnvmlDevice, cId, cnvmlGpuInstance) __v := (Return)(__ret) return __v } // nvmlGpuInstanceGetInfo function as declared in nvml/nvml.h -func nvmlGpuInstanceGetInfo(GpuInstance GpuInstance, Info *GpuInstanceInfo) Return { - cGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&GpuInstance)), cgoAllocsUnknown +func nvmlGpuInstanceGetInfo(nvmlGpuInstance nvmlGpuInstance, Info *nvmlGpuInstanceInfo) Return { + cnvmlGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&nvmlGpuInstance)), cgoAllocsUnknown cInfo, _ := (*C.nvmlGpuInstanceInfo_t)(unsafe.Pointer(Info)), cgoAllocsUnknown - __ret := C.nvmlGpuInstanceGetInfo(cGpuInstance, cInfo) + __ret := C.nvmlGpuInstanceGetInfo(cnvmlGpuInstance, cInfo) __v := (Return)(__ret) return __v } // nvmlGpuInstanceGetComputeInstanceProfileInfo function as declared in nvml/nvml.h -func nvmlGpuInstanceGetComputeInstanceProfileInfo(GpuInstance GpuInstance, Profile uint32, EngProfile uint32, Info *ComputeInstanceProfileInfo) Return { - cGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&GpuInstance)), cgoAllocsUnknown +func nvmlGpuInstanceGetComputeInstanceProfileInfo(nvmlGpuInstance nvmlGpuInstance, Profile uint32, EngProfile uint32, Info *ComputeInstanceProfileInfo) Return { + cnvmlGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&nvmlGpuInstance)), cgoAllocsUnknown cProfile, _ := (C.uint)(Profile), cgoAllocsUnknown cEngProfile, _ := (C.uint)(EngProfile), cgoAllocsUnknown cInfo, _ := (*C.nvmlComputeInstanceProfileInfo_t)(unsafe.Pointer(Info)), cgoAllocsUnknown - __ret := C.nvmlGpuInstanceGetComputeInstanceProfileInfo(cGpuInstance, cProfile, cEngProfile, cInfo) + __ret := C.nvmlGpuInstanceGetComputeInstanceProfileInfo(cnvmlGpuInstance, cProfile, cEngProfile, cInfo) __v := (Return)(__ret) return __v } // nvmlGpuInstanceGetComputeInstanceProfileInfoV function as declared in nvml/nvml.h -func nvmlGpuInstanceGetComputeInstanceProfileInfoV(GpuInstance GpuInstance, Profile uint32, EngProfile uint32, Info *ComputeInstanceProfileInfo_v2) Return { - cGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&GpuInstance)), cgoAllocsUnknown +func nvmlGpuInstanceGetComputeInstanceProfileInfoV(nvmlGpuInstance nvmlGpuInstance, Profile uint32, EngProfile uint32, Info *ComputeInstanceProfileInfo_v2) Return { + cnvmlGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&nvmlGpuInstance)), cgoAllocsUnknown cProfile, _ := (C.uint)(Profile), cgoAllocsUnknown cEngProfile, _ := (C.uint)(EngProfile), cgoAllocsUnknown cInfo, _ := (*C.nvmlComputeInstanceProfileInfo_v2_t)(unsafe.Pointer(Info)), cgoAllocsUnknown - __ret := C.nvmlGpuInstanceGetComputeInstanceProfileInfoV(cGpuInstance, cProfile, cEngProfile, cInfo) + __ret := C.nvmlGpuInstanceGetComputeInstanceProfileInfoV(cnvmlGpuInstance, cProfile, cEngProfile, cInfo) __v := (Return)(__ret) return __v } // nvmlGpuInstanceGetComputeInstanceRemainingCapacity function as declared in nvml/nvml.h -func nvmlGpuInstanceGetComputeInstanceRemainingCapacity(GpuInstance GpuInstance, ProfileId uint32, Count *uint32) Return { - cGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&GpuInstance)), cgoAllocsUnknown +func nvmlGpuInstanceGetComputeInstanceRemainingCapacity(nvmlGpuInstance nvmlGpuInstance, ProfileId uint32, Count *uint32) Return { + cnvmlGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&nvmlGpuInstance)), cgoAllocsUnknown cProfileId, _ := (C.uint)(ProfileId), cgoAllocsUnknown cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown - __ret := C.nvmlGpuInstanceGetComputeInstanceRemainingCapacity(cGpuInstance, cProfileId, cCount) + __ret := C.nvmlGpuInstanceGetComputeInstanceRemainingCapacity(cnvmlGpuInstance, cProfileId, cCount) __v := (Return)(__ret) return __v } // nvmlGpuInstanceGetComputeInstancePossiblePlacements function as declared in nvml/nvml.h -func nvmlGpuInstanceGetComputeInstancePossiblePlacements(GpuInstance GpuInstance, ProfileId uint32, Placements *ComputeInstancePlacement, Count *uint32) Return { - cGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&GpuInstance)), cgoAllocsUnknown +func nvmlGpuInstanceGetComputeInstancePossiblePlacements(nvmlGpuInstance nvmlGpuInstance, ProfileId uint32, Placements *ComputeInstancePlacement, Count *uint32) Return { + cnvmlGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&nvmlGpuInstance)), cgoAllocsUnknown cProfileId, _ := (C.uint)(ProfileId), cgoAllocsUnknown cPlacements, _ := (*C.nvmlComputeInstancePlacement_t)(unsafe.Pointer(Placements)), cgoAllocsUnknown cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown - __ret := C.nvmlGpuInstanceGetComputeInstancePossiblePlacements(cGpuInstance, cProfileId, cPlacements, cCount) + __ret := C.nvmlGpuInstanceGetComputeInstancePossiblePlacements(cnvmlGpuInstance, cProfileId, cPlacements, cCount) __v := (Return)(__ret) return __v } // nvmlGpuInstanceCreateComputeInstance function as declared in nvml/nvml.h -func nvmlGpuInstanceCreateComputeInstance(GpuInstance GpuInstance, ProfileId uint32, ComputeInstance *ComputeInstance) Return { - cGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&GpuInstance)), cgoAllocsUnknown +func nvmlGpuInstanceCreateComputeInstance(nvmlGpuInstance nvmlGpuInstance, ProfileId uint32, nvmlComputeInstance *nvmlComputeInstance) Return { + cnvmlGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&nvmlGpuInstance)), cgoAllocsUnknown cProfileId, _ := (C.uint)(ProfileId), cgoAllocsUnknown - cComputeInstance, _ := (*C.nvmlComputeInstance_t)(unsafe.Pointer(ComputeInstance)), cgoAllocsUnknown - __ret := C.nvmlGpuInstanceCreateComputeInstance(cGpuInstance, cProfileId, cComputeInstance) + cnvmlComputeInstance, _ := (*C.nvmlComputeInstance_t)(unsafe.Pointer(nvmlComputeInstance)), cgoAllocsUnknown + __ret := C.nvmlGpuInstanceCreateComputeInstance(cnvmlGpuInstance, cProfileId, cnvmlComputeInstance) __v := (Return)(__ret) return __v } // nvmlGpuInstanceCreateComputeInstanceWithPlacement function as declared in nvml/nvml.h -func nvmlGpuInstanceCreateComputeInstanceWithPlacement(GpuInstance GpuInstance, ProfileId uint32, Placement *ComputeInstancePlacement, ComputeInstance *ComputeInstance) Return { - cGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&GpuInstance)), cgoAllocsUnknown +func nvmlGpuInstanceCreateComputeInstanceWithPlacement(nvmlGpuInstance nvmlGpuInstance, ProfileId uint32, Placement *ComputeInstancePlacement, nvmlComputeInstance *nvmlComputeInstance) Return { + cnvmlGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&nvmlGpuInstance)), cgoAllocsUnknown cProfileId, _ := (C.uint)(ProfileId), cgoAllocsUnknown cPlacement, _ := (*C.nvmlComputeInstancePlacement_t)(unsafe.Pointer(Placement)), cgoAllocsUnknown - cComputeInstance, _ := (*C.nvmlComputeInstance_t)(unsafe.Pointer(ComputeInstance)), cgoAllocsUnknown - __ret := C.nvmlGpuInstanceCreateComputeInstanceWithPlacement(cGpuInstance, cProfileId, cPlacement, cComputeInstance) + cnvmlComputeInstance, _ := (*C.nvmlComputeInstance_t)(unsafe.Pointer(nvmlComputeInstance)), cgoAllocsUnknown + __ret := C.nvmlGpuInstanceCreateComputeInstanceWithPlacement(cnvmlGpuInstance, cProfileId, cPlacement, cnvmlComputeInstance) __v := (Return)(__ret) return __v } // nvmlComputeInstanceDestroy function as declared in nvml/nvml.h -func nvmlComputeInstanceDestroy(ComputeInstance ComputeInstance) Return { - cComputeInstance, _ := *(*C.nvmlComputeInstance_t)(unsafe.Pointer(&ComputeInstance)), cgoAllocsUnknown - __ret := C.nvmlComputeInstanceDestroy(cComputeInstance) +func nvmlComputeInstanceDestroy(nvmlComputeInstance nvmlComputeInstance) Return { + cnvmlComputeInstance, _ := *(*C.nvmlComputeInstance_t)(unsafe.Pointer(&nvmlComputeInstance)), cgoAllocsUnknown + __ret := C.nvmlComputeInstanceDestroy(cnvmlComputeInstance) __v := (Return)(__ret) return __v } // nvmlGpuInstanceGetComputeInstances function as declared in nvml/nvml.h -func nvmlGpuInstanceGetComputeInstances(GpuInstance GpuInstance, ProfileId uint32, ComputeInstances *ComputeInstance, Count *uint32) Return { - cGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&GpuInstance)), cgoAllocsUnknown +func nvmlGpuInstanceGetComputeInstances(nvmlGpuInstance nvmlGpuInstance, ProfileId uint32, ComputeInstances *nvmlComputeInstance, Count *uint32) Return { + cnvmlGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&nvmlGpuInstance)), cgoAllocsUnknown cProfileId, _ := (C.uint)(ProfileId), cgoAllocsUnknown cComputeInstances, _ := (*C.nvmlComputeInstance_t)(unsafe.Pointer(ComputeInstances)), cgoAllocsUnknown cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown - __ret := C.nvmlGpuInstanceGetComputeInstances(cGpuInstance, cProfileId, cComputeInstances, cCount) + __ret := C.nvmlGpuInstanceGetComputeInstances(cnvmlGpuInstance, cProfileId, cComputeInstances, cCount) __v := (Return)(__ret) return __v } // nvmlGpuInstanceGetComputeInstanceById function as declared in nvml/nvml.h -func nvmlGpuInstanceGetComputeInstanceById(GpuInstance GpuInstance, Id uint32, ComputeInstance *ComputeInstance) Return { - cGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&GpuInstance)), cgoAllocsUnknown +func nvmlGpuInstanceGetComputeInstanceById(nvmlGpuInstance nvmlGpuInstance, Id uint32, nvmlComputeInstance *nvmlComputeInstance) Return { + cnvmlGpuInstance, _ := *(*C.nvmlGpuInstance_t)(unsafe.Pointer(&nvmlGpuInstance)), cgoAllocsUnknown cId, _ := (C.uint)(Id), cgoAllocsUnknown - cComputeInstance, _ := (*C.nvmlComputeInstance_t)(unsafe.Pointer(ComputeInstance)), cgoAllocsUnknown - __ret := C.nvmlGpuInstanceGetComputeInstanceById(cGpuInstance, cId, cComputeInstance) + cnvmlComputeInstance, _ := (*C.nvmlComputeInstance_t)(unsafe.Pointer(nvmlComputeInstance)), cgoAllocsUnknown + __ret := C.nvmlGpuInstanceGetComputeInstanceById(cnvmlGpuInstance, cId, cnvmlComputeInstance) __v := (Return)(__ret) return __v } // nvmlComputeInstanceGetInfo_v2 function as declared in nvml/nvml.h -func nvmlComputeInstanceGetInfo_v2(ComputeInstance ComputeInstance, Info *ComputeInstanceInfo) Return { - cComputeInstance, _ := *(*C.nvmlComputeInstance_t)(unsafe.Pointer(&ComputeInstance)), cgoAllocsUnknown +func nvmlComputeInstanceGetInfo_v2(nvmlComputeInstance nvmlComputeInstance, Info *nvmlComputeInstanceInfo) Return { + cnvmlComputeInstance, _ := *(*C.nvmlComputeInstance_t)(unsafe.Pointer(&nvmlComputeInstance)), cgoAllocsUnknown cInfo, _ := (*C.nvmlComputeInstanceInfo_t)(unsafe.Pointer(Info)), cgoAllocsUnknown - __ret := C.nvmlComputeInstanceGetInfo_v2(cComputeInstance, cInfo) + __ret := C.nvmlComputeInstanceGetInfo_v2(cnvmlComputeInstance, cInfo) __v := (Return)(__ret) return __v } // nvmlDeviceIsMigDeviceHandle function as declared in nvml/nvml.h -func nvmlDeviceIsMigDeviceHandle(Device Device, IsMigDevice *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceIsMigDeviceHandle(nvmlDevice nvmlDevice, IsMigDevice *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cIsMigDevice, _ := (*C.uint)(unsafe.Pointer(IsMigDevice)), cgoAllocsUnknown - __ret := C.nvmlDeviceIsMigDeviceHandle(cDevice, cIsMigDevice) + __ret := C.nvmlDeviceIsMigDeviceHandle(cnvmlDevice, cIsMigDevice) __v := (Return)(__ret) return __v } // nvmlDeviceGetGpuInstanceId function as declared in nvml/nvml.h -func nvmlDeviceGetGpuInstanceId(Device Device, Id *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGpuInstanceId(nvmlDevice nvmlDevice, Id *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cId, _ := (*C.uint)(unsafe.Pointer(Id)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGpuInstanceId(cDevice, cId) + __ret := C.nvmlDeviceGetGpuInstanceId(cnvmlDevice, cId) __v := (Return)(__ret) return __v } // nvmlDeviceGetComputeInstanceId function as declared in nvml/nvml.h -func nvmlDeviceGetComputeInstanceId(Device Device, Id *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetComputeInstanceId(nvmlDevice nvmlDevice, Id *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cId, _ := (*C.uint)(unsafe.Pointer(Id)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetComputeInstanceId(cDevice, cId) + __ret := C.nvmlDeviceGetComputeInstanceId(cnvmlDevice, cId) __v := (Return)(__ret) return __v } // nvmlDeviceGetMaxMigDeviceCount function as declared in nvml/nvml.h -func nvmlDeviceGetMaxMigDeviceCount(Device Device, Count *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMaxMigDeviceCount(nvmlDevice nvmlDevice, Count *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMaxMigDeviceCount(cDevice, cCount) + __ret := C.nvmlDeviceGetMaxMigDeviceCount(cnvmlDevice, cCount) __v := (Return)(__ret) return __v } // nvmlDeviceGetMigDeviceHandleByIndex function as declared in nvml/nvml.h -func nvmlDeviceGetMigDeviceHandleByIndex(Device Device, Index uint32, MigDevice *Device) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMigDeviceHandleByIndex(nvmlDevice nvmlDevice, Index uint32, MigDevice *nvmlDevice) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cIndex, _ := (C.uint)(Index), cgoAllocsUnknown cMigDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(MigDevice)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMigDeviceHandleByIndex(cDevice, cIndex, cMigDevice) + __ret := C.nvmlDeviceGetMigDeviceHandleByIndex(cnvmlDevice, cIndex, cMigDevice) __v := (Return)(__ret) return __v } // nvmlDeviceGetDeviceHandleFromMigDeviceHandle function as declared in nvml/nvml.h -func nvmlDeviceGetDeviceHandleFromMigDeviceHandle(MigDevice Device, Device *Device) Return { +func nvmlDeviceGetDeviceHandleFromMigDeviceHandle(MigDevice nvmlDevice, nvmlDevice *nvmlDevice) Return { cMigDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&MigDevice)), cgoAllocsUnknown - cDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetDeviceHandleFromMigDeviceHandle(cMigDevice, cDevice) - __v := (Return)(__ret) - return __v -} - -// nvmlDeviceGetBusType function as declared in nvml/nvml.h -func nvmlDeviceGetBusType(Device Device, _type *BusType) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - c_type, _ := (*C.nvmlBusType_t)(unsafe.Pointer(_type)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetBusType(cDevice, c_type) - __v := (Return)(__ret) - return __v -} - -// nvmlDeviceGetDynamicPstatesInfo function as declared in nvml/nvml.h -func nvmlDeviceGetDynamicPstatesInfo(Device Device, PDynamicPstatesInfo *GpuDynamicPstatesInfo) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cPDynamicPstatesInfo, _ := (*C.nvmlGpuDynamicPstatesInfo_t)(unsafe.Pointer(PDynamicPstatesInfo)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetDynamicPstatesInfo(cDevice, cPDynamicPstatesInfo) - __v := (Return)(__ret) - return __v -} - -// nvmlDeviceSetFanSpeed_v2 function as declared in nvml/nvml.h -func nvmlDeviceSetFanSpeed_v2(Device Device, Fan uint32, Speed uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cFan, _ := (C.uint)(Fan), cgoAllocsUnknown - cSpeed, _ := (C.uint)(Speed), cgoAllocsUnknown - __ret := C.nvmlDeviceSetFanSpeed_v2(cDevice, cFan, cSpeed) - __v := (Return)(__ret) - return __v -} - -// nvmlDeviceGetGpcClkVfOffset function as declared in nvml/nvml.h -func nvmlDeviceGetGpcClkVfOffset(Device Device, Offset *int32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cOffset, _ := (*C.int)(unsafe.Pointer(Offset)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGpcClkVfOffset(cDevice, cOffset) - __v := (Return)(__ret) - return __v -} - -// nvmlDeviceSetGpcClkVfOffset function as declared in nvml/nvml.h -func nvmlDeviceSetGpcClkVfOffset(Device Device, Offset int32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cOffset, _ := (C.int)(Offset), cgoAllocsUnknown - __ret := C.nvmlDeviceSetGpcClkVfOffset(cDevice, cOffset) - __v := (Return)(__ret) - return __v -} - -// nvmlDeviceGetMemClkVfOffset function as declared in nvml/nvml.h -func nvmlDeviceGetMemClkVfOffset(Device Device, Offset *int32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cOffset, _ := (*C.int)(unsafe.Pointer(Offset)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMemClkVfOffset(cDevice, cOffset) - __v := (Return)(__ret) - return __v -} - -// nvmlDeviceSetMemClkVfOffset function as declared in nvml/nvml.h -func nvmlDeviceSetMemClkVfOffset(Device Device, Offset int32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cOffset, _ := (C.int)(Offset), cgoAllocsUnknown - __ret := C.nvmlDeviceSetMemClkVfOffset(cDevice, cOffset) - __v := (Return)(__ret) - return __v -} - -// nvmlDeviceGetMinMaxClockOfPState function as declared in nvml/nvml.h -func nvmlDeviceGetMinMaxClockOfPState(Device Device, _type ClockType, Pstate Pstates, MinClockMHz *uint32, MaxClockMHz *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - c_type, _ := (C.nvmlClockType_t)(_type), cgoAllocsUnknown - cPstate, _ := (C.nvmlPstates_t)(Pstate), cgoAllocsUnknown - cMinClockMHz, _ := (*C.uint)(unsafe.Pointer(MinClockMHz)), cgoAllocsUnknown - cMaxClockMHz, _ := (*C.uint)(unsafe.Pointer(MaxClockMHz)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMinMaxClockOfPState(cDevice, c_type, cPstate, cMinClockMHz, cMaxClockMHz) + cnvmlDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetDeviceHandleFromMigDeviceHandle(cMigDevice, cnvmlDevice) __v := (Return)(__ret) return __v } -// nvmlDeviceGetSupportedPerformanceStates function as declared in nvml/nvml.h -func nvmlDeviceGetSupportedPerformanceStates(Device Device, Pstates *Pstates, Size uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cPstates, _ := (*C.nvmlPstates_t)(unsafe.Pointer(Pstates)), cgoAllocsUnknown - cSize, _ := (C.uint)(Size), cgoAllocsUnknown - __ret := C.nvmlDeviceGetSupportedPerformanceStates(cDevice, cPstates, cSize) +// nvmlGpmMetricsGet function as declared in nvml/nvml.h +func nvmlGpmMetricsGet(MetricsGet *nvmlGpmMetricsGetType) Return { + cMetricsGet, _ := (*C.nvmlGpmMetricsGet_t)(unsafe.Pointer(MetricsGet)), cgoAllocsUnknown + __ret := C.nvmlGpmMetricsGet(cMetricsGet) __v := (Return)(__ret) return __v } -// nvmlDeviceGetGpcClkMinMaxVfOffset function as declared in nvml/nvml.h -func nvmlDeviceGetGpcClkMinMaxVfOffset(Device Device, MinOffset *int32, MaxOffset *int32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cMinOffset, _ := (*C.int)(unsafe.Pointer(MinOffset)), cgoAllocsUnknown - cMaxOffset, _ := (*C.int)(unsafe.Pointer(MaxOffset)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGpcClkMinMaxVfOffset(cDevice, cMinOffset, cMaxOffset) +// nvmlGpmSampleFree function as declared in nvml/nvml.h +func nvmlGpmSampleFree(nvmlGpmSample nvmlGpmSample) Return { + cnvmlGpmSample, _ := *(*C.nvmlGpmSample_t)(unsafe.Pointer(&nvmlGpmSample)), cgoAllocsUnknown + __ret := C.nvmlGpmSampleFree(cnvmlGpmSample) __v := (Return)(__ret) return __v } -// nvmlDeviceGetMemClkMinMaxVfOffset function as declared in nvml/nvml.h -func nvmlDeviceGetMemClkMinMaxVfOffset(Device Device, MinOffset *int32, MaxOffset *int32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cMinOffset, _ := (*C.int)(unsafe.Pointer(MinOffset)), cgoAllocsUnknown - cMaxOffset, _ := (*C.int)(unsafe.Pointer(MaxOffset)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMemClkMinMaxVfOffset(cDevice, cMinOffset, cMaxOffset) +// nvmlGpmSampleAlloc function as declared in nvml/nvml.h +func nvmlGpmSampleAlloc(nvmlGpmSample *nvmlGpmSample) Return { + cnvmlGpmSample, _ := (*C.nvmlGpmSample_t)(unsafe.Pointer(nvmlGpmSample)), cgoAllocsUnknown + __ret := C.nvmlGpmSampleAlloc(cnvmlGpmSample) __v := (Return)(__ret) return __v } -// nvmlDeviceGetGpuFabricInfo function as declared in nvml/nvml.h -func nvmlDeviceGetGpuFabricInfo(Device Device, GpuFabricInfo *GpuFabricInfo) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cGpuFabricInfo, _ := (*C.nvmlGpuFabricInfo_t)(unsafe.Pointer(GpuFabricInfo)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGpuFabricInfo(cDevice, cGpuFabricInfo) +// nvmlGpmSampleGet function as declared in nvml/nvml.h +func nvmlGpmSampleGet(nvmlDevice nvmlDevice, nvmlGpmSample nvmlGpmSample) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cnvmlGpmSample, _ := *(*C.nvmlGpmSample_t)(unsafe.Pointer(&nvmlGpmSample)), cgoAllocsUnknown + __ret := C.nvmlGpmSampleGet(cnvmlDevice, cnvmlGpmSample) __v := (Return)(__ret) return __v } -// nvmlGpmMetricsGet function as declared in nvml/nvml.h -func nvmlGpmMetricsGet(MetricsGet *GpmMetricsGetType) Return { - cMetricsGet, _ := (*C.nvmlGpmMetricsGet_t)(unsafe.Pointer(MetricsGet)), cgoAllocsUnknown - __ret := C.nvmlGpmMetricsGet(cMetricsGet) +// nvmlGpmMigSampleGet function as declared in nvml/nvml.h +func nvmlGpmMigSampleGet(nvmlDevice nvmlDevice, GpuInstanceId uint32, nvmlGpmSample nvmlGpmSample) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cGpuInstanceId, _ := (C.uint)(GpuInstanceId), cgoAllocsUnknown + cnvmlGpmSample, _ := *(*C.nvmlGpmSample_t)(unsafe.Pointer(&nvmlGpmSample)), cgoAllocsUnknown + __ret := C.nvmlGpmMigSampleGet(cnvmlDevice, cGpuInstanceId, cnvmlGpmSample) __v := (Return)(__ret) return __v } -// nvmlGpmSampleFree function as declared in nvml/nvml.h -func nvmlGpmSampleFree(GpmSample GpmSample) Return { - cGpmSample, _ := *(*C.nvmlGpmSample_t)(unsafe.Pointer(&GpmSample)), cgoAllocsUnknown - __ret := C.nvmlGpmSampleFree(cGpmSample) +// nvmlGpmQueryDeviceSupport function as declared in nvml/nvml.h +func nvmlGpmQueryDeviceSupport(nvmlDevice nvmlDevice, GpmSupport *GpmSupport) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cGpmSupport, _ := (*C.nvmlGpmSupport_t)(unsafe.Pointer(GpmSupport)), cgoAllocsUnknown + __ret := C.nvmlGpmQueryDeviceSupport(cnvmlDevice, cGpmSupport) __v := (Return)(__ret) return __v } -// nvmlGpmSampleAlloc function as declared in nvml/nvml.h -func nvmlGpmSampleAlloc(GpmSample *GpmSample) Return { - cGpmSample, _ := (*C.nvmlGpmSample_t)(unsafe.Pointer(GpmSample)), cgoAllocsUnknown - __ret := C.nvmlGpmSampleAlloc(cGpmSample) +// nvmlGpmQueryIfStreamingEnabled function as declared in nvml/nvml.h +func nvmlGpmQueryIfStreamingEnabled(nvmlDevice nvmlDevice, State *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cState, _ := (*C.uint)(unsafe.Pointer(State)), cgoAllocsUnknown + __ret := C.nvmlGpmQueryIfStreamingEnabled(cnvmlDevice, cState) __v := (Return)(__ret) return __v } -// nvmlGpmSampleGet function as declared in nvml/nvml.h -func nvmlGpmSampleGet(Device Device, GpmSample GpmSample) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cGpmSample, _ := *(*C.nvmlGpmSample_t)(unsafe.Pointer(&GpmSample)), cgoAllocsUnknown - __ret := C.nvmlGpmSampleGet(cDevice, cGpmSample) +// nvmlGpmSetStreamingEnabled function as declared in nvml/nvml.h +func nvmlGpmSetStreamingEnabled(nvmlDevice nvmlDevice, State uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cState, _ := (C.uint)(State), cgoAllocsUnknown + __ret := C.nvmlGpmSetStreamingEnabled(cnvmlDevice, cState) __v := (Return)(__ret) return __v } -// nvmlGpmMigSampleGet function as declared in nvml/nvml.h -func nvmlGpmMigSampleGet(Device Device, GpuInstanceId uint32, GpmSample GpmSample) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cGpuInstanceId, _ := (C.uint)(GpuInstanceId), cgoAllocsUnknown - cGpmSample, _ := *(*C.nvmlGpmSample_t)(unsafe.Pointer(&GpmSample)), cgoAllocsUnknown - __ret := C.nvmlGpmMigSampleGet(cDevice, cGpuInstanceId, cGpmSample) +// nvmlDeviceSetNvLinkDeviceLowPowerThreshold function as declared in nvml/nvml.h +func nvmlDeviceSetNvLinkDeviceLowPowerThreshold(nvmlDevice nvmlDevice, Info *NvLinkPowerThres) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cInfo, _ := (*C.nvmlNvLinkPowerThres_t)(unsafe.Pointer(Info)), cgoAllocsUnknown + __ret := C.nvmlDeviceSetNvLinkDeviceLowPowerThreshold(cnvmlDevice, cInfo) __v := (Return)(__ret) return __v } -// nvmlGpmQueryDeviceSupport function as declared in nvml/nvml.h -func nvmlGpmQueryDeviceSupport(Device Device, GpmSupport *GpmSupport) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cGpmSupport, _ := (*C.nvmlGpmSupport_t)(unsafe.Pointer(GpmSupport)), cgoAllocsUnknown - __ret := C.nvmlGpmQueryDeviceSupport(cDevice, cGpmSupport) +// nvmlSystemSetNvlinkBwMode function as declared in nvml/nvml.h +func nvmlSystemSetNvlinkBwMode(NvlinkBwMode uint32) Return { + cNvlinkBwMode, _ := (C.uint)(NvlinkBwMode), cgoAllocsUnknown + __ret := C.nvmlSystemSetNvlinkBwMode(cNvlinkBwMode) __v := (Return)(__ret) return __v } -// nvmlDeviceCcuGetStreamState function as declared in nvml/nvml.h -func nvmlDeviceCcuGetStreamState(Device Device, State *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cState, _ := (*C.uint)(unsafe.Pointer(State)), cgoAllocsUnknown - __ret := C.nvmlDeviceCcuGetStreamState(cDevice, cState) +// nvmlSystemGetNvlinkBwMode function as declared in nvml/nvml.h +func nvmlSystemGetNvlinkBwMode(NvlinkBwMode *uint32) Return { + cNvlinkBwMode, _ := (*C.uint)(unsafe.Pointer(NvlinkBwMode)), cgoAllocsUnknown + __ret := C.nvmlSystemGetNvlinkBwMode(cNvlinkBwMode) __v := (Return)(__ret) return __v } -// nvmlDeviceCcuSetStreamState function as declared in nvml/nvml.h -func nvmlDeviceCcuSetStreamState(Device Device, State uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cState, _ := (C.uint)(State), cgoAllocsUnknown - __ret := C.nvmlDeviceCcuSetStreamState(cDevice, cState) +// nvmlDeviceSetPowerManagementLimit_v2 function as declared in nvml/nvml.h +func nvmlDeviceSetPowerManagementLimit_v2(nvmlDevice nvmlDevice, PowerValue *PowerValue_v2) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cPowerValue, _ := (*C.nvmlPowerValue_v2_t)(unsafe.Pointer(PowerValue)), cgoAllocsUnknown + __ret := C.nvmlDeviceSetPowerManagementLimit_v2(cnvmlDevice, cPowerValue) __v := (Return)(__ret) return __v } -// nvmlDeviceSetNvLinkDeviceLowPowerThreshold function as declared in nvml/nvml.h -func nvmlDeviceSetNvLinkDeviceLowPowerThreshold(Device Device, Info *NvLinkPowerThres) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown - cInfo, _ := (*C.nvmlNvLinkPowerThres_t)(unsafe.Pointer(Info)), cgoAllocsUnknown - __ret := C.nvmlDeviceSetNvLinkDeviceLowPowerThreshold(cDevice, cInfo) +// nvmlDeviceGetSramEccErrorStatus function as declared in nvml/nvml.h +func nvmlDeviceGetSramEccErrorStatus(nvmlDevice nvmlDevice, Status *EccSramErrorStatus) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown + cStatus, _ := (*C.nvmlEccSramErrorStatus_t)(unsafe.Pointer(Status)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetSramEccErrorStatus(cnvmlDevice, cStatus) __v := (Return)(__ret) return __v } @@ -2782,74 +3121,74 @@ func nvmlDeviceGetCount_v1(DeviceCount *uint32) Return { } // nvmlDeviceGetHandleByIndex_v1 function as declared in nvml/nvml.h -func nvmlDeviceGetHandleByIndex_v1(Index uint32, Device *Device) Return { +func nvmlDeviceGetHandleByIndex_v1(Index uint32, nvmlDevice *nvmlDevice) Return { cIndex, _ := (C.uint)(Index), cgoAllocsUnknown - cDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetHandleByIndex(cIndex, cDevice) + cnvmlDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetHandleByIndex(cIndex, cnvmlDevice) __v := (Return)(__ret) return __v } // nvmlDeviceGetHandleByPciBusId_v1 function as declared in nvml/nvml.h -func nvmlDeviceGetHandleByPciBusId_v1(PciBusId string, Device *Device) Return { +func nvmlDeviceGetHandleByPciBusId_v1(PciBusId string, nvmlDevice *nvmlDevice) Return { cPciBusId, _ := unpackPCharString(PciBusId) - cDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(Device)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetHandleByPciBusId(cPciBusId, cDevice) + cnvmlDevice, _ := (*C.nvmlDevice_t)(unsafe.Pointer(nvmlDevice)), cgoAllocsUnknown + __ret := C.nvmlDeviceGetHandleByPciBusId(cPciBusId, cnvmlDevice) __v := (Return)(__ret) return __v } // nvmlDeviceGetPciInfo_v1 function as declared in nvml/nvml.h -func nvmlDeviceGetPciInfo_v1(Device Device, Pci *PciInfo) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPciInfo_v1(nvmlDevice nvmlDevice, Pci *PciInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPci, _ := (*C.nvmlPciInfo_t)(unsafe.Pointer(Pci)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPciInfo(cDevice, cPci) + __ret := C.nvmlDeviceGetPciInfo(cnvmlDevice, cPci) __v := (Return)(__ret) return __v } // nvmlDeviceGetPciInfo_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetPciInfo_v2(Device Device, Pci *PciInfo) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetPciInfo_v2(nvmlDevice nvmlDevice, Pci *PciInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPci, _ := (*C.nvmlPciInfo_t)(unsafe.Pointer(Pci)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetPciInfo_v2(cDevice, cPci) + __ret := C.nvmlDeviceGetPciInfo_v2(cnvmlDevice, cPci) __v := (Return)(__ret) return __v } // nvmlDeviceGetNvLinkRemotePciInfo_v1 function as declared in nvml/nvml.h -func nvmlDeviceGetNvLinkRemotePciInfo_v1(Device Device, Link uint32, Pci *PciInfo) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetNvLinkRemotePciInfo_v1(nvmlDevice nvmlDevice, Link uint32, Pci *PciInfo) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cLink, _ := (C.uint)(Link), cgoAllocsUnknown cPci, _ := (*C.nvmlPciInfo_t)(unsafe.Pointer(Pci)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetNvLinkRemotePciInfo(cDevice, cLink, cPci) + __ret := C.nvmlDeviceGetNvLinkRemotePciInfo(cnvmlDevice, cLink, cPci) __v := (Return)(__ret) return __v } // nvmlDeviceGetGridLicensableFeatures_v1 function as declared in nvml/nvml.h -func nvmlDeviceGetGridLicensableFeatures_v1(Device Device, PGridLicensableFeatures *GridLicensableFeatures) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGridLicensableFeatures_v1(nvmlDevice nvmlDevice, PGridLicensableFeatures *GridLicensableFeatures) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPGridLicensableFeatures, _ := (*C.nvmlGridLicensableFeatures_t)(unsafe.Pointer(PGridLicensableFeatures)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGridLicensableFeatures(cDevice, cPGridLicensableFeatures) + __ret := C.nvmlDeviceGetGridLicensableFeatures(cnvmlDevice, cPGridLicensableFeatures) __v := (Return)(__ret) return __v } // nvmlDeviceGetGridLicensableFeatures_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetGridLicensableFeatures_v2(Device Device, PGridLicensableFeatures *GridLicensableFeatures) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGridLicensableFeatures_v2(nvmlDevice nvmlDevice, PGridLicensableFeatures *GridLicensableFeatures) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPGridLicensableFeatures, _ := (*C.nvmlGridLicensableFeatures_t)(unsafe.Pointer(PGridLicensableFeatures)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGridLicensableFeatures_v2(cDevice, cPGridLicensableFeatures) + __ret := C.nvmlDeviceGetGridLicensableFeatures_v2(cnvmlDevice, cPGridLicensableFeatures) __v := (Return)(__ret) return __v } // nvmlDeviceGetGridLicensableFeatures_v3 function as declared in nvml/nvml.h -func nvmlDeviceGetGridLicensableFeatures_v3(Device Device, PGridLicensableFeatures *GridLicensableFeatures) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGridLicensableFeatures_v3(nvmlDevice nvmlDevice, PGridLicensableFeatures *GridLicensableFeatures) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cPGridLicensableFeatures, _ := (*C.nvmlGridLicensableFeatures_t)(unsafe.Pointer(PGridLicensableFeatures)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGridLicensableFeatures_v3(cDevice, cPGridLicensableFeatures) + __ret := C.nvmlDeviceGetGridLicensableFeatures_v3(cnvmlDevice, cPGridLicensableFeatures) __v := (Return)(__ret) return __v } @@ -2863,7 +3202,7 @@ func nvmlDeviceRemoveGpu_v1(PciInfo *PciInfo) Return { } // nvmlEventSetWait_v1 function as declared in nvml/nvml.h -func nvmlEventSetWait_v1(Set EventSet, Data *EventData, Timeoutms uint32) Return { +func nvmlEventSetWait_v1(Set nvmlEventSet, Data *nvmlEventData, Timeoutms uint32) Return { cSet, _ := *(*C.nvmlEventSet_t)(unsafe.Pointer(&Set)), cgoAllocsUnknown cData, _ := (*C.nvmlEventData_t)(unsafe.Pointer(Data)), cgoAllocsUnknown cTimeoutms, _ := (C.uint)(Timeoutms), cgoAllocsUnknown @@ -2873,99 +3212,99 @@ func nvmlEventSetWait_v1(Set EventSet, Data *EventData, Timeoutms uint32) Return } // nvmlDeviceGetAttributes_v1 function as declared in nvml/nvml.h -func nvmlDeviceGetAttributes_v1(Device Device, Attributes *DeviceAttributes) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetAttributes_v1(nvmlDevice nvmlDevice, Attributes *DeviceAttributes) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cAttributes, _ := (*C.nvmlDeviceAttributes_t)(unsafe.Pointer(Attributes)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetAttributes(cDevice, cAttributes) + __ret := C.nvmlDeviceGetAttributes(cnvmlDevice, cAttributes) __v := (Return)(__ret) return __v } // nvmlComputeInstanceGetInfo_v1 function as declared in nvml/nvml.h -func nvmlComputeInstanceGetInfo_v1(ComputeInstance ComputeInstance, Info *ComputeInstanceInfo) Return { - cComputeInstance, _ := *(*C.nvmlComputeInstance_t)(unsafe.Pointer(&ComputeInstance)), cgoAllocsUnknown +func nvmlComputeInstanceGetInfo_v1(nvmlComputeInstance nvmlComputeInstance, Info *nvmlComputeInstanceInfo) Return { + cnvmlComputeInstance, _ := *(*C.nvmlComputeInstance_t)(unsafe.Pointer(&nvmlComputeInstance)), cgoAllocsUnknown cInfo, _ := (*C.nvmlComputeInstanceInfo_t)(unsafe.Pointer(Info)), cgoAllocsUnknown - __ret := C.nvmlComputeInstanceGetInfo(cComputeInstance, cInfo) + __ret := C.nvmlComputeInstanceGetInfo(cnvmlComputeInstance, cInfo) __v := (Return)(__ret) return __v } // nvmlDeviceGetComputeRunningProcesses_v1 function as declared in nvml/nvml.h -func nvmlDeviceGetComputeRunningProcesses_v1(Device Device, InfoCount *uint32, Infos *ProcessInfo_v1) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetComputeRunningProcesses_v1(nvmlDevice nvmlDevice, InfoCount *uint32, Infos *ProcessInfo_v1) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cInfoCount, _ := (*C.uint)(unsafe.Pointer(InfoCount)), cgoAllocsUnknown cInfos, _ := (*C.nvmlProcessInfo_v1_t)(unsafe.Pointer(Infos)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetComputeRunningProcesses(cDevice, cInfoCount, cInfos) + __ret := C.nvmlDeviceGetComputeRunningProcesses(cnvmlDevice, cInfoCount, cInfos) __v := (Return)(__ret) return __v } // nvmlDeviceGetComputeRunningProcesses_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetComputeRunningProcesses_v2(Device Device, InfoCount *uint32, Infos *ProcessInfo_v2) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetComputeRunningProcesses_v2(nvmlDevice nvmlDevice, InfoCount *uint32, Infos *ProcessInfo_v2) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cInfoCount, _ := (*C.uint)(unsafe.Pointer(InfoCount)), cgoAllocsUnknown cInfos, _ := (*C.nvmlProcessInfo_v2_t)(unsafe.Pointer(Infos)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetComputeRunningProcesses_v2(cDevice, cInfoCount, cInfos) + __ret := C.nvmlDeviceGetComputeRunningProcesses_v2(cnvmlDevice, cInfoCount, cInfos) __v := (Return)(__ret) return __v } // nvmlDeviceGetGraphicsRunningProcesses_v1 function as declared in nvml/nvml.h -func nvmlDeviceGetGraphicsRunningProcesses_v1(Device Device, InfoCount *uint32, Infos *ProcessInfo_v1) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGraphicsRunningProcesses_v1(nvmlDevice nvmlDevice, InfoCount *uint32, Infos *ProcessInfo_v1) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cInfoCount, _ := (*C.uint)(unsafe.Pointer(InfoCount)), cgoAllocsUnknown cInfos, _ := (*C.nvmlProcessInfo_v1_t)(unsafe.Pointer(Infos)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGraphicsRunningProcesses(cDevice, cInfoCount, cInfos) + __ret := C.nvmlDeviceGetGraphicsRunningProcesses(cnvmlDevice, cInfoCount, cInfos) __v := (Return)(__ret) return __v } // nvmlDeviceGetGraphicsRunningProcesses_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetGraphicsRunningProcesses_v2(Device Device, InfoCount *uint32, Infos *ProcessInfo_v2) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGraphicsRunningProcesses_v2(nvmlDevice nvmlDevice, InfoCount *uint32, Infos *ProcessInfo_v2) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cInfoCount, _ := (*C.uint)(unsafe.Pointer(InfoCount)), cgoAllocsUnknown cInfos, _ := (*C.nvmlProcessInfo_v2_t)(unsafe.Pointer(Infos)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGraphicsRunningProcesses_v2(cDevice, cInfoCount, cInfos) + __ret := C.nvmlDeviceGetGraphicsRunningProcesses_v2(cnvmlDevice, cInfoCount, cInfos) __v := (Return)(__ret) return __v } // nvmlDeviceGetMPSComputeRunningProcesses_v1 function as declared in nvml/nvml.h -func nvmlDeviceGetMPSComputeRunningProcesses_v1(Device Device, InfoCount *uint32, Infos *ProcessInfo_v1) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMPSComputeRunningProcesses_v1(nvmlDevice nvmlDevice, InfoCount *uint32, Infos *ProcessInfo_v1) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cInfoCount, _ := (*C.uint)(unsafe.Pointer(InfoCount)), cgoAllocsUnknown cInfos, _ := (*C.nvmlProcessInfo_v1_t)(unsafe.Pointer(Infos)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMPSComputeRunningProcesses(cDevice, cInfoCount, cInfos) + __ret := C.nvmlDeviceGetMPSComputeRunningProcesses(cnvmlDevice, cInfoCount, cInfos) __v := (Return)(__ret) return __v } // nvmlDeviceGetMPSComputeRunningProcesses_v2 function as declared in nvml/nvml.h -func nvmlDeviceGetMPSComputeRunningProcesses_v2(Device Device, InfoCount *uint32, Infos *ProcessInfo_v2) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetMPSComputeRunningProcesses_v2(nvmlDevice nvmlDevice, InfoCount *uint32, Infos *ProcessInfo_v2) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cInfoCount, _ := (*C.uint)(unsafe.Pointer(InfoCount)), cgoAllocsUnknown cInfos, _ := (*C.nvmlProcessInfo_v2_t)(unsafe.Pointer(Infos)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetMPSComputeRunningProcesses_v2(cDevice, cInfoCount, cInfos) + __ret := C.nvmlDeviceGetMPSComputeRunningProcesses_v2(cnvmlDevice, cInfoCount, cInfos) __v := (Return)(__ret) return __v } // nvmlDeviceGetGpuInstancePossiblePlacements_v1 function as declared in nvml/nvml.h -func nvmlDeviceGetGpuInstancePossiblePlacements_v1(Device Device, ProfileId uint32, Placements *GpuInstancePlacement, Count *uint32) Return { - cDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&Device)), cgoAllocsUnknown +func nvmlDeviceGetGpuInstancePossiblePlacements_v1(nvmlDevice nvmlDevice, ProfileId uint32, Placements *GpuInstancePlacement, Count *uint32) Return { + cnvmlDevice, _ := *(*C.nvmlDevice_t)(unsafe.Pointer(&nvmlDevice)), cgoAllocsUnknown cProfileId, _ := (C.uint)(ProfileId), cgoAllocsUnknown cPlacements, _ := (*C.nvmlGpuInstancePlacement_t)(unsafe.Pointer(Placements)), cgoAllocsUnknown cCount, _ := (*C.uint)(unsafe.Pointer(Count)), cgoAllocsUnknown - __ret := C.nvmlDeviceGetGpuInstancePossiblePlacements(cDevice, cProfileId, cPlacements, cCount) + __ret := C.nvmlDeviceGetGpuInstancePossiblePlacements(cnvmlDevice, cProfileId, cPlacements, cCount) __v := (Return)(__ret) return __v } // nvmlVgpuInstanceGetLicenseInfo_v1 function as declared in nvml/nvml.h -func nvmlVgpuInstanceGetLicenseInfo_v1(VgpuInstance VgpuInstance, LicenseInfo *VgpuLicenseInfo) Return { - cVgpuInstance, _ := (C.nvmlVgpuInstance_t)(VgpuInstance), cgoAllocsUnknown +func nvmlVgpuInstanceGetLicenseInfo_v1(nvmlVgpuInstance nvmlVgpuInstance, LicenseInfo *VgpuLicenseInfo) Return { + cnvmlVgpuInstance, _ := (C.nvmlVgpuInstance_t)(nvmlVgpuInstance), cgoAllocsUnknown cLicenseInfo, _ := (*C.nvmlVgpuLicenseInfo_t)(unsafe.Pointer(LicenseInfo)), cgoAllocsUnknown - __ret := C.nvmlVgpuInstanceGetLicenseInfo(cVgpuInstance, cLicenseInfo) + __ret := C.nvmlVgpuInstanceGetLicenseInfo(cnvmlVgpuInstance, cLicenseInfo) __v := (Return)(__ret) return __v } diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/nvml.h b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/nvml.h index 8c71ff8a..1e4eb12d 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/nvml.h +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/nvml.h @@ -1,7 +1,7 @@ -/*** NVML VERSION: 12.0.76 ***/ -/*** From https://api.anaconda.org/download/nvidia/cuda-nvml-dev/12.0.76/linux-64/cuda-nvml-dev-12.0.76-0.tar.bz2 ***/ +/*** NVML VERSION: 12.4.127 ***/ +/*** From https://api.anaconda.org/download/nvidia/cuda-nvml-dev/12.4.127/linux-64/cuda-nvml-dev-12.4.127-0.tar.bz2 ***/ /* - * Copyright 1993-2022 NVIDIA Corporation. All rights reserved. + * Copyright 1993-2023 NVIDIA Corporation. All rights reserved. * * NOTICE TO USER: * @@ -97,8 +97,8 @@ extern "C" { /** * NVML API versioning support */ -#define NVML_API_VERSION 11 -#define NVML_API_VERSION_STR "11" +#define NVML_API_VERSION 12 +#define NVML_API_VERSION_STR "12" /** * Defining NVML_NO_UNVERSIONED_FUNC_DEFS will disable "auto upgrading" of APIs. * e.g. the user will have to call nvmlInit_v2 instead of nvmlInit. Enable this @@ -158,6 +158,27 @@ typedef struct */ #define NVML_DEVICE_PCI_BUS_ID_BUFFER_V2_SIZE 16 +/** + * PCI information about a GPU device. + */ +typedef struct +{ + unsigned int version; //!< The version number of this struct + unsigned int domain; //!< The PCI domain on which the device's bus resides, 0 to 0xffffffff + unsigned int bus; //!< The bus on which the device resides, 0 to 0xff + unsigned int device; //!< The device's id on the bus, 0 to 31 + + unsigned int pciDeviceId; //!< The combined 16-bit device id and 16-bit vendor id + unsigned int pciSubSystemId; //!< The 32-bit Sub System Device ID + + unsigned int baseClass; //!< The 8-bit PCI base class code + unsigned int subClass; //!< The 8-bit PCI sub class code + + char busId[NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE]; //!< The tuple domain:bus:device.function PCI identifier (& NULL terminator) +} nvmlPciInfoExt_v1_t; +typedef nvmlPciInfoExt_v1_t nvmlPciInfoExt_t; +#define nvmlPciInfoExt_v1 NVML_STRUCT_VERSION(PciInfoExt, 1) + /** * PCI information about a GPU device. */ @@ -232,7 +253,6 @@ typedef struct nvmlMemory_st * Memory allocation information for a device (v2). * * Version 2 adds versioning for the struct and the amount of system-reserved memory as an output. - * @note The \ref nvmlMemory_v2_t.used amount also includes the \ref nvmlMemory_v2_t.reserved amount. */ typedef struct nvmlMemory_v2_st { @@ -240,7 +260,7 @@ typedef struct nvmlMemory_v2_st unsigned long long total; //!< Total physical device memory (in bytes) unsigned long long reserved; //!< Device memory (in bytes) reserved for system use (driver or firmware) unsigned long long free; //!< Unallocated device memory (in bytes) - unsigned long long used; //!< Allocated device memory (in bytes). Note that the driver/GPU always sets aside a small amount of memory for bookkeeping + unsigned long long used; //!< Allocated device memory (in bytes). } nvmlMemory_v2_t; #define nvmlMemory_v2 NVML_STRUCT_VERSION(Memory, 2) @@ -280,23 +300,41 @@ typedef struct nvmlProcessInfo_v2_st // 0xFFFFFFFF otherwise. unsigned int computeInstanceId; //!< If MIG is enabled, stores a valid compute instance ID. computeInstanceId is set to // 0xFFFFFFFF otherwise. -} nvmlProcessInfo_v2_t; +} nvmlProcessInfo_v2_t, nvmlProcessInfo_t; /** - * Information about running compute processes on the GPU - * Version 2 adds versioning for the struct + * Information about running process on the GPU with protected memory */ -typedef struct nvmlProcessInfo_st +typedef struct { - unsigned int pid; //!< Process ID - unsigned long long usedGpuMemory; //!< Amount of used GPU memory in bytes. - //! Under WDDM, \ref NVML_VALUE_NOT_AVAILABLE is always reported - //! because Windows KMD manages all the memory and not the NVIDIA driver - unsigned int gpuInstanceId; //!< If MIG is enabled, stores a valid GPU instance ID. gpuInstanceId is set to - // 0xFFFFFFFF otherwise. - unsigned int computeInstanceId; //!< If MIG is enabled, stores a valid compute instance ID. computeInstanceId is set to - // 0xFFFFFFFF otherwise. -} nvmlProcessInfo_t; + unsigned int pid; //!< Process ID + unsigned long long usedGpuMemory; //!< Amount of used GPU memory in bytes. + //! Under WDDM, \ref NVML_VALUE_NOT_AVAILABLE is always reported + //! because Windows KMD manages all the memory and not the NVIDIA driver + unsigned int gpuInstanceId; //!< If MIG is enabled, stores a valid GPU instance ID. gpuInstanceId is + // set to 0xFFFFFFFF otherwise. + unsigned int computeInstanceId; //!< If MIG is enabled, stores a valid compute instance ID. computeInstanceId + // is set to 0xFFFFFFFF otherwise. + unsigned long long usedGpuCcProtectedMemory; //!< Amount of used GPU conf compute protected memory in bytes. +} nvmlProcessDetail_v1_t; + +/** + * Information about all running processes on the GPU for the given mode + */ +typedef struct +{ + unsigned int version; //!< Struct version, MUST be nvmlProcessDetailList_v1 + unsigned int mode; //!< Process mode(Compute/Graphics/MPSCompute) + unsigned int numProcArrayEntries; //!< Number of process entries in procArray + nvmlProcessDetail_v1_t *procArray; //!< Process array +} nvmlProcessDetailList_v1_t; + +typedef nvmlProcessDetailList_v1_t nvmlProcessDetailList_t; + +/** + * nvmlProcessDetailList version + */ +#define nvmlProcessDetailList_v1 NVML_STRUCT_VERSION(ProcessDetailList, 1) typedef struct nvmlDeviceAttributes_st { @@ -311,6 +349,16 @@ typedef struct nvmlDeviceAttributes_st unsigned long long memorySizeMB; //!< Device memory size (in MiB) } nvmlDeviceAttributes_t; +/** + * C2C Mode information for a device + */ +typedef struct +{ + unsigned int isC2cEnabled; +} nvmlC2cModeInfo_v1_t; + +#define nvmlC2cModeInfo_v1 NVML_STRUCT_VERSION(C2cModeInfo, 1) + /** * Possible values that classify the remap availability for each bank. The max * field will contain the number of banks that have maximum remap availability @@ -447,6 +495,7 @@ typedef enum nvmlGpuP2PStatus_enum { NVML_P2P_STATUS_OK = 0, NVML_P2P_STATUS_CHIPSET_NOT_SUPPORED, + NVML_P2P_STATUS_CHIPSET_NOT_SUPPORTED = NVML_P2P_STATUS_CHIPSET_NOT_SUPPORED, NVML_P2P_STATUS_GPU_NOT_SUPPORTED, NVML_P2P_STATUS_IOH_TOPOLOGY_NOT_SUPPORTED, NVML_P2P_STATUS_DISABLED_BY_REGKEY, @@ -459,11 +508,16 @@ typedef enum nvmlGpuP2PStatus_enum typedef enum nvmlGpuP2PCapsIndex_enum { NVML_P2P_CAPS_INDEX_READ = 0, - NVML_P2P_CAPS_INDEX_WRITE, - NVML_P2P_CAPS_INDEX_NVLINK, - NVML_P2P_CAPS_INDEX_ATOMICS, - NVML_P2P_CAPS_INDEX_PROP, - NVML_P2P_CAPS_INDEX_UNKNOWN + NVML_P2P_CAPS_INDEX_WRITE = 1, + NVML_P2P_CAPS_INDEX_NVLINK = 2, + NVML_P2P_CAPS_INDEX_ATOMICS = 3, + NVML_P2P_CAPS_INDEX_PCI = 4, + /* + * DO NOT USE! NVML_P2P_CAPS_INDEX_PROP is deprecated. + * Use NVML_P2P_CAPS_INDEX_PCI instead. + */ + NVML_P2P_CAPS_INDEX_PROP = NVML_P2P_CAPS_INDEX_PCI, + NVML_P2P_CAPS_INDEX_UNKNOWN = 5, }nvmlGpuP2PCapsIndex_t; /** @@ -502,6 +556,9 @@ typedef enum nvmlSamplingType_enum NVML_DEC_UTILIZATION_SAMPLES = 4, //!< To represent percent of time during which NVDEC remains busy NVML_PROCESSOR_CLK_SAMPLES = 5, //!< To represent processor clock samples NVML_MEMORY_CLK_SAMPLES = 6, //!< To represent memory clock samples + NVML_MODULE_POWER_SAMPLES = 7, //!< To represent module power samples for total module starting Grace Hopper + NVML_JPG_UTILIZATION_SAMPLES = 8, //!< To represent percent of time during which NVJPG remains busy + NVML_OFA_UTILIZATION_SAMPLES = 9, //!< To represent percent of time during which NVOFA remains busy // Keep this last NVML_SAMPLINGTYPE_COUNT @@ -529,6 +586,7 @@ typedef enum nvmlValueType_enum NVML_VALUE_TYPE_UNSIGNED_LONG = 2, NVML_VALUE_TYPE_UNSIGNED_LONG_LONG = 3, NVML_VALUE_TYPE_SIGNED_LONG_LONG = 4, + NVML_VALUE_TYPE_SIGNED_INT = 5, // Keep this last NVML_VALUE_TYPE_COUNT @@ -541,6 +599,7 @@ typedef enum nvmlValueType_enum typedef union nvmlValue_st { double dVal; //!< If the value is double + int siVal; //!< If the value is signed int unsigned int uiVal; //!< If the value is unsigned int unsigned long ulVal; //!< If the value is unsigned long unsigned long long ullVal; //!< If the value is unsigned long long @@ -977,7 +1036,10 @@ typedef enum nvmlReturn_enum NVML_ERROR_INSUFFICIENT_RESOURCES = 23, //!< Ran out of critical resources, other than memory NVML_ERROR_FREQ_NOT_SUPPORTED = 24, //!< Ran out of critical resources, other than memory NVML_ERROR_ARGUMENT_VERSION_MISMATCH = 25, //!< The provided version is invalid/unsupported - NVML_ERROR_DEPRECATED = 26, //!< The requested functionality has been deprecated + NVML_ERROR_DEPRECATED = 26, //!< The requested functionality has been deprecated + NVML_ERROR_NOT_READY = 27, //!< The system is not ready for the request + NVML_ERROR_GPU_NOT_FOUND = 28, //!< No GPUs were found + NVML_ERROR_INVALID_STATE = 29, //!< Resource not in correct state to perform requested operation NVML_ERROR_UNKNOWN = 999 //!< An internal driver error occurred } nvmlReturn_t; @@ -1108,7 +1170,6 @@ typedef enum nvmlVgpuCapability_enum NVML_VGPU_CAP_COUNT } nvmlVgpuCapability_t; - /** * vGPU driver queryable capabilities */ @@ -1119,15 +1180,19 @@ typedef enum nvmlVgpuDriverCapability_enum NVML_VGPU_DRIVER_CAP_COUNT } nvmlVgpuDriverCapability_t; - /** * Device vGPU queryable capabilities */ typedef enum nvmlDeviceVgpuCapability_enum { - NVML_DEVICE_VGPU_CAP_FRACTIONAL_MULTI_VGPU = 0, //!< Fractional vGPU profiles on this GPU can be used in multi-vGPU configurations - NVML_DEVICE_VGPU_CAP_HETEROGENEOUS_TIMESLICE_PROFILES = 1, //!< Supports concurrent execution of timesliced vGPU profiles of differing types - NVML_DEVICE_VGPU_CAP_HETEROGENEOUS_TIMESLICE_SIZES = 2, //!< Supports concurrent execution of timesliced vGPU profiles of differing framebuffer sizes + NVML_DEVICE_VGPU_CAP_FRACTIONAL_MULTI_VGPU = 0, //!< Query if the fractional vGPU profiles on this GPU can be used in multi-vGPU configurations + NVML_DEVICE_VGPU_CAP_HETEROGENEOUS_TIMESLICE_PROFILES = 1, //!< Query if the GPU support concurrent execution of timesliced vGPU profiles of differing types + NVML_DEVICE_VGPU_CAP_HETEROGENEOUS_TIMESLICE_SIZES = 2, //!< Query if the GPU support concurrent execution of timesliced vGPU profiles of differing framebuffer sizes + NVML_DEVICE_VGPU_CAP_READ_DEVICE_BUFFER_BW = 3, //!< Query the GPU's read_device_buffer expected bandwidth capacity in megabytes per second + NVML_DEVICE_VGPU_CAP_WRITE_DEVICE_BUFFER_BW = 4, //!< Query the GPU's write_device_buffer expected bandwidth capacity in megabytes per second + NVML_DEVICE_VGPU_CAP_DEVICE_STREAMING = 5, //!< Query if vGPU profiles on the GPU supports migration data streaming + NVML_DEVICE_VGPU_CAP_MINI_QUARTER_GPU = 6, //!< Set/Get support for mini-quarter vGPU profiles + NVML_DEVICE_VGPU_CAP_COMPUTE_MEDIA_ENGINE_GPU = 7, //!< Set/Get support for compute media engine vGPU profiles // Keep this last NVML_DEVICE_VGPU_CAP_COUNT } nvmlDeviceVgpuCapability_t; @@ -1154,6 +1219,8 @@ typedef enum nvmlDeviceVgpuCapability_enum #define INVALID_GPU_INSTANCE_ID 0xFFFFFFFF +#define NVML_INVALID_VGPU_PLACEMENT_ID 0xFFFF + /*! * Macros for vGPU instance's virtualization capabilities bitfield. */ @@ -1180,6 +1247,41 @@ typedef unsigned int nvmlVgpuTypeId_t; typedef unsigned int nvmlVgpuInstance_t; +/** + * Structure to store the vGPU heterogeneous mode of device -- version 1 + */ +typedef struct +{ + unsigned int version; //!< The version number of this struct + unsigned int mode; //!< The vGPU heterogeneous mode +} nvmlVgpuHeterogeneousMode_v1_t; +typedef nvmlVgpuHeterogeneousMode_v1_t nvmlVgpuHeterogeneousMode_t; +#define nvmlVgpuHeterogeneousMode_v1 NVML_STRUCT_VERSION(VgpuHeterogeneousMode, 1) + +/** + * Structure to store the placement ID of vGPU instance -- version 1 + */ +typedef struct +{ + unsigned int version; //!< The version number of this struct + unsigned int placementId; //!< Placement ID of the active vGPU instance +} nvmlVgpuPlacementId_v1_t; +typedef nvmlVgpuPlacementId_v1_t nvmlVgpuPlacementId_t; +#define nvmlVgpuPlacementId_v1 NVML_STRUCT_VERSION(VgpuPlacementId, 1) + +/** + * Structure to store the list of vGPU placements -- version 1 + */ +typedef struct +{ + unsigned int version; //!< The version number of this struct + unsigned int placementSize; //!< The number of slots occupied by the vGPU type + unsigned int count; //!< Count of placement IDs fetched + unsigned int *placementIds; //!< Placement IDs for the vGPU type +} nvmlVgpuPlacementList_v1_t; +typedef nvmlVgpuPlacementList_v1_t nvmlVgpuPlacementList_t; +#define nvmlVgpuPlacementList_v1 NVML_STRUCT_VERSION(VgpuPlacementList, 1) + /** * Structure to store Utilization Value and vgpuInstance */ @@ -1193,6 +1295,35 @@ typedef struct nvmlVgpuInstanceUtilizationSample_st nvmlValue_t decUtil; //!< Decoder Util Value } nvmlVgpuInstanceUtilizationSample_t; +/** + * Structure to store Utilization Value and vgpuInstance Info -- Version 1 + */ +typedef struct +{ + unsigned long long timeStamp; //!< CPU Timestamp in microseconds + nvmlVgpuInstance_t vgpuInstance; //!< vGPU Instance + nvmlValue_t smUtil; //!< SM (3D/Compute) Util Value + nvmlValue_t memUtil; //!< Frame Buffer Memory Util Value + nvmlValue_t encUtil; //!< Encoder Util Value + nvmlValue_t decUtil; //!< Decoder Util Value + nvmlValue_t jpgUtil; //!< Jpeg Util Value + nvmlValue_t ofaUtil; //!< Ofa Util Value +} nvmlVgpuInstanceUtilizationInfo_v1_t; + +/** + * Structure to store recent utilization for vGPU instances running on a device -- version 1 + */ +typedef struct +{ + unsigned int version; //!< The version number of this struct + nvmlValueType_t sampleValType; //!< Hold the type of returned sample values + unsigned int vgpuInstanceCount; //!< Hold the number of vGPU instances + unsigned long long lastSeenTimeStamp; //!< Return only samples with timestamp greater than lastSeenTimeStamp + nvmlVgpuInstanceUtilizationInfo_v1_t *vgpuUtilArray; //!< The array (allocated by caller) in which vGPU utilization are returned +} nvmlVgpuInstancesUtilizationInfo_v1_t; +typedef nvmlVgpuInstancesUtilizationInfo_v1_t nvmlVgpuInstancesUtilizationInfo_t; +#define nvmlVgpuInstancesUtilizationInfo_v1 NVML_STRUCT_VERSION(VgpuInstancesUtilizationInfo, 1) + /** * Structure to store Utilization Value, vgpuInstance and subprocess information */ @@ -1208,6 +1339,36 @@ typedef struct nvmlVgpuProcessUtilizationSample_st unsigned int decUtil; //!< Decoder Util Value } nvmlVgpuProcessUtilizationSample_t; +/** + * Structure to store Utilization Value, vgpuInstance and subprocess information for process running on vGPU instance -- version 1 + */ +typedef struct +{ + char processName[NVML_VGPU_NAME_BUFFER_SIZE]; //!< Name of process running within the vGPU VM + unsigned long long timeStamp; //!< CPU Timestamp in microseconds + nvmlVgpuInstance_t vgpuInstance; //!< vGPU Instance + unsigned int pid; //!< PID of process running within the vGPU VM + unsigned int smUtil; //!< SM (3D/Compute) Util Value + unsigned int memUtil; //!< Frame Buffer Memory Util Value + unsigned int encUtil; //!< Encoder Util Value + unsigned int decUtil; //!< Decoder Util Value + unsigned int jpgUtil; //!< Jpeg Util Value + unsigned int ofaUtil; //!< Ofa Util Value +} nvmlVgpuProcessUtilizationInfo_v1_t; + +/** + * Structure to store recent utilization, vgpuInstance and subprocess information for processes running on vGPU instances active on a device -- version 1 + */ +typedef struct +{ + unsigned int version; //!< The version number of this struct + unsigned int vgpuProcessCount; //!< Hold the number of processes running on vGPU instances + unsigned long long lastSeenTimeStamp; //!< Return only samples with timestamp greater than lastSeenTimeStamp + nvmlVgpuProcessUtilizationInfo_v1_t *vgpuProcUtilArray; //!< The array (allocated by caller) in which utilization of processes running on vGPU instances are returned +} nvmlVgpuProcessesUtilizationInfo_v1_t; +typedef nvmlVgpuProcessesUtilizationInfo_v1_t nvmlVgpuProcessesUtilizationInfo_t; +#define nvmlVgpuProcessesUtilizationInfo_v1 NVML_STRUCT_VERSION(VgpuProcessesUtilizationInfo, 1) + /** * vGPU scheduler policies */ @@ -1220,6 +1381,10 @@ typedef struct nvmlVgpuProcessUtilizationSample_st #define NVML_SCHEDULER_SW_MAX_LOG_ENTRIES 200 +#define NVML_VGPU_SCHEDULER_ARR_DEFAULT 0 +#define NVML_VGPU_SCHEDULER_ARR_DISABLE 1 +#define NVML_VGPU_SCHEDULER_ARR_ENABLE 2 + typedef struct { unsigned int avgFactor; unsigned int timeslice; @@ -1260,7 +1425,7 @@ typedef struct nvmlVgpuSchedulerLog_st { unsigned int engineId; //!< Engine whose software runlist log entries are fetched unsigned int schedulerPolicy; //!< Scheduler policy - unsigned int isEnabledARR; //!< Flag to check Adaptive Round Robin scheduler mode + unsigned int arrMode; //!< Adaptive Round Robin scheduler mode. One of the NVML_VGPU_SCHEDULER_ARR_*. nvmlVgpuSchedulerParams_t schedulerParams; unsigned int entriesCount; //!< Count of log entries fetched nvmlVgpuSchedulerLogEntry_t logEntries[NVML_SCHEDULER_SW_MAX_LOG_ENTRIES]; @@ -1272,7 +1437,7 @@ typedef struct nvmlVgpuSchedulerLog_st typedef struct nvmlVgpuSchedulerGetState_st { unsigned int schedulerPolicy; //!< Scheduler policy - unsigned int isEnabledARR; //!< Flag to check Adaptive Round Robin scheduler mode + unsigned int arrMode; //!< Adaptive Round Robin scheduler mode. One of the NVML_VGPU_SCHEDULER_ARR_*. nvmlVgpuSchedulerParams_t schedulerParams; } nvmlVgpuSchedulerGetState_t; @@ -1302,7 +1467,7 @@ typedef union typedef struct nvmlVgpuSchedulerSetState_st { unsigned int schedulerPolicy; //!< Scheduler policy - unsigned int enableARRMode; //!< Flag to enable/disable Adaptive Round Robin scheduler + unsigned int enableARRMode; //!< Adaptive Round Robin scheduler nvmlVgpuSchedulerSetParams_t schedulerParams; } nvmlVgpuSchedulerSetState_t; @@ -1365,6 +1530,34 @@ typedef struct nvmlProcessUtilizationSample_st unsigned int decUtil; //!< Decoder Util Value } nvmlProcessUtilizationSample_t; +/** + * Structure to store utilization value and process Id -- version 1 + */ +typedef struct +{ + unsigned long long timeStamp; //!< CPU Timestamp in microseconds + unsigned int pid; //!< PID of process + unsigned int smUtil; //!< SM (3D/Compute) Util Value + unsigned int memUtil; //!< Frame Buffer Memory Util Value + unsigned int encUtil; //!< Encoder Util Value + unsigned int decUtil; //!< Decoder Util Value + unsigned int jpgUtil; //!< Jpeg Util Value + unsigned int ofaUtil; //!< Ofa Util Value +} nvmlProcessUtilizationInfo_v1_t; + +/** + * Structure to store utilization and process ID for each running process -- version 1 + */ +typedef struct +{ + unsigned int version; //!< The version number of this struct + unsigned int processSamplesCount; //!< Caller-supplied array size, and returns number of processes running + unsigned long long lastSeenTimeStamp; //!< Return only samples with timestamp greater than lastSeenTimeStamp + nvmlProcessUtilizationInfo_v1_t *procUtilArray; //!< The array (allocated by caller) of the utilization of GPU SM, framebuffer, video encoder, video decoder, JPEG, and OFA +} nvmlProcessesUtilizationInfo_v1_t; +typedef nvmlProcessesUtilizationInfo_v1_t nvmlProcessesUtilizationInfo_t; +#define nvmlProcessesUtilizationInfo_v1 NVML_STRUCT_VERSION(ProcessesUtilizationInfo, 1) + /** * Structure to store license expiry date and time values */ @@ -1402,6 +1595,29 @@ typedef struct nvmlGridLicensableFeatures_st nvmlGridLicensableFeature_t gridLicensableFeatures[NVML_GRID_LICENSE_FEATURE_MAX_COUNT]; //!< Array of vGPU software licensable features. } nvmlGridLicensableFeatures_t; +/** + * Structure to store SRAM uncorrectable error counters + */ +typedef struct +{ + unsigned int version; //!< the API version number + unsigned long long aggregateUncParity; //!< aggregate uncorrectable parity error count + unsigned long long aggregateUncSecDed; //!< aggregate uncorrectable SEC-DED error count + unsigned long long aggregateCor; //!< aggregate correctable error count + unsigned long long volatileUncParity; //!< volatile uncorrectable parity error count + unsigned long long volatileUncSecDed; //!< volatile uncorrectable SEC-DED error count + unsigned long long volatileCor; //!< volatile correctable error count + unsigned long long aggregateUncBucketL2; //!< aggregate uncorrectable error count for L2 cache bucket + unsigned long long aggregateUncBucketSm; //!< aggregate uncorrectable error count for SM bucket + unsigned long long aggregateUncBucketPcie; //!< aggregate uncorrectable error count for PCIE bucket + unsigned long long aggregateUncBucketMcu; //!< aggregate uncorrectable error count for Microcontroller bucket + unsigned long long aggregateUncBucketOther; //!< aggregate uncorrectable error count for Other bucket + unsigned int bThresholdExceeded; //!< if the error threshold of field diag is exceeded +} nvmlEccSramErrorStatus_v1_t; + +typedef nvmlEccSramErrorStatus_v1_t nvmlEccSramErrorStatus_t; +#define nvmlEccSramErrorStatus_v1 NVML_STRUCT_VERSION(EccSramErrorStatus, 1) + /** * GSP firmware */ @@ -1415,11 +1631,8 @@ typedef struct nvmlGridLicensableFeatures_st #define NVML_DEVICE_ARCH_PASCAL 4 // Devices based on the NVIDIA Pascal architecture #define NVML_DEVICE_ARCH_VOLTA 5 // Devices based on the NVIDIA Volta architecture #define NVML_DEVICE_ARCH_TURING 6 // Devices based on the NVIDIA Turing architecture - #define NVML_DEVICE_ARCH_AMPERE 7 // Devices based on the NVIDIA Ampere architecture - #define NVML_DEVICE_ARCH_ADA 8 // Devices based on the NVIDIA Ada architecture - #define NVML_DEVICE_ARCH_HOPPER 9 // Devices based on the NVIDIA Hopper architecture #define NVML_DEVICE_ARCH_UNKNOWN 0xffffffff // Anything else, presumably something newer @@ -1452,8 +1665,9 @@ typedef unsigned int nvmlFanControlPolicy_t; /** * Device Power Source */ -#define NVML_POWER_SOURCE_AC 0x00000000 -#define NVML_POWER_SOURCE_BATTERY 0x00000001 +#define NVML_POWER_SOURCE_AC 0x00000000 +#define NVML_POWER_SOURCE_BATTERY 0x00000001 +#define NVML_POWER_SOURCE_UNDERSIZED 0x00000002 typedef unsigned int nvmlPowerSource_t; @@ -1752,21 +1966,70 @@ typedef struct nvmlGpuDynamicPstatesInfo_st #define NVML_FI_DEV_NVLINK_ECC_DATA_ERROR_COUNT_L9 157 //!< NVLink data ECC Error Counter for Link 9 #define NVML_FI_DEV_NVLINK_ECC_DATA_ERROR_COUNT_L10 158 //!< NVLink data ECC Error Counter for Link 10 #define NVML_FI_DEV_NVLINK_ECC_DATA_ERROR_COUNT_L11 159 //!< NVLink data ECC Error Counter for Link 11 -#define NVML_FI_DEV_NVLINK_ECC_DATA_ERROR_COUNT_TOTAL 160 //!< NvLink data ECC Error Counter total for all Links +#define NVML_FI_DEV_NVLINK_ECC_DATA_ERROR_COUNT_TOTAL 160 //!< NVLink data ECC Error Counter total for all Links + +#define NVML_FI_DEV_NVLINK_ERROR_DL_REPLAY 161 //!< NVLink Replay Error Counter +#define NVML_FI_DEV_NVLINK_ERROR_DL_RECOVERY 162 //!< NVLink Recovery Error Counter +#define NVML_FI_DEV_NVLINK_ERROR_DL_CRC 163 //!< NVLink CRC Error Counter +#define NVML_FI_DEV_NVLINK_GET_SPEED 164 //!< NVLink Speed in MBps +#define NVML_FI_DEV_NVLINK_GET_STATE 165 //!< NVLink State - Active,Inactive +#define NVML_FI_DEV_NVLINK_GET_VERSION 166 //!< NVLink Version + +#define NVML_FI_DEV_NVLINK_GET_POWER_STATE 167 //!< NVLink Power state. 0=HIGH_SPEED 1=LOW_SPEED +#define NVML_FI_DEV_NVLINK_GET_POWER_THRESHOLD 168 //!< NVLink length of idle period (in units of 100us) before transitioning links to sleep state -#define NVML_FI_DEV_NVLINK_ERROR_DL_REPLAY 161 -#define NVML_FI_DEV_NVLINK_ERROR_DL_RECOVERY 162 -#define NVML_FI_DEV_NVLINK_ERROR_DL_CRC 163 -#define NVML_FI_DEV_NVLINK_GET_SPEED 164 -#define NVML_FI_DEV_NVLINK_GET_STATE 165 -#define NVML_FI_DEV_NVLINK_GET_VERSION 166 +#define NVML_FI_DEV_PCIE_L0_TO_RECOVERY_COUNTER 169 //!< Device PEX error recovery counter -#define NVML_FI_DEV_NVLINK_GET_POWER_STATE 167 -#define NVML_FI_DEV_NVLINK_GET_POWER_THRESHOLD 168 +#define NVML_FI_DEV_C2C_LINK_COUNT 170 //!< Number of C2C Links present on the device +#define NVML_FI_DEV_C2C_LINK_GET_STATUS 171 //!< C2C Link Status 0=INACTIVE 1=ACTIVE +#define NVML_FI_DEV_C2C_LINK_GET_MAX_BW 172 //!< C2C Link Speed in MBps for active links + +#define NVML_FI_DEV_PCIE_COUNT_CORRECTABLE_ERRORS 173 +#define NVML_FI_DEV_PCIE_COUNT_NAKS_RECEIVED 174 +#define NVML_FI_DEV_PCIE_COUNT_RECEIVER_ERROR 175 +#define NVML_FI_DEV_PCIE_COUNT_BAD_TLP 176 +#define NVML_FI_DEV_PCIE_COUNT_NAKS_SENT 177 +#define NVML_FI_DEV_PCIE_COUNT_BAD_DLLP 178 +#define NVML_FI_DEV_PCIE_COUNT_NON_FATAL_ERROR 179 +#define NVML_FI_DEV_PCIE_COUNT_FATAL_ERROR 180 +#define NVML_FI_DEV_PCIE_COUNT_UNSUPPORTED_REQ 181 +#define NVML_FI_DEV_PCIE_COUNT_LCRC_ERROR 182 +#define NVML_FI_DEV_PCIE_COUNT_LANE_ERROR 183 + +#define NVML_FI_DEV_IS_RESETLESS_MIG_SUPPORTED 184 + +/** + * Retrieves power usage for this GPU in milliwatts. + * It is only available if power management mode is supported. See \ref nvmlDeviceGetPowerManagementMode and + * \ref nvmlDeviceGetPowerUsage. + * + * scopeId needs to be specified. It signifies: + * 0 - GPU Only Scope - Metrics for GPU are retrieved + * 1 - Module scope - Metrics for the module (e.g. CPU + GPU) are retrieved. + * Note: CPU here refers to NVIDIA CPU (e.g. Grace). x86 or non-NVIDIA ARM is not supported + */ +#define NVML_FI_DEV_POWER_AVERAGE 185 //!< GPU power averaged over 1 sec interval, supported on Ampere (except GA100) or newer architectures. +#define NVML_FI_DEV_POWER_INSTANT 186 //!< Current GPU power, supported on all architectures. +#define NVML_FI_DEV_POWER_MIN_LIMIT 187 //!< Minimum power limit in milliwatts. +#define NVML_FI_DEV_POWER_MAX_LIMIT 188 //!< Maximum power limit in milliwatts. +#define NVML_FI_DEV_POWER_DEFAULT_LIMIT 189 //!< Default power limit in milliwatts (limit which device boots with). +#define NVML_FI_DEV_POWER_CURRENT_LIMIT 190 //!< Limit currently enforced in milliwatts (This includes other limits set elsewhere. E.g. Out-of-band). +#define NVML_FI_DEV_ENERGY 191 //!< Total energy consumption (in mJ) since the driver was last reloaded. Same as \ref NVML_FI_DEV_TOTAL_ENERGY_CONSUMPTION for the GPU. +#define NVML_FI_DEV_POWER_REQUESTED_LIMIT 192 //!< Power limit requested by NVML or any other userspace client. + +/** + * GPU T.Limit temperature thresholds in degree Celsius + * + * These fields are supported on Ada and later architectures and supersedes \ref nvmlDeviceGetTemperatureThreshold. + */ +#define NVML_FI_DEV_TEMPERATURE_SHUTDOWN_TLIMIT 193 //!< T.Limit temperature after which GPU may shut down for HW protection +#define NVML_FI_DEV_TEMPERATURE_SLOWDOWN_TLIMIT 194 //!< T.Limit temperature after which GPU may begin HW slowdown +#define NVML_FI_DEV_TEMPERATURE_MEM_MAX_TLIMIT 195 //!< T.Limit temperature after which GPU may begin SW slowdown due to memory temperature +#define NVML_FI_DEV_TEMPERATURE_GPU_MAX_TLIMIT 196 //!< T.Limit temperature after which GPU may be throttled below base clock -#define NVML_FI_DEV_PCIE_L0_TO_RECOVERY_COUNTER 169 +#define NVML_FI_DEV_IS_MIG_MODE_INDEPENDENT_MIG_QUERY_CAPABLE 199 //!< MIG mode independent, MIG query capable device. 1=yes. 0=no. -#define NVML_FI_MAX 170 //!< One greater than the largest field ID defined above +#define NVML_FI_MAX 200 //!< One greater than the largest field ID defined above /** * Information for a Field Value Sample @@ -1981,7 +2244,7 @@ typedef struct nvmlEventData_st /** @} */ /***************************************************************************************************/ -/** @addtogroup nvmlClocksThrottleReasons +/** @addtogroup nvmlClocksEventReasons * @{ */ /***************************************************************************************************/ @@ -1989,28 +2252,28 @@ typedef struct nvmlEventData_st /** Nothing is running on the GPU and the clocks are dropping to Idle state * \note This limiter may be removed in a later release */ -#define nvmlClocksThrottleReasonGpuIdle 0x0000000000000001LL +#define nvmlClocksEventReasonGpuIdle 0x0000000000000001LL /** GPU clocks are limited by current setting of applications clocks * * @see nvmlDeviceSetApplicationsClocks * @see nvmlDeviceGetApplicationsClock */ -#define nvmlClocksThrottleReasonApplicationsClocksSetting 0x0000000000000002LL +#define nvmlClocksEventReasonApplicationsClocksSetting 0x0000000000000002LL /** * @deprecated Renamed to \ref nvmlClocksThrottleReasonApplicationsClocksSetting * as the name describes the situation more accurately. */ -#define nvmlClocksThrottleReasonUserDefinedClocks nvmlClocksThrottleReasonApplicationsClocksSetting +#define nvmlClocksThrottleReasonUserDefinedClocks nvmlClocksEventReasonApplicationsClocksSetting -/** SW Power Scaling algorithm is reducing the clocks below requested clocks +/** The clocks have been optimized to ensure not to exceed currently set power limits * * @see nvmlDeviceGetPowerUsage * @see nvmlDeviceSetPowerManagementLimit * @see nvmlDeviceGetPowerManagementLimit */ -#define nvmlClocksThrottleReasonSwPowerCap 0x0000000000000004LL +#define nvmlClocksEventReasonSwPowerCap 0x0000000000000004LL /** HW Slowdown (reducing the core clocks by a factor of 2 or more) is engaged * @@ -2036,16 +2299,16 @@ typedef struct nvmlEventData_st * holding this one at lower clocks. * */ -#define nvmlClocksThrottleReasonSyncBoost 0x0000000000000010LL +#define nvmlClocksEventReasonSyncBoost 0x0000000000000010LL /** SW Thermal Slowdown * - * This is an indicator of one or more of the following: - * - Current GPU temperature above the GPU Max Operating Temperature - * - Current memory temperature above the Memory Max Operating Temperature + * The current clocks have been optimized to ensure the the following is true: + * - Current GPU temperature does not exceed GPU Max Operating Temperature + * - Current memory temperature does not exceeed Memory Max Operating Temperature * */ -#define nvmlClocksThrottleReasonSwThermalSlowdown 0x0000000000000020LL +#define nvmlClocksEventReasonSwThermalSlowdown 0x0000000000000020LL /** HW Thermal Slowdown (reducing the core clocks by a factor of 2 or more) is engaged * @@ -2073,28 +2336,61 @@ typedef struct nvmlEventData_st * * @see bug 1997531 */ -#define nvmlClocksThrottleReasonDisplayClockSetting 0x0000000000000100LL +#define nvmlClocksEventReasonDisplayClockSetting 0x0000000000000100LL /** Bit mask representing no clocks throttling * * Clocks are as high as possible. * */ -#define nvmlClocksThrottleReasonNone 0x0000000000000000LL +#define nvmlClocksEventReasonNone 0x0000000000000000LL /** Bit mask representing all supported clocks throttling reasons * New reasons might be added to this list in the future */ -#define nvmlClocksThrottleReasonAll (nvmlClocksThrottleReasonNone \ - | nvmlClocksThrottleReasonGpuIdle \ - | nvmlClocksThrottleReasonApplicationsClocksSetting \ - | nvmlClocksThrottleReasonSwPowerCap \ +#define nvmlClocksEventReasonAll (nvmlClocksThrottleReasonNone \ + | nvmlClocksEventReasonGpuIdle \ + | nvmlClocksEventReasonApplicationsClocksSetting \ + | nvmlClocksEventReasonSwPowerCap \ | nvmlClocksThrottleReasonHwSlowdown \ - | nvmlClocksThrottleReasonSyncBoost \ - | nvmlClocksThrottleReasonSwThermalSlowdown \ + | nvmlClocksEventReasonSyncBoost \ + | nvmlClocksEventReasonSwThermalSlowdown \ | nvmlClocksThrottleReasonHwThermalSlowdown \ | nvmlClocksThrottleReasonHwPowerBrakeSlowdown \ - | nvmlClocksThrottleReasonDisplayClockSetting \ + | nvmlClocksEventReasonDisplayClockSetting \ ) + +/** + * @deprecated Use \ref nvmlClocksEventReasonGpuIdle instead + */ +#define nvmlClocksThrottleReasonGpuIdle nvmlClocksEventReasonGpuIdle +/** + * @deprecated Use \ref nvmlClocksEventReasonApplicationsClocksSetting instead + */ +#define nvmlClocksThrottleReasonApplicationsClocksSetting nvmlClocksEventReasonApplicationsClocksSetting +/** + * @deprecated Use \ref nvmlClocksEventReasonSyncBoost instead + */ +#define nvmlClocksThrottleReasonSyncBoost nvmlClocksEventReasonSyncBoost +/** + * @deprecated Use \ref nvmlClocksEventReasonSwPowerCap instead + */ +#define nvmlClocksThrottleReasonSwPowerCap nvmlClocksEventReasonSwPowerCap +/** + * @deprecated Use \ref nvmlClocksEventReasonSwThermalSlowdown instead + */ +#define nvmlClocksThrottleReasonSwThermalSlowdown nvmlClocksEventReasonSwThermalSlowdown +/** + * @deprecated Use \ref nvmlClocksEventReasonDisplayClockSetting instead + */ +#define nvmlClocksThrottleReasonDisplayClockSetting nvmlClocksEventReasonDisplayClockSetting +/** + * @deprecated Use \ref nvmlClocksEventReasonNone instead + */ +#define nvmlClocksThrottleReasonNone nvmlClocksEventReasonNone +/** + * @deprecated Use \ref nvmlClocksEventReasonAll instead + */ +#define nvmlClocksThrottleReasonAll nvmlClocksEventReasonAll /** @} */ /***************************************************************************************************/ @@ -2150,8 +2446,10 @@ typedef struct nvmlAccountingStats_st { */ typedef enum nvmlEncoderQueryType_enum { - NVML_ENCODER_QUERY_H264 = 0, //!< H264 encoder - NVML_ENCODER_QUERY_HEVC = 1 //!< HEVC encoder + NVML_ENCODER_QUERY_H264 = 0x00, //!< H264 encoder + NVML_ENCODER_QUERY_HEVC = 0x01, //!< HEVC encoder + NVML_ENCODER_QUERY_AV1 = 0x02, //!< AV1 encoder + NVML_ENCODER_QUERY_UNKNOWN = 0xFF //!< Unknown encoder }nvmlEncoderType_t; /** @@ -2182,7 +2480,7 @@ typedef struct nvmlEncoderSessionInfo_st */ typedef enum nvmlFBCSessionType_enum { - NVML_FBC_SESSION_TYPE_UNKNOWN = 0, //!< Unknwon + NVML_FBC_SESSION_TYPE_UNKNOWN = 0, //!< Unknown NVML_FBC_SESSION_TYPE_TOSYS, //!< ToSys NVML_FBC_SESSION_TYPE_CUDA, //!< Cuda NVML_FBC_SESSION_TYPE_VID, //!< Vid @@ -2252,6 +2550,143 @@ typedef enum nvmlPcieLinkState_enum /** @} */ +/***************************************************************************************************/ +/** @defgroup nvmlSystem/nvmlDevice definitions related to Confidential Computing + * @{ + */ +/***************************************************************************************************/ +/** + * Confidential Compute CPU Capabilities values + */ +#define NVML_CC_SYSTEM_CPU_CAPS_NONE 0 +#define NVML_CC_SYSTEM_CPU_CAPS_AMD_SEV 1 +#define NVML_CC_SYSTEM_CPU_CAPS_INTEL_TDX 2 + +/** + * Confidenial Compute GPU Capabilities values + */ +#define NVML_CC_SYSTEM_GPUS_CC_NOT_CAPABLE 0 +#define NVML_CC_SYSTEM_GPUS_CC_CAPABLE 1 + +typedef struct nvmlConfComputeSystemCaps_st { + unsigned int cpuCaps; + unsigned int gpusCaps; +} nvmlConfComputeSystemCaps_t; + +/** + * Confidential Compute DevTools Mode values + */ +#define NVML_CC_SYSTEM_DEVTOOLS_MODE_OFF 0 +#define NVML_CC_SYSTEM_DEVTOOLS_MODE_ON 1 + +/** + * Confidential Compute Environment values + */ +#define NVML_CC_SYSTEM_ENVIRONMENT_UNAVAILABLE 0 +#define NVML_CC_SYSTEM_ENVIRONMENT_SIM 1 +#define NVML_CC_SYSTEM_ENVIRONMENT_PROD 2 + +/** + * Confidential Compute Feature Status values + */ +#define NVML_CC_SYSTEM_FEATURE_DISABLED 0 +#define NVML_CC_SYSTEM_FEATURE_ENABLED 1 + +typedef struct nvmlConfComputeSystemState_st { + unsigned int environment; + unsigned int ccFeature; + unsigned int devToolsMode; +} nvmlConfComputeSystemState_t; + +/** + * Confidential Compute Multigpu mode values + */ +#define NVML_CC_SYSTEM_MULTIGPU_NONE 0 +#define NVML_CC_SYSTEM_MULTIGPU_PROTECTED_PCIE 1 + +/** + * Confidential Compute System settings + */ +typedef struct { + unsigned int version; + unsigned int environment; + unsigned int ccFeature; + unsigned int devToolsMode; + unsigned int multiGpuMode; +} nvmlSystemConfComputeSettings_v1_t; + +typedef nvmlSystemConfComputeSettings_v1_t nvmlSystemConfComputeSettings_t; +#define nvmlSystemConfComputeSettings_v1 NVML_STRUCT_VERSION(SystemConfComputeSettings, 1) + +/** + * Protected memory size + */ +typedef struct +nvmlConfComputeMemSizeInfo_st +{ + unsigned long long protectedMemSizeKib; + unsigned long long unprotectedMemSizeKib; +} nvmlConfComputeMemSizeInfo_t; + +/** + * Confidential Compute GPUs/System Ready State values + */ +#define NVML_CC_ACCEPTING_CLIENT_REQUESTS_FALSE 0 +#define NVML_CC_ACCEPTING_CLIENT_REQUESTS_TRUE 1 + +/** + * GPU Certificate Details + */ +#define NVML_GPU_CERT_CHAIN_SIZE 0x1000 +#define NVML_GPU_ATTESTATION_CERT_CHAIN_SIZE 0x1400 + +typedef struct nvmlConfComputeGpuCertificate_st { + unsigned int certChainSize; + unsigned int attestationCertChainSize; + unsigned char certChain[NVML_GPU_CERT_CHAIN_SIZE]; + unsigned char attestationCertChain[NVML_GPU_ATTESTATION_CERT_CHAIN_SIZE]; +} nvmlConfComputeGpuCertificate_t; + +/** + * GPU Attestation Report + */ +#define NVML_CC_GPU_CEC_NONCE_SIZE 0x20 +#define NVML_CC_GPU_ATTESTATION_REPORT_SIZE 0x2000 +#define NVML_CC_GPU_CEC_ATTESTATION_REPORT_SIZE 0x1000 +#define NVML_CC_CEC_ATTESTATION_REPORT_NOT_PRESENT 0 +#define NVML_CC_CEC_ATTESTATION_REPORT_PRESENT 1 +#define NVML_CC_KEY_ROTATION_THRESHOLD_ATTACKER_ADVANTAGE_MIN 50 +#define NVML_CC_KEY_ROTATION_THRESHOLD_ATTACKER_ADVANTAGE_MAX 75 + +typedef struct nvmlConfComputeGpuAttestationReport_st { + unsigned int isCecAttestationReportPresent; + unsigned int attestationReportSize; + unsigned int cecAttestationReportSize; + unsigned char nonce[NVML_CC_GPU_CEC_NONCE_SIZE]; + unsigned char attestationReport[NVML_CC_GPU_ATTESTATION_REPORT_SIZE]; + unsigned char cecAttestationReport[NVML_CC_GPU_CEC_ATTESTATION_REPORT_SIZE]; +} nvmlConfComputeGpuAttestationReport_t; + +typedef struct nvmlConfComputeSetKeyRotationThresholdInfo_st { + unsigned int version; + unsigned long long maxAttackerAdvantage; +} nvmlConfComputeSetKeyRotationThresholdInfo_v1_t; + +typedef nvmlConfComputeSetKeyRotationThresholdInfo_v1_t nvmlConfComputeSetKeyRotationThresholdInfo_t; +#define nvmlConfComputeSetKeyRotationThresholdInfo_v1 \ + NVML_STRUCT_VERSION(ConfComputeSetKeyRotationThresholdInfo, 1) + +typedef struct nvmlConfComputeGetKeyRotationThresholdInfo_st { + unsigned int version; + unsigned long long attackerAdvantage; +} nvmlConfComputeGetKeyRotationThresholdInfo_v1_t; + +typedef nvmlConfComputeGetKeyRotationThresholdInfo_v1_t nvmlConfComputeGetKeyRotationThresholdInfo_t; +#define nvmlConfComputeGetKeyRotationThresholdInfo_v1 \ + NVML_STRUCT_VERSION(ConfComputeGetKeyRotationThresholdInfo, 1) + +/** @} */ + #define NVML_GPU_FABRIC_UUID_LEN 16 #define NVML_GPU_FABRIC_STATE_NOT_SUPPORTED 0 @@ -2262,11 +2697,79 @@ typedef enum nvmlPcieLinkState_enum typedef unsigned char nvmlGpuFabricState_t; typedef struct { - char clusterUuid[NVML_GPU_FABRIC_UUID_LEN]; //!< Uuid of the cluster to which this GPU belongs + unsigned char clusterUuid[NVML_GPU_FABRIC_UUID_LEN]; //!< Uuid of the cluster to which this GPU belongs nvmlReturn_t status; //!< Error status, if any. Must be checked only if state returns "complete". - unsigned int partitionId; //!< ID of the fabric partition to which this GPU belongs + unsigned int cliqueId; //!< ID of the fabric clique to which this GPU belongs nvmlGpuFabricState_t state; //!< Current state of GPU registration process } nvmlGpuFabricInfo_t; + +#define NVML_GPU_FABRIC_HEALTH_MASK_DEGRADED_BW_NOT_SUPPORTED 0 +#define NVML_GPU_FABRIC_HEALTH_MASK_DEGRADED_BW_TRUE 1 +#define NVML_GPU_FABRIC_HEALTH_MASK_DEGRADED_BW_FALSE 2 + +#define NVML_GPU_FABRIC_HEALTH_MASK_SHIFT_DEGRADED_BW 0 +#define NVML_GPU_FABRIC_HEALTH_MASK_WIDTH_DEGRADED_BW 0x11 + +/** + * GPU Fabric Health Status Mask for various fields can be obtained + * using the below macro. + * Ex - NVML_GPU_FABRIC_HEALTH_GET(var, _DEGRADED_BW) + */ +#define NVML_GPU_FABRIC_HEALTH_GET(var, type) \ + (((var) >> NVML_GPU_FABRIC_HEALTH_MASK_SHIFT##type) & \ + (NVML_GPU_FABRIC_HEALTH_MASK_WIDTH##type)) + +/** + * GPU Fabric Health Status Mask for various fields can be tested + * using the below macro. + * Ex - NVML_GPU_FABRIC_HEALTH_TEST(var, _DEGRADED_BW, _TRUE) + */ +#define NVML_GPU_FABRIC_HEALTH_TEST(var, type, val) \ + (NVML_GPU_FABRIC_HEALTH_GET(var, type) == \ + NVML_GPU_FABRIC_HEALTH_MASK##type##val) + +/** +* GPU Fabric information (v2). +* +* Version 2 adds the \ref nvmlGpuFabricInfo_v2_t.version field +* to the start of the structure, and the \ref nvmlGpuFabricInfo_v2_t.healthMask +* field to the end. This structure is not backwards-compatible with +* \ref nvmlGpuFabricInfo_t. +*/ +typedef struct { + unsigned int version; //!< Structure version identifier (set to \ref nvmlGpuFabricInfo_v2) + unsigned char clusterUuid[NVML_GPU_FABRIC_UUID_LEN]; //!< Uuid of the cluster to which this GPU belongs + nvmlReturn_t status; //!< Error status, if any. Must be checked only if state returns "complete". + unsigned int cliqueId; //!< ID of the fabric clique to which this GPU belongs + nvmlGpuFabricState_t state; //!< Current state of GPU registration process + unsigned int healthMask; //!< GPU Fabric health Status Mask +} nvmlGpuFabricInfo_v2_t; + +typedef nvmlGpuFabricInfo_v2_t nvmlGpuFabricInfoV_t; + +/** +* Version identifier value for \ref nvmlGpuFabricInfo_v2_t.version. +*/ +#define nvmlGpuFabricInfo_v2 NVML_STRUCT_VERSION(GpuFabricInfo, 2) + +/** + * Device Scope - This is useful to retrieve the telemetry at GPU and module (e.g. GPU + CPU) level + */ +#define NVML_POWER_SCOPE_GPU 0U //!< Targets only GPU +#define NVML_POWER_SCOPE_MODULE 1U //!< Targets the whole module +#define NVML_POWER_SCOPE_MEMORY 2U //!< Targets the GPU Memory + +typedef unsigned char nvmlPowerScopeType_t; + +typedef struct +{ + unsigned int version; //!< Structure format version (must be 1) + nvmlPowerScopeType_t powerScope; //!< [in] Device type: GPU or Total Module + unsigned int powerValueMw; //!< [out] Power value to retrieve or set in milliwatts +} nvmlPowerValue_v2_t; + +#define nvmlPowerValue_v2 NVML_STRUCT_VERSION(PowerValue, 2) + /** @} */ /***************************************************************************************************/ @@ -2531,34 +3034,73 @@ nvmlReturn_t DECLDIR nvmlSystemGetCudaDriverVersion_v2(int *cudaDriverVersion); */ nvmlReturn_t DECLDIR nvmlSystemGetProcessName(unsigned int pid, char *name, unsigned int length); -/** @} */ - -/***************************************************************************************************/ -/** @defgroup nvmlUnitQueries Unit Queries - * This chapter describes that queries that NVML can perform against each unit. For S-class systems only. - * In each case the device is identified with an nvmlUnit_t handle. This handle is obtained by - * calling \ref nvmlUnitGetHandleByIndex(). - * @{ - */ -/***************************************************************************************************/ - - /** - * Retrieves the number of units in the system. +/** + * Retrieves the IDs and firmware versions for any Host Interface Cards (HICs) in the system. * * For S-class products. * - * @param unitCount Reference in which to return the number of units + * The \a hwbcCount argument is expected to be set to the size of the input \a hwbcEntries array. + * The HIC must be connected to an S-class system for it to be reported by this function. + * + * @param hwbcCount Size of hwbcEntries array + * @param hwbcEntries Array holding information about hwbc * * @return - * - \ref NVML_SUCCESS if \a unitCount has been set + * - \ref NVML_SUCCESS if \a hwbcCount and \a hwbcEntries have been populated * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a unitCount is NULL - * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * - \ref NVML_ERROR_INVALID_ARGUMENT if either \a hwbcCount or \a hwbcEntries is NULL + * - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a hwbcCount indicates that the \a hwbcEntries array is too small */ -nvmlReturn_t DECLDIR nvmlUnitGetCount(unsigned int *unitCount); +nvmlReturn_t DECLDIR nvmlSystemGetHicVersion(unsigned int *hwbcCount, nvmlHwbcEntry_t *hwbcEntries); /** - * Acquire the handle for a particular unit, based on its index. + * Retrieve the set of GPUs that have a CPU affinity with the given CPU number + * For all products. + * Supported on Linux only. + * + * @param cpuNumber The CPU number + * @param count When zero, is set to the number of matching GPUs such that \a deviceArray + * can be malloc'd. When non-zero, \a deviceArray will be filled with \a count + * number of device handles. + * @param deviceArray An array of device handles for GPUs found with affinity to \a cpuNumber + * + * @return + * - \ref NVML_SUCCESS if \a deviceArray or \a count (if initially zero) has been set + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a cpuNumber, or \a count is invalid, or \a deviceArray is NULL with a non-zero \a count + * - \ref NVML_ERROR_NOT_SUPPORTED if the device or OS does not support this feature + * - \ref NVML_ERROR_UNKNOWN an error has occurred in underlying topology discovery + */ +nvmlReturn_t DECLDIR nvmlSystemGetTopologyGpuSet(unsigned int cpuNumber, unsigned int *count, nvmlDevice_t *deviceArray); + + +/** @} */ + +/***************************************************************************************************/ +/** @defgroup nvmlUnitQueries Unit Queries + * This chapter describes that queries that NVML can perform against each unit. For S-class systems only. + * In each case the device is identified with an nvmlUnit_t handle. This handle is obtained by + * calling \ref nvmlUnitGetHandleByIndex(). + * @{ + */ +/***************************************************************************************************/ + + /** + * Retrieves the number of units in the system. + * + * For S-class products. + * + * @param unitCount Reference in which to return the number of units + * + * @return + * - \ref NVML_SUCCESS if \a unitCount has been set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a unitCount is NULL + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlUnitGetCount(unsigned int *unitCount); + +/** + * Acquire the handle for a particular unit, based on its index. * * For S-class products. * @@ -2696,24 +3238,6 @@ nvmlReturn_t DECLDIR nvmlUnitGetFanSpeedInfo(nvmlUnit_t unit, nvmlUnitFanSpeeds_ */ nvmlReturn_t DECLDIR nvmlUnitGetDevices(nvmlUnit_t unit, unsigned int *deviceCount, nvmlDevice_t *devices); -/** - * Retrieves the IDs and firmware versions for any Host Interface Cards (HICs) in the system. - * - * For S-class products. - * - * The \a hwbcCount argument is expected to be set to the size of the input \a hwbcEntries array. - * The HIC must be connected to an S-class system for it to be reported by this function. - * - * @param hwbcCount Size of hwbcEntries array - * @param hwbcEntries Array holding information about hwbc - * - * @return - * - \ref NVML_SUCCESS if \a hwbcCount and \a hwbcEntries have been populated - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if either \a hwbcCount or \a hwbcEntries is NULL - * - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a hwbcCount indicates that the \a hwbcEntries array is too small - */ -nvmlReturn_t DECLDIR nvmlSystemGetHicVersion(unsigned int *hwbcCount, nvmlHwbcEntry_t *hwbcEntries); /** @} */ /***************************************************************************************************/ @@ -3008,6 +3532,37 @@ nvmlReturn_t DECLDIR nvmlDeviceGetIndex(nvmlDevice_t device, unsigned int *index */ nvmlReturn_t DECLDIR nvmlDeviceGetSerial(nvmlDevice_t device, char *serial, unsigned int length); +/* +* Get a unique identifier for the device module on the baseboard +* +* This API retrieves a unique identifier for each GPU module that exists on a given baseboard. +* For non-baseboard products, this ID would always be 0. +* +* @param device The identifier of the target device +* @param moduleId Unique identifier for the GPU module +* +* @return +* - \ref NVML_SUCCESS if \a moduleId has been successfully retrieved +* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized +* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device or \a moduleId is invalid +* - \ref NVML_ERROR_UNKNOWN on any unexpected error +*/ +nvmlReturn_t DECLDIR nvmlDeviceGetModuleId(nvmlDevice_t device, unsigned int *moduleId); + +/** + * Retrieves the Device's C2C Mode information + * + * @param device The identifier of the target device + * @param c2cModeInfo Output struct containing the device's C2C Mode info + * + * @return + * - \ref NVML_SUCCESS if \a C2C Mode Infor query is successful + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a serial is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetC2cModeInfoV(nvmlDevice_t device, nvmlC2cModeInfo_v1_t *c2cModeInfo); /***************************************************************************************************/ @@ -3147,6 +3702,19 @@ nvmlReturn_t DECLDIR nvmlDeviceSetCpuAffinity(nvmlDevice_t device); */ nvmlReturn_t DECLDIR nvmlDeviceClearCpuAffinity(nvmlDevice_t device); +/** + * Get the NUMA node of the given GPU device. + * This only applies to platforms where the GPUs are NUMA nodes. + * + * @param[in] device The device handle + * @param[out] node NUMA node ID of the device + * + * @returns + * - \ref NVML_SUCCESS if the NUMA node is retrieved successfully + * - \ref NVML_ERROR_NOT_SUPPORTED if request is not supported on the current platform + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device \a node is invalid + */ +nvmlReturn_t DECLDIR nvmlDeviceGetNumaNodeId(nvmlDevice_t device, unsigned int *node); /** * Retrieve the common ancestor for two devices * For all products. @@ -3186,25 +3754,6 @@ nvmlReturn_t DECLDIR nvmlDeviceGetTopologyCommonAncestor(nvmlDevice_t device1, n */ nvmlReturn_t DECLDIR nvmlDeviceGetTopologyNearestGpus(nvmlDevice_t device, nvmlGpuTopologyLevel_t level, unsigned int *count, nvmlDevice_t *deviceArray); -/** - * Retrieve the set of GPUs that have a CPU affinity with the given CPU number - * For all products. - * Supported on Linux only. - * - * @param cpuNumber The CPU number - * @param count When zero, is set to the number of matching GPUs such that \a deviceArray - * can be malloc'd. When non-zero, \a deviceArray will be filled with \a count - * number of device handles. - * @param deviceArray An array of device handles for GPUs found with affinity to \a cpuNumber - * - * @return - * - \ref NVML_SUCCESS if \a deviceArray or \a count (if initially zero) has been set - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a cpuNumber, or \a count is invalid, or \a deviceArray is NULL with a non-zero \a count - * - \ref NVML_ERROR_NOT_SUPPORTED if the device or OS does not support this feature - * - \ref NVML_ERROR_UNKNOWN an error has occurred in underlying topology discovery - */ -nvmlReturn_t DECLDIR nvmlSystemGetTopologyGpuSet(unsigned int cpuNumber, unsigned int *count, nvmlDevice_t *deviceArray); - /** * Retrieve the status for a given p2p capability index between a given pair of GPU * @@ -3248,31 +3797,6 @@ nvmlReturn_t DECLDIR nvmlDeviceGetP2PStatus(nvmlDevice_t device1, nvmlDevice_t d */ nvmlReturn_t DECLDIR nvmlDeviceGetUUID(nvmlDevice_t device, char *uuid, unsigned int length); -/** - * Retrieve the MDEV UUID of a vGPU instance. - * - * The MDEV UUID is a globally unique identifier of the mdev device assigned to the VM, and is returned as a 5-part hexadecimal string, - * not exceeding 80 characters in length (including the NULL terminator). - * MDEV UUID is displayed only on KVM platform. - * See \ref nvmlConstants::NVML_DEVICE_UUID_BUFFER_SIZE. - * - * For Maxwell &tm; or newer fully supported devices. - * - * @param vgpuInstance Identifier of the target vGPU instance - * @param mdevUuid Pointer to caller-supplied buffer to hold MDEV UUID - * @param size Size of buffer in bytes - * - * @return - * - \ref NVML_SUCCESS successful completion - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_NOT_SUPPORTED on any hypervisor other than KVM - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a vgpuInstance is 0, or \a mdevUuid is NULL - * - \ref NVML_ERROR_NOT_FOUND if \a vgpuInstance does not match a valid active vGPU instance on the system - * - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a size is too small - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlVgpuInstanceGetMdevUUID(nvmlVgpuInstance_t vgpuInstance, char *mdevUuid, unsigned int size); - /** * Retrieves minor number for the device. The minor number for the device is such that the Nvidia device node file for * each GPU will have the form /dev/nvidia[minor number]. @@ -3408,6 +3932,27 @@ nvmlReturn_t DECLDIR nvmlDeviceGetInforomConfigurationChecksum(nvmlDevice_t devi */ nvmlReturn_t DECLDIR nvmlDeviceValidateInforom(nvmlDevice_t device); +/** + * Retrieves the timestamp and the duration of the last flush of the BBX (blackbox) infoROM object during the current run. + * + * For all products with an inforom. + * + * @param device The identifier of the target device + * @param timestamp The start timestamp of the last BBX Flush + * @param durationUs The duration (us) of the last BBX Flush + * + * @return + * - \ref NVML_SUCCESS if \a timestamp and \a durationUs are successfully retrieved + * - \ref NVML_ERROR_NOT_READY if the BBX object has not been flushed yet + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not have an infoROM + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * + * @see nvmlDeviceGetInforomVersion + */ +nvmlReturn_t DECLDIR nvmlDeviceGetLastBBXFlushTime(nvmlDevice_t device, unsigned long long *timestamp, + unsigned long *durationUs); + /** * Retrieves the display mode for the device. * @@ -3482,6 +4027,25 @@ nvmlReturn_t DECLDIR nvmlDeviceGetDisplayActive(nvmlDevice_t device, nvmlEnableS */ nvmlReturn_t DECLDIR nvmlDeviceGetPersistenceMode(nvmlDevice_t device, nvmlEnableState_t *mode); +/** + * Retrieves PCI attributes of this device. + * + * For all products. + * + * See \ref nvmlPciInfoExt_t for details on the available PCI info. + * + * @param device The identifier of the target device + * @param pci Reference in which to return the PCI info + * + * @return + * - \ref NVML_SUCCESS if \a pci has been populated + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a pci is NULL + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetPciInfoExt(nvmlDevice_t device, nvmlPciInfoExt_t *pci); + /** * Retrieves the PCI attributes of this device. * @@ -3683,6 +4247,20 @@ nvmlReturn_t DECLDIR nvmlDeviceGetClockInfo(nvmlDevice_t device, nvmlClockType_t */ nvmlReturn_t DECLDIR nvmlDeviceGetMaxClockInfo(nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock); +/** + * Retrieve the GPCCLK VF offset value + * @param[in] device The identifier of the target device + * @param[out] offset The retrieved GPCCLK VF offset value + * + * @return + * - \ref NVML_SUCCESS if \a offset has been successfully queried + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a offset is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetGpcClkVfOffset(nvmlDevice_t device, int *offset); + /** * Retrieves the current setting of a clock that applications will use unless an overspec situation occurs. * Can be changed using \ref nvmlDeviceSetApplicationsClocks. @@ -3725,33 +4303,6 @@ nvmlReturn_t DECLDIR nvmlDeviceGetApplicationsClock(nvmlDevice_t device, nvmlClo */ nvmlReturn_t DECLDIR nvmlDeviceGetDefaultApplicationsClock(nvmlDevice_t device, nvmlClockType_t clockType, unsigned int *clockMHz); -/** - * Resets the application clock to the default value - * - * This is the applications clock that will be used after system reboot or driver reload. - * Default value is constant, but the current value an be changed using \ref nvmlDeviceSetApplicationsClocks. - * - * On Pascal and newer hardware, if clocks were previously locked with \ref nvmlDeviceSetApplicationsClocks, - * this call will unlock clocks. This returns clocks their default behavior ofautomatically boosting above - * base clocks as thermal limits allow. - * - * @see nvmlDeviceGetApplicationsClock - * @see nvmlDeviceSetApplicationsClocks - * - * For Fermi &tm; or newer non-GeForce fully supported devices and Maxwell or newer GeForce devices. - * - * @param device The identifier of the target device - * - * @return - * - \ref NVML_SUCCESS if new settings were successfully set - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature - * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceResetApplicationsClocks(nvmlDevice_t device); - /** * Retrieves the clock speed for the clock specified by the clock type and clock ID. * @@ -3871,107 +4422,44 @@ nvmlReturn_t DECLDIR nvmlDeviceGetSupportedGraphicsClocks(nvmlDevice_t device, u nvmlReturn_t DECLDIR nvmlDeviceGetAutoBoostedClocksEnabled(nvmlDevice_t device, nvmlEnableState_t *isEnabled, nvmlEnableState_t *defaultIsEnabled); /** - * Try to set the current state of Auto Boosted clocks on a device. - * - * For Kepler &tm; or newer fully supported devices. + * Retrieves the intended operating speed of the device's fan. * - * Auto Boosted clocks are enabled by default on some hardware, allowing the GPU to run at higher clock rates - * to maximize performance as thermal limits allow. Auto Boosted clocks should be disabled if fixed clock - * rates are desired. + * Note: The reported speed is the intended fan speed. If the fan is physically blocked and unable to spin, the + * output will not match the actual fan speed. * - * Non-root users may use this API by default but can be restricted by root from using this API by calling - * \ref nvmlDeviceSetAPIRestriction with apiType=NVML_RESTRICTED_API_SET_AUTO_BOOSTED_CLOCKS. - * Note: Persistence Mode is required to modify current Auto Boost settings, therefore, it must be enabled. + * For all discrete products with dedicated fans. * - * On Pascal and newer hardware, Auto Boosted clocks are controlled through application clocks. - * Use \ref nvmlDeviceSetApplicationsClocks and \ref nvmlDeviceResetApplicationsClocks to control Auto Boost - * behavior. + * The fan speed is expressed as a percentage of the product's maximum noise tolerance fan speed. + * This value may exceed 100% in certain cases. * * @param device The identifier of the target device - * @param enabled What state to try to set Auto Boosted clocks of the target device to + * @param speed Reference in which to return the fan speed percentage * * @return - * - \ref NVML_SUCCESS If the Auto Boosted clocks were successfully set to the state specified by \a enabled + * - \ref NVML_SUCCESS if \a speed has been set * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support Auto Boosted clocks + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a speed is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not have a fan * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible * - \ref NVML_ERROR_UNKNOWN on any unexpected error - * */ -nvmlReturn_t DECLDIR nvmlDeviceSetAutoBoostedClocksEnabled(nvmlDevice_t device, nvmlEnableState_t enabled); +nvmlReturn_t DECLDIR nvmlDeviceGetFanSpeed(nvmlDevice_t device, unsigned int *speed); + /** - * Try to set the default state of Auto Boosted clocks on a device. This is the default state that Auto Boosted clocks will - * return to when no compute running processes (e.g. CUDA application which have an active context) are running + * Retrieves the intended operating speed of the device's specified fan. * - * For Kepler &tm; or newer non-GeForce fully supported devices and Maxwell or newer GeForce devices. - * Requires root/admin permissions. + * Note: The reported speed is the intended fan speed. If the fan is physically blocked and unable to spin, the + * output will not match the actual fan speed. * - * Auto Boosted clocks are enabled by default on some hardware, allowing the GPU to run at higher clock rates - * to maximize performance as thermal limits allow. Auto Boosted clocks should be disabled if fixed clock - * rates are desired. + * For all discrete products with dedicated fans. * - * On Pascal and newer hardware, Auto Boosted clocks are controlled through application clocks. - * Use \ref nvmlDeviceSetApplicationsClocks and \ref nvmlDeviceResetApplicationsClocks to control Auto Boost - * behavior. + * The fan speed is expressed as a percentage of the product's maximum noise tolerance fan speed. + * This value may exceed 100% in certain cases. * - * @param device The identifier of the target device - * @param enabled What state to try to set default Auto Boosted clocks of the target device to - * @param flags Flags that change the default behavior. Currently Unused. - * - * @return - * - \ref NVML_SUCCESS If the Auto Boosted clock's default state was successfully set to the state specified by \a enabled - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_NO_PERMISSION If the calling user does not have permission to change Auto Boosted clock's default state. - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support Auto Boosted clocks - * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - * - */ -nvmlReturn_t DECLDIR nvmlDeviceSetDefaultAutoBoostedClocksEnabled(nvmlDevice_t device, nvmlEnableState_t enabled, unsigned int flags); - - -/** - * Retrieves the intended operating speed of the device's fan. - * - * Note: The reported speed is the intended fan speed. If the fan is physically blocked and unable to spin, the - * output will not match the actual fan speed. - * - * For all discrete products with dedicated fans. - * - * The fan speed is expressed as a percentage of the product's maximum noise tolerance fan speed. - * This value may exceed 100% in certain cases. - * - * @param device The identifier of the target device - * @param speed Reference in which to return the fan speed percentage - * - * @return - * - \ref NVML_SUCCESS if \a speed has been set - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a speed is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not have a fan - * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceGetFanSpeed(nvmlDevice_t device, unsigned int *speed); - - -/** - * Retrieves the intended operating speed of the device's specified fan. - * - * Note: The reported speed is the intended fan speed. If the fan is physically blocked and unable to spin, the - * output will not match the actual fan speed. - * - * For all discrete products with dedicated fans. - * - * The fan speed is expressed as a percentage of the product's maximum noise tolerance fan speed. - * This value may exceed 100% in certain cases. - * - * @param device The identifier of the target device - * @param fan The index of the target fan, zero indexed. - * @param speed Reference in which to return the fan speed percentage + * @param device The identifier of the target device + * @param fan The index of the target fan, zero indexed. + * @param speed Reference in which to return the fan speed percentage * * @return * - \ref NVML_SUCCESS if \a speed has been set @@ -4011,24 +4499,6 @@ nvmlReturn_t DECLDIR nvmlDeviceGetFanSpeed_v2(nvmlDevice_t device, unsigned int */ nvmlReturn_t DECLDIR nvmlDeviceGetTargetFanSpeed(nvmlDevice_t device, unsigned int fan, unsigned int *targetSpeed); -/** - * Sets the speed of the fan control policy to default. - * - * For all cuda-capable discrete products with fans - * - * @param device The identifier of the target device - * @param fan The index of the fan, starting at zero - * - * return - * NVML_SUCCESS if speed has been adjusted - * NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * NVML_ERROR_INVALID_ARGUMENT if device is invalid - * NVML_ERROR_NOT_SUPPORTED if the device does not support this - * (doesn't have fans) - * NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceSetDefaultFanSpeed_v2(nvmlDevice_t device, unsigned int fan); - /** * Retrieves the min and max fan speed that user can set for the GPU fan. * @@ -4070,29 +4540,6 @@ nvmlReturn_t DECLDIR nvmlDeviceGetMinMaxFanSpeed(nvmlDevice_t device, unsigned i nvmlReturn_t DECLDIR nvmlDeviceGetFanControlPolicy_v2(nvmlDevice_t device, unsigned int fan, nvmlFanControlPolicy_t *policy); -/** - * Sets current fan control policy. - * - * For Maxwell &tm; or newer fully supported devices. - * - * Requires privileged user. - * - * For all cuda-capable discrete products with fans - * - * device The identifier of the target \a device - * policy The fan control \a policy to set - * - * return - * NVML_SUCCESS if \a policy has been set - * NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a policy is null or the \a fan given doesn't reference - * a fan that exists. - * NVML_ERROR_NOT_SUPPORTED if the \a device is older than Maxwell - * NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceSetFanControlPolicy(nvmlDevice_t device, unsigned int fan, - nvmlFanControlPolicy_t policy); - /** * Retrieves the number of fans on the device. * @@ -4139,6 +4586,14 @@ nvmlReturn_t DECLDIR nvmlDeviceGetTemperature(nvmlDevice_t device, nvmlTemperatu * * See \ref nvmlTemperatureThresholds_t for details on available temperature thresholds. * + * Note: This API is no longer the preferred interface for retrieving the following temperature thresholds + * on Ada and later architectures: NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, + * NVML_TEMPERATURE_THRESHOLD_MEM_MAX and NVML_TEMPERATURE_THRESHOLD_GPU_MAX. + * + * Support for reading these temperature thresholds for Ada and later architectures would be removed from this + * API in future releases. Please use \ref nvmlDeviceGetFieldValues with NVML_FI_DEV_TEMPERATURE_* fields to retrieve + * temperature thresholds on these architectures. + * * @param device The identifier of the target device * @param thresholdType The type of threshold value queried * @param temp Reference in which to return the temperature reading @@ -4152,26 +4607,6 @@ nvmlReturn_t DECLDIR nvmlDeviceGetTemperature(nvmlDevice_t device, nvmlTemperatu */ nvmlReturn_t DECLDIR nvmlDeviceGetTemperatureThreshold(nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp); -/** - * Sets the temperature threshold for the GPU with the specified threshold type in degrees C. - * - * For Maxwell &tm; or newer fully supported devices. - * - * See \ref nvmlTemperatureThresholds_t for details on available temperature thresholds. - * - * @param device The identifier of the target device - * @param thresholdType The type of threshold value to be set - * @param temp Reference which hold the value to be set - * @return - * - \ref NVML_SUCCESS if \a temp has been set - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a thresholdType is invalid or \a temp is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not have a temperature sensor or is unsupported - * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceSetTemperatureThreshold(nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, int *temp); - /** * Used to execute a list of thermal system instructions. * @@ -4210,50 +4645,60 @@ nvmlReturn_t DECLDIR nvmlDeviceGetThermalSettings(nvmlDevice_t device, unsigned nvmlReturn_t DECLDIR nvmlDeviceGetPerformanceState(nvmlDevice_t device, nvmlPstates_t *pState); /** - * Retrieves current clocks throttling reasons. + * Retrieves current clocks event reasons. * * For all fully supported products. * * \note More than one bit can be enabled at the same time. Multiple reasons can be affecting clocks at once. * * @param device The identifier of the target device - * @param clocksThrottleReasons Reference in which to return bitmask of active clocks throttle + * @param clocksEventReasons Reference in which to return bitmask of active clocks event * reasons * * @return - * - \ref NVML_SUCCESS if \a clocksThrottleReasons has been set + * - \ref NVML_SUCCESS if \a clocksEventReasons has been set * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a clocksThrottleReasons is NULL + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a clocksEventReasons is NULL * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible * - \ref NVML_ERROR_UNKNOWN on any unexpected error * - * @see nvmlClocksThrottleReasons - * @see nvmlDeviceGetSupportedClocksThrottleReasons + * @see nvmlClocksEventReasons + * @see nvmlDeviceGetSupportedClocksEventReasons + */ +nvmlReturn_t DECLDIR nvmlDeviceGetCurrentClocksEventReasons(nvmlDevice_t device, unsigned long long *clocksEventReasons); + +/** + * @deprecated Use \ref nvmlDeviceGetCurrentClocksEventReasons instead */ nvmlReturn_t DECLDIR nvmlDeviceGetCurrentClocksThrottleReasons(nvmlDevice_t device, unsigned long long *clocksThrottleReasons); /** - * Retrieves bitmask of supported clocks throttle reasons that can be returned by - * \ref nvmlDeviceGetCurrentClocksThrottleReasons + * Retrieves bitmask of supported clocks event reasons that can be returned by + * \ref nvmlDeviceGetCurrentClocksEventReasons * * For all fully supported products. * * This method is not supported in virtual machines running virtual GPU (vGPU). * * @param device The identifier of the target device - * @param supportedClocksThrottleReasons Reference in which to return bitmask of supported - * clocks throttle reasons + * @param supportedClocksEventReasons Reference in which to return bitmask of supported + * clocks event reasons * * @return - * - \ref NVML_SUCCESS if \a supportedClocksThrottleReasons has been set + * - \ref NVML_SUCCESS if \a supportedClocksEventReasons has been set * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a supportedClocksThrottleReasons is NULL + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a supportedClocksEventReasons is NULL * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible * - \ref NVML_ERROR_UNKNOWN on any unexpected error * - * @see nvmlClocksThrottleReasons - * @see nvmlDeviceGetCurrentClocksThrottleReasons + * @see nvmlClocksEventReasons + * @see nvmlDeviceGetCurrentClocksEventReasons + */ +nvmlReturn_t DECLDIR nvmlDeviceGetSupportedClocksEventReasons(nvmlDevice_t device, unsigned long long *supportedClocksEventReasons); + +/** + * @deprecated Use \ref nvmlDeviceGetSupportedClocksEventReasons instead */ nvmlReturn_t DECLDIR nvmlDeviceGetSupportedClocksThrottleReasons(nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons); @@ -4279,6 +4724,113 @@ nvmlReturn_t DECLDIR nvmlDeviceGetSupportedClocksThrottleReasons(nvmlDevice_t de */ nvmlReturn_t DECLDIR nvmlDeviceGetPowerState(nvmlDevice_t device, nvmlPstates_t *pState); +/** + * Retrieve performance monitor samples from the associated subdevice. + * + * @param device + * @param pDynamicPstatesInfo + * + * @return + * - \ref NVML_SUCCESS if \a pDynamicPstatesInfo has been set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a pDynamicPstatesInfo is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetDynamicPstatesInfo(nvmlDevice_t device, nvmlGpuDynamicPstatesInfo_t *pDynamicPstatesInfo); + +/** + * Retrieve the MemClk (Memory Clock) VF offset value. + * @param[in] device The identifier of the target device + * @param[out] offset The retrieved MemClk VF offset value + * + * @return + * - \ref NVML_SUCCESS if \a offset has been successfully queried + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a offset is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetMemClkVfOffset(nvmlDevice_t device, int *offset); + +/** + * Retrieve min and max clocks of some clock domain for a given PState + * + * @param device The identifier of the target device + * @param type Clock domain + * @param pstate PState to query + * @param minClockMHz Reference in which to return min clock frequency + * @param maxClockMHz Reference in which to return max clock frequency + * + * @return + * - \ref NVML_SUCCESS if everything worked + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device, \a type or \a pstate are invalid or both + * \a minClockMHz and \a maxClockMHz are NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + */ +nvmlReturn_t DECLDIR nvmlDeviceGetMinMaxClockOfPState(nvmlDevice_t device, nvmlClockType_t type, nvmlPstates_t pstate, + unsigned int * minClockMHz, unsigned int * maxClockMHz); + +/** + * Get all supported Performance States (P-States) for the device. + * + * The returned array would contain a contiguous list of valid P-States supported by + * the device. If the number of supported P-States is fewer than the size of the array + * supplied missing elements would contain \a NVML_PSTATE_UNKNOWN. + * + * The number of elements in the returned list will never exceed \a NVML_MAX_GPU_PERF_PSTATES. + * + * @param device The identifier of the target device + * @param pstates Container to return the list of performance states + * supported by device + * @param size Size of the supplied \a pstates array in bytes + * + * @return + * - \ref NVML_SUCCESS if \a pstates array has been retrieved + * - \ref NVML_ERROR_INSUFFICIENT_SIZE if the the container supplied was not large enough to + * hold the resulting list + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device or \a pstates is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support performance state readings + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetSupportedPerformanceStates(nvmlDevice_t device, + nvmlPstates_t *pstates, unsigned int size); + +/** + * Retrieve the GPCCLK min max VF offset value. + * @param[in] device The identifier of the target device + * @param[out] minOffset The retrieved GPCCLK VF min offset value + * @param[out] maxOffset The retrieved GPCCLK VF max offset value + * + * @return + * - \ref NVML_SUCCESS if \a offset has been successfully queried + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a offset is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetGpcClkMinMaxVfOffset(nvmlDevice_t device, + int *minOffset, int *maxOffset); + +/** + * Retrieve the MemClk (Memory Clock) min max VF offset value. + * @param[in] device The identifier of the target device + * @param[out] minOffset The retrieved MemClk VF min offset value + * @param[out] maxOffset The retrieved MemClk VF max offset value + * + * @return + * - \ref NVML_SUCCESS if \a offset has been successfully queried + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a offset is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetMemClkMinMaxVfOffset(nvmlDevice_t device, + int *minOffset, int *maxOffset); + /** * This API has been deprecated. * @@ -4378,7 +4930,12 @@ nvmlReturn_t DECLDIR nvmlDeviceGetPowerManagementDefaultLimit(nvmlDevice_t devic * * For Fermi &tm; or newer fully supported devices. * - * On Fermi and Kepler GPUs the reading is accurate to within +/- 5% of current power draw. + * On Fermi and Kepler GPUs the reading is accurate to within +/- 5% of current power draw. On Ampere + * (except GA100) or newer GPUs, the API returns power averaged over 1 sec interval. On GA100 and + * older architectures, instantaneous power is returned. + * + * See \ref NVML_FI_DEV_POWER_AVERAGE and \ref NVML_FI_DEV_POWER_INSTANT to query specific power + * values. * * It is only available if power management mode is supported. See \ref nvmlDeviceGetPowerManagementMode. * @@ -4478,6 +5035,14 @@ nvmlReturn_t DECLDIR nvmlDeviceGetGpuOperationMode(nvmlDevice_t device, nvmlGpuO * * @note nvmlDeviceGetMemoryInfo_v2 adds additional memory information. * + * @note On systems where GPUs are NUMA nodes, the accuracy of FB memory utilization + * provided by this API depends on the memory accounting of the operating system. + * This is because FB memory is managed by the operating system instead of the NVIDIA GPU driver. + * Typically, pages allocated from FB memory are not released even after + * the process terminates to enhance performance. In scenarios where + * the operating system is under memory pressure, it may resort to utilizing FB memory. + * Such actions can result in discrepancies in the accuracy of memory reporting. + * * @param device The identifier of the target device * @param memory Reference in which to return the memory information * @@ -4834,10 +5399,10 @@ nvmlReturn_t DECLDIR nvmlDeviceGetEncoderStats (nvmlDevice_t device, unsigned in * Retrieves information about active encoder sessions on a target device. * * An array of active encoder sessions is returned in the caller-supplied buffer pointed at by \a sessionInfos. The - * array elememt count is passed in \a sessionCount, and \a sessionCount is used to return the number of sessions + * array element count is passed in \a sessionCount, and \a sessionCount is used to return the number of sessions * written to the buffer. * - * If the supplied buffer is not large enough to accomodate the active session array, the function returns + * If the supplied buffer is not large enough to accommodate the active session array, the function returns * NVML_ERROR_INSUFFICIENT_SIZE, with the element count of nvmlEncoderSessionInfo_t array required in \a sessionCount. * To query the number of active encoder sessions, call this function with *sessionCount = 0. The code will return * NVML_SUCCESS with number of active encoder sessions updated in *sessionCount. @@ -4881,33 +5446,75 @@ nvmlReturn_t DECLDIR nvmlDeviceGetEncoderSessions(nvmlDevice_t device, unsigned nvmlReturn_t DECLDIR nvmlDeviceGetDecoderUtilization(nvmlDevice_t device, unsigned int *utilization, unsigned int *samplingPeriodUs); /** -* Retrieves the active frame buffer capture sessions statistics for a given device. -* -* For Maxwell &tm; or newer fully supported devices. -* -* @param device The identifier of the target device -* @param fbcStats Reference to nvmlFBCStats_t structure contianing NvFBC stats -* -* @return -* - \ref NVML_SUCCESS if \a fbcStats is fetched -* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized -* - \ref NVML_ERROR_INVALID_ARGUMENT if \a fbcStats is NULL -* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible -* - \ref NVML_ERROR_UNKNOWN on any unexpected error -*/ -nvmlReturn_t DECLDIR nvmlDeviceGetFBCStats(nvmlDevice_t device, nvmlFBCStats_t *fbcStats); - -/** -* Retrieves information about active frame buffer capture sessions on a target device. -* -* An array of active FBC sessions is returned in the caller-supplied buffer pointed at by \a sessionInfo. The -* array element count is passed in \a sessionCount, and \a sessionCount is used to return the number of sessions -* written to the buffer. -* -* If the supplied buffer is not large enough to accomodate the active session array, the function returns -* NVML_ERROR_INSUFFICIENT_SIZE, with the element count of nvmlFBCSessionInfo_t array required in \a sessionCount. -* To query the number of active FBC sessions, call this function with *sessionCount = 0. The code will return -* NVML_SUCCESS with number of active FBC sessions updated in *sessionCount. + * Retrieves the current utilization and sampling size in microseconds for the JPG + * + * %TURING_OR_NEWER% + * + * @note On MIG-enabled GPUs, querying decoder utilization is not currently supported. + * + * @param device The identifier of the target device + * @param utilization Reference to an unsigned int for jpg utilization info + * @param samplingPeriodUs Reference to an unsigned int for the sampling period in US + * + * @return + * - \ref NVML_SUCCESS if \a utilization has been populated + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a utilization is NULL, or \a samplingPeriodUs is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetJpgUtilization(nvmlDevice_t device, unsigned int *utilization, unsigned int *samplingPeriodUs); + +/** + * Retrieves the current utilization and sampling size in microseconds for the OFA (Optical Flow Accelerator) + * + * %TURING_OR_NEWER% + * + * @note On MIG-enabled GPUs, querying decoder utilization is not currently supported. + * + * @param device The identifier of the target device + * @param utilization Reference to an unsigned int for ofa utilization info + * @param samplingPeriodUs Reference to an unsigned int for the sampling period in US + * + * @return + * - \ref NVML_SUCCESS if \a utilization has been populated + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a utilization is NULL, or \a samplingPeriodUs is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetOfaUtilization(nvmlDevice_t device, unsigned int *utilization, unsigned int *samplingPeriodUs); + +/** +* Retrieves the active frame buffer capture sessions statistics for a given device. +* +* For Maxwell &tm; or newer fully supported devices. +* +* @param device The identifier of the target device +* @param fbcStats Reference to nvmlFBCStats_t structure containing NvFBC stats +* +* @return +* - \ref NVML_SUCCESS if \a fbcStats is fetched +* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized +* - \ref NVML_ERROR_INVALID_ARGUMENT if \a fbcStats is NULL +* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible +* - \ref NVML_ERROR_UNKNOWN on any unexpected error +*/ +nvmlReturn_t DECLDIR nvmlDeviceGetFBCStats(nvmlDevice_t device, nvmlFBCStats_t *fbcStats); + +/** +* Retrieves information about active frame buffer capture sessions on a target device. +* +* An array of active FBC sessions is returned in the caller-supplied buffer pointed at by \a sessionInfo. The +* array element count is passed in \a sessionCount, and \a sessionCount is used to return the number of sessions +* written to the buffer. +* +* If the supplied buffer is not large enough to accommodate the active session array, the function returns +* NVML_ERROR_INSUFFICIENT_SIZE, with the element count of nvmlFBCSessionInfo_t array required in \a sessionCount. +* To query the number of active FBC sessions, call this function with *sessionCount = 0. The code will return +* NVML_SUCCESS with number of active FBC sessions updated in *sessionCount. * * For Maxwell &tm; or newer fully supported devices. * @@ -5126,6 +5733,57 @@ nvmlReturn_t DECLDIR nvmlDeviceGetGraphicsRunningProcesses_v3(nvmlDevice_t devic */ nvmlReturn_t DECLDIR nvmlDeviceGetMPSComputeRunningProcesses_v3(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_t *infos); +/** + * Get information about running processes on a device for input context + * + * %HOPPER_OR_NEWER% + * + * This function returns information only about running processes (e.g. CUDA application which have + * active context). + * + * To determine the size of the @ref plist->procArray array to allocate, call the function with + * @ref plist->numProcArrayEntries set to zero and @ref plist->procArray set to NULL. The return + * code will be either NVML_ERROR_INSUFFICIENT_SIZE (if there are valid processes of type + * @ref plist->mode to report on, in which case the @ref plist->numProcArrayEntries field will + * indicate the required number of entries in the array) or NVML_SUCCESS (if no processes of type + * @ref plist->mode exist). + * + * The usedGpuMemory field returned is all of the memory used by the application. + * The usedGpuCcProtectedMemory field returned is all of the protected memory used by the application. + * + * Keep in mind that information returned by this call is dynamic and the number of elements might change in + * time. Allocate more space for \a plist->procArray table in case new processes are spawned. + * + * @note In MIG mode, if device handle is provided, the API returns aggregate information, only if + * the caller has appropriate privileges. Per-instance information can be queried by using + * specific MIG device handles. + * Querying per-instance information using MIG device handles is not supported if the device is in + * vGPU Host virtualization mode. + * Protected memory usage is currently not available in MIG mode and in windows. + * + * @param device The device handle or MIG device handle + * @param plist Reference in which to process detail list + * @param plist->version The api version + * @param plist->mode The process mode + * @param plist->procArray Reference in which to return the process information + * @param plist->numProcArrayEntries Proc array size of returned entries + * + * @return + * - \ref NVML_SUCCESS if \a plist->numprocArrayEntries and \a plist->procArray have been populated + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a plist->numprocArrayEntries indicates that the \a plist->procArray is too small + * \a plist->numprocArrayEntries will contain minimal amount of space necessary for + * the call to complete + * - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a plist is NULL, \a plist->version is invalid, + * \a plist->mode is invalid, + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by \a device + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * + */ +nvmlReturn_t DECLDIR nvmlDeviceGetRunningProcessDetailList(nvmlDevice_t device, nvmlProcessDetailList_t *plist); + /** * Check if the GPU devices are on the same physical board. * @@ -5369,7 +6027,9 @@ nvmlReturn_t DECLDIR nvmlDeviceGetPcieSpeed(nvmlDevice_t device, unsigned int *p * Gets the device's Adaptive Clock status * * @param device The identifier of the target device - * @param adaptiveClockStatus The current adaptive clocking status + * @param adaptiveClockStatus The current adaptive clocking status, either + * @ref NVML_ADAPTIVE_CLOCKING_INFO_STATUS_DISABLED + * or @ref NVML_ADAPTIVE_CLOCKING_INFO_STATUS_ENABLED * * @return * - \ref NVML_SUCCESS if the current adaptive clocking status is successfully retrieved @@ -5382,152 +6042,407 @@ nvmlReturn_t DECLDIR nvmlDeviceGetPcieSpeed(nvmlDevice_t device, unsigned int *p nvmlReturn_t DECLDIR nvmlDeviceGetAdaptiveClockInfoStatus(nvmlDevice_t device, unsigned int *adaptiveClockStatus); /** - * @} + * Get the type of the GPU Bus (PCIe, PCI, ...) + * + * @param device The identifier of the target device + * @param type The PCI Bus type + * + * return + * - \ref NVML_SUCCESS if the bus \a type is successfully retreived + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \device is invalid or \type is NULL + * - \ref NVML_ERROR_UNKNOWN on any unexpected error */ +nvmlReturn_t DECLDIR nvmlDeviceGetBusType(nvmlDevice_t device, nvmlBusType_t *type); -/** @addtogroup nvmlAccountingStats - * @{ - */ -/** - * Queries the state of per process accounting mode. + /** + * Deprecated: Will be deprecated in a future release. Use \ref nvmlDeviceGetGpuFabricInfoV instead * - * For Kepler &tm; or newer fully supported devices. + * Get fabric information associated with the device. + * + * %HOPPER_OR_NEWER% + * + * On Hopper + NVSwitch systems, GPU is registered with the NVIDIA Fabric Manager + * Upon successful registration, the GPU is added to the NVLink fabric to enable + * peer-to-peer communication. + * This API reports the current state of the GPU in the NVLink fabric + * along with other useful information. * - * See \ref nvmlDeviceGetAccountingStats for more details. - * See \ref nvmlDeviceSetAccountingMode * * @param device The identifier of the target device - * @param mode Reference in which to return the current accounting mode + * @param gpuFabricInfo Information about GPU fabric state * * @return - * - \ref NVML_SUCCESS if the mode has been successfully retrieved - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a mode are NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature - * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * - \ref NVML_SUCCESS Upon success + * - \ref NVML_ERROR_NOT_SUPPORTED If \a device doesn't support gpu fabric */ -nvmlReturn_t DECLDIR nvmlDeviceGetAccountingMode(nvmlDevice_t device, nvmlEnableState_t *mode); +nvmlReturn_t DECLDIR nvmlDeviceGetGpuFabricInfo(nvmlDevice_t device, nvmlGpuFabricInfo_t *gpuFabricInfo); /** - * Queries process's accounting stats. - * - * For Kepler &tm; or newer fully supported devices. +* Versioned wrapper around \ref nvmlDeviceGetGpuFabricInfo that accepts a versioned +* \ref nvmlGpuFabricInfo_v2_t or later output structure. +* +* @note The caller must set the \ref nvmlGpuFabricInfoV_t.version field to the +* appropriate version prior to calling this function. For example: +* \code +* nvmlGpuFabricInfoV_t fabricInfo = +* { .version = nvmlGpuFabricInfo_v2 }; +* nvmlReturn_t result = nvmlDeviceGetGpuFabricInfoV(device,&fabricInfo); +* \endcode +* +* %HOPPER_OR_NEWER% +* +* @param device The identifier of the target device +* @param gpuFabricInfo Information about GPU fabric state +* +* @return +* - \ref NVML_SUCCESS Upon success +* - \ref NVML_ERROR_NOT_SUPPORTED If \a device doesn't support gpu fabric +*/ +nvmlReturn_t DECLDIR nvmlDeviceGetGpuFabricInfoV(nvmlDevice_t device, + nvmlGpuFabricInfoV_t *gpuFabricInfo); + +/** + * Get Conf Computing System capabilities. * - * Accounting stats capture GPU utilization and other statistics across the lifetime of a process. - * Accounting stats can be queried during life time of the process and after its termination. - * The time field in \ref nvmlAccountingStats_t is reported as 0 during the lifetime of the process and - * updated to actual running time after its termination. - * Accounting stats are kept in a circular buffer, newly created processes overwrite information about old - * processes. + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux, Windows TCC. * - * See \ref nvmlAccountingStats_t for description of each returned metric. - * List of processes that can be queried can be retrieved from \ref nvmlDeviceGetAccountingPids. + * @param capabilities System CC capabilities * - * @note Accounting Mode needs to be on. See \ref nvmlDeviceGetAccountingMode. - * @note Only compute and graphics applications stats can be queried. Monitoring applications stats can't be - * queried since they don't contribute to GPU utilization. - * @note In case of pid collision stats of only the latest process (that terminated last) will be reported + * @return + * - \ref NVML_SUCCESS if \a capabilities were successfully queried + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a capabilities is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + */ +nvmlReturn_t DECLDIR nvmlSystemGetConfComputeCapabilities(nvmlConfComputeSystemCaps_t *capabilities); + +/** + * Get Conf Computing System State. * - * @warning On Kepler devices per process statistics are accurate only if there's one process running on a GPU. + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux, Windows TCC. * - * @param device The identifier of the target device - * @param pid Process Id of the target process to query stats for - * @param stats Reference in which to return the process's accounting stats + * @param state System CC State * * @return - * - \ref NVML_SUCCESS if stats have been successfully retrieved + * - \ref NVML_SUCCESS if \a state were successfully queried * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a stats are NULL - * - \ref NVML_ERROR_NOT_FOUND if process stats were not found - * - \ref NVML_ERROR_NOT_SUPPORTED if \a device doesn't support this feature or accounting mode is disabled - * or on vGPU host. - * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a state is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + */ +nvmlReturn_t DECLDIR nvmlSystemGetConfComputeState(nvmlConfComputeSystemState_t *state); + +/** + * Get Conf Computing Protected and Unprotected Memory Sizes. * - * @see nvmlDeviceGetAccountingBufferSize + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux, Windows TCC. + * + * @param device Device handle + * @param memInfo Protected/Unprotected Memory sizes + * + * @return + * - \ref NVML_SUCCESS if \a memInfo were successfully queried + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a memInfo or \a device is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device */ -nvmlReturn_t DECLDIR nvmlDeviceGetAccountingStats(nvmlDevice_t device, unsigned int pid, nvmlAccountingStats_t *stats); +nvmlReturn_t DECLDIR nvmlDeviceGetConfComputeMemSizeInfo(nvmlDevice_t device, nvmlConfComputeMemSizeInfo_t *memInfo); /** - * Queries list of processes that can be queried for accounting stats. The list of processes returned - * can be in running or terminated state. + * Get Conf Computing GPUs ready state. * - * For Kepler &tm; or newer fully supported devices. + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux, Windows TCC. * - * To just query the number of processes ready to be queried, call this function with *count = 0 and - * pids=NULL. The return code will be NVML_ERROR_INSUFFICIENT_SIZE, or NVML_SUCCESS if list is empty. + * @param isAcceptingWork Returns GPU current work accepting state, + * NVML_CC_ACCEPTING_CLIENT_REQUESTS_TRUE or + * NVML_CC_ACCEPTING_CLIENT_REQUESTS_FALSE * - * For more details see \ref nvmlDeviceGetAccountingStats. + * return + * - \ref NVML_SUCCESS if \a current GPUs ready state were successfully queried + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a isAcceptingWork is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + */ +nvmlReturn_t DECLDIR nvmlSystemGetConfComputeGpusReadyState(unsigned int *isAcceptingWork); + +/** + * Get Conf Computing protected memory usage. * - * @note In case of PID collision some processes might not be accessible before the circular buffer is full. + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux, Windows TCC. * * @param device The identifier of the target device - * @param count Reference in which to provide the \a pids array size, and - * to return the number of elements ready to be queried - * @param pids Reference in which to return list of process ids + * @param memory Reference in which to return the memory information * * @return - * - \ref NVML_SUCCESS if pids were successfully retrieved + * - \ref NVML_SUCCESS if \a memory has been populated * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a count is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if \a device doesn't support this feature or accounting mode is disabled - * or on vGPU host. - * - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a count is too small (\a count is set to - * expected value) + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a memory is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device * - \ref NVML_ERROR_UNKNOWN on any unexpected error - * - * @see nvmlDeviceGetAccountingBufferSize */ -nvmlReturn_t DECLDIR nvmlDeviceGetAccountingPids(nvmlDevice_t device, unsigned int *count, unsigned int *pids); +nvmlReturn_t DECLDIR nvmlDeviceGetConfComputeProtectedMemoryUsage(nvmlDevice_t device, nvmlMemory_t *memory); /** - * Returns the number of processes that the circular buffer with accounting pids can hold. - * - * For Kepler &tm; or newer fully supported devices. + * Get Conf Computing Gpu certificate details. * - * This is the maximum number of processes that accounting information will be stored for before information - * about oldest processes will get overwritten by information about new processes. + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux, Windows TCC. * * @param device The identifier of the target device - * @param bufferSize Reference in which to provide the size (in number of elements) - * of the circular buffer for accounting stats. + * @param gpuCert Reference in which to return the gpu certificate information * * @return - * - \ref NVML_SUCCESS if buffer size was successfully retrieved + * - \ref NVML_SUCCESS if \a gpu certificate info has been populated * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a bufferSize is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature or accounting mode is disabled + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a memory is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device * - \ref NVML_ERROR_UNKNOWN on any unexpected error - * - * @see nvmlDeviceGetAccountingStats - * @see nvmlDeviceGetAccountingPids - */ -nvmlReturn_t DECLDIR nvmlDeviceGetAccountingBufferSize(nvmlDevice_t device, unsigned int *bufferSize); - -/** @} */ - -/** @addtogroup nvmlDeviceQueries - * @{ */ +nvmlReturn_t DECLDIR nvmlDeviceGetConfComputeGpuCertificate(nvmlDevice_t device, + nvmlConfComputeGpuCertificate_t *gpuCert); /** - * Returns the list of retired pages by source, including pages that are pending retirement - * The address information provided from this API is the hardware address of the page that was retired. Note - * that this does not match the virtual address used in CUDA, but will match the address information in XID 63 + * Get Conf Computing Gpu attestation report. * - * For Kepler &tm; or newer fully supported devices. + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux, Windows TCC. * - * @param device The identifier of the target device - * @param cause Filter page addresses by cause of retirement - * @param pageCount Reference in which to provide the \a addresses buffer size, and - * to return the number of retired pages that match \a cause - * Set to 0 to query the size without allocating an \a addresses buffer - * @param addresses Buffer to write the page addresses into + * @param device The identifier of the target device + * @param gpuAtstReport Reference in which to return the gpu attestation report * * @return - * - \ref NVML_SUCCESS if \a pageCount was populated and \a addresses was filled - * - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a pageCount indicates the buffer is not large enough to store all the - * matching page addresses. \a pageCount is set to the needed size. + * - \ref NVML_SUCCESS if \a gpu attestation report has been populated + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a memory is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetConfComputeGpuAttestationReport(nvmlDevice_t device, + nvmlConfComputeGpuAttestationReport_t *gpuAtstReport); +/** + * Get Conf Computing key rotation threshold detail. + * + * %HOPPER_OR_NEWER% + * Supported on Linux, Windows TCC. + * + * @param pKeyRotationThrInfo Reference in which to return the key rotation threshold data + * + * @return + * - \ref NVML_SUCCESS if \a gpu key rotation threshold info has been populated + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a memory is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlSystemGetConfComputeKeyRotationThresholdInfo( + nvmlConfComputeGetKeyRotationThresholdInfo_t *pKeyRotationThrInfo); + +/** + * Get Conf Computing System Settings. + * + * %HOPPER_OR_NEWER% + * Supported on Linux, Windows TCC. + * + * @param settings System CC settings + * + * @return + * - \ref NVML_SUCCESS if the query is success + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a counters is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_ARGUMENT_VERSION_MISMATCH if the provided version is invalid/unsupported + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlSystemGetConfComputeSettings(nvmlSystemConfComputeSettings_t *settings); + +/** + * Retrieve GSP firmware version. + * + * The caller passes in buffer via \a version and corresponding GSP firmware numbered version + * is returned with the same parameter in string format. + * + * @param device Device handle + * @param version The retrieved GSP firmware version + * + * @return + * - \ref NVML_SUCCESS if GSP firmware version is sucessfully retrieved + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or GSP \a version pointer is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if GSP firmware is not enabled for GPU + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetGspFirmwareVersion(nvmlDevice_t device, char *version); + +/** + * Retrieve GSP firmware mode. + * + * The caller passes in integer pointers. GSP firmware enablement and default mode information is returned with + * corresponding parameters. The return value in \a isEnabled and \a defaultMode should be treated as boolean. + * + * @param device Device handle + * @param isEnabled Pointer to specify if GSP firmware is enabled + * @param defaultMode Pointer to specify if GSP firmware is supported by default on \a device + * + * @return + * - \ref NVML_SUCCESS if GSP firmware mode is sucessfully retrieved + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or any of \a isEnabled or \a defaultMode is NULL + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetGspFirmwareMode(nvmlDevice_t device, unsigned int *isEnabled, unsigned int *defaultMode); + +/** + * @} + */ + +/** @addtogroup nvmlAccountingStats + * @{ + */ + +/** + * Queries the state of per process accounting mode. + * + * For Kepler &tm; or newer fully supported devices. + * + * See \ref nvmlDeviceGetAccountingStats for more details. + * See \ref nvmlDeviceSetAccountingMode + * + * @param device The identifier of the target device + * @param mode Reference in which to return the current accounting mode + * + * @return + * - \ref NVML_SUCCESS if the mode has been successfully retrieved + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a mode are NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetAccountingMode(nvmlDevice_t device, nvmlEnableState_t *mode); + +/** + * Queries process's accounting stats. + * + * For Kepler &tm; or newer fully supported devices. + * + * Accounting stats capture GPU utilization and other statistics across the lifetime of a process. + * Accounting stats can be queried during life time of the process and after its termination. + * The time field in \ref nvmlAccountingStats_t is reported as 0 during the lifetime of the process and + * updated to actual running time after its termination. + * Accounting stats are kept in a circular buffer, newly created processes overwrite information about old + * processes. + * + * See \ref nvmlAccountingStats_t for description of each returned metric. + * List of processes that can be queried can be retrieved from \ref nvmlDeviceGetAccountingPids. + * + * @note Accounting Mode needs to be on. See \ref nvmlDeviceGetAccountingMode. + * @note Only compute and graphics applications stats can be queried. Monitoring applications stats can't be + * queried since they don't contribute to GPU utilization. + * @note In case of pid collision stats of only the latest process (that terminated last) will be reported + * + * @warning On Kepler devices per process statistics are accurate only if there's one process running on a GPU. + * + * @param device The identifier of the target device + * @param pid Process Id of the target process to query stats for + * @param stats Reference in which to return the process's accounting stats + * + * @return + * - \ref NVML_SUCCESS if stats have been successfully retrieved + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a stats are NULL + * - \ref NVML_ERROR_NOT_FOUND if process stats were not found + * - \ref NVML_ERROR_NOT_SUPPORTED if \a device doesn't support this feature or accounting mode is disabled + * or on vGPU host. + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * + * @see nvmlDeviceGetAccountingBufferSize + */ +nvmlReturn_t DECLDIR nvmlDeviceGetAccountingStats(nvmlDevice_t device, unsigned int pid, nvmlAccountingStats_t *stats); + +/** + * Queries list of processes that can be queried for accounting stats. The list of processes returned + * can be in running or terminated state. + * + * For Kepler &tm; or newer fully supported devices. + * + * To just query the number of processes ready to be queried, call this function with *count = 0 and + * pids=NULL. The return code will be NVML_ERROR_INSUFFICIENT_SIZE, or NVML_SUCCESS if list is empty. + * + * For more details see \ref nvmlDeviceGetAccountingStats. + * + * @note In case of PID collision some processes might not be accessible before the circular buffer is full. + * + * @param device The identifier of the target device + * @param count Reference in which to provide the \a pids array size, and + * to return the number of elements ready to be queried + * @param pids Reference in which to return list of process ids + * + * @return + * - \ref NVML_SUCCESS if pids were successfully retrieved + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a count is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if \a device doesn't support this feature or accounting mode is disabled + * or on vGPU host. + * - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a count is too small (\a count is set to + * expected value) + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * + * @see nvmlDeviceGetAccountingBufferSize + */ +nvmlReturn_t DECLDIR nvmlDeviceGetAccountingPids(nvmlDevice_t device, unsigned int *count, unsigned int *pids); + +/** + * Returns the number of processes that the circular buffer with accounting pids can hold. + * + * For Kepler &tm; or newer fully supported devices. + * + * This is the maximum number of processes that accounting information will be stored for before information + * about oldest processes will get overwritten by information about new processes. + * + * @param device The identifier of the target device + * @param bufferSize Reference in which to provide the size (in number of elements) + * of the circular buffer for accounting stats. + * + * @return + * - \ref NVML_SUCCESS if buffer size was successfully retrieved + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a bufferSize is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature or accounting mode is disabled + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * + * @see nvmlDeviceGetAccountingStats + * @see nvmlDeviceGetAccountingPids + */ +nvmlReturn_t DECLDIR nvmlDeviceGetAccountingBufferSize(nvmlDevice_t device, unsigned int *bufferSize); + +/** @} */ + +/** @addtogroup nvmlDeviceQueries + * @{ + */ + +/** + * Returns the list of retired pages by source, including pages that are pending retirement + * The address information provided from this API is the hardware address of the page that was retired. Note + * that this does not match the virtual address used in CUDA, but will match the address information in XID 63 + * + * For Kepler &tm; or newer fully supported devices. + * + * @param device The identifier of the target device + * @param cause Filter page addresses by cause of retirement + * @param pageCount Reference in which to provide the \a addresses buffer size, and + * to return the number of retired pages that match \a cause + * Set to 0 to query the size without allocating an \a addresses buffer + * @param addresses Buffer to write the page addresses into + * + * @return + * - \ref NVML_SUCCESS if \a pageCount was populated and \a addresses was filled + * - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a pageCount indicates the buffer is not large enough to store all the + * matching page addresses. \a pageCount is set to the needed size. * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a pageCount is NULL, \a cause is invalid, or * \a addresses is NULL @@ -5543,7 +6458,7 @@ nvmlReturn_t DECLDIR nvmlDeviceGetRetiredPages(nvmlDevice_t device, nvmlPageReti * The address information provided from this API is the hardware address of the page that was retired. Note * that this does not match the virtual address used in CUDA, but will match the address information in XID 63 * - * \note nvmlDeviceGetRetiredPages_v2 adds an additional timestamps paramter to return the time of each page's + * \note nvmlDeviceGetRetiredPages_v2 adds an additional timestamps parameter to return the time of each page's * retirement. * * For Kepler &tm; or newer fully supported devices. @@ -5643,6 +6558,119 @@ nvmlReturn_t DECLDIR nvmlDeviceGetRowRemapperHistogram(nvmlDevice_t device, nvml */ nvmlReturn_t DECLDIR nvmlDeviceGetArchitecture(nvmlDevice_t device, nvmlDeviceArchitecture_t *arch); +/** + * Retrieves the frequency monitor fault status for the device. + * + * For Ampere &tm; or newer fully supported devices. + * Requires root user. + * + * See \ref nvmlClkMonStatus_t for details on decoding the status output. + * + * @param device The identifier of the target device + * @param status Reference in which to return the clkmon fault status + * + * @return + * - \ref NVML_SUCCESS if \a status has been set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a status is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * + * @see nvmlDeviceGetClkMonStatus() + */ +nvmlReturn_t DECLDIR nvmlDeviceGetClkMonStatus(nvmlDevice_t device, nvmlClkMonStatus_t *status); + +/** + * Retrieves the current utilization and process ID + * + * For Maxwell &tm; or newer fully supported devices. + * + * Reads recent utilization of GPU SM (3D/Compute), framebuffer, video encoder, and video decoder for processes running. + * Utilization values are returned as an array of utilization sample structures in the caller-supplied buffer pointed at + * by \a utilization. One utilization sample structure is returned per process running, that had some non-zero utilization + * during the last sample period. It includes the CPU timestamp at which the samples were recorded. Individual utilization values + * are returned as "unsigned int" values. If no valid sample entries are found since the lastSeenTimeStamp, NVML_ERROR_NOT_FOUND + * is returned. + * + * To read utilization values, first determine the size of buffer required to hold the samples by invoking the function with + * \a utilization set to NULL. The caller should allocate a buffer of size + * processSamplesCount * sizeof(nvmlProcessUtilizationSample_t). Invoke the function again with the allocated buffer passed + * in \a utilization, and \a processSamplesCount set to the number of entries the buffer is sized for. + * + * On successful return, the function updates \a processSamplesCount with the number of process utilization sample + * structures that were actually written. This may differ from a previously read value as instances are created or + * destroyed. + * + * lastSeenTimeStamp represents the CPU timestamp in microseconds at which utilization samples were last read. Set it to 0 + * to read utilization based on all the samples maintained by the driver's internal sample buffer. Set lastSeenTimeStamp + * to a timeStamp retrieved from a previous query to read utilization since the previous query. + * + * @note On MIG-enabled GPUs, querying process utilization is not currently supported. + * + * @param device The identifier of the target device + * @param utilization Pointer to caller-supplied buffer in which guest process utilization samples are returned + * @param processSamplesCount Pointer to caller-supplied array size, and returns number of processes running + * @param lastSeenTimeStamp Return only samples with timestamp greater than lastSeenTimeStamp. + + * @return + * - \ref NVML_SUCCESS if \a utilization has been populated + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a utilization is NULL, or \a samplingPeriodUs is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_NOT_FOUND if sample entries are not found + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetProcessUtilization(nvmlDevice_t device, nvmlProcessUtilizationSample_t *utilization, + unsigned int *processSamplesCount, unsigned long long lastSeenTimeStamp); + +/** + * Retrieves the recent utilization and process ID for all running processes + * + * For Maxwell &tm; or newer fully supported devices. + * + * Reads recent utilization of GPU SM (3D/Compute), framebuffer, video encoder, and video decoder, jpeg decoder, OFA (Optical Flow Accelerator) + * for all running processes. Utilization values are returned as an array of utilization sample structures in the caller-supplied buffer pointed at + * by \a procesesUtilInfo->procUtilArray. One utilization sample structure is returned per process running, that had some non-zero utilization + * during the last sample period. It includes the CPU timestamp at which the samples were recorded. Individual utilization values + * are returned as "unsigned int" values. + * + * The caller should allocate a buffer of size processSamplesCount * sizeof(nvmlProcessUtilizationInfo_t). If the buffer is too small, the API will + * return \a NVML_ERROR_INSUFFICIENT_SIZE, with the recommended minimal buffer size at \a procesesUtilInfo->processSamplesCount. The caller should + * invoke the function again with the allocated buffer passed in \a procesesUtilInfo->procUtilArray, and \a procesesUtilInfo->processSamplesCount + * set to the number no less than the recommended value by the previous API return. + * + * On successful return, the function updates \a procesesUtilInfo->processSamplesCount with the number of process utilization info structures + * that were actually written. This may differ from a previously read value as instances are created or destroyed. + * + * \a procesesUtilInfo->lastSeenTimeStamp represents the CPU timestamp in microseconds at which utilization samples were last read. Set it to 0 + * to read utilization based on all the samples maintained by the driver's internal sample buffer. Set \a procesesUtilInfo->lastSeenTimeStamp + * to a timeStamp retrieved from a previous query to read utilization since the previous query. + * + * \a procesesUtilInfo->version is the version number of the structure nvmlProcessesUtilizationInfo_t, the caller should set the correct version + * number to retrieve the specific version of processes utilization information. + * + * @note On MIG-enabled GPUs, querying process utilization is not currently supported. + * + * @param device The identifier of the target device + * @param procesesUtilInfo Pointer to the caller-provided structure of nvmlProcessesUtilizationInfo_t. + + * @return + * - \ref NVML_SUCCESS if \a procesesUtilInfo->procUtilArray has been populated + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a procesesUtilInfo is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_NOT_FOUND if sample entries are not found + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_VERSION_MISMATCH if the version of \a procesesUtilInfo is invalid + * - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a procesesUtilInfo->procUtilArray is NULL, or the buffer size of procesesUtilInfo->procUtilArray is too small. + * The caller should check the minimul array size from the returned procesesUtilInfo->processSamplesCount, and call + * the function again with a buffer no smaller than procesesUtilInfo->processSamplesCount * sizeof(nvmlProcessUtilizationInfo_t) + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetProcessesUtilizationInfo(nvmlDevice_t device, nvmlProcessesUtilizationInfo_t *procesesUtilInfo); + /** @} */ /***************************************************************************************************/ @@ -5880,7 +6908,7 @@ typedef enum nvmlClockLimitId_enum { * Set clocks that device will lock to. * * Sets the clocks that the device will be running at to the value in the range of minGpuClockMHz to maxGpuClockMHz. - * Setting this will supercede application clock values and take effect regardless if a cuda app is running. + * Setting this will supersede application clock values and take effect regardless if a cuda app is running. * See /ref nvmlDeviceSetApplicationsClocks * * Can be used as a setting to request constant performance. @@ -5957,109 +6985,236 @@ nvmlReturn_t DECLDIR nvmlDeviceResetGpuLockedClocks(nvmlDevice_t device); * After system reboot or driver reload applications clocks go back to their default value. * See \ref nvmlDeviceResetMemoryLockedClocks. * - * For Ampere &tm; or newer fully supported devices. + * For Ampere &tm; or newer fully supported devices. + * + * @param device The identifier of the target device + * @param minMemClockMHz Requested minimum memory clock in MHz + * @param maxMemClockMHz Requested maximum memory clock in MHz + * + * @return + * - \ref NVML_SUCCESS if new settings were successfully set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a minGpuClockMHz and \a maxGpuClockMHz + * is not a valid clock combination + * - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation + * - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceSetMemoryLockedClocks(nvmlDevice_t device, unsigned int minMemClockMHz, unsigned int maxMemClockMHz); + +/** + * Resets the memory clock to the default value + * + * This is the memory clock that will be used after system reboot or driver reload. + * Default values are idle clocks, but the current values can be changed using \ref nvmlDeviceSetApplicationsClocks. + * + * @see nvmlDeviceSetMemoryLockedClocks + * + * For Ampere &tm; or newer fully supported devices. + * + * @param device The identifier of the target device + * + * @return + * - \ref NVML_SUCCESS if new settings were successfully set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceResetMemoryLockedClocks(nvmlDevice_t device); + +/** + * Set clocks that applications will lock to. + * + * Sets the clocks that compute and graphics applications will be running at. + * e.g. CUDA driver requests these clocks during context creation which means this property + * defines clocks at which CUDA applications will be running unless some overspec event + * occurs (e.g. over power, over thermal or external HW brake). + * + * Can be used as a setting to request constant performance. + * + * On Pascal and newer hardware, this will automatically disable automatic boosting of clocks. + * + * On K80 and newer Kepler and Maxwell GPUs, users desiring fixed performance should also call + * \ref nvmlDeviceSetAutoBoostedClocksEnabled to prevent clocks from automatically boosting + * above the clock value being set. + * + * For Kepler &tm; or newer non-GeForce fully supported devices and Maxwell or newer GeForce devices. + * Requires root/admin permissions. + * + * See \ref nvmlDeviceGetSupportedMemoryClocks and \ref nvmlDeviceGetSupportedGraphicsClocks + * for details on how to list available clocks combinations. + * + * After system reboot or driver reload applications clocks go back to their default value. + * See \ref nvmlDeviceResetApplicationsClocks. + * + * @param device The identifier of the target device + * @param memClockMHz Requested memory clock in MHz + * @param graphicsClockMHz Requested graphics clock in MHz + * + * @return + * - \ref NVML_SUCCESS if new settings were successfully set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a memClockMHz and \a graphicsClockMHz + * is not a valid clock combination + * - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation + * - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceSetApplicationsClocks(nvmlDevice_t device, unsigned int memClockMHz, unsigned int graphicsClockMHz); + +/** + * Resets the application clock to the default value + * + * This is the applications clock that will be used after system reboot or driver reload. + * Default value is constant, but the current value an be changed using \ref nvmlDeviceSetApplicationsClocks. + * + * On Pascal and newer hardware, if clocks were previously locked with \ref nvmlDeviceSetApplicationsClocks, + * this call will unlock clocks. This returns clocks their default behavior ofautomatically boosting above + * base clocks as thermal limits allow. + * + * @see nvmlDeviceGetApplicationsClock + * @see nvmlDeviceSetApplicationsClocks + * + * For Fermi &tm; or newer non-GeForce fully supported devices and Maxwell or newer GeForce devices. + * + * @param device The identifier of the target device + * + * @return + * - \ref NVML_SUCCESS if new settings were successfully set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceResetApplicationsClocks(nvmlDevice_t device); + +/** + * Try to set the current state of Auto Boosted clocks on a device. + * + * For Kepler &tm; or newer fully supported devices. + * + * Auto Boosted clocks are enabled by default on some hardware, allowing the GPU to run at higher clock rates + * to maximize performance as thermal limits allow. Auto Boosted clocks should be disabled if fixed clock + * rates are desired. + * + * Non-root users may use this API by default but can be restricted by root from using this API by calling + * \ref nvmlDeviceSetAPIRestriction with apiType=NVML_RESTRICTED_API_SET_AUTO_BOOSTED_CLOCKS. + * Note: Persistence Mode is required to modify current Auto Boost settings, therefore, it must be enabled. + * + * On Pascal and newer hardware, Auto Boosted clocks are controlled through application clocks. + * Use \ref nvmlDeviceSetApplicationsClocks and \ref nvmlDeviceResetApplicationsClocks to control Auto Boost + * behavior. * * @param device The identifier of the target device - * @param minMemClockMHz Requested minimum memory clock in MHz - * @param maxMemClockMHz Requested maximum memory clock in MHz + * @param enabled What state to try to set Auto Boosted clocks of the target device to * * @return - * - \ref NVML_SUCCESS if new settings were successfully set + * - \ref NVML_SUCCESS If the Auto Boosted clocks were successfully set to the state specified by \a enabled * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a minGpuClockMHz and \a maxGpuClockMHz - * is not a valid clock combination - * - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation - * - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support Auto Boosted clocks * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * */ -nvmlReturn_t DECLDIR nvmlDeviceSetMemoryLockedClocks(nvmlDevice_t device, unsigned int minMemClockMHz, unsigned int maxMemClockMHz); +nvmlReturn_t DECLDIR nvmlDeviceSetAutoBoostedClocksEnabled(nvmlDevice_t device, nvmlEnableState_t enabled); /** - * Resets the memory clock to the default value + * Try to set the default state of Auto Boosted clocks on a device. This is the default state that Auto Boosted clocks will + * return to when no compute running processes (e.g. CUDA application which have an active context) are running * - * This is the memory clock that will be used after system reboot or driver reload. - * Default values are idle clocks, but the current values can be changed using \ref nvmlDeviceSetApplicationsClocks. + * For Kepler &tm; or newer non-GeForce fully supported devices and Maxwell or newer GeForce devices. + * Requires root/admin permissions. * - * @see nvmlDeviceSetMemoryLockedClocks + * Auto Boosted clocks are enabled by default on some hardware, allowing the GPU to run at higher clock rates + * to maximize performance as thermal limits allow. Auto Boosted clocks should be disabled if fixed clock + * rates are desired. * - * For Ampere &tm; or newer fully supported devices. + * On Pascal and newer hardware, Auto Boosted clocks are controlled through application clocks. + * Use \ref nvmlDeviceSetApplicationsClocks and \ref nvmlDeviceResetApplicationsClocks to control Auto Boost + * behavior. * * @param device The identifier of the target device + * @param enabled What state to try to set default Auto Boosted clocks of the target device to + * @param flags Flags that change the default behavior. Currently Unused. * * @return - * - \ref NVML_SUCCESS if new settings were successfully set + * - \ref NVML_SUCCESS If the Auto Boosted clock's default state was successfully set to the state specified by \a enabled * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_NO_PERMISSION If the calling user does not have permission to change Auto Boosted clock's default state. * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support Auto Boosted clocks * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * */ -nvmlReturn_t DECLDIR nvmlDeviceResetMemoryLockedClocks(nvmlDevice_t device); +nvmlReturn_t DECLDIR nvmlDeviceSetDefaultAutoBoostedClocksEnabled(nvmlDevice_t device, nvmlEnableState_t enabled, unsigned int flags); /** - * Set clocks that applications will lock to. - * - * Sets the clocks that compute and graphics applications will be running at. - * e.g. CUDA driver requests these clocks during context creation which means this property - * defines clocks at which CUDA applications will be running unless some overspec event - * occurs (e.g. over power, over thermal or external HW brake). + * Sets the speed of the fan control policy to default. * - * Can be used as a setting to request constant performance. + * For all cuda-capable discrete products with fans * - * On Pascal and newer hardware, this will automatically disable automatic boosting of clocks. + * @param device The identifier of the target device + * @param fan The index of the fan, starting at zero * - * On K80 and newer Kepler and Maxwell GPUs, users desiring fixed performance should also call - * \ref nvmlDeviceSetAutoBoostedClocksEnabled to prevent clocks from automatically boosting - * above the clock value being set. + * return + * NVML_SUCCESS if speed has been adjusted + * NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * NVML_ERROR_INVALID_ARGUMENT if device is invalid + * NVML_ERROR_NOT_SUPPORTED if the device does not support this + * (doesn't have fans) + * NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceSetDefaultFanSpeed_v2(nvmlDevice_t device, unsigned int fan); + +/** + * Sets current fan control policy. * - * For Kepler &tm; or newer non-GeForce fully supported devices and Maxwell or newer GeForce devices. - * Requires root/admin permissions. + * For Maxwell &tm; or newer fully supported devices. * - * See \ref nvmlDeviceGetSupportedMemoryClocks and \ref nvmlDeviceGetSupportedGraphicsClocks - * for details on how to list available clocks combinations. + * Requires privileged user. * - * After system reboot or driver reload applications clocks go back to their default value. - * See \ref nvmlDeviceResetApplicationsClocks. + * For all cuda-capable discrete products with fans * - * @param device The identifier of the target device - * @param memClockMHz Requested memory clock in MHz - * @param graphicsClockMHz Requested graphics clock in MHz + * device The identifier of the target \a device + * policy The fan control \a policy to set * - * @return - * - \ref NVML_SUCCESS if new settings were successfully set - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a memClockMHz and \a graphicsClockMHz - * is not a valid clock combination - * - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation - * - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature - * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible - * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * return + * NVML_SUCCESS if \a policy has been set + * NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a policy is null or the \a fan given doesn't reference + * a fan that exists. + * NVML_ERROR_NOT_SUPPORTED if the \a device is older than Maxwell + * NVML_ERROR_UNKNOWN on any unexpected error */ -nvmlReturn_t DECLDIR nvmlDeviceSetApplicationsClocks(nvmlDevice_t device, unsigned int memClockMHz, unsigned int graphicsClockMHz); +nvmlReturn_t DECLDIR nvmlDeviceSetFanControlPolicy(nvmlDevice_t device, unsigned int fan, + nvmlFanControlPolicy_t policy); /** - * Retrieves the frequency monitor fault status for the device. + * Sets the temperature threshold for the GPU with the specified threshold type in degrees C. * - * For Ampere &tm; or newer fully supported devices. - * Requires root user. + * For Maxwell &tm; or newer fully supported devices. * - * See \ref nvmlClkMonStatus_t for details on decoding the status output. + * See \ref nvmlTemperatureThresholds_t for details on available temperature thresholds. * * @param device The identifier of the target device - * @param status Reference in which to return the clkmon fault status - * + * @param thresholdType The type of threshold value to be set + * @param temp Reference which hold the value to be set * @return - * - \ref NVML_SUCCESS if \a status has been set + * - \ref NVML_SUCCESS if \a temp has been set * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a status is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a thresholdType is invalid or \a temp is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not have a temperature sensor or is unsupported * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible * - \ref NVML_ERROR_UNKNOWN on any unexpected error - * - * @see nvmlDeviceGetClkMonStatus() */ -nvmlReturn_t DECLDIR nvmlDeviceGetClkMonStatus(nvmlDevice_t device, nvmlClkMonStatus_t *status); +nvmlReturn_t DECLDIR nvmlDeviceSetTemperatureThreshold(nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, int *temp); /** * Set new power limit of this device. @@ -6147,6 +7302,118 @@ nvmlReturn_t DECLDIR nvmlDeviceSetGpuOperationMode(nvmlDevice_t device, nvmlGpuO */ nvmlReturn_t DECLDIR nvmlDeviceSetAPIRestriction(nvmlDevice_t device, nvmlRestrictedAPI_t apiType, nvmlEnableState_t isRestricted); +/** + * Sets the speed of a specified fan. + * + * WARNING: This function changes the fan control policy to manual. It means that YOU have to monitor + * the temperature and adjust the fan speed accordingly. + * If you set the fan speed too low you can burn your GPU! + * Use nvmlDeviceSetDefaultFanSpeed_v2 to restore default control policy. + * + * For all cuda-capable discrete products with fans that are Maxwell or Newer. + * + * device The identifier of the target device + * fan The index of the fan, starting at zero + * speed The target speed of the fan [0-100] in % of max speed + * + * return + * NVML_SUCCESS if the fan speed has been set + * NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * NVML_ERROR_INVALID_ARGUMENT if the device is not valid, or the speed is outside acceptable ranges, + * or if the fan index doesn't reference an actual fan. + * NVML_ERROR_NOT_SUPPORTED if the device is older than Maxwell. + * NVML_ERROR_UNKNOWN if there was an unexpected error. + */ +nvmlReturn_t DECLDIR nvmlDeviceSetFanSpeed_v2(nvmlDevice_t device, unsigned int fan, unsigned int speed); + +/** + * Set the GPCCLK VF offset value + * @param[in] device The identifier of the target device + * @param[in] offset The GPCCLK VF offset value to set + * + * @return + * - \ref NVML_SUCCESS if \a offset has been set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a offset is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceSetGpcClkVfOffset(nvmlDevice_t device, int offset); + +/** + * Set the MemClk (Memory Clock) VF offset value. It requires elevated privileges. + * @param[in] device The identifier of the target device + * @param[in] offset The MemClk VF offset value to set + * + * @return + * - \ref NVML_SUCCESS if \a offset has been set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a offset is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceSetMemClkVfOffset(nvmlDevice_t device, int offset); + +/** + * Set Conf Computing Unprotected Memory Size. + * + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux, Windows TCC. + * + * @param device Device Handle + * @param sizeKiB Unprotected Memory size to be set in KiB + * + * @return + * - \ref NVML_SUCCESS if \a sizeKiB successfully set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + */ +nvmlReturn_t DECLDIR nvmlDeviceSetConfComputeUnprotectedMemSize(nvmlDevice_t device, unsigned long long sizeKiB); + +/** + * Set Conf Computing GPUs ready state. + * + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux, Windows TCC. + * + * @param isAcceptingWork GPU accepting new work, NVML_CC_ACCEPTING_CLIENT_REQUESTS_TRUE or + * NVML_CC_ACCEPTING_CLIENT_REQUESTS_FALSE + * + * return + * - \ref NVML_SUCCESS if \a current GPUs ready state is successfully set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a isAcceptingWork is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + */ +nvmlReturn_t DECLDIR nvmlSystemSetConfComputeGpusReadyState(unsigned int isAcceptingWork); + +/** + * Set Conf Computing key rotation threshold. + * + * %HOPPER_OR_NEWER% + * Supported on Linux, Windows TCC. + * + * This function is to set the confidential compute key rotation threshold parameters. + * @ref pKeyRotationThrInfo->maxAttackerAdvantage should be in the range from + * NVML_CC_KEY_ROTATION_THRESHOLD_ATTACKER_ADVANTAGE_MIN to NVML_CC_KEY_ROTATION_THRESHOLD_ATTACKER_ADVANTAGE_MAX. + * Default value is 60. + * + * @param pKeyRotationThrInfo Reference to the key rotation threshold data + * + * @return + * - \ref NVML_SUCCESS if \a key rotation threashold max attacker advantage has been set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a memory is NULL + * - \ref NVML_ERROR_INVALID_STATE if confidential compute GPU ready state is enabled + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlSystemSetConfComputeKeyRotationThresholdInfo( + nvmlConfComputeSetKeyRotationThresholdInfo_t *pKeyRotationThrInfo); + /** * @} */ @@ -6824,118 +8091,206 @@ nvmlReturn_t DECLDIR nvmlDeviceGetVirtualizationMode(nvmlDevice_t device, nvmlGp * - \ref NVML_ERROR_NOT_SUPPORTED if \a device doesn't support this feature. * - \ref NVML_ERROR_UNKNOWN if any unexpected error occurred */ -nvmlReturn_t DECLDIR nvmlDeviceGetHostVgpuMode(nvmlDevice_t device, nvmlHostVgpuMode_t *pHostVgpuMode); +nvmlReturn_t DECLDIR nvmlDeviceGetHostVgpuMode(nvmlDevice_t device, nvmlHostVgpuMode_t *pHostVgpuMode); + +/** + * This method is used to set the virtualization mode corresponding to the GPU. + * + * For Kepler &tm; or newer fully supported devices. + * + * @param device Identifier of the target device + * @param virtualMode virtualization mode. One of NVML_GPU_VIRTUALIZATION_? + * + * @return + * - \ref NVML_SUCCESS if \a virtualMode is set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a virtualMode is NULL + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_NOT_SUPPORTED if setting of virtualization mode is not supported. + * - \ref NVML_ERROR_NO_PERMISSION if setting of virtualization mode is not allowed for this client. + */ +nvmlReturn_t DECLDIR nvmlDeviceSetVirtualizationMode(nvmlDevice_t device, nvmlGpuVirtualizationMode_t virtualMode); + +/** + * Get the vGPU heterogeneous mode for the device. + * + * When in heterogeneous mode, a vGPU can concurrently host timesliced vGPUs with differing framebuffer sizes. + * + * On successful return, the function returns \a pHeterogeneousMode->mode with the current vGPU heterogeneous mode. + * \a pHeterogeneousMode->version is the version number of the structure nvmlVgpuHeterogeneousMode_t, the caller should + * set the correct version number to retrieve the vGPU heterogeneous mode. + * \a pHeterogeneousMode->mode can either be \ref NVML_FEATURE_ENABLED or \ref NVML_FEATURE_DISABLED. + * + * @param device The identifier of the target device + * @param pHeterogeneousMode Pointer to the caller-provided structure of nvmlVgpuHeterogeneousMode_t + * + * @return + * - \ref NVML_SUCCESS Upon success + * - \ref NVML_ERROR_UNINITIALIZED If library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT If \a device is invalid or \a pHeterogeneousMode is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED If \a device doesn't support this feature + * - \ref NVML_ERROR_VERSION_MISMATCH If the version of \a pHeterogeneousMode is invalid + * - \ref NVML_ERROR_UNKNOWN On any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetVgpuHeterogeneousMode(nvmlDevice_t device, nvmlVgpuHeterogeneousMode_t *pHeterogeneousMode); + +/** + * Enable or disable vGPU heterogeneous mode for the device. + * + * When in heterogeneous mode, a vGPU can concurrently host timesliced vGPUs with differing framebuffer sizes. + * + * API would return an appropriate error code upon unsuccessful activation. For example, the heterogeneous mode + * set will fail with error \ref NVML_ERROR_IN_USE if any vGPU instance is active on the device. The caller of this API + * is expected to shutdown the vGPU VMs and retry setting the \a mode. + * On successful return, the function updates the vGPU heterogeneous mode with the user provided \a pHeterogeneousMode->mode. + * \a pHeterogeneousMode->version is the version number of the structure nvmlVgpuHeterogeneousMode_t, the caller should + * set the correct version number to set the vGPU heterogeneous mode. + * + * @param device Identifier of the target device + * @param pHeterogeneousMode Pointer to the caller-provided structure of nvmlVgpuHeterogeneousMode_t + * + * @return + * - \ref NVML_SUCCESS Upon success + * - \ref NVML_ERROR_UNINITIALIZED If library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT If \a device or \a pHeterogeneousMode is NULL or \a pHeterogeneousMode->mode is invalid + * - \ref NVML_ERROR_IN_USE If the \a device is in use + * - \ref NVML_ERROR_NO_PERMISSION If user doesn't have permission to perform the operation + * - \ref NVML_ERROR_NOT_SUPPORTED If MIG is enabled or \a device doesn't support this feature + * - \ref NVML_ERROR_VERSION_MISMATCH If the version of \a pHeterogeneousMode is invalid + * - \ref NVML_ERROR_UNKNOWN On any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceSetVgpuHeterogeneousMode(nvmlDevice_t device, const nvmlVgpuHeterogeneousMode_t *pHeterogeneousMode); /** - * This method is used to set the virtualization mode corresponding to the GPU. + * Query the placement ID of active vGPU instance. * - * For Kepler &tm; or newer fully supported devices. + * When in vGPU heterogeneous mode, this function returns a valid placement ID as \a pPlacement->placementId + * else NVML_INVALID_VGPU_PLACEMENT_ID is returned. + * \a pPlacement->version is the version number of the structure nvmlVgpuPlacementId_t, the caller should + * set the correct version number to get placement id of the vGPU instance \a vgpuInstance. * - * @param device Identifier of the target device - * @param virtualMode virtualization mode. One of NVML_GPU_VIRTUALIZATION_? + * @param vgpuInstance Identifier of the target vGPU instance + * @param pPlacement Pointer to vGPU placement ID structure \a nvmlVgpuPlacementId_t * * @return - * - \ref NVML_SUCCESS if \a pVirtualMode is set - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a pVirtualMode is NULL - * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible - * - \ref NVML_ERROR_NOT_SUPPORTED if setting of virtualization mode is not supported. - * - \ref NVML_ERROR_NO_PERMISSION if setting of virtualization mode is not allowed for this client. + * - \ref NVML_SUCCESS If information is successfully retrieved + * - \ref NVML_ERROR_NOT_FOUND If \a vgpuInstance does not match a valid active vGPU instance + * - \ref NVML_ERROR_INVALID_ARGUMENT If \a vgpuInstance is invalid or \a pPlacement is NULL + * - \ref NVML_ERROR_VERSION_MISMATCH If the version of \a pPlacement is invalid + * - \ref NVML_ERROR_UNKNOWN On any unexpected error */ -nvmlReturn_t DECLDIR nvmlDeviceSetVirtualizationMode(nvmlDevice_t device, nvmlGpuVirtualizationMode_t virtualMode); +nvmlReturn_t DECLDIR nvmlVgpuInstanceGetPlacementId(nvmlVgpuInstance_t vgpuInstance, nvmlVgpuPlacementId_t *pPlacement); /** - * Retrieve the vGPU Software licensable features. + * Query the supported vGPU placement ID of the vGPU type. * - * Identifies whether the system supports vGPU Software Licensing. If it does, return the list of licensable feature(s) - * and their current license status. + * An array of supported vGPU placement IDs for the vGPU type ID indicated by \a vgpuTypeId is returned in the + * caller-supplied buffer of \a pPlacementList->placementIds. Memory needed for the placementIds array should be + * allocated based on maximum instances of a vGPU type which can be queried via \ref nvmlVgpuTypeGetMaxInstances(). * - * @param device Identifier of the target device - * @param pGridLicensableFeatures Pointer to structure in which vGPU software licensable features are returned + * This function will return supported placement IDs even if GPU is not in vGPU heterogeneous mode. + * + * @param device Identifier of the target device + * @param vgpuTypeId Handle to vGPU type. The vGPU type ID + * @param pPlacementList Pointer to the vGPU placement structure \a nvmlVgpuPlacementList_t * * @return - * - \ref NVML_SUCCESS if licensable features are successfully retrieved - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a pGridLicensableFeatures is NULL - * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * - \ref NVML_SUCCESS Upon success + * - \ref NVML_ERROR_UNINITIALIZED If library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT If \a device or \a vgpuTypeId is invalid or \a pPlacementList is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED If \a device or \a vgpuTypeId isn't supported + * - \ref NVML_ERROR_NO_PERMISSION If user doesn't have permission to perform the operation + * - \ref NVML_ERROR_VERSION_MISMATCH If the version of \a pPlacementList is invalid + * - \ref NVML_ERROR_UNKNOWN On any unexpected error */ -nvmlReturn_t DECLDIR nvmlDeviceGetGridLicensableFeatures_v4(nvmlDevice_t device, nvmlGridLicensableFeatures_t *pGridLicensableFeatures); +nvmlReturn_t DECLDIR nvmlDeviceGetVgpuTypeSupportedPlacements(nvmlDevice_t device, nvmlVgpuTypeId_t vgpuTypeId, nvmlVgpuPlacementList_t *pPlacementList); /** - * Retrieves the current utilization and process ID - * - * For Maxwell &tm; or newer fully supported devices. - * - * Reads recent utilization of GPU SM (3D/Compute), framebuffer, video encoder, and video decoder for processes running. - * Utilization values are returned as an array of utilization sample structures in the caller-supplied buffer pointed at - * by \a utilization. One utilization sample structure is returned per process running, that had some non-zero utilization - * during the last sample period. It includes the CPU timestamp at which the samples were recorded. Individual utilization values - * are returned as "unsigned int" values. + * Query the creatable vGPU placement ID of the vGPU type. * - * To read utilization values, first determine the size of buffer required to hold the samples by invoking the function with - * \a utilization set to NULL. The caller should allocate a buffer of size - * processSamplesCount * sizeof(nvmlProcessUtilizationSample_t). Invoke the function again with the allocated buffer passed - * in \a utilization, and \a processSamplesCount set to the number of entries the buffer is sized for. + * An array of creatable vGPU placement IDs for the vGPU type ID indicated by \a vgpuTypeId is returned in the + * caller-supplied buffer of \a pPlacementList->placementIds. Memory needed for the placementIds array should be + * allocated based on maximum instances of a vGPU type which can be queried via \ref nvmlVgpuTypeGetMaxInstances(). + * The creatable vGPU placement IDs may differ over time, as there may be restrictions on what type of vGPU the + * vGPU instance is running. * - * On successful return, the function updates \a processSamplesCount with the number of process utilization sample - * structures that were actually written. This may differ from a previously read value as instances are created or - * destroyed. + * The function will return \ref NVML_ERROR_NOT_SUPPORTED if the \a device is not in vGPU heterogeneous mode. * - * lastSeenTimeStamp represents the CPU timestamp in microseconds at which utilization samples were last read. Set it to 0 - * to read utilization based on all the samples maintained by the driver's internal sample buffer. Set lastSeenTimeStamp - * to a timeStamp retrieved from a previous query to read utilization since the previous query. + * @param device The identifier of the target device + * @param vgpuTypeId Handle to vGPU type. The vGPU type ID + * @param pPlacementList Pointer to the list of vGPU placement structure \a nvmlVgpuPlacementList_t * - * @note On MIG-enabled GPUs, querying process utilization is not currently supported. + * @return + * - \ref NVML_SUCCESS Upon success + * - \ref NVML_ERROR_UNINITIALIZED If library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT If \a device or \a vgpuTypeId is invalid or \a pPlacementList is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED If \a device or \a vgpuTypeId isn't supported + * - \ref NVML_ERROR_NO_PERMISSION If user doesn't have permission to perform the operation + * - \ref NVML_ERROR_VERSION_MISMATCH If the version of \a pPlacementList is invalid + * - \ref NVML_ERROR_UNKNOWN On any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetVgpuTypeCreatablePlacements(nvmlDevice_t device, nvmlVgpuTypeId_t vgpuTypeId, nvmlVgpuPlacementList_t *pPlacementList); + +/** + * Retrieve the static GSP heap size of the vGPU type in bytes * - * @param device The identifier of the target device - * @param utilization Pointer to caller-supplied buffer in which guest process utilization samples are returned - * @param processSamplesCount Pointer to caller-supplied array size, and returns number of processes running - * @param lastSeenTimeStamp Return only samples with timestamp greater than lastSeenTimeStamp. + * @param vgpuTypeId Handle to vGPU type + * @param gspHeapSize Reference to return the GSP heap size value + * @return + * - \ref NVML_SUCCESS Successful completion + * - \ref NVML_ERROR_UNINITIALIZED If the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT If \a vgpuTypeId is invalid, or \a gspHeapSize is NULL + * - \ref NVML_ERROR_UNKNOWN On any unexpected error + */ +nvmlReturn_t DECLDIR nvmlVgpuTypeGetGspHeapSize(nvmlVgpuTypeId_t vgpuTypeId, unsigned long long *gspHeapSize); +/** + * Retrieve the static framebuffer reservation of the vGPU type in bytes + * + * @param vgpuTypeId Handle to vGPU type + * @param fbReservation Reference to return the framebuffer reservation * @return - * - \ref NVML_SUCCESS if \a utilization has been populated - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a utilization is NULL, or \a samplingPeriodUs is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature - * - \ref NVML_ERROR_NOT_FOUND if sample entries are not found - * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible - * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * - \ref NVML_SUCCESS Successful completion + * - \ref NVML_ERROR_UNINITIALIZED If the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT If \a vgpuTypeId is invalid, or \a fbReservation is NULL + * - \ref NVML_ERROR_UNKNOWN On any unexpected error */ -nvmlReturn_t DECLDIR nvmlDeviceGetProcessUtilization(nvmlDevice_t device, nvmlProcessUtilizationSample_t *utilization, - unsigned int *processSamplesCount, unsigned long long lastSeenTimeStamp); +nvmlReturn_t DECLDIR nvmlVgpuTypeGetFbReservation(nvmlVgpuTypeId_t vgpuTypeId, unsigned long long *fbReservation); /** - * Retrieve GSP firmware version. + * Set the desirable vGPU capability of a device * - * The caller passes in buffer via \a version and corresponding GSP firmware numbered version - * is returned with the same parameter in string format. + * Refer to the \a nvmlDeviceVgpuCapability_t structure for the specific capabilities that can be set. + * See \ref nvmlEnableState_t for available state. * - * @param device Device handle - * @param version The retrieved GSP firmware version + * @param device The identifier of the target device + * @param capability Specifies the \a nvmlDeviceVgpuCapability_t to be set + * @param state The target capability mode * * @return - * - \ref NVML_SUCCESS if GSP firmware version is sucessfully retrieved - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or GSP \a version pointer is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if GSP firmware is not enabled for GPU - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceGetGspFirmwareVersion(nvmlDevice_t device, char *version); + * - \ref NVML_SUCCESS Successful completion + * - \ref NVML_ERROR_UNINITIALIZED If the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT If \a device is invalid, or \a capability is invalid, or \a state is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED The API is not supported in current state, or \a device not in vGPU mode + * - \ref NVML_ERROR_UNKNOWN On any unexpected error +*/ +nvmlReturn_t DECLDIR nvmlDeviceSetVgpuCapabilities(nvmlDevice_t device, nvmlDeviceVgpuCapability_t capability, nvmlEnableState_t state); /** - * Retrieve GSP firmware mode. + * Retrieve the vGPU Software licensable features. * - * The caller passes in integer pointers. GSP firmware enablement and default mode information is returned with - * corresponding parameters. The return value in \a isEnabled and \a defaultMode should be treated as boolean. + * Identifies whether the system supports vGPU Software Licensing. If it does, return the list of licensable feature(s) + * and their current license status. * - * @param device Device handle - * @param isEnabled Pointer to specify if GSP firmware is enabled - * @param defaultMode Pointer to specify if GSP firmware is supported by default on \a device + * @param device Identifier of the target device + * @param pGridLicensableFeatures Pointer to structure in which vGPU software licensable features are returned * * @return - * - \ref NVML_SUCCESS if GSP firmware mode is sucessfully retrieved - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or any of \a isEnabled or \a defaultMode is NULL + * - \ref NVML_SUCCESS if licensable features are successfully retrieved + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a pGridLicensableFeatures is NULL * - \ref NVML_ERROR_UNKNOWN on any unexpected error */ -nvmlReturn_t DECLDIR nvmlDeviceGetGspFirmwareMode(nvmlDevice_t device, unsigned int *isEnabled, unsigned int *defaultMode); +nvmlReturn_t DECLDIR nvmlDeviceGetGridLicensableFeatures_v4(nvmlDevice_t device, nvmlGridLicensableFeatures_t *pGridLicensableFeatures); /** @} */ @@ -6972,14 +8327,14 @@ nvmlReturn_t DECLDIR nvmlGetVgpuDriverCapabilities(nvmlVgpuDriverCapability_t ca * Retrieve the requested vGPU capability for GPU. * * Refer to the \a nvmlDeviceVgpuCapability_t structure for the specific capabilities that can be queried. - * The return value in \a capResult should be treated as a boolean, with a non-zero value indicating that the capability - * is supported. + * The return value in \a capResult reports a non-zero value indicating that the capability + * is supported, and also reports the capability's data based on the queried capability. * * For Maxwell &tm; or newer fully supported devices. * * @param device The identifier of the target device * @param capability Specifies the \a nvmlDeviceVgpuCapability_t to be queried - * @param capResult A boolean for the queried capability indicating that feature is supported + * @param capResult Specifies that the queried capability is supported, and also returns capability's data * * @return * - \ref NVML_SUCCESS successful completion @@ -6997,7 +8352,7 @@ nvmlReturn_t DECLDIR nvmlDeviceGetVgpuCapabilities(nvmlDevice_t device, nvmlDevi * pointed at by \a vgpuTypeIds. The element count of nvmlVgpuTypeId_t array is passed in \a vgpuCount, and \a vgpuCount * is used to return the number of vGPU types written to the buffer. * - * If the supplied buffer is not large enough to accomodate the vGPU type array, the function returns + * If the supplied buffer is not large enough to accommodate the vGPU type array, the function returns * NVML_ERROR_INSUFFICIENT_SIZE, with the element count of nvmlVgpuTypeId_t array required in \a vgpuCount. * To query the number of vGPU types supported for the GPU, call this function with *vgpuCount = 0. * The code will return NVML_ERROR_INSUFFICIENT_SIZE, or NVML_SUCCESS if no vGPU types are supported. @@ -7026,9 +8381,9 @@ nvmlReturn_t DECLDIR nvmlDeviceGetSupportedVgpus(nvmlDevice_t device, unsigned i * can concurrently run on a device. For example, if only one vGPU type is allowed at a time on a device, then the creatable * list will be restricted to whatever vGPU type is already running on the device. * - * If the supplied buffer is not large enough to accomodate the vGPU type array, the function returns + * If the supplied buffer is not large enough to accommodate the vGPU type array, the function returns * NVML_ERROR_INSUFFICIENT_SIZE, with the element count of nvmlVgpuTypeId_t array required in \a vgpuCount. - * To query the number of vGPU types createable for the GPU, call this function with *vgpuCount = 0. + * To query the number of vGPU types that can be created for the GPU, call this function with *vgpuCount = 0. * The code will return NVML_ERROR_INSUFFICIENT_SIZE, or NVML_SUCCESS if no vGPU types are creatable. * * @param device The identifier of the target device @@ -7108,7 +8463,7 @@ nvmlReturn_t DECLDIR nvmlVgpuTypeGetGpuInstanceProfileId(nvmlVgpuTypeId_t vgpuTy * * @param vgpuTypeId Handle to vGPU type * @param deviceID Device ID and vendor ID of the device contained in single 32 bit value - * @param subsystemID Subsytem ID and subsytem vendor ID of the device contained in single 32 bit value + * @param subsystemID Subsystem ID and subsystem vendor ID of the device contained in single 32 bit value * * @return * - \ref NVML_SUCCESS successful completion @@ -7247,10 +8602,10 @@ nvmlReturn_t DECLDIR nvmlVgpuTypeGetMaxInstancesPerVm(nvmlVgpuTypeId_t vgpuTypeI * Retrieve the active vGPU instances on a device. * * An array of active vGPU instances is returned in the caller-supplied buffer pointed at by \a vgpuInstances. The - * array elememt count is passed in \a vgpuCount, and \a vgpuCount is used to return the number of vGPU instances + * array element count is passed in \a vgpuCount, and \a vgpuCount is used to return the number of vGPU instances * written to the buffer. * - * If the supplied buffer is not large enough to accomodate the vGPU instance array, the function returns + * If the supplied buffer is not large enough to accommodate the vGPU instance array, the function returns * NVML_ERROR_INSUFFICIENT_SIZE, with the element count of nvmlVgpuInstance_t array required in \a vgpuCount. * To query the number of active vGPU instances, call this function with *vgpuCount = 0. The code will return * NVML_ERROR_INSUFFICIENT_SIZE, or NVML_SUCCESS if no vGPU Types are supported. @@ -7451,7 +8806,7 @@ nvmlReturn_t DECLDIR nvmlVgpuInstanceGetEccMode(nvmlVgpuInstance_t vgpuInstance, * @param encoderCapacity Reference to an unsigned int for the encoder capacity * * @return - * - \ref NVML_SUCCESS if \a encoderCapacity has been retrived + * - \ref NVML_SUCCESS if \a encoderCapacity has been retrieved * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized * - \ref NVML_ERROR_INVALID_ARGUMENT if \a vgpuInstance is 0, or \a encoderQueryType is invalid * - \ref NVML_ERROR_NOT_FOUND if \a vgpuInstance does not match a valid active vGPU instance on the system @@ -7504,7 +8859,7 @@ nvmlReturn_t DECLDIR nvmlVgpuInstanceGetEncoderStats(nvmlVgpuInstance_t vgpuInst * array element count is passed in \a sessionCount, and \a sessionCount is used to return the number of sessions * written to the buffer. * - * If the supplied buffer is not large enough to accomodate the active session array, the function returns + * If the supplied buffer is not large enough to accommodate the active session array, the function returns * NVML_ERROR_INSUFFICIENT_SIZE, with the element count of nvmlEncoderSessionInfo_t array required in \a sessionCount. * To query the number of active encoder sessions, call this function with *sessionCount = 0. The code will return * NVML_SUCCESS with number of active encoder sessions updated in *sessionCount. @@ -7534,7 +8889,7 @@ nvmlReturn_t DECLDIR nvmlVgpuInstanceGetEncoderSessions(nvmlVgpuInstance_t vgpuI * For Maxwell &tm; or newer fully supported devices. * * @param vgpuInstance Identifier of the target vGPU instance -* @param fbcStats Reference to nvmlFBCStats_t structure contianing NvFBC stats +* @param fbcStats Reference to nvmlFBCStats_t structure containing NvFBC stats * * @return * - \ref NVML_SUCCESS if \a fbcStats is fetched @@ -7552,7 +8907,7 @@ nvmlReturn_t DECLDIR nvmlVgpuInstanceGetFBCStats(nvmlVgpuInstance_t vgpuInstance * array element count is passed in \a sessionCount, and \a sessionCount is used to return the number of sessions * written to the buffer. * -* If the supplied buffer is not large enough to accomodate the active session array, the function returns +* If the supplied buffer is not large enough to accommodate the active session array, the function returns * NVML_ERROR_INSUFFICIENT_SIZE, with the element count of nvmlFBCSessionInfo_t array required in \a sessionCount. * To query the number of active FBC sessions, call this function with *sessionCount = 0. The code will return * NVML_SUCCESS with number of active FBC sessions updated in *sessionCount. @@ -7633,6 +8988,31 @@ nvmlReturn_t DECLDIR nvmlVgpuInstanceGetGpuPciId(nvmlVgpuInstance_t vgpuInstance */ nvmlReturn_t DECLDIR nvmlVgpuTypeGetCapabilities(nvmlVgpuTypeId_t vgpuTypeId, nvmlVgpuCapability_t capability, unsigned int *capResult); +/** + * Retrieve the MDEV UUID of a vGPU instance. + * + * The MDEV UUID is a globally unique identifier of the mdev device assigned to the VM, and is returned as a 5-part hexadecimal string, + * not exceeding 80 characters in length (including the NULL terminator). + * MDEV UUID is displayed only on KVM platform. + * See \ref nvmlConstants::NVML_DEVICE_UUID_BUFFER_SIZE. + * + * For Maxwell &tm; or newer fully supported devices. + * + * @param vgpuInstance Identifier of the target vGPU instance + * @param mdevUuid Pointer to caller-supplied buffer to hold MDEV UUID + * @param size Size of buffer in bytes + * + * @return + * - \ref NVML_SUCCESS successful completion + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_NOT_SUPPORTED on any hypervisor other than KVM + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a vgpuInstance is 0, or \a mdevUuid is NULL + * - \ref NVML_ERROR_NOT_FOUND if \a vgpuInstance does not match a valid active vGPU instance on the system + * - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a size is too small + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlVgpuInstanceGetMdevUUID(nvmlVgpuInstance_t vgpuInstance, char *mdevUuid, unsigned int size); + /** @} */ /***************************************************************************************************/ @@ -7662,7 +9042,7 @@ typedef struct nvmlVgpuMetadata_st char guestDriverVersion[NVML_SYSTEM_DRIVER_VERSION_BUFFER_SIZE]; //!< Version of driver installed in guest char hostDriverVersion[NVML_SYSTEM_DRIVER_VERSION_BUFFER_SIZE]; //!< Version of driver installed in host unsigned int reserved[6]; //!< Reserved for internal use - unsigned int vgpuVirtualizationCaps; //!< vGPU virtualizaion capabilities bitfileld + unsigned int vgpuVirtualizationCaps; //!< vGPU virtualization capabilities bitfield unsigned int guestVgpuVersion; //!< vGPU version of guest driver unsigned int opaqueDataSize; //!< Size of opaque data field in bytes char opaqueData[4]; //!< Opaque data @@ -7676,7 +9056,7 @@ typedef struct nvmlVgpuPgpuMetadata_st unsigned int version; //!< Current version of the structure unsigned int revision; //!< Current revision of the structure char hostDriverVersion[NVML_SYSTEM_DRIVER_VERSION_BUFFER_SIZE]; //!< Host driver version - unsigned int pgpuVirtualizationCaps; //!< Pgpu virtualizaion capabilities bitfileld + unsigned int pgpuVirtualizationCaps; //!< Pgpu virtualization capabilities bitfield unsigned int reserved[5]; //!< Reserved for internal use nvmlVgpuVersion_t hostSupportedVgpuRange; //!< vGPU version range supported by host driver unsigned int opaqueDataSize; //!< Size of opaque data field in bytes @@ -7774,7 +9154,7 @@ nvmlReturn_t DECLDIR nvmlDeviceGetVgpuMetadata(nvmlDevice_t device, nvmlVgpuPgpu * * The caller passes in a buffer via \a compatibilityInfo, into which a compatibility information structure is written. The * structure defines the states in which the vGPU / VM may be booted on the physical GPU. If the vGPU / VM compatibility - * with the physical GPU is limited, a limit code indicates the factor limiting compability. + * with the physical GPU is limited, a limit code indicates the factor limiting compatability. * (see \ref nvmlVgpuPgpuCompatibilityLimitCode_t for details). * * Note: vGPU compatibility does not take into account dynamic capacity conditions that may limit a system's ability to @@ -7833,6 +9213,7 @@ nvmlReturn_t DECLDIR nvmlDeviceGetVgpuSchedulerLog(nvmlDevice_t device, nvmlVgpu /** * Returns the vGPU scheduler state. + * The information returned in \a nvmlVgpuSchedulerGetState_t is not relevant if the BEST EFFORT policy is set. * * For Pascal &tm; or newer fully supported devices. * @@ -7847,31 +9228,6 @@ nvmlReturn_t DECLDIR nvmlDeviceGetVgpuSchedulerLog(nvmlDevice_t device, nvmlVgpu */ nvmlReturn_t DECLDIR nvmlDeviceGetVgpuSchedulerState(nvmlDevice_t device, nvmlVgpuSchedulerGetState_t *pSchedulerState); -/** - * Sets the vGPU scheduler state. - * - * For Pascal &tm; or newer fully supported devices. - * - * The scheduler state change won’t persist across module load/unload. - * Scheduler state and params will be allowed to set only when no VM is running. - * In \a nvmlVgpuSchedulerSetState_t, IFF enableARRMode=1 then - * provide avgFactorForARR and frequency as input. If enableARRMode is disabled - * then provide timeslice as input. - * - * @param device The identifier of the target \a device - * @param pSchedulerState vGPU \a pSchedulerState to set - * - * @return - * - \ref NVML_SUCCESS vGPU scheduler state has been successfully set - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a pSchedulerState is NULL or \a device is invalid - * - \ref NVML_ERROR_RESET_REQUIRED if setting \a pSchedulerState failed with fatal error, - * reboot is required to overcome from this error. - * - \ref NVML_ERROR_NOT_SUPPORTED The API is not supported in current state or \a device not in vGPU host mode - * or if any vGPU instance currently exists on the \a device - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceSetVgpuSchedulerState(nvmlDevice_t device, nvmlVgpuSchedulerSetState_t *pSchedulerState); - /** * Returns the vGPU scheduler capabilities. * The list of supported vGPU schedulers returned in \a nvmlVgpuSchedulerCapabilities_t is from @@ -7895,6 +9251,31 @@ nvmlReturn_t DECLDIR nvmlDeviceSetVgpuSchedulerState(nvmlDevice_t device, nvmlVg */ nvmlReturn_t DECLDIR nvmlDeviceGetVgpuSchedulerCapabilities(nvmlDevice_t device, nvmlVgpuSchedulerCapabilities_t *pCapabilities); +/** + * Sets the vGPU scheduler state. + * + * For Pascal &tm; or newer fully supported devices. + * + * The scheduler state change won't persist across module load/unload. + * Scheduler state and params will be allowed to set only when no VM is running. + * In \a nvmlVgpuSchedulerSetState_t, IFF enableARRMode is enabled then + * provide avgFactorForARR and frequency as input. If enableARRMode is disabled + * then provide timeslice as input. + * + * @param device The identifier of the target \a device + * @param pSchedulerState vGPU \a pSchedulerState to set + * + * @return + * - \ref NVML_SUCCESS vGPU scheduler state has been successfully set + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a pSchedulerState is NULL or \a device is invalid + * - \ref NVML_ERROR_RESET_REQUIRED if setting \a pSchedulerState failed with fatal error, + * reboot is required to overcome from this error. + * - \ref NVML_ERROR_NOT_SUPPORTED The API is not supported in current state or \a device not in vGPU host mode + * or if any vGPU instance currently exists on the \a device + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceSetVgpuSchedulerState(nvmlDevice_t device, nvmlVgpuSchedulerSetState_t *pSchedulerState); + /* * Virtual GPU (vGPU) version * @@ -8012,6 +9393,52 @@ nvmlReturn_t DECLDIR nvmlDeviceGetVgpuUtilization(nvmlDevice_t device, unsigned nvmlValueType_t *sampleValType, unsigned int *vgpuInstanceSamplesCount, nvmlVgpuInstanceUtilizationSample_t *utilizationSamples); +/** + * Retrieves recent utilization for vGPU instances running on a physical GPU (device). + * + * For Kepler &tm; or newer fully supported devices. + * + * Reads recent utilization of GPU SM (3D/Compute), framebuffer, video encoder, video decoder, jpeg decoder, and OFA for vGPU + * instances running on a device. Utilization values are returned as an array of utilization sample structures in the caller-supplied + * buffer pointed at by \a vgpuUtilInfo->vgpuUtilArray. One utilization sample structure is returned per vGPU instance, and includes the + * CPU timestamp at which the samples were recorded. Individual utilization values are returned as "unsigned int" values + * in nvmlValue_t unions. The function sets the caller-supplied \a vgpuUtilInfo->sampleValType to NVML_VALUE_TYPE_UNSIGNED_INT to + * indicate the returned value type. + * + * To read utilization values, first determine the size of buffer required to hold the samples by invoking the function with + * \a vgpuUtilInfo->vgpuUtilArray set to NULL. The function will return NVML_ERROR_INSUFFICIENT_SIZE, with the current vGPU instance + * count in \a vgpuUtilInfo->vgpuInstanceCount, or NVML_SUCCESS if the current vGPU instance count is zero. The caller should allocate + * a buffer of size vgpuUtilInfo->vgpuInstanceCount * sizeof(nvmlVgpuInstanceUtilizationInfo_t). Invoke the function again with + * the allocated buffer passed in \a vgpuUtilInfo->vgpuUtilArray, and \a vgpuUtilInfo->vgpuInstanceCount set to the number of entries the + * buffer is sized for. + * + * On successful return, the function updates \a vgpuUtilInfo->vgpuInstanceCount with the number of vGPU utilization sample + * structures that were actually written. This may differ from a previously read value as vGPU instances are created or + * destroyed. + * + * \a vgpuUtilInfo->lastSeenTimeStamp represents the CPU timestamp in microseconds at which utilization samples were last read. Set it to 0 + * to read utilization based on all the samples maintained by the driver's internal sample buffer. Set \a vgpuUtilInfo->lastSeenTimeStamp + * to a timeStamp retrieved from a previous query to read utilization since the previous query. + * + * @param device The identifier for the target device + * @param vgpuUtilInfo Pointer to the caller-provided structure of nvmlVgpuInstancesUtilizationInfo_t + + * @return + * - \ref NVML_SUCCESS if utilization samples are successfully retrieved + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a vgpuUtilInfo is NULL, or \a vgpuUtilInfo->vgpuInstanceCount is 0 + * - \ref NVML_ERROR_NOT_SUPPORTED if vGPU is not supported by the device + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_VERSION_MISMATCH if the version of \a vgpuUtilInfo is invalid + * - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a vgpuUtilInfo->vgpuUtilArray is NULL, or the buffer size of vgpuUtilInfo->vgpuInstanceCount is too small. + * The caller should check the current vGPU instance count from the returned vgpuUtilInfo->vgpuInstanceCount, and call + * the function again with a buffer of size vgpuUtilInfo->vgpuInstanceCount * sizeof(nvmlVgpuInstanceUtilizationInfo_t) + * - \ref NVML_ERROR_NOT_FOUND if sample entries are not found + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetVgpuInstancesUtilizationInfo(nvmlDevice_t device, + nvmlVgpuInstancesUtilizationInfo_t *vgpuUtilInfo); + /** * Retrieves current utilization for processes running on vGPUs on a physical GPU (device). * @@ -8058,6 +9485,52 @@ nvmlReturn_t DECLDIR nvmlDeviceGetVgpuUtilization(nvmlDevice_t device, unsigned nvmlReturn_t DECLDIR nvmlDeviceGetVgpuProcessUtilization(nvmlDevice_t device, unsigned long long lastSeenTimeStamp, unsigned int *vgpuProcessSamplesCount, nvmlVgpuProcessUtilizationSample_t *utilizationSamples); + +/** + * Retrieves recent utilization for processes running on vGPU instances on a physical GPU (device). + * + * For Maxwell &tm; or newer fully supported devices. + * + * Reads recent utilization of GPU SM (3D/Compute), framebuffer, video encoder, video decoder, jpeg decoder, and OFA for processes running + * on vGPU instances active on a device. Utilization values are returned as an array of utilization sample structures in the caller-supplied + * buffer pointed at by \a vgpuProcUtilInfo->vgpuProcUtilArray. One utilization sample structure is returned per process running + * on vGPU instances, that had some non-zero utilization during the last sample period. It includes the CPU timestamp at which + * the samples were recorded. Individual utilization values are returned as "unsigned int" values. + * + * To read utilization values, first determine the size of buffer required to hold the samples by invoking the function with + * \a vgpuProcUtilInfo->vgpuProcUtilArray set to NULL. The function will return NVML_ERROR_INSUFFICIENT_SIZE, with the current processes' count + * running on vGPU instances in \a vgpuProcUtilInfo->vgpuProcessCount. The caller should allocate a buffer of size + * vgpuProcUtilInfo->vgpuProcessCount * sizeof(nvmlVgpuProcessUtilizationSample_t). Invoke the function again with the allocated buffer passed + * in \a vgpuProcUtilInfo->vgpuProcUtilArray, and \a vgpuProcUtilInfo->vgpuProcessCount set to the number of entries the buffer is sized for. + * + * On successful return, the function updates \a vgpuProcUtilInfo->vgpuProcessCount with the number of vGPU sub process utilization sample + * structures that were actually written. This may differ from a previously read value depending on the number of processes that are active + * in any given sample period. + * + * vgpuProcUtilInfo->lastSeenTimeStamp represents the CPU timestamp in microseconds at which utilization samples were last read. Set it to 0 + * to read utilization based on all the samples maintained by the driver's internal sample buffer. Set vgpuProcUtilInfo->lastSeenTimeStamp + * to a timeStamp retrieved from a previous query to read utilization since the previous query. + * + * @param device The identifier for the target device + * @param vgpuProcUtilInfo Pointer to the caller-provided structure of nvmlVgpuProcessesUtilizationInfo_t + + * @return + * - \ref NVML_SUCCESS if utilization samples are successfully retrieved + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a vgpuProcUtilInfo is null + * - \ref NVML_ERROR_VERSION_MISMATCH if the version of \a vgpuProcUtilInfo is invalid + * - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a vgpuProcUtilInfo->vgpuProcUtilArray is null, or supplied \a vgpuProcUtilInfo->vgpuProcessCount + * is too small to return samples for all processes on vGPU instances currently executing on the device. + * The caller should check the current processes count from the returned \a vgpuProcUtilInfo->vgpuProcessCount, + * and call the function again with a buffer of size + * vgpuProcUtilInfo->vgpuProcessCount * sizeof(nvmlVgpuProcessUtilizationSample_t) + * - \ref NVML_ERROR_NOT_SUPPORTED if vGPU is not supported by the device + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_NOT_FOUND if sample entries are not found + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetVgpuProcessesUtilizationInfo(nvmlDevice_t device, nvmlVgpuProcessesUtilizationInfo_t *vgpuProcUtilInfo); + /** * Queries the state of per process accounting mode on vGPU. * @@ -8269,6 +9742,22 @@ nvmlReturn_t DECLDIR nvmlGetExcludedDeviceInfoByIndex(unsigned int index, nvmlEx #define NVML_GPU_INSTANCE_PROFILE_1_SLICE_REV2 0x9 #define NVML_GPU_INSTANCE_PROFILE_COUNT 0xA +/** + * MIG GPU instance profile capability. + * + * Bit field values representing MIG profile capabilities + * \ref nvmlGpuInstanceProfileInfo_v3_t.capabilities + */ +#define NVML_GPU_INTSTANCE_PROFILE_CAPS_P2P 0x1 + +/** + * MIG compute instance profile capability. + * + * Bit field values representing MIG profile capabilities + * \ref nvmlComputeInstanceProfileInfo_v3_t.capabilities + */ +/* No capabilities for compute profiles currently exposed */ + typedef struct nvmlGpuInstancePlacement_st { unsigned int start; //!< Index of first occupied memory slice @@ -8303,9 +9792,36 @@ typedef struct nvmlGpuInstanceProfileInfo_st */ typedef struct nvmlGpuInstanceProfileInfo_v2_st { - unsigned int version; //!< Structure version identifier (set to \ref nvmlGpuInstanceProfileInfo_v2) + unsigned int version; //!< Structure version identifier (set to \ref nvmlGpuInstanceProfileInfo_v2) + unsigned int id; //!< Unique profile ID within the device + unsigned int isP2pSupported; //!< Peer-to-Peer support + unsigned int sliceCount; //!< GPU Slice count + unsigned int instanceCount; //!< GPU instance count + unsigned int multiprocessorCount; //!< Streaming Multiprocessor count + unsigned int copyEngineCount; //!< Copy Engine count + unsigned int decoderCount; //!< Decoder Engine count + unsigned int encoderCount; //!< Encoder Engine count + unsigned int jpegCount; //!< JPEG Engine count + unsigned int ofaCount; //!< OFA Engine count + unsigned long long memorySizeMB; //!< Memory size in MBytes + char name[NVML_DEVICE_NAME_V2_BUFFER_SIZE]; //!< Profile name +} nvmlGpuInstanceProfileInfo_v2_t; + +/** + * Version identifier value for \ref nvmlGpuInstanceProfileInfo_v2_t.version. + */ +#define nvmlGpuInstanceProfileInfo_v2 NVML_STRUCT_VERSION(GpuInstanceProfileInfo, 2) + +/** + * GPU instance profile information (v3). + * + * Version 3 removes isP2pSupported field and adds the \ref nvmlGpuInstanceProfileInfo_v3_t.capabilities + * field \ref nvmlGpuInstanceProfileInfo_t. + */ +typedef struct nvmlGpuInstanceProfileInfo_v3_st +{ + unsigned int version; //!< Structure version identifier (set to \ref nvmlGpuInstanceProfileInfo_v3) unsigned int id; //!< Unique profile ID within the device - unsigned int isP2pSupported; //!< Peer-to-Peer support unsigned int sliceCount; //!< GPU Slice count unsigned int instanceCount; //!< GPU instance count unsigned int multiprocessorCount; //!< Streaming Multiprocessor count @@ -8316,12 +9832,13 @@ typedef struct nvmlGpuInstanceProfileInfo_v2_st unsigned int ofaCount; //!< OFA Engine count unsigned long long memorySizeMB; //!< Memory size in MBytes char name[NVML_DEVICE_NAME_V2_BUFFER_SIZE]; //!< Profile name -} nvmlGpuInstanceProfileInfo_v2_t; + unsigned int capabilities; //!< Additional capabilities +} nvmlGpuInstanceProfileInfo_v3_t; /** - * Version identifier value for \ref nvmlGpuInstanceProfileInfo_v2_t.version. + * Version identifier value for \ref nvmlGpuInstanceProfileInfo_v3_t.version. */ -#define nvmlGpuInstanceProfileInfo_v2 NVML_STRUCT_VERSION(GpuInstanceProfileInfo, 2) +#define nvmlGpuInstanceProfileInfo_v3 NVML_STRUCT_VERSION(GpuInstanceProfileInfo, 3) typedef struct nvmlGpuInstanceInfo_st { @@ -8342,13 +9859,13 @@ typedef struct * These macros should be passed to \ref nvmlGpuInstanceGetComputeInstanceProfileInfo to retrieve the * detailed information about a compute instance such as profile ID, engine counts */ -#define NVML_COMPUTE_INSTANCE_PROFILE_1_SLICE 0x0 -#define NVML_COMPUTE_INSTANCE_PROFILE_2_SLICE 0x1 -#define NVML_COMPUTE_INSTANCE_PROFILE_3_SLICE 0x2 -#define NVML_COMPUTE_INSTANCE_PROFILE_4_SLICE 0x3 -#define NVML_COMPUTE_INSTANCE_PROFILE_7_SLICE 0x4 -#define NVML_COMPUTE_INSTANCE_PROFILE_8_SLICE 0x5 -#define NVML_COMPUTE_INSTANCE_PROFILE_6_SLICE 0x6 +#define NVML_COMPUTE_INSTANCE_PROFILE_1_SLICE 0x0 +#define NVML_COMPUTE_INSTANCE_PROFILE_2_SLICE 0x1 +#define NVML_COMPUTE_INSTANCE_PROFILE_3_SLICE 0x2 +#define NVML_COMPUTE_INSTANCE_PROFILE_4_SLICE 0x3 +#define NVML_COMPUTE_INSTANCE_PROFILE_7_SLICE 0x4 +#define NVML_COMPUTE_INSTANCE_PROFILE_8_SLICE 0x5 +#define NVML_COMPUTE_INSTANCE_PROFILE_6_SLICE 0x6 #define NVML_COMPUTE_INSTANCE_PROFILE_1_SLICE_REV1 0x7 #define NVML_COMPUTE_INSTANCE_PROFILE_COUNT 0x8 @@ -8405,6 +9922,33 @@ typedef struct nvmlComputeInstanceProfileInfo_v2_st */ #define nvmlComputeInstanceProfileInfo_v2 NVML_STRUCT_VERSION(ComputeInstanceProfileInfo, 2) +/** + * Compute instance profile information (v3). + * + * Version 3 adds the \ref nvmlComputeInstanceProfileInfo_v3_t.capabilities field + * \ref nvmlComputeInstanceProfileInfo_t. + */ +typedef struct nvmlComputeInstanceProfileInfo_v3_st +{ + unsigned int version; //!< Structure version identifier (set to \ref nvmlComputeInstanceProfileInfo_v3) + unsigned int id; //!< Unique profile ID within the GPU instance + unsigned int sliceCount; //!< GPU Slice count + unsigned int instanceCount; //!< Compute instance count + unsigned int multiprocessorCount; //!< Streaming Multiprocessor count + unsigned int sharedCopyEngineCount; //!< Shared Copy Engine count + unsigned int sharedDecoderCount; //!< Shared Decoder Engine count + unsigned int sharedEncoderCount; //!< Shared Encoder Engine count + unsigned int sharedJpegCount; //!< Shared JPEG Engine count + unsigned int sharedOfaCount; //!< Shared OFA Engine count + char name[NVML_DEVICE_NAME_V2_BUFFER_SIZE]; //!< Profile name + unsigned int capabilities; //!< Additional capabilities +} nvmlComputeInstanceProfileInfo_v3_t; + +/** + * Version identifier value for \ref nvmlComputeInstanceProfileInfo_v3_t.version. + */ +#define nvmlComputeInstanceProfileInfo_v3 NVML_STRUCT_VERSION(ComputeInstanceProfileInfo, 3) + typedef struct nvmlComputeInstanceInfo_st { nvmlDevice_t device; //!< Parent device @@ -8477,7 +10021,7 @@ nvmlReturn_t DECLDIR nvmlDeviceSetMigMode(nvmlDevice_t device, unsigned int mode nvmlReturn_t DECLDIR nvmlDeviceGetMigMode(nvmlDevice_t device, unsigned int *currentMode, unsigned int *pendingMode); /** - * Get GPU instance profile information. + * Get GPU instance profile information * * Information provided by this API is immutable throughout the lifetime of a MIG mode. * @@ -8492,7 +10036,7 @@ nvmlReturn_t DECLDIR nvmlDeviceGetMigMode(nvmlDevice_t device, unsigned int *cur * - \ref NVML_SUCCESS Upon success * - \ref NVML_ERROR_UNINITIALIZED If library has not been successfully initialized * - \ref NVML_ERROR_INVALID_ARGUMENT If \a device, \a profile or \a info are invalid - * - \ref NVML_ERROR_NOT_SUPPORTED If \a device doesn't have MIG mode enabled or \a profile isn't supported + * - \ref NVML_ERROR_NOT_SUPPORTED If \a device doesn't support MIG or \a profile isn't supported * - \ref NVML_ERROR_NO_PERMISSION If user doesn't have permission to perform the operation */ nvmlReturn_t DECLDIR nvmlDeviceGetGpuInstanceProfileInfo(nvmlDevice_t device, unsigned int profile, @@ -8533,7 +10077,7 @@ nvmlReturn_t DECLDIR nvmlDeviceGetGpuInstanceProfileInfoV(nvmlDevice_t device, u * Get GPU instance placements. * * A placement represents the location of a GPU instance within a device. This API only returns all the possible - * placements for the given profile. + * placements for the given profile regardless of whether MIG is enabled or not. * A created GPU instance occupies memory slices described by its placement. Creation of new GPU instance will * fail if there is overlap with the already occupied memory slices. * @@ -8552,7 +10096,7 @@ nvmlReturn_t DECLDIR nvmlDeviceGetGpuInstanceProfileInfoV(nvmlDevice_t device, u * - \ref NVML_SUCCESS Upon success * - \ref NVML_ERROR_UNINITIALIZED If library has not been successfully initialized * - \ref NVML_ERROR_INVALID_ARGUMENT If \a device, \a profileId or \a count are invalid - * - \ref NVML_ERROR_NOT_SUPPORTED If \a device doesn't have MIG mode enabled or \a profileId isn't supported + * - \ref NVML_ERROR_NOT_SUPPORTED If \a device doesn't support MIG or \a profileId isn't supported * - \ref NVML_ERROR_NO_PERMISSION If user doesn't have permission to perform the operation */ nvmlReturn_t DECLDIR nvmlDeviceGetGpuInstancePossiblePlacements_v2(nvmlDevice_t device, unsigned int profileId, @@ -8946,365 +10490,157 @@ nvmlReturn_t DECLDIR nvmlGpuInstanceGetComputeInstances(nvmlGpuInstance_t gpuIns * - \ref NVML_ERROR_INVALID_ARGUMENT If \a device, \a ID or \a computeInstance are invalid * - \ref NVML_ERROR_NOT_SUPPORTED If \a device doesn't have MIG mode enabled * - \ref NVML_ERROR_NO_PERMISSION If user doesn't have permission to perform the operation - * - \ref NVML_ERROR_NOT_FOUND If the compute instance is not found. - */ -nvmlReturn_t DECLDIR nvmlGpuInstanceGetComputeInstanceById(nvmlGpuInstance_t gpuInstance, unsigned int id, - nvmlComputeInstance_t *computeInstance); - -/** - * Get compute instance information. - * - * For Ampere &tm; or newer fully supported devices. - * Supported on Linux only. - * - * @param computeInstance The compute instance handle - * @param info Return compute instance information - * - * @return - * - \ref NVML_SUCCESS Upon success - * - \ref NVML_ERROR_UNINITIALIZED If library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT If \a computeInstance or \a info are invalid - * - \ref NVML_ERROR_NO_PERMISSION If user doesn't have permission to perform the operation - */ -nvmlReturn_t DECLDIR nvmlComputeInstanceGetInfo_v2(nvmlComputeInstance_t computeInstance, nvmlComputeInstanceInfo_t *info); - -/** - * Test if the given handle refers to a MIG device. - * - * A MIG device handle is an NVML abstraction which maps to a MIG compute instance. - * These overloaded references can be used (with some restrictions) interchangeably - * with a GPU device handle to execute queries at a per-compute instance granularity. - * - * For Ampere &tm; or newer fully supported devices. - * Supported on Linux only. - * - * @param device NVML handle to test - * @param isMigDevice True when handle refers to a MIG device - * - * @return - * - \ref NVML_SUCCESS if \a device status was successfully retrieved - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device handle or \a isMigDevice reference is invalid - * - \ref NVML_ERROR_NOT_SUPPORTED if this check is not supported by the device - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceIsMigDeviceHandle(nvmlDevice_t device, unsigned int *isMigDevice); - -/** - * Get GPU instance ID for the given MIG device handle. - * - * GPU instance IDs are unique per device and remain valid until the GPU instance is destroyed. - * - * For Ampere &tm; or newer fully supported devices. - * Supported on Linux only. - * - * @param device Target MIG device handle - * @param id GPU instance ID - * - * @return - * - \ref NVML_SUCCESS if instance ID was successfully retrieved - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device or \a id reference is invalid - * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceGetGpuInstanceId(nvmlDevice_t device, unsigned int *id); - -/** - * Get compute instance ID for the given MIG device handle. - * - * Compute instance IDs are unique per GPU instance and remain valid until the compute instance - * is destroyed. - * - * For Ampere &tm; or newer fully supported devices. - * Supported on Linux only. - * - * @param device Target MIG device handle - * @param id Compute instance ID - * - * @return - * - \ref NVML_SUCCESS if instance ID was successfully retrieved - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device or \a id reference is invalid - * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceGetComputeInstanceId(nvmlDevice_t device, unsigned int *id); - -/** - * Get the maximum number of MIG devices that can exist under a given parent NVML device. - * - * Returns zero if MIG is not supported or enabled. - * - * For Ampere &tm; or newer fully supported devices. - * Supported on Linux only. - * - * @param device Target device handle - * @param count Count of MIG devices - * - * @return - * - \ref NVML_SUCCESS if \a count was successfully retrieved - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device or \a count reference is invalid - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceGetMaxMigDeviceCount(nvmlDevice_t device, unsigned int *count); - -/** - * Get MIG device handle for the given index under its parent NVML device. - * - * If the compute instance is destroyed either explicitly or by destroying, - * resetting or unbinding the parent GPU instance or the GPU device itself - * the MIG device handle would remain invalid and must be requested again - * using this API. Handles may be reused and their properties can change in - * the process. - * - * For Ampere &tm; or newer fully supported devices. - * Supported on Linux only. - * - * @param device Reference to the parent GPU device handle - * @param index Index of the MIG device - * @param migDevice Reference to the MIG device handle - * - * @return - * - \ref NVML_SUCCESS if \a migDevice handle was successfully created - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device, \a index or \a migDevice reference is invalid - * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device - * - \ref NVML_ERROR_NOT_FOUND if no valid MIG device was found at \a index - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceGetMigDeviceHandleByIndex(nvmlDevice_t device, unsigned int index, - nvmlDevice_t *migDevice); - -/** - * Get parent device handle from a MIG device handle. - * - * For Ampere &tm; or newer fully supported devices. - * Supported on Linux only. - * - * @param migDevice MIG device handle - * @param device Device handle - * - * @return - * - \ref NVML_SUCCESS if \a device handle was successfully created - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a migDevice or \a device is invalid - * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceGetDeviceHandleFromMigDeviceHandle(nvmlDevice_t migDevice, nvmlDevice_t *device); - -/** - * Get the type of the GPU Bus (PCIe, PCI, ...) - * - * @param device The identifier of the target device - * @param type The PCI Bus type - * - * return - * - \ref NVML_SUCCESS if the bus \a type is successfully retreived - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \device is invalid or \type is NULL - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceGetBusType(nvmlDevice_t device, nvmlBusType_t *type); - -/** - * Retrieve performance monitor samples from the associated subdevice. - * - * @param device - * @param pDynamicPstatesInfo - * - * @return - * - \ref NVML_SUCCESS if \a pDynamicPstatesInfo has been set - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a pDynamicPstatesInfo is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature - * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceGetDynamicPstatesInfo(nvmlDevice_t device, nvmlGpuDynamicPstatesInfo_t *pDynamicPstatesInfo); - -/** - * Sets the speed of a specified fan. - * - * WARNING: This function changes the fan control policy to manual. It means that YOU have to monitor - * the temperature and adjust the fan speed accordingly. - * If you set the fan speed too low you can burn your GPU! - * Use nvmlDeviceSetDefaultFanSpeed_v2 to restore default control policy. - * - * For all cuda-capable discrete products with fans that are Maxwell or Newer. - * - * device The identifier of the target device - * fan The index of the fan, starting at zero - * speed The target speed of the fan [0-100] in % of max speed - * - * return - * NVML_SUCCESS if the fan speed has been set - * NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * NVML_ERROR_INVALID_ARGUMENT if the device is not valid, or the speed is outside acceptable ranges, - * or if the fan index doesn't reference an actual fan. - * NVML_ERROR_NOT_SUPPORTED if the device is older than Maxwell. - * NVML_ERROR_UNKNOWN if there was an unexpected error. - */ -nvmlReturn_t DECLDIR nvmlDeviceSetFanSpeed_v2(nvmlDevice_t device, unsigned int fan, unsigned int speed); - -/** - * Retrieve the GPCCLK VF offset value - * @param[in] device The identifier of the target device - * @param[out] offset The retrieved GPCCLK VF offset value - * - * @return - * - \ref NVML_SUCCESS if \a offset has been successfully queried - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a offset is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature - * - \ref NVML_ERROR_UNKNOWN on any unexpected error - */ -nvmlReturn_t DECLDIR nvmlDeviceGetGpcClkVfOffset(nvmlDevice_t device, int *offset); - -/** - * Set the GPCCLK VF offset value - * @param[in] device The identifier of the target device - * @param[in] offset The GPCCLK VF offset value to set - * - * @return - * - \ref NVML_SUCCESS if \a offset has been set - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a offset is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature - * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible - * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * - \ref NVML_ERROR_NOT_FOUND If the compute instance is not found. */ -nvmlReturn_t DECLDIR nvmlDeviceSetGpcClkVfOffset(nvmlDevice_t device, int offset); +nvmlReturn_t DECLDIR nvmlGpuInstanceGetComputeInstanceById(nvmlGpuInstance_t gpuInstance, unsigned int id, + nvmlComputeInstance_t *computeInstance); /** - * Retrieve the MemClk (Memory Clock) VF offset value. - * @param[in] device The identifier of the target device - * @param[out] offset The retrieved MemClk VF offset value + * Get compute instance information. + * + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux only. + * + * @param computeInstance The compute instance handle + * @param info Return compute instance information * * @return - * - \ref NVML_SUCCESS if \a offset has been successfully queried - * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a offset is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature - * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * - \ref NVML_SUCCESS Upon success + * - \ref NVML_ERROR_UNINITIALIZED If library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT If \a computeInstance or \a info are invalid + * - \ref NVML_ERROR_NO_PERMISSION If user doesn't have permission to perform the operation */ -nvmlReturn_t DECLDIR nvmlDeviceGetMemClkVfOffset(nvmlDevice_t device, int *offset); +nvmlReturn_t DECLDIR nvmlComputeInstanceGetInfo_v2(nvmlComputeInstance_t computeInstance, nvmlComputeInstanceInfo_t *info); /** - * Set the MemClk (Memory Clock) VF offset value. It requires elevated privileges. - * @param[in] device The identifier of the target device - * @param[in] offset The MemClk VF offset value to set + * Test if the given handle refers to a MIG device. + * + * A MIG device handle is an NVML abstraction which maps to a MIG compute instance. + * These overloaded references can be used (with some restrictions) interchangeably + * with a GPU device handle to execute queries at a per-compute instance granularity. + * + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux only. + * + * @param device NVML handle to test + * @param isMigDevice True when handle refers to a MIG device * * @return - * - \ref NVML_SUCCESS if \a offset has been set + * - \ref NVML_SUCCESS if \a device status was successfully retrieved * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a offset is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature - * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device handle or \a isMigDevice reference is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if this check is not supported by the device * - \ref NVML_ERROR_UNKNOWN on any unexpected error */ -nvmlReturn_t DECLDIR nvmlDeviceSetMemClkVfOffset(nvmlDevice_t device, int offset); +nvmlReturn_t DECLDIR nvmlDeviceIsMigDeviceHandle(nvmlDevice_t device, unsigned int *isMigDevice); /** - * Retrieve min and max clocks of some clock domain for a given PState + * Get GPU instance ID for the given MIG device handle. * - * @param device The identifier of the target device - * @param type Clock domain - * @param pstate PState to query - * @param minClockMHz Reference in which to return min clock frequency - * @param maxClockMHz Reference in which to return max clock frequency + * GPU instance IDs are unique per device and remain valid until the GPU instance is destroyed. + * + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux only. + * + * @param device Target MIG device handle + * @param id GPU instance ID * * @return - * - \ref NVML_SUCCESS if everything worked + * - \ref NVML_SUCCESS if instance ID was successfully retrieved * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device, \a type or \a pstate are invalid or both - * \a minClockMHz and \a maxClockMHz are NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device or \a id reference is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + * - \ref NVML_ERROR_UNKNOWN on any unexpected error */ -nvmlReturn_t DECLDIR nvmlDeviceGetMinMaxClockOfPState(nvmlDevice_t device, nvmlClockType_t type, nvmlPstates_t pstate, - unsigned int * minClockMHz, unsigned int * maxClockMHz); +nvmlReturn_t DECLDIR nvmlDeviceGetGpuInstanceId(nvmlDevice_t device, unsigned int *id); /** - * Get all supported Performance States (P-States) for the device. + * Get compute instance ID for the given MIG device handle. * - * The returned array would contain a contiguous list of valid P-States supported by - * the device. If the number of supported P-States is fewer than the size of the array - * supplied missing elements would contain \a NVML_PSTATE_UNKNOWN. + * Compute instance IDs are unique per GPU instance and remain valid until the compute instance + * is destroyed. * - * The number of elements in the returned list will never exceed \a NVML_MAX_GPU_PERF_PSTATES. + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux only. * - * @param device The identifier of the target device - * @param pstates Container to return the list of performance states - * supported by device - * @param size Size of the supplied \a pstates array in bytes + * @param device Target MIG device handle + * @param id Compute instance ID * * @return - * - \ref NVML_SUCCESS if \a pstates array has been retrieved - * - \ref NVML_ERROR_INSUFFICIENT_SIZE if the the container supplied was not large enough to - * hold the resulting list + * - \ref NVML_SUCCESS if instance ID was successfully retrieved * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device or \a pstates is invalid - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support performance state readings + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device or \a id reference is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device * - \ref NVML_ERROR_UNKNOWN on any unexpected error */ -nvmlReturn_t DECLDIR nvmlDeviceGetSupportedPerformanceStates(nvmlDevice_t device, - nvmlPstates_t *pstates, unsigned int size); +nvmlReturn_t DECLDIR nvmlDeviceGetComputeInstanceId(nvmlDevice_t device, unsigned int *id); /** - * Retrieve the GPCCLK min max VF offset value. - * @param[in] device The identifier of the target device - * @param[out] minOffset The retrieved GPCCLK VF min offset value - * @param[out] maxOffset The retrieved GPCCLK VF max offset value + * Get the maximum number of MIG devices that can exist under a given parent NVML device. + * + * Returns zero if MIG is not supported or enabled. + * + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux only. + * + * @param device Target device handle + * @param count Count of MIG devices * * @return - * - \ref NVML_SUCCESS if \a offset has been successfully queried + * - \ref NVML_SUCCESS if \a count was successfully retrieved * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a offset is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device or \a count reference is invalid * - \ref NVML_ERROR_UNKNOWN on any unexpected error */ -nvmlReturn_t DECLDIR nvmlDeviceGetGpcClkMinMaxVfOffset(nvmlDevice_t device, - int *minOffset, int *maxOffset); +nvmlReturn_t DECLDIR nvmlDeviceGetMaxMigDeviceCount(nvmlDevice_t device, unsigned int *count); /** - * Retrieve the MemClk (Memory Clock) min max VF offset value. - * @param[in] device The identifier of the target device - * @param[out] minOffset The retrieved MemClk VF min offset value - * @param[out] maxOffset The retrieved MemClk VF max offset value + * Get MIG device handle for the given index under its parent NVML device. + * + * If the compute instance is destroyed either explicitly or by destroying, + * resetting or unbinding the parent GPU instance or the GPU device itself + * the MIG device handle would remain invalid and must be requested again + * using this API. Handles may be reused and their properties can change in + * the process. + * + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux only. + * + * @param device Reference to the parent GPU device handle + * @param index Index of the MIG device + * @param migDevice Reference to the MIG device handle * * @return - * - \ref NVML_SUCCESS if \a offset has been successfully queried + * - \ref NVML_SUCCESS if \a migDevice handle was successfully created * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized - * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a offset is NULL - * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device, \a index or \a migDevice reference is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + * - \ref NVML_ERROR_NOT_FOUND if no valid MIG device was found at \a index * - \ref NVML_ERROR_UNKNOWN on any unexpected error */ -nvmlReturn_t DECLDIR nvmlDeviceGetMemClkMinMaxVfOffset(nvmlDevice_t device, - int *minOffset, int *maxOffset); +nvmlReturn_t DECLDIR nvmlDeviceGetMigDeviceHandleByIndex(nvmlDevice_t device, unsigned int index, + nvmlDevice_t *migDevice); /** - * Get fabric information associated with the device. - * - * %HOPPER_OR_NEWER% + * Get parent device handle from a MIG device handle. * - * On Hopper + NVSwitch systems, GPU is registered with the NVIDIA Fabric Manager - * Upon successful registration, the GPU is added to the NVLink fabric to enable - * peer-to-peer communication. - * This API reports the current state of the GPU in the NVLink fabric - * along with other useful information. + * For Ampere &tm; or newer fully supported devices. + * Supported on Linux only. * - * @param device The identifier of the target device - * @param gpuFabricInfo Information about GPU fabric state + * @param migDevice MIG device handle + * @param device Device handle * * @return - * - \ref NVML_SUCCESS Upon success - * - \ref NVML_ERROR_NOT_SUPPORTED If \a device doesn't support gpu fabric + * - \ref NVML_SUCCESS if \a device handle was successfully created + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a migDevice or \a device is invalid + * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device + * - \ref NVML_ERROR_UNKNOWN on any unexpected error */ -nvmlReturn_t DECLDIR nvmlDeviceGetGpuFabricInfo(nvmlDevice_t device, nvmlGpuFabricInfo_t *gpuFabricInfo); +nvmlReturn_t DECLDIR nvmlDeviceGetDeviceHandleFromMigDeviceHandle(nvmlDevice_t migDevice, nvmlDevice_t *device); + +/** @} */ // @defgroup nvmlMultiInstanceGPU -/** @} */ /***************************************************************************************************/ /** @defgroup GPM NVML GPM @@ -9316,81 +10652,81 @@ nvmlReturn_t DECLDIR nvmlDeviceGetGpuFabricInfo(nvmlDevice_t device, nvmlGpuFabr */ /***************************************************************************************************/ -/* GPM Metric Identifiers */ +/** + * GPM Metric Identifiers + */ typedef enum { - NVML_GPM_METRIC_GRAPHICS_UTIL = 1, /* Percentage of time any compute/graphics app was active on the GPU. 0.0 - 100.0 */ - NVML_GPM_METRIC_SM_UTIL = 2, /* Percentage of SMs that were busy. 0.0 - 100.0 */ - NVML_GPM_METRIC_SM_OCCUPANCY = 3, /* Percentage of warps that were active vs theoretical maximum. 0.0 - 100.0 */ - NVML_GPM_METRIC_INTEGER_UTIL = 4, /* Percentage of time the GPU's SMs were doing integer operations. 0.0 - 100.0 */ - NVML_GPM_METRIC_ANY_TENSOR_UTIL = 5, /* Percentage of time the GPU's SMs were doing ANY tensor operations. 0.0 - 100.0 */ - NVML_GPM_METRIC_DFMA_TENSOR_UTIL = 6, /* Percentage of time the GPU's SMs were doing DFMA tensor operations. 0.0 - 100.0 */ - NVML_GPM_METRIC_HMMA_TENSOR_UTIL = 7, /* Percentage of time the GPU's SMs were doing HMMA tensor operations. 0.0 - 100.0 */ - NVML_GPM_METRIC_IMMA_TENSOR_UTIL = 9, /* Percentage of time the GPU's SMs were doing IMMA tensor operations. 0.0 - 100.0 */ - NVML_GPM_METRIC_DRAM_BW_UTIL = 10, /* Percentage of DRAM bw used vs theoretical maximum. 0.0 - 100.0 */ - NVML_GPM_METRIC_FP64_UTIL = 11, /* Percentage of time the GPU's SMs were doing non-tensor FP64 math. 0.0 - 100.0 */ - NVML_GPM_METRIC_FP32_UTIL = 12, /* Percentage of time the GPU's SMs were doing non-tensor FP32 math. 0.0 - 100.0 */ - NVML_GPM_METRIC_FP16_UTIL = 13, /* Percentage of time the GPU's SMs were doing non-tensor FP16 math. 0.0 - 100.0 */ - NVML_GPM_METRIC_PCIE_TX_PER_SEC = 20, /* PCIe traffic from this GPU in MiB/sec */ - NVML_GPM_METRIC_PCIE_RX_PER_SEC = 21, /* PCIe traffic to this GPU in MiB/sec */ - NVML_GPM_METRIC_NVDEC_0_UTIL = 30, /* Percent utilization of NVDEC 0. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVDEC_1_UTIL = 31, /* Percent utilization of NVDEC 1. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVDEC_2_UTIL = 32, /* Percent utilization of NVDEC 2. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVDEC_3_UTIL = 33, /* Percent utilization of NVDEC 3. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVDEC_4_UTIL = 34, /* Percent utilization of NVDEC 4. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVDEC_5_UTIL = 35, /* Percent utilization of NVDEC 5. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVDEC_6_UTIL = 36, /* Percent utilization of NVDEC 6. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVDEC_7_UTIL = 37, /* Percent utilization of NVDEC 7. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVJPG_0_UTIL = 40, /* Percent utilization of NVJPG 0. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVJPG_1_UTIL = 41, /* Percent utilization of NVJPG 1. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVJPG_2_UTIL = 42, /* Percent utilization of NVJPG 2. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVJPG_3_UTIL = 43, /* Percent utilization of NVJPG 3. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVJPG_4_UTIL = 44, /* Percent utilization of NVJPG 4. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVJPG_5_UTIL = 45, /* Percent utilization of NVJPG 5. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVJPG_6_UTIL = 46, /* Percent utilization of NVJPG 6. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVJPG_7_UTIL = 47, /* Percent utilization of NVJPG 7. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVOFA_0_UTIL = 50, /* Percent utilization of NVOFA 0. 0.0 - 100.0 */ - NVML_GPM_METRIC_NVLINK_TOTAL_RX_PER_SEC = 60, /* NvLink read bandwidth for all links in MiB/sec */ - NVML_GPM_METRIC_NVLINK_TOTAL_TX_PER_SEC = 61, /* NvLink write bandwidth for all links in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L0_RX_PER_SEC = 62, /* NvLink read bandwidth for link 0 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L0_TX_PER_SEC = 63, /* NvLink write bandwidth for link 0 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L1_RX_PER_SEC = 64, /* NvLink read bandwidth for link 1 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L1_TX_PER_SEC = 65, /* NvLink write bandwidth for link 1 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L2_RX_PER_SEC = 66, /* NvLink read bandwidth for link 2 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L2_TX_PER_SEC = 67, /* NvLink write bandwidth for link 2 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L3_RX_PER_SEC = 68, /* NvLink read bandwidth for link 3 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L3_TX_PER_SEC = 69, /* NvLink write bandwidth for link 3 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L4_RX_PER_SEC = 70, /* NvLink read bandwidth for link 4 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L4_TX_PER_SEC = 71, /* NvLink write bandwidth for link 4 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L5_RX_PER_SEC = 72, /* NvLink read bandwidth for link 5 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L5_TX_PER_SEC = 73, /* NvLink write bandwidth for link 5 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L6_RX_PER_SEC = 74, /* NvLink read bandwidth for link 6 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L6_TX_PER_SEC = 75, /* NvLink write bandwidth for link 6 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L7_RX_PER_SEC = 76, /* NvLink read bandwidth for link 7 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L7_TX_PER_SEC = 77, /* NvLink write bandwidth for link 7 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L8_RX_PER_SEC = 78, /* NvLink read bandwidth for link 8 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L8_TX_PER_SEC = 79, /* NvLink write bandwidth for link 8 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L9_RX_PER_SEC = 80, /* NvLink read bandwidth for link 9 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L9_TX_PER_SEC = 81, /* NvLink write bandwidth for link 9 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L10_RX_PER_SEC = 82, /* NvLink read bandwidth for link 10 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L10_TX_PER_SEC = 83, /* NvLink write bandwidth for link 10 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L11_RX_PER_SEC = 84, /* NvLink read bandwidth for link 11 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L11_TX_PER_SEC = 85, /* NvLink write bandwidth for link 11 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L12_RX_PER_SEC = 86, /* NvLink read bandwidth for link 12 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L12_TX_PER_SEC = 87, /* NvLink write bandwidth for link 12 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L13_RX_PER_SEC = 88, /* NvLink read bandwidth for link 13 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L13_TX_PER_SEC = 89, /* NvLink write bandwidth for link 13 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L14_RX_PER_SEC = 90, /* NvLink read bandwidth for link 14 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L14_TX_PER_SEC = 91, /* NvLink write bandwidth for link 14 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L15_RX_PER_SEC = 92, /* NvLink read bandwidth for link 15 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L15_TX_PER_SEC = 93, /* NvLink write bandwidth for link 15 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L16_RX_PER_SEC = 94, /* NvLink read bandwidth for link 16 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L16_TX_PER_SEC = 95, /* NvLink write bandwidth for link 16 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L17_RX_PER_SEC = 96, /* NvLink read bandwidth for link 17 in MiB/sec */ - NVML_GPM_METRIC_NVLINK_L17_TX_PER_SEC = 97, /* NvLink write bandwidth for link 17 in MiB/sec */ - NVML_GPM_METRIC_MAX = 98, /* Maximum value above +1. Note that changing this - should also change NVML_GPM_METRICS_GET_VERSION - due to struct size change */ + NVML_GPM_METRIC_GRAPHICS_UTIL = 1, //!< Percentage of time any compute/graphics app was active on the GPU. 0.0 - 100.0 + NVML_GPM_METRIC_SM_UTIL = 2, //!< Percentage of SMs that were busy. 0.0 - 100.0 + NVML_GPM_METRIC_SM_OCCUPANCY = 3, //!< Percentage of warps that were active vs theoretical maximum. 0.0 - 100.0 + NVML_GPM_METRIC_INTEGER_UTIL = 4, //!< Percentage of time the GPU's SMs were doing integer operations. 0.0 - 100.0 + NVML_GPM_METRIC_ANY_TENSOR_UTIL = 5, //!< Percentage of time the GPU's SMs were doing ANY tensor operations. 0.0 - 100.0 + NVML_GPM_METRIC_DFMA_TENSOR_UTIL = 6, //!< Percentage of time the GPU's SMs were doing DFMA tensor operations. 0.0 - 100.0 + NVML_GPM_METRIC_HMMA_TENSOR_UTIL = 7, //!< Percentage of time the GPU's SMs were doing HMMA tensor operations. 0.0 - 100.0 + NVML_GPM_METRIC_IMMA_TENSOR_UTIL = 9, //!< Percentage of time the GPU's SMs were doing IMMA tensor operations. 0.0 - 100.0 + NVML_GPM_METRIC_DRAM_BW_UTIL = 10, //!< Percentage of DRAM bw used vs theoretical maximum. 0.0 - 100.0 */ + NVML_GPM_METRIC_FP64_UTIL = 11, //!< Percentage of time the GPU's SMs were doing non-tensor FP64 math. 0.0 - 100.0 + NVML_GPM_METRIC_FP32_UTIL = 12, //!< Percentage of time the GPU's SMs were doing non-tensor FP32 math. 0.0 - 100.0 + NVML_GPM_METRIC_FP16_UTIL = 13, //!< Percentage of time the GPU's SMs were doing non-tensor FP16 math. 0.0 - 100.0 + NVML_GPM_METRIC_PCIE_TX_PER_SEC = 20, //!< PCIe traffic from this GPU in MiB/sec + NVML_GPM_METRIC_PCIE_RX_PER_SEC = 21, //!< PCIe traffic to this GPU in MiB/sec + NVML_GPM_METRIC_NVDEC_0_UTIL = 30, //!< Percent utilization of NVDEC 0. 0.0 - 100.0 + NVML_GPM_METRIC_NVDEC_1_UTIL = 31, //!< Percent utilization of NVDEC 1. 0.0 - 100.0 + NVML_GPM_METRIC_NVDEC_2_UTIL = 32, //!< Percent utilization of NVDEC 2. 0.0 - 100.0 + NVML_GPM_METRIC_NVDEC_3_UTIL = 33, //!< Percent utilization of NVDEC 3. 0.0 - 100.0 + NVML_GPM_METRIC_NVDEC_4_UTIL = 34, //!< Percent utilization of NVDEC 4. 0.0 - 100.0 + NVML_GPM_METRIC_NVDEC_5_UTIL = 35, //!< Percent utilization of NVDEC 5. 0.0 - 100.0 + NVML_GPM_METRIC_NVDEC_6_UTIL = 36, //!< Percent utilization of NVDEC 6. 0.0 - 100.0 + NVML_GPM_METRIC_NVDEC_7_UTIL = 37, //!< Percent utilization of NVDEC 7. 0.0 - 100.0 + NVML_GPM_METRIC_NVJPG_0_UTIL = 40, //!< Percent utilization of NVJPG 0. 0.0 - 100.0 + NVML_GPM_METRIC_NVJPG_1_UTIL = 41, //!< Percent utilization of NVJPG 1. 0.0 - 100.0 + NVML_GPM_METRIC_NVJPG_2_UTIL = 42, //!< Percent utilization of NVJPG 2. 0.0 - 100.0 + NVML_GPM_METRIC_NVJPG_3_UTIL = 43, //!< Percent utilization of NVJPG 3. 0.0 - 100.0 + NVML_GPM_METRIC_NVJPG_4_UTIL = 44, //!< Percent utilization of NVJPG 4. 0.0 - 100.0 + NVML_GPM_METRIC_NVJPG_5_UTIL = 45, //!< Percent utilization of NVJPG 5. 0.0 - 100.0 + NVML_GPM_METRIC_NVJPG_6_UTIL = 46, //!< Percent utilization of NVJPG 6. 0.0 - 100.0 + NVML_GPM_METRIC_NVJPG_7_UTIL = 47, //!< Percent utilization of NVJPG 7. 0.0 - 100.0 + NVML_GPM_METRIC_NVOFA_0_UTIL = 50, //!< Percent utilization of NVOFA 0. 0.0 - 100.0 + NVML_GPM_METRIC_NVLINK_TOTAL_RX_PER_SEC = 60, //!< NvLink read bandwidth for all links in MiB/sec + NVML_GPM_METRIC_NVLINK_TOTAL_TX_PER_SEC = 61, //!< NvLink write bandwidth for all links in MiB/sec + NVML_GPM_METRIC_NVLINK_L0_RX_PER_SEC = 62, //!< NvLink read bandwidth for link 0 in MiB/sec + NVML_GPM_METRIC_NVLINK_L0_TX_PER_SEC = 63, //!< NvLink write bandwidth for link 0 in MiB/sec + NVML_GPM_METRIC_NVLINK_L1_RX_PER_SEC = 64, //!< NvLink read bandwidth for link 1 in MiB/sec + NVML_GPM_METRIC_NVLINK_L1_TX_PER_SEC = 65, //!< NvLink write bandwidth for link 1 in MiB/sec + NVML_GPM_METRIC_NVLINK_L2_RX_PER_SEC = 66, //!< NvLink read bandwidth for link 2 in MiB/sec + NVML_GPM_METRIC_NVLINK_L2_TX_PER_SEC = 67, //!< NvLink write bandwidth for link 2 in MiB/sec + NVML_GPM_METRIC_NVLINK_L3_RX_PER_SEC = 68, //!< NvLink read bandwidth for link 3 in MiB/sec + NVML_GPM_METRIC_NVLINK_L3_TX_PER_SEC = 69, //!< NvLink write bandwidth for link 3 in MiB/sec + NVML_GPM_METRIC_NVLINK_L4_RX_PER_SEC = 70, //!< NvLink read bandwidth for link 4 in MiB/sec + NVML_GPM_METRIC_NVLINK_L4_TX_PER_SEC = 71, //!< NvLink write bandwidth for link 4 in MiB/sec + NVML_GPM_METRIC_NVLINK_L5_RX_PER_SEC = 72, //!< NvLink read bandwidth for link 5 in MiB/sec + NVML_GPM_METRIC_NVLINK_L5_TX_PER_SEC = 73, //!< NvLink write bandwidth for link 5 in MiB/sec + NVML_GPM_METRIC_NVLINK_L6_RX_PER_SEC = 74, //!< NvLink read bandwidth for link 6 in MiB/sec + NVML_GPM_METRIC_NVLINK_L6_TX_PER_SEC = 75, //!< NvLink write bandwidth for link 6 in MiB/sec + NVML_GPM_METRIC_NVLINK_L7_RX_PER_SEC = 76, //!< NvLink read bandwidth for link 7 in MiB/sec + NVML_GPM_METRIC_NVLINK_L7_TX_PER_SEC = 77, //!< NvLink write bandwidth for link 7 in MiB/sec + NVML_GPM_METRIC_NVLINK_L8_RX_PER_SEC = 78, //!< NvLink read bandwidth for link 8 in MiB/sec + NVML_GPM_METRIC_NVLINK_L8_TX_PER_SEC = 79, //!< NvLink write bandwidth for link 8 in MiB/sec + NVML_GPM_METRIC_NVLINK_L9_RX_PER_SEC = 80, //!< NvLink read bandwidth for link 9 in MiB/sec + NVML_GPM_METRIC_NVLINK_L9_TX_PER_SEC = 81, //!< NvLink write bandwidth for link 9 in MiB/sec + NVML_GPM_METRIC_NVLINK_L10_RX_PER_SEC = 82, //!< NvLink read bandwidth for link 10 in MiB/sec + NVML_GPM_METRIC_NVLINK_L10_TX_PER_SEC = 83, //!< NvLink write bandwidth for link 10 in MiB/sec + NVML_GPM_METRIC_NVLINK_L11_RX_PER_SEC = 84, //!< NvLink read bandwidth for link 11 in MiB/sec + NVML_GPM_METRIC_NVLINK_L11_TX_PER_SEC = 85, //!< NvLink write bandwidth for link 11 in MiB/sec + NVML_GPM_METRIC_NVLINK_L12_RX_PER_SEC = 86, //!< NvLink read bandwidth for link 12 in MiB/sec + NVML_GPM_METRIC_NVLINK_L12_TX_PER_SEC = 87, //!< NvLink write bandwidth for link 12 in MiB/sec + NVML_GPM_METRIC_NVLINK_L13_RX_PER_SEC = 88, //!< NvLink read bandwidth for link 13 in MiB/sec + NVML_GPM_METRIC_NVLINK_L13_TX_PER_SEC = 89, //!< NvLink write bandwidth for link 13 in MiB/sec + NVML_GPM_METRIC_NVLINK_L14_RX_PER_SEC = 90, //!< NvLink read bandwidth for link 14 in MiB/sec + NVML_GPM_METRIC_NVLINK_L14_TX_PER_SEC = 91, //!< NvLink write bandwidth for link 14 in MiB/sec + NVML_GPM_METRIC_NVLINK_L15_RX_PER_SEC = 92, //!< NvLink read bandwidth for link 15 in MiB/sec + NVML_GPM_METRIC_NVLINK_L15_TX_PER_SEC = 93, //!< NvLink write bandwidth for link 15 in MiB/sec + NVML_GPM_METRIC_NVLINK_L16_RX_PER_SEC = 94, //!< NvLink read bandwidth for link 16 in MiB/sec + NVML_GPM_METRIC_NVLINK_L16_TX_PER_SEC = 95, //!< NvLink write bandwidth for link 16 in MiB/sec + NVML_GPM_METRIC_NVLINK_L17_RX_PER_SEC = 96, //!< NvLink read bandwidth for link 17 in MiB/sec + NVML_GPM_METRIC_NVLINK_L17_TX_PER_SEC = 97, //!< NvLink write bandwidth for link 17 in MiB/sec + NVML_GPM_METRIC_MAX = 98, //!< Maximum value above +1. Note that changing this should also change NVML_GPM_METRICS_GET_VERSION due to struct size change } nvmlGpmMetricId_t; /** @} */ // @defgroup nvmlGpmEnums @@ -9402,8 +10738,9 @@ typedef enum */ /***************************************************************************************************/ -/* Handle to an allocated GPM sample allocated with nvmlGpmSampleAlloc() - Free this with nvmlGpmSampleFree() */ +/** + * Handle to an allocated GPM sample allocated with nvmlGpmSampleAlloc(). Free this with nvmlGpmSampleFree(). + */ typedef struct { struct nvmlGpmSample_st* handle; @@ -9415,30 +10752,38 @@ typedef struct { char *unit; } nvmlGpmMetricMetricInfo_t; +/** + * GPM metric information. + */ typedef struct { - unsigned int metricId; /* IN: NVML_GPM_METRIC_? #define of which metric to retrieve */ - nvmlReturn_t nvmlReturn; /* OUT: Status of this metric. If this is nonzero, then value is not valid */ - double value; /* OUT: Value of this metric. Is only valid if nvmlReturn is 0 (NVML_SUCCESS) */ - nvmlGpmMetricMetricInfo_t metricInfo; /* OUT: Metric name and unit. Those can be NULL if not defined */ + unsigned int metricId; //!< IN: NVML_GPM_METRIC_? #define of which metric to retrieve + nvmlReturn_t nvmlReturn; //!< OUT: Status of this metric. If this is nonzero, then value is not valid + double value; //!< OUT: Value of this metric. Is only valid if nvmlReturn is 0 (NVML_SUCCESS) + nvmlGpmMetricMetricInfo_t metricInfo; //!< OUT: Metric name and unit. Those can be NULL if not defined } nvmlGpmMetric_t; +/** + * GPM buffer information. + */ typedef struct { - unsigned int version; /* IN: Set to NVML_GPM_METRICS_GET_VERSION */ - unsigned int numMetrics; /* IN: How many metrics to retrieve in metrics[] */ - nvmlGpmSample_t sample1; /* IN: Sample buffer */ - nvmlGpmSample_t sample2; /* IN: Sample buffer */ - nvmlGpmMetric_t metrics[NVML_GPM_METRIC_MAX]; /* IN/OUT: Array of metrics. Set metricId on call. - see nvmlReturn and value on return */ + unsigned int version; //!< IN: Set to NVML_GPM_METRICS_GET_VERSION + unsigned int numMetrics; //!< IN: How many metrics to retrieve in metrics[] + nvmlGpmSample_t sample1; //!< IN: Sample buffer + nvmlGpmSample_t sample2; //!< IN: Sample buffer + nvmlGpmMetric_t metrics[NVML_GPM_METRIC_MAX]; //!< IN/OUT: Array of metrics. Set metricId on call. See nvmlReturn and value on return } nvmlGpmMetricsGet_t; #define NVML_GPM_METRICS_GET_VERSION 1 +/** + * GPM device information. + */ typedef struct { - unsigned int version; /* IN: Set to NVML_GPM_SUPPORT_VERSION */ - unsigned int isSupportedDevice; /* OUT: Indicates device support */ + unsigned int version; //!< IN: Set to NVML_GPM_SUPPORT_VERSION + unsigned int isSupportedDevice; //!< OUT: Indicates device support } nvmlGpmSupport_t; #define NVML_GPM_SUPPORT_VERSION 1 @@ -9454,10 +10799,9 @@ typedef struct /** * Calculate GPM metrics from two samples. * + * For Hopper &tm; or newer fully supported devices. * - * @param metricsGet IN/OUT: populated nvmlGpmMetricsGet_t struct - * - * %HOPPER_OR_NEWER% + * @param metricsGet IN/OUT: populated \a nvmlGpmMetricsGet_t struct * * @return * - \ref NVML_SUCCESS on success @@ -9469,7 +10813,7 @@ nvmlReturn_t DECLDIR nvmlGpmMetricsGet(nvmlGpmMetricsGet_t *metricsGet); /** * Free an allocated sample buffer that was allocated with \ref nvmlGpmSampleAlloc() * - * %HOPPER_OR_NEWER% + * For Hopper &tm; or newer fully supported devices. * * @param gpmSample Sample to free * @@ -9484,7 +10828,7 @@ nvmlReturn_t DECLDIR nvmlGpmSampleFree(nvmlGpmSample_t gpmSample); * Allocate a sample buffer to be used with NVML GPM . You will need to allocate * at least two of these buffers to use with the NVML GPM feature * - * %HOPPER_OR_NEWER% + * For Hopper &tm; or newer fully supported devices. * * @param gpmSample Where the allocated sample will be stored * @@ -9500,7 +10844,7 @@ nvmlReturn_t DECLDIR nvmlGpmSampleAlloc(nvmlGpmSample_t *gpmSample); * two samples are gathered, you can call nvmlGpmMetricGet on those samples to * retrive metrics * - * %HOPPER_OR_NEWER% + * For Hopper &tm; or newer fully supported devices. * * @param device Device to get samples for * @param gpmSample Buffer to read samples into @@ -9517,7 +10861,7 @@ nvmlReturn_t DECLDIR nvmlGpmSampleGet(nvmlDevice_t device, nvmlGpmSample_t gpmSa * After two samples are gathered, you can call nvmlGpmMetricGet on those * samples to retrive metrics * - * %HOPPER_OR_NEWER% + * For Hopper &tm; or newer fully supported devices. * * @param device Device to get samples for * @param gpuInstanceId MIG GPU Instance ID @@ -9533,7 +10877,7 @@ nvmlReturn_t DECLDIR nvmlGpmMigSampleGet(nvmlDevice_t device, unsigned int gpuIn * Indicate whether the supplied device supports GPM * * @param device NVML device to query for - * @param gpmSupport Structure to indicate GPM support. Indicates + * @param gpmSupport Structure to indicate GPM support \a nvmlGpmSupport_t. Indicates * GPM support per system for the supplied device * * @return @@ -9542,58 +10886,45 @@ nvmlReturn_t DECLDIR nvmlGpmMigSampleGet(nvmlDevice_t device, unsigned int gpuIn */ nvmlReturn_t DECLDIR nvmlGpmQueryDeviceSupport(nvmlDevice_t device, nvmlGpmSupport_t *gpmSupport); -/** @} */ // @defgroup nvmlGpmFunctions -/** @} */ // @defgroup GPM - -/***************************************************************************************************/ -/** @defgroup nvmlDevice definitions related to Counter Collection Unit - * @{ - */ -/***************************************************************************************************/ - -/* CCU Stream State */ -#define NVML_COUNTER_COLLECTION_UNIT_STREAM_STATE_DISABLE 0 -#define NVML_COUNTER_COLLECTION_UNIT_STREAM_STATE_ENABLE 1 - +/* GPM Stream State */ /** - * Get counter collection unit stream state. + * Get GPM stream state. * * %HOPPER_OR_NEWER% * Supported on Linux, Windows TCC. * * @param device The identifier of the target device - * @param state Returns counter collection unit stream state - * NVML_COUNTER_COLLECTION_UNIT_STREAM_STATE_DISABLE or - * NVML_COUNTER_COLLECTION_UNIT_STREAM_STATE_ENABLE + * @param state Returns GPM stream state + * NVML_FEATURE_DISABLED or NVML_FEATURE_ENABLED * * @return - * - \ref NVML_SUCCESS if \a current counter collection unit stream state were successfully queried + * - \ref NVML_SUCCESS if \a current GPM stream state were successfully queried * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a state is NULL * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device */ -nvmlReturn_t DECLDIR nvmlDeviceCcuGetStreamState(nvmlDevice_t device, unsigned int *state); +nvmlReturn_t DECLDIR nvmlGpmQueryIfStreamingEnabled(nvmlDevice_t device, unsigned int *state); /** - * Set counter collection unit stream state. + * Set GPM stream state. * * %HOPPER_OR_NEWER% * Supported on Linux, Windows TCC. * * @param device The identifier of the target device - * @param state Counter collection unit stream state, - * NVML_COUNTER_COLLECTION_UNIT_STREAM_STATE_DISABLE or - * NVML_COUNTER_COLLECTION_UNIT_STREAM_STATE_ENABLE + * @param state GPM stream state, + * NVML_FEATURE_DISABLED or NVML_FEATURE_ENABLED * * @return - * - \ref NVML_SUCCESS if \a current counter collection unit stream state is successfully set + * - \ref NVML_SUCCESS if \a current GPM stream state is successfully set * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid * - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device */ -nvmlReturn_t DECLDIR nvmlDeviceCcuSetStreamState(nvmlDevice_t device, unsigned int state); +nvmlReturn_t DECLDIR nvmlGpmSetStreamingEnabled(nvmlDevice_t device, unsigned int state); -/** @} */ // @defgroup CCU +/** @} */ // @defgroup nvmlGpmFunctions +/** @} */ // @defgroup GPM #define NVML_NVLINK_POWER_STATE_HIGH_SPEED 0x0 #define NVML_NVLINK_POWER_STATE_LOW 0x1 @@ -9626,6 +10957,87 @@ typedef struct nvmlNvLinkPowerThres_st **/ nvmlReturn_t DECLDIR nvmlDeviceSetNvLinkDeviceLowPowerThreshold(nvmlDevice_t device, nvmlNvLinkPowerThres_t *info); +/** + * Set the global nvlink bandwith mode + * + * @param nvlinkBwMode nvlink bandwidth mode + * @return + * - \ref NVML_SUCCESS on success + * - \ref NVML_ERROR_INVALID_ARGUMENT if an invalid argument is provided + * - \ref NVML_ERROR_IN_USE if P2P object exists + * - \ref NVML_ERROR_NOT_SUPPORTED if GPU is not Hopper or newer architecture. + * - \ref NVML_ERROR_NO_PERMISSION if not root user + */ +nvmlReturn_t DECLDIR nvmlSystemSetNvlinkBwMode(unsigned int nvlinkBwMode); + +/** + * Get the global nvlink bandwith mode + * + * @param nvlinkBwMode reference of nvlink bandwidth mode + * @return + * - \ref NVML_SUCCESS on success + * - \ref NVML_ERROR_INVALID_ARGUMENT if an invalid pointer is provided + * - \ref NVML_ERROR_NOT_SUPPORTED if GPU is not Hopper or newer architecture. + * - \ref NVML_ERROR_NO_PERMISSION if not root user + */ +nvmlReturn_t DECLDIR nvmlSystemGetNvlinkBwMode(unsigned int *nvlinkBwMode); + +/** + * Set new power limit of this device. + * + * For Kepler &tm; or newer fully supported devices. + * Requires root/admin permissions. + * + * See \ref nvmlDeviceGetPowerManagementLimitConstraints to check the allowed ranges of values. + * + * See \ref nvmlPowerValue_v2_t for more information on the struct. + * + * \note Limit is not persistent across reboots or driver unloads. + * Enable persistent mode to prevent driver from unloading when no application is using the device. + * + * This API replaces nvmlDeviceSetPowerManagementLimit. It can be used as a drop-in replacement for the older version. + * + * @param device The identifier of the target device + * @param powerValue Power management limit in milliwatts to set + * + * @return + * - \ref NVML_SUCCESS if \a limit has been set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a powerValue is NULL or contains invalid values + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + * + * @see NVML_FI_DEV_POWER_AVERAGE + * @see NVML_FI_DEV_POWER_INSTANT + * @see NVML_FI_DEV_POWER_MIN_LIMIT + * @see NVML_FI_DEV_POWER_MAX_LIMIT + * @see NVML_FI_DEV_POWER_CURRENT_LIMIT + */ +nvmlReturn_t DECLDIR nvmlDeviceSetPowerManagementLimit_v2(nvmlDevice_t device, nvmlPowerValue_v2_t *powerValue); + +/** + * Get SRAM ECC error status of this device. + * + * For Ampere &tm; or newer fully supported devices. + * Requires root/admin permissions. + * + * See \ref nvmlEccSramErrorStatus_v1_t for more information on the struct. + * + * @param device The identifier of the target device + * @param status Returns SRAM ECC error status + * + * @return + * - \ref NVML_SUCCESS if \a limit has been set + * - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized + * - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a counters is NULL + * - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature + * - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible + * - \ref NVML_ERROR_VERSION_MISMATCH if the version of \a nvmlEccSramErrorStatus_t is invalid + * - \ref NVML_ERROR_UNKNOWN on any unexpected error + */ +nvmlReturn_t DECLDIR nvmlDeviceGetSramEccErrorStatus(nvmlDevice_t device, + nvmlEccSramErrorStatus_t *status); /** * NVML API versioning support */ @@ -9653,7 +11065,6 @@ nvmlReturn_t DECLDIR nvmlDeviceGetMPSComputeRunningProcesses(nvmlDevice_t device nvmlReturn_t DECLDIR nvmlDeviceGetMPSComputeRunningProcesses_v2(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_v2_t *infos); nvmlReturn_t DECLDIR nvmlDeviceGetGpuInstancePossiblePlacements(nvmlDevice_t device, unsigned int profileId, nvmlGpuInstancePlacement_t *placements, unsigned int *count); nvmlReturn_t DECLDIR nvmlVgpuInstanceGetLicenseInfo(nvmlVgpuInstance_t vgpuInstance, nvmlVgpuLicenseInfo_t *licenseInfo); - #endif // #ifdef NVML_NO_UNVERSIONED_FUNC_DEFS #if defined(NVML_NO_UNVERSIONED_FUNC_DEFS) @@ -9679,6 +11090,7 @@ nvmlReturn_t DECLDIR nvmlVgpuInstanceGetLicenseInfo(nvmlVgpuInstance_t vgpuInsta #undef nvmlGetBlacklistDeviceInfoByIndex #undef nvmlDeviceGetGpuInstancePossiblePlacements #undef nvmlVgpuInstanceGetLicenseInfo +#undef nvmlDeviceSetPowerManagementLimit #endif diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/return.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/return.go index 0a0cceee..1aec3ecc 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/return.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/return.go @@ -19,17 +19,27 @@ import ( ) // nvml.ErrorString() -func ErrorString(r Return) string { - if err := GetLibrary().Lookup("nvmlErrorString"); err != nil { - return fallbackErrorStringFunc(r) - } - return nvmlErrorString(r) +func (l *library) ErrorString(r Return) string { + return r.Error() +} + +// String returns the string representation of a Return. +func (r Return) String() string { + return r.Error() } -// fallbackErrorStringFunc provides a basic nvmlErrorString implementation. +// Error returns the string representation of a Return. +func (r Return) Error() string { + return errorStringFunc(r) +} + +// Assigned to nvml.ErrorString if the system nvml library is in use. +var errorStringFunc = defaultErrorStringFunc + +// defaultErrorStringFunc provides a basic nvmlErrorString implementation. // This allows the nvml.ErrorString function to be used even if the NVML library // is not loaded. -var fallbackErrorStringFunc = func(r Return) string { +var defaultErrorStringFunc = func(r Return) string { switch r { case SUCCESS: return "SUCCESS" diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/system.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/system.go index 424f99bd..bee39641 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/system.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/system.go @@ -15,67 +15,124 @@ package nvml // nvml.SystemGetDriverVersion() -func SystemGetDriverVersion() (string, Return) { +func (l *library) 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) { +func (l *library) 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) { +func (l *library) SystemGetCudaDriverVersion() (int, Return) { var CudaDriverVersion int32 ret := nvmlSystemGetCudaDriverVersion(&CudaDriverVersion) return int(CudaDriverVersion), ret } // nvml.SystemGetCudaDriverVersion_v2() -func SystemGetCudaDriverVersion_v2() (int, Return) { +func (l *library) 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 +func (l *library) 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 +func (l *library) SystemGetHicVersion() ([]HwbcEntry, Return) { + var hwbcCount uint32 = 1 // Will be reduced upon returning for { - HwbcEntries := make([]HwbcEntry, HwbcCount) - ret := nvmlSystemGetHicVersion(&HwbcCount, &HwbcEntries[0]) + hwbcEntries := make([]HwbcEntry, hwbcCount) + ret := nvmlSystemGetHicVersion(&hwbcCount, &hwbcEntries[0]) if ret == SUCCESS { - return HwbcEntries[:HwbcCount], ret + return hwbcEntries[:hwbcCount], ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - HwbcCount *= 2 + hwbcCount *= 2 } } // nvml.SystemGetTopologyGpuSet() -func SystemGetTopologyGpuSet(CpuNumber int) ([]Device, Return) { - var Count uint32 - ret := nvmlSystemGetTopologyGpuSet(uint32(CpuNumber), &Count, nil) +func (l *library) SystemGetTopologyGpuSet(cpuNumber int) ([]Device, Return) { + var count uint32 + ret := nvmlSystemGetTopologyGpuSet(uint32(cpuNumber), &count, nil) if ret != SUCCESS { return nil, ret } - if Count == 0 { + if count == 0 { return []Device{}, ret } - DeviceArray := make([]Device, Count) - ret = nvmlSystemGetTopologyGpuSet(uint32(CpuNumber), &Count, &DeviceArray[0]) - return DeviceArray, ret + deviceArray := make([]nvmlDevice, count) + ret = nvmlSystemGetTopologyGpuSet(uint32(cpuNumber), &count, &deviceArray[0]) + return convertSlice[nvmlDevice, Device](deviceArray), ret +} + +// nvml.SystemGetConfComputeCapabilities() +func (l *library) SystemGetConfComputeCapabilities() (ConfComputeSystemCaps, Return) { + var capabilities ConfComputeSystemCaps + ret := nvmlSystemGetConfComputeCapabilities(&capabilities) + return capabilities, ret +} + +// nvml.SystemGetConfComputeState() +func SystemGetConfComputeState() (ConfComputeSystemState, Return) { + var state ConfComputeSystemState + ret := nvmlSystemGetConfComputeState(&state) + return state, ret +} + +// nvml.SystemGetConfComputeGpusReadyState() +func SystemGetConfComputeGpusReadyState() (uint32, Return) { + var isAcceptingWork uint32 + ret := nvmlSystemGetConfComputeGpusReadyState(&isAcceptingWork) + return isAcceptingWork, ret +} + +// nvml.SystemSetConfComputeGpusReadyState() +func SystemSetConfComputeGpusReadyState(isAcceptingWork uint32) Return { + return nvmlSystemSetConfComputeGpusReadyState(isAcceptingWork) +} + +// nvml.SystemSetNvlinkBwMode() +func SystemSetNvlinkBwMode(nvlinkBwMode uint32) Return { + return nvmlSystemSetNvlinkBwMode(nvlinkBwMode) +} + +// nvml.SystemGetNvlinkBwMode() +func SystemGetNvlinkBwMode() (uint32, Return) { + var nvlinkBwMode uint32 + ret := nvmlSystemGetNvlinkBwMode(&nvlinkBwMode) + return nvlinkBwMode, ret +} + +// nvml.SystemGetConfComputeKeyRotationThresholdInfo() +func (l *library) SystemGetConfComputeKeyRotationThresholdInfo() (ConfComputeGetKeyRotationThresholdInfo, Return) { + var keyRotationThresholdInfo ConfComputeGetKeyRotationThresholdInfo + ret := nvmlSystemGetConfComputeKeyRotationThresholdInfo(&keyRotationThresholdInfo) + return keyRotationThresholdInfo, ret +} + +// nvml.SystemGetConfComputeSettings() +func (l *library) SystemGetConfComputeSettings() (SystemConfComputeSettings, Return) { + var settings SystemConfComputeSettings + ret := nvmlSystemGetConfComputeSettings(&settings) + return settings, ret +} + +// nvml.SystemSetConfComputeKeyRotationThresholdInfo() +func (l *library) SystemSetConfComputeKeyRotationThresholdInfo(keyRotationThresholdInfo ConfComputeSetKeyRotationThresholdInfo) Return { + return nvmlSystemSetConfComputeKeyRotationThresholdInfo(&keyRotationThresholdInfo) } diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/types_gen.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/types_gen.go index 396886d6..6ee33a6a 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/types_gen.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/types_gen.go @@ -5,10 +5,34 @@ package nvml import "unsafe" -type Device struct { +type nvmlDevice struct { Handle *_Ctype_struct_nvmlDevice_st } +type PciInfoExt_v1 struct { + Version uint32 + Domain uint32 + Bus uint32 + Device uint32 + PciDeviceId uint32 + PciSubSystemId uint32 + BaseClass uint32 + SubClass uint32 + BusId [32]int8 +} + +type PciInfoExt struct { + Version uint32 + Domain uint32 + Bus uint32 + Device uint32 + PciDeviceId uint32 + PciSubSystemId uint32 + BaseClass uint32 + SubClass uint32 + BusId [32]int8 +} + type PciInfo struct { BusIdLegacy [16]int8 Domain uint32 @@ -70,6 +94,28 @@ type ProcessInfo struct { ComputeInstanceId uint32 } +type ProcessDetail_v1 struct { + Pid uint32 + UsedGpuMemory uint64 + GpuInstanceId uint32 + ComputeInstanceId uint32 + UsedGpuCcProtectedMemory uint64 +} + +type ProcessDetailList_v1 struct { + Version uint32 + Mode uint32 + NumProcArrayEntries uint32 + ProcArray *ProcessDetail_v1 +} + +type ProcessDetailList struct { + Version uint32 + Mode uint32 + NumProcArrayEntries uint32 + ProcArray *ProcessDetail_v1 +} + type DeviceAttributes struct { MultiprocessorCount uint32 SharedCopyEngineCount uint32 @@ -82,6 +128,10 @@ type DeviceAttributes struct { MemorySizeMB uint64 } +type C2cModeInfo_v1 struct { + IsC2cEnabled uint32 +} + type RowRemapperHistogramValues struct { Max uint32 High uint32 @@ -143,9 +193,43 @@ type ClkMonStatus struct { ClkMonList [32]ClkMonFaultInfo } -type VgpuTypeId uint32 +type nvmlVgpuTypeId uint32 + +type nvmlVgpuInstance uint32 + +type VgpuHeterogeneousMode_v1 struct { + Version uint32 + Mode uint32 +} + +type VgpuHeterogeneousMode struct { + Version uint32 + Mode uint32 +} -type VgpuInstance uint32 +type VgpuPlacementId_v1 struct { + Version uint32 + PlacementId uint32 +} + +type VgpuPlacementId struct { + Version uint32 + PlacementId uint32 +} + +type VgpuPlacementList_v1 struct { + Version uint32 + PlacementSize uint32 + Count uint32 + PlacementIds *uint32 +} + +type VgpuPlacementList struct { + Version uint32 + PlacementSize uint32 + Count uint32 + PlacementIds *uint32 +} type VgpuInstanceUtilizationSample struct { VgpuInstance uint32 @@ -156,6 +240,34 @@ type VgpuInstanceUtilizationSample struct { DecUtil [8]byte } +type VgpuInstanceUtilizationInfo_v1 struct { + TimeStamp uint64 + VgpuInstance uint32 + Pad_cgo_0 [4]byte + SmUtil [8]byte + MemUtil [8]byte + EncUtil [8]byte + DecUtil [8]byte + JpgUtil [8]byte + OfaUtil [8]byte +} + +type VgpuInstancesUtilizationInfo_v1 struct { + Version uint32 + SampleValType uint32 + VgpuInstanceCount uint32 + LastSeenTimeStamp uint64 + VgpuUtilArray *VgpuInstanceUtilizationInfo_v1 +} + +type VgpuInstancesUtilizationInfo struct { + Version uint32 + SampleValType uint32 + VgpuInstanceCount uint32 + LastSeenTimeStamp uint64 + VgpuUtilArray *VgpuInstanceUtilizationInfo_v1 +} + type VgpuProcessUtilizationSample struct { VgpuInstance uint32 Pid uint32 @@ -167,6 +279,33 @@ type VgpuProcessUtilizationSample struct { DecUtil uint32 } +type VgpuProcessUtilizationInfo_v1 struct { + ProcessName [64]int8 + TimeStamp uint64 + VgpuInstance uint32 + Pid uint32 + SmUtil uint32 + MemUtil uint32 + EncUtil uint32 + DecUtil uint32 + JpgUtil uint32 + OfaUtil uint32 +} + +type VgpuProcessesUtilizationInfo_v1 struct { + Version uint32 + VgpuProcessCount uint32 + LastSeenTimeStamp uint64 + VgpuProcUtilArray *VgpuProcessUtilizationInfo_v1 +} + +type VgpuProcessesUtilizationInfo struct { + Version uint32 + VgpuProcessCount uint32 + LastSeenTimeStamp uint64 + VgpuProcUtilArray *VgpuProcessUtilizationInfo_v1 +} + type VgpuSchedulerParamsVgpuSchedDataWithARR struct { AvgFactor uint32 Timeslice uint32 @@ -192,7 +331,7 @@ type VgpuSchedulerLogEntry struct { type VgpuSchedulerLog struct { EngineId uint32 SchedulerPolicy uint32 - IsEnabledARR uint32 + ArrMode uint32 SchedulerParams [8]byte EntriesCount uint32 LogEntries [200]VgpuSchedulerLogEntry @@ -200,7 +339,7 @@ type VgpuSchedulerLog struct { type VgpuSchedulerGetState struct { SchedulerPolicy uint32 - IsEnabledARR uint32 + ArrMode uint32 SchedulerParams [8]byte } @@ -260,6 +399,32 @@ type ProcessUtilizationSample struct { DecUtil uint32 } +type ProcessUtilizationInfo_v1 struct { + TimeStamp uint64 + Pid uint32 + SmUtil uint32 + MemUtil uint32 + EncUtil uint32 + DecUtil uint32 + JpgUtil uint32 + OfaUtil uint32 + Pad_cgo_0 [4]byte +} + +type ProcessesUtilizationInfo_v1 struct { + Version uint32 + ProcessSamplesCount uint32 + LastSeenTimeStamp uint64 + ProcUtilArray *ProcessUtilizationInfo_v1 +} + +type ProcessesUtilizationInfo struct { + Version uint32 + ProcessSamplesCount uint32 + LastSeenTimeStamp uint64 + ProcUtilArray *ProcessUtilizationInfo_v1 +} + type GridLicenseExpiry struct { Year uint32 Month uint16 @@ -286,6 +451,40 @@ type GridLicensableFeatures struct { GridLicensableFeatures [3]GridLicensableFeature } +type EccSramErrorStatus_v1 struct { + Version uint32 + AggregateUncParity uint64 + AggregateUncSecDed uint64 + AggregateCor uint64 + VolatileUncParity uint64 + VolatileUncSecDed uint64 + VolatileCor uint64 + AggregateUncBucketL2 uint64 + AggregateUncBucketSm uint64 + AggregateUncBucketPcie uint64 + AggregateUncBucketMcu uint64 + AggregateUncBucketOther uint64 + BThresholdExceeded uint32 + Pad_cgo_0 [4]byte +} + +type EccSramErrorStatus struct { + Version uint32 + AggregateUncParity uint64 + AggregateUncSecDed uint64 + AggregateCor uint64 + VolatileUncParity uint64 + VolatileUncSecDed uint64 + VolatileCor uint64 + AggregateUncBucketL2 uint64 + AggregateUncBucketSm uint64 + AggregateUncBucketPcie uint64 + AggregateUncBucketMcu uint64 + AggregateUncBucketOther uint64 + BThresholdExceeded uint32 + Pad_cgo_0 [4]byte +} + type DeviceArchitecture uint32 type BusType uint32 @@ -316,7 +515,7 @@ type FieldValue struct { Value [8]byte } -type Unit struct { +type nvmlUnit struct { Handle *_Ctype_struct_nvmlUnit_st } @@ -354,12 +553,12 @@ type UnitFanSpeeds struct { Count uint32 } -type EventSet struct { +type nvmlEventSet struct { Handle *_Ctype_struct_nvmlEventSet_st } -type EventData struct { - Device Device +type nvmlEventData struct { + Device nvmlDevice EventType uint64 EventData uint64 GpuInstanceId uint32 @@ -408,16 +607,110 @@ type FBCSessionInfo struct { AverageLatency uint32 } +type ConfComputeSystemCaps struct { + CpuCaps uint32 + GpusCaps uint32 +} + +type ConfComputeSystemState struct { + Environment uint32 + CcFeature uint32 + DevToolsMode uint32 +} + +type SystemConfComputeSettings_v1 struct { + Version uint32 + Environment uint32 + CcFeature uint32 + DevToolsMode uint32 + MultiGpuMode uint32 +} + +type SystemConfComputeSettings struct { + Version uint32 + Environment uint32 + CcFeature uint32 + DevToolsMode uint32 + MultiGpuMode uint32 +} + +type ConfComputeMemSizeInfo struct { + ProtectedMemSizeKib uint64 + UnprotectedMemSizeKib uint64 +} + +type ConfComputeGpuCertificate struct { + CertChainSize uint32 + AttestationCertChainSize uint32 + CertChain [4096]uint8 + AttestationCertChain [5120]uint8 +} + +type ConfComputeGpuAttestationReport struct { + IsCecAttestationReportPresent uint32 + AttestationReportSize uint32 + CecAttestationReportSize uint32 + Nonce [32]uint8 + AttestationReport [8192]uint8 + CecAttestationReport [4096]uint8 +} + +type ConfComputeSetKeyRotationThresholdInfo_v1 struct { + Version uint32 + MaxAttackerAdvantage uint64 +} + +type ConfComputeSetKeyRotationThresholdInfo struct { + Version uint32 + MaxAttackerAdvantage uint64 +} + +type ConfComputeGetKeyRotationThresholdInfo_v1 struct { + Version uint32 + AttackerAdvantage uint64 +} + +type ConfComputeGetKeyRotationThresholdInfo struct { + Version uint32 + AttackerAdvantage uint64 +} + type GpuFabricState byte type GpuFabricInfo struct { - ClusterUuid [16]int8 + ClusterUuid [16]uint8 Status uint32 - PartitionId uint32 + CliqueId uint32 State uint8 Pad_cgo_0 [3]byte } +type GpuFabricInfo_v2 struct { + Version uint32 + ClusterUuid [16]uint8 + Status uint32 + CliqueId uint32 + State uint8 + HealthMask uint32 +} + +type GpuFabricInfoV struct { + Version uint32 + ClusterUuid [16]uint8 + Status uint32 + CliqueId uint32 + State uint8 + HealthMask uint32 +} + +type PowerScopeType byte + +type PowerValue_v2 struct { + Version uint32 + PowerScope uint8 + PowerValueMw uint32 +} + type AffinityScope uint32 type VgpuVersion struct { @@ -494,14 +787,31 @@ type GpuInstanceProfileInfo_v2 struct { Name [96]int8 } -type GpuInstanceInfo struct { - Device Device +type GpuInstanceProfileInfo_v3 struct { + Version uint32 + Id uint32 + SliceCount uint32 + InstanceCount uint32 + MultiprocessorCount uint32 + CopyEngineCount uint32 + DecoderCount uint32 + EncoderCount uint32 + JpegCount uint32 + OfaCount uint32 + MemorySizeMB uint64 + Name [96]int8 + Capabilities uint32 + Pad_cgo_0 [4]byte +} + +type nvmlGpuInstanceInfo struct { + Device nvmlDevice Id uint32 ProfileId uint32 Placement GpuInstancePlacement } -type GpuInstance struct { +type nvmlGpuInstance struct { Handle *_Ctype_struct_nvmlGpuInstance_st } @@ -536,19 +846,34 @@ type ComputeInstanceProfileInfo_v2 struct { Name [96]int8 } -type ComputeInstanceInfo struct { - Device Device - GpuInstance GpuInstance +type ComputeInstanceProfileInfo_v3 struct { + Version uint32 + Id uint32 + SliceCount uint32 + InstanceCount uint32 + MultiprocessorCount uint32 + SharedCopyEngineCount uint32 + SharedDecoderCount uint32 + SharedEncoderCount uint32 + SharedJpegCount uint32 + SharedOfaCount uint32 + Name [96]int8 + Capabilities uint32 +} + +type nvmlComputeInstanceInfo struct { + Device nvmlDevice + GpuInstance nvmlGpuInstance Id uint32 ProfileId uint32 Placement ComputeInstancePlacement } -type ComputeInstance struct { +type nvmlComputeInstance struct { Handle *_Ctype_struct_nvmlComputeInstance_st } -type GpmSample struct { +type nvmlGpmSample struct { Handle *_Ctype_struct_nvmlGpmSample_st } @@ -565,11 +890,11 @@ type GpmMetric struct { MetricInfo GpmMetricMetricInfo } -type GpmMetricsGetType struct { +type nvmlGpmMetricsGetType struct { Version uint32 NumMetrics uint32 - Sample1 GpmSample - Sample2 GpmSample + Sample1 nvmlGpmSample + Sample2 nvmlGpmSample Metrics [98]GpmMetric } diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/unit.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/unit.go index aba916ae..617ad546 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/unit.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/unit.go @@ -15,99 +15,99 @@ package nvml // nvml.UnitGetCount() -func UnitGetCount() (int, Return) { +func (l *library) 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 +func (l *library) UnitGetHandleByIndex(index int) (Unit, Return) { + var unit nvmlUnit + 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 (l *library) UnitGetUnitInfo(unit Unit) (UnitInfo, Return) { + return unit.GetUnitInfo() } -func (Unit Unit) GetUnitInfo() (UnitInfo, Return) { - return UnitGetUnitInfo(Unit) +func (unit nvmlUnit) GetUnitInfo() (UnitInfo, Return) { + var info UnitInfo + ret := nvmlUnitGetUnitInfo(unit, &info) + return info, ret } // nvml.UnitGetLedState() -func UnitGetLedState(Unit Unit) (LedState, Return) { - var State LedState - ret := nvmlUnitGetLedState(Unit, &State) - return State, ret +func (l *library) UnitGetLedState(unit Unit) (LedState, Return) { + return unit.GetLedState() } -func (Unit Unit) GetLedState() (LedState, Return) { - return UnitGetLedState(Unit) +func (unit nvmlUnit) GetLedState() (LedState, Return) { + var state LedState + ret := nvmlUnitGetLedState(unit, &state) + return state, ret } // nvml.UnitGetPsuInfo() -func UnitGetPsuInfo(Unit Unit) (PSUInfo, Return) { - var Psu PSUInfo - ret := nvmlUnitGetPsuInfo(Unit, &Psu) - return Psu, ret +func (l *library) UnitGetPsuInfo(unit Unit) (PSUInfo, Return) { + return unit.GetPsuInfo() } -func (Unit Unit) GetPsuInfo() (PSUInfo, Return) { - return UnitGetPsuInfo(Unit) +func (unit nvmlUnit) GetPsuInfo() (PSUInfo, Return) { + var psu PSUInfo + ret := nvmlUnitGetPsuInfo(unit, &psu) + return psu, ret } // nvml.UnitGetTemperature() -func UnitGetTemperature(Unit Unit, Type int) (uint32, Return) { - var Temp uint32 - ret := nvmlUnitGetTemperature(Unit, uint32(Type), &Temp) - return Temp, ret +func (l *library) UnitGetTemperature(unit Unit, ttype int) (uint32, Return) { + return unit.GetTemperature(ttype) } -func (Unit Unit) GetTemperature(Type int) (uint32, Return) { - return UnitGetTemperature(Unit, Type) +func (unit nvmlUnit) GetTemperature(ttype int) (uint32, Return) { + var temp uint32 + ret := nvmlUnitGetTemperature(unit, uint32(ttype), &temp) + return temp, ret } // nvml.UnitGetFanSpeedInfo() -func UnitGetFanSpeedInfo(Unit Unit) (UnitFanSpeeds, Return) { - var FanSpeeds UnitFanSpeeds - ret := nvmlUnitGetFanSpeedInfo(Unit, &FanSpeeds) - return FanSpeeds, ret +func (l *library) UnitGetFanSpeedInfo(unit Unit) (UnitFanSpeeds, Return) { + return unit.GetFanSpeedInfo() } -func (Unit Unit) GetFanSpeedInfo() (UnitFanSpeeds, Return) { - return UnitGetFanSpeedInfo(Unit) +func (unit nvmlUnit) GetFanSpeedInfo() (UnitFanSpeeds, Return) { + var fanSpeeds UnitFanSpeeds + ret := nvmlUnitGetFanSpeedInfo(unit, &fanSpeeds) + return fanSpeeds, ret } // nvml.UnitGetDevices() -func UnitGetDevices(Unit Unit) ([]Device, Return) { - var DeviceCount uint32 = 1 // Will be reduced upon returning +func (l *library) UnitGetDevices(unit Unit) ([]Device, Return) { + return unit.GetDevices() +} + +func (unit nvmlUnit) GetDevices() ([]Device, Return) { + var deviceCount uint32 = 1 // Will be reduced upon returning for { - Devices := make([]Device, DeviceCount) - ret := nvmlUnitGetDevices(Unit, &DeviceCount, &Devices[0]) + devices := make([]nvmlDevice, deviceCount) + ret := nvmlUnitGetDevices(unit, &deviceCount, &devices[0]) if ret == SUCCESS { - return Devices[:DeviceCount], ret + return convertSlice[nvmlDevice, Device](devices[:deviceCount]), ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - DeviceCount *= 2 + 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 (l *library) UnitSetLedState(unit Unit, color LedColor) Return { + return unit.SetLedState(color) } -func (Unit Unit) SetLedState(Color LedColor) Return { - return UnitSetLedState(Unit, Color) +func (unit nvmlUnit) SetLedState(color LedColor) Return { + return nvmlUnitSetLedState(unit, color) } diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/vgpu.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/vgpu.go index 2366fb70..da495242 100644 --- a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/vgpu.go +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/vgpu.go @@ -31,450 +31,450 @@ type VgpuPgpuMetadata struct { } // 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 (l *library) VgpuTypeGetClass(vgpuTypeId VgpuTypeId) (string, Return) { + return vgpuTypeId.GetClass() } -func (VgpuTypeId VgpuTypeId) GetClass() (string, Return) { - return VgpuTypeGetClass(VgpuTypeId) +func (vgpuTypeId nvmlVgpuTypeId) GetClass() (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 } // 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 (l *library) VgpuTypeGetName(vgpuTypeId VgpuTypeId) (string, Return) { + return vgpuTypeId.GetName() } -func (VgpuTypeId VgpuTypeId) GetName() (string, Return) { - return VgpuTypeGetName(VgpuTypeId) +func (vgpuTypeId nvmlVgpuTypeId) GetName() (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 } // nvml.VgpuTypeGetGpuInstanceProfileId() -func VgpuTypeGetGpuInstanceProfileId(VgpuTypeId VgpuTypeId) (uint32, Return) { - var Size uint32 - ret := nvmlVgpuTypeGetGpuInstanceProfileId(VgpuTypeId, &Size) - return Size, ret +func (l *library) VgpuTypeGetGpuInstanceProfileId(vgpuTypeId VgpuTypeId) (uint32, Return) { + return vgpuTypeId.GetGpuInstanceProfileId() } -func (VgpuTypeId VgpuTypeId) GetGpuInstanceProfileId() (uint32, Return) { - return VgpuTypeGetGpuInstanceProfileId(VgpuTypeId) +func (vgpuTypeId nvmlVgpuTypeId) GetGpuInstanceProfileId() (uint32, Return) { + var size uint32 + ret := nvmlVgpuTypeGetGpuInstanceProfileId(vgpuTypeId, &size) + return size, ret } // nvml.VgpuTypeGetDeviceID() -func VgpuTypeGetDeviceID(VgpuTypeId VgpuTypeId) (uint64, uint64, Return) { - var DeviceID, SubsystemID uint64 - ret := nvmlVgpuTypeGetDeviceID(VgpuTypeId, &DeviceID, &SubsystemID) - return DeviceID, SubsystemID, ret +func (l *library) VgpuTypeGetDeviceID(vgpuTypeId VgpuTypeId) (uint64, uint64, Return) { + return vgpuTypeId.GetDeviceID() } -func (VgpuTypeId VgpuTypeId) GetDeviceID() (uint64, uint64, Return) { - return VgpuTypeGetDeviceID(VgpuTypeId) +func (vgpuTypeId nvmlVgpuTypeId) GetDeviceID() (uint64, uint64, Return) { + var deviceID, subsystemID uint64 + ret := nvmlVgpuTypeGetDeviceID(vgpuTypeId, &deviceID, &subsystemID) + return deviceID, subsystemID, ret } // nvml.VgpuTypeGetFramebufferSize() -func VgpuTypeGetFramebufferSize(VgpuTypeId VgpuTypeId) (uint64, Return) { - var FbSize uint64 - ret := nvmlVgpuTypeGetFramebufferSize(VgpuTypeId, &FbSize) - return FbSize, ret +func (l *library) VgpuTypeGetFramebufferSize(vgpuTypeId VgpuTypeId) (uint64, Return) { + return vgpuTypeId.GetFramebufferSize() } -func (VgpuTypeId VgpuTypeId) GetFramebufferSize() (uint64, Return) { - return VgpuTypeGetFramebufferSize(VgpuTypeId) +func (vgpuTypeId nvmlVgpuTypeId) GetFramebufferSize() (uint64, Return) { + var fbSize uint64 + ret := nvmlVgpuTypeGetFramebufferSize(vgpuTypeId, &fbSize) + return fbSize, ret } // nvml.VgpuTypeGetNumDisplayHeads() -func VgpuTypeGetNumDisplayHeads(VgpuTypeId VgpuTypeId) (int, Return) { - var NumDisplayHeads uint32 - ret := nvmlVgpuTypeGetNumDisplayHeads(VgpuTypeId, &NumDisplayHeads) - return int(NumDisplayHeads), ret +func (l *library) VgpuTypeGetNumDisplayHeads(vgpuTypeId VgpuTypeId) (int, Return) { + return vgpuTypeId.GetNumDisplayHeads() } -func (VgpuTypeId VgpuTypeId) GetNumDisplayHeads() (int, Return) { - return VgpuTypeGetNumDisplayHeads(VgpuTypeId) +func (vgpuTypeId nvmlVgpuTypeId) GetNumDisplayHeads() (int, Return) { + var numDisplayHeads uint32 + ret := nvmlVgpuTypeGetNumDisplayHeads(vgpuTypeId, &numDisplayHeads) + return int(numDisplayHeads), ret } // 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 (l *library) VgpuTypeGetResolution(vgpuTypeId VgpuTypeId, displayIndex int) (uint32, uint32, Return) { + return vgpuTypeId.GetResolution(displayIndex) } -func (VgpuTypeId VgpuTypeId) GetResolution(DisplayIndex int) (uint32, uint32, Return) { - return VgpuTypeGetResolution(VgpuTypeId, DisplayIndex) +func (vgpuTypeId nvmlVgpuTypeId) GetResolution(displayIndex int) (uint32, uint32, Return) { + var xdim, ydim uint32 + ret := nvmlVgpuTypeGetResolution(vgpuTypeId, uint32(displayIndex), &xdim, &ydim) + return xdim, ydim, ret } // 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 (l *library) VgpuTypeGetLicense(vgpuTypeId VgpuTypeId) (string, Return) { + return vgpuTypeId.GetLicense() } -func (VgpuTypeId VgpuTypeId) GetLicense() (string, Return) { - return VgpuTypeGetLicense(VgpuTypeId) +func (vgpuTypeId nvmlVgpuTypeId) GetLicense() (string, Return) { + vgpuTypeLicenseString := make([]byte, GRID_LICENSE_BUFFER_SIZE) + ret := nvmlVgpuTypeGetLicense(vgpuTypeId, &vgpuTypeLicenseString[0], GRID_LICENSE_BUFFER_SIZE) + return string(vgpuTypeLicenseString[:clen(vgpuTypeLicenseString)]), ret } // nvml.VgpuTypeGetFrameRateLimit() -func VgpuTypeGetFrameRateLimit(VgpuTypeId VgpuTypeId) (uint32, Return) { - var FrameRateLimit uint32 - ret := nvmlVgpuTypeGetFrameRateLimit(VgpuTypeId, &FrameRateLimit) - return FrameRateLimit, ret +func (l *library) VgpuTypeGetFrameRateLimit(vgpuTypeId VgpuTypeId) (uint32, Return) { + return vgpuTypeId.GetFrameRateLimit() } -func (VgpuTypeId VgpuTypeId) GetFrameRateLimit() (uint32, Return) { - return VgpuTypeGetFrameRateLimit(VgpuTypeId) +func (vgpuTypeId nvmlVgpuTypeId) GetFrameRateLimit() (uint32, Return) { + var frameRateLimit uint32 + ret := nvmlVgpuTypeGetFrameRateLimit(vgpuTypeId, &frameRateLimit) + return frameRateLimit, ret } // nvml.VgpuTypeGetMaxInstances() -func VgpuTypeGetMaxInstances(Device Device, VgpuTypeId VgpuTypeId) (int, Return) { - var VgpuInstanceCount uint32 - ret := nvmlVgpuTypeGetMaxInstances(Device, VgpuTypeId, &VgpuInstanceCount) - return int(VgpuInstanceCount), ret +func (l *library) VgpuTypeGetMaxInstances(device Device, vgpuTypeId VgpuTypeId) (int, Return) { + return vgpuTypeId.GetMaxInstances(device) } -func (Device Device) VgpuTypeGetMaxInstances(VgpuTypeId VgpuTypeId) (int, Return) { - return VgpuTypeGetMaxInstances(Device, VgpuTypeId) +func (device nvmlDevice) VgpuTypeGetMaxInstances(vgpuTypeId VgpuTypeId) (int, Return) { + return vgpuTypeId.GetMaxInstances(device) } -func (VgpuTypeId VgpuTypeId) GetMaxInstances(Device Device) (int, Return) { - return VgpuTypeGetMaxInstances(Device, VgpuTypeId) +func (vgpuTypeId nvmlVgpuTypeId) GetMaxInstances(device Device) (int, Return) { + var vgpuInstanceCount uint32 + ret := nvmlVgpuTypeGetMaxInstances(nvmlDeviceHandle(device), vgpuTypeId, &vgpuInstanceCount) + return int(vgpuInstanceCount), ret } // nvml.VgpuTypeGetMaxInstancesPerVm() -func VgpuTypeGetMaxInstancesPerVm(VgpuTypeId VgpuTypeId) (int, Return) { - var VgpuInstanceCountPerVm uint32 - ret := nvmlVgpuTypeGetMaxInstancesPerVm(VgpuTypeId, &VgpuInstanceCountPerVm) - return int(VgpuInstanceCountPerVm), ret +func (l *library) VgpuTypeGetMaxInstancesPerVm(vgpuTypeId VgpuTypeId) (int, Return) { + return vgpuTypeId.GetMaxInstancesPerVm() } -func (VgpuTypeId VgpuTypeId) GetMaxInstancesPerVm() (int, Return) { - return VgpuTypeGetMaxInstancesPerVm(VgpuTypeId) +func (vgpuTypeId nvmlVgpuTypeId) GetMaxInstancesPerVm() (int, Return) { + var vgpuInstanceCountPerVm uint32 + ret := nvmlVgpuTypeGetMaxInstancesPerVm(vgpuTypeId, &vgpuInstanceCountPerVm) + return int(vgpuInstanceCountPerVm), ret } // 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 (l *library) VgpuInstanceGetVmID(vgpuInstance VgpuInstance) (string, VgpuVmIdType, Return) { + return vgpuInstance.GetVmID() } -func (VgpuInstance VgpuInstance) GetVmID() (string, VgpuVmIdType, Return) { - return VgpuInstanceGetVmID(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetVmID() (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 } // 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 (l *library) VgpuInstanceGetUUID(vgpuInstance VgpuInstance) (string, Return) { + return vgpuInstance.GetUUID() } -func (VgpuInstance VgpuInstance) GetUUID() (string, Return) { - return VgpuInstanceGetUUID(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetUUID() (string, Return) { + uuid := make([]byte, DEVICE_UUID_BUFFER_SIZE) + ret := nvmlVgpuInstanceGetUUID(vgpuInstance, &uuid[0], DEVICE_UUID_BUFFER_SIZE) + return string(uuid[:clen(uuid)]), ret } // 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 (l *library) VgpuInstanceGetVmDriverVersion(vgpuInstance VgpuInstance) (string, Return) { + return vgpuInstance.GetVmDriverVersion() } -func (VgpuInstance VgpuInstance) GetVmDriverVersion() (string, Return) { - return VgpuInstanceGetVmDriverVersion(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetVmDriverVersion() (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 } // nvml.VgpuInstanceGetFbUsage() -func VgpuInstanceGetFbUsage(VgpuInstance VgpuInstance) (uint64, Return) { - var FbUsage uint64 - ret := nvmlVgpuInstanceGetFbUsage(VgpuInstance, &FbUsage) - return FbUsage, ret +func (l *library) VgpuInstanceGetFbUsage(vgpuInstance VgpuInstance) (uint64, Return) { + return vgpuInstance.GetFbUsage() } -func (VgpuInstance VgpuInstance) GetFbUsage() (uint64, Return) { - return VgpuInstanceGetFbUsage(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetFbUsage() (uint64, Return) { + var fbUsage uint64 + ret := nvmlVgpuInstanceGetFbUsage(vgpuInstance, &fbUsage) + return fbUsage, ret } // nvml.VgpuInstanceGetLicenseInfo() -func VgpuInstanceGetLicenseInfo(VgpuInstance VgpuInstance) (VgpuLicenseInfo, Return) { - var LicenseInfo VgpuLicenseInfo - ret := nvmlVgpuInstanceGetLicenseInfo(VgpuInstance, &LicenseInfo) - return LicenseInfo, ret +func (l *library) VgpuInstanceGetLicenseInfo(vgpuInstance VgpuInstance) (VgpuLicenseInfo, Return) { + return vgpuInstance.GetLicenseInfo() } -func (VgpuInstance VgpuInstance) GetLicenseInfo() (VgpuLicenseInfo, Return) { - return VgpuInstanceGetLicenseInfo(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetLicenseInfo() (VgpuLicenseInfo, Return) { + var licenseInfo VgpuLicenseInfo + ret := nvmlVgpuInstanceGetLicenseInfo(vgpuInstance, &licenseInfo) + return licenseInfo, ret } // nvml.VgpuInstanceGetLicenseStatus() -func VgpuInstanceGetLicenseStatus(VgpuInstance VgpuInstance) (int, Return) { - var Licensed uint32 - ret := nvmlVgpuInstanceGetLicenseStatus(VgpuInstance, &Licensed) - return int(Licensed), ret +func (l *library) VgpuInstanceGetLicenseStatus(vgpuInstance VgpuInstance) (int, Return) { + return vgpuInstance.GetLicenseStatus() } -func (VgpuInstance VgpuInstance) GetLicenseStatus() (int, Return) { - return VgpuInstanceGetLicenseStatus(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetLicenseStatus() (int, Return) { + var licensed uint32 + ret := nvmlVgpuInstanceGetLicenseStatus(vgpuInstance, &licensed) + return int(licensed), ret } // nvml.VgpuInstanceGetType() -func VgpuInstanceGetType(VgpuInstance VgpuInstance) (VgpuTypeId, Return) { - var VgpuTypeId VgpuTypeId - ret := nvmlVgpuInstanceGetType(VgpuInstance, &VgpuTypeId) - return VgpuTypeId, ret +func (l *library) VgpuInstanceGetType(vgpuInstance VgpuInstance) (VgpuTypeId, Return) { + return vgpuInstance.GetType() } -func (VgpuInstance VgpuInstance) GetType() (VgpuTypeId, Return) { - return VgpuInstanceGetType(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetType() (VgpuTypeId, Return) { + var vgpuTypeId nvmlVgpuTypeId + ret := nvmlVgpuInstanceGetType(vgpuInstance, &vgpuTypeId) + return vgpuTypeId, ret } // nvml.VgpuInstanceGetFrameRateLimit() -func VgpuInstanceGetFrameRateLimit(VgpuInstance VgpuInstance) (uint32, Return) { - var FrameRateLimit uint32 - ret := nvmlVgpuInstanceGetFrameRateLimit(VgpuInstance, &FrameRateLimit) - return FrameRateLimit, ret +func (l *library) VgpuInstanceGetFrameRateLimit(vgpuInstance VgpuInstance) (uint32, Return) { + return vgpuInstance.GetFrameRateLimit() } -func (VgpuInstance VgpuInstance) GetFrameRateLimit() (uint32, Return) { - return VgpuInstanceGetFrameRateLimit(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetFrameRateLimit() (uint32, Return) { + var frameRateLimit uint32 + ret := nvmlVgpuInstanceGetFrameRateLimit(vgpuInstance, &frameRateLimit) + return frameRateLimit, ret } // nvml.VgpuInstanceGetEccMode() -func VgpuInstanceGetEccMode(VgpuInstance VgpuInstance) (EnableState, Return) { - var EccMode EnableState - ret := nvmlVgpuInstanceGetEccMode(VgpuInstance, &EccMode) - return EccMode, ret +func (l *library) VgpuInstanceGetEccMode(vgpuInstance VgpuInstance) (EnableState, Return) { + return vgpuInstance.GetEccMode() } -func (VgpuInstance VgpuInstance) GetEccMode() (EnableState, Return) { - return VgpuInstanceGetEccMode(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetEccMode() (EnableState, Return) { + var eccMode EnableState + ret := nvmlVgpuInstanceGetEccMode(vgpuInstance, &eccMode) + return eccMode, ret } // nvml.VgpuInstanceGetEncoderCapacity() -func VgpuInstanceGetEncoderCapacity(VgpuInstance VgpuInstance) (int, Return) { - var EncoderCapacity uint32 - ret := nvmlVgpuInstanceGetEncoderCapacity(VgpuInstance, &EncoderCapacity) - return int(EncoderCapacity), ret +func (l *library) VgpuInstanceGetEncoderCapacity(vgpuInstance VgpuInstance) (int, Return) { + return vgpuInstance.GetEncoderCapacity() } -func (VgpuInstance VgpuInstance) GetEncoderCapacity() (int, Return) { - return VgpuInstanceGetEncoderCapacity(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetEncoderCapacity() (int, Return) { + var encoderCapacity uint32 + ret := nvmlVgpuInstanceGetEncoderCapacity(vgpuInstance, &encoderCapacity) + return int(encoderCapacity), ret } // nvml.VgpuInstanceSetEncoderCapacity() -func VgpuInstanceSetEncoderCapacity(VgpuInstance VgpuInstance, EncoderCapacity int) Return { - return nvmlVgpuInstanceSetEncoderCapacity(VgpuInstance, uint32(EncoderCapacity)) +func (l *library) VgpuInstanceSetEncoderCapacity(vgpuInstance VgpuInstance, encoderCapacity int) Return { + return vgpuInstance.SetEncoderCapacity(encoderCapacity) } -func (VgpuInstance VgpuInstance) SetEncoderCapacity(EncoderCapacity int) Return { - return VgpuInstanceSetEncoderCapacity(VgpuInstance, EncoderCapacity) +func (vgpuInstance nvmlVgpuInstance) SetEncoderCapacity(encoderCapacity int) Return { + return nvmlVgpuInstanceSetEncoderCapacity(vgpuInstance, uint32(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 (l *library) VgpuInstanceGetEncoderStats(vgpuInstance VgpuInstance) (int, uint32, uint32, Return) { + return vgpuInstance.GetEncoderStats() } -func (VgpuInstance VgpuInstance) GetEncoderStats() (int, uint32, uint32, Return) { - return VgpuInstanceGetEncoderStats(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetEncoderStats() (int, uint32, uint32, Return) { + var sessionCount, averageFps, averageLatency uint32 + ret := nvmlVgpuInstanceGetEncoderStats(vgpuInstance, &sessionCount, &averageFps, &averageLatency) + return int(sessionCount), averageFps, averageLatency, ret } // 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 (l *library) VgpuInstanceGetEncoderSessions(vgpuInstance VgpuInstance) (int, EncoderSessionInfo, Return) { + return vgpuInstance.GetEncoderSessions() } -func (VgpuInstance VgpuInstance) GetEncoderSessions() (int, EncoderSessionInfo, Return) { - return VgpuInstanceGetEncoderSessions(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetEncoderSessions() (int, EncoderSessionInfo, Return) { + var sessionCount uint32 + var sessionInfo EncoderSessionInfo + ret := nvmlVgpuInstanceGetEncoderSessions(vgpuInstance, &sessionCount, &sessionInfo) + return int(sessionCount), sessionInfo, ret } // nvml.VgpuInstanceGetFBCStats() -func VgpuInstanceGetFBCStats(VgpuInstance VgpuInstance) (FBCStats, Return) { - var FbcStats FBCStats - ret := nvmlVgpuInstanceGetFBCStats(VgpuInstance, &FbcStats) - return FbcStats, ret +func (l *library) VgpuInstanceGetFBCStats(vgpuInstance VgpuInstance) (FBCStats, Return) { + return vgpuInstance.GetFBCStats() } -func (VgpuInstance VgpuInstance) GetFBCStats() (FBCStats, Return) { - return VgpuInstanceGetFBCStats(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetFBCStats() (FBCStats, Return) { + var fbcStats FBCStats + ret := nvmlVgpuInstanceGetFBCStats(vgpuInstance, &fbcStats) + return fbcStats, ret } // 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 (l *library) VgpuInstanceGetFBCSessions(vgpuInstance VgpuInstance) (int, FBCSessionInfo, Return) { + return vgpuInstance.GetFBCSessions() } -func (VgpuInstance VgpuInstance) GetFBCSessions() (int, FBCSessionInfo, Return) { - return VgpuInstanceGetFBCSessions(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetFBCSessions() (int, FBCSessionInfo, Return) { + var sessionCount uint32 + var sessionInfo FBCSessionInfo + ret := nvmlVgpuInstanceGetFBCSessions(vgpuInstance, &sessionCount, &sessionInfo) + return int(sessionCount), sessionInfo, ret } // nvml.VgpuInstanceGetGpuInstanceId() -func VgpuInstanceGetGpuInstanceId(VgpuInstance VgpuInstance) (int, Return) { +func (l *library) VgpuInstanceGetGpuInstanceId(vgpuInstance VgpuInstance) (int, Return) { + return vgpuInstance.GetGpuInstanceId() +} + +func (vgpuInstance nvmlVgpuInstance) GetGpuInstanceId() (int, Return) { var gpuInstanceId uint32 - ret := nvmlVgpuInstanceGetGpuInstanceId(VgpuInstance, &gpuInstanceId) + ret := nvmlVgpuInstanceGetGpuInstanceId(vgpuInstance, &gpuInstanceId) return int(gpuInstanceId), ret } -func (VgpuInstance VgpuInstance) GetGpuInstanceId() (int, Return) { - return VgpuInstanceGetGpuInstanceId(VgpuInstance) +// nvml.VgpuInstanceGetGpuPciId() +func (l *library) VgpuInstanceGetGpuPciId(vgpuInstance VgpuInstance) (string, Return) { + return vgpuInstance.GetGpuPciId() } -// nvml.VgpuInstanceGetGpuPciId() -func VgpuInstanceGetGpuPciId(VgpuInstance VgpuInstance) (string, Return) { - var Length uint32 = 1 // Will be reduced upon returning +func (vgpuInstance nvmlVgpuInstance) GetGpuPciId() (string, Return) { + var length uint32 = 1 // Will be reduced upon returning for { - VgpuPciId := make([]byte, Length) - ret := nvmlVgpuInstanceGetGpuPciId(VgpuInstance, &VgpuPciId[0], &Length) + vgpuPciId := make([]byte, length) + ret := nvmlVgpuInstanceGetGpuPciId(vgpuInstance, &vgpuPciId[0], &length) if ret == SUCCESS { - return string(VgpuPciId[:clen(VgpuPciId)]), ret + return string(vgpuPciId[:clen(vgpuPciId)]), ret } if ret != ERROR_INSUFFICIENT_SIZE { return "", ret } - Length *= 2 + length *= 2 } } -func (VgpuInstance VgpuInstance) GetGpuPciId() (string, Return) { - return VgpuInstanceGetGpuPciId(VgpuInstance) +// nvml.VgpuInstanceGetMetadata() +func (l *library) VgpuInstanceGetMetadata(vgpuInstance VgpuInstance) (VgpuMetadata, Return) { + return vgpuInstance.GetMetadata() } -// nvml.VgpuInstanceGetMetadata() -func VgpuInstanceGetMetadata(VgpuInstance VgpuInstance) (VgpuMetadata, Return) { - var VgpuMetadata VgpuMetadata - OpaqueDataSize := unsafe.Sizeof(VgpuMetadata.nvmlVgpuMetadata.OpaqueData) - VgpuMetadataSize := unsafe.Sizeof(VgpuMetadata.nvmlVgpuMetadata) - OpaqueDataSize +func (vgpuInstance nvmlVgpuInstance) GetMetadata() (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) + 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 + vgpuMetadata.nvmlVgpuMetadata = *nvmlVgpuMetadataPtr + vgpuMetadata.OpaqueData = buffer[vgpuMetadataSize:bufferSize] + return vgpuMetadata, ret } if ret != ERROR_INSUFFICIENT_SIZE { - return VgpuMetadata, ret + return vgpuMetadata, ret } - OpaqueDataSize = 2 * OpaqueDataSize + 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 (l *library) VgpuInstanceGetAccountingMode(vgpuInstance VgpuInstance) (EnableState, Return) { + return vgpuInstance.GetAccountingMode() } -func (VgpuInstance VgpuInstance) GetAccountingMode() (EnableState, Return) { - return VgpuInstanceGetAccountingMode(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetAccountingMode() (EnableState, Return) { + var mode EnableState + ret := nvmlVgpuInstanceGetAccountingMode(vgpuInstance, &mode) + return mode, ret } // nvml.VgpuInstanceGetAccountingPids() -func VgpuInstanceGetAccountingPids(VgpuInstance VgpuInstance) ([]int, Return) { - var Count uint32 = 1 // Will be reduced upon returning +func (l *library) VgpuInstanceGetAccountingPids(vgpuInstance VgpuInstance) ([]int, Return) { + return vgpuInstance.GetAccountingPids() +} + +func (vgpuInstance nvmlVgpuInstance) GetAccountingPids() ([]int, Return) { + var count uint32 = 1 // Will be reduced upon returning for { - Pids := make([]uint32, Count) - ret := nvmlVgpuInstanceGetAccountingPids(VgpuInstance, &Count, &Pids[0]) + pids := make([]uint32, count) + ret := nvmlVgpuInstanceGetAccountingPids(vgpuInstance, &count, &pids[0]) if ret == SUCCESS { - return uint32SliceToIntSlice(Pids[:Count]), ret + return uint32SliceToIntSlice(pids[:count]), ret } if ret != ERROR_INSUFFICIENT_SIZE { return nil, ret } - Count *= 2 + 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 (l *library) VgpuInstanceGetAccountingStats(vgpuInstance VgpuInstance, pid int) (AccountingStats, Return) { + return vgpuInstance.GetAccountingStats(pid) } -func (VgpuInstance VgpuInstance) GetAccountingStats(Pid int) (AccountingStats, Return) { - return VgpuInstanceGetAccountingStats(VgpuInstance, Pid) +func (vgpuInstance nvmlVgpuInstance) GetAccountingStats(pid int) (AccountingStats, Return) { + var stats AccountingStats + ret := nvmlVgpuInstanceGetAccountingStats(vgpuInstance, uint32(pid), &stats) + return stats, ret } // nvml.GetVgpuCompatibility() -func GetVgpuCompatibility(nvmlVgpuMetadata *nvmlVgpuMetadata, PgpuMetadata *nvmlVgpuPgpuMetadata) (VgpuPgpuCompatibility, Return) { - var CompatibilityInfo VgpuPgpuCompatibility - ret := nvmlGetVgpuCompatibility(nvmlVgpuMetadata, PgpuMetadata, &CompatibilityInfo) - return CompatibilityInfo, ret +func (l *library) GetVgpuCompatibility(vgpuMetadata *VgpuMetadata, pgpuMetadata *VgpuPgpuMetadata) (VgpuPgpuCompatibility, Return) { + var compatibilityInfo VgpuPgpuCompatibility + ret := nvmlGetVgpuCompatibility(&vgpuMetadata.nvmlVgpuMetadata, &pgpuMetadata.nvmlVgpuPgpuMetadata, &compatibilityInfo) + return compatibilityInfo, ret } // nvml.GetVgpuVersion() -func GetVgpuVersion() (VgpuVersion, VgpuVersion, Return) { - var Supported, Current VgpuVersion - ret := nvmlGetVgpuVersion(&Supported, &Current) - return Supported, Current, ret +func (l *library) GetVgpuVersion() (VgpuVersion, VgpuVersion, Return) { + var supported, current VgpuVersion + ret := nvmlGetVgpuVersion(&supported, ¤t) + return supported, current, ret } // nvml.SetVgpuVersion() -func SetVgpuVersion(VgpuVersion *VgpuVersion) Return { - return nvmlSetVgpuVersion(VgpuVersion) +func (l *library) SetVgpuVersion(vgpuVersion *VgpuVersion) Return { + return nvmlSetVgpuVersion(vgpuVersion) } // nvml.VgpuInstanceClearAccountingPids() -func VgpuInstanceClearAccountingPids(VgpuInstance VgpuInstance) Return { - return nvmlVgpuInstanceClearAccountingPids(VgpuInstance) +func (l *library) VgpuInstanceClearAccountingPids(vgpuInstance VgpuInstance) Return { + return vgpuInstance.ClearAccountingPids() } -func (VgpuInstance VgpuInstance) ClearAccountingPids() Return { - return VgpuInstanceClearAccountingPids(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) ClearAccountingPids() Return { + return nvmlVgpuInstanceClearAccountingPids(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 (l *library) VgpuInstanceGetMdevUUID(vgpuInstance VgpuInstance) (string, Return) { + return vgpuInstance.GetMdevUUID() } -func (VgpuInstance VgpuInstance) GetMdevUUID() (string, Return) { - return VgpuInstanceGetMdevUUID(VgpuInstance) +func (vgpuInstance nvmlVgpuInstance) GetMdevUUID() (string, Return) { + mdevUUID := make([]byte, DEVICE_UUID_BUFFER_SIZE) + ret := nvmlVgpuInstanceGetMdevUUID(vgpuInstance, &mdevUUID[0], DEVICE_UUID_BUFFER_SIZE) + return string(mdevUUID[:clen(mdevUUID)]), ret } // nvml.VgpuTypeGetCapabilities() -func VgpuTypeGetCapabilities(VgpuTypeId VgpuTypeId, Capability VgpuCapability) (bool, Return) { - var CapResult uint32 - ret := nvmlVgpuTypeGetCapabilities(VgpuTypeId, Capability, &CapResult) - return (CapResult != 0), ret +func (l *library) VgpuTypeGetCapabilities(vgpuTypeId VgpuTypeId, capability VgpuCapability) (bool, Return) { + return vgpuTypeId.GetCapabilities(capability) } -func (VgpuTypeId VgpuTypeId) GetCapabilities(Capability VgpuCapability) (bool, Return) { - return VgpuTypeGetCapabilities(VgpuTypeId, Capability) +func (vgpuTypeId nvmlVgpuTypeId) GetCapabilities(capability VgpuCapability) (bool, Return) { + var capResult uint32 + ret := nvmlVgpuTypeGetCapabilities(vgpuTypeId, capability, &capResult) + return (capResult != 0), ret } // nvml.GetVgpuDriverCapabilities() -func GetVgpuDriverCapabilities(Capability VgpuDriverCapability) (bool, Return) { - var CapResult uint32 - ret := nvmlGetVgpuDriverCapabilities(Capability, &CapResult) - return (CapResult != 0), ret +func (l *library) GetVgpuDriverCapabilities(capability VgpuDriverCapability) (bool, Return) { + var capResult uint32 + ret := nvmlGetVgpuDriverCapabilities(capability, &capResult) + return (capResult != 0), ret } diff --git a/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/zz_generated.api.go b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/zz_generated.api.go new file mode 100644 index 00000000..c1ecb2d0 --- /dev/null +++ b/vendor/github.com/NVIDIA/go-nvml/pkg/nvml/zz_generated.api.go @@ -0,0 +1,1007 @@ +/** +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +// Generated Code; DO NOT EDIT. + +package nvml + +// The variables below represent package level methods from the library type. +var ( + ComputeInstanceDestroy = libnvml.ComputeInstanceDestroy + ComputeInstanceGetInfo = libnvml.ComputeInstanceGetInfo + DeviceClearAccountingPids = libnvml.DeviceClearAccountingPids + DeviceClearCpuAffinity = libnvml.DeviceClearCpuAffinity + DeviceClearEccErrorCounts = libnvml.DeviceClearEccErrorCounts + DeviceClearFieldValues = libnvml.DeviceClearFieldValues + DeviceCreateGpuInstance = libnvml.DeviceCreateGpuInstance + DeviceCreateGpuInstanceWithPlacement = libnvml.DeviceCreateGpuInstanceWithPlacement + DeviceDiscoverGpus = libnvml.DeviceDiscoverGpus + DeviceFreezeNvLinkUtilizationCounter = libnvml.DeviceFreezeNvLinkUtilizationCounter + DeviceGetAPIRestriction = libnvml.DeviceGetAPIRestriction + DeviceGetAccountingBufferSize = libnvml.DeviceGetAccountingBufferSize + DeviceGetAccountingMode = libnvml.DeviceGetAccountingMode + DeviceGetAccountingPids = libnvml.DeviceGetAccountingPids + DeviceGetAccountingStats = libnvml.DeviceGetAccountingStats + DeviceGetActiveVgpus = libnvml.DeviceGetActiveVgpus + DeviceGetAdaptiveClockInfoStatus = libnvml.DeviceGetAdaptiveClockInfoStatus + DeviceGetApplicationsClock = libnvml.DeviceGetApplicationsClock + DeviceGetArchitecture = libnvml.DeviceGetArchitecture + DeviceGetAttributes = libnvml.DeviceGetAttributes + DeviceGetAutoBoostedClocksEnabled = libnvml.DeviceGetAutoBoostedClocksEnabled + DeviceGetBAR1MemoryInfo = libnvml.DeviceGetBAR1MemoryInfo + DeviceGetBoardId = libnvml.DeviceGetBoardId + DeviceGetBoardPartNumber = libnvml.DeviceGetBoardPartNumber + DeviceGetBrand = libnvml.DeviceGetBrand + DeviceGetBridgeChipInfo = libnvml.DeviceGetBridgeChipInfo + DeviceGetBusType = libnvml.DeviceGetBusType + DeviceGetC2cModeInfoV = libnvml.DeviceGetC2cModeInfoV + DeviceGetClkMonStatus = libnvml.DeviceGetClkMonStatus + DeviceGetClock = libnvml.DeviceGetClock + DeviceGetClockInfo = libnvml.DeviceGetClockInfo + DeviceGetComputeInstanceId = libnvml.DeviceGetComputeInstanceId + DeviceGetComputeMode = libnvml.DeviceGetComputeMode + DeviceGetComputeRunningProcesses = libnvml.DeviceGetComputeRunningProcesses + DeviceGetConfComputeGpuAttestationReport = libnvml.DeviceGetConfComputeGpuAttestationReport + DeviceGetConfComputeGpuCertificate = libnvml.DeviceGetConfComputeGpuCertificate + DeviceGetConfComputeMemSizeInfo = libnvml.DeviceGetConfComputeMemSizeInfo + DeviceGetConfComputeProtectedMemoryUsage = libnvml.DeviceGetConfComputeProtectedMemoryUsage + DeviceGetCount = libnvml.DeviceGetCount + DeviceGetCpuAffinity = libnvml.DeviceGetCpuAffinity + DeviceGetCpuAffinityWithinScope = libnvml.DeviceGetCpuAffinityWithinScope + DeviceGetCreatableVgpus = libnvml.DeviceGetCreatableVgpus + DeviceGetCudaComputeCapability = libnvml.DeviceGetCudaComputeCapability + DeviceGetCurrPcieLinkGeneration = libnvml.DeviceGetCurrPcieLinkGeneration + DeviceGetCurrPcieLinkWidth = libnvml.DeviceGetCurrPcieLinkWidth + DeviceGetCurrentClocksEventReasons = libnvml.DeviceGetCurrentClocksEventReasons + DeviceGetCurrentClocksThrottleReasons = libnvml.DeviceGetCurrentClocksThrottleReasons + DeviceGetDecoderUtilization = libnvml.DeviceGetDecoderUtilization + DeviceGetDefaultApplicationsClock = libnvml.DeviceGetDefaultApplicationsClock + DeviceGetDefaultEccMode = libnvml.DeviceGetDefaultEccMode + DeviceGetDetailedEccErrors = libnvml.DeviceGetDetailedEccErrors + DeviceGetDeviceHandleFromMigDeviceHandle = libnvml.DeviceGetDeviceHandleFromMigDeviceHandle + DeviceGetDisplayActive = libnvml.DeviceGetDisplayActive + DeviceGetDisplayMode = libnvml.DeviceGetDisplayMode + DeviceGetDriverModel = libnvml.DeviceGetDriverModel + DeviceGetDynamicPstatesInfo = libnvml.DeviceGetDynamicPstatesInfo + DeviceGetEccMode = libnvml.DeviceGetEccMode + DeviceGetEncoderCapacity = libnvml.DeviceGetEncoderCapacity + DeviceGetEncoderSessions = libnvml.DeviceGetEncoderSessions + DeviceGetEncoderStats = libnvml.DeviceGetEncoderStats + DeviceGetEncoderUtilization = libnvml.DeviceGetEncoderUtilization + DeviceGetEnforcedPowerLimit = libnvml.DeviceGetEnforcedPowerLimit + DeviceGetFBCSessions = libnvml.DeviceGetFBCSessions + DeviceGetFBCStats = libnvml.DeviceGetFBCStats + DeviceGetFanControlPolicy_v2 = libnvml.DeviceGetFanControlPolicy_v2 + DeviceGetFanSpeed = libnvml.DeviceGetFanSpeed + DeviceGetFanSpeed_v2 = libnvml.DeviceGetFanSpeed_v2 + DeviceGetFieldValues = libnvml.DeviceGetFieldValues + DeviceGetGpcClkMinMaxVfOffset = libnvml.DeviceGetGpcClkMinMaxVfOffset + DeviceGetGpcClkVfOffset = libnvml.DeviceGetGpcClkVfOffset + DeviceGetGpuFabricInfo = libnvml.DeviceGetGpuFabricInfo + DeviceGetGpuFabricInfoV = libnvml.DeviceGetGpuFabricInfoV + DeviceGetGpuInstanceById = libnvml.DeviceGetGpuInstanceById + DeviceGetGpuInstanceId = libnvml.DeviceGetGpuInstanceId + DeviceGetGpuInstancePossiblePlacements = libnvml.DeviceGetGpuInstancePossiblePlacements + DeviceGetGpuInstanceProfileInfo = libnvml.DeviceGetGpuInstanceProfileInfo + DeviceGetGpuInstanceProfileInfoV = libnvml.DeviceGetGpuInstanceProfileInfoV + DeviceGetGpuInstanceRemainingCapacity = libnvml.DeviceGetGpuInstanceRemainingCapacity + DeviceGetGpuInstances = libnvml.DeviceGetGpuInstances + DeviceGetGpuMaxPcieLinkGeneration = libnvml.DeviceGetGpuMaxPcieLinkGeneration + DeviceGetGpuOperationMode = libnvml.DeviceGetGpuOperationMode + DeviceGetGraphicsRunningProcesses = libnvml.DeviceGetGraphicsRunningProcesses + DeviceGetGridLicensableFeatures = libnvml.DeviceGetGridLicensableFeatures + DeviceGetGspFirmwareMode = libnvml.DeviceGetGspFirmwareMode + DeviceGetGspFirmwareVersion = libnvml.DeviceGetGspFirmwareVersion + DeviceGetHandleByIndex = libnvml.DeviceGetHandleByIndex + DeviceGetHandleByPciBusId = libnvml.DeviceGetHandleByPciBusId + DeviceGetHandleBySerial = libnvml.DeviceGetHandleBySerial + DeviceGetHandleByUUID = libnvml.DeviceGetHandleByUUID + DeviceGetHostVgpuMode = libnvml.DeviceGetHostVgpuMode + DeviceGetIndex = libnvml.DeviceGetIndex + DeviceGetInforomConfigurationChecksum = libnvml.DeviceGetInforomConfigurationChecksum + DeviceGetInforomImageVersion = libnvml.DeviceGetInforomImageVersion + DeviceGetInforomVersion = libnvml.DeviceGetInforomVersion + DeviceGetIrqNum = libnvml.DeviceGetIrqNum + DeviceGetJpgUtilization = libnvml.DeviceGetJpgUtilization + DeviceGetLastBBXFlushTime = libnvml.DeviceGetLastBBXFlushTime + DeviceGetMPSComputeRunningProcesses = libnvml.DeviceGetMPSComputeRunningProcesses + DeviceGetMaxClockInfo = libnvml.DeviceGetMaxClockInfo + DeviceGetMaxCustomerBoostClock = libnvml.DeviceGetMaxCustomerBoostClock + DeviceGetMaxMigDeviceCount = libnvml.DeviceGetMaxMigDeviceCount + DeviceGetMaxPcieLinkGeneration = libnvml.DeviceGetMaxPcieLinkGeneration + DeviceGetMaxPcieLinkWidth = libnvml.DeviceGetMaxPcieLinkWidth + DeviceGetMemClkMinMaxVfOffset = libnvml.DeviceGetMemClkMinMaxVfOffset + DeviceGetMemClkVfOffset = libnvml.DeviceGetMemClkVfOffset + DeviceGetMemoryAffinity = libnvml.DeviceGetMemoryAffinity + DeviceGetMemoryBusWidth = libnvml.DeviceGetMemoryBusWidth + DeviceGetMemoryErrorCounter = libnvml.DeviceGetMemoryErrorCounter + DeviceGetMemoryInfo = libnvml.DeviceGetMemoryInfo + DeviceGetMemoryInfo_v2 = libnvml.DeviceGetMemoryInfo_v2 + DeviceGetMigDeviceHandleByIndex = libnvml.DeviceGetMigDeviceHandleByIndex + DeviceGetMigMode = libnvml.DeviceGetMigMode + DeviceGetMinMaxClockOfPState = libnvml.DeviceGetMinMaxClockOfPState + DeviceGetMinMaxFanSpeed = libnvml.DeviceGetMinMaxFanSpeed + DeviceGetMinorNumber = libnvml.DeviceGetMinorNumber + DeviceGetModuleId = libnvml.DeviceGetModuleId + DeviceGetMultiGpuBoard = libnvml.DeviceGetMultiGpuBoard + DeviceGetName = libnvml.DeviceGetName + DeviceGetNumFans = libnvml.DeviceGetNumFans + DeviceGetNumGpuCores = libnvml.DeviceGetNumGpuCores + DeviceGetNumaNodeId = libnvml.DeviceGetNumaNodeId + DeviceGetNvLinkCapability = libnvml.DeviceGetNvLinkCapability + DeviceGetNvLinkErrorCounter = libnvml.DeviceGetNvLinkErrorCounter + DeviceGetNvLinkRemoteDeviceType = libnvml.DeviceGetNvLinkRemoteDeviceType + DeviceGetNvLinkRemotePciInfo = libnvml.DeviceGetNvLinkRemotePciInfo + DeviceGetNvLinkState = libnvml.DeviceGetNvLinkState + DeviceGetNvLinkUtilizationControl = libnvml.DeviceGetNvLinkUtilizationControl + DeviceGetNvLinkUtilizationCounter = libnvml.DeviceGetNvLinkUtilizationCounter + DeviceGetNvLinkVersion = libnvml.DeviceGetNvLinkVersion + DeviceGetOfaUtilization = libnvml.DeviceGetOfaUtilization + DeviceGetP2PStatus = libnvml.DeviceGetP2PStatus + DeviceGetPciInfo = libnvml.DeviceGetPciInfo + DeviceGetPciInfoExt = libnvml.DeviceGetPciInfoExt + DeviceGetPcieLinkMaxSpeed = libnvml.DeviceGetPcieLinkMaxSpeed + DeviceGetPcieReplayCounter = libnvml.DeviceGetPcieReplayCounter + DeviceGetPcieSpeed = libnvml.DeviceGetPcieSpeed + DeviceGetPcieThroughput = libnvml.DeviceGetPcieThroughput + DeviceGetPerformanceState = libnvml.DeviceGetPerformanceState + DeviceGetPersistenceMode = libnvml.DeviceGetPersistenceMode + DeviceGetPgpuMetadataString = libnvml.DeviceGetPgpuMetadataString + DeviceGetPowerManagementDefaultLimit = libnvml.DeviceGetPowerManagementDefaultLimit + DeviceGetPowerManagementLimit = libnvml.DeviceGetPowerManagementLimit + DeviceGetPowerManagementLimitConstraints = libnvml.DeviceGetPowerManagementLimitConstraints + DeviceGetPowerManagementMode = libnvml.DeviceGetPowerManagementMode + DeviceGetPowerSource = libnvml.DeviceGetPowerSource + DeviceGetPowerState = libnvml.DeviceGetPowerState + DeviceGetPowerUsage = libnvml.DeviceGetPowerUsage + DeviceGetProcessUtilization = libnvml.DeviceGetProcessUtilization + DeviceGetProcessesUtilizationInfo = libnvml.DeviceGetProcessesUtilizationInfo + DeviceGetRemappedRows = libnvml.DeviceGetRemappedRows + DeviceGetRetiredPages = libnvml.DeviceGetRetiredPages + DeviceGetRetiredPagesPendingStatus = libnvml.DeviceGetRetiredPagesPendingStatus + DeviceGetRetiredPages_v2 = libnvml.DeviceGetRetiredPages_v2 + DeviceGetRowRemapperHistogram = libnvml.DeviceGetRowRemapperHistogram + DeviceGetRunningProcessDetailList = libnvml.DeviceGetRunningProcessDetailList + DeviceGetSamples = libnvml.DeviceGetSamples + DeviceGetSerial = libnvml.DeviceGetSerial + DeviceGetSramEccErrorStatus = libnvml.DeviceGetSramEccErrorStatus + DeviceGetSupportedClocksEventReasons = libnvml.DeviceGetSupportedClocksEventReasons + DeviceGetSupportedClocksThrottleReasons = libnvml.DeviceGetSupportedClocksThrottleReasons + DeviceGetSupportedEventTypes = libnvml.DeviceGetSupportedEventTypes + DeviceGetSupportedGraphicsClocks = libnvml.DeviceGetSupportedGraphicsClocks + DeviceGetSupportedMemoryClocks = libnvml.DeviceGetSupportedMemoryClocks + DeviceGetSupportedPerformanceStates = libnvml.DeviceGetSupportedPerformanceStates + DeviceGetSupportedVgpus = libnvml.DeviceGetSupportedVgpus + DeviceGetTargetFanSpeed = libnvml.DeviceGetTargetFanSpeed + DeviceGetTemperature = libnvml.DeviceGetTemperature + DeviceGetTemperatureThreshold = libnvml.DeviceGetTemperatureThreshold + DeviceGetThermalSettings = libnvml.DeviceGetThermalSettings + DeviceGetTopologyCommonAncestor = libnvml.DeviceGetTopologyCommonAncestor + DeviceGetTopologyNearestGpus = libnvml.DeviceGetTopologyNearestGpus + DeviceGetTotalEccErrors = libnvml.DeviceGetTotalEccErrors + DeviceGetTotalEnergyConsumption = libnvml.DeviceGetTotalEnergyConsumption + DeviceGetUUID = libnvml.DeviceGetUUID + DeviceGetUtilizationRates = libnvml.DeviceGetUtilizationRates + DeviceGetVbiosVersion = libnvml.DeviceGetVbiosVersion + DeviceGetVgpuCapabilities = libnvml.DeviceGetVgpuCapabilities + DeviceGetVgpuHeterogeneousMode = libnvml.DeviceGetVgpuHeterogeneousMode + DeviceGetVgpuInstancesUtilizationInfo = libnvml.DeviceGetVgpuInstancesUtilizationInfo + DeviceGetVgpuMetadata = libnvml.DeviceGetVgpuMetadata + DeviceGetVgpuProcessUtilization = libnvml.DeviceGetVgpuProcessUtilization + DeviceGetVgpuProcessesUtilizationInfo = libnvml.DeviceGetVgpuProcessesUtilizationInfo + DeviceGetVgpuSchedulerCapabilities = libnvml.DeviceGetVgpuSchedulerCapabilities + DeviceGetVgpuSchedulerLog = libnvml.DeviceGetVgpuSchedulerLog + DeviceGetVgpuSchedulerState = libnvml.DeviceGetVgpuSchedulerState + DeviceGetVgpuTypeCreatablePlacements = libnvml.DeviceGetVgpuTypeCreatablePlacements + DeviceGetVgpuTypeSupportedPlacements = libnvml.DeviceGetVgpuTypeSupportedPlacements + DeviceGetVgpuUtilization = libnvml.DeviceGetVgpuUtilization + DeviceGetViolationStatus = libnvml.DeviceGetViolationStatus + DeviceGetVirtualizationMode = libnvml.DeviceGetVirtualizationMode + DeviceIsMigDeviceHandle = libnvml.DeviceIsMigDeviceHandle + DeviceModifyDrainState = libnvml.DeviceModifyDrainState + DeviceOnSameBoard = libnvml.DeviceOnSameBoard + DeviceQueryDrainState = libnvml.DeviceQueryDrainState + DeviceRegisterEvents = libnvml.DeviceRegisterEvents + DeviceRemoveGpu = libnvml.DeviceRemoveGpu + DeviceRemoveGpu_v2 = libnvml.DeviceRemoveGpu_v2 + DeviceResetApplicationsClocks = libnvml.DeviceResetApplicationsClocks + DeviceResetGpuLockedClocks = libnvml.DeviceResetGpuLockedClocks + DeviceResetMemoryLockedClocks = libnvml.DeviceResetMemoryLockedClocks + DeviceResetNvLinkErrorCounters = libnvml.DeviceResetNvLinkErrorCounters + DeviceResetNvLinkUtilizationCounter = libnvml.DeviceResetNvLinkUtilizationCounter + DeviceSetAPIRestriction = libnvml.DeviceSetAPIRestriction + DeviceSetAccountingMode = libnvml.DeviceSetAccountingMode + DeviceSetApplicationsClocks = libnvml.DeviceSetApplicationsClocks + DeviceSetAutoBoostedClocksEnabled = libnvml.DeviceSetAutoBoostedClocksEnabled + DeviceSetComputeMode = libnvml.DeviceSetComputeMode + DeviceSetConfComputeUnprotectedMemSize = libnvml.DeviceSetConfComputeUnprotectedMemSize + DeviceSetCpuAffinity = libnvml.DeviceSetCpuAffinity + DeviceSetDefaultAutoBoostedClocksEnabled = libnvml.DeviceSetDefaultAutoBoostedClocksEnabled + DeviceSetDefaultFanSpeed_v2 = libnvml.DeviceSetDefaultFanSpeed_v2 + DeviceSetDriverModel = libnvml.DeviceSetDriverModel + DeviceSetEccMode = libnvml.DeviceSetEccMode + DeviceSetFanControlPolicy = libnvml.DeviceSetFanControlPolicy + DeviceSetFanSpeed_v2 = libnvml.DeviceSetFanSpeed_v2 + DeviceSetGpcClkVfOffset = libnvml.DeviceSetGpcClkVfOffset + DeviceSetGpuLockedClocks = libnvml.DeviceSetGpuLockedClocks + DeviceSetGpuOperationMode = libnvml.DeviceSetGpuOperationMode + DeviceSetMemClkVfOffset = libnvml.DeviceSetMemClkVfOffset + DeviceSetMemoryLockedClocks = libnvml.DeviceSetMemoryLockedClocks + DeviceSetMigMode = libnvml.DeviceSetMigMode + DeviceSetNvLinkDeviceLowPowerThreshold = libnvml.DeviceSetNvLinkDeviceLowPowerThreshold + DeviceSetNvLinkUtilizationControl = libnvml.DeviceSetNvLinkUtilizationControl + DeviceSetPersistenceMode = libnvml.DeviceSetPersistenceMode + DeviceSetPowerManagementLimit = libnvml.DeviceSetPowerManagementLimit + DeviceSetPowerManagementLimit_v2 = libnvml.DeviceSetPowerManagementLimit_v2 + DeviceSetTemperatureThreshold = libnvml.DeviceSetTemperatureThreshold + DeviceSetVgpuCapabilities = libnvml.DeviceSetVgpuCapabilities + DeviceSetVgpuHeterogeneousMode = libnvml.DeviceSetVgpuHeterogeneousMode + DeviceSetVgpuSchedulerState = libnvml.DeviceSetVgpuSchedulerState + DeviceSetVirtualizationMode = libnvml.DeviceSetVirtualizationMode + DeviceValidateInforom = libnvml.DeviceValidateInforom + ErrorString = libnvml.ErrorString + EventSetCreate = libnvml.EventSetCreate + EventSetFree = libnvml.EventSetFree + EventSetWait = libnvml.EventSetWait + Extensions = libnvml.Extensions + GetExcludedDeviceCount = libnvml.GetExcludedDeviceCount + GetExcludedDeviceInfoByIndex = libnvml.GetExcludedDeviceInfoByIndex + GetVgpuCompatibility = libnvml.GetVgpuCompatibility + GetVgpuDriverCapabilities = libnvml.GetVgpuDriverCapabilities + GetVgpuVersion = libnvml.GetVgpuVersion + GpmMetricsGet = libnvml.GpmMetricsGet + GpmMetricsGetV = libnvml.GpmMetricsGetV + GpmMigSampleGet = libnvml.GpmMigSampleGet + GpmQueryDeviceSupport = libnvml.GpmQueryDeviceSupport + GpmQueryDeviceSupportV = libnvml.GpmQueryDeviceSupportV + GpmQueryIfStreamingEnabled = libnvml.GpmQueryIfStreamingEnabled + GpmSampleAlloc = libnvml.GpmSampleAlloc + GpmSampleFree = libnvml.GpmSampleFree + GpmSampleGet = libnvml.GpmSampleGet + GpmSetStreamingEnabled = libnvml.GpmSetStreamingEnabled + GpuInstanceCreateComputeInstance = libnvml.GpuInstanceCreateComputeInstance + GpuInstanceCreateComputeInstanceWithPlacement = libnvml.GpuInstanceCreateComputeInstanceWithPlacement + GpuInstanceDestroy = libnvml.GpuInstanceDestroy + GpuInstanceGetComputeInstanceById = libnvml.GpuInstanceGetComputeInstanceById + GpuInstanceGetComputeInstancePossiblePlacements = libnvml.GpuInstanceGetComputeInstancePossiblePlacements + GpuInstanceGetComputeInstanceProfileInfo = libnvml.GpuInstanceGetComputeInstanceProfileInfo + GpuInstanceGetComputeInstanceProfileInfoV = libnvml.GpuInstanceGetComputeInstanceProfileInfoV + GpuInstanceGetComputeInstanceRemainingCapacity = libnvml.GpuInstanceGetComputeInstanceRemainingCapacity + GpuInstanceGetComputeInstances = libnvml.GpuInstanceGetComputeInstances + GpuInstanceGetInfo = libnvml.GpuInstanceGetInfo + Init = libnvml.Init + InitWithFlags = libnvml.InitWithFlags + SetVgpuVersion = libnvml.SetVgpuVersion + Shutdown = libnvml.Shutdown + SystemGetConfComputeCapabilities = libnvml.SystemGetConfComputeCapabilities + SystemGetConfComputeKeyRotationThresholdInfo = libnvml.SystemGetConfComputeKeyRotationThresholdInfo + SystemGetConfComputeSettings = libnvml.SystemGetConfComputeSettings + SystemGetCudaDriverVersion = libnvml.SystemGetCudaDriverVersion + SystemGetCudaDriverVersion_v2 = libnvml.SystemGetCudaDriverVersion_v2 + SystemGetDriverVersion = libnvml.SystemGetDriverVersion + SystemGetHicVersion = libnvml.SystemGetHicVersion + SystemGetNVMLVersion = libnvml.SystemGetNVMLVersion + SystemGetProcessName = libnvml.SystemGetProcessName + SystemGetTopologyGpuSet = libnvml.SystemGetTopologyGpuSet + SystemSetConfComputeKeyRotationThresholdInfo = libnvml.SystemSetConfComputeKeyRotationThresholdInfo + UnitGetCount = libnvml.UnitGetCount + UnitGetDevices = libnvml.UnitGetDevices + UnitGetFanSpeedInfo = libnvml.UnitGetFanSpeedInfo + UnitGetHandleByIndex = libnvml.UnitGetHandleByIndex + UnitGetLedState = libnvml.UnitGetLedState + UnitGetPsuInfo = libnvml.UnitGetPsuInfo + UnitGetTemperature = libnvml.UnitGetTemperature + UnitGetUnitInfo = libnvml.UnitGetUnitInfo + UnitSetLedState = libnvml.UnitSetLedState + VgpuInstanceClearAccountingPids = libnvml.VgpuInstanceClearAccountingPids + VgpuInstanceGetAccountingMode = libnvml.VgpuInstanceGetAccountingMode + VgpuInstanceGetAccountingPids = libnvml.VgpuInstanceGetAccountingPids + VgpuInstanceGetAccountingStats = libnvml.VgpuInstanceGetAccountingStats + VgpuInstanceGetEccMode = libnvml.VgpuInstanceGetEccMode + VgpuInstanceGetEncoderCapacity = libnvml.VgpuInstanceGetEncoderCapacity + VgpuInstanceGetEncoderSessions = libnvml.VgpuInstanceGetEncoderSessions + VgpuInstanceGetEncoderStats = libnvml.VgpuInstanceGetEncoderStats + VgpuInstanceGetFBCSessions = libnvml.VgpuInstanceGetFBCSessions + VgpuInstanceGetFBCStats = libnvml.VgpuInstanceGetFBCStats + VgpuInstanceGetFbUsage = libnvml.VgpuInstanceGetFbUsage + VgpuInstanceGetFrameRateLimit = libnvml.VgpuInstanceGetFrameRateLimit + VgpuInstanceGetGpuInstanceId = libnvml.VgpuInstanceGetGpuInstanceId + VgpuInstanceGetGpuPciId = libnvml.VgpuInstanceGetGpuPciId + VgpuInstanceGetLicenseInfo = libnvml.VgpuInstanceGetLicenseInfo + VgpuInstanceGetLicenseStatus = libnvml.VgpuInstanceGetLicenseStatus + VgpuInstanceGetMdevUUID = libnvml.VgpuInstanceGetMdevUUID + VgpuInstanceGetMetadata = libnvml.VgpuInstanceGetMetadata + VgpuInstanceGetType = libnvml.VgpuInstanceGetType + VgpuInstanceGetUUID = libnvml.VgpuInstanceGetUUID + VgpuInstanceGetVmDriverVersion = libnvml.VgpuInstanceGetVmDriverVersion + VgpuInstanceGetVmID = libnvml.VgpuInstanceGetVmID + VgpuInstanceSetEncoderCapacity = libnvml.VgpuInstanceSetEncoderCapacity + VgpuTypeGetCapabilities = libnvml.VgpuTypeGetCapabilities + VgpuTypeGetClass = libnvml.VgpuTypeGetClass + VgpuTypeGetDeviceID = libnvml.VgpuTypeGetDeviceID + VgpuTypeGetFrameRateLimit = libnvml.VgpuTypeGetFrameRateLimit + VgpuTypeGetFramebufferSize = libnvml.VgpuTypeGetFramebufferSize + VgpuTypeGetGpuInstanceProfileId = libnvml.VgpuTypeGetGpuInstanceProfileId + VgpuTypeGetLicense = libnvml.VgpuTypeGetLicense + VgpuTypeGetMaxInstances = libnvml.VgpuTypeGetMaxInstances + VgpuTypeGetMaxInstancesPerVm = libnvml.VgpuTypeGetMaxInstancesPerVm + VgpuTypeGetName = libnvml.VgpuTypeGetName + VgpuTypeGetNumDisplayHeads = libnvml.VgpuTypeGetNumDisplayHeads + VgpuTypeGetResolution = libnvml.VgpuTypeGetResolution +) + +// Interface represents the interface for the library type. +// +//go:generate moq -out mock/interface.go -pkg mock . Interface:Interface +type Interface interface { + ComputeInstanceDestroy(ComputeInstance) Return + ComputeInstanceGetInfo(ComputeInstance) (ComputeInstanceInfo, Return) + DeviceClearAccountingPids(Device) Return + DeviceClearCpuAffinity(Device) Return + DeviceClearEccErrorCounts(Device, EccCounterType) Return + DeviceClearFieldValues(Device, []FieldValue) Return + DeviceCreateGpuInstance(Device, *GpuInstanceProfileInfo) (GpuInstance, Return) + DeviceCreateGpuInstanceWithPlacement(Device, *GpuInstanceProfileInfo, *GpuInstancePlacement) (GpuInstance, Return) + DeviceDiscoverGpus() (PciInfo, Return) + DeviceFreezeNvLinkUtilizationCounter(Device, int, int, EnableState) Return + DeviceGetAPIRestriction(Device, RestrictedAPI) (EnableState, Return) + DeviceGetAccountingBufferSize(Device) (int, Return) + DeviceGetAccountingMode(Device) (EnableState, Return) + DeviceGetAccountingPids(Device) ([]int, Return) + DeviceGetAccountingStats(Device, uint32) (AccountingStats, Return) + DeviceGetActiveVgpus(Device) ([]VgpuInstance, Return) + DeviceGetAdaptiveClockInfoStatus(Device) (uint32, Return) + DeviceGetApplicationsClock(Device, ClockType) (uint32, Return) + DeviceGetArchitecture(Device) (DeviceArchitecture, Return) + DeviceGetAttributes(Device) (DeviceAttributes, Return) + DeviceGetAutoBoostedClocksEnabled(Device) (EnableState, EnableState, Return) + DeviceGetBAR1MemoryInfo(Device) (BAR1Memory, Return) + DeviceGetBoardId(Device) (uint32, Return) + DeviceGetBoardPartNumber(Device) (string, Return) + DeviceGetBrand(Device) (BrandType, Return) + DeviceGetBridgeChipInfo(Device) (BridgeChipHierarchy, Return) + DeviceGetBusType(Device) (BusType, Return) + DeviceGetC2cModeInfoV(Device) C2cModeInfoHandler + DeviceGetClkMonStatus(Device) (ClkMonStatus, Return) + DeviceGetClock(Device, ClockType, ClockId) (uint32, Return) + DeviceGetClockInfo(Device, ClockType) (uint32, Return) + DeviceGetComputeInstanceId(Device) (int, Return) + DeviceGetComputeMode(Device) (ComputeMode, Return) + DeviceGetComputeRunningProcesses(Device) ([]ProcessInfo, Return) + DeviceGetConfComputeGpuAttestationReport(Device) (ConfComputeGpuAttestationReport, Return) + DeviceGetConfComputeGpuCertificate(Device) (ConfComputeGpuCertificate, Return) + DeviceGetConfComputeMemSizeInfo(Device) (ConfComputeMemSizeInfo, Return) + DeviceGetConfComputeProtectedMemoryUsage(Device) (Memory, Return) + DeviceGetCount() (int, Return) + DeviceGetCpuAffinity(Device, int) ([]uint, Return) + DeviceGetCpuAffinityWithinScope(Device, int, AffinityScope) ([]uint, Return) + DeviceGetCreatableVgpus(Device) ([]VgpuTypeId, Return) + DeviceGetCudaComputeCapability(Device) (int, int, Return) + DeviceGetCurrPcieLinkGeneration(Device) (int, Return) + DeviceGetCurrPcieLinkWidth(Device) (int, Return) + DeviceGetCurrentClocksEventReasons(Device) (uint64, Return) + DeviceGetCurrentClocksThrottleReasons(Device) (uint64, Return) + DeviceGetDecoderUtilization(Device) (uint32, uint32, Return) + DeviceGetDefaultApplicationsClock(Device, ClockType) (uint32, Return) + DeviceGetDefaultEccMode(Device) (EnableState, Return) + DeviceGetDetailedEccErrors(Device, MemoryErrorType, EccCounterType) (EccErrorCounts, Return) + DeviceGetDeviceHandleFromMigDeviceHandle(Device) (Device, Return) + DeviceGetDisplayActive(Device) (EnableState, Return) + DeviceGetDisplayMode(Device) (EnableState, Return) + DeviceGetDriverModel(Device) (DriverModel, DriverModel, Return) + DeviceGetDynamicPstatesInfo(Device) (GpuDynamicPstatesInfo, Return) + DeviceGetEccMode(Device) (EnableState, EnableState, Return) + DeviceGetEncoderCapacity(Device, EncoderType) (int, Return) + DeviceGetEncoderSessions(Device) ([]EncoderSessionInfo, Return) + DeviceGetEncoderStats(Device) (int, uint32, uint32, Return) + DeviceGetEncoderUtilization(Device) (uint32, uint32, Return) + DeviceGetEnforcedPowerLimit(Device) (uint32, Return) + DeviceGetFBCSessions(Device) ([]FBCSessionInfo, Return) + DeviceGetFBCStats(Device) (FBCStats, Return) + DeviceGetFanControlPolicy_v2(Device, int) (FanControlPolicy, Return) + DeviceGetFanSpeed(Device) (uint32, Return) + DeviceGetFanSpeed_v2(Device, int) (uint32, Return) + DeviceGetFieldValues(Device, []FieldValue) Return + DeviceGetGpcClkMinMaxVfOffset(Device) (int, int, Return) + DeviceGetGpcClkVfOffset(Device) (int, Return) + DeviceGetGpuFabricInfo(Device) (GpuFabricInfo, Return) + DeviceGetGpuFabricInfoV(Device) GpuFabricInfoHandler + DeviceGetGpuInstanceById(Device, int) (GpuInstance, Return) + DeviceGetGpuInstanceId(Device) (int, Return) + DeviceGetGpuInstancePossiblePlacements(Device, *GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) + DeviceGetGpuInstanceProfileInfo(Device, int) (GpuInstanceProfileInfo, Return) + DeviceGetGpuInstanceProfileInfoV(Device, int) GpuInstanceProfileInfoHandler + DeviceGetGpuInstanceRemainingCapacity(Device, *GpuInstanceProfileInfo) (int, Return) + DeviceGetGpuInstances(Device, *GpuInstanceProfileInfo) ([]GpuInstance, Return) + DeviceGetGpuMaxPcieLinkGeneration(Device) (int, Return) + DeviceGetGpuOperationMode(Device) (GpuOperationMode, GpuOperationMode, Return) + DeviceGetGraphicsRunningProcesses(Device) ([]ProcessInfo, Return) + DeviceGetGridLicensableFeatures(Device) (GridLicensableFeatures, Return) + DeviceGetGspFirmwareMode(Device) (bool, bool, Return) + DeviceGetGspFirmwareVersion(Device) (string, Return) + DeviceGetHandleByIndex(int) (Device, Return) + DeviceGetHandleByPciBusId(string) (Device, Return) + DeviceGetHandleBySerial(string) (Device, Return) + DeviceGetHandleByUUID(string) (Device, Return) + DeviceGetHostVgpuMode(Device) (HostVgpuMode, Return) + DeviceGetIndex(Device) (int, Return) + DeviceGetInforomConfigurationChecksum(Device) (uint32, Return) + DeviceGetInforomImageVersion(Device) (string, Return) + DeviceGetInforomVersion(Device, InforomObject) (string, Return) + DeviceGetIrqNum(Device) (int, Return) + DeviceGetJpgUtilization(Device) (uint32, uint32, Return) + DeviceGetLastBBXFlushTime(Device) (uint64, uint, Return) + DeviceGetMPSComputeRunningProcesses(Device) ([]ProcessInfo, Return) + DeviceGetMaxClockInfo(Device, ClockType) (uint32, Return) + DeviceGetMaxCustomerBoostClock(Device, ClockType) (uint32, Return) + DeviceGetMaxMigDeviceCount(Device) (int, Return) + DeviceGetMaxPcieLinkGeneration(Device) (int, Return) + DeviceGetMaxPcieLinkWidth(Device) (int, Return) + DeviceGetMemClkMinMaxVfOffset(Device) (int, int, Return) + DeviceGetMemClkVfOffset(Device) (int, Return) + DeviceGetMemoryAffinity(Device, int, AffinityScope) ([]uint, Return) + DeviceGetMemoryBusWidth(Device) (uint32, Return) + DeviceGetMemoryErrorCounter(Device, MemoryErrorType, EccCounterType, MemoryLocation) (uint64, Return) + DeviceGetMemoryInfo(Device) (Memory, Return) + DeviceGetMemoryInfo_v2(Device) (Memory_v2, Return) + DeviceGetMigDeviceHandleByIndex(Device, int) (Device, Return) + DeviceGetMigMode(Device) (int, int, Return) + DeviceGetMinMaxClockOfPState(Device, ClockType, Pstates) (uint32, uint32, Return) + DeviceGetMinMaxFanSpeed(Device) (int, int, Return) + DeviceGetMinorNumber(Device) (int, Return) + DeviceGetModuleId(Device) (int, Return) + DeviceGetMultiGpuBoard(Device) (int, Return) + DeviceGetName(Device) (string, Return) + DeviceGetNumFans(Device) (int, Return) + DeviceGetNumGpuCores(Device) (int, Return) + DeviceGetNumaNodeId(Device) (int, Return) + DeviceGetNvLinkCapability(Device, int, NvLinkCapability) (uint32, Return) + DeviceGetNvLinkErrorCounter(Device, int, NvLinkErrorCounter) (uint64, Return) + DeviceGetNvLinkRemoteDeviceType(Device, int) (IntNvLinkDeviceType, Return) + DeviceGetNvLinkRemotePciInfo(Device, int) (PciInfo, Return) + DeviceGetNvLinkState(Device, int) (EnableState, Return) + DeviceGetNvLinkUtilizationControl(Device, int, int) (NvLinkUtilizationControl, Return) + DeviceGetNvLinkUtilizationCounter(Device, int, int) (uint64, uint64, Return) + DeviceGetNvLinkVersion(Device, int) (uint32, Return) + DeviceGetOfaUtilization(Device) (uint32, uint32, Return) + DeviceGetP2PStatus(Device, Device, GpuP2PCapsIndex) (GpuP2PStatus, Return) + DeviceGetPciInfo(Device) (PciInfo, Return) + DeviceGetPciInfoExt(Device) (PciInfoExt, Return) + DeviceGetPcieLinkMaxSpeed(Device) (uint32, Return) + DeviceGetPcieReplayCounter(Device) (int, Return) + DeviceGetPcieSpeed(Device) (int, Return) + DeviceGetPcieThroughput(Device, PcieUtilCounter) (uint32, Return) + DeviceGetPerformanceState(Device) (Pstates, Return) + DeviceGetPersistenceMode(Device) (EnableState, Return) + DeviceGetPgpuMetadataString(Device) (string, Return) + DeviceGetPowerManagementDefaultLimit(Device) (uint32, Return) + DeviceGetPowerManagementLimit(Device) (uint32, Return) + DeviceGetPowerManagementLimitConstraints(Device) (uint32, uint32, Return) + DeviceGetPowerManagementMode(Device) (EnableState, Return) + DeviceGetPowerSource(Device) (PowerSource, Return) + DeviceGetPowerState(Device) (Pstates, Return) + DeviceGetPowerUsage(Device) (uint32, Return) + DeviceGetProcessUtilization(Device, uint64) ([]ProcessUtilizationSample, Return) + DeviceGetProcessesUtilizationInfo(Device) (ProcessesUtilizationInfo, Return) + DeviceGetRemappedRows(Device) (int, int, bool, bool, Return) + DeviceGetRetiredPages(Device, PageRetirementCause) ([]uint64, Return) + DeviceGetRetiredPagesPendingStatus(Device) (EnableState, Return) + DeviceGetRetiredPages_v2(Device, PageRetirementCause) ([]uint64, []uint64, Return) + DeviceGetRowRemapperHistogram(Device) (RowRemapperHistogramValues, Return) + DeviceGetRunningProcessDetailList(Device) (ProcessDetailList, Return) + DeviceGetSamples(Device, SamplingType, uint64) (ValueType, []Sample, Return) + DeviceGetSerial(Device) (string, Return) + DeviceGetSramEccErrorStatus(Device) (EccSramErrorStatus, Return) + DeviceGetSupportedClocksEventReasons(Device) (uint64, Return) + DeviceGetSupportedClocksThrottleReasons(Device) (uint64, Return) + DeviceGetSupportedEventTypes(Device) (uint64, Return) + DeviceGetSupportedGraphicsClocks(Device, int) (int, uint32, Return) + DeviceGetSupportedMemoryClocks(Device) (int, uint32, Return) + DeviceGetSupportedPerformanceStates(Device) ([]Pstates, Return) + DeviceGetSupportedVgpus(Device) ([]VgpuTypeId, Return) + DeviceGetTargetFanSpeed(Device, int) (int, Return) + DeviceGetTemperature(Device, TemperatureSensors) (uint32, Return) + DeviceGetTemperatureThreshold(Device, TemperatureThresholds) (uint32, Return) + DeviceGetThermalSettings(Device, uint32) (GpuThermalSettings, Return) + DeviceGetTopologyCommonAncestor(Device, Device) (GpuTopologyLevel, Return) + DeviceGetTopologyNearestGpus(Device, GpuTopologyLevel) ([]Device, Return) + DeviceGetTotalEccErrors(Device, MemoryErrorType, EccCounterType) (uint64, Return) + DeviceGetTotalEnergyConsumption(Device) (uint64, Return) + DeviceGetUUID(Device) (string, Return) + DeviceGetUtilizationRates(Device) (Utilization, Return) + DeviceGetVbiosVersion(Device) (string, Return) + DeviceGetVgpuCapabilities(Device, DeviceVgpuCapability) (bool, Return) + DeviceGetVgpuHeterogeneousMode(Device) (VgpuHeterogeneousMode, Return) + DeviceGetVgpuInstancesUtilizationInfo(Device) (VgpuInstancesUtilizationInfo, Return) + DeviceGetVgpuMetadata(Device) (VgpuPgpuMetadata, Return) + DeviceGetVgpuProcessUtilization(Device, uint64) ([]VgpuProcessUtilizationSample, Return) + DeviceGetVgpuProcessesUtilizationInfo(Device) (VgpuProcessesUtilizationInfo, Return) + DeviceGetVgpuSchedulerCapabilities(Device) (VgpuSchedulerCapabilities, Return) + DeviceGetVgpuSchedulerLog(Device) (VgpuSchedulerLog, Return) + DeviceGetVgpuSchedulerState(Device) (VgpuSchedulerGetState, Return) + DeviceGetVgpuTypeCreatablePlacements(Device, VgpuTypeId) (VgpuPlacementList, Return) + DeviceGetVgpuTypeSupportedPlacements(Device, VgpuTypeId) (VgpuPlacementList, Return) + DeviceGetVgpuUtilization(Device, uint64) (ValueType, []VgpuInstanceUtilizationSample, Return) + DeviceGetViolationStatus(Device, PerfPolicyType) (ViolationTime, Return) + DeviceGetVirtualizationMode(Device) (GpuVirtualizationMode, Return) + DeviceIsMigDeviceHandle(Device) (bool, Return) + DeviceModifyDrainState(*PciInfo, EnableState) Return + DeviceOnSameBoard(Device, Device) (int, Return) + DeviceQueryDrainState(*PciInfo) (EnableState, Return) + DeviceRegisterEvents(Device, uint64, EventSet) Return + DeviceRemoveGpu(*PciInfo) Return + DeviceRemoveGpu_v2(*PciInfo, DetachGpuState, PcieLinkState) Return + DeviceResetApplicationsClocks(Device) Return + DeviceResetGpuLockedClocks(Device) Return + DeviceResetMemoryLockedClocks(Device) Return + DeviceResetNvLinkErrorCounters(Device, int) Return + DeviceResetNvLinkUtilizationCounter(Device, int, int) Return + DeviceSetAPIRestriction(Device, RestrictedAPI, EnableState) Return + DeviceSetAccountingMode(Device, EnableState) Return + DeviceSetApplicationsClocks(Device, uint32, uint32) Return + DeviceSetAutoBoostedClocksEnabled(Device, EnableState) Return + DeviceSetComputeMode(Device, ComputeMode) Return + DeviceSetConfComputeUnprotectedMemSize(Device, uint64) Return + DeviceSetCpuAffinity(Device) Return + DeviceSetDefaultAutoBoostedClocksEnabled(Device, EnableState, uint32) Return + DeviceSetDefaultFanSpeed_v2(Device, int) Return + DeviceSetDriverModel(Device, DriverModel, uint32) Return + DeviceSetEccMode(Device, EnableState) Return + DeviceSetFanControlPolicy(Device, int, FanControlPolicy) Return + DeviceSetFanSpeed_v2(Device, int, int) Return + DeviceSetGpcClkVfOffset(Device, int) Return + DeviceSetGpuLockedClocks(Device, uint32, uint32) Return + DeviceSetGpuOperationMode(Device, GpuOperationMode) Return + DeviceSetMemClkVfOffset(Device, int) Return + DeviceSetMemoryLockedClocks(Device, uint32, uint32) Return + DeviceSetMigMode(Device, int) (Return, Return) + DeviceSetNvLinkDeviceLowPowerThreshold(Device, *NvLinkPowerThres) Return + DeviceSetNvLinkUtilizationControl(Device, int, int, *NvLinkUtilizationControl, bool) Return + DeviceSetPersistenceMode(Device, EnableState) Return + DeviceSetPowerManagementLimit(Device, uint32) Return + DeviceSetPowerManagementLimit_v2(Device, *PowerValue_v2) Return + DeviceSetTemperatureThreshold(Device, TemperatureThresholds, int) Return + DeviceSetVgpuCapabilities(Device, DeviceVgpuCapability, EnableState) Return + DeviceSetVgpuHeterogeneousMode(Device, VgpuHeterogeneousMode) Return + DeviceSetVgpuSchedulerState(Device, *VgpuSchedulerSetState) Return + DeviceSetVirtualizationMode(Device, GpuVirtualizationMode) Return + DeviceValidateInforom(Device) Return + ErrorString(Return) string + EventSetCreate() (EventSet, Return) + EventSetFree(EventSet) Return + EventSetWait(EventSet, uint32) (EventData, Return) + Extensions() ExtendedInterface + GetExcludedDeviceCount() (int, Return) + GetExcludedDeviceInfoByIndex(int) (ExcludedDeviceInfo, Return) + GetVgpuCompatibility(*VgpuMetadata, *VgpuPgpuMetadata) (VgpuPgpuCompatibility, Return) + GetVgpuDriverCapabilities(VgpuDriverCapability) (bool, Return) + GetVgpuVersion() (VgpuVersion, VgpuVersion, Return) + GpmMetricsGet(*GpmMetricsGetType) Return + GpmMetricsGetV(*GpmMetricsGetType) GpmMetricsGetVType + GpmMigSampleGet(Device, int, GpmSample) Return + GpmQueryDeviceSupport(Device) (GpmSupport, Return) + GpmQueryDeviceSupportV(Device) GpmSupportV + GpmQueryIfStreamingEnabled(Device) (uint32, Return) + GpmSampleAlloc() (GpmSample, Return) + GpmSampleFree(GpmSample) Return + GpmSampleGet(Device, GpmSample) Return + GpmSetStreamingEnabled(Device, uint32) Return + GpuInstanceCreateComputeInstance(GpuInstance, *ComputeInstanceProfileInfo) (ComputeInstance, Return) + GpuInstanceCreateComputeInstanceWithPlacement(GpuInstance, *ComputeInstanceProfileInfo, *ComputeInstancePlacement) (ComputeInstance, Return) + GpuInstanceDestroy(GpuInstance) Return + GpuInstanceGetComputeInstanceById(GpuInstance, int) (ComputeInstance, Return) + GpuInstanceGetComputeInstancePossiblePlacements(GpuInstance, *ComputeInstanceProfileInfo) ([]ComputeInstancePlacement, Return) + GpuInstanceGetComputeInstanceProfileInfo(GpuInstance, int, int) (ComputeInstanceProfileInfo, Return) + GpuInstanceGetComputeInstanceProfileInfoV(GpuInstance, int, int) ComputeInstanceProfileInfoHandler + GpuInstanceGetComputeInstanceRemainingCapacity(GpuInstance, *ComputeInstanceProfileInfo) (int, Return) + GpuInstanceGetComputeInstances(GpuInstance, *ComputeInstanceProfileInfo) ([]ComputeInstance, Return) + GpuInstanceGetInfo(GpuInstance) (GpuInstanceInfo, Return) + Init() Return + InitWithFlags(uint32) Return + SetVgpuVersion(*VgpuVersion) Return + Shutdown() Return + SystemGetConfComputeCapabilities() (ConfComputeSystemCaps, Return) + SystemGetConfComputeKeyRotationThresholdInfo() (ConfComputeGetKeyRotationThresholdInfo, Return) + SystemGetConfComputeSettings() (SystemConfComputeSettings, Return) + SystemGetCudaDriverVersion() (int, Return) + SystemGetCudaDriverVersion_v2() (int, Return) + SystemGetDriverVersion() (string, Return) + SystemGetHicVersion() ([]HwbcEntry, Return) + SystemGetNVMLVersion() (string, Return) + SystemGetProcessName(int) (string, Return) + SystemGetTopologyGpuSet(int) ([]Device, Return) + SystemSetConfComputeKeyRotationThresholdInfo(ConfComputeSetKeyRotationThresholdInfo) Return + UnitGetCount() (int, Return) + UnitGetDevices(Unit) ([]Device, Return) + UnitGetFanSpeedInfo(Unit) (UnitFanSpeeds, Return) + UnitGetHandleByIndex(int) (Unit, Return) + UnitGetLedState(Unit) (LedState, Return) + UnitGetPsuInfo(Unit) (PSUInfo, Return) + UnitGetTemperature(Unit, int) (uint32, Return) + UnitGetUnitInfo(Unit) (UnitInfo, Return) + UnitSetLedState(Unit, LedColor) Return + VgpuInstanceClearAccountingPids(VgpuInstance) Return + VgpuInstanceGetAccountingMode(VgpuInstance) (EnableState, Return) + VgpuInstanceGetAccountingPids(VgpuInstance) ([]int, Return) + VgpuInstanceGetAccountingStats(VgpuInstance, int) (AccountingStats, Return) + VgpuInstanceGetEccMode(VgpuInstance) (EnableState, Return) + VgpuInstanceGetEncoderCapacity(VgpuInstance) (int, Return) + VgpuInstanceGetEncoderSessions(VgpuInstance) (int, EncoderSessionInfo, Return) + VgpuInstanceGetEncoderStats(VgpuInstance) (int, uint32, uint32, Return) + VgpuInstanceGetFBCSessions(VgpuInstance) (int, FBCSessionInfo, Return) + VgpuInstanceGetFBCStats(VgpuInstance) (FBCStats, Return) + VgpuInstanceGetFbUsage(VgpuInstance) (uint64, Return) + VgpuInstanceGetFrameRateLimit(VgpuInstance) (uint32, Return) + VgpuInstanceGetGpuInstanceId(VgpuInstance) (int, Return) + VgpuInstanceGetGpuPciId(VgpuInstance) (string, Return) + VgpuInstanceGetLicenseInfo(VgpuInstance) (VgpuLicenseInfo, Return) + VgpuInstanceGetLicenseStatus(VgpuInstance) (int, Return) + VgpuInstanceGetMdevUUID(VgpuInstance) (string, Return) + VgpuInstanceGetMetadata(VgpuInstance) (VgpuMetadata, Return) + VgpuInstanceGetType(VgpuInstance) (VgpuTypeId, Return) + VgpuInstanceGetUUID(VgpuInstance) (string, Return) + VgpuInstanceGetVmDriverVersion(VgpuInstance) (string, Return) + VgpuInstanceGetVmID(VgpuInstance) (string, VgpuVmIdType, Return) + VgpuInstanceSetEncoderCapacity(VgpuInstance, int) Return + VgpuTypeGetCapabilities(VgpuTypeId, VgpuCapability) (bool, Return) + VgpuTypeGetClass(VgpuTypeId) (string, Return) + VgpuTypeGetDeviceID(VgpuTypeId) (uint64, uint64, Return) + VgpuTypeGetFrameRateLimit(VgpuTypeId) (uint32, Return) + VgpuTypeGetFramebufferSize(VgpuTypeId) (uint64, Return) + VgpuTypeGetGpuInstanceProfileId(VgpuTypeId) (uint32, Return) + VgpuTypeGetLicense(VgpuTypeId) (string, Return) + VgpuTypeGetMaxInstances(Device, VgpuTypeId) (int, Return) + VgpuTypeGetMaxInstancesPerVm(VgpuTypeId) (int, Return) + VgpuTypeGetName(VgpuTypeId) (string, Return) + VgpuTypeGetNumDisplayHeads(VgpuTypeId) (int, Return) + VgpuTypeGetResolution(VgpuTypeId, int) (uint32, uint32, Return) +} + +// Device represents the interface for the nvmlDevice type. +// +//go:generate moq -out mock/device.go -pkg mock . Device:Device +type Device interface { + ClearAccountingPids() Return + ClearCpuAffinity() Return + ClearEccErrorCounts(EccCounterType) Return + ClearFieldValues([]FieldValue) Return + CreateGpuInstance(*GpuInstanceProfileInfo) (GpuInstance, Return) + CreateGpuInstanceWithPlacement(*GpuInstanceProfileInfo, *GpuInstancePlacement) (GpuInstance, Return) + FreezeNvLinkUtilizationCounter(int, int, EnableState) Return + GetAPIRestriction(RestrictedAPI) (EnableState, Return) + GetAccountingBufferSize() (int, Return) + GetAccountingMode() (EnableState, Return) + GetAccountingPids() ([]int, Return) + GetAccountingStats(uint32) (AccountingStats, Return) + GetActiveVgpus() ([]VgpuInstance, Return) + GetAdaptiveClockInfoStatus() (uint32, Return) + GetApplicationsClock(ClockType) (uint32, Return) + GetArchitecture() (DeviceArchitecture, Return) + GetAttributes() (DeviceAttributes, Return) + GetAutoBoostedClocksEnabled() (EnableState, EnableState, Return) + GetBAR1MemoryInfo() (BAR1Memory, Return) + GetBoardId() (uint32, Return) + GetBoardPartNumber() (string, Return) + GetBrand() (BrandType, Return) + GetBridgeChipInfo() (BridgeChipHierarchy, Return) + GetBusType() (BusType, Return) + GetC2cModeInfoV() C2cModeInfoHandler + GetClkMonStatus() (ClkMonStatus, Return) + GetClock(ClockType, ClockId) (uint32, Return) + GetClockInfo(ClockType) (uint32, Return) + GetComputeInstanceId() (int, Return) + GetComputeMode() (ComputeMode, Return) + GetComputeRunningProcesses() ([]ProcessInfo, Return) + GetConfComputeGpuAttestationReport() (ConfComputeGpuAttestationReport, Return) + GetConfComputeGpuCertificate() (ConfComputeGpuCertificate, Return) + GetConfComputeMemSizeInfo() (ConfComputeMemSizeInfo, Return) + GetConfComputeProtectedMemoryUsage() (Memory, Return) + GetCpuAffinity(int) ([]uint, Return) + GetCpuAffinityWithinScope(int, AffinityScope) ([]uint, Return) + GetCreatableVgpus() ([]VgpuTypeId, Return) + GetCudaComputeCapability() (int, int, Return) + GetCurrPcieLinkGeneration() (int, Return) + GetCurrPcieLinkWidth() (int, Return) + GetCurrentClocksEventReasons() (uint64, Return) + GetCurrentClocksThrottleReasons() (uint64, Return) + GetDecoderUtilization() (uint32, uint32, Return) + GetDefaultApplicationsClock(ClockType) (uint32, Return) + GetDefaultEccMode() (EnableState, Return) + GetDetailedEccErrors(MemoryErrorType, EccCounterType) (EccErrorCounts, Return) + GetDeviceHandleFromMigDeviceHandle() (Device, Return) + GetDisplayActive() (EnableState, Return) + GetDisplayMode() (EnableState, Return) + GetDriverModel() (DriverModel, DriverModel, Return) + GetDynamicPstatesInfo() (GpuDynamicPstatesInfo, Return) + GetEccMode() (EnableState, EnableState, Return) + GetEncoderCapacity(EncoderType) (int, Return) + GetEncoderSessions() ([]EncoderSessionInfo, Return) + GetEncoderStats() (int, uint32, uint32, Return) + GetEncoderUtilization() (uint32, uint32, Return) + GetEnforcedPowerLimit() (uint32, Return) + GetFBCSessions() ([]FBCSessionInfo, Return) + GetFBCStats() (FBCStats, Return) + GetFanControlPolicy_v2(int) (FanControlPolicy, Return) + GetFanSpeed() (uint32, Return) + GetFanSpeed_v2(int) (uint32, Return) + GetFieldValues([]FieldValue) Return + GetGpcClkMinMaxVfOffset() (int, int, Return) + GetGpcClkVfOffset() (int, Return) + GetGpuFabricInfo() (GpuFabricInfo, Return) + GetGpuFabricInfoV() GpuFabricInfoHandler + GetGpuInstanceById(int) (GpuInstance, Return) + GetGpuInstanceId() (int, Return) + GetGpuInstancePossiblePlacements(*GpuInstanceProfileInfo) ([]GpuInstancePlacement, Return) + GetGpuInstanceProfileInfo(int) (GpuInstanceProfileInfo, Return) + GetGpuInstanceProfileInfoV(int) GpuInstanceProfileInfoHandler + GetGpuInstanceRemainingCapacity(*GpuInstanceProfileInfo) (int, Return) + GetGpuInstances(*GpuInstanceProfileInfo) ([]GpuInstance, Return) + GetGpuMaxPcieLinkGeneration() (int, Return) + GetGpuOperationMode() (GpuOperationMode, GpuOperationMode, Return) + GetGraphicsRunningProcesses() ([]ProcessInfo, Return) + GetGridLicensableFeatures() (GridLicensableFeatures, Return) + GetGspFirmwareMode() (bool, bool, Return) + GetGspFirmwareVersion() (string, Return) + GetHostVgpuMode() (HostVgpuMode, Return) + GetIndex() (int, Return) + GetInforomConfigurationChecksum() (uint32, Return) + GetInforomImageVersion() (string, Return) + GetInforomVersion(InforomObject) (string, Return) + GetIrqNum() (int, Return) + GetJpgUtilization() (uint32, uint32, Return) + GetLastBBXFlushTime() (uint64, uint, Return) + GetMPSComputeRunningProcesses() ([]ProcessInfo, Return) + GetMaxClockInfo(ClockType) (uint32, Return) + GetMaxCustomerBoostClock(ClockType) (uint32, Return) + GetMaxMigDeviceCount() (int, Return) + GetMaxPcieLinkGeneration() (int, Return) + GetMaxPcieLinkWidth() (int, Return) + GetMemClkMinMaxVfOffset() (int, int, Return) + GetMemClkVfOffset() (int, Return) + GetMemoryAffinity(int, AffinityScope) ([]uint, Return) + GetMemoryBusWidth() (uint32, Return) + GetMemoryErrorCounter(MemoryErrorType, EccCounterType, MemoryLocation) (uint64, Return) + GetMemoryInfo() (Memory, Return) + GetMemoryInfo_v2() (Memory_v2, Return) + GetMigDeviceHandleByIndex(int) (Device, Return) + GetMigMode() (int, int, Return) + GetMinMaxClockOfPState(ClockType, Pstates) (uint32, uint32, Return) + GetMinMaxFanSpeed() (int, int, Return) + GetMinorNumber() (int, Return) + GetModuleId() (int, Return) + GetMultiGpuBoard() (int, Return) + GetName() (string, Return) + GetNumFans() (int, Return) + GetNumGpuCores() (int, Return) + GetNumaNodeId() (int, Return) + GetNvLinkCapability(int, NvLinkCapability) (uint32, Return) + GetNvLinkErrorCounter(int, NvLinkErrorCounter) (uint64, Return) + GetNvLinkRemoteDeviceType(int) (IntNvLinkDeviceType, Return) + GetNvLinkRemotePciInfo(int) (PciInfo, Return) + GetNvLinkState(int) (EnableState, Return) + GetNvLinkUtilizationControl(int, int) (NvLinkUtilizationControl, Return) + GetNvLinkUtilizationCounter(int, int) (uint64, uint64, Return) + GetNvLinkVersion(int) (uint32, Return) + GetOfaUtilization() (uint32, uint32, Return) + GetP2PStatus(Device, GpuP2PCapsIndex) (GpuP2PStatus, Return) + GetPciInfo() (PciInfo, Return) + GetPciInfoExt() (PciInfoExt, Return) + GetPcieLinkMaxSpeed() (uint32, Return) + GetPcieReplayCounter() (int, Return) + GetPcieSpeed() (int, Return) + GetPcieThroughput(PcieUtilCounter) (uint32, Return) + GetPerformanceState() (Pstates, Return) + GetPersistenceMode() (EnableState, Return) + GetPgpuMetadataString() (string, Return) + GetPowerManagementDefaultLimit() (uint32, Return) + GetPowerManagementLimit() (uint32, Return) + GetPowerManagementLimitConstraints() (uint32, uint32, Return) + GetPowerManagementMode() (EnableState, Return) + GetPowerSource() (PowerSource, Return) + GetPowerState() (Pstates, Return) + GetPowerUsage() (uint32, Return) + GetProcessUtilization(uint64) ([]ProcessUtilizationSample, Return) + GetProcessesUtilizationInfo() (ProcessesUtilizationInfo, Return) + GetRemappedRows() (int, int, bool, bool, Return) + GetRetiredPages(PageRetirementCause) ([]uint64, Return) + GetRetiredPagesPendingStatus() (EnableState, Return) + GetRetiredPages_v2(PageRetirementCause) ([]uint64, []uint64, Return) + GetRowRemapperHistogram() (RowRemapperHistogramValues, Return) + GetRunningProcessDetailList() (ProcessDetailList, Return) + GetSamples(SamplingType, uint64) (ValueType, []Sample, Return) + GetSerial() (string, Return) + GetSramEccErrorStatus() (EccSramErrorStatus, Return) + GetSupportedClocksEventReasons() (uint64, Return) + GetSupportedClocksThrottleReasons() (uint64, Return) + GetSupportedEventTypes() (uint64, Return) + GetSupportedGraphicsClocks(int) (int, uint32, Return) + GetSupportedMemoryClocks() (int, uint32, Return) + GetSupportedPerformanceStates() ([]Pstates, Return) + GetSupportedVgpus() ([]VgpuTypeId, Return) + GetTargetFanSpeed(int) (int, Return) + GetTemperature(TemperatureSensors) (uint32, Return) + GetTemperatureThreshold(TemperatureThresholds) (uint32, Return) + GetThermalSettings(uint32) (GpuThermalSettings, Return) + GetTopologyCommonAncestor(Device) (GpuTopologyLevel, Return) + GetTopologyNearestGpus(GpuTopologyLevel) ([]Device, Return) + GetTotalEccErrors(MemoryErrorType, EccCounterType) (uint64, Return) + GetTotalEnergyConsumption() (uint64, Return) + GetUUID() (string, Return) + GetUtilizationRates() (Utilization, Return) + GetVbiosVersion() (string, Return) + GetVgpuCapabilities(DeviceVgpuCapability) (bool, Return) + GetVgpuHeterogeneousMode() (VgpuHeterogeneousMode, Return) + GetVgpuInstancesUtilizationInfo() (VgpuInstancesUtilizationInfo, Return) + GetVgpuMetadata() (VgpuPgpuMetadata, Return) + GetVgpuProcessUtilization(uint64) ([]VgpuProcessUtilizationSample, Return) + GetVgpuProcessesUtilizationInfo() (VgpuProcessesUtilizationInfo, Return) + GetVgpuSchedulerCapabilities() (VgpuSchedulerCapabilities, Return) + GetVgpuSchedulerLog() (VgpuSchedulerLog, Return) + GetVgpuSchedulerState() (VgpuSchedulerGetState, Return) + GetVgpuTypeCreatablePlacements(VgpuTypeId) (VgpuPlacementList, Return) + GetVgpuTypeSupportedPlacements(VgpuTypeId) (VgpuPlacementList, Return) + GetVgpuUtilization(uint64) (ValueType, []VgpuInstanceUtilizationSample, Return) + GetViolationStatus(PerfPolicyType) (ViolationTime, Return) + GetVirtualizationMode() (GpuVirtualizationMode, Return) + GpmMigSampleGet(int, GpmSample) Return + GpmQueryDeviceSupport() (GpmSupport, Return) + GpmQueryDeviceSupportV() GpmSupportV + GpmQueryIfStreamingEnabled() (uint32, Return) + GpmSampleGet(GpmSample) Return + GpmSetStreamingEnabled(uint32) Return + IsMigDeviceHandle() (bool, Return) + OnSameBoard(Device) (int, Return) + RegisterEvents(uint64, EventSet) Return + ResetApplicationsClocks() Return + ResetGpuLockedClocks() Return + ResetMemoryLockedClocks() Return + ResetNvLinkErrorCounters(int) Return + ResetNvLinkUtilizationCounter(int, int) Return + SetAPIRestriction(RestrictedAPI, EnableState) Return + SetAccountingMode(EnableState) Return + SetApplicationsClocks(uint32, uint32) Return + SetAutoBoostedClocksEnabled(EnableState) Return + SetComputeMode(ComputeMode) Return + SetConfComputeUnprotectedMemSize(uint64) Return + SetCpuAffinity() Return + SetDefaultAutoBoostedClocksEnabled(EnableState, uint32) Return + SetDefaultFanSpeed_v2(int) Return + SetDriverModel(DriverModel, uint32) Return + SetEccMode(EnableState) Return + SetFanControlPolicy(int, FanControlPolicy) Return + SetFanSpeed_v2(int, int) Return + SetGpcClkVfOffset(int) Return + SetGpuLockedClocks(uint32, uint32) Return + SetGpuOperationMode(GpuOperationMode) Return + SetMemClkVfOffset(int) Return + SetMemoryLockedClocks(uint32, uint32) Return + SetMigMode(int) (Return, Return) + SetNvLinkDeviceLowPowerThreshold(*NvLinkPowerThres) Return + SetNvLinkUtilizationControl(int, int, *NvLinkUtilizationControl, bool) Return + SetPersistenceMode(EnableState) Return + SetPowerManagementLimit(uint32) Return + SetPowerManagementLimit_v2(*PowerValue_v2) Return + SetTemperatureThreshold(TemperatureThresholds, int) Return + SetVgpuCapabilities(DeviceVgpuCapability, EnableState) Return + SetVgpuHeterogeneousMode(VgpuHeterogeneousMode) Return + SetVgpuSchedulerState(*VgpuSchedulerSetState) Return + SetVirtualizationMode(GpuVirtualizationMode) Return + ValidateInforom() Return + VgpuTypeGetMaxInstances(VgpuTypeId) (int, Return) +} + +// GpuInstance represents the interface for the nvmlGpuInstance type. +// +//go:generate moq -out mock/gpuinstance.go -pkg mock . GpuInstance:GpuInstance +type GpuInstance interface { + CreateComputeInstance(*ComputeInstanceProfileInfo) (ComputeInstance, Return) + CreateComputeInstanceWithPlacement(*ComputeInstanceProfileInfo, *ComputeInstancePlacement) (ComputeInstance, Return) + Destroy() Return + GetComputeInstanceById(int) (ComputeInstance, Return) + GetComputeInstancePossiblePlacements(*ComputeInstanceProfileInfo) ([]ComputeInstancePlacement, Return) + GetComputeInstanceProfileInfo(int, int) (ComputeInstanceProfileInfo, Return) + GetComputeInstanceProfileInfoV(int, int) ComputeInstanceProfileInfoHandler + GetComputeInstanceRemainingCapacity(*ComputeInstanceProfileInfo) (int, Return) + GetComputeInstances(*ComputeInstanceProfileInfo) ([]ComputeInstance, Return) + GetInfo() (GpuInstanceInfo, Return) +} + +// ComputeInstance represents the interface for the nvmlComputeInstance type. +// +//go:generate moq -out mock/computeinstance.go -pkg mock . ComputeInstance:ComputeInstance +type ComputeInstance interface { + Destroy() Return + GetInfo() (ComputeInstanceInfo, Return) +} + +// EventSet represents the interface for the nvmlEventSet type. +// +//go:generate moq -out mock/eventset.go -pkg mock . EventSet:EventSet +type EventSet interface { + Free() Return + Wait(uint32) (EventData, Return) +} + +// GpmSample represents the interface for the nvmlGpmSample type. +// +//go:generate moq -out mock/gpmsample.go -pkg mock . GpmSample:GpmSample +type GpmSample interface { + Free() Return + Get(Device) Return + MigGet(Device, int) Return +} + +// Unit represents the interface for the nvmlUnit type. +// +//go:generate moq -out mock/unit.go -pkg mock . Unit:Unit +type Unit interface { + GetDevices() ([]Device, Return) + GetFanSpeedInfo() (UnitFanSpeeds, Return) + GetLedState() (LedState, Return) + GetPsuInfo() (PSUInfo, Return) + GetTemperature(int) (uint32, Return) + GetUnitInfo() (UnitInfo, Return) + SetLedState(LedColor) Return +} + +// VgpuInstance represents the interface for the nvmlVgpuInstance type. +// +//go:generate moq -out mock/vgpuinstance.go -pkg mock . VgpuInstance:VgpuInstance +type VgpuInstance interface { + ClearAccountingPids() Return + GetAccountingMode() (EnableState, Return) + GetAccountingPids() ([]int, Return) + GetAccountingStats(int) (AccountingStats, Return) + GetEccMode() (EnableState, Return) + GetEncoderCapacity() (int, Return) + GetEncoderSessions() (int, EncoderSessionInfo, Return) + GetEncoderStats() (int, uint32, uint32, Return) + GetFBCSessions() (int, FBCSessionInfo, Return) + GetFBCStats() (FBCStats, Return) + GetFbUsage() (uint64, Return) + GetFrameRateLimit() (uint32, Return) + GetGpuInstanceId() (int, Return) + GetGpuPciId() (string, Return) + GetLicenseInfo() (VgpuLicenseInfo, Return) + GetLicenseStatus() (int, Return) + GetMdevUUID() (string, Return) + GetMetadata() (VgpuMetadata, Return) + GetType() (VgpuTypeId, Return) + GetUUID() (string, Return) + GetVmDriverVersion() (string, Return) + GetVmID() (string, VgpuVmIdType, Return) + SetEncoderCapacity(int) Return +} + +// VgpuTypeId represents the interface for the nvmlVgpuTypeId type. +// +//go:generate moq -out mock/vgputypeid.go -pkg mock . VgpuTypeId:VgpuTypeId +type VgpuTypeId interface { + GetCapabilities(VgpuCapability) (bool, Return) + GetClass() (string, Return) + GetCreatablePlacements(Device) (VgpuPlacementList, Return) + GetDeviceID() (uint64, uint64, Return) + GetFrameRateLimit() (uint32, Return) + GetFramebufferSize() (uint64, Return) + GetGpuInstanceProfileId() (uint32, Return) + GetLicense() (string, Return) + GetMaxInstances(Device) (int, Return) + GetMaxInstancesPerVm() (int, Return) + GetName() (string, Return) + GetNumDisplayHeads() (int, Return) + GetResolution(int) (uint32, uint32, Return) + GetSupportedPlacements(Device) (VgpuPlacementList, Return) +} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/graphics.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/graphics.go index 35b51982..b5c248d4 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/graphics.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/graphics.go @@ -36,70 +36,237 @@ import ( // TODO: The logic for creating DRM devices should be consolidated between this // and the logic for generating CDI specs for a single device. This is only used // when applying OCI spec modifications to an incoming spec in "legacy" mode. -func NewDRMNodesDiscoverer(logger logger.Interface, devices image.VisibleDevices, devRoot string, nvidiaCTKPath string) (Discover, error) { +func NewDRMNodesDiscoverer(logger logger.Interface, devices image.VisibleDevices, devRoot string, nvidiaCDIHookPath string) (Discover, error) { drmDeviceNodes, err := newDRMDeviceDiscoverer(logger, devices, devRoot) if err != nil { return nil, fmt.Errorf("failed to create DRM device discoverer: %v", err) } - drmByPathSymlinks := newCreateDRMByPathSymlinks(logger, drmDeviceNodes, devRoot, nvidiaCTKPath) + drmByPathSymlinks := newCreateDRMByPathSymlinks(logger, drmDeviceNodes, devRoot, nvidiaCDIHookPath) discover := Merge(drmDeviceNodes, drmByPathSymlinks) return discover, nil } // NewGraphicsMountsDiscoverer creates a discoverer for the mounts required by graphics tools such as vulkan. -func NewGraphicsMountsDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCTKPath string) (Discover, error) { - libraries := NewMounts( - logger, - driver.Libraries(), - driver.Root, - []string{ - "libnvidia-egl-gbm.so.*", - }, - ) +func NewGraphicsMountsDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCDIHookPath string) (Discover, error) { + libraries := newGraphicsLibrariesDiscoverer(logger, driver, nvidiaCDIHookPath) - jsonMounts := NewMounts( + configs := NewMounts( logger, driver.Configs(), driver.Root, []string{ "glvnd/egl_vendor.d/10_nvidia.json", - "vulkan/icd.d/nvidia_icd.json", - "vulkan/icd.d/nvidia_layers.json", - "vulkan/implicit_layer.d/nvidia_layers.json", "egl/egl_external_platform.d/15_nvidia_gbm.json", "egl/egl_external_platform.d/10_nvidia_wayland.json", "nvidia/nvoptix.bin", + "X11/xorg.conf.d/10-nvidia.conf", + "X11/xorg.conf.d/nvidia-drm-outputclass.conf", }, ) - xorg := optionalXorgDiscoverer(logger, driver, nvidiaCTKPath) - discover := Merge( libraries, - jsonMounts, - xorg, + configs, + newVulkanConfigsDiscover(logger, driver), ) return discover, nil } +// newVulkanConfigsDiscover creates a discoverer for vulkan ICD files. +// For these files we search the standard driver config paths as well as the +// driver root itself. This allows us to support GKE installations where the +// vulkan ICD files are at {{ .driverRoot }}/vulkan instead of in /etc/vulkan. +func newVulkanConfigsDiscover(logger logger.Interface, driver *root.Driver) Discover { + locator := lookup.First(driver.Configs(), driver.Files()) + return &mountsToContainerPath{ + logger: logger, + locator: locator, + required: []string{ + "vulkan/icd.d/nvidia_icd.json", + "vulkan/icd.d/nvidia_layers.json", + "vulkan/implicit_layer.d/nvidia_layers.json", + }, + containerRoot: "/etc", + } +} + +type graphicsDriverLibraries struct { + Discover + logger logger.Interface + nvidiaCDIHookPath string +} + +var _ Discover = (*graphicsDriverLibraries)(nil) + +func newGraphicsLibrariesDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCDIHookPath string) Discover { + cudaLibRoot, cudaVersionPattern := getCUDALibRootAndVersionPattern(logger, driver) + + libraries := NewMounts( + logger, + driver.Libraries(), + driver.Root, + []string{ + // The libnvidia-egl-gbm and libnvidia-egl-wayland libraries do not + // have the RM version. Use the *.* pattern to match X.Y.Z versions. + "libnvidia-egl-gbm.so.*.*", + "libnvidia-egl-wayland.so.*.*", + // We include the following libraries to have them available for + // symlink creation below: + // If CDI injection is used, these should already be detected as: + // * libnvidia-allocator.so.RM_VERSION + // * libnvidia-vulkan-producer.so.RM_VERSION + // but need to be handled for the legacy case too. + "libnvidia-allocator.so." + cudaVersionPattern, + "libnvidia-vulkan-producer.so." + cudaVersionPattern, + }, + ) + + xorgLibraries := NewMounts( + logger, + lookup.NewFileLocator( + lookup.WithLogger(logger), + lookup.WithRoot(driver.Root), + lookup.WithSearchPaths(buildXOrgSearchPaths(cudaLibRoot)...), + lookup.WithCount(1), + ), + driver.Root, + []string{ + "nvidia_drv.so", + "libglxserver_nvidia.so." + cudaVersionPattern, + }, + ) + + return &graphicsDriverLibraries{ + Discover: Merge(libraries, xorgLibraries), + logger: logger, + nvidiaCDIHookPath: nvidiaCDIHookPath, + } +} + +// Create necessary library symlinks for graphics drivers +func (d graphicsDriverLibraries) Hooks() ([]Hook, error) { + mounts, err := d.Discover.Mounts() + if err != nil { + return nil, fmt.Errorf("failed to get library mounts: %v", err) + } + + var links []string + for _, mount := range mounts { + dir, filename := filepath.Split(mount.Path) + switch { + case d.isDriverLibrary(filename, "libnvidia-allocator.so"): + // gbm/nvidia-drm_gbm.so is a symlink to ../libnvidia-allocator.so.1 which + // in turn symlinks to libnvidia-allocator.so.RM_VERSION and is created + // when ldconfig is run in the container. + // create libnvidia-allocate.so.1 -> libnvidia-allocate.so.RM_VERSION symlink + links = append(links, fmt.Sprintf("%s::%s", filename, filepath.Join(dir, "libnvidia-allocator.so.1"))) + // create gbm/nvidia-drm_gbm.so -> ../libnvidia-allocate.so.1 symlink + linkPath := filepath.Join(dir, "gbm", "nvidia-drm_gbm.so") + links = append(links, fmt.Sprintf("%s::%s", "../libnvidia-allocator.so.1", linkPath)) + case d.isDriverLibrary(filename, "libnvidia-vulkan-producer.so"): + // libnvidia-vulkan-producer.so is a drirect symlink to libnvidia-vulkan-producer.so.RM_VERSION + // create libnvidia-vulkan-producer.so -> libnvidia-vulkan-producer.so.RM_VERSION symlink + linkPath := filepath.Join(dir, "libnvidia-vulkan-producer.so") + links = append(links, fmt.Sprintf("%s::%s", filename, linkPath)) + case d.isDriverLibrary(filename, "libglxserver_nvidia.so"): + // libglxserver_nvidia.so is a directl symlink to libglxserver_nvidia.so.RM_VERSION + // create libglxserver_nvidia.so -> libglxserver_nvidia.so.RM_VERSION symlink + linkPath := filepath.Join(dir, "libglxserver_nvidia.so") + links = append(links, fmt.Sprintf("%s::%s", filename, linkPath)) + } + } + if len(links) == 0 { + return nil, nil + } + + hooks := CreateCreateSymlinkHook(d.nvidiaCDIHookPath, links) + + return hooks.Hooks() +} + +// isDriverLibrary checks whether the specified filename is a specific driver library. +func (d graphicsDriverLibraries) isDriverLibrary(filename string, libraryName string) bool { + // TODO: Instead of `.*.*` we could use the driver version. + pattern := strings.TrimSuffix(libraryName, ".") + ".*.*" + match, _ := filepath.Match(pattern, filename) + return match +} + +// getCUDALibRootAndVersionPattern returns the parent directory and the version +// suffix of the libcuda.so.*.* library at the driver root. +// If the library cannot be located an empty root is returned. +// If the version string cannot be extracted, the generic *.* pattern is returned. +func getCUDALibRootAndVersionPattern(logger logger.Interface, driver *root.Driver) (string, string) { + libCudaPaths, err := cuda.New( + driver.Libraries(), + ).Locate(".*.*") + if err != nil { + logger.Warningf("failed to locate libcuda.so: %v; using *.*", err) + return "", "*.*" + } + libcudaPath := libCudaPaths[0] + + libRoot := filepath.Dir(libcudaPath) + version := strings.TrimPrefix(filepath.Base(libcudaPath), "libcuda.so.") + if version == "" { + logger.Warningf("failed to extract version from %v; using *.*", libcudaPath) + version = "*.*" + } + + return driver.RelativeToRoot(libRoot), version +} + +// buildXOrgSearchPaths returns the ordered list of search paths for XOrg files. +func buildXOrgSearchPaths(libRoot string) []string { + var paths []string + if libRoot != "" { + paths = append(paths, + filepath.Join(libRoot, "nvidia/xorg"), + filepath.Join(libRoot, "xorg", "modules", "drivers"), + filepath.Join(libRoot, "xorg", "modules", "extensions"), + filepath.Join(libRoot, "xorg", "modules/updates", "drivers"), + filepath.Join(libRoot, "xorg", "modules/updates", "extensions"), + ) + } + + return append(paths, + filepath.Join("/usr/lib/xorg", "modules", "drivers"), + filepath.Join("/usr/lib/xorg", "modules", "extensions"), + filepath.Join("/usr/lib/xorg", "modules/updates", "drivers"), + filepath.Join("/usr/lib/xorg", "modules/updates", "extensions"), + filepath.Join("/usr/lib64/xorg", "modules", "drivers"), + filepath.Join("/usr/lib64/xorg", "modules", "extensions"), + filepath.Join("/usr/lib64/xorg", "modules/updates", "drivers"), + filepath.Join("/usr/lib64/xorg", "modules/updates", "extensions"), + filepath.Join("/usr/X11R6/lib", "modules", "drivers"), + filepath.Join("/usr/X11R6/lib", "modules", "extensions"), + filepath.Join("/usr/X11R6/lib", "modules/updates", "drivers"), + filepath.Join("/usr/X11R6/lib", "modules/updates", "extensions"), + filepath.Join("/usr/X11R6/lib64", "modules", "drivers"), + filepath.Join("/usr/X11R6/lib64", "modules", "extensions"), + filepath.Join("/usr/X11R6/lib64", "modules/updates", "drivers"), + filepath.Join("/usr/X11R6/lib64", "modules/updates", "extensions"), + ) +} + type drmDevicesByPath struct { None - logger logger.Interface - nvidiaCTKPath string - devRoot string - devicesFrom Discover + logger logger.Interface + nvidiaCDIHookPath string + devRoot string + devicesFrom Discover } // newCreateDRMByPathSymlinks creates a discoverer for a hook to create the by-path symlinks for DRM devices discovered by the specified devices discoverer -func newCreateDRMByPathSymlinks(logger logger.Interface, devices Discover, devRoot string, nvidiaCTKPath string) Discover { +func newCreateDRMByPathSymlinks(logger logger.Interface, devices Discover, devRoot string, nvidiaCDIHookPath string) Discover { d := drmDevicesByPath{ - logger: logger, - nvidiaCTKPath: nvidiaCTKPath, - devRoot: devRoot, - devicesFrom: devices, + logger: logger, + nvidiaCDIHookPath: nvidiaCDIHookPath, + devRoot: devRoot, + devicesFrom: devices, } return &d @@ -127,8 +294,8 @@ func (d drmDevicesByPath) Hooks() ([]Hook, error) { args = append(args, "--link", l) } - hook := CreateNvidiaCTKHook( - d.nvidiaCTKPath, + hook := CreateNvidiaCDIHook( + d.nvidiaCDIHookPath, "create-symlinks", args..., ) @@ -232,118 +399,6 @@ func newDRMDeviceFilter(devices image.VisibleDevices, devRoot string) (Filter, e return filter, nil } -type xorgHooks struct { - libraries Discover - driverVersion string - nvidiaCTKPath string -} - -var _ Discover = (*xorgHooks)(nil) - -// optionalXorgDiscoverer creates a discoverer for Xorg libraries. -// If the creation of the discoverer fails, a None discoverer is returned. -func optionalXorgDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCTKPath string) Discover { - xorg, err := newXorgDiscoverer(logger, driver, nvidiaCTKPath) - if err != nil { - logger.Warningf("Failed to create Xorg discoverer: %v; skipping xorg libraries", err) - return None{} - } - return xorg -} - -func newXorgDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCTKPath string) (Discover, error) { - libCudaPaths, err := cuda.New( - driver.Libraries(), - ).Locate(".*.*") - if err != nil { - return nil, fmt.Errorf("failed to locate libcuda.so: %v", err) - } - libcudaPath := libCudaPaths[0] - - version := strings.TrimPrefix(filepath.Base(libcudaPath), "libcuda.so.") - if version == "" { - return nil, fmt.Errorf("failed to determine libcuda.so version from path: %q", libcudaPath) - } - - libRoot := filepath.Dir(libcudaPath) - xorgLibs := NewMounts( - logger, - lookup.NewFileLocator( - lookup.WithLogger(logger), - lookup.WithRoot(driver.Root), - lookup.WithSearchPaths(libRoot, "/usr/lib/x86_64-linux-gnu"), - lookup.WithCount(1), - ), - driver.Root, - []string{ - "nvidia/xorg/nvidia_drv.so", - fmt.Sprintf("nvidia/xorg/libglxserver_nvidia.so.%s", version), - }, - ) - xorgHooks := xorgHooks{ - libraries: xorgLibs, - driverVersion: version, - nvidiaCTKPath: nvidiaCTKPath, - } - - xorgConfig := NewMounts( - logger, - driver.Configs(), - driver.Root, - []string{"X11/xorg.conf.d/10-nvidia.conf"}, - ) - - d := Merge( - xorgLibs, - xorgConfig, - xorgHooks, - ) - - return d, nil -} - -// Devices returns no devices for Xorg -func (m xorgHooks) Devices() ([]Device, error) { - return nil, nil -} - -// Hooks returns a hook to create symlinks for Xorg libraries -func (m xorgHooks) Hooks() ([]Hook, error) { - mounts, err := m.libraries.Mounts() - if err != nil { - return nil, fmt.Errorf("failed to get mounts: %v", err) - } - if len(mounts) == 0 { - return nil, nil - } - - var target string - for _, mount := range mounts { - filename := filepath.Base(mount.HostPath) - if filename == "libglxserver_nvidia.so."+m.driverVersion { - target = mount.Path - } - } - - if target == "" { - return nil, nil - } - - link := strings.TrimSuffix(target, "."+m.driverVersion) - links := []string{fmt.Sprintf("%s::%s", filepath.Base(target), link)} - symlinkHook := CreateCreateSymlinkHook( - m.nvidiaCTKPath, - links, - ) - - return symlinkHook.Hooks() -} - -// Mounts returns the libraries required for Xorg -func (m xorgHooks) Mounts() ([]Mount, error) { - return nil, nil -} - // selectDeviceByPath is a filter that allows devices to be selected by the path type selectDeviceByPath map[string]bool diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/hooks.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/hooks.go index d68ecdbd..4259ccf8 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/hooks.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/hooks.go @@ -41,7 +41,7 @@ func (h Hook) Hooks() ([]Hook, error) { } // CreateCreateSymlinkHook creates a hook which creates a symlink from link -> target. -func CreateCreateSymlinkHook(nvidiaCTKPath string, links []string) Discover { +func CreateCreateSymlinkHook(nvidiaCDIHookPath string, links []string) Discover { if len(links) == 0 { return None{} } @@ -50,18 +50,31 @@ func CreateCreateSymlinkHook(nvidiaCTKPath string, links []string) Discover { for _, link := range links { args = append(args, "--link", link) } - return CreateNvidiaCTKHook( - nvidiaCTKPath, + return CreateNvidiaCDIHook( + nvidiaCDIHookPath, "create-symlinks", args..., ) } -// CreateNvidiaCTKHook creates a hook which invokes the NVIDIA Container CLI hook subcommand. -func CreateNvidiaCTKHook(nvidiaCTKPath string, hookName string, additionalArgs ...string) Hook { +// CreateNvidiaCDIHook creates a hook which invokes the NVIDIA Container CLI hook subcommand. +func CreateNvidiaCDIHook(nvidiaCDIHookPath string, hookName string, additionalArgs ...string) Hook { + return cdiHook(nvidiaCDIHookPath).Create(hookName, additionalArgs...) +} + +type cdiHook string + +func (c cdiHook) Create(name string, args ...string) Hook { return Hook{ Lifecycle: cdi.CreateContainerHook, - Path: nvidiaCTKPath, - Args: append([]string{filepath.Base(nvidiaCTKPath), "hook", hookName}, additionalArgs...), + Path: string(c), + Args: append(c.requiredArgs(name), args...), + } +} +func (c cdiHook) requiredArgs(name string) []string { + base := filepath.Base(string(c)) + if base == "nvidia-ctk" { + return []string{base, "hook", name} } + return []string{base, name} } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/ldconfig.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/ldconfig.go index a1182ed2..b81b9be5 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/ldconfig.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/ldconfig.go @@ -25,12 +25,12 @@ import ( ) // NewLDCacheUpdateHook creates a discoverer that updates the ldcache for the specified mounts. A logger can also be specified -func NewLDCacheUpdateHook(logger logger.Interface, mounts Discover, nvidiaCTKPath, ldconfigPath string) (Discover, error) { +func NewLDCacheUpdateHook(logger logger.Interface, mounts Discover, nvidiaCDIHookPath, ldconfigPath string) (Discover, error) { d := ldconfig{ - logger: logger, - nvidiaCTKPath: nvidiaCTKPath, - ldconfigPath: ldconfigPath, - mountsFrom: mounts, + logger: logger, + nvidiaCDIHookPath: nvidiaCDIHookPath, + ldconfigPath: ldconfigPath, + mountsFrom: mounts, } return &d, nil @@ -38,10 +38,10 @@ func NewLDCacheUpdateHook(logger logger.Interface, mounts Discover, nvidiaCTKPat type ldconfig struct { None - logger logger.Interface - nvidiaCTKPath string - ldconfigPath string - mountsFrom Discover + logger logger.Interface + nvidiaCDIHookPath string + ldconfigPath string + mountsFrom Discover } // Hooks checks the required mounts for libraries and returns a hook to update the LDcache for the discovered paths. @@ -51,7 +51,7 @@ func (d ldconfig) Hooks() ([]Hook, error) { return nil, fmt.Errorf("failed to discover mounts for ldcache update: %v", err) } h := CreateLDCacheUpdateHook( - d.nvidiaCTKPath, + d.nvidiaCDIHookPath, d.ldconfigPath, getLibraryPaths(mounts), ) @@ -70,7 +70,7 @@ func CreateLDCacheUpdateHook(executable string, ldconfig string, libraries []str args = append(args, "--folder", f) } - hook := CreateNvidiaCTKHook( + hook := CreateNvidiaCDIHook( executable, "update-ldcache", args..., diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/mounts-to-container-path.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/mounts-to-container-path.go new file mode 100644 index 00000000..602f153d --- /dev/null +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/discover/mounts-to-container-path.go @@ -0,0 +1,81 @@ +/** +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package discover + +import ( + "fmt" + "path/filepath" + "strings" + + "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" + "github.com/NVIDIA/nvidia-container-toolkit/internal/lookup" +) + +// mountsToContainerPath defines a Discoverer for a required set of mounts. +// When these are discovered by a locator the specified container root is used +// to construct the container path for the mount returned. +type mountsToContainerPath struct { + None + logger logger.Interface + locator lookup.Locator + required []string + containerRoot string +} + +func (d *mountsToContainerPath) Mounts() ([]Mount, error) { + seen := make(map[string]bool) + var mounts []Mount + for _, target := range d.required { + if strings.Contains(target, "*") { + // TODO: We could relax this condition. + return nil, fmt.Errorf("wildcard patterns are not supported: %s", target) + } + candidates, err := d.locator.Locate(target) + if err != nil { + d.logger.Warningf("Could not locate %v: %v", target, err) + continue + } + if len(candidates) == 0 { + d.logger.Warningf("Missing %v", target) + continue + } + hostPath := candidates[0] + if seen[hostPath] { + d.logger.Debugf("Skipping duplicate mount %v", hostPath) + continue + } + seen[hostPath] = true + d.logger.Debugf("Located %v as %v", target, hostPath) + + containerPath := filepath.Join(d.containerRoot, target) + d.logger.Infof("Selecting %v as %v", hostPath, containerPath) + + mount := Mount{ + HostPath: hostPath, + Path: containerPath, + Options: []string{ + "ro", + "nosuid", + "nodev", + "bind", + }, + } + mounts = append(mounts, mount) + } + + return mounts, nil +} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/logger/api.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/logger/api.go index b8db9766..750c64c6 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/logger/api.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/logger/api.go @@ -24,4 +24,5 @@ type Interface interface { Infof(string, ...interface{}) Warning(...interface{}) Warningf(string, ...interface{}) + Tracef(string, ...interface{}) } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/logger/lib.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/logger/lib.go index 300e925f..ddb227bf 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/logger/lib.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/logger/lib.go @@ -45,3 +45,6 @@ func (l *NullLogger) Warning(...interface{}) {} // Warningf is a no-op for the null logger func (l *NullLogger) Warningf(string, ...interface{}) {} + +// Tracef is a no-op for the null logger +func (l *NullLogger) Tracef(string, ...interface{}) {} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/root/root.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/root/root.go index 4a475ccd..d0c83701 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/root/root.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/root/root.go @@ -19,6 +19,7 @@ package root import ( "os" "path/filepath" + "strings" "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" "github.com/NVIDIA/nvidia-container-toolkit/internal/lookup" @@ -47,6 +48,28 @@ func New(opts ...Option) *Driver { return d } +// RelativeToRoot returns the specified path relative to the driver root. +func (r *Driver) RelativeToRoot(path string) string { + if r.Root == "" || r.Root == "/" { + return path + } + if !filepath.IsAbs(path) { + return path + } + + return strings.TrimPrefix(path, r.Root) +} + +// Files returns a Locator for arbitrary driver files. +func (r *Driver) Files(opts ...lookup.Option) lookup.Locator { + return lookup.NewFileLocator( + append(opts, + lookup.WithLogger(r.logger), + lookup.WithRoot(r.Root), + )..., + ) +} + // Libraries returns a Locator for driver libraries. func (r *Driver) Libraries() lookup.Locator { return lookup.NewLibraryLocator( diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime.go index 438fc5d2..2ea71cb2 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime.go @@ -16,10 +16,11 @@ package oci -//go:generate moq -stub -out runtime_mock.go . Runtime - // Runtime is an interface for a runtime shim. The Exec method accepts a list // of command line arguments, and returns an error / nil. +// +//go:generate moq -rm -stub -out runtime_mock.go . Runtime type Runtime interface { Exec([]string) error + String() string } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_low_level.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_low_level.go index 4150eb52..65ae8b21 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_low_level.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_low_level.go @@ -31,8 +31,6 @@ func NewLowLevelRuntime(logger logger.Interface, candidates []string) (Runtime, if err != nil { return nil, fmt.Errorf("error locating runtime: %v", err) } - - logger.Infof("Using low-level runtime %v", runtimePath) return NewRuntimeForPath(logger, runtimePath) } @@ -45,13 +43,12 @@ func findRuntime(logger logger.Interface, candidates []string) (string, error) { locator := lookup.NewExecutableLocator(logger, "/") for _, candidate := range candidates { - logger.Debugf("Looking for runtime binary '%v'", candidate) + logger.Tracef("Looking for runtime binary '%v'", candidate) targets, err := locator.Locate(candidate) if err == nil && len(targets) > 0 { - logger.Debugf("Found runtime binary '%v'", targets) + logger.Tracef("Found runtime binary '%v'", targets) return targets[0], nil } - logger.Debugf("Runtime binary '%v' not found: %v (targets=%v)", candidate, err, targets) } return "", fmt.Errorf("no runtime binary found from candidate list: %v", candidates) diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_mock.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_mock.go index b6331f27..147035d4 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_mock.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_mock.go @@ -20,6 +20,9 @@ var _ Runtime = &RuntimeMock{} // ExecFunc: func(strings []string) error { // panic("mock out the Exec method") // }, +// StringFunc: func() string { +// panic("mock out the String method") +// }, // } // // // use mockedRuntime in code that requires Runtime @@ -30,6 +33,9 @@ type RuntimeMock struct { // ExecFunc mocks the Exec method. ExecFunc func(strings []string) error + // StringFunc mocks the String method. + StringFunc func() string + // calls tracks calls to the methods. calls struct { // Exec holds details about calls to the Exec method. @@ -37,8 +43,12 @@ type RuntimeMock struct { // Strings is the strings argument value. Strings []string } + // String holds details about calls to the String method. + String []struct { + } } - lockExec sync.RWMutex + lockExec sync.RWMutex + lockString sync.RWMutex } // Exec calls ExecFunc. @@ -75,3 +85,33 @@ func (mock *RuntimeMock) ExecCalls() []struct { mock.lockExec.RUnlock() return calls } + +// String calls StringFunc. +func (mock *RuntimeMock) String() string { + callInfo := struct { + }{} + mock.lockString.Lock() + mock.calls.String = append(mock.calls.String, callInfo) + mock.lockString.Unlock() + if mock.StringFunc == nil { + var ( + sOut string + ) + return sOut + } + return mock.StringFunc() +} + +// StringCalls gets all the calls that were made to String. +// Check the length with: +// +// len(mockedRuntime.StringCalls()) +func (mock *RuntimeMock) StringCalls() []struct { +} { + var calls []struct { + } + mock.lockString.RLock() + calls = mock.calls.String + mock.lockString.RUnlock() + return calls +} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_modifier.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_modifier.go index 797f5cd9..50ca42fb 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_modifier.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_modifier.go @@ -35,7 +35,7 @@ var _ Runtime = (*modifyingRuntimeWrapper)(nil) // before invoking the wrapped runtime. If the modifier is nil, the input runtime is returned. func NewModifyingRuntimeWrapper(logger logger.Interface, runtime Runtime, spec Spec, modifier SpecModifier) Runtime { if modifier == nil { - logger.Infof("Using low-level runtime with no modification") + logger.Tracef("Using low-level runtime with no modification") return runtime } @@ -52,16 +52,15 @@ func NewModifyingRuntimeWrapper(logger logger.Interface, runtime Runtime, spec S // into the wrapped runtime. func (r *modifyingRuntimeWrapper) Exec(args []string) error { if HasCreateSubcommand(args) { + r.logger.Debugf("Create command detected; applying OCI specification modifications") err := r.modify() if err != nil { - return fmt.Errorf("could not apply required modification to OCI specification: %v", err) + return fmt.Errorf("could not apply required modification to OCI specification: %w", err) } - r.logger.Infof("Applied required modification to OCI specification") - } else { - r.logger.Infof("No modification of OCI specification required") + r.logger.Debugf("Applied required modification to OCI specification") } - r.logger.Infof("Forwarding command to runtime") + r.logger.Debugf("Forwarding command to runtime %v", r.runtime.String()) return r.runtime.Exec(args) } @@ -83,3 +82,8 @@ func (r *modifyingRuntimeWrapper) modify() error { } return nil } + +// String returns a string representation of the runtime. +func (r *modifyingRuntimeWrapper) String() string { + return fmt.Sprintf("modify on-create and forward to %s", r.runtime.String()) +} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_path.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_path.go index 3c43f31d..8c15a107 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_path.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_path.go @@ -63,3 +63,8 @@ func (s pathRuntime) Exec(args []string) error { return s.execRuntime.Exec(runtimeArgs) } + +// String returns the path to the specified runtime as the string representation. +func (s pathRuntime) String() string { + return s.path +} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_syscall_exec.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_syscall_exec.go index 6820e3a1..349edf86 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_syscall_exec.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/runtime_syscall_exec.go @@ -37,3 +37,7 @@ func (r syscallExec) Exec(args []string) error { // err is nil or not. return fmt.Errorf("unexpected return from exec '%v'", args[0]) } + +func (r syscallExec) String() string { + return "exec" +} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/spec.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/spec.go index 2daa7503..e95ea1cf 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/spec.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/oci/spec.go @@ -26,7 +26,7 @@ import ( // SpecModifier defines an interface for modifying a (raw) OCI spec type SpecModifier interface { - // Modify is a method that accepts a pointer to an OCI Srec and returns an + // Modify is a method that accepts a pointer to an OCI Spec and returns an // error. The intention is that the function would modify the spec in-place. Modify(*specs.Spec) error } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/by-path-hooks.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/by-path-hooks.go new file mode 100644 index 00000000..cd38f5e7 --- /dev/null +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/by-path-hooks.go @@ -0,0 +1,117 @@ +/** +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package dgpu + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/NVIDIA/nvidia-container-toolkit/internal/discover" + "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" +) + +// byPathHookDiscoverer discovers the entities required for injecting by-path DRM device links +type byPathHookDiscoverer struct { + logger logger.Interface + devRoot string + nvidiaCDIHookPath string + pciBusID string + deviceNodes discover.Discover +} + +var _ discover.Discover = (*byPathHookDiscoverer)(nil) + +// Devices returns the empty list for the by-path hook discoverer +func (d *byPathHookDiscoverer) Devices() ([]discover.Device, error) { + return nil, nil +} + +// Hooks returns the hooks for the GPU device. +// The following hooks are detected: +// 1. A hook to create /dev/dri/by-path symlinks +func (d *byPathHookDiscoverer) Hooks() ([]discover.Hook, error) { + links, err := d.deviceNodeLinks() + if err != nil { + return nil, fmt.Errorf("failed to discover DRA device links: %v", err) + } + if len(links) == 0 { + return nil, nil + } + + var args []string + for _, l := range links { + args = append(args, "--link", l) + } + + hook := discover.CreateNvidiaCDIHook( + d.nvidiaCDIHookPath, + "create-symlinks", + args..., + ) + + return []discover.Hook{hook}, nil +} + +// Mounts returns an empty slice for a full GPU +func (d *byPathHookDiscoverer) Mounts() ([]discover.Mount, error) { + return nil, nil +} + +func (d *byPathHookDiscoverer) deviceNodeLinks() ([]string, error) { + devices, err := d.deviceNodes.Devices() + if err != nil { + return nil, fmt.Errorf("failed to discover device nodes: %v", err) + } + + if len(devices) == 0 { + return nil, nil + } + + selectedDevices := make(map[string]bool) + for _, d := range devices { + selectedDevices[d.HostPath] = true + } + + candidates := []string{ + fmt.Sprintf("/dev/dri/by-path/pci-%s-card", d.pciBusID), + fmt.Sprintf("/dev/dri/by-path/pci-%s-render", d.pciBusID), + } + + var links []string + for _, c := range candidates { + linkPath := filepath.Join(d.devRoot, c) + device, err := os.Readlink(linkPath) + if err != nil { + d.logger.Warningf("Failed to evaluate symlink %v; ignoring", linkPath) + continue + } + + deviceNode := device + if !filepath.IsAbs(device) { + deviceNode = filepath.Join(filepath.Dir(linkPath), device) + } + if !selectedDevices[deviceNode] { + d.logger.Debugf("ignoring device symlink %v -> %v since %v is not mounted", linkPath, device, deviceNode) + continue + } + d.logger.Debugf("adding device symlink %v -> %v", linkPath, device) + links = append(links, fmt.Sprintf("%v::%v", device, linkPath)) + } + + return links, nil +} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/dgpu.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/dgpu.go new file mode 100644 index 00000000..00982a62 --- /dev/null +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/dgpu.go @@ -0,0 +1,57 @@ +/** +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package dgpu + +import ( + "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" + + "github.com/NVIDIA/nvidia-container-toolkit/internal/discover" + "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" +) + +// NewForDevice creates a discoverer for the specified Device. +func NewForDevice(d device.Device, opts ...Option) (discover.Discover, error) { + o := &options{} + for _, opt := range opts { + opt(o) + } + + if o.logger == nil { + o.logger = logger.New() + } + + return o.newNvmlDGPUDiscoverer(&toRequiredInfo{d}) +} + +// NewForDevice creates a discoverer for the specified device and its associated MIG device. +func NewForMigDevice(d device.Device, mig device.MigDevice, opts ...Option) (discover.Discover, error) { + o := &options{} + for _, opt := range opts { + opt(o) + } + + if o.logger == nil { + o.logger = logger.New() + } + + return o.newNvmlMigDiscoverer( + &toRequiredMigInfo{ + MigDevice: mig, + parent: &toRequiredInfo{d}, + }, + ) +} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/nvml.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/nvml.go new file mode 100644 index 00000000..e4b67641 --- /dev/null +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/nvml.go @@ -0,0 +1,168 @@ +/** +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package dgpu + +import ( + "fmt" + + "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" + "github.com/NVIDIA/go-nvml/pkg/nvml" + + "github.com/NVIDIA/nvidia-container-toolkit/internal/discover" + "github.com/NVIDIA/nvidia-container-toolkit/internal/info/drm" + "github.com/NVIDIA/nvidia-container-toolkit/internal/nvcaps" +) + +type requiredInfo interface { + GetMinorNumber() (int, error) + GetPCIBusID() (string, error) + getDevNodePath() (string, error) +} + +func (o *options) newNvmlDGPUDiscoverer(d requiredInfo) (discover.Discover, error) { + path, err := d.getDevNodePath() + if err != nil { + return nil, fmt.Errorf("error getting device node path: %w", err) + } + + pciBusID, err := d.GetPCIBusID() + if err != nil { + return nil, fmt.Errorf("error getting PCI info for device: %w", err) + } + + drmDeviceNodes, err := drm.GetDeviceNodesByBusID(pciBusID) + if err != nil { + return nil, fmt.Errorf("failed to determine DRM devices for %v: %v", pciBusID, err) + } + + deviceNodePaths := append([]string{path}, drmDeviceNodes...) + + deviceNodes := discover.NewCharDeviceDiscoverer( + o.logger, + o.devRoot, + deviceNodePaths, + ) + + byPathHooks := &byPathHookDiscoverer{ + logger: o.logger, + devRoot: o.devRoot, + nvidiaCDIHookPath: o.nvidiaCDIHookPath, + pciBusID: pciBusID, + deviceNodes: deviceNodes, + } + + dd := discover.Merge( + deviceNodes, + byPathHooks, + ) + return dd, nil +} + +type requiredMigInfo interface { + getPlacementInfo() (int, int, int, error) + getDevNodePath() (string, error) +} + +func (o *options) newNvmlMigDiscoverer(d requiredMigInfo) (discover.Discover, error) { + gpu, gi, ci, err := d.getPlacementInfo() + if err != nil { + return nil, fmt.Errorf("error getting placement info: %w", err) + } + + migCaps, err := nvcaps.NewMigCaps() + if err != nil { + return nil, fmt.Errorf("error getting MIG capability device paths: %v", err) + } + + giCap := nvcaps.NewGPUInstanceCap(gpu, gi) + giCapDevicePath, err := migCaps.GetCapDevicePath(giCap) + if err != nil { + return nil, fmt.Errorf("failed to get GI cap device path: %v", err) + } + + ciCap := nvcaps.NewComputeInstanceCap(gpu, gi, ci) + ciCapDevicePath, err := migCaps.GetCapDevicePath(ciCap) + if err != nil { + return nil, fmt.Errorf("failed to get CI cap device path: %v", err) + } + + parentPath, err := d.getDevNodePath() + if err != nil { + return nil, err + } + + deviceNodes := discover.NewCharDeviceDiscoverer( + o.logger, + o.devRoot, + []string{ + parentPath, + giCapDevicePath, + ciCapDevicePath, + }, + ) + + return deviceNodes, nil +} + +type toRequiredInfo struct { + device.Device +} + +func (d *toRequiredInfo) GetMinorNumber() (int, error) { + minor, ret := d.Device.GetMinorNumber() + if ret != nvml.SUCCESS { + return 0, ret + } + return minor, nil +} + +func (d *toRequiredInfo) getDevNodePath() (string, error) { + minor, err := d.GetMinorNumber() + if err != nil { + return "", fmt.Errorf("error getting GPU device minor number: %w", err) + } + path := fmt.Sprintf("/dev/nvidia%d", minor) + return path, nil +} + +type toRequiredMigInfo struct { + device.MigDevice + parent requiredInfo +} + +func (d *toRequiredMigInfo) getPlacementInfo() (int, int, int, error) { + gpu, ret := d.parent.GetMinorNumber() + if ret != nvml.SUCCESS { + return 0, 0, 0, fmt.Errorf("error getting GPU minor: %v", ret) + } + + gi, ret := d.GetGpuInstanceId() + if ret != nvml.SUCCESS { + return 0, 0, 0, fmt.Errorf("error getting GPU Instance ID: %v", ret) + } + + ci, ret := d.GetComputeInstanceId() + if ret != nvml.SUCCESS { + return 0, 0, 0, fmt.Errorf("error getting Compute Instance ID: %v", ret) + } + + return gpu, gi, ci, nil +} + +func (d *toRequiredMigInfo) getDevNodePath() (string, error) { + return d.parent.getDevNodePath() +} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/options.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/options.go new file mode 100644 index 00000000..cea58c6d --- /dev/null +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu/options.go @@ -0,0 +1,50 @@ +/** +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package dgpu + +import ( + "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" +) + +type options struct { + logger logger.Interface + devRoot string + nvidiaCDIHookPath string +} + +type Option func(*options) + +// WithDevRoot sets the root where /dev is located. +func WithDevRoot(root string) Option { + return func(l *options) { + l.devRoot = root + } +} + +// WithLogger sets the logger for the library +func WithLogger(logger logger.Interface) Option { + return func(l *options) { + l.logger = logger + } +} + +// WithNVIDIACDIHookPath sets the path to the NVIDIA Container Toolkit CLI path for the library +func WithNVIDIACDIHookPath(path string) Option { + return func(l *options) { + l.nvidiaCDIHookPath = path + } +} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/tegra/symlinks.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/tegra/symlinks.go index 283b2f4d..37b07e6d 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/tegra/symlinks.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/tegra/symlinks.go @@ -28,10 +28,10 @@ import ( type symlinkHook struct { discover.None - logger logger.Interface - nvidiaCTKPath string - targets []string - mountsFrom discover.Discover + logger logger.Interface + nvidiaCDIHookPath string + targets []string + mountsFrom discover.Discover // The following can be overridden for testing symlinkChainLocator lookup.Locator @@ -42,7 +42,7 @@ type symlinkHook struct { func (o tegraOptions) createCSVSymlinkHooks(targets []string, mounts discover.Discover) discover.Discover { return symlinkHook{ logger: o.logger, - nvidiaCTKPath: o.nvidiaCTKPath, + nvidiaCDIHookPath: o.nvidiaCDIHookPath, targets: targets, mountsFrom: mounts, symlinkChainLocator: o.symlinkChainLocator, @@ -60,7 +60,7 @@ func (d symlinkHook) Hooks() ([]discover.Hook, error) { csvSymlinks := d.getCSVFileSymlinks() return discover.CreateCreateSymlinkHook( - d.nvidiaCTKPath, + d.nvidiaCDIHookPath, append(csvSymlinks, specificLinks...), ).Hooks() } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/tegra/tegra.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/tegra/tegra.go index 771b31f2..1031fc72 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/tegra/tegra.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/tegra/tegra.go @@ -30,7 +30,7 @@ type tegraOptions struct { csvFiles []string driverRoot string devRoot string - nvidiaCTKPath string + nvidiaCDIHookPath string ldconfigPath string librarySearchPaths []string ignorePatterns ignoreMountSpecPatterns @@ -80,7 +80,7 @@ func New(opts ...Option) (discover.Discover, error) { return nil, fmt.Errorf("failed to create CSV discoverer: %v", err) } - ldcacheUpdateHook, err := discover.NewLDCacheUpdateHook(o.logger, csvDiscoverer, o.nvidiaCTKPath, o.ldconfigPath) + ldcacheUpdateHook, err := discover.NewLDCacheUpdateHook(o.logger, csvDiscoverer, o.nvidiaCDIHookPath, o.ldconfigPath) if err != nil { return nil, fmt.Errorf("failed to create ldcach update hook discoverer: %v", err) } @@ -133,10 +133,10 @@ func WithCSVFiles(csvFiles []string) Option { } } -// WithNVIDIACTKPath sets the path to the nvidia-container-toolkit binary. -func WithNVIDIACTKPath(nvidiaCTKPath string) Option { +// WithNVIDIACDIHookPath sets the path to the nvidia-cdi-hook binary. +func WithNVIDIACDIHookPath(nvidiaCDIHookPath string) Option { return func(o *tegraOptions) { - o.nvidiaCTKPath = nvidiaCTKPath + o.nvidiaCDIHookPath = nvidiaCDIHookPath } } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/common-nvml.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/common-nvml.go index f4bfe30a..4dd1bc35 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/common-nvml.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/common-nvml.go @@ -36,12 +36,12 @@ func (l *nvmllib) newCommonNVMLDiscoverer() (discover.Discover, error) { }, ) - graphicsMounts, err := discover.NewGraphicsMountsDiscoverer(l.logger, l.driver, l.nvidiaCTKPath) + graphicsMounts, err := discover.NewGraphicsMountsDiscoverer(l.logger, l.driver, l.nvidiaCDIHookPath) if err != nil { l.logger.Warningf("failed to create discoverer for graphics mounts: %v", err) } - driverFiles, err := NewDriverDiscoverer(l.logger, l.driver, l.nvidiaCTKPath, l.ldconfigPath, l.nvmllib) + driverFiles, err := NewDriverDiscoverer(l.logger, l.driver, l.nvidiaCDIHookPath, l.ldconfigPath, l.nvmllib) if err != nil { return nil, fmt.Errorf("failed to create discoverer for driver files: %v", err) } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/driver-nvml.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/driver-nvml.go index 10d154d6..8fb39888 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/driver-nvml.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/driver-nvml.go @@ -22,7 +22,7 @@ import ( "path/filepath" "strings" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" "golang.org/x/sys/unix" "github.com/NVIDIA/nvidia-container-toolkit/internal/discover" @@ -34,7 +34,7 @@ import ( // NewDriverDiscoverer creates a discoverer for the libraries and binaries associated with a driver installation. // The supplied NVML Library is used to query the expected driver version. -func NewDriverDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCTKPath string, ldconfigPath string, nvmllib nvml.Interface) (discover.Discover, error) { +func NewDriverDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCDIHookPath string, ldconfigPath string, nvmllib nvml.Interface) (discover.Discover, error) { if r := nvmllib.Init(); r != nvml.SUCCESS { return nil, fmt.Errorf("failed to initialize NVML: %v", r) } @@ -49,11 +49,11 @@ func NewDriverDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCTK return nil, fmt.Errorf("failed to determine driver version: %v", r) } - return newDriverVersionDiscoverer(logger, driver, nvidiaCTKPath, ldconfigPath, version) + return newDriverVersionDiscoverer(logger, driver, nvidiaCDIHookPath, ldconfigPath, version) } -func newDriverVersionDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCTKPath, ldconfigPath, version string) (discover.Discover, error) { - libraries, err := NewDriverLibraryDiscoverer(logger, driver, nvidiaCTKPath, ldconfigPath, version) +func newDriverVersionDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCDIHookPath, ldconfigPath, version string) (discover.Discover, error) { + libraries, err := NewDriverLibraryDiscoverer(logger, driver, nvidiaCDIHookPath, ldconfigPath, version) if err != nil { return nil, fmt.Errorf("failed to create discoverer for driver libraries: %v", err) } @@ -81,7 +81,7 @@ func newDriverVersionDiscoverer(logger logger.Interface, driver *root.Driver, nv } // NewDriverLibraryDiscoverer creates a discoverer for the libraries associated with the specified driver version. -func NewDriverLibraryDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCTKPath, ldconfigPath, version string) (discover.Discover, error) { +func NewDriverLibraryDiscoverer(logger logger.Interface, driver *root.Driver, nvidiaCDIHookPath, ldconfigPath, version string) (discover.Discover, error) { libraryPaths, err := getVersionLibs(logger, driver, version) if err != nil { return nil, fmt.Errorf("failed to get libraries for driver version: %v", err) @@ -97,7 +97,7 @@ func NewDriverLibraryDiscoverer(logger logger.Interface, driver *root.Driver, nv libraryPaths, ) - hooks, _ := discover.NewLDCacheUpdateHook(logger, libraries, nvidiaCTKPath, ldconfigPath) + hooks, _ := discover.NewLDCacheUpdateHook(logger, libraries, nvidiaCDIHookPath, ldconfigPath) d := discover.Merge( libraries, diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/driver-wsl.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/driver-wsl.go index e87bcb03..d184d777 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/driver-wsl.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/driver-wsl.go @@ -39,7 +39,7 @@ var requiredDriverStoreFiles = []string{ } // newWSLDriverDiscoverer returns a Discoverer for WSL2 drivers. -func newWSLDriverDiscoverer(logger logger.Interface, driverRoot string, nvidiaCTKPath, ldconfigPath string) (discover.Discover, error) { +func newWSLDriverDiscoverer(logger logger.Interface, driverRoot string, nvidiaCDIHookPath, ldconfigPath string) (discover.Discover, error) { err := dxcore.Init() if err != nil { return nil, fmt.Errorf("failed to initialize dxcore: %v", err) @@ -56,11 +56,11 @@ func newWSLDriverDiscoverer(logger logger.Interface, driverRoot string, nvidiaCT } logger.Infof("Using WSL driver store paths: %v", driverStorePaths) - return newWSLDriverStoreDiscoverer(logger, driverRoot, nvidiaCTKPath, ldconfigPath, driverStorePaths) + return newWSLDriverStoreDiscoverer(logger, driverRoot, nvidiaCDIHookPath, ldconfigPath, driverStorePaths) } // newWSLDriverStoreDiscoverer returns a Discoverer for WSL2 drivers in the driver store associated with a dxcore adapter. -func newWSLDriverStoreDiscoverer(logger logger.Interface, driverRoot string, nvidiaCTKPath string, ldconfigPath string, driverStorePaths []string) (discover.Discover, error) { +func newWSLDriverStoreDiscoverer(logger logger.Interface, driverRoot string, nvidiaCDIHookPath string, ldconfigPath string, driverStorePaths []string) (discover.Discover, error) { var searchPaths []string seen := make(map[string]bool) for _, path := range driverStorePaths { @@ -88,12 +88,12 @@ func newWSLDriverStoreDiscoverer(logger logger.Interface, driverRoot string, nvi ) symlinkHook := nvidiaSMISimlinkHook{ - logger: logger, - mountsFrom: libraries, - nvidiaCTKPath: nvidiaCTKPath, + logger: logger, + mountsFrom: libraries, + nvidiaCDIHookPath: nvidiaCDIHookPath, } - ldcacheHook, _ := discover.NewLDCacheUpdateHook(logger, libraries, nvidiaCTKPath, ldconfigPath) + ldcacheHook, _ := discover.NewLDCacheUpdateHook(logger, libraries, nvidiaCDIHookPath, ldconfigPath) d := discover.Merge( libraries, @@ -106,9 +106,9 @@ func newWSLDriverStoreDiscoverer(logger logger.Interface, driverRoot string, nvi type nvidiaSMISimlinkHook struct { discover.None - logger logger.Interface - mountsFrom discover.Discover - nvidiaCTKPath string + logger logger.Interface + mountsFrom discover.Discover + nvidiaCDIHookPath string } // Hooks returns a hook that creates a symlink to nvidia-smi in the driver store. @@ -135,7 +135,7 @@ func (m nvidiaSMISimlinkHook) Hooks() ([]discover.Hook, error) { } link := "/usr/bin/nvidia-smi" links := []string{fmt.Sprintf("%s::%s", target, link)} - symlinkHook := discover.CreateCreateSymlinkHook(m.nvidiaCTKPath, links) + symlinkHook := discover.CreateCreateSymlinkHook(m.nvidiaCDIHookPath, links) return symlinkHook.Hooks() } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/full-gpu-nvml.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/full-gpu-nvml.go index 9e4013ef..881d102d 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/full-gpu-nvml.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/full-gpu-nvml.go @@ -18,19 +18,14 @@ package nvcdi import ( "fmt" - "os" - "path/filepath" - "strings" "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" - "github.com/NVIDIA/go-nvlib/pkg/nvml" "tags.cncf.io/container-device-interface/pkg/cdi" "tags.cncf.io/container-device-interface/specs-go" "github.com/NVIDIA/nvidia-container-toolkit/internal/discover" "github.com/NVIDIA/nvidia-container-toolkit/internal/edits" - "github.com/NVIDIA/nvidia-container-toolkit/internal/info/drm" - "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" + "github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu" ) // GetGPUDeviceSpecs returns the CDI device specs for the full GPU represented by 'device'. @@ -58,7 +53,7 @@ func (l *nvmllib) GetGPUDeviceSpecs(i int, d device.Device) ([]specs.Device, err // GetGPUDeviceEdits returns the CDI edits for the full GPU represented by 'device'. func (l *nvmllib) GetGPUDeviceEdits(d device.Device) (*cdi.ContainerEdits, error) { - device, err := newFullGPUDiscoverer(l.logger, l.devRoot, l.nvidiaCTKPath, d) + device, err := l.newFullGPUDiscoverer(d) if err != nil { return nil, fmt.Errorf("failed to create device discoverer: %v", err) } @@ -71,164 +66,28 @@ func (l *nvmllib) GetGPUDeviceEdits(d device.Device) (*cdi.ContainerEdits, error return editsForDevice, nil } -// byPathHookDiscoverer discovers the entities required for injecting by-path DRM device links -type byPathHookDiscoverer struct { - logger logger.Interface - devRoot string - nvidiaCTKPath string - pciBusID string - deviceNodes discover.Discover -} - -var _ discover.Discover = (*byPathHookDiscoverer)(nil) - // newFullGPUDiscoverer creates a discoverer for the full GPU defined by the specified device. -func newFullGPUDiscoverer(logger logger.Interface, devRoot string, nvidiaCTKPath string, d device.Device) (discover.Discover, error) { - // TODO: The functionality to get device paths should be integrated into the go-nvlib/pkg/device.Device interface. - // This will allow reuse here and in other code where the paths are queried such as the NVIDIA device plugin. - minor, ret := d.GetMinorNumber() - if ret != nvml.SUCCESS { - return nil, fmt.Errorf("error getting GPU device minor number: %v", ret) - } - path := fmt.Sprintf("/dev/nvidia%d", minor) - - pciInfo, ret := d.GetPciInfo() - if ret != nvml.SUCCESS { - return nil, fmt.Errorf("error getting PCI info for device: %v", ret) - } - pciBusID := getBusID(pciInfo) - - drmDeviceNodes, err := drm.GetDeviceNodesByBusID(pciBusID) - if err != nil { - return nil, fmt.Errorf("failed to determine DRM devices for %v: %v", pciBusID, err) - } - - deviceNodePaths := append([]string{path}, drmDeviceNodes...) - - deviceNodes := discover.NewCharDeviceDiscoverer( - logger, - devRoot, - deviceNodePaths, +func (l *nvmllib) newFullGPUDiscoverer(d device.Device) (discover.Discover, error) { + deviceNodes, err := dgpu.NewForDevice(d, + dgpu.WithDevRoot(l.devRoot), + dgpu.WithLogger(l.logger), + dgpu.WithNVIDIACDIHookPath(l.nvidiaCDIHookPath), ) - - byPathHooks := &byPathHookDiscoverer{ - logger: logger, - devRoot: devRoot, - nvidiaCTKPath: nvidiaCTKPath, - pciBusID: pciBusID, - deviceNodes: deviceNodes, + if err != nil { + return nil, fmt.Errorf("failed to create device discoverer: %v", err) } deviceFolderPermissionHooks := newDeviceFolderPermissionHookDiscoverer( - logger, - devRoot, - nvidiaCTKPath, + l.logger, + l.devRoot, + l.nvidiaCDIHookPath, deviceNodes, ) dd := discover.Merge( deviceNodes, - byPathHooks, deviceFolderPermissionHooks, ) return dd, nil } - -// Devices returns the empty list for the by-path hook discoverer -func (d *byPathHookDiscoverer) Devices() ([]discover.Device, error) { - return nil, nil -} - -// Hooks returns the hooks for the GPU device. -// The following hooks are detected: -// 1. A hook to create /dev/dri/by-path symlinks -func (d *byPathHookDiscoverer) Hooks() ([]discover.Hook, error) { - links, err := d.deviceNodeLinks() - if err != nil { - return nil, fmt.Errorf("failed to discover DRA device links: %v", err) - } - if len(links) == 0 { - return nil, nil - } - - var args []string - for _, l := range links { - args = append(args, "--link", l) - } - - hook := discover.CreateNvidiaCTKHook( - d.nvidiaCTKPath, - "create-symlinks", - args..., - ) - - return []discover.Hook{hook}, nil -} - -// Mounts returns an empty slice for a full GPU -func (d *byPathHookDiscoverer) Mounts() ([]discover.Mount, error) { - return nil, nil -} - -func (d *byPathHookDiscoverer) deviceNodeLinks() ([]string, error) { - devices, err := d.deviceNodes.Devices() - if err != nil { - return nil, fmt.Errorf("failed to discover device nodes: %v", err) - } - - if len(devices) == 0 { - return nil, nil - } - - selectedDevices := make(map[string]bool) - for _, d := range devices { - selectedDevices[d.HostPath] = true - } - - candidates := []string{ - fmt.Sprintf("/dev/dri/by-path/pci-%s-card", d.pciBusID), - fmt.Sprintf("/dev/dri/by-path/pci-%s-render", d.pciBusID), - } - - var links []string - for _, c := range candidates { - linkPath := filepath.Join(d.devRoot, c) - device, err := os.Readlink(linkPath) - if err != nil { - d.logger.Warningf("Failed to evaluate symlink %v; ignoring", linkPath) - continue - } - - deviceNode := device - if !filepath.IsAbs(device) { - deviceNode = filepath.Join(filepath.Dir(linkPath), device) - } - if !selectedDevices[deviceNode] { - d.logger.Debugf("ignoring device symlink %v -> %v since %v is not mounted", linkPath, device, deviceNode) - continue - } - d.logger.Debugf("adding device symlink %v -> %v", linkPath, device) - links = append(links, fmt.Sprintf("%v::%v", device, linkPath)) - } - - return links, nil -} - -// getBusID provides a utility function that returns the string representation of the bus ID. -func getBusID(p nvml.PciInfo) string { - var bytes []byte - for _, b := range p.BusId { - if byte(b) == '\x00' { - break - } - bytes = append(bytes, byte(b)) - } - id := strings.ToLower(string(bytes)) - - if id != "0000" { - id = strings.TrimPrefix(id, "0000") - } - - return id -} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib-csv.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib-csv.go index 4acc5cd6..649b801a 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib-csv.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib-csv.go @@ -44,7 +44,7 @@ func (l *csvlib) GetAllDeviceSpecs() ([]specs.Device, error) { tegra.WithLogger(l.logger), tegra.WithDriverRoot(l.driverRoot), tegra.WithDevRoot(l.devRoot), - tegra.WithNVIDIACTKPath(l.nvidiaCTKPath), + tegra.WithNVIDIACDIHookPath(l.nvidiaCDIHookPath), tegra.WithLdconfigPath(l.ldconfigPath), tegra.WithCSVFiles(l.csvFiles), tegra.WithLibrarySearchPaths(l.librarySearchPaths...), diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib-nvml.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib-nvml.go index 0403901a..ab7cb8ba 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib-nvml.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib-nvml.go @@ -22,7 +22,7 @@ import ( "strings" "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" "tags.cncf.io/container-device-interface/pkg/cdi" "tags.cncf.io/container-device-interface/specs-go" @@ -80,7 +80,17 @@ func (l *nvmllib) GetCommonEdits() (*cdi.ContainerEdits, error) { // GetDeviceSpecsByID returns the CDI device specs for the GPU(s) represented by // the provided identifiers, where an identifier is an index or UUID of a valid // GPU device. -func (l *nvmllib) GetDeviceSpecsByID(identifiers ...string) ([]specs.Device, error) { +// Deprecated: Use GetDeviceSpecsBy instead. +func (l *nvmllib) GetDeviceSpecsByID(ids ...string) ([]specs.Device, error) { + var identifiers []device.Identifier + for _, id := range ids { + identifiers = append(identifiers, device.Identifier(id)) + } + return l.GetDeviceSpecsBy(identifiers...) +} + +// GetDeviceSpecsBy is not supported for the gdslib specs. +func (l *nvmllib) GetDeviceSpecsBy(identifiers ...device.Identifier) ([]specs.Device, error) { for _, id := range identifiers { if id == "all" { return l.GetAllDeviceSpecs() @@ -109,7 +119,7 @@ func (l *nvmllib) GetDeviceSpecsByID(identifiers ...string) ([]specs.Device, err return nil, fmt.Errorf("failed to get CDI device edits for identifier %q: %w", identifiers[i], err) } deviceSpec := specs.Device{ - Name: identifiers[i], + Name: string(identifiers[i]), ContainerEdits: *deviceEdits.ContainerEdits, } deviceSpecs = append(deviceSpecs, deviceSpec) @@ -119,7 +129,7 @@ func (l *nvmllib) GetDeviceSpecsByID(identifiers ...string) ([]specs.Device, err } // TODO: move this to go-nvlib? -func (l *nvmllib) getNVMLDevicesByID(identifiers ...string) ([]nvml.Device, error) { +func (l *nvmllib) getNVMLDevicesByID(identifiers ...device.Identifier) ([]nvml.Device, error) { var devices []nvml.Device for _, id := range identifiers { dev, err := l.getNVMLDeviceByID(id) @@ -131,25 +141,24 @@ func (l *nvmllib) getNVMLDevicesByID(identifiers ...string) ([]nvml.Device, erro return devices, nil } -func (l *nvmllib) getNVMLDeviceByID(id string) (nvml.Device, error) { +func (l *nvmllib) getNVMLDeviceByID(id device.Identifier) (nvml.Device, error) { var err error - devID := device.Identifier(id) - if devID.IsUUID() { - return l.nvmllib.DeviceGetHandleByUUID(id) + if id.IsUUID() { + return l.nvmllib.DeviceGetHandleByUUID(string(id)) } - if devID.IsGpuIndex() { - if idx, err := strconv.Atoi(id); err == nil { + if id.IsGpuIndex() { + if idx, err := strconv.Atoi(string(id)); err == nil { return l.nvmllib.DeviceGetHandleByIndex(idx) } return nil, fmt.Errorf("failed to convert device index to an int: %w", err) } - if devID.IsMigIndex() { + if id.IsMigIndex() { var gpuIdx, migIdx int var parent nvml.Device - split := strings.SplitN(id, ":", 2) + split := strings.SplitN(string(id), ":", 2) if gpuIdx, err = strconv.Atoi(split[0]); err != nil { return nil, fmt.Errorf("failed to convert device index to an int: %w", err) } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib-wsl.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib-wsl.go index 5e8ea97b..1c96c538 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib-wsl.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib-wsl.go @@ -54,7 +54,7 @@ func (l *wsllib) GetAllDeviceSpecs() ([]specs.Device, error) { // GetCommonEdits generates a CDI specification that can be used for ANY devices func (l *wsllib) GetCommonEdits() (*cdi.ContainerEdits, error) { - driver, err := newWSLDriverDiscoverer(l.logger, l.driverRoot, l.nvidiaCTKPath, l.ldconfigPath) + driver, err := newWSLDriverDiscoverer(l.logger, l.driverRoot, l.nvidiaCDIHookPath, l.ldconfigPath) if err != nil { return nil, fmt.Errorf("failed to create discoverer for WSL driver: %v", err) } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib.go index ad75a239..d2db3b6c 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/lib.go @@ -21,7 +21,7 @@ import ( "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" "github.com/NVIDIA/go-nvlib/pkg/nvlib/info" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" "tags.cncf.io/container-device-interface/pkg/cdi" "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" @@ -48,7 +48,7 @@ type nvcdilib struct { deviceNamers DeviceNamers driverRoot string devRoot string - nvidiaCTKPath string + nvidiaCDIHookPath string ldconfigPath string configSearchPaths []string librarySearchPaths []string @@ -81,24 +81,43 @@ func New(opts ...Option) (Interface, error) { indexNamer, _ := NewDeviceNamer(DeviceNameStrategyIndex) l.deviceNamers = []DeviceNamer{indexNamer} } + if l.nvidiaCDIHookPath == "" { + l.nvidiaCDIHookPath = "/usr/bin/nvidia-cdi-hook" + } if l.driverRoot == "" { l.driverRoot = "/" } if l.devRoot == "" { l.devRoot = l.driverRoot } - if l.nvidiaCTKPath == "" { - l.nvidiaCTKPath = "/usr/bin/nvidia-ctk" - } - if l.infolib == nil { - l.infolib = info.New() - } - l.driver = root.New( root.WithLogger(l.logger), root.WithDriverRoot(l.driverRoot), root.WithLibrarySearchPaths(l.librarySearchPaths...), ) + if l.nvmllib == nil { + var nvmlOpts []nvml.LibraryOption + candidates, err := l.driver.Libraries().Locate("libnvidia-ml.so.1") + if err != nil { + l.logger.Warningf("Ignoring error in locating libnvidia-ml.so.1: %v", err) + } else { + libNvidiaMlPath := candidates[0] + l.logger.Infof("Using %v", libNvidiaMlPath) + nvmlOpts = append(nvmlOpts, nvml.WithLibraryPath(libNvidiaMlPath)) + } + l.nvmllib = nvml.New(nvmlOpts...) + } + if l.devicelib == nil { + l.devicelib = device.New(l.nvmllib) + } + if l.infolib == nil { + l.infolib = info.New( + info.WithRoot(l.driverRoot), + info.WithLogger(l.logger), + info.WithNvmlLib(l.nvmllib), + info.WithDeviceLib(l.devicelib), + ) + } var lib Interface switch l.resolveMode() { @@ -113,13 +132,6 @@ func New(opts ...Option) (Interface, error) { } lib = (*managementlib)(l) case ModeNvml: - if l.nvmllib == nil { - l.nvmllib = nvml.New() - } - if l.devicelib == nil { - l.devicelib = device.New(device.WithNvml(l.nvmllib)) - } - lib = (*nvmllib)(l) case ModeWsl: lib = (*wsllib)(l) @@ -184,26 +196,19 @@ func (l *nvcdilib) resolveMode() (rmode string) { return l.mode } defer func() { - l.logger.Infof("Auto-detected mode as %q", rmode) + l.logger.Infof("Auto-detected mode as '%v'", rmode) }() - isWSL, reason := l.infolib.HasDXCore() - l.logger.Debugf("Is WSL-based system? %v: %v", isWSL, reason) - - if isWSL { - return ModeWsl - } - - isNvml, reason := l.infolib.HasNvml() - l.logger.Debugf("Is NVML-based system? %v: %v", isNvml, reason) - - isTegra, reason := l.infolib.IsTegraSystem() - l.logger.Debugf("Is Tegra-based system? %v: %v", isTegra, reason) - - if isTegra && !isNvml { + platform := l.infolib.ResolvePlatform() + switch platform { + case info.PlatformNVML: + return ModeNvml + case info.PlatformTegra: return ModeCSV + case info.PlatformWSL: + return ModeWsl } - + l.logger.Warningf("Unsupported platform detected: %v; assuming %v", platform, ModeNvml) return ModeNvml } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/management.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/management.go index c906db2c..4648e5bb 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/management.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/management.go @@ -66,7 +66,7 @@ func (m *managementlib) GetCommonEdits() (*cdi.ContainerEdits, error) { return nil, fmt.Errorf("failed to get CUDA version: %v", err) } - driver, err := newDriverVersionDiscoverer(m.logger, m.driver, m.nvidiaCTKPath, m.ldconfigPath, version) + driver, err := newDriverVersionDiscoverer(m.logger, m.driver, m.nvidiaCDIHookPath, m.ldconfigPath, version) if err != nil { return nil, fmt.Errorf("failed to create driver library discoverer: %v", err) } @@ -123,7 +123,7 @@ func (m *managementlib) newManagementDeviceDiscoverer() (discover.Discover, erro deviceFolderPermissionHooks := newDeviceFolderPermissionHookDiscoverer( m.logger, m.devRoot, - m.nvidiaCTKPath, + m.nvidiaCDIHookPath, deviceNodes, ) diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/mig-device-nvml.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/mig-device-nvml.go index 86ce04d2..91fe879c 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/mig-device-nvml.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/mig-device-nvml.go @@ -20,14 +20,11 @@ import ( "fmt" "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" - "github.com/NVIDIA/go-nvlib/pkg/nvml" "tags.cncf.io/container-device-interface/pkg/cdi" "tags.cncf.io/container-device-interface/specs-go" - "github.com/NVIDIA/nvidia-container-toolkit/internal/discover" "github.com/NVIDIA/nvidia-container-toolkit/internal/edits" - "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" - "github.com/NVIDIA/nvidia-container-toolkit/internal/nvcaps" + "github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu" ) // GetMIGDeviceSpecs returns the CDI device specs for the full GPU represented by 'device'. @@ -54,74 +51,19 @@ func (l *nvmllib) GetMIGDeviceSpecs(i int, d device.Device, j int, mig device.Mi // GetMIGDeviceEdits returns the CDI edits for the MIG device represented by 'mig' on 'parent'. func (l *nvmllib) GetMIGDeviceEdits(parent device.Device, mig device.MigDevice) (*cdi.ContainerEdits, error) { - gpu, ret := parent.GetMinorNumber() - if ret != nvml.SUCCESS { - return nil, fmt.Errorf("error getting GPU minor: %v", ret) - } - - gi, ret := mig.GetGpuInstanceId() - if ret != nvml.SUCCESS { - return nil, fmt.Errorf("error getting GPU Instance ID: %v", ret) - } - - ci, ret := mig.GetComputeInstanceId() - if ret != nvml.SUCCESS { - return nil, fmt.Errorf("error getting Compute Instance ID: %v", ret) - } - - editsForDevice, err := l.GetEditsForComputeInstance(gpu, gi, ci) - if err != nil { - return nil, fmt.Errorf("failed to create container edits for MIG device: %v", err) - } - - return editsForDevice, nil -} - -// GetEditsForComputeInstance returns the CDI edits for a particular compute instance defined by the (gpu, gi, ci) tuple -func (l *nvmllib) GetEditsForComputeInstance(gpu int, gi int, ci int) (*cdi.ContainerEdits, error) { - computeInstance, err := newComputeInstanceDiscoverer(l.logger, l.devRoot, gpu, gi, ci) + deviceNodes, err := dgpu.NewForMigDevice(parent, mig, + dgpu.WithDevRoot(l.devRoot), + dgpu.WithLogger(l.logger), + dgpu.WithNVIDIACDIHookPath(l.nvidiaCDIHookPath), + ) if err != nil { - return nil, fmt.Errorf("failed to create discoverer for Compute Instance: %v", err) + return nil, fmt.Errorf("failed to create device discoverer: %v", err) } - editsForDevice, err := edits.FromDiscoverer(computeInstance) + editsForDevice, err := edits.FromDiscoverer(deviceNodes) if err != nil { return nil, fmt.Errorf("failed to create container edits for Compute Instance: %v", err) } return editsForDevice, nil } - -// newComputeInstanceDiscoverer returns a discoverer for the specified compute instance -func newComputeInstanceDiscoverer(logger logger.Interface, devRoot string, gpu int, gi int, ci int) (discover.Discover, error) { - parentPath := fmt.Sprintf("/dev/nvidia%d", gpu) - - migCaps, err := nvcaps.NewMigCaps() - if err != nil { - return nil, fmt.Errorf("error getting MIG capability device paths: %v", err) - } - - giCap := nvcaps.NewGPUInstanceCap(gpu, gi) - giCapDevicePath, err := migCaps.GetCapDevicePath(giCap) - if err != nil { - return nil, fmt.Errorf("failed to get GI cap device path: %v", err) - } - - ciCap := nvcaps.NewComputeInstanceCap(gpu, gi, ci) - ciCapDevicePath, err := migCaps.GetCapDevicePath(ciCap) - if err != nil { - return nil, fmt.Errorf("failed to get CI cap device path: %v", err) - } - - deviceNodes := discover.NewCharDeviceDiscoverer( - logger, - devRoot, - []string{ - parentPath, - giCapDevicePath, - ciCapDevicePath, - }, - ) - - return deviceNodes, nil -} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/namer.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/namer.go index e6a27f45..8edd8f07 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/namer.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/namer.go @@ -20,7 +20,7 @@ import ( "errors" "fmt" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" ) // UUIDer is an interface for getting UUIDs. diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/namer_nvml_mock.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/namer_nvml_mock.go index 68bc1782..6a704b45 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/namer_nvml_mock.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/namer_nvml_mock.go @@ -6,7 +6,7 @@ package nvcdi import ( "sync" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvml/pkg/nvml" ) // Ensure, that nvmlUUIDerMock does implement nvmlUUIDer. diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/options.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/options.go index a4e49b60..417687b9 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/options.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/options.go @@ -18,7 +18,8 @@ package nvcdi import ( "github.com/NVIDIA/go-nvlib/pkg/nvlib/device" - "github.com/NVIDIA/go-nvlib/pkg/nvml" + "github.com/NVIDIA/go-nvlib/pkg/nvlib/info" + "github.com/NVIDIA/go-nvml/pkg/nvml" "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" "github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/transform" @@ -34,6 +35,13 @@ func WithDeviceLib(devicelib device.Interface) Option { } } +// WithInfoLib sets the info library for CDI spec generation. +func WithInfoLib(infolib info.Interface) Option { + return func(l *nvcdilib) { + l.infolib = infolib + } +} + // WithDeviceNamers sets the device namer for the library func WithDeviceNamers(namers ...DeviceNamer) Option { return func(l *nvcdilib) { @@ -63,9 +71,16 @@ func WithLogger(logger logger.Interface) Option { } // WithNVIDIACTKPath sets the path to the NVIDIA Container Toolkit CLI path for the library +// +// Deprecated: Use WithNVIDIACDIHookPath instead. func WithNVIDIACTKPath(path string) Option { + return WithNVIDIACDIHookPath(path) +} + +// WithNVIDIACDIHookPath sets the path to the NVIDIA Container Toolkit CLI path for the library +func WithNVIDIACDIHookPath(path string) Option { return func(l *nvcdilib) { - l.nvidiaCTKPath = path + l.nvidiaCDIHookPath = path } } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/api.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/api.go index b91072c5..918f56f2 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/api.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/api.go @@ -24,6 +24,8 @@ import ( const ( // DetectMinimumVersion is a constant that triggers a spec to detect the minimum required version. + // + // Deprecated: DetectMinimumVersion is deprecated and will be removed. DetectMinimumVersion = "DETECT_MINIMUM_VERSION" // FormatJSON indicates a JSON output format diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/builder.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/builder.go index 8fb80a68..b7dffd98 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/builder.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/builder.go @@ -39,6 +39,8 @@ type builder struct { mergedDeviceOptions []transform.MergedDeviceOption noSimplify bool permissions os.FileMode + + transformOnSave transform.Transformer } // newBuilder creates a new spec builder with the supplied options @@ -47,15 +49,23 @@ func newBuilder(opts ...Option) *builder { for _, opt := range opts { opt(s) } + if s.raw != nil { s.noSimplify = true vendor, class := parser.ParseQualifier(s.raw.Kind) - s.vendor = vendor - s.class = class + if s.vendor == "" { + s.vendor = vendor + } + if s.class == "" { + s.class = class + } + if s.version == "" || s.version == DetectMinimumVersion { + s.version = s.raw.Version + } } - - if s.version == "" { - s.version = DetectMinimumVersion + if s.version == "" || s.version == DetectMinimumVersion { + s.transformOnSave = &setMinimumRequiredVersion{} + s.version = cdi.CurrentVersion } if s.vendor == "" { s.vendor = "nvidia.com" @@ -67,7 +77,7 @@ func newBuilder(opts ...Option) *builder { s.format = FormatYAML } if s.permissions == 0 { - s.permissions = 0600 + s.permissions = 0644 } return s } @@ -83,13 +93,8 @@ func (o *builder) Build() (*spec, error) { ContainerEdits: o.edits, } } - - if raw.Version == DetectMinimumVersion { - minVersion, err := cdi.MinimumRequiredVersion(raw) - if err != nil { - return nil, fmt.Errorf("failed to get minimum required CDI spec version: %v", err) - } - raw.Version = minVersion + if raw.Version == "" { + raw.Version = o.version } if !o.noSimplify { @@ -110,11 +115,11 @@ func (o *builder) Build() (*spec, error) { } s := spec{ - Spec: raw, - format: o.format, - permissions: o.permissions, + Spec: raw, + format: o.format, + permissions: o.permissions, + transformOnSave: o.transformOnSave, } - return &s, nil } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/set-minimum-version.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/set-minimum-version.go new file mode 100644 index 00000000..69969c0b --- /dev/null +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/set-minimum-version.go @@ -0,0 +1,35 @@ +/** +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package spec + +import ( + "fmt" + + "tags.cncf.io/container-device-interface/pkg/cdi" + "tags.cncf.io/container-device-interface/specs-go" +) + +type setMinimumRequiredVersion struct{} + +func (d setMinimumRequiredVersion) Transform(spec *specs.Spec) error { + minVersion, err := cdi.MinimumRequiredVersion(spec) + if err != nil { + return fmt.Errorf("failed to get minimum required CDI spec version: %v", err) + } + spec.Version = minVersion + return nil +} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/spec.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/spec.go index c27c4de3..28cccc51 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/spec.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec/spec.go @@ -24,12 +24,15 @@ import ( "tags.cncf.io/container-device-interface/pkg/cdi" "tags.cncf.io/container-device-interface/specs-go" + + "github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/transform" ) type spec struct { *specs.Spec - format string - permissions os.FileMode + format string + permissions os.FileMode + transformOnSave transform.Transformer } var _ Interface = (*spec)(nil) @@ -41,6 +44,12 @@ func New(opts ...Option) (Interface, error) { // Save writes the spec to the specified path and overwrites the file if it exists. func (s *spec) Save(path string) error { + if s.transformOnSave != nil { + err := s.transformOnSave.Transform(s.Raw()) + if err != nil { + return fmt.Errorf("error applying transform: %w", err) + } + } path, err := s.normalizePath(path) if err != nil { return fmt.Errorf("failed to normalize path: %w", err) diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/workarounds-device-folder-permissions.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/workarounds-device-folder-permissions.go index e183ed6e..511eb1fc 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/workarounds-device-folder-permissions.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/workarounds-device-folder-permissions.go @@ -25,10 +25,10 @@ import ( ) type deviceFolderPermissions struct { - logger logger.Interface - devRoot string - nvidiaCTKPath string - devices discover.Discover + logger logger.Interface + devRoot string + nvidiaCDIHookPath string + devices discover.Discover } var _ discover.Discover = (*deviceFolderPermissions)(nil) @@ -39,12 +39,12 @@ var _ discover.Discover = (*deviceFolderPermissions)(nil) // The nested devices that are applicable to the NVIDIA GPU devices are: // - DRM devices at /dev/dri/* // - NVIDIA Caps devices at /dev/nvidia-caps/* -func newDeviceFolderPermissionHookDiscoverer(logger logger.Interface, devRoot string, nvidiaCTKPath string, devices discover.Discover) discover.Discover { +func newDeviceFolderPermissionHookDiscoverer(logger logger.Interface, devRoot string, nvidiaCDIHookPath string, devices discover.Discover) discover.Discover { d := &deviceFolderPermissions{ - logger: logger, - devRoot: devRoot, - nvidiaCTKPath: nvidiaCTKPath, - devices: devices, + logger: logger, + devRoot: devRoot, + nvidiaCDIHookPath: nvidiaCDIHookPath, + devices: devices, } return d @@ -70,8 +70,8 @@ func (d *deviceFolderPermissions) Hooks() ([]discover.Hook, error) { args = append(args, "--path", folder) } - hook := discover.CreateNvidiaCTKHook( - d.nvidiaCTKPath, + hook := discover.CreateNvidiaCDIHook( + d.nvidiaCDIHookPath, "chmod", args..., ) diff --git a/vendor/modules.txt b/vendor/modules.txt index c7ffd572..2a2fd6c7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -2,20 +2,19 @@ ## explicit; go 1.16 github.com/BurntSushi/toml github.com/BurntSushi/toml/internal -# github.com/NVIDIA/go-nvlib v0.2.0 +# github.com/NVIDIA/go-nvlib v0.6.0 ## explicit; go 1.20 github.com/NVIDIA/go-nvlib/pkg/nvlib/device github.com/NVIDIA/go-nvlib/pkg/nvlib/info -github.com/NVIDIA/go-nvlib/pkg/nvml github.com/NVIDIA/go-nvlib/pkg/nvpci github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio github.com/NVIDIA/go-nvlib/pkg/pciids -# github.com/NVIDIA/go-nvml v0.12.0-3 +# github.com/NVIDIA/go-nvml v0.12.4-0 ## explicit; go 1.20 github.com/NVIDIA/go-nvml/pkg/dl github.com/NVIDIA/go-nvml/pkg/nvml -# github.com/NVIDIA/nvidia-container-toolkit v1.15.0 +# github.com/NVIDIA/nvidia-container-toolkit v1.16.0 ## explicit; go 1.20 github.com/NVIDIA/nvidia-container-toolkit/internal/config/image github.com/NVIDIA/nvidia-container-toolkit/internal/discover @@ -31,6 +30,7 @@ github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/root github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/symlinks github.com/NVIDIA/nvidia-container-toolkit/internal/nvcaps github.com/NVIDIA/nvidia-container-toolkit/internal/oci +github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/dgpu github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/tegra github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/tegra/csv github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi @@ -145,10 +145,10 @@ github.com/syndtr/gocapability/capability ## explicit; go 1.18 github.com/urfave/cli/v2 github.com/urfave/cli/v2/altsrc -# github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 -## explicit; go 1.15.0 +# github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 +## explicit; go 1.15 github.com/xrash/smetrics -# golang.org/x/mod v0.17.0 +# golang.org/x/mod v0.19.0 ## explicit; go 1.18 golang.org/x/mod/semver # golang.org/x/net v0.23.0