para18 - Parallel Algorithms IV(18 Parallel Algorithm...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Parallel Algorithm Pseudocode Conventions for Mesh Models – Continued Read/Write Statements We will assume the existence of two parallel I/O statements, read for input and write for output. Suppose, for example, that we have a list of n values stored sequentially in the input device. These n values might be read into a one- dimensional mesh M P by the following statement: for P i , 1 i n do in parallel read ( P i : L ) end in parallel This in parallel statement simultaneously reads the i th value in the external input device into the variable P i : L in the local memory of processor P i , i {1, …, n}. Typically, when using read or write statements in a procedure or function, a dcl statement is included which covers all variables participating in I/O, together with range descriptions when interconnection models are considered (the range variable is not required for PRAM models due to the shared nature of the memory). Also, the terms external input and external output will be utilized in the opening syntax. Algorithms for the Mesh Model As we did for the PRAM model, we now will develop a complete algorithm for searching on the two-dimensional mesh model. Recall from our earlier discussions of this algorithm, that similar to the PRAM algorithm for the same problem, the 2-d mesh algorithm for searching consisted of three distinct phases, the first of which was broadcasting phase in which the value of the search element x was broadcast as a distributed element to all the participating processors. Using the pseudocode that we have developed for the interconnection network models, this algorithm would have the pseudocode shown in Figure 1. Parallel Algorithms IV - 1 Parallel Algorithms IV (18) procedure broadcast2Dmesh (P 1,1 :x, n) model: Two-dimensional mesh M q,q with p = n = q 2 processors input: P 1,1 :x (element to be broadcast) output: P 1,1 :x (element is broadcast to each processor in M q,q ) for i := 1 to q-1 do P 1, i+1 :x P 1, i : x {propagate x to right across first row} endfor for i := 1 to q-1 do for P i, j , 1 j q do in parallel P i+1, j :x P i, j : x {propagate x down row by row} end in parallel endfor end broadcast2Dmesh
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Figure 1 – Parallel pseudocode algorithm for broadcasting in a 2D mesh. The second phase of the algorithm begins after the search value has been broadcast through the distributed variable . Each processor P i, j in parallel compares P i,j : L to P i,j : x and writes the value into P i,j : index if P i,j : L P i,j x . This comparison is accomplished using the pseudocode shown in Figure 2. Figure 2 – Pseudocode to perform the parallel search in the 2d mesh. The third and final phase of the algorithm consists of a reverse broadcast technique to filter the minimum processor index value into processor P 1,1 .
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 11

para18 - Parallel Algorithms IV(18 Parallel Algorithm...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online