Changeset 5689 in /cluster/svnroot


Ignore:
Timestamp:
May 22, 2016 1:02:54 PM (5 years ago)
Author:
skylar
Message:

include openmp initialization

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

Legend:

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

    r5685 r5689  
    33CC                      = gcc
    44CFLAGS          = -Wall -gstabs+
     5OMP_FLAGS       = -fopenmp
    56
    6 EXPENDABLES     = serial matmul.o
     7EXPENDABLES     = serial openmp matmul-serial.o matmul-omp.o
    78
    8 matmul.o: matmul.c matmul.h
     9matmul-serial.o: matmul.c matmul.h
    910        $(CC) $(CFLAGS) -o $@ -c $<
    1011
    11 serial: serial.c matmul.o
    12         $(CC) $(CFLAGS) -o $@ matmul.o $<
     12matmul-omp.o: matmul.c matmul.h
     13        $(CC) $(CFLAGS) $(OMP_FLAGS) -o $@ -c $<
     14
     15serial: serial-omp.c matmul-serial.o
     16        $(CC) $(CFLAGS) -o $@ matmul-serial.o $<
     17
     18openmp: serial-omp.c matmul-omp.o
     19        $(CC) $(CFLAGS) $(OMP_FLAGS) -o $@ matmul-omp.o $<
    1320
    1421.PHONY: clean
  • bccd-ng/bw-institute/2016/day06/matmul/matmul.c

    r5688 r5689  
    5252// Takes in an int array of size c, and a pointer to a random seed. Sets a random number in each cell
    5353void init_array(int *m,const int c,unsigned int *s) {
    54     int i;
     54    int i,t;
    5555
     56#ifdef _OPENMP
     57#pragma omp parallel
     58    {
     59    t = omp_get_thread_num();
     60#pragma omp for
     61#else
     62    t = 1;
     63#endif
    5664    for(i=0;i<c;i++) {
    57         m[c] = rand_r(s);
     65        m[c] = rand_r(&s[t]);
    5866    }
     67#ifdef _OPENMP
     68    }
     69#endif
    5970}
  • bccd-ng/bw-institute/2016/day06/matmul/matmul.h

    r5688 r5689  
    1010#include <getopt.h> // getopt(3)
    1111#include <time.h> // time(2)
     12#include <omp.h>
    1213
    13 #ifdef OPENMP
     14#ifdef _OPENMP
    1415#define NUM_THREADS omp_get_num_threads()
    1516#else
Note: See TracChangeset for help on using the changeset viewer.