Copy of Parallel Graph Algorithms

download Copy of Parallel Graph Algorithms

of 17

Transcript of Copy of Parallel Graph Algorithms

  • 8/14/2019 Copy of Parallel Graph Algorithms

    1/17

    [1]NationalInstitute ofScience& Technology

    Parallel Graph Algorithms

    Anshuman Chakraborty

    A technical Seminar onParallel Graph Algorithms

    Anshuman Chakraborty

    CS200118214under the guidance of

    Anisur Rahman

    By

  • 8/14/2019 Copy of Parallel Graph Algorithms

    2/17

    [2]NationalInstitute ofScience& Technology

    Parallel Graph Algorithms

    Anshuman Chakraborty

    What is Parallel Processing? Parallel processing is processing a

    task with several processing units, or

    many processors Most powerful computers containtwo or more processing units thatshare among themselves the jobssubmitted for processing

  • 8/14/2019 Copy of Parallel Graph Algorithms

    3/17

    [3]NationalInstitute ofScience& Technology

    Parallel Graph Algorithms

    Anshuman Chakraborty

    Why Parallel processing? Several operations are performedsimultaneously, so the time taken by a

    computation can be reduced. A problem to be solved is broken into a

    no.of subproblems. These subproblems arenow solved simultaneously, each ondifferent processors. The results are then

    combined to produce an answer to theoriginal problem. To achieve speedup of processing

  • 8/14/2019 Copy of Parallel Graph Algorithms

    4/17

    [4]NationalInstitute ofScien

    ce& Technology

    Parallel Graph Algorithms

    Anshuman Chakraborty

    Speedup of Computation Sppedup is measured in contrast with sequential

    version of the same algorithm

    speedup =ws/wp where ws=worst case running

    time of fastest known sequential algorithm for the problem and wp= worst case running time of the parallel algorithm for the same problem.

    Pipelines have been extensively used in processorsto increase the performance.

  • 8/14/2019 Copy of Parallel Graph Algorithms

    5/17

    [5]NationalInstitute ofScien

    ce& Technology

    Parallel Graph Algorithms

    Anshuman Chakraborty

    Computational Model The stream of instruction tells the computer what to do at eachstep and are divided into four types:1. Single Instruction stream, single Data stream (SISD)2. Multiple Instruction stream, Single Data stream(MISD)3. Single Instruction stream, Multiple Data stream(SIMD)

    4. Multiple Instruction stream, Multiple Data stream(MIMD )

  • 8/14/2019 Copy of Parallel Graph Algorithms

    6/17

    [6]NationalInstitute ofScien

    ce& Technology

    Parallel Graph Algorithms

    Anshuman Chakraborty

    Introducing Graph

    A graph consists of afinite set of nodes and

    a finite set of edgesconnecting pairs of these nodes

    One graph can berepresented either byan adjacency matrix or adjacency list

  • 8/14/2019 Copy of Parallel Graph Algorithms

    7/17

  • 8/14/2019 Copy of Parallel Graph Algorithms

    8/17[8]NationalInstitute ofScien

    ce& Technology

    Parallel Graph Algorithms

    Anshuman Chakraborty

    The connectivity matrix contd

    Procedure: CUBE CONNECTIVITY (A, C)

    Step 1 : {The diagonal elements of the adjacency matrix are made equal to 1}

    for j = 0 to n -1 do in parallel

    A(0, j, j) 1end for.

    Step 2 : {The A registers are copied into the B registers}

    for j = 0 to n-1 do in parallel

    for k = 0 to n-1 do in parallel

    B(0, j, k)

  • 8/14/2019 Copy of Parallel Graph Algorithms

    9/17[9]NationalInstitute ofScien

    ce& Technology

    Parallel Graph Algorithms

    Anshuman Chakraborty

    The connectivity matrix contdStep 3 : {The connectivity matrix is obtained through repeated Boolean

    multiplication)

    for i = 1 to [log(n - 1)] do[3.1] CUBE MATRIX MULTIPLICATION (A, B, C)

    [3.2] for j=0 to n-1 do in parallelfor k = 0 to n -1 do in parallel

    (i)A(0, j, k) C(0, j, k)(ii) B(0, j ,k) C(0, j, k)

    end for

    end for end for It takesO(log n) time. This step is iterated (log n) times. It follows that the

    overall running time of this procedure is t (n) = O (log 2 n).

  • 8/14/2019 Copy of Parallel Graph Algorithms

    10/17[10]NationalInstitute ofScien

    ce& Technology

    Parallel Graph Algorithms

    Anshuman Chakraborty

    All pair shortest path Let d

    k ij denote the length of the shortest path from v i to v j that goes through at most k-1 intermediate

    vertices.

    Thus d1

    ij =w ij ,(the weight of the edge from v i to v j.

    d1

    ij = . Also d 1ii=0. G has no cycles of negative line, there is no advantage in visiting any vertex more thanonce in a shortest path from v i to v j

    In order to compute for k > 1 we can use the fact that

    dk

    ij = min l{d k/2 il+d k/2 lj }and d ij =d n-1 ij

    The procedure runs on a cube-connected SIMD computer with N = n3 processors, each with three registers

    A, B, and C. As before, the processors can be regarded as being arranged in an (n x n x n) array pattern.

  • 8/14/2019 Copy of Parallel Graph Algorithms

    11/17[11]NationalInstitute ofScien

    ce& Technology

    Parallel Graph Algorithms

    Anshuman Chakraborty

    All Pair Shortest Path algo

    Procedure CUBE SHORTESTPATHS (A, C)

    Step 1: (Construct the matrix D 1 andstore it in registers A and B)

    for j = 0 to n-1 do in parallel

    for k = 0 to n-1 do in parallel

    if j!=k and A(0, j, k) = 0

    then A(0, j, k) = Inf

    end if

    [1.2] B(0, j, k) = A(0, j, k)

    end for

    end for

    Slep 2: (Construct the matrices D 2, D 4,.., D n-1 through repeated matrixmultiplication}

    for i = l to log(n-1) do

    [2.1] CUBE MATRIXMULTIPLICATION (A, B, C)[2.2] for j = 0 to n-1 do in parallel for k = 0 lo n-1 do in parallel [1]A(0, j, k )=C(0, j, k)

    [2]B(0, j, k) =C(0, j, k)

    end for end for

    end for.

  • 8/14/2019 Copy of Parallel Graph Algorithms

    12/17[12]NationalInstitute ofScien

    ce& Technology

    Parallel Graph Algorithms

    Anshuman Chakraborty

    All Pair Shortest Path(complexity)

    Steps 1 and 2 take constant time. There are [log(n-1)] iterations of step 2.1 each requiring O(logn)time.

    The overall running time of procedure CUBESHORTEST PATHS is therefore t(n) = O(log 2n).Since p(n)=n 3 ,c(n) = O(n 3log 2n)

    The sequential algorithm takes O(n 3) time

    The speed up = 2 k.k 2 where k=log 2n.

  • 8/14/2019 Copy of Parallel Graph Algorithms

    13/17[13]NationalInstitute ofScien

    ce& Techno

    logy

    Parallel Graph Algorithms

    Anshuman Chakraborty

    Example

  • 8/14/2019 Copy of Parallel Graph Algorithms

    14/17[14]NationalInstitute ofScien

    ce& Techno

    logy

    Parallel Graph Algorithms

    Anshuman Chakraborty

    Computation of All pair Shortest Path

  • 8/14/2019 Copy of Parallel Graph Algorithms

    15/17[15]NationalInstitute ofScien

    ce& Techno

    logy

    Parallel Graph Algorithms

    Anshuman Chakraborty

    Computation of All pair Shortest Path

  • 8/14/2019 Copy of Parallel Graph Algorithms

    16/17[16]

    NationalInstitute ofScien

    ce& Techno

    logy

    Parallel Graph Algorithms

    Anshuman Chakraborty

    Conclusion Graph Theory and algorithms has a very

    wide area of application in practical problems of Networking

    So it is very good if a speed up is achievedin few graph algorithms like finding MSTor finding Transitive Closure

    It is a great experience in doing a Technicalseminar related to Parallel Processing

  • 8/14/2019 Copy of Parallel Graph Algorithms

    17/17[17]

    NationalInstitute ofScien

    ce& Techno

    logy

    Parallel Graph Algorithms

    Anshuman Chakraborty

    Thank You!!!