Jacobi iteration, using HPF: 



REALX(N.N). Y(N.N) 

 !HPF$ DISTRIBUTE (*,BLOCK)::X,Y 



FORALLi J = 2 : N-l ) 



FORALL( 1 = 2 : N-l ) 

 Xd.J) = 0.25 * (Y(I-I.J) + Y(I+1,J) + Y(I.J-l) + Y(I.J+1) 



END FORALL 

 END FORALL 



Jacobi iteration, using message passing: 



REAL X(N.N_OVER_P). Y(N.0:N_OVER_P-i-l) 



IF(MY_ID.NE. OiTHEN 



SEND( Y(LN.l). MYJD-1 ) 

 END IF 

 IF(MY_ID.NE. P-DTHEN 



SEND( Y(LN.N_OVER^P). MY_ID+1 ) 

 END IF 

 IF (MYJD.NE. P-DTHEN 



RECEIVE{ Y(LN.N_0VER_P+1). MYJD-t-l ) 

 END IF 

 IF(MY_ID.NE. 0)THEN 



RECEIVE( XlLN.O). MY_ID-1 ) 

 END IF 

 LOW= I 



IF{MY_ID.EQ. 0)LOW=2 

 HIGH = N_OVER_P 



IF (MYJD .EQ. P- 1 ) HIGH=N_OVER_P- 1 

 DO J = LOW.HIGH 



DO I = 2. N-l 

 X(I.J) = 0.25 * (Y(l-l.J) -1- YdH-l.J) + Y(I.J-l) -F Y(I.J-Hl)) 



END DO 

 END DO 



These code segments both perform square mesh Jacobi relaxation on a distributed memory parallel com- 

 puting system. 



157 



