1
0
mirror of https://github.com/newnius/YAO-scheduler.git synced 2025-06-07 22:31:55 +00:00
This commit is contained in:
Newnius 2020-04-13 23:03:34 +08:00
parent 05d2ea3ee5
commit 8d06ddd9a0
2 changed files with 30 additions and 23 deletions

View File

@ -52,7 +52,7 @@ func (pool *ResourcePool) start() {
pool.bindings = map[string]map[string]bool{}
pool.utils = map[string][]int{}
pool.poolsCount = 10
pool.poolsCount = 100
for i := 0; i < pool.poolsCount; i++ {
pool.pools = append(pool.pools, map[string]NodeStatus{})
pool.poolsMu = append(pool.poolsMu, sync.Mutex{})

View File

@ -170,11 +170,12 @@ func (scheduler *SchedulerFair) Schedule(job Job) {
func (scheduler *SchedulerFair) AcquireResource(job Job, task Task) NodeStatus {
poolID := rand.Intn(pool.poolsCount)
pool.poolsMu[poolID].Lock()
defer pool.poolsMu[poolID].Unlock()
res := NodeStatus{}
for id, node := range pool.pools[poolID] {
for i := poolID; i < pool.poolsCount; i++ {
pool.poolsMu[i].Lock()
flag := false
for id, node := range pool.pools[i] {
var available []GPUStatus
for _, status := range node.Status {
if status.MemoryTotal-status.MemoryAllocated >= task.MemoryGPU {
@ -196,6 +197,12 @@ func (scheduler *SchedulerFair) AcquireResource(job Job, task Task) NodeStatus {
}
}
}
flag = true
break
}
}
pool.poolsMu[i].Unlock()
if flag {
break
}
}