Basic PRAM algorithms - PowerPoint PPT Presentation

About This Presentation
Title:

Basic PRAM algorithms

Description:

The Common CRCW rule allows concurrent ... minima in the blocks. Complexity. We can compute minimum of n numbers using CRCW PRAM model in O(log log n) with n ... – PowerPoint PPT presentation

Number of Views:133
Avg rating:3.0/5.0
Slides: 10
Provided by: IgorPo
Category:

less

Transcript and Presenter's Notes

Title: Basic PRAM algorithms


1
Basic PRAM algorithms
  • Problem 1. Min of n numbers
  • Problem 2. Computing a position of the first one
    in the sequence of 0s and 1s.

2
Basic techniques for CRCW PRAM
  • The Common CRCW rule allows concurrent writes
    only when all the processors attempting to write
    into a common memory location are trying to write
    the same value.
  • Problem 1. Min of n numbers
  • Sequential solution linear time
  • Parallel optimal solution constant time and
    linear
  • number of processors.

3
The following program computes MIN of n numbers
stored in the array C1..n in O(1) time with n2
processors.
  • Algorithm A1
  • for each 1? i ? n do in parallel
  • Mi0
  • for each 1? i,j ? n do in parallel
  • if i?j Ci ? Cj then Mj1
  • for each 1? i ? n do in parallel
  • if Mi0 then outputi

4
Let us reduce a number of processors
  • Assume that we have an algorithm Ak working in
    O(1) time with processors
  • Algorithm Ak1
  • 1.Let ?1/2
  • 2. Partition the input array C of size n into
    disjoint
  • blocks of size n? each
  • 3. Apply in parallel algorithm Ak to each of
    these blocks
  • 4. Apply algorithm Ak to the array C
    consisting of n/ n?
  • minima in the blocks.

5
Complexity
  • We can compute minimum of n numbers using CRCW
    PRAM model in O(log log n) with n processors by
    applying a strategy of partitioning the input
    into pieces of size
  • ParCost n ? log log n

6
Problem 2. Computing a position of the first one
in the sequence of 0s and 1s.
  • FIRST-ONE-POSITION(A)4 for the input array
  • A0,0,0,1,0,0,0,1,1,1,0,0,0,1
  • Algorithm A (2 parallel steps and n2 processors)
  • for each 1? iltj ? n do in parallel
  • if Ai 1 and Aj1 then Aj0
  • for each 1? i ? n do in parallel
  • if Ai 1 then FIRST-ONE-POSITIONi

7
Reducing number of processors
  • Algorithm B
  • it reports if there is any one in the table.
  • There-is-one0
  • for each 1? i ? n do in parallel
  • if Ai 1 then There-is-one1

8
Now we can merge two algorithms
  1. Partition table A into segments of size
  2. In each segment apply the algorithm B
  3. Find position of the first one in these sequence
    by applying algorithm B
  4. Apply algorithm A to this single segment and
    compute the final value

9
Complexity
  • We apply twice algorithm A each time to the array
    of length
  • which need only ( )2 n
    processors
  • The time is O(1) and number of processors is n.
Write a Comment
User Comments (0)
About PowerShow.com