mirror of
https://github.com/newnius/YAO-scheduler.git
synced 2025-06-08 06:41:56 +00:00
bug fix
This commit is contained in:
parent
05d2ea3ee5
commit
8d06ddd9a0
@ -52,7 +52,7 @@ func (pool *ResourcePool) start() {
|
|||||||
pool.bindings = map[string]map[string]bool{}
|
pool.bindings = map[string]map[string]bool{}
|
||||||
pool.utils = map[string][]int{}
|
pool.utils = map[string][]int{}
|
||||||
|
|
||||||
pool.poolsCount = 10
|
pool.poolsCount = 100
|
||||||
for i := 0; i < pool.poolsCount; i++ {
|
for i := 0; i < pool.poolsCount; i++ {
|
||||||
pool.pools = append(pool.pools, map[string]NodeStatus{})
|
pool.pools = append(pool.pools, map[string]NodeStatus{})
|
||||||
pool.poolsMu = append(pool.poolsMu, sync.Mutex{})
|
pool.poolsMu = append(pool.poolsMu, sync.Mutex{})
|
||||||
|
@ -170,32 +170,39 @@ func (scheduler *SchedulerFair) Schedule(job Job) {
|
|||||||
|
|
||||||
func (scheduler *SchedulerFair) AcquireResource(job Job, task Task) NodeStatus {
|
func (scheduler *SchedulerFair) AcquireResource(job Job, task Task) NodeStatus {
|
||||||
poolID := rand.Intn(pool.poolsCount)
|
poolID := rand.Intn(pool.poolsCount)
|
||||||
pool.poolsMu[poolID].Lock()
|
|
||||||
defer pool.poolsMu[poolID].Unlock()
|
|
||||||
|
|
||||||
res := NodeStatus{}
|
res := NodeStatus{}
|
||||||
for id, node := range pool.pools[poolID] {
|
|
||||||
var available []GPUStatus
|
|
||||||
for _, status := range node.Status {
|
|
||||||
if status.MemoryTotal-status.MemoryAllocated >= task.MemoryGPU {
|
|
||||||
available = append(available, status)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(available) >= task.NumberGPU {
|
|
||||||
res.ClientID = id
|
|
||||||
res.ClientHost = node.ClientHost
|
|
||||||
res.Status = available[0:task.NumberGPU]
|
|
||||||
res.NumCPU = task.NumberCPU
|
|
||||||
res.MemTotal = task.Memory
|
|
||||||
|
|
||||||
for i := range res.Status {
|
for i := poolID; i < pool.poolsCount; i++ {
|
||||||
for j := range node.Status {
|
pool.poolsMu[i].Lock()
|
||||||
if res.Status[i].UUID == node.Status[j].UUID {
|
flag := false
|
||||||
node.Status[j].MemoryAllocated += task.MemoryGPU
|
for id, node := range pool.pools[i] {
|
||||||
res.Status[i].MemoryTotal = task.MemoryGPU
|
var available []GPUStatus
|
||||||
}
|
for _, status := range node.Status {
|
||||||
|
if status.MemoryTotal-status.MemoryAllocated >= task.MemoryGPU {
|
||||||
|
available = append(available, status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(available) >= task.NumberGPU {
|
||||||
|
res.ClientID = id
|
||||||
|
res.ClientHost = node.ClientHost
|
||||||
|
res.Status = available[0:task.NumberGPU]
|
||||||
|
res.NumCPU = task.NumberCPU
|
||||||
|
res.MemTotal = task.Memory
|
||||||
|
|
||||||
|
for i := range res.Status {
|
||||||
|
for j := range node.Status {
|
||||||
|
if res.Status[i].UUID == node.Status[j].UUID {
|
||||||
|
node.Status[j].MemoryAllocated += task.MemoryGPU
|
||||||
|
res.Status[i].MemoryTotal = task.MemoryGPU
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
flag = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pool.poolsMu[i].Unlock()
|
||||||
|
if flag {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user