Dear Gray,
thank you very much. But your answer does not quite help me. The task have
quite different execution time so I have to make sure it is executed in an
beneficial order. I have posted below a simplified version of the code.
However, the code block below #create local variables does not work.
Best wishes,
Sebastian
-----------------------------------------------------------------
times=linspace(0.1,2.0,10) # times in secs representing different difficult
computations
sort!(times,rev=true)
np = nprocs()
n = length(times)
#create local variables
for p=1:np
if p != myid() || np == 1
remotecall(p,stack = Float64p[]) #does not work
end
end
@everywhere function fun(s)
mid=myid()
sleep(s)
#s represents some computation save to local stack
push!(stack,s)
end
#asynchronously do the computations
@everywhere i = 1
function nextidx()
global i
idx=i;
i+=1;
return idx;
end
@sync begin
for p=1:np
if p != myid() || np == 1
@async begin
j=1
res=zeros(40);
while true
idx = nextidx()
if idx > n
break
end
remotecall(fun, times[idx])
end
end
end
end
end
# collect the results of the computations
for p=1:np
if p != myid() || np == 1
tmpStack=fetch(p,stack)
#do someting with the results
end
end