Changeset 5709 in /cluster/svnroot
 Timestamp:
 May 26, 2016 8:17:18 PM (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

bccdng/bwinstitute/2016/day06/matmul/mpi.c
r5708 r5709 10 10 int main(int argc,char **argv) { 11 11 int rank,size,c; 12 unsigned int start_row,stop_row,stride; 12 13 bool print; 13 14 struct matrix m1,m2,dst_m; … … 89 90 } 90 91 92 // Broadcast each element of the structs, to avoid the complexity 93 // of creating custom data types 91 94 MPI_Bcast(&m1.rows,1,MPI_INT,FIRST_RANK,MPI_COMM_WORLD); 92 95 MPI_Bcast(&m1.cols,1,MPI_INT,FIRST_RANK,MPI_COMM_WORLD); … … 95 98 MPI_Bcast(m1.matrix,m1.rows*m1.cols,MPI_INT,FIRST_RANK,MPI_COMM_WORLD); 96 99 MPI_Bcast(m2.matrix,m2.rows*m2.cols,MPI_INT,FIRST_RANK,MPI_COMM_WORLD); 97 #ifdef DEBUG98 fprintf(stderr,"Matrix 1 on rank %d\n",rank);99 print_matrix(&m1);100 fprintf(stderr,"\n");101 fprintf(stderr,"Matrix 2 on rank %d\n",rank);102 fprintf(stderr,"\n");103 print_matrix(&m2);104 fprintf(stderr,"\n");105 #endif106 100 107 101 // Calculate row offset in product matrix to start and stop calculation 102 stride = m1.rows/size; 103 start_row = rank*stride; 104 stop_row = stride*(rank+1); 105 #ifdef DEBUG 106 fprintf(stderr,"Rank %d  Stride %u, start_row %u, stop_row %u\n", 107 rank,stride,start_row,stop_row); 108 #endif 108 109 109 110 MPI_Finalize();
Note: See TracChangeset
for help on using the changeset viewer.