-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestutils.jl
29 lines (27 loc) · 863 Bytes
/
testutils.jl
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
#=
Utility functions for testing the DataFlowTasks package.
=#
using DataFlowTasks
# define a simple function to mimic a problem with fork-join parallelization.
# The execution starts with one node, spawns `n` independent nodes, and then
# joint them later at a last node. This is repeated m times. The computation waits for the last node, and
# each block works for `s` seconds
function fork_join(n, s, m = 1)
A = rand(2n)
@dspawn do_work(s, @RW A) label = "first"
for iter in 1:m
for i in 1:n
Av = view(A, [i, i + n])
@dspawn do_work(s, @RW Av) label = "indep($i)"
end
@dspawn do_work(s, @RW A) label = "dep($iter)"
end
res = @dspawn identity(@R A) label = "last"
return fetch(res)
end
function do_work(t, args...)
ti = time()
while (time() - ti) < t
end
return
end