Hi, I have a problem with distributed calculation, here is a small example can reflect my question
@everywhere begin
function f(x, b)
return x^2 + sum(b)
end
end
@everywhere using Distributed, SharedArrays
function example(a) # without parameter a, this works well, with parameter a, it reminds a not defined
@everywhere begin
xmin = 0.0
xmax = 10.0
datapoints = 10
xtemp = range(xmin, xmax, length = datapoints + 1)
b = [1, a]
end
rel = SharedVector{Float64}(datapoints + 1)
@sync @distributed for i = 1:datapoints+1
rel[i] = f(xtemp[i], b)
end
return rel
end
c = example(1)
Don’t know why it cannot identify a, any suggestions ?