NVIDIA / go-nvml

Go Bindings for the NVIDIA Management Library (NVML)
Apache License 2.0
290 stars 62 forks source link

Collected GPM metrics are not returned to caller #121

Closed elezar closed 3 months ago

elezar commented 4 months ago

When calling GpmMetricsGet we convert the GpmMetricsGetType to an nvmlGpmMetricsGetType for the call to nvmlGpmMetricsGet.

On returning from nvmlGpmMetricsGet the contents of the nvmlGpmMetricsGetType.Metrics field corresponds to the collected metrics. These are never transferred into the GpmMetricsGetType passed as input.

This should be addressed by changing:

func (l *library) GpmMetricsGet(metricsGet *GpmMetricsGetType) Return {
    metricsGet.Version = GPM_METRICS_GET_VERSION
    return nvmlGpmMetricsGet(metricsGet.convert())
}

to something equivalent to:

func (l *library) GpmMetricsGet(metricsGet *GpmMetricsGetType) Return {
    metricsGet.Version = GPM_METRICS_GET_VERSION
    nvmlMetricsGet := metricsGet.convert()
    defer func() {
        for i := range nvmlMetricsGet.Metrics {
            metricsGet.Metrics[i] = nvmlMetricsGet.Metrics[i]
        }
    }()
    return nvmlGpmMetricsGet(nvmlMetricsGet)
}