Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduler: give more context to device allocator #1958

Merged
merged 1 commit into from
Mar 15, 2024
Merged
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
8 changes: 8 additions & 0 deletions pkg/scheduler/plugins/deviceshare/device_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type requestContext struct {
required map[schedulingv1alpha1.DeviceType]sets.Int
preferred map[schedulingv1alpha1.DeviceType]sets.Int
allocationScorer *resourceAllocationScorer
nodeDevice *nodeDevice
allocateByTopology bool
}

type AutopilotAllocator struct {
Expand Down Expand Up @@ -113,6 +115,7 @@ func (a *AutopilotAllocator) Allocate(
allocationScorer: a.scorer,
required: required,
preferred: preferred,
nodeDevice: a.nodeDevice,
}

deviceAllocations, status := a.tryJointAllocate(requestCtx, a.state.jointAllocate, nodeDevice)
Expand Down Expand Up @@ -210,6 +213,10 @@ func (a *AutopilotAllocator) tryJointAllocate(requestCtx *requestContext, jointA
}

func (a *AutopilotAllocator) allocateByTopology(requestCtx *requestContext, nodeDevice *nodeDevice, topologyGuide *deviceTopologyGuide, primaryDeviceType schedulingv1alpha1.DeviceType, jointAllocate *apiext.DeviceJointAllocate, secondaryDeviceTypes []schedulingv1alpha1.DeviceType) (apiext.DeviceAllocations, *framework.Status) {
requestCtx.allocateByTopology = true
defer func() {
requestCtx.allocateByTopology = false
}()
desiredCount := requestCtx.desiredCountPerDeviceType[primaryDeviceType]
if desiredCount == 0 {
return nil, nil
Expand All @@ -236,6 +243,7 @@ func (a *AutopilotAllocator) allocateByTopology(requestCtx *requestContext, node

// TODO(joseph): Currently, scenarios with multiple sockets and multiple nodes are not supported

requestCtx.allocateByTopology = false
// In this case, we can only try to allocate jointly from the whole machine dimension and try to allocate them together as much as possible.
var preferredPCIes sets.String
for _, group := range groupedNodeDevices {
Expand Down
Loading