<< Chapter < Page | Chapter >> Page > |
* Compute my geometry - What subset do I process? (INUM=0 values)
* Actual Column = OFFSET + Column (OFFSET = 0)* Column 0 = neighbors from left
* Column 1 = send to left* Columns 1..mylen My cells to compute
* Column mylen = Send to right (mylen=50)* Column mylen+1 = Neighbors from Right (Column 51)IAMFIRST = (INUM .EQ. 0)
IAMLAST = (INUM .EQ. NPROC-1)OFFSET = (ROWS/NPROC * INUM )
MYLEN = ROWS/NPROCIF ( IAMLAST ) MYLEN = TOTCOLS - OFFSET
PRINT *,’INUM:’,INUM,’ Local’,1,MYLEN,+ ’ Global’,OFFSET+1,OFFSET+MYLEN* Start Cold
DO C=0,COLS+1DO R=0,ROWS+1
BLACK(R,C) = 0.0ENDDO
ENDDO
Now we run the time steps. The first act in each time step is to reset the heat sources. In this simulation, we have four heat sources placed near the middle of the plate. We must restore all the values each time through the simulation as they are modified in the main loop:
* Begin running the time steps
DO TICK=1,MAXTIME* Set the heat persistent sourcesCALL STORE(BLACK,ROWS,COLS,OFFSET,MYLEN,
+ ROWS/3,TOTCOLS/3,10.0,INUM)CALL STORE(BLACK,ROWS,COLS,OFFSET,MYLEN,
+ 2*ROWS/3,TOTCOLS/3,20.0,INUM)CALL STORE(BLACK,ROWS,COLS,OFFSET,MYLEN,
+ ROWS/3,2*TOTCOLS/3,-20.0,INUM)CALL STORE(BLACK,ROWS,COLS,OFFSET,MYLEN,
+ 2*ROWS/3,2*TOTCOLS/3,20.0,INUM)
Now we perform the exchange of the “ghost values” with our neighboring processes. For example, Process 0 contains the elements for global column 50. To compute the next time step values for column 50, we need column 51, which is stored in Process 1. Similarly, before Process 1 can compute the new values for column 51, it needs Process 0’s values for column 50.
[link] shows how the data is transferred between processors. Each process sends its leftmost column to the left and its rightmost column to the right. Because the first and last processes border unchanging boundary values on the left and right respectively, this is not necessary for columns one and 200. If all is done properly, each process can receive its ghost values from their left and right neighbors.
The net result of all of the transfers is that for each space that must be computed, it’s surrounded by one layer of either boundary values or ghost values from the right or left neighbors:
* Send left and right
IF ( .NOT. IAMFIRST ) THENCALL PVMFINITSEND(PVMDEFAULT,TRUE)
CALL PVMFPACK( REAL8, BLACK(1,1), ROWS, 1, INFO )CALL PVMFSEND( TIDS(INUM-1), 1, INFO )
ENDIFIF ( .NOT. IAMLAST ) THEN
CALL PVMFINITSEND(PVMDEFAULT,TRUE)CALL PVMFPACK( REAL8, BLACK(1,MYLEN), ROWS, 1, INFO )CALL PVMFSEND( TIDS(INUM+1), 2, INFO )
ENDIF* Receive right, then left
IF ( .NOT. IAMLAST ) THENCALL PVMFRECV( TIDS(INUM+1), 1, BUFID )
CALL PVMFUNPACK ( REAL8, BLACK(1,MYLEN+1), ROWS, 1, INFOENDIF
IF ( .NOT. IAMFIRST ) THENCALL PVMFRECV( TIDS(INUM-1), 2, BUFID )
CALL PVMFUNPACK ( REAL8, BLACK(1,0), ROWS, 1, INFO)ENDIF
Notification Switch
Would you like to follow the 'High performance computing' conversation and receive update notifications?