Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars T Hansen committed Dec 12, 2024
1 parent 5536667 commit 9ceb8e4
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions adhoc-reports/energy/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,11 @@ func main() {
record[nState] = "CANCELLED"
}

// CPU count and GPU names
// CPU count, GPU count, GPU type
// The AllocTRES is a comma-separated list of name=value
// We want cpu=n
// We want gres/gpu:type=m or barring that, gres/gpu=m, in the latter
// case we must infer the gpu type from the sinfo
//
// The cpu data is just n
// The gpu data is a colon-separated list of m of the gpu type
// If there is not gpu then leave the gpu field blank
//
// Then we want to replace the AllocTRES field by the cpu field, and
// we want to extend the record with the gpu field

var gpuType, gpuCount, cpuCount string
for _, f := range strings.Split(record[nAlloc], ",") {
if m := tresRe.FindStringSubmatch(f); m != nil {
Expand Down Expand Up @@ -116,22 +108,17 @@ func main() {
gpuType = g.kind
}

// Replace AllocTRES by CPUS and then attach GPUS and GPUType
record[nAlloc] = cpuCount
if gpuType != "" {
record = append(record, gpuCount)
record = append(record, gpuType)
} else {
record = append(record, "0") // GPUS
record = append(record, "") // GPUType
}
record = append(record, gpuCount, gpuType)

data[r] = record
}

w := csv.NewWriter(os.Stdout)
defer w.Flush()

// Header
// Header, same fields are replaced/added as above
fieldNames[nAlloc] = "CPUS"
fieldNames = append(fieldNames, "GPUS", "GPUType")
w.Write(fieldNames)
Expand Down

0 comments on commit 9ceb8e4

Please sign in to comment.