Skip to content

Commit

Permalink
scheduler: give more context to device allocator (koordinator-sh#1958)
Browse files Browse the repository at this point in the history
Signed-off-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com>
Co-authored-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com>
  • Loading branch information
2 people authored and ls-2018 committed Mar 25, 2024
1 parent 4568bb8 commit 88a2d1a
Showing 1 changed file with 8 additions and 0 deletions.
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

0 comments on commit 88a2d1a

Please sign in to comment.