Changeset 5716 in /cluster/svnroot


Ignore:
Timestamp:
Jun 5, 2016 1:21:42 PM (4 years ago)
Author:
skylar
Message:

fix segfault, fix variable names, Makefile styling

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

Legend:

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

    r5706 r5716  
    1515EXPENDABLES     = serial openmp mpi-serial matmul-serial.o matmul-omp.o
    1616
    17 matmul-serial.o: matmul.c matmul.h
    18         $(CC) $(CFLAGS) -o $@ -c $<
    19 
    20 matmul-omp.o: matmul.c matmul.h
    21         $(CC) $(CFLAGS) $(OMP_FLAGS) -o $@ -c $<
    22 
    2317serial: serial-omp.c matmul-serial.o
    2418        $(CC) $(CFLAGS) -o $@ matmul-serial.o $<
     
    3024        $(MPICC) $(CFLAGS) $(MPI_FLAGS) -o $@ matmul-serial.o $<
    3125
     26matmul-serial.o: matmul.c matmul.h
     27        $(CC) $(CFLAGS) -o $@ -c $<
     28
     29matmul-omp.o: matmul.c matmul.h
     30        $(CC) $(CFLAGS) $(OMP_FLAGS) -o $@ -c $<
     31
    3232.PHONY: clean
    3333clean:
  • bccd-ng/bw-institute/2016/day06/matmul/README

    r5706 r5716  
    44
    551. Make the serial version: make serial
    6 2. Make the openmp version: make openmp
    7 3. Make the openmp version: make mpi
     62. Make the OpenMP version: make openmp
     73. Make the non-OpenMP MPI version: make mpi-serial
    88
    99Add DEBUG=1 for debugging statements. Add PROFILE=1 for gprof output.
    1010
    11 To run:
     11To run serially:
    1212
    1313./serial -x <m1-cols> -y <m1-rows> -a <m2-cols> -b <m2-rows>
    1414
    15 Substitute openmp for the openmp version.
     15To run with OpenMP:
     16
     17./openmp -x <m1-cols> -y <m1-rows> -a <m2-cols> -b <m2-rows>
     18
     19To run with MPI:
     20
     21mpirun -np <num-procs> ./mpi-serial -x <m1-cols> -y <m1-rows> -a <m2-cols> -b <m2-rows>
    1622
    1723Add -p if you want matrices to be printed to STDOUT.
  • bccd-ng/bw-institute/2016/day06/matmul/mpi.c

    r5715 r5716  
    99
    1010int main(int argc,char **argv) {
    11     int rank,size,c;
     11    int rank,num_ranks,c;
    1212    unsigned int start_row,stop_row,stride;
    1313    bool print;
     
    1515
    1616    MPI_Init(&argc,&argv);
    17     MPI_Comm_size(MPI_COMM_WORLD,&size);
     17    MPI_Comm_size(MPI_COMM_WORLD,&num_ranks);
    1818    MPI_Comm_rank(MPI_COMM_WORLD,&rank);
    1919
    2020#ifdef DEBUG
    21     fprintf(stderr,"Rank %d/%d - Hello World\n",rank,size);
     21    fprintf(stderr,"Rank %d/%d - Hello World\n",rank,num_ranks);
    2222#endif
    2323
     
    103103
    104104    // Calculate row offset in product matrix to start and stop calculation
    105     stride                  = m1.rows/size;
     105    stride                  = m1.rows/num_ranks;
    106106    start_row               = rank*stride;
    107107
    108108    // Assign an even number of rows to each rank, except for the last rank
    109     // whiich gets the remainder
    110     if(rank<(size-1)) {
     109    // which gets the remainder (from its start_row to the end of the matrix)
     110    if(rank<(num_ranks-1)) {
    111111        stop_row = stride*(rank+1);
    112112    }
     
    153153    free(m1.matrix);
    154154    free(m2.matrix);
    155     free(local_dst_m.matrix);
    156155    if(rank == FIRST_RANK) {
    157156        free(dst_m.matrix);
     157    }
     158    else {
     159        free(local_dst_m.matrix);
    158160    }
    159161
Note: See TracChangeset for help on using the changeset viewer.