Changeset 5709 in /cluster/svnroot


Ignore:
Timestamp:
May 26, 2016 8:17:18 PM (5 years ago)
Author:
skylar
Message:

row offset calc

File:
1 edited

Legend:

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

    r5708 r5709  
    1010int main(int argc,char **argv) {
    1111    int rank,size,c;
     12    unsigned int start_row,stop_row,stride;
    1213    bool print;
    1314    struct matrix m1,m2,dst_m;
     
    8990    }
    9091
     92    // Broadcast each element of the structs, to avoid the complexity
     93    // of creating custom data types
    9194    MPI_Bcast(&m1.rows,1,MPI_INT,FIRST_RANK,MPI_COMM_WORLD);
    9295    MPI_Bcast(&m1.cols,1,MPI_INT,FIRST_RANK,MPI_COMM_WORLD);
     
    9598    MPI_Bcast(m1.matrix,m1.rows*m1.cols,MPI_INT,FIRST_RANK,MPI_COMM_WORLD);
    9699    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
    106100
    107101    // 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
    108109
    109110    MPI_Finalize();
Note: See TracChangeset for help on using the changeset viewer.