Skip to content

Commit

Permalink
Suggested changes applied
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyrja committed Nov 15, 2023
1 parent 8769a0f commit 92282a0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cmd/gpu_fakedev/gpu_fakedev.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,6 @@ func generateDriFiles(opts genOptions) {
log.Printf("Generating fake DRI device(s) sysfs, debugfs and devfs content under '%s' & '%s'",
sysfsPath, devfsPath)

makeXelinkSideCar(opts.Capabilities["connection-topology"], opts.DevCount, opts.TilesPerDev, opts.Capabilities["connections"])

opts.dirs, opts.files = 0, 0
for i := 0; i < opts.DevCount; i++ {
if err := addSysfsDriTree(sysfsPath, &opts, i); err != nil {
Expand All @@ -295,16 +293,22 @@ func generateDriFiles(opts genOptions) {
}
}
log.Printf("Done, created %d dirs, %d devices and %d files.", opts.dirs, opts.devs, opts.files)

makeXelinkSideCar(opts)
}

func makeXelinkSideCar(topology string, gpus, tiles int, connections string) {
func makeXelinkSideCar(opts genOptions) {
topology := opts.Capabilities["connection-topology"]
gpus := opts.DevCount
tiles := opts.TilesPerDev
connections := opts.Capabilities["connections"]

if topology != fullyConnected {
log.Printf("XELINK: generate xelink sidecar label file, using (GPUs: %d, Tiles: %d)", gpus, tiles)
saveSideCarFile(connections)
} else {
log.Printf("XELINK: generate xelink sidecar label file, using (GPUs: %d, Tiles: %d, Topology: %s)", gpus, tiles, topology)
saveSideCarFile(buildConnectionList(gpus, tiles))
}
log.Printf("XELINK: generate xelink sidecar label file, using (GPUs: %d, Tiles: %d, Topology: %s)", gpus, tiles, topology)
}

func buildConnectionList(gpus, tiles int) string {
Expand Down Expand Up @@ -338,7 +342,7 @@ func buildConnectionList(gpus, tiles int) string {
}
}

return fmt.Sprintf("%s", strings.Join(smap, "_"))
return strings.Join(smap, "_")
}

func saveSideCarFile(connections string) {
Expand Down

0 comments on commit 92282a0

Please sign in to comment.