Skip to content

Commit

Permalink
tweak @parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
amitmurthy committed Aug 8, 2015
1 parent b78659e commit 9c48da1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions base/multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9c48da1

Please sign in to comment.