1
0
mirror of https://github.com/newnius/YAO-scheduler.git synced 2025-12-15 08:16:43 +00:00
This commit is contained in:
2020-04-13 01:30:25 +08:00
parent 4ce9378bf6
commit 533099c14b
4 changed files with 55 additions and 5 deletions

View File

@@ -27,8 +27,9 @@ type ResourcePool struct {
counter int
counterTotal int
bindings map[string]map[string]bool
utils map[string][]int
bindings map[string]map[string]bool
utils map[string][]int
bindingMu sync.Mutex
}
func (pool *ResourcePool) start() {
@@ -210,6 +211,8 @@ func (pool *ResourcePool) releaseNetwork(network string) {
}
func (pool *ResourcePool) attach(GPU string, job string) {
pool.bindingMu.Lock()
defer pool.bindingMu.Unlock()
if _, ok := pool.bindings[GPU]; !ok {
pool.bindings[GPU] = map[string]bool{}
}
@@ -221,6 +224,8 @@ func (pool *ResourcePool) attach(GPU string, job string) {
}
func (pool *ResourcePool) detach(GPU string, jobName string) {
pool.bindingMu.Lock()
defer pool.bindingMu.Unlock()
if _, ok := pool.bindings[GPU]; ok {
if len(pool.bindings[GPU]) == 1 {
InstanceOfOptimizer().feed(jobName, pool.utils[GPU])