CS 8803 Multicore Computing Homework 4: Parallel Algorithms and PRAM Model, Assignments of Computer Science

Homework problems for the cs 8803 multicore computing course focusing on parallel algorithms and the pram model. Topics include scheduling dags for matrix multiplication, broadcasting data, prefix sums, and cycle graph problems. Students are expected to develop optimal solutions for each problem using the erew and crew pram models.

Typology: Assignments

Pre 2010

Uploaded on 08/05/2009

koofers-user-1vj-1
koofers-user-1vj-1 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Spring 2007
CS 8803 Multicore Computing
Homework 4
1. We have seen how to schedule the DAG corresponding to the standard algorithm for
multiplying two n×nmatrices in O(log n)timeusingn3processors. What is the
optimal schedule for an arbitrary number pof processors, where 1 pn3?Whatis
the corresponding parallel complexity?
2. An item Xis stored in a specific location of the global memory of an EREW PRAM.
Show how to broadcast Xtoallthelocalmemoriesofthepprocessors of the EREW
PRAM in O(log p) time. Determine how much time it takes to perform the same
operation on the CREW PRAM.
3. Develop an optimal nonrecursive prefix-sums algorithm that is similar to the nonre-
cursive prefix-sums algorithm presented in class but that does not use the auxiliary
varia ble s Band C. The input array Ashould hold the prefix sums when the algorithm
terminates.
4. Suppose we are given a set of nelements stored in array Atogether with an array
Lsuch that L(i)∈{1,2,...,k}represents the label of element A(i), where kis a
constant. Develop an optimal O(log n) time EREW PRAM algorithm that stores all
the elements of Awith label 1 into the upper part of Awhile preserving their initial
ordering, followed by the elements labeled 2 with the same initial ordering, and so on.
5. (Segmented Prefix Sums) We are given a sequence A=(a1,a
2,...,a
n)ofelements
from a set Swith an associative operation , and a Boolean array Bof length nsuch
that b1=bn=1. Foreachi1<i
2such that bi1=bi2=1andbj=0foralli1<j <i
2,
we wish to compute the prefix sums of the subarray (ai1+1,...,a
i2)ofA. Develop an
O(log n) time algorithm to compute all the corresponding prefix sums. Your algorithm
should use O(n) operations and should run on the EREW PRAM.
6. Consider a cycle C=(v1,v
2,...,v
n) with an additional set Eof edges between the
vertices of Csuch that, for each vertex vi, there exists at most one edge in Eincident
on vi. Consider the problem of determining whether or not it is possible to draw all the
edges in Einside the cycle Cwithout any two of them crossing. Develop an O(log n)
time algorithm to solve this problem. The total number of operations used must be
O(n). Your algorithm should run on the EREW PRAM model.

Partial preview of the text

Download CS 8803 Multicore Computing Homework 4: Parallel Algorithms and PRAM Model and more Assignments Computer Science in PDF only on Docsity!

Spring 2007 CS 8803 Multicore Computing

Homework 4

  1. We have seen how to schedule the DAG corresponding to the standard algorithm for multiplying two n × n matrices in O(log n) time using n^3 processors. What is the optimal schedule for an arbitrary number p of processors, where 1 ≤ p ≤ n^3? What is the corresponding parallel complexity?
  2. An item X is stored in a specific location of the global memory of an EREW PRAM. Show how to broadcast X to all the local memories of the p processors of the EREW PRAM in O(log p) time. Determine how much time it takes to perform the same operation on the CREW PRAM.
  3. Develop an optimal nonrecursive prefix-sums algorithm that is similar to the nonre- cursive prefix-sums algorithm presented in class but that does not use the auxiliary variables B and C. The input array A should hold the prefix sums when the algorithm terminates.
  4. Suppose we are given a set of n elements stored in array A together with an array L such that L(i) ∈ { 1 , 2 ,... , k} represents the label of element A(i), where k is a constant. Develop an optimal O(log n) time EREW PRAM algorithm that stores all the elements of A with label 1 into the upper part of A while preserving their initial ordering, followed by the elements labeled 2 with the same initial ordering, and so on.
  5. (Segmented Prefix Sums) We are given a sequence A = (a 1 , a 2 ,... , an) of elements from a set S with an associative operation , and a Boolean array B of length n such that b 1 = bn = 1. For each i 1 < i 2 such that bi 1 = bi 2 = 1 and bj = 0 for all i 1 < j < i 2 , we wish to compute the prefix sums of the subarray (ai 1 +1,... , ai 2 ) of A. Develop an O(log n) time algorithm to compute all the corresponding prefix sums. Your algorithm should use O(n) operations and should run on the EREW PRAM.
  6. Consider a cycle C = (v 1 , v 2 ,... , vn) with an additional set E of edges between the vertices of C such that, for each vertex vi, there exists at most one edge in E incident on vi. Consider the problem of determining whether or not it is possible to draw all the edges in E inside the cycle C without any two of them crossing. Develop an O(log n) time algorithm to solve this problem. The total number of operations used must be O(n). Your algorithm should run on the EREW PRAM model.