1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
| package slave
|
| import (
| "analysis/app"
| "analysis/logo"
| "analysis/util"
| "context"
| "plugin"
|
| "basic.com/valib/gogpu.git"
| )
|
| // TwoPluginConflict test
| func TwoPluginConflict(commSoFile, config string) bool {
| cfg, err := app.ReadConfig(config)
| if err != nil {
| logo.Errorln("Slave Read Config Error: ", err)
| return false
| }
| sdk := loadSDK(cfg.SoFile)
| if sdk == nil {
| }
|
| plug, err := plugin.Open(commSoFile)
| if err != nil || plug == nil {
| logo.Errorln("Slave Open so File: ", commSoFile, " Error: ", err)
| return false
| }
| return true
| }
|
| // Run run
| func Run(ctx context.Context, config, typ, id string, gpu int, shm bool) bool {
| cfg, err := app.ReadConfig(config)
| if err != nil {
| logo.Errorln("Slave Read Config Error: ", err)
| return false
| }
| sdk := loadSDK(cfg.SoFile)
| if sdk == nil {
| return false
| }
|
| // 配置文件设置了gpu memory且值至少两位数,判断是否有gpu可用
| if v, ok := cfg.Param["gpu-memory"]; ok && len(v) > 1 {
| indices := gogpu.RankGPU()
| if len(indices) == 0 {
| logo.Errorln("!!!!!!THERE IS NO VALID GPU")
| return false
| }
| }
| // func Create(config string, typ, id string, gpu int, shm bool, ipc2Rule string, ruleMaxSize int, fn func(...interface{}), reserved map[string]string) interface{}
| // func Run(ctx context.Context, i interface{}) {
|
| handle := sdk.fnCreate(config, typ, id, gpu, shm, util.ToRuleIPC, 30, logo.Infoln, nil)
| if handle == nil {
| logo.Errorln("Create SDK: ", typ, " ID: ", id, " Error")
| return false
| }
|
| sdk.fnRun(ctx, handle)
|
| return true
| }
|
|