From 9c48da1bc896796c6effc79f26109cbed9ef7750 Mon Sep 17 00:00:00 2001 From: Amit Murthy Date: Thu, 6 Aug 2015 18:28:49 +0530 Subject: [PATCH] tweak @parallel --- base/multi.jl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/base/multi.jl b/base/multi.jl index 85801a1576509..a5bc60d5f5f6a 100644 --- a/base/multi.jl +++ b/base/multi.jl @@ -1468,12 +1468,15 @@ function splitrange(N::Int, np::Int) end function preduce(reducer, f, N::Int) - chunks = splitrange(N, nworkers()) + w=workers() + chunks = splitrange(N, length(w)) results = cell(length(chunks)) - for i in 1:length(chunks) - results[i] = @spawn f(first(chunks[i]), last(chunks[i])) + @sync begin + for i in 1:length(chunks) + @async results[i] = remotecall_fetch(w[i], f, first(chunks[i]), last(chunks[i])) + end end - mapreduce(fetch, reducer, results) + reduce(reducer, results) end function pfor(f, N::Int)