/* * example program for CDA5125 * * To compile: gcc -O3 my_mm.c * * To run: ./a.out matrix_size iter method * Example: to perform matrix multiplication of 1024x1024 matrices * 2 times using method 0 -- './a.out 1024 2 0' * * Note: This program assumes that the matrix size is a multiple of 16 * and does not deal with the cases when the size is not a multiple * of 16. */ #include #include #include #include struct timeval t1, t2; void naive_mm(int size, double *a, double *b, double *c) { int i, j, k; for (i=0; i= 4) method = atoi(argv[3]); srand48(100); A = (double *)malloc(N*N*sizeof(double)); B = (double *)malloc(N*N*sizeof(double)); C = (double *)malloc(N*N*sizeof(double)); W = (double *)malloc(N*N*sizeof(double)); for (i=0; i