Skip to content

Commit

Permalink
fix(bidengine): parse GPU interface (troian suggestions)
Browse files Browse the repository at this point in the history
  • Loading branch information
andy108369 committed Apr 25, 2024
1 parent 67ac419 commit cf8e86d
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions bidengine/shellscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,34 +75,32 @@ func parseGPU(resource *atypes.GPU) gpuElement {
case "vendor":
vendor := tokens[1]
model := tokens[3]
var ram *string
var gpuInterface *string

// vendor/nvidia/model/a100/ram/80Gi
if len(tokens) == 6 && tokens[4] == "ram" {
ram = new(string)
*ram = tokens[5]
}
tokens = tokens[4:]

// vendor/nvidia/model/a100/interface/pcie
if len(tokens) == 6 && tokens[4] == "interface" {
gpuInterface = new(string)
*gpuInterface = tokens[5]
}

// When both ram & interface tokens are set:
// vendor/nvidia/model/t4/ram/16Gi/interface/pcie
if len(tokens) == 8 && tokens[4] == "ram" && tokens[6] == "interface" {
ram = new(string)
gpuInterface = new(string)
*ram = tokens[5]
*gpuInterface = tokens[7]
var ram *string
var iface *string

for i := 0; i < len(tokens); i += 2 {
key := tokens[i]
val := tokens[i+1]

switch key {
case "ram":
ram = new(string)
*ram = val
case "interface":
iface = new(string)
*iface = val
default:
continue
}
}

res.Attributes.Vendor[vendor] = gpuVendorAttributes{
Model: model,
RAM: ram,
Interface: gpuInterface,
Model: model,
RAM: ram,
Interface: iface,
}
default:
}
Expand Down

0 comments on commit cf8e86d

Please sign in to comment.