Computer Science 400
Parallel Processing

Siena College
Fall 2008


Lab 4: Multithreaded Matrix-Matrix Multiplication
Due: 5:00 PM, Monday, October 6, 2008


There are several files to turn in for this assignment. They should all be submitted with the turnin utility under the name lab4. Please use the filenames specified and be sure to include your name in each file.

  1. Write a C or C++ program using pthreads that implements a domain decomposition approach to the matrix-matrix multiplication example. However, instead of dividing up the work by rows, your program should divide up the work by assigning square submatrices to each thread. To simplify things, you may assume that the number of threads is a perfect square, and that the square root of the number of threads evenly divides the number of rows and columns in the matrices. You may also define the number of threads as a constant in your program rather than on the command line. You may use one of the demo programs as your starting point. Once your program works, run for 750 × 750 matrices, using 4 threads on the four-processor Solaris node (wetteland). Compare the timings for the compute phase of your submatrix decomposition implementation with those for each of the multithreaded matrix-matrix multiplication examples. Explain the differences in running times. Write your answer to this part in a plain text file lab4.txt.
  2. Convert your program to use OpenMP instead of pthreads. Compare the timings for the compute phase with the other OpenMP matrix-matrix multiply examples. Include a discussion of these results in lab4.txt. Also discuss how OpenMP compares with pthreads in efficiency and ease of programming.

Your submission should include the lab4.txt file and subdirectories named pthreads and openmp, each of which contains an appropriate Makefile, your C or C++ source code (including the timer code from class, if you choose to use it), a brief README file expaining how to run your programs. Please do not include object files or your executable.

Academic honesty guidelines: While the programming is to be done

individually, I want to encourage you to ask questions and discuss the program with me and with each other as you develop it. However, no sharing of code is permitted. If you have any doubts, please check first and avoid honor code problems later.

Grading guidelines: Your grade for the programming will be

determined by correctness, design, documentation, and style, as well as the presentation of your timing results.