Re: [mpich-discuss] Matrix dimension
This problem has nothing to do with MPI. You are allocating a lot of memory on the stack. Try allocating the matrix with a bunch of malloc's instead. -- Pavan On 11/22/2012 12:35 PM US Central Time, Alejandro Allievi wrote:
Hi,
The following matrix multiplication code does not execute in my machine for MATRIX_ORDER greater than 400 or so, and I've got plenty of memory. Is there anything I need to tweak in MPI.h for this to work??
Thanks for any help.
Alejandro
#include <stdio.h> #include "mpi.h" /* for the Wtime() function only */
#define MATRIX_ORDER 400
typedef float MATRIX_T[MATRIX_ORDER][MATRIX_ORDER];
void serial_matrix_mult(MATRIX_T A, MATRIX_T B, MATRIX_T C, int n);
int main(int argc, char* argv[]) { MATRIX_T A; MATRIX_T B; MATRIX_T C; int i, j; double start, finish; int p, my_rank;
MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD, &p); MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
for (i = 0; i < MATRIX_ORDER; i++) /* initialize matrices */ for (j = 0; j < MATRIX_ORDER; j++) /* to an arbitrary value */ { A[i][j] = 5; B[i][j] = 5; }
start = MPI_Wtime(); serial_matrix_mult(A, B, C, MATRIX_ORDER); finish = MPI_Wtime();
printf("Elapsed time in seconds is %e\n", finish - start );
MPI_Finalize();
} _______________________________________________ discuss mailing list [email protected] To manage subscription options or unsubscribe: https://lists.mpich.org/mailman/listinfo/discuss
-- Pavan Balaji http://www.mcs.anl.gov/~balaji
participants (1)
-
Pavan Balaji