zhangmeng
2019-07-11 fb217f9ffc1b40d49feae8d4683efa5d8c5da1c9
add protection
1个文件已修改
15 ■■■■■ 已修改文件
gogpu.go 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
gogpu.go
@@ -23,6 +23,21 @@
    return int(C.get_idle_gpu(C.int(memSize)))
}
// SatisfyGPU satisfy unit "M"
func SatisfyGPU(index, memSize, reserve int) bool {
    info, err := Info()
    if err != nil || info.Count >= index {
        fmt.Println("SatisfyGPU no gpu or index ilegal: ", index, " gpu count : ", info.Count)
        return false
    }
    var M1 int64 = 1024 * 1024
    if info.Info[index].GpuMemoryFree-int64(memSize)*M1 > int64(reserve)*M1 {
        return true
    }
    return false
}
// GPURank sort
type GPURank []GpuUnitInfo