Hi, I’m wondering if I could decrease the computation time for calculating large size array.

Because I was new to Julia, I almost copied the format of ‘advection_shared!(q,u)’ in https://docs.julialang.org/en/latest/manual/parallel-computing like following

```
@everywhere const Hist_x = collect(5000:10:15000)
@everywhere const Hist_y = collect(5000:10:15000)
@everywhere function div(X::SharedArray,q::Array)
idx = indexpids(X)
nchunks = length(procs(X))
splits = [round(Int, s) for s in linspace(0,length(q),nchunks+1)]
splits[idx]+1:splits[idx+1]
end
@everywhere function Xs!(X_ray::SharedArray{Float64,2},ρ::Array{Float64,1},Pos::Array{Float64,2},T::Array{Float64,1},Width::Array{Float64,1},M::Array{Float64,1},X_lim::UnitRange{Int64},Y_lim::UnitRange{Int64})
One = ones(length(ρ))
L_X = X_ray_Luminosity(M,ρ,T) #Function that returns Float64 array
for i in X_lim, j in Y_lim
Inter_X = (min.(Pos[1,:]+Width./2.,(Hist_x[i]+Hist_bin/2.)*One)-max.(Pos[1,:]-Width./2.,(Hist_x[i]-Hist_bin/2.)*One))./Width
Inter_Y = (min.(Pos[2,:]+Width./2.,(Hist_y[j]+Hist_bin/2.)*One)-max.(Pos[2,:]-Width./2.,(Hist_y[j]-Hist_bin/2.)*One))./Width
Inter_X[Inter_X.<0] = 0
Inter_Y[Inter_Y.<0] = 0
X_ray[i,j] = sum(L_X .* (Inter_Y .* Inter_X))/(Hist_bin^2.)
end
X_ray
end
@everywhere Xk!(X_ray::SharedArray{Float64,2},Params::Array{Array{Float64,N} where N})=Xs!(X_ray,Params[1],Params[2],Params[3],Params[4],Params[5],div(X_ray,Hist_x),1:length(Hist_y))
function Xx(GPos::Array{Float64,2},M::Array{Float64,1},ρ::Array{Float64,1},T::Array{Float64,1},Width::Array{Float64,1})
# Length for other array = 10^6
X_ray = SharedArray{Float64}(length(Hist_x),length(Hist_y)) #1000x1000 array
@sync begin
for p in procs(X_ray)
@async remotecall_wait(Xk!,p,X_ray,[ρ,GPos,T,Width,M])
end
end
X_ray
end
```

and the computation time for this code was extremely large(>1 days with 7 processors)

Although the number of calculation was large(10^6 * 1000 * 1000), I think it’s … well too long.

Are there any ways to reduce the time for this?