Changeset 5708 in /cluster/svnroot


Ignore:
Timestamp:
May 25, 2016 11:52:43 PM (5 years ago)
Author:
skylar
Message:

done for the night

Location:
bccd-ng/bw-institute/2016/day06/matmul
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • bccd-ng/bw-institute/2016/day06/matmul/matmul.c

    r5705 r5708  
    9595}
    9696
    97 // Takes in a matrix and prints it to STDOUT
     97// Takes in a matrix and prints it to STDERR
    9898void print_matrix(const struct matrix *m) {
    9999    int row,col;
     
    101101    for(row=0;row<m->rows;row++) {
    102102        for(col=0;col<m->cols;col++) {
    103             printf("%d ",m->matrix[coord(m,row,col)]);
     103            fprintf(stderr,"%d ",m->matrix[coord(m,row,col)]);
    104104        }
    105         puts("");
     105        fprintf(stderr,"\n");
    106106    }
    107107}
  • bccd-ng/bw-institute/2016/day06/matmul/matmul.h

    r5706 r5708  
    4646unsigned int coord(const struct matrix *,const unsigned int,const unsigned int);
    4747
    48 // Takes in a matrix. Prints it to STDOUT
     48// Takes in a matrix. Prints it to STDERR
    4949void print_matrix(const struct matrix *);
    5050
  • bccd-ng/bw-institute/2016/day06/matmul/mpi.c

    r5707 r5708  
    7373            );
    7474
    75     // Each thread will get a separate random seed
    76 
    7775    if(rank == FIRST_RANK) {
     76        // Each thread will get a separate random seed
    7877        unsigned int *random_seeds = init_random_seeds();
    7978        init_matrix(&m1,random_seeds);
     
    9089    }
    9190
     91    MPI_Bcast(&m1.rows,1,MPI_INT,FIRST_RANK,MPI_COMM_WORLD);
     92    MPI_Bcast(&m1.cols,1,MPI_INT,FIRST_RANK,MPI_COMM_WORLD);
     93    MPI_Bcast(&m2.rows,1,MPI_INT,FIRST_RANK,MPI_COMM_WORLD);
     94    MPI_Bcast(&m2.cols,1,MPI_INT,FIRST_RANK,MPI_COMM_WORLD);
     95    MPI_Bcast(m1.matrix,m1.rows*m1.cols,MPI_INT,FIRST_RANK,MPI_COMM_WORLD);
     96    MPI_Bcast(m2.matrix,m2.rows*m2.cols,MPI_INT,FIRST_RANK,MPI_COMM_WORLD);
     97#ifdef DEBUG
     98    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#endif
     106
     107    // Calculate row offset in product matrix to start and stop calculation
     108
    92109    MPI_Finalize();
    93110
Note: See TracChangeset for help on using the changeset viewer.