From 5d2628beb662cb4c318f67d0d6213d862aa7c21a Mon Sep 17 00:00:00 2001 From: Thomas Roehl Date: Mon, 23 May 2022 16:29:06 +0200 Subject: [PATCH] store GPU index explicitly --- collectors/rocmsmiMetric.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/collectors/rocmsmiMetric.go b/collectors/rocmsmiMetric.go index 6da7001..f2acfbf 100644 --- a/collectors/rocmsmiMetric.go +++ b/collectors/rocmsmiMetric.go @@ -21,6 +21,7 @@ type RocmSmiCollectorConfig struct { type RocmSmiCollectorDevice struct { device rocm_smi.DeviceHandle + index int tags map[string]string // default tags meta map[string]string // default meta information excludeMetrics map[string]bool // copy of exclude metrics from config @@ -150,6 +151,7 @@ func (m *RocmSmiCollector) Init(config json.RawMessage) error { for _, e := range m.config.ExcludeMetrics { dev.excludeMetrics[e] = true } + dev.index = i m.devices = append(m.devices, dev) } @@ -167,7 +169,7 @@ func (m *RocmSmiCollector) Read(interval time.Duration, output chan lp.CCMetric) for _, dev := range m.devices { metrics, ret := rocm_smi.DeviceGetMetrics(dev.device) if ret != rocm_smi.STATUS_SUCCESS { - cclog.ComponentError(m.name, "Unable to get metrics for device at index", dev.device.Index, ":", rocm_smi.StatusStringNoError(ret)) + cclog.ComponentError(m.name, "Unable to get metrics for device at index", dev.index, ":", rocm_smi.StatusStringNoError(ret)) continue }