25
PARALLEL JACOBI ALGORITHM Rayan Alsemmeri Amseena Mansoor

Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Embed Size (px)

Citation preview

Page 1: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

PARALLEL JACOBI ALGORITHM

Rayan AlsemmeriAmseena Mansoor

Page 2: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

LINEAR SYSTEMSJacobi method is used to solve linear systems

of the form Ax=b, where A is the square and invertible.

Recall that if A is invertible there is unique solution

Page 3: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

METHODS SOLVE LINEAR SYSTEMSDirect solvers

Gaussian eliminationLU decomposition

Iterative solversStationary iterative solvers

Jacobi Gauss-Seidel Successive over-relaxation

Non-Stationary iterative methods Generalized minimum residual (GMRES) Conjugate gradient

Page 4: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Direct vs Iterative Direct Method -Dense systems Gaussian Eliminations Changes sparsity pattern -introduces non-zero entries which

were originally zero Iterative Method Sparse systems(usually come in very large size)Jacobi method:Main source is numerical approximation of PDE

-

Page 5: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

ITERATIVE METHODSStarts with an initial approximation for the

solution vector (x0)

At each iteration algorithm updates the x vector by using the sytem Ax=b

During the iterations coefficient A, matrix is not changed so sparsity is preserved

Each iteration involves a matrix-vector product

If A is sparse this product is efficiently done

Page 6: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Jacobi Algorithm The first iterative technique is called the Jacobi method. This method makes two assumptions: First, the system given by

has a unique solution

Page 7: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Jacobi MethodThe coefficient matrix A has no zeros on its main diagonal. If any of the diagonal entries are zero, then rows or columns must be interchanged to obtain a coefficient matrix that has nonzero entries on the main diagonal.To begin the Jacobi method, solve the first equation for x1, the second equation for x2and so on, as follows.

Page 8: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

How to apply the jacobi method

Continue the iterations until two successive approximations are identical when rounded tothree significant digits.To begin, write the system in the form

Page 9: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Example of Jacobi

Page 10: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Stopping CriteriaDifference between two consecutive

approximations component wise is less than some tolerance

There exist other ways of computing distance between two vectors, using norms

Page 11: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Jacobi iteration

nnnnnn

nn

nn

bxaxaxa

bxaxaxa

bxaxaxa

2211

22222121

11212111

0

02

01

0

nx

x

x

x

)(1 0

11022

011

1 nnnnnn

nnn xaxaxaba

x

Page 12: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

SEQUENTIAL JACOBI ALGORITHM

))((11 kk xULbDx

bAx

ULDA

D is diagonal matrixL is lower triangular matrixU is upper triangular

matrix

Page 13: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Pseudo Code for JacobiX-new //new approximationX-old//previous approximationTol//given(specified by the number)Counter=0//counts number of iterationsIter-max//maximum number of iterations(specified by problem)

While(diff>tol &&counter<iter_max){X_new=D-1(b-(L+u)X_old);Diff=X_new-X_old;X_old=X_new;Counter=counter+1;}

Page 14: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Does Jacobi Always Converge?As k,under what conditions on A the

sequence {xk} converges to the solution vector

For the same A matrix, one method may converge while the other may diverge

Page 15: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Example of Divergence

Page 16: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

How to guarantee the convergenceThe coefficient matrix of A should be strictly

diagonally dominant matrixIf the coefficient matrix of A is not strictly

diagonally dominant matrix we can exchange the rows to keep it strictly diagonally dominant

𝑎11 𝑎 12 𝑎 13𝑎 21 𝑎 22 𝑎 23𝑎 31 𝑎 32 𝑎 33

+…….

+…….

+…….

Page 17: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Theorem If A is strictly diagonally dominant, then the

system of linear equations given by, has a unique solution to which the Jacobi method will converge for any initial approximation

Page 18: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Parallel Implementations of Jacobi Algorithm

))((11 kk xULbDx

Xk+1 D-1 b L+U XK

-

Page 19: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Parallel Jacobi Algorithm

Row wise Matrix Vector multiplicationShared-memory parallelization very

straightforwardConsider distributed memory machine using

MPI

Page 20: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Row wise with shared memoryXk+1 D-1 b L+U XK

-

Page 21: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Pseudo code of Jacobi distributed memory systems1. Distribute D-1,b,L+U row wise at each node2. Distribute initial guess X0 to all nodes3. Perform Jacobi iterative at each node to

compute corresponding parts4. Broadcast all parts of new approximation to

the master process(Let us say p=0)5. Distribute new approximation to all nodes

row wise6. Repeat from 3

Page 22: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Complexity

The most expensive part is matrix vector multiplication which is of order O(n2)

But, with p-threads we have the complexity O(n2/p)

Page 23: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

ConclusionEasier implementation in shared memoryVarious Distribution schemes for distributed

system(block-cycle)Modifications of Jacobi Method -Gauss Seidel & Successive Over

Relaxation(SOR)

Page 25: Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible

Thank You!!!!!!