Skip to content

Commit

Permalink
Add constants and skip metrics based on constant
Browse files Browse the repository at this point in the history
Signed-off-by: Trey Dockendorf <[email protected]>
  • Loading branch information
treydock committed Jul 10, 2020
1 parent b11d0e5 commit ed27d32
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
26 changes: 21 additions & 5 deletions bindings/go/dcgm/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,27 @@ type FieldValue_v1 struct {
}

const (
DCGM_FT_BINARY = uint('b')
DCGM_FT_DOUBLE = uint('d')
DCGM_FT_INT64 = uint('i')
DCGM_FT_STRING = uint('s')
DCGM_FT_TIMESTAMP = uint('t')
DCGM_FT_BINARY = uint('b')
DCGM_FT_DOUBLE = uint('d')
DCGM_FT_INT64 = uint('i')
DCGM_FT_STRING = uint('s')
DCGM_FT_TIMESTAMP = uint('t')
DCGM_FT_INT32_BLANK = int64(2147483632)
DCGM_FT_INT32_NOT_FOUND = int64(DCGM_FT_INT32_BLANK + 1)
DCGM_FT_INT32_NOT_SUPPORTED = int64(DCGM_FT_INT32_BLANK + 2)
DCGM_FT_INT32_NOT_PERMISSIONED = int64(DCGM_FT_INT32_BLANK + 3)
DCGM_FT_INT64_BLANK = int64(9223372036854775792)
DCGM_FT_INT64_NOT_FOUND = int64(DCGM_FT_INT64_BLANK + 1)
DCGM_FT_INT64_NOT_SUPPORTED = int64(DCGM_FT_INT64_BLANK + 2)
DCGM_FT_INT64_NOT_PERMISSIONED = int64(DCGM_FT_INT64_BLANK + 3)
DCGM_FT_FP64_BLANK = 140737488355328.0
DCGM_FT_FP64_NOT_FOUND = float64(DCGM_FT_FP64_BLANK + 1.0)
DCGM_FT_FP64_NOT_SUPPORTED = float64(DCGM_FT_FP64_BLANK + 2.0)
DCGM_FT_FP64_NOT_PERMISSIONED = float64(DCGM_FT_FP64_BLANK + 3.0)
DCGM_FT_STR_BLANK = "<<<NULL>>>"
DCGM_FT_STR_NOT_FOUND = "<<<NOT_FOUND>>>"
DCGM_FT_STR_NOT_SUPPORTED = "<<<NOT_SUPPORTED>>>"
DCGM_FT_STR_NOT_PERMISSIONED = "<<<NOT_PERM>>>"

DCGM_FI_UNKNOWN = 0
DCGM_FI_DRIVER_VERSION = 1
Expand Down
30 changes: 29 additions & 1 deletion pkg/gpu_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func ToMetric(values []dcgm.FieldValue_v1, c []Counter, d dcgm.Device) []Metric
for i, val := range values {
v := ToString(val)
// Filter out counters with no value
if v == "9223372036854775794" {
if v == SkipDCGMValue {
continue
}
m := Metric{
Expand All @@ -94,6 +94,34 @@ func ToMetric(values []dcgm.FieldValue_v1, c []Counter, d dcgm.Device) []Metric
}

func ToString(value dcgm.FieldValue_v1) string {
switch v := value.Int64(); v {
case dcgm.DCGM_FT_INT32_BLANK:
return SkipDCGMValue
case dcgm.DCGM_FT_INT32_NOT_FOUND:
return SkipDCGMValue
case dcgm.DCGM_FT_INT32_NOT_SUPPORTED:
return SkipDCGMValue
case dcgm.DCGM_FT_INT32_NOT_PERMISSIONED:
return SkipDCGMValue
case dcgm.DCGM_FT_INT64_BLANK:
return SkipDCGMValue
case dcgm.DCGM_FT_INT64_NOT_FOUND:
return SkipDCGMValue
case dcgm.DCGM_FT_INT64_NOT_SUPPORTED:
return SkipDCGMValue
case dcgm.DCGM_FT_INT64_NOT_PERMISSIONED:
return SkipDCGMValue
}
switch v := value.Float64(); v {
case dcgm.DCGM_FT_FP64_BLANK:
return SkipDCGMValue
case dcgm.DCGM_FT_FP64_NOT_FOUND:
return SkipDCGMValue
case dcgm.DCGM_FT_FP64_NOT_SUPPORTED:
return SkipDCGMValue
case dcgm.DCGM_FT_FP64_NOT_PERMISSIONED:
return SkipDCGMValue
}
switch v := value.FieldType; v {
case dcgm.DCGM_FT_STRING:
return value.String()
Expand Down
1 change: 1 addition & 0 deletions pkg/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
)

var (
SkipDCGMValue = "SKIPPING DCGM VALUE"
FailedToConvert = "ERROR - FAILED TO CONVERT TO STRING"

nvidiaResourceName = "nvidia.com/gpu"
Expand Down

0 comments on commit ed27d32

Please sign in to comment.