程序代写代做代考 Shared Memory Jacobi psuedocode:

Shared Memory Jacobi psuedocode:
const TOLERANCE = …
main() {
double A[n,n], B[n,n]
double maxdiff = 0.0
bool done := false
initialize A, B
co id := 0 to P-1 {
double diff
int startrow := id * n / P
int endrow := (id+1) * n / P – 1
while not done {
for i := 1 to n-2 { forj:=1ton-2 {
A[i][j] := (B[i][j-1] + B[i][j+1] + B[i-1][j] + B[i+1][j]) / 4 diff := abs(A[i][j] – B[i][j])
< if (maxdiff < diff) maxdiff = diff >
} }
barrier // needed?
if (id == 0)
if maxdiff < TOLERANCE done := true else { swap(A,B) maxdiff := 0 } barrier // needed? } print out answer }