Lab05: Matrix Multiply Part 2

Objective
  • Apply parallel techniques to matrix algebra
  • Use MPI_Type_vector to create a new datatype representing the column of the matrix.
  • Send the columns of a matrix to different processors.

    BACKGROUND:

    C stores matrices in "row major" form. For the following matrix:

    1 2 3 4 5
    6 7 8 9 10
    11 12 13 14 15
    16 17 18 19 20
    21 22 23 24 25

  • x[0][3] = 4 (a single element in the matrix, first row, fourth element)
  • x[4][4] = 25 (a single element in the matrix, fifth row, fifth element)
  • x[0] = a reference to 1 2 3 4 5 (the first row)
  • x[3] = a reference to 16 17 18 19 20 (the fourth row)

    "Column major":

    We want a data structure in which we can refer to the columns of the matrix:

  • x[0] = a reference to 1 6 11 16 21 (the first column)
  • x[3] = a reference to 4 8 13 18 23 (the fourth column)

    Assignment for Part 2

    1. Create a matrix of size maxn (from Part 1).
    2. Send each column of the matrix to a different process
    3. Print each column from each process,
      IDENTIFY THE PROCESS THAT IS PRINTING THE COLUMN
    4. As in Part 1, print the entire matrix from process 0

    Help

  • Argo Beowulf Cluster: MPI Commands and Examples, click the link to MPI_Type_vector and read the example program
  • Also use: MPI_Type_commit and MPI_Type_free
  • Read section 5.7 in the Introduction to MPI course at WebCT-HPC