Hi Gray,
That was certainly a problem! Moving the require was important to the fix,
but the main problem that I just found was that I was using a bracket,
where I should have been using a parentheses. Please find the corrected
code below and I hope this may help others who are trying
to parallelize non-trivial examples.
Alex
"needed_all_over.jl"
srand(2)
## Data that stays the same
X=rand(100,1)
##Function
function squarer(x)
estimate = mean(x.^2)
return estimate
end
## Estimate Basic Function Here
sim_estimates=zeros(50,1);
function square_with_rand(input)
println("hi")
for i=1:50
sim_estimates[i,1]=squarer([X ; input[i]])
end
println("bye")
return sim_estimates
end
Main File
srand(2);
## Generate Data that is different across draws (Error Sequence)
## The number of Draws
sim_reps_main=100;
sim_reps_node=50;
## Generate the std normal error sequence
rando=rand(sim_reps_main);
addprocs(1)
nprocs() # Now I am doing this on two cores.
require("needed_all_over.jl")
sim_estimates_pmap = pmap(square_with_rand,(rando[1:50],rando[51:100]))
samples = vcat(sim_estimates_pmap[1],sim_estimates_pmap[2])