2.18k likes | 2.75k Views
Parallel and Distributed Algorithms. Overview. Parallel Algorithm vs Distributed Algorithm PRAM Maximal Independent Set Sorting using PRAM Choice coordination problem Real world applications. Introduction. CPUs with 1000 processors. A massively parallel processing machine.
E N D
Overview • Parallel Algorithm vs Distributed Algorithm • PRAM • Maximal Independent Set • Sorting using PRAM • Choice coordination problem • Real world applications
CPUs with 1000 processors A massively parallel processing machine Moore’s law coming to an end Need of distributed processing
Parallel Algorithm • A parallel algorithm is an algorithm which can be executed a piece at a time on many different processing devices, and then combined together again at the end to get the correct result.* * Blelloch, Guy E.; Maggs, Bruce M. Parallel Algorithms. USA: School of Computer Science, Carnegie Mellon University.
Distributed Algorithm • A distributed algorithm is an algorithm designed to run on computer hardware constructed from interconnected processors.* *Lynch, Nancy (1996). Distributed Algorithms. San Francisco, CA: Morgan Kaufmann Publishers. ISBN978-1-55860-348-6.
Random Access Machine • An abstract machine with unbounded number of local memory cells and with simple set of instruction sets • Time complexity: number of instructions executed • Space complexity: number of memory cells used • All operations take Unit time
PRAM (Parallel Random Access Machine) • PRAM is a parallel version of RAM for designing the algorithms applicable to parallel computers • Why PRAM ? • The number of processor execute per one cycle on P processors is at most P • Any processor can read/write any shared memory cell in unit time • It abstracts from overhead which makes the complexity of PRAM algorithm easier • It is a benchmark
Read A[i-1], Computation A[i]=A[i-1]+1, Write A[i] A[0] Shared Memory (A) P1 A[1]=A[0]+1 A[1] A[1] P2 A[2]=A[1]+1 A[2] A[n-1] Pn A[n]=A[n-1]+1 A[n]
Share Memory Access Conflicts • Exclusive Read(ER) : all processors can simultaneously read from distinct memory locations • Exclusive Write(EW) : all processors can simultaneously write to distinct memory locations • Concurrent Read(CR) : all processors can simultaneously read from any memory location • Concurrent Write(CW) : all processors can write to any memory location • EREW, CREW, CRCW
Complexity • Parallel time complexity: The number of synchronous steps in the algorithm • Space complexity: The number of share memory cell • Parallelism: The number of processors used
LahiruSamarakoon SumanarubanRajadurai Maximal Independent Set
Independent Set (IS): Any set of nodes that are not adjacent
Maximal Independent Set (MIS): An independent set that is no subset of any other independent set
a maximal independent set a maximum independent set Maximal vs. Maximum IS
A Sequential Greedy algorithm Suppose that will hold the final MIS Initially
Phase 1: Pick a node and add it to
Phase 2: Pick a node and add it to
Phases 3,4,5,…: Repeat until all nodes are removed
Phases 3,4,5,…,x: Repeat until all nodes are removed No remaining nodes
Running time of algorithm: Worst case graph: nodes
Intuition for parallelization At each phase we may select any independent set (instead of a single node), remove S and neighbors of S from the graph.
Example: Suppose that will hold the final MIS Initially
Phase 1: Find any independent set And insert to :
Phase 2: On new graph Find any independent set And insert to :
Phase 3: On new graph Find any independent set And insert to :
remove and neighbors No nodes are left
Observation: The number of phases depends on the choice of independent set in each phase The larger the independent set at each phase the faster the algorithm
Randomized Maximal Independent Set ( MIS ) Let be the degree of node 2 1
At each phase : Each node elects itself with probability degree of in 2 1 Elected nodes are candidates for the independent set
If two neighbors are elected simultaneously, then the higher degree node wins Example: if
If both have the same degree, ties are broken arbitrarily Example: if
Using previous rules, problematic nodes are removed Problematic nodes
The remaining elected nodes form independent set
Luby’s algorithm mark lower-degree vertices with higher probability
Using previous rules, problematic nodes are removed Problematic nodes
Luby’s algorithm if both end-points of an edge is marked, unmark the one with the lower degree
The remaining elected nodes form independent set
Luby’s algorithm add all marked vertices to MIS remove marked vertices with their neighbors and corresponding edges