-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
concurrent_pipeline2.flx
63 lines (52 loc) · 1.1 KB
/
concurrent_pipeline2.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
57
58
59
60
61
62
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,5) > 0;
return 1;
}
proc countem (y:int) {
//println$ "Got one";
}
proc check(concurrent:bool)
{
async_run {
if concurrent do
spawn_process {; };
/*
spawn_process {; };
spawn_process {; };
spawn_process {; };
spawn_process {; };
spawn_process {; };
spawn_process {; };
*/
done
for(var i = 1; i<1000; ++i;) {
//if i%100 == 0 perform
//println$ "i=" + i.str;
#(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;