Computer Sciences Dept.

CS/ECE 757 Advanced Computer Architecture II Spring 2005 Section 1
Instructor Mark D. Hill and T. A. Bhavesh Mehta
URL: http://www.cs.wisc.edu/~markhill/cs757/Spring2005/

UNDER CONSTRUCTION

Homework 1 // Due at Lecture Mon Feb 7

You should do this assignment alone. No late assignments.

The purpose of this assignment is to give you experience writing simple programs in shared memory and message passing. This experience will provide a foundation for writing and/or running much more complex programs.

We have given you accounts on 14-processor Sun E6000 named cabernet.cs.wisc.edu. Unless you already had an account, you should only use this machine only for 757 homework assigments or, with instructor's permission, for your course project. In any case, you should never interfere with the research work on this research machine.

Problem 1

Please read Getting Started - Threads with Shared Memory and follow the pthread's option.

(a) Write a shared-memory program that reads in three N x N matrices, multiplies them, and writes the output to a file. Your program should operate in parallel with P processors specified on the command line. It is okay to only handle the just easy cases (e.g., N is multiple of P).

(b) For N a power of two, how big does N have to be for your program to reliably take over one minute in the parallel phase?

(c) Write an improved program that multiplies matrices more rapidly (where N is set to the size of your answer to part (b).

Problem 2

Please read and follow Getting Started - MPI.

(a) Write the same program as in Problem 1 except this time write it using message-passing mechanisms instead of shared memory. You will be using the MPI (Message Passing Interface) standard to implement your message-passing code. You will be able to write C (not C++) code, compile it, and run it on the same machine as Problem 1.

Program Guidelines

  • The matrices should be inputted via text files, one for each matrix. The matrices should have one row on each line of a plain text file, and the columns should be space seperated.
  • Please dynamically allocate the arrays in your program
  • Use the following command-line syntax for the shared memory program:
    <executableName> <NumProcs> <N> <matrixA_file> <matrixB_file> <matrixC_file>
  • Use the following command-line syntax for the MPI program:
    mpirun -np <numProcs> <exeName> <N> <MatrixA_file> <MatrixB_file> <matrixC_file>

What to Hand In

Please turn this homework in on paper at the beginning of lecture.

  • For each program, describe how you parallelized the program and why you chose that approach.
  • Present the analysis asked for in problem 1b
  • Provide runtimes for your programs on matrices large enough to see significant speedups. Always remember to give matrix size and number of processors used.
  • Attach your programs as appendices.

 
Computer Sciences | UW Home