Skip to content

Commit

Permalink
quick return for edge case
Browse files Browse the repository at this point in the history
Signed-off-by: kerthcet <[email protected]>
  • Loading branch information
kerthcet committed Dec 12, 2023
1 parent bf96ab0 commit 4b24c1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gpuallocator/besteffort_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func (p *bestEffortPolicy) Allocate(available []*Device, required []*Device, siz
return []*Device{}
}

if len(required) > len(available) {
return []*Device{}
}

// Find the highest scoring GPU partition with sets of of size 'size'.
// Don't consider partitions that don't have at least one set that contains
// all of the GPUs 'required' by the allocation.
Expand Down
8 changes: 8 additions & 0 deletions gpuallocator/besteffort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ func TestBestEffortAllocate(t *testing.T) {
4,
[]int{},
},
{
"Required too many devices than available",
devices,
[]int{0, 1, 2, 3, 4, 5},
[]int{1, 2, 3, 4, 5, 6},
1,
[]int{},
},
}

RunPolicyAllocTests(t, policy, tests)
Expand Down

0 comments on commit 4b24c1b

Please sign in to comment.