2023-11-15 20:38:54 +00:00
|
|
|
// 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
|
|
|
|
|
2024-04-18 13:01:03 +00:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2023-11-15 20:38:54 +00:00
|
|
|
// nvml.GpmMetricsGet()
|
|
|
|
type GpmMetricsGetVType struct {
|
2024-04-18 13:01:03 +00:00
|
|
|
metricsGet *nvmlGpmMetricsGetType
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
2024-04-18 13:01:03 +00:00
|
|
|
func (l *library) GpmMetricsGetV(metricsGet *GpmMetricsGetType) GpmMetricsGetVType {
|
|
|
|
return GpmMetricsGetVType{metricsGet.convert()}
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
2024-04-18 13:01:03 +00:00
|
|
|
func (metricsGetV GpmMetricsGetVType) V1() Return {
|
|
|
|
metricsGetV.metricsGet.Version = 1
|
|
|
|
return nvmlGpmMetricsGet(metricsGetV.metricsGet)
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
2024-04-18 13:01:03 +00:00
|
|
|
func (l *library) GpmMetricsGet(metricsGet *GpmMetricsGetType) Return {
|
|
|
|
metricsGet.Version = GPM_METRICS_GET_VERSION
|
|
|
|
return nvmlGpmMetricsGet(metricsGet.convert())
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// nvml.GpmSampleFree()
|
2024-04-18 13:01:03 +00:00
|
|
|
func (l *library) GpmSampleFree(gpmSample GpmSample) Return {
|
|
|
|
return gpmSample.Free()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (gpmSample nvmlGpmSample) Free() Return {
|
|
|
|
return nvmlGpmSampleFree(gpmSample)
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// nvml.GpmSampleAlloc()
|
2024-04-18 13:01:03 +00:00
|
|
|
func (l *library) GpmSampleAlloc() (GpmSample, Return) {
|
|
|
|
var gpmSample nvmlGpmSample
|
|
|
|
ret := nvmlGpmSampleAlloc(&gpmSample)
|
|
|
|
return gpmSample, ret
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// nvml.GpmSampleGet()
|
2024-04-18 13:01:03 +00:00
|
|
|
func (l *library) GpmSampleGet(device Device, gpmSample GpmSample) Return {
|
|
|
|
return gpmSample.Get(device)
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
2024-04-18 13:01:03 +00:00
|
|
|
func (device nvmlDevice) GpmSampleGet(gpmSample GpmSample) Return {
|
|
|
|
return gpmSample.Get(device)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (gpmSample nvmlGpmSample) Get(device Device) Return {
|
|
|
|
return nvmlGpmSampleGet(device.(nvmlDevice), gpmSample)
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// nvml.GpmQueryDeviceSupport()
|
|
|
|
type GpmSupportV struct {
|
2024-04-18 13:01:03 +00:00
|
|
|
device nvmlDevice
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
2024-04-18 13:01:03 +00:00
|
|
|
func (l *library) GpmQueryDeviceSupportV(device Device) GpmSupportV {
|
|
|
|
return device.GpmQueryDeviceSupportV()
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
2024-04-18 13:01:03 +00:00
|
|
|
func (device nvmlDevice) GpmQueryDeviceSupportV() GpmSupportV {
|
|
|
|
return GpmSupportV{device}
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
2024-04-18 13:01:03 +00:00
|
|
|
func (gpmSupportV GpmSupportV) V1() (GpmSupport, Return) {
|
|
|
|
var gpmSupport GpmSupport
|
|
|
|
gpmSupport.Version = 1
|
|
|
|
ret := nvmlGpmQueryDeviceSupport(gpmSupportV.device, &gpmSupport)
|
|
|
|
return gpmSupport, ret
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
2024-04-18 13:01:03 +00:00
|
|
|
func (l *library) GpmQueryDeviceSupport(device Device) (GpmSupport, Return) {
|
|
|
|
return device.GpmQueryDeviceSupport()
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
2024-04-18 13:01:03 +00:00
|
|
|
func (device nvmlDevice) GpmQueryDeviceSupport() (GpmSupport, Return) {
|
|
|
|
var gpmSupport GpmSupport
|
|
|
|
gpmSupport.Version = GPM_SUPPORT_VERSION
|
|
|
|
ret := nvmlGpmQueryDeviceSupport(device, &gpmSupport)
|
|
|
|
return gpmSupport, ret
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// nvml.GpmMigSampleGet()
|
2024-04-18 13:01:03 +00:00
|
|
|
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)
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
2024-04-18 13:01:03 +00:00
|
|
|
func (gpmSample nvmlGpmSample) MigGet(device Device, gpuInstanceId int) Return {
|
|
|
|
return nvmlGpmMigSampleGet(device.(nvmlDevice), uint32(gpuInstanceId), gpmSample)
|
2023-11-15 20:38:54 +00:00
|
|
|
}
|