Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/multithread.jl')
-rw-r--r--src/multithread.jl16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/multithread.jl b/src/multithread.jl
new file mode 100644
index 0000000..f61cdd7
--- /dev/null
+++ b/src/multithread.jl
@@ -0,0 +1,16 @@
+# split up 1...n among workers
+function spawn_workers(n::Int64)
+ # number of workers
+ nw=nworkers()
+ # split jobs among workers
+ work=Array{Array{Int64,1},1}(undef,nw)
+ # init empty arrays
+ for p in 1:nw
+ work[p]=Int64[]
+ end
+ for i in 1:n
+ append!(work[(i-1)%nw+1],[i])
+ end
+
+ return work
+end