for each processor i, in parallel do if next[i] = NIL then d[i] 0 else d[i] 1 while there exists an object i such that next[i] NIL do for each processor i, in parallel do if next[i] NIL then d[i] d[i] + d[next[i]] next[i] next[next[i]]
|
PRAM Recursive Prefix Sum Algorithm Input: Array of (x1, x2, …, xn) elements, n = 2k Output: Prefix sums si, 1 < i < n begin if n = 1 then s1 = x1; exit for 1 < i < n/2 pardo yi := x2i–1 + x2i Recursively compute prefix sums of y and store in z for 1 < i < n pardo if i is even then si := zi/2 if i > 1 is odd then si := z(i–1)/2 + xi if i = 1 then s1 := x1 EREW PRAM can be simulated to run in O(T log p) time by an algorithm that runs in T time on the p-processor priority CRCW PRAM. To execute in O(log p) time, a concurrent reading or writing of a p-processor CRCW PRAM can be implemented on a p processor EREW PRAM. Q1,…,Qp CRCW processors, such that Qi has to read (write) M[ji] P1,…,Pp EREW processors M1,…,Mp denote shared memory locations for special use Pi stores in Mi Sort pairs using the EREW merge sort algorithm in lexicographically non-decreasing order in O(log p) time Representative Pi reads (writes) from M[k] with <k,_> in Mi from each block of pairs having the same firs part in O(1) time and copies data to each M in the block in O(log p) time using EREW segmented parallel prefix algorithm Pi reads data from Mi. For n x n matrix M with non-negative integer coefficients, define M and specify the computational algorithm m. Prove that M cnan is determined at O(log n)time from n x n matrix M using CRCW PRAM processors for any fixed € > 0 Consider the multiplication of n'n matrix C=A B using n3 processors. Each C element cij = Σk=1..n aik bkj CREW PRAM can be calculated in parallel using n processors in O(log n) time All cij can be calculated using n3 processors in O(log n) Matrix multiply with n3 processors (i,j,l) Each processor (i,j,l) executes: Input: n×n matrices A and B, n = 2k Output: C = A B begin C‟[i,j,l] := A[i,l]B[l,j] for h = 1 to log n do if i < n/2h then C‟[i,j,l] := C‟[i,j,2l–1] + C‟[i,j,2l] if l = 1 then C[i,j] := C‟[i,j,1] End |