Skip to content

Commit d5cb53a

Browse files
committed
labeler: add xe support for tile counting
Signed-off-by: Tuomas Katila <tuomas.katila@intel.com>
1 parent af04d41 commit d5cb53a

File tree

2 files changed

+78
-58
lines changed

2 files changed

+78
-58
lines changed

cmd/internal/labeler/labeler.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,16 @@ func GetMemoryAmount(sysfsDrmDir, gpuName string, numTiles uint64) uint64 {
184184
}
185185

186186
// GetTileCount reads the tile count.
187-
func GetTileCount(sysfsDrmDir, gpuName string) (numTiles uint64) {
188-
filePath := filepath.Join(sysfsDrmDir, gpuName, "gt/gt*")
187+
func GetTileCount(cardPath string) (numTiles uint64) {
188+
files := []string{}
189189

190-
files, _ := filepath.Glob(filePath)
190+
paths, _ := filepath.Glob(filepath.Join(cardPath, "gt/gt*")) // i915 driver
191+
files = append(files, paths...)
192+
193+
paths, _ = filepath.Glob(filepath.Join(cardPath, "device/tile?")) // Xe driver
194+
files = append(files, paths...)
195+
196+
klog.V(4).Info("tile files found:", files)
191197

192198
if len(files) == 0 {
193199
return 1
@@ -308,7 +314,7 @@ func (l *labeler) createLabels() error {
308314
return errors.Wrap(err, "gpu name parsing error")
309315
}
310316

311-
numTiles := GetTileCount(l.sysfsDRMDir, gpuName)
317+
numTiles := GetTileCount(filepath.Join(l.sysfsDRMDir, gpuName))
312318
tileCount += int(numTiles)
313319

314320
memoryAmount := GetMemoryAmount(l.sysfsDRMDir, gpuName, numTiles)

cmd/internal/labeler/labeler_test.go

Lines changed: 68 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -137,60 +137,6 @@ func getTestCases() []testcase {
137137
"gpu.intel.com/tiles": "1",
138138
},
139139
},
140-
{
141-
sysfsdirs: []string{
142-
"card0/device/drm/card0",
143-
},
144-
sysfsfiles: map[string][]byte{
145-
"card0/device/vendor": []byte("0x8086"),
146-
},
147-
name: "when gen:capability info is missing",
148-
memoryOverride: 16000000000,
149-
expectedRetval: nil,
150-
expectedLabels: labelMap{
151-
"gpu.intel.com/millicores": "1000",
152-
"gpu.intel.com/memory.max": "16000000000",
153-
"gpu.intel.com/cards": "card0",
154-
"gpu.intel.com/gpu-numbers": "0",
155-
"gpu.intel.com/tiles": "1",
156-
},
157-
},
158-
{
159-
sysfsdirs: []string{
160-
"card0/device/drm/card0",
161-
},
162-
sysfsfiles: map[string][]byte{
163-
"card0/device/vendor": []byte("0x8086"),
164-
},
165-
name: "gen version missing, but media & graphics versions present",
166-
memoryOverride: 16000000000,
167-
expectedRetval: nil,
168-
expectedLabels: labelMap{
169-
"gpu.intel.com/millicores": "1000",
170-
"gpu.intel.com/memory.max": "16000000000",
171-
"gpu.intel.com/cards": "card0",
172-
"gpu.intel.com/gpu-numbers": "0",
173-
"gpu.intel.com/tiles": "1",
174-
},
175-
},
176-
{
177-
sysfsdirs: []string{
178-
"card0/device/drm/card0",
179-
},
180-
sysfsfiles: map[string][]byte{
181-
"card0/device/vendor": []byte("0x8086"),
182-
},
183-
name: "only media version present",
184-
memoryOverride: 16000000000,
185-
expectedRetval: nil,
186-
expectedLabels: labelMap{
187-
"gpu.intel.com/millicores": "1000",
188-
"gpu.intel.com/memory.max": "16000000000",
189-
"gpu.intel.com/cards": "card0",
190-
"gpu.intel.com/gpu-numbers": "0",
191-
"gpu.intel.com/tiles": "1",
192-
},
193-
},
194140
{
195141
sysfsdirs: []string{
196142
"card0/device/drm/card0",
@@ -562,6 +508,74 @@ func getTestCases() []testcase {
562508
"gpu.intel.com/tiles": "1",
563509
},
564510
},
511+
{
512+
sysfsdirs: []string{
513+
"card0/device/drm/card0",
514+
"card0/device/tile0/gt0",
515+
"card0/device/tile1/gt0",
516+
"card1/device/drm/card1",
517+
"card1/device/tile0/gt0",
518+
"card1/device/tile1/gt0",
519+
"card2/device/drm/card2",
520+
"card2/device/tile0/gt0",
521+
"card2/device/tile1/gt0",
522+
},
523+
sysfsfiles: map[string][]byte{
524+
"card0/device/vendor": []byte("0x8086"),
525+
"card0/lmem_total_bytes": []byte("8000"),
526+
"card0/device/numa_node": []byte("1"),
527+
"card1/device/vendor": []byte("0x8086"),
528+
"card1/lmem_total_bytes": []byte("8000"),
529+
"card1/device/numa_node": []byte("1"),
530+
"card2/device/vendor": []byte("0x8086"),
531+
"card2/lmem_total_bytes": []byte("8000"),
532+
"card2/device/numa_node": []byte("1"),
533+
},
534+
name: "successful labeling with three cards and with xe driver",
535+
expectedRetval: nil,
536+
expectedLabels: labelMap{
537+
"gpu.intel.com/millicores": "3000",
538+
"gpu.intel.com/memory.max": "48000",
539+
"gpu.intel.com/gpu-numbers": "0.1.2",
540+
"gpu.intel.com/cards": "card0.card1.card2",
541+
"gpu.intel.com/tiles": "6",
542+
"gpu.intel.com/numa-gpu-map": "1-0.1.2",
543+
},
544+
},
545+
{
546+
sysfsdirs: []string{
547+
"card0/device/drm/card0",
548+
"card0/device/tile0/gt0",
549+
"card0/device/tile0/gt1",
550+
"card0/device/tile1/gt2",
551+
"card0/device/tile1/gt3",
552+
"card0/device/tile1/gt4",
553+
"card0/device/tile1/gt5",
554+
"card1/device/drm/card1",
555+
"card1/device/tile0/gt0",
556+
"card1/device/tile0/gt1",
557+
"card1/device/tile1/gt2",
558+
"card1/device/tile1/gt4",
559+
},
560+
sysfsfiles: map[string][]byte{
561+
"card0/device/vendor": []byte("0x8086"),
562+
"card0/lmem_total_bytes": []byte("8000"),
563+
"card0/device/numa_node": []byte("1"),
564+
"card1/device/vendor": []byte("0x8086"),
565+
"card1/lmem_total_bytes": []byte("8000"),
566+
"card1/device/numa_node": []byte("1"),
567+
},
568+
name: "successful labeling with two cards, two tiles per card and multiple gts per tile",
569+
expectedRetval: nil,
570+
expectedLabels: labelMap{
571+
"gpu.intel.com/millicores": "2000",
572+
"gpu.intel.com/memory.max": "32000",
573+
"gpu.intel.com/gpu-numbers": "0.1",
574+
"gpu.intel.com/cards": "card0.card1",
575+
"gpu.intel.com/tiles": "4",
576+
"gpu.intel.com/numa-gpu-map": "1-0.1",
577+
},
578+
},
565579
}
566580
}
567581

0 commit comments

Comments
 (0)