Hello! I’m trying to parallelize this jacobi code but it is not working, can someone help me, please?
using Distributed
addprocs(2)
@everywhere using LinearAlgebra
@everywhere using DistributedArrays
@everywhere n=5
@everywhere m=n^2
I=Diagonal(ones(n,n))
A = Tridiagonal([fill(-1, n-2); -1], fill(2, n), [-1; fill(-1, n-2);])
A=kron(A,I)+kron(I,A)
b=ones(m,1)
x=ones(m,1)
d=ones(m,1)
A=distribute(A; dist=(2,1))
b=distribute(b; dist=(2,1))
x=distribute(x; dist=(2,1))
d=distribute(d; dist=(2,1))
@everywhere maxit=10
#@everywhere dx=[]
diagon =Diagonal(A)
@sync begin
for k in 1:maxit
for i in 1:length(localindices[1])
localpart[d][i]=diagon[i,i]
end
dx = (b-A*x)./d
x = x+dx
if norm(dx)< 0.00001
break
end
end
end
x