Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

Commit 2d641c5

Browse files
uniemimutogashidm
authored andcommitted
strip GAS struct from functions that don't need it
In order to help with concurrency evaluations, drop GAS from functions which don't access it. Signed-off-by: Ukri Niemimuukko <ukri.niemimuukko@intel.com>
1 parent 347f039 commit 2d641c5

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

gpu-aware-scheduling/pkg/gpuscheduler/scheduler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ func (m *GASExtender) checkForSpaceResourceRequests(perGPUCapacity resourceMap,
658658
containerCards := [][]string{}
659659
preferred := false
660660

661-
samegpuNamesMap, err := m.containersRequestingSamegpu(pod)
661+
samegpuNamesMap, err := containersRequestingSamegpu(pod)
662662
if err != nil {
663663
return containerCards, preferred, err
664664
}
@@ -702,7 +702,7 @@ func (m *GASExtender) checkForSpaceResourceRequests(perGPUCapacity resourceMap,
702702
func (m *GASExtender) getCardForSamegpu(samegpuIndexMap map[int]bool, allContainerRequests []resourceMap,
703703
perGPUCapacity resourceMap, node *v1.Node, pod *v1.Pod, nodeResourcesUsed nodeResources,
704704
gpuMap map[string]bool) ([]string, bool, error) {
705-
if err := m.sanitizeSamegpuResourcesRequest(samegpuIndexMap, allContainerRequests); err != nil {
705+
if err := sanitizeSamegpuResourcesRequest(samegpuIndexMap, allContainerRequests); err != nil {
706706
return []string{}, false, err
707707
}
708708

@@ -1129,7 +1129,7 @@ func (m *GASExtender) readNodeResources(nodeName string) (nodeResources, error)
11291129

11301130
// return search map of container names that should have same GPU based on samegpuAnnotationName.
11311131
// Return empty map if either there are duplicates or absent containers listed.
1132-
func (m *GASExtender) containersRequestingSamegpu(pod *v1.Pod) (map[string]bool, error) {
1132+
func containersRequestingSamegpu(pod *v1.Pod) (map[string]bool, error) {
11331133
csvSamegpulist, ok := pod.Annotations[samegpuAnnotationName]
11341134
if !ok {
11351135
return map[string]bool{}, nil
@@ -1172,7 +1172,7 @@ func (m *GASExtender) containersRequestingSamegpu(pod *v1.Pod) (map[string]bool,
11721172
return samegpuMap, nil
11731173
}
11741174

1175-
func (m *GASExtender) sanitizeSamegpuResourcesRequest(
1175+
func sanitizeSamegpuResourcesRequest(
11761176
samegpuIndexMap map[int]bool, allResourceRequests []resourceMap) error {
11771177
if len(samegpuIndexMap) == 0 {
11781178
return nil

gpu-aware-scheduling/pkg/gpuscheduler/scheduler_test.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,8 +1179,6 @@ func TestSanitizeSamegpulist(t *testing.T) {
11791179
},
11801180
Spec: *getMockPodSpecMultiContSamegpu(),
11811181
}
1182-
clientset := fake.NewSimpleClientset(pod)
1183-
gas := NewGASExtender(clientset, false, false, "")
11841182

11851183
wrongValueReason := map[string]string{
11861184
"container1,container5": "Listing absent containers makes gas-same-gpu ignored",
@@ -1191,7 +1189,7 @@ func TestSanitizeSamegpulist(t *testing.T) {
11911189

11921190
Convey("Ensure no gas-same-gpu annotation returns blank list with no error",
11931191
t, func() {
1194-
containerNames, err := gas.containersRequestingSamegpu(pod)
1192+
containerNames, err := containersRequestingSamegpu(pod)
11951193
So(len(containerNames), ShouldEqual, 0)
11961194
So(err, ShouldEqual, nil)
11971195
})
@@ -1201,7 +1199,7 @@ func TestSanitizeSamegpulist(t *testing.T) {
12011199

12021200
Convey(reason,
12031201
t, func() {
1204-
containerNames, err := gas.containersRequestingSamegpu(pod)
1202+
containerNames, err := containersRequestingSamegpu(pod)
12051203
So(len(containerNames), ShouldEqual, 0)
12061204
So("malformed annotation", ShouldEqual, err.Error())
12071205
})
@@ -1211,33 +1209,29 @@ func TestSanitizeSamegpulist(t *testing.T) {
12111209

12121210
Convey("Ensure correct annotation returns all listed container names with no error",
12131211
t, func() {
1214-
containerNames, err := gas.containersRequestingSamegpu(pod)
1212+
containerNames, err := containersRequestingSamegpu(pod)
12151213
So(containerNames, ShouldResemble, map[string]bool{"container2": true, "container3": true})
12161214
So(err, ShouldEqual, nil)
12171215
})
12181216
}
12191217

12201218
func TestSanitizeSamegpuResourcesRequest(t *testing.T) {
1221-
pod := getFakePod()
1222-
clientset := fake.NewSimpleClientset(pod)
1223-
gas := NewGASExtender(clientset, false, false, "")
1224-
12251219
Convey("Tiles and monitoring resources are not allowed in same-gpu resourceRequests",
12261220
t, func() {
12271221
// fail because of tiles
12281222
samegpuIndexes := map[int]bool{0: true}
12291223
resourceRequests := []resourceMap{
12301224
{"gpu.intel.com/i915": 1, "gpu.intel.com/tiles": 2},
12311225
}
1232-
err := gas.sanitizeSamegpuResourcesRequest(samegpuIndexes, resourceRequests)
1226+
err := sanitizeSamegpuResourcesRequest(samegpuIndexes, resourceRequests)
12331227
So(err.Error(), ShouldEqual, "resources conflict")
12341228

12351229
// fail because of monitoring
12361230
samegpuIndexes = map[int]bool{0: true}
12371231
resourceRequests = []resourceMap{
12381232
{"gpu.intel.com/i915": 1, "gpu.intel.com/i915_monitoring": 1},
12391233
}
1240-
err = gas.sanitizeSamegpuResourcesRequest(samegpuIndexes, resourceRequests)
1234+
err = sanitizeSamegpuResourcesRequest(samegpuIndexes, resourceRequests)
12411235
So(err.Error(), ShouldEqual, "resources conflict")
12421236

12431237
// success
@@ -1248,7 +1242,7 @@ func TestSanitizeSamegpuResourcesRequest(t *testing.T) {
12481242
"gpu.intel.com/memory.max": 8589934592,
12491243
},
12501244
}
1251-
err = gas.sanitizeSamegpuResourcesRequest(samegpuIndexes, resourceRequests)
1245+
err = sanitizeSamegpuResourcesRequest(samegpuIndexes, resourceRequests)
12521246
So(err, ShouldEqual, nil)
12531247
})
12541248

@@ -1260,7 +1254,7 @@ func TestSanitizeSamegpuResourcesRequest(t *testing.T) {
12601254
{"gpu.intel.com/i915": 1, "gpu.intel.com/millicores": 200},
12611255
{"gpu.intel.com/i915": 2, "gpu.intel.com/millicores": 200},
12621256
}
1263-
err := gas.sanitizeSamegpuResourcesRequest(samegpuIndexes, resourceRequests)
1257+
err := sanitizeSamegpuResourcesRequest(samegpuIndexes, resourceRequests)
12641258
So(err.Error(), ShouldEqual, "resources conflict")
12651259

12661260
// Failure homogeneous
@@ -1269,7 +1263,7 @@ func TestSanitizeSamegpuResourcesRequest(t *testing.T) {
12691263
{"gpu.intel.com/i915": 2, "gpu.intel.com/millicores": 200},
12701264
{"gpu.intel.com/i915": 2, "gpu.intel.com/millicores": 200},
12711265
}
1272-
err = gas.sanitizeSamegpuResourcesRequest(samegpuIndexes, resourceRequests)
1266+
err = sanitizeSamegpuResourcesRequest(samegpuIndexes, resourceRequests)
12731267
So(err.Error(), ShouldEqual, "resources conflict")
12741268

12751269
// Success
@@ -1278,7 +1272,7 @@ func TestSanitizeSamegpuResourcesRequest(t *testing.T) {
12781272
{"gpu.intel.com/i915": 1, "gpu.intel.com/millicores": 200},
12791273
{"gpu.intel.com/i915": 1, "gpu.intel.com/millicores": 300},
12801274
}
1281-
err = gas.sanitizeSamegpuResourcesRequest(samegpuIndexes, resourceRequests)
1275+
err = sanitizeSamegpuResourcesRequest(samegpuIndexes, resourceRequests)
12821276
So(err, ShouldEqual, nil)
12831277
})
12841278
}

0 commit comments

Comments
 (0)