Changeset 5710 in /cluster/svnroot
 Timestamp:
 May 26, 2016 8:24:55 PM (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

bccdng/bwinstitute/2016/day06/matmul/mpi.c
r5709 r5710 12 12 unsigned int start_row,stop_row,stride; 13 13 bool print; 14 struct matrix m1,m2, dst_m;14 struct matrix m1,m2,local_dst_m; 15 15 16 16 MPI_Init(&argc,&argv); … … 58 58 } 59 59 60 dst_m.rows = m1.rows;61 dst_m.cols = m2.cols;62 60 63 61 m1.matrix = safe_malloc_int( … … 69 67 "Allocating second matrix" 70 68 ); 71 dst_m.matrix = safe_malloc_int(72 dst_m.rows*dst_m.cols,73 "Allocating destination matrix"74 );75 69 76 70 if(rank == FIRST_RANK) { … … 79 73 init_matrix(&m1,random_seeds); 80 74 init_matrix(&m2,random_seeds); 75 76 // Declare and allocate full destination matrix 77 // Will be populated via MPI_Gather 78 struct matrix dst_m; 79 dst_m.rows = m1.rows; 80 dst_m.cols = m2.cols; 81 dst_m.matrix = safe_malloc_int( 82 dst_m.rows*dst_m.cols, 83 "Allocating destination matrix" 84 ); 81 85 82 86 if(print) { … … 102 106 stride = m1.rows/size; 103 107 start_row = rank*stride; 104 stop_row = stride*(rank+1); 108 109 // Assign an even number of rows to each rank, except for the last rank 110 // whiich gets the remainder 111 if(rank<(size1)) { 112 stop_row = stride*(rank+1); 113 } 114 else { 115 stop_row = m1.rows; 116 } 105 117 #ifdef DEBUG 106 118 fprintf(stderr,"Rank %d  Stride %u, start_row %u, stop_row %u\n",
Note: See TracChangeset
for help on using the changeset viewer.