MCPcopy
hub / github.com/jaypipes/ghw / gpuFillNUMANodes

Function gpuFillNUMANodes

pkg/gpu/gpu_linux.go:134–174  ·  view source on GitHub ↗

Loops through each GraphicsCard struct and find which NUMA node the card is affined to, setting the GraphicsCard.Node field accordingly. If the host system is not a NUMA system, the Node field will be set to nil.

(ctx context.Context, cards []*GraphicsCard)

Source from the content-addressed store, hash-verified

132// affined to, setting the GraphicsCard.Node field accordingly. If the host
133// system is not a NUMA system, the Node field will be set to nil.
134func gpuFillNUMANodes(ctx context.Context, cards []*GraphicsCard) {
135 paths := linuxpath.New(ctx)
136 // Skip topology detection if requested to reduce memory consumption
137 if !config.TopologyEnabled(ctx) {
138 for _, card := range cards {
139 card.Node = nil
140 }
141 return
142 }
143
144 topo, err := topology.New(ctx)
145 if err != nil {
146 // Problem getting topology information so just set the graphics card's
147 // node to nil
148 for _, card := range cards {
149 card.Node = nil
150 }
151 return
152 }
153 for _, card := range cards {
154 // Each graphics card on a NUMA system will have a pseudo-file
155 // called /sys/class/drm/card$CARD_INDEX/device/numa_node which
156 // contains the NUMA node that the card is affined to
157 cardIndexStr := strconv.Itoa(card.Index)
158 fpath := filepath.Join(
159 paths.SysClassDRM,
160 "card"+cardIndexStr,
161 "device",
162 "numa_node",
163 )
164 nodeIdx := util.SafeIntFromFile(ctx, fpath)
165 if nodeIdx == -1 {
166 continue
167 }
168 for _, node := range topo.Nodes {
169 if nodeIdx == int(node.ID) {
170 card.Node = node
171 }
172 }
173 }
174}

Callers 1

loadMethod · 0.85

Calls 4

NewFunction · 0.92
TopologyEnabledFunction · 0.92
NewFunction · 0.92
SafeIntFromFileFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…