Searching on a Mesh

5.3.3 Searching on a Mesh

In this section we show how a two-dimensional array of processors can be used to solve the various searching problems described earlier. Consider the n-processor mesh-connected SIMD computer illustrated in Fig. 5.8 for n =

16, where each processor stores one record of the file to be searched. This architecture has the following characteristics:

1. The wire length is constant, that is, independent of the size of the array;

2. the area used is

and

3. the running time per query or maintenance operation is and the period is constant regardless of any assumption about wire delay.

Clearly, this behavior is a significant improvement over that of the tree architecture under the assumption that the propagation time of a signal along a wire is linearly proportional to the length of that wire. (Of course, if the wire delay is assumed to be a constant, then the tree is superior for the searching problem since log n for sufficiently large n.)

In order to justify the statement in 3 regarding the running time and period of query and maintenance operations on the mesh, we describe an algorithm for that architecture that solves the basic query problem; namely, given an integer x, it is required to search the file of records on the field for x. We then show that the algorithm produces a yes or no answer to such a query in

5.3.3.1 Querying.

time. Let us denote by

time and that queries can be processed in

the field of the record held by processor j). The algorithm consists of two stages: unfolding and folding.

it produces an output equal to 1; otherwise

Unfolding. Processor

reads x. If x =

0. It then communicates

x) to If x = or

5.3 Searching

a Random Sequence

Figure

5.8 Mesh-connected computer for searching.

x ) to and respectively. Once

neighbors and

send ( b

x ) and

have been computed, the two column neighbors and

and

and respectively. This unfolding process, which alternates row and column propagation,

until x reaches

Folding. At the end of the unfolding stage every processor has had a chance to "see" x and compare it to the s field of the record it holds. In this

stage, the reverse action takes place. The output bits are propagated from row to row and from column to column in an alternating fashion, right to left and bottom to top, until the answer emerges from P ( l , 1). The algorithm is given as procedure MESH SEARCH:

procedure MESH SEARCH (S, x, answer) Step 1:

1) reads the input)

if x =

then b,,, else

end if. Step 2: {Unfolding}

for i = 1 to

- 1 do (2.1) for j= 1 to i do in parallel

(i)

i) transmits

, or = 1) then , ,

x) to

(ii) if ( X =

end if

Searching Chap. 5

(2.2) for j

1 to i + 1 do in j) transmits

x)

or

then else

end if end for

end for. Step

3: {Folding} for i =

2 do

(3.1) for j = 1 t o i do in parallel

i) transmits

to

end for (3.2) for j =

1 to i - 1 do in parallel

end for (3.3) if

or

else

end if (3.4) for j = 1 to i-

1 do in parallel

j) transmits

to P(i -

end for (3.5) for j = 1 to i

2 do in parallel

else end if

end for. Step 4:

produces the output}

if

1 then answer

1 and 4 takes constant time and steps 2 and 3 consist of - 1 constant-time iterations, the time to process a query is

As each of steps

Notice that after the first iteration of step 2, processor

is free to receive a new query. The same remark applies to other processors in subsequent iterations. Thus queries can be

processed in pipeline fashion. Inputs are submitted to at a constant rate. Since the answer to a basic query is of fixed length, outputs are also produced by P(l, 1) at a constant rate following the answer to the first query. Hence the period is constant.

Example 5.3 Let a set of

16 records stored in a 4 x 4 mesh-connected SIMD computer be as shown in Fig.

5.9. Each square in Fig. represents a processor and the number inside it is the

5.3 Searching a Random Sequence

Figure 5.9 Searching sequence of sixteen elements using procedure SEARCH.

field of the associated record. Wires connecting the processors are omitted for simplicity. It is required to determine whether there exists a record with field equal to 15

= 15). Figures illustrate the propagation of 15 in the Figure shows the relevant b values at the end of step 2. Figures

illustrate the folding process. Finally Fig.

shows the result as produced in step 4. Note that in Fig. processor

is shown empty indicating that it has done its job propagating 15 and is now ready to receive a new query.

Some final comments are in order regarding procedure M E S H SEARCH.

1. N o justification was given for transmitting along with x during unfolding stage. Indeed, if only one query is t o be answered, n o processor needs t o communicate its b value to a neighbor: All processors can compute and retain their outputs; these can then be combined during the folding stage. However, if

132 Searching Chap. 5 several queries are to be processed in pipeline fashion, then each processor must

first transmit its current b value before computing the next one. In this way the are continually moving, and no processor needs to store its

b value.

2. When several queries are being processed in pipeline fashion, the folding stage of one query inevitably encounters the unfolding stage of another. As we did for the tree, we assume that a processor simultaneously receiving data from opposite

directions can process them in a single time unit or that every processor alternately switches its attention from one direction to the other.

3. It should be clear that all variations over the basic query problem described in section

5.3.2.1 can be easily handled by minor modifications to procedure MESH SEARCH.

5.3.3.2 Maintenance. All three maintenance operations can be easily implemented on the mesh.

1. Insertion Each processor in the top row of the mesh keeps track of the number of unoccupied processors in its column. When a new record is to be inserted, it is propagated along the top row until a column is found with an unoccupied

processor. The record is then propagated down the column and inserted in the first unoccupied processor it encounters. The number of unoccupied processors in that

column is reduced by 1.

2. Updating All records to be updated are first located using procedure MESH SEARCH and then the change is implemented.

3. Deletion When a record is to be deleted, it is first located, an indicator is placed in the processor holding it signifying it is unoccupied, and the count at the processor in the top row of the column is incremented by 1.