• Keine Ergebnisse gefunden

Exercise2(MatrixMultiplicationforAPSP, 5Credits ) Exercise1(MatrixVectorMultiplication, 5Credits ) DueDate11.06.2014 AssignmentonMassivelyParallelAlgorithms-Sheet6

N/A
N/A
Protected

Academic year: 2021

Aktie "Exercise2(MatrixMultiplicationforAPSP, 5Credits ) Exercise1(MatrixVectorMultiplication, 5Credits ) DueDate11.06.2014 AssignmentonMassivelyParallelAlgorithms-Sheet6"

Copied!
3
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Prof. G. Zachmann A. Srinivas

University of Bremen School of Computer Science

CGVR Group May 28, 2014

Summer Semester 2014

Assignment on Massively Parallel Algorithms - Sheet 6

Due Date 11. 06. 2014

Exercise 1 (Matrix Vector Multiplication, 5 Credits)

In the given FrameworkMatrixVectorMul Matrix A is stored using a row major order.

Your tasks are the following:

a) Implement a Matrix Vector multiplication kernel for the above Matrix stored in row major order.

b) Implement a method to store the above Matrix in column major order and then modify the above Matrix vector multiplication kernel to handle matrix stored in column major order .

c) Compare run times between the above two implementations (row major order vs column major order) for different Matrix sizes and provide arguments for the differences/similarities between run times for these two implementations .

Exercise 2 (Matrix Multiplication for APSP, 5 Credits)

Given a directed graphG = (V, E) with distance function dist : E → R,|V| =n where V is the vertices (or nodes) set andE edges set. The adjacency Matrix of the above given directed graph is defined as follows:

n×nmatrixA= (δij) of edge distances :

δij =





dist(vi, vj), if (vi, vj)∈E

∞, if (vi, vj)∈/E

0, ifi=j

(1)

GivenD1=A, compute a series of matricesD2, D3, ..., Dn−1( generated by algorithmEXT EN D− P AT H(Dm−1, A) see Algorithm 2 ), where Dk = (dkij) form= 1,2, ..., n−1 contains the shortest path distances between each pair of verticesvi, vj with at mostkedges Then the final matrixDn−1 contains actual shortest path distances. Simple algorithm for computingDn−1see Algorithm 1 The given APSP framework computes the matrix product of two matricesA (8×8) and B (8×8) and then resulting matrixC=cij is displayed using color coding as follows.

colorij =









(r= 0, g= 0, b= 0) ifcij = 0 (r= 2∗cij/20, g= 0, b= 0), if 0< cij ≤10 (r= 1.0, g=cij/20, b= 0), if 10< cij ≤20 (r= 0, g= 1.0, b= 0), ifcij >20

(2)

1

(2)

Algorithm 1Slow APSP Algorithm

1: procedureSLOW-APSP(A)

2: D1←A

3: fork←0ton−1do

4: Dk←EXTEND-PATH(Dk−1, A)

5: end for

6: returnDn−1

7: end procedure

Algorithm 2Method for computing the next D matrix

1: procedureEXTEND-PATH(D, A)

2: D=dijis an n×nmatrix

3: fori←1ton do

4: forj←1ton do

5: dij ← ∞

6: forl←1 tondo

7: dij ←min(dij, dillj)

8: end for

9: end for

10: end for

11: returnD

12: end procedure

1

0

2

3 4

5

6

7

6

4 5

2 9

3

7

6 3

5 3

5

Figure 1: Graph

2

(3)

Your task is to modify theAPSP framework in order to compute the shortest path matrix for the graph given above see Figure 1.You needfreeglutfor the framework. For installation please see the slides from the first tutorial.

Hint: Please note that the tiled version of Matrix Multiplication is used in the above given framework and use the similarities between algorithm EXTEND-PATH and Matrix multiplication algorithm to modify the above framework for computing All pairs shortest path as discussed in the lecture..

3

Referenzen

ÄHNLICHE DOKUMENTE

The fan shot generates an equally distributed field of rays (see Figure 2), starting from the start vector, for the x and z axis (these are two vectors perpendicular to direction

F¨ ur kd-Trees gilt dies nicht: Zeigen Sie, dass es keine Konstante c gibt, so dass f¨ ur jedes Paar sich nicht schneidender Liniensegmente ein kd-Tree von maximaler Gr¨ oße

Include the X3D models ” GiftBox2.x3d”, ”GiftBox3.x3d” and ” kugel.x3d” (these files are available on the lecture website in frameworks column in

Please compare the following categories of VR displays: fish tank VR display (i.e., stereoscopic moni- tor, please specify whether you consider autostereo or with glasses),

The fan shot generates an equally distributed field of rays (see Figure 2), starting from the start vector, for the x and y axis (applying the above illustrated scheme), whereas z

[r]

Fachbereich Mathematik und

The protocol of Gennaro, Rabin and Rabin (1998) is a well known and efficient protocol for the secure multiparty multiplication of two polynomially shared values over Z q with a