Академический Документы
Профессиональный Документы
Культура Документы
Overview
Example | PageRank
Googles search algorithm works with PageRank
For each web-page a weight (PageRank) is computed.
The weight is higher when more sides point/linked to this
page.
The weight is even higher, when the linked pages have
higher weights
Thus, the weight PRi of page i computes from the weight
PRj of the linked web-pages j.
Is page j linked to cj web-pages, the weight PRj is
distributed over these linked pages
Patent US6285999: Method for node ranking in a linked database
. Registered 10.01.1997 by Lawrence Page.
29.06.2015 Thorsten Grahs Parallel Computing I SS 2015 Seite 7
Example | PageRank
with d=0.85.
Example | PageRank
This gives rise to the following recursive formula
X PRj
1d
PRi =
+d
n
cj
j(j,i)
Example | PageRank
This system leads to the Eigenvalue problem
PT (PR) = PR
Matrix-matrix multiplication
Series of inner product (dot product) operations
Block-matrix computation
Block-matrix computation
Communication of B
Communication of B (cont.)
Communication of B (cont.)
Communication of B (cont.)
Complexity
Algorithm has p iterations
During each iteration a process multiplies
(n/p) (n/p) block of A by (n/p) n block of B,
i.e. multiplications per processor: O(n3 /p2 )
Total computation time O(n3 /p)
Each process ends up passing
(p 1)n2 /p = O(n2 ) elements of B
Weakness
Each process must access every element of matrix B
Ratio of computations per communication is poor:
only 2n/p
29.06.2015 Thorsten Grahs Parallel Computing I SS 2015 Seite 19
Cannons algorithm
Compute C = A B.
A, B RNN
Alignment
Alignment
Matrix A
The block-rows of matrix A are shifted to the left
This has to be be done for each row, until the diagonal
blocks are placed in the first column.
Matrix B
The block-columns of matrix B are shifted upwards
This has to be be done for each columns, until the diagonal
blocks are placed in the first row.
B(j+i)% P,j
Columns j is shifted j-times upwards
29.06.2015 Thorsten Grahs Parallel Computing I SS 2015 Seite 22
Alignment phase
Before
After alignment
Example
Starting point
Example
Rotation
Example | Iteration
12
3
4
5
6
7
8
/* Matrix rotation A */
MPI_Cart_shift(comm_2d, 0, -mycoords[0], &shiftsource, &
shiftdest);
MPI_Sendrecv_replace(a, nlocal*nlocal, MPI_DOUBLE,
shiftdest, 77, shiftsource, 77,comm_2d, &
status);
/* Matrix rotation B */
MPI_Cart_shift(comm_2d, 1, -mycoords[1], &shiftsource, &
shiftdest);
MPI_Sendrecv_replace(b, nlocal*nlocal, MPI_DOUBLE,
shiftdest, 77, shiftsource, 77, comm_2d, &
status);
Cartesian topology
Each process is connected to its neighbours in a virtual
grid
Boundaries can be cyclic
Processes can be identified by Cartesian coordinates
Cartesian example
1
MPI_Comm vu;
2
3
4
5
6
7
8
period[0]=TRUE;
period[1]=FALSE;
reorder=TRUE;
9
10
11
MPI_Cart_create(MPI_COMM_WORLD,
2,dim,period,reorder,&vu);
Cartesian example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Neighbouring ranks
output
Proc. at position (3,1) has rank 10
P:5 My coordinates are 1 2
Computing ranks of neighbouring processors
int MPI_Cart_shift (MPI_Comm comm, int direction,
int disp, int *rank_source, int *rank_dest)
Does not actually shift data: returns the correct ranks for a
shift that can be used in subsequent communication calls
Neighbouring ranks
Arguments
direction dimension in which the shift should be made)
disp (length of the shift in processor coordinates [+ or -])
rank_source (where calling process should receive a
message from during the shift)
rank_dest (where calling process should send a
message to during the shift)
Non-periodic case (period[i]=false)
If we shift off the topology, MPI_Cart_shift returns
MPI_Proc_null i.e. (1) for processors outside the
interval [0, n].
29.06.2015 Thorsten Grahs Parallel Computing I SS 2015 Seite 39