/* * Parallel Matrix Multiplication Program * * Doug Hoyte, 2003 * */ #include #include #include #include #include "mpi.h" /* Timer for the *C*omputation */ double cstartwtime,cstopwtime; /* Timer for how long the whole procedure *A*ctually took */ double astartwtime,astopwtime; void printmatrix(FILE *outfp, int m, int n, float *mat) { int i,j; for(i=0; i \n\n",argv[0]); fprintf(stderr, " This program computes A * B matrix multiplication in parallel using MPI.\n"); fprintf(stderr, " If outfile is '-' then the answer will be printed on stdout.\n"); MPI_Finalize(); return 0; } f1 = argv[1]; f2 = argv[2]; f3 = argv[3]; } astartwtime = MPI_Wtime(); res = multmatrices(f1, f2, f3); astopwtime = MPI_Wtime(); if (trank == 0) { if (res == 0) { fprintf(stderr, "\nMatrix Multiplication Failed...\n"); } else { fprintf(stdout, "\nMatrix multiplication done.\n"); fprintf(stdout, "%f seconds of computation, %f total seconds\n", cstopwtime-cstartwtime, astopwtime-astartwtime); } } MPI_Finalize(); return 0; }