Changeset 5686 in /cluster/svnroot


Ignore:
Timestamp:
May 19, 2016 11:41:42 PM (5 years ago)
Author:
skylar
Message:

working on random state init

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

Legend:

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

    r5685 r5686  
    99}
    1010
    11 int *safe_malloc(const int c,const char *msg) {
     11int *safe_malloc_int(const int c,const char *msg) {
    1212    int *m;
    1313    if((m = malloc(c*sizeof(int))) == NULL) {
     
    1919    return m;
    2020}
     21
     22struct random_data *safe_malloc_random_data(const int c,const char *msg) {
     23    struct random_data *m;
     24    if((m = malloc(c*sizeof(struct random_data))) == NULL) {
     25        fprintf(stderr,"%s failed at %s, line %d: %s\n",
     26                msg,__FILE__,__LINE__,strerror(errno));
     27        exit(EXIT_FAILURE);
     28    }
     29
     30    return m;
     31}
     32
     33struct random_data *init_random_bufs() {
     34    struct random_data *random_bufs;
     35
     36    random_bufs = safe_malloc_random_data(NUM_THREADS,"Allocating random data array");
     37
     38    return random_bufs;
     39}
     40
     41void init_array(int *m,const int c) {
     42    int i;
     43
     44    for(i=0;i<c;i++) {
     45    }
     46}
  • bccd-ng/bw-institute/2016/day06/matmul/matmul.h

    r5685 r5686  
    1010#include <getopt.h>
    1111
     12#ifdef OPENMP
     13#define NUM_THREADS omp_get_num_threads()
     14#else
     15#define NUM_THREADS 1
     16#endif
     17
    1218void usage();
    13 int *safe_malloc(const int,const char *);
     19
     20// Take in a count of objects and a failure message, returns allocated array
     21int *safe_malloc_int(const int,const char *);
     22struct random_data *safe_malloc_random_data(const int,const char *);
     23
     24// Returns an array of size threads of initialized random_r buffers
     25struct random_data *init_random_bufs();
     26
     27// Take in a reference to an allocated array and its size, initializes with random integers
     28void init_array(int *,const int);
  • bccd-ng/bw-institute/2016/day06/matmul/serial.c

    r5685 r5686  
    88    int c,m1_rows,m1_cols,m2_rows,m2_cols;
    99    int *m1,*m2,*dst_m;
     10    struct random_data *random_bufs;
    1011
    1112    m1_rows = m1_cols = m2_rows = m2_cols = 0;
     
    2425            case 'b':
    2526                m2_rows = atoi(optarg);
     27                break;
    2628            case '?':
    2729                usage();
     
    3638    }
    3739
    38     m1      = safe_malloc(m1_rows*m1_cols,"Allocating first matrix");
    39     m2      = safe_malloc(m2_rows*m2_cols,"Allocating second matrix");
    40     dst_m   = safe_malloc(m1_rows*m2_cols,"Allocating destination matrix");
     40    m1      = safe_malloc_int(m1_rows*m1_cols,"Allocating first matrix");
     41    m2      = safe_malloc_int(m2_rows*m2_cols,"Allocating second matrix");
     42    dst_m   = safe_malloc_int(m1_rows*m2_cols,"Allocating destination matrix");
     43
     44    // Initialize random state
     45    random_bufs = safe_malloc_random_data(NUM_THREADS,"Allocating random data array");
    4146
    4247    exit(EXIT_SUCCESS);
Note: See TracChangeset for help on using the changeset viewer.