EREW
EREW
1 EREW Searching
Assume that an N-processor EREW SM SIMD computer is available to search S for a given element x, where I < N < n. To begin, the value of x must be made known to all processors. This can be done using procedure BROADCAST in O(log N) time. The sequence S is then subdivided into N subsequences of length n/N each, and processor Pi is assigned {S(i-I)(/IN)+1, S(i-I)(n/N)+2, ... , Sij(/N)}. All processors now perform procedure BINARY SEARCH on their assigned subsequences. This requires O(log(n/N)) in the worst case. Since the elements of S are all distinct, at most one processor finds an Sk equal to x and returns k. The total time required by this EREW searching algorithm is therefore O(log N) + O(log(n/N)), which is O(log n). Since this is precisely the time required by procedure BINARY SEARCH (running on a single processor!), no speedup is achieved by this approach. Oke kalo gitu kenapa pake parallel? EREW PRAM algorithm:
1. P0 broadcasts x to P1,...,Pp in log p steps using binary broadcast tree. 2. All processors perform local searches, each on [ n/p] items in [ n/p] steps. 3. Every processor defines a flag Found and all processors perform a parallel reduction.
T(n,p)=log p + n/p
==== What is the time complexity for the Exclusive-write? Initially elements think that they might be the maximum First iteration: For n/2 pairs, compare. n/2 elements might be the maximum. Second iteration: n/4 elements might be the maximum. log n-th iteration: one element is the maximum. So Fast_max with Exclusive-write takes O(log n). =========
Si
Other Information
a. Asumsikan bahwa N-Prosesor komputer EREW SM SIMD mampu melakukan pencarian S untuk elemen x, dimana I<N<n. b. Nilai x perlu diketahui untuk semua prosesor. Bias menggunakan prosedur broadcast dengan kompleksitas waktu O(log N) c. Membagi sequence S menjadi N subsequence dengan panjang, n/N dan prosesor Pi ditandai dengan {S(i-I)(/IN)+1,S(i-I)(n/N0+2,,Sij(/N)} d. Prosesor melakukan pencarian menggunakan prosedur binary Search, pada subsequence masing masing. e. Satu prosesor satu binary search (mereun) hahahah
--------------- We assume throughout this section that the sequence S = {s1, s2, .. , s} is sorted in nondecreasing order, that is, sI < s2 < . < s". Typically, a file with n records is available, which is sorted on the s field of each record. This file is to be searched using s as the key; that is, given an integer x, a record is sought whose s field equals x. If such a record is found, then the information stored in the other fields may now be retrieved. The format of a record is illustrated in Fig. 5.1. Note that if the values of the s fields are not unique and all records whose s fields equal a given x are needed, then the search algorithm is continued until the file is exhausted. For simplicity we begin by assuming that the si are distinct; this assumption is later removed. We assume throughout this section that the sequence S = {s1, s2, .. , s} is sorted in nondecreasing order, that is, s1 < s2 < < s a file with n records is available, which is sorted on the s field of each record. This file is to be searched using s as the key; that is, given an integer x, a record is sought whose s field equals x
If such a record is found, then the information stored in the other fields may now be retrieved
Figure 5.1 Format of record in file to be searched.
Si
Other Information
Note that if the values of the s fields are not unique and all records whose s fields equal a given x are needed, then the search algorithm is continued until the file is exhausted. For simplicity we begin by assuming that the si are distinct; this assumption is later removed