![]() |
Department of
Mathematics and Computer Science |
|
Math 169
|
|
Language: MPI / Parallel Programming |
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!
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.