Changeset 5700 in /cluster/svnroot


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

timing for serial runs

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

Legend:

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

    r5699 r5700  
    9696}
    9797
     98struct timeval safe_gettimeofday() {
     99    struct timeval now_t;
     100
     101    if((gettimeofday(&now_t,NULL)) == -1) {
     102        fprintf(stderr,"gettimeofday failed: %s\n",strerror(errno));
     103        exit(EXIT_FAILURE);
     104    }
     105
     106    return now_t;
     107}
     108
    98109void matmul(struct matrix *m1,struct matrix *m2,struct matrix *dst_m) {
    99110    unsigned int dst_row,dst_col,i,dst_coord;
     
    105116#pragma omp parallel for private(dst_coord,i) collapse(2) schedule(static,1)
    106117#else
    107     struct timeval start_t;
     118    struct timeval start_t = safe_gettimeofday();
    108119#endif
    109120    // Process each cell in the destination matrix, and calculate the result
     
    146157#ifdef _OPENMP
    147158    fprintf(stderr,"OpenMP took %f seconds\n",omp_get_wtime()-start_t);
     159#else
     160    struct timeval end_t,run_t;
     161    end_t = safe_gettimeofday();
     162    timersub(&end_t,&start_t,&run_t);
     163    fprintf(stderr,"Serial took %ld.%ld seconds\n",
     164            (long int)run_t.tv_sec,(long int)run_t.tv_usec);
    148165#endif
    149166}
  • bccd-ng/bw-institute/2016/day06/matmul/matmul.h

    r5699 r5700  
    5151void print_matrix(const struct matrix *);
    5252
     53// Returns a timeval struct for the current time
     54struct timeval safe_gettimeofday();
     55
    5356// Takes in two sources matrices and a destination matrix
    5457// Populates destination matrix by multiplying the first two matrices
Note: See TracChangeset for help on using the changeset viewer.