Lab 2

Lab 2

Broadcast

MPI has a primitive (MPI_Bcast) for performing a broadcast. All processes should call it at the same time to perform a broadcast.

  1. How can you specify which process is the sender ?
  2. Write an MPI code which performs a Broadcast from 0 to all other processes.

All-to-All

We consider p processes, each with an array tab of size p such that tab[rank]=rank et tab[i]=0 pour i!=rank.

  1. Write an MPI program using MPI_BCast so that all processes end up with the same array.

Matrix-vector

  1. Implement the matrix-vector product on a ring
    • Consider a NxN matrix
    • Every process will have a copy of the vector.
    • The matrix is initially divided in blocks of size (N/P)
    • Each node will compute the sub-result
    • All intermediate results will be sent back to processus 0 to display the final result.