1
0
mirror of https://github.com/newnius/YAO-scheduler.git synced 2025-06-07 14:21:55 +00:00
This commit is contained in:
Newnius 2020-06-11 09:10:00 +08:00
parent 00d420fa05
commit bc7092766c
2 changed files with 20 additions and 16 deletions

View File

@ -82,13 +82,13 @@ func (allocator *Allocator) fastBestFit(nodes []NodeStatus, tasks []Task) Alloca
if _, ok := allocation.TasksOnNode[node.ClientID]; !ok {
allocation.TasksOnNode[node.ClientID] = []Task{}
}
numberGPU := 0
available := 0
for _, gpu := range node.Status {
if gpu.MemoryAllocated == 0 {
numberGPU += 1
available += 1
}
}
if task.NumberGPU > numberGPU {
if task.NumberGPU > available {
continue
}
eva.add(node, task)
@ -108,10 +108,13 @@ func (allocator *Allocator) fastBestFit(nodes []NodeStatus, tasks []Task) Alloca
//fmt.Println(task, nodeID, allocation.TasksOnNode, minCost)
allocation.TasksOnNode[best.ClientID] = append(allocation.TasksOnNode[best.ClientID], task)
eva.add(*best, task)
cnt := 0
for i := range best.Status {
//allocate more than 1
if best.Status[i].MemoryAllocated == 0 {
best.Status[i].MemoryAllocated += task.MemoryGPU
cnt++
}
if cnt >= task.NumberGPU {
break
}
}
@ -205,11 +208,11 @@ func (allocator *Allocator) GA(nodes []NodeStatus, tasks []Task, useBestFit bool
if allocation.Nodes[nodeID].Status[i].MemoryAllocated == 0 {
allocation.Nodes[nodeID].Status[i].MemoryAllocated += task.MemoryGPU
cnt--
}
if cnt == 0 {
break
}
}
}
} else {
allocation.Flags["valid"] = false
break
@ -225,11 +228,11 @@ func (allocator *Allocator) GA(nodes []NodeStatus, tasks []Task, useBestFit bool
if allocation.Nodes[nodeID].Status[i].MemoryAllocated == 0 {
allocation.Nodes[nodeID].Status[i].MemoryAllocated += task.MemoryGPU
cnt--
}
if cnt == 0 {
break
}
}
}
} else {
allocation.Flags["valid"] = false
break
@ -258,13 +261,13 @@ func randomFit(allocation Allocation, task Task) (string, bool) {
flag := false
nodeID := ""
for nodeID = range allocation.Nodes {
numberGPU := 0
available := 0
for _, gpu := range allocation.Nodes[nodeID].Status {
if gpu.MemoryAllocated == 0 {
numberGPU += 1
available += 1
}
}
if task.NumberGPU <= numberGPU {
if task.NumberGPU <= available {
flag = true
break
}
@ -279,13 +282,13 @@ func firstFit(allocation Allocation, task Task) (string, bool) {
if _, ok := allocation.Nodes[nodeID]; !ok {
continue
}
numberGPU := 0
available := 0
for _, gpu := range allocation.Nodes[nodeID].Status {
if gpu.MemoryAllocated == 0 {
numberGPU += 1
available += 1
}
}
if task.NumberGPU <= numberGPU {
if task.NumberGPU <= available {
flag = true
break
}

View File

@ -943,6 +943,7 @@ func (pool *ResourcePool) doAcquireResource(job Job) []NodeStatus {
res.ClientHost = node.ClientHost
res.NumCPU = task.NumberCPU
res.MemTotal = task.Memory
/* bug */
res.Status = available[0:task.NumberGPU]
available = available[task.NumberGPU:]