-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathintercomm-sched.chai
76 lines (62 loc) · 1.45 KB
/
intercomm-sched.chai
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
65
66
67
68
69
70
71
72
73
74
75
76
var sched = Scheduler()
def world(args)
{
var procmap = ProcMap()
var namemap = NameMap()
sleep(1)
if(procmap.group() == "producer")
{
var sim = load("../simple/simulation 250", procmap)
var snd = load("../../tools/send consumer t:int data:array", procmap)
sim.proceed()
while(sim.running())
{
snd.proceed()
sim.proceed()
}
snd.signal_stop()
snd.proceed()
}
else if(procmap.group() == "consumer")
{
var rcv = load("../../tools/receive producer t:int data:array", procmap)
var ana = load("../simple/analysis", procmap)
rcv.proceed()
while(rcv.running())
{
ana.proceed()
rcv.proceed()
}
if (procmap.local_rank() == 0)
{
var sum = namemap.get("sum")
print("Final sum: ${sum}")
return sum
}
}
else
{
print("I'm not part of producer or consumer group!!! Error!")
flush()
}
}
if(sched.is_controller())
{
var number_trials = 10
for(var m = 0; m < number_trials; ++m)
{
sched.schedule("${m}", "world", [], ["producer" : 0, "consumer" : 0], sched.workers())
}
while(sched.control()) { }
sched.finish()
print("Jobs finished")
while(!sched.results_empty())
{
var x = sched.pop()
print("Got result: ${x}")
}
}
else
{
sched.listen()
}