mirror of
https://github.com/newnius/YAO-scheduler.git
synced 2025-06-07 14:21:55 +00:00
update
This commit is contained in:
parent
00d420fa05
commit
bc7092766c
@ -82,13 +82,13 @@ func (allocator *Allocator) fastBestFit(nodes []NodeStatus, tasks []Task) Alloca
|
|||||||
if _, ok := allocation.TasksOnNode[node.ClientID]; !ok {
|
if _, ok := allocation.TasksOnNode[node.ClientID]; !ok {
|
||||||
allocation.TasksOnNode[node.ClientID] = []Task{}
|
allocation.TasksOnNode[node.ClientID] = []Task{}
|
||||||
}
|
}
|
||||||
numberGPU := 0
|
available := 0
|
||||||
for _, gpu := range node.Status {
|
for _, gpu := range node.Status {
|
||||||
if gpu.MemoryAllocated == 0 {
|
if gpu.MemoryAllocated == 0 {
|
||||||
numberGPU += 1
|
available += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if task.NumberGPU > numberGPU {
|
if task.NumberGPU > available {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
eva.add(node, task)
|
eva.add(node, task)
|
||||||
@ -108,10 +108,13 @@ func (allocator *Allocator) fastBestFit(nodes []NodeStatus, tasks []Task) Alloca
|
|||||||
//fmt.Println(task, nodeID, allocation.TasksOnNode, minCost)
|
//fmt.Println(task, nodeID, allocation.TasksOnNode, minCost)
|
||||||
allocation.TasksOnNode[best.ClientID] = append(allocation.TasksOnNode[best.ClientID], task)
|
allocation.TasksOnNode[best.ClientID] = append(allocation.TasksOnNode[best.ClientID], task)
|
||||||
eva.add(*best, task)
|
eva.add(*best, task)
|
||||||
|
cnt := 0
|
||||||
for i := range best.Status {
|
for i := range best.Status {
|
||||||
//allocate more than 1
|
|
||||||
if best.Status[i].MemoryAllocated == 0 {
|
if best.Status[i].MemoryAllocated == 0 {
|
||||||
best.Status[i].MemoryAllocated += task.MemoryGPU
|
best.Status[i].MemoryAllocated += task.MemoryGPU
|
||||||
|
cnt++
|
||||||
|
}
|
||||||
|
if cnt >= task.NumberGPU {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -205,11 +208,11 @@ func (allocator *Allocator) GA(nodes []NodeStatus, tasks []Task, useBestFit bool
|
|||||||
if allocation.Nodes[nodeID].Status[i].MemoryAllocated == 0 {
|
if allocation.Nodes[nodeID].Status[i].MemoryAllocated == 0 {
|
||||||
allocation.Nodes[nodeID].Status[i].MemoryAllocated += task.MemoryGPU
|
allocation.Nodes[nodeID].Status[i].MemoryAllocated += task.MemoryGPU
|
||||||
cnt--
|
cnt--
|
||||||
|
}
|
||||||
if cnt == 0 {
|
if cnt == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
allocation.Flags["valid"] = false
|
allocation.Flags["valid"] = false
|
||||||
break
|
break
|
||||||
@ -225,11 +228,11 @@ func (allocator *Allocator) GA(nodes []NodeStatus, tasks []Task, useBestFit bool
|
|||||||
if allocation.Nodes[nodeID].Status[i].MemoryAllocated == 0 {
|
if allocation.Nodes[nodeID].Status[i].MemoryAllocated == 0 {
|
||||||
allocation.Nodes[nodeID].Status[i].MemoryAllocated += task.MemoryGPU
|
allocation.Nodes[nodeID].Status[i].MemoryAllocated += task.MemoryGPU
|
||||||
cnt--
|
cnt--
|
||||||
|
}
|
||||||
if cnt == 0 {
|
if cnt == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
allocation.Flags["valid"] = false
|
allocation.Flags["valid"] = false
|
||||||
break
|
break
|
||||||
@ -258,13 +261,13 @@ func randomFit(allocation Allocation, task Task) (string, bool) {
|
|||||||
flag := false
|
flag := false
|
||||||
nodeID := ""
|
nodeID := ""
|
||||||
for nodeID = range allocation.Nodes {
|
for nodeID = range allocation.Nodes {
|
||||||
numberGPU := 0
|
available := 0
|
||||||
for _, gpu := range allocation.Nodes[nodeID].Status {
|
for _, gpu := range allocation.Nodes[nodeID].Status {
|
||||||
if gpu.MemoryAllocated == 0 {
|
if gpu.MemoryAllocated == 0 {
|
||||||
numberGPU += 1
|
available += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if task.NumberGPU <= numberGPU {
|
if task.NumberGPU <= available {
|
||||||
flag = true
|
flag = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -279,13 +282,13 @@ func firstFit(allocation Allocation, task Task) (string, bool) {
|
|||||||
if _, ok := allocation.Nodes[nodeID]; !ok {
|
if _, ok := allocation.Nodes[nodeID]; !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
numberGPU := 0
|
available := 0
|
||||||
for _, gpu := range allocation.Nodes[nodeID].Status {
|
for _, gpu := range allocation.Nodes[nodeID].Status {
|
||||||
if gpu.MemoryAllocated == 0 {
|
if gpu.MemoryAllocated == 0 {
|
||||||
numberGPU += 1
|
available += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if task.NumberGPU <= numberGPU {
|
if task.NumberGPU <= available {
|
||||||
flag = true
|
flag = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -943,6 +943,7 @@ func (pool *ResourcePool) doAcquireResource(job Job) []NodeStatus {
|
|||||||
res.ClientHost = node.ClientHost
|
res.ClientHost = node.ClientHost
|
||||||
res.NumCPU = task.NumberCPU
|
res.NumCPU = task.NumberCPU
|
||||||
res.MemTotal = task.Memory
|
res.MemTotal = task.Memory
|
||||||
|
/* bug */
|
||||||
res.Status = available[0:task.NumberGPU]
|
res.Status = available[0:task.NumberGPU]
|
||||||
available = available[task.NumberGPU:]
|
available = available[task.NumberGPU:]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user