[Santa Clara University]
Department of Mathematics
and Computer Science

Machine Problem 3

Math 169
D. C. Smolarski, S.J.
Fall 2007

                              
Language: MPI / Parallel Programming
30 points
DUE: Noon, Tuesday, November 6, 2007

Gentle Reminder: This program is to be done individually, without any collaboration! See the information found on the web page: General Rules and Other Information.

This program is to be done using MPI with either Fortran or C/C++ code. Since there are more examples on-line with Fortran or C, using those languages would probably be better than using C++. Neither code is very long -- both less than a single page, without many loops -- think carefully first!

Part I - Factorial Problem.

Read in 5 numbers. For the integers between 0 and 10 calculate their square and factorial. Since the system is such that one can only have 3 simultaneous processors active at one time, write the code so that the squares and factorials of the first three numbers are calculated SIMULTANEOUSLY, and then of the last two numbers SIMULTANEOUSLY. (I.e., individual processors work on computing the square and factorial for one specific number.) Print the results as they are computed by individual processors. If the integers are negative or greater than 10 print an appropriate error message. The input file should be 3, -2, 6, 10, 25. Run this code with 3 processors. Run this code twice and turn in two output files (you may capture the outputs via script files).

Part II - LANGUAGE SPECIFIC PROBLEM.

Use MPI (or Path Pascal) to implement PARALLEL DOT PRODUCT.

Recall that if x = (x1,x2,x3) and y = (y1,y2,y3), then the dot product of x and y is x1y1 + x2y2 +x3y3.

In this version, broadcast the values of two vectors to various processors, but have each processor only compute one product (associating the subscript number somehow with the processor id-number). Then "reduce" these individual values by a sum-reduction, and print out the final value.

To check your answer, before the "parallel" dot product, code a standard dot product performed by the root process (or use the Fortran 95 library function).

Each vector should be of length 3 and you should run the code with 3 processors. One vector should have values 3i) (i.e., 3, 6, 9) and the other vector should have values 2(4-i) (i.e., 6, 4, 2).


This page is maintained by Dennis C. Smolarski, S.J. dsmolarski@math.scu.edu
© Copyright 2007 Dennis C. Smolarski, SJ, All rights reserved.
Last changed: 16 October 2007.