Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gpuallocator/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Allocator struct {
allocated DeviceSet
}

// Policy defines an interface for plugagable allocation policies to be added
// Policy defines an interface for pluggable allocation policies to be added
// to an Allocator.
type Policy interface {
// Allocate is meant to do the heavy-lifting of implementing the actual
Expand Down
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{1, 2, 3, 4, 5},
[]int{1, 2, 3, 4, 5, 6},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here.

1,
[]int{},
},
}

RunPolicyAllocTests(t, policy, tests)
Expand Down