<< Chapter < Page Chapter >> Page >

Assigning grid elements to processors

This figure is a large chart, with rows and columns that are abbreviated but reach from 1 through 201. Inside, the first and last rows and first and last columns are lined with a B in every corresponding space. Inside this box of B's are cells consistently lined down their columns with values of 1, 2, or 3.

* 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.

Pattern of communication for ghost values

This figure is a flowchart and diagram describing how data is transferred between processors. There are four boxes, lined with letters B or G, and labeled inside as Tasks 1 through 4. Between the boxes are arrows showing movement between them.

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

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, High performance computing. OpenStax CNX. Aug 25, 2010 Download for free at http://cnx.org/content/col11136/1.5
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'High performance computing' conversation and receive update notifications?

Ask