-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
concurrent_pipeline.flx
57 lines (46 loc) · 1.12 KB
/
concurrent_pipeline.flx
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
fun ack(x:int,y:int):int =>
if x == 0 then y + 1
elif y == 0 then ack(x - 1, 1)
else ack(x - 1, ack(x, y - 1))
endif
;
fun slow (x:int) {
//println$ "Slow " + x.str;
assert ack(3,12) > 0;
return 1;
}
proc countem (y:int) {
//println$ "Got one";
}
proc check(concurrent:bool)
{
async_run {
if concurrent do
spawn_process { println$ "Helper 1"; };
spawn_process { println$ "Helper 2"; };
spawn_process { println$ "Helper 3"; };
spawn_process { println$ "Helper 4"; };
spawn_process { println$ "Helper 5"; };
spawn_process { println$ "Helper 6"; };
spawn_process { println$ "Helper 7"; };
done
#(source_from_list ([1,2,3,4,5,6,7,8]) |->
function slow |->
function slow |->
function slow |->
function slow |->
function slow |->
function slow |->
function slow |->
function slow |->
procedure countem);
};
}
var start = time();
check(false);
var elapsed = time() - start;
println$ "Serial Elapsed " + elapsed.str;
start = time();
check(true);
elapsed = time() - start;
println$ "Concurrent Elapsed " + elapsed.str;