#include #include #include #include #include "timers.h" #define NDIM 1024 double a[NDIM][NDIM]; double b[NDIM][NDIM]; double c[NDIM][NDIM]; void matrix_multiply(double a[NDIM][NDIM], double b[NDIM][NDIM], double c[NDIM][NDIM], int num_threads) { int i; omp_set_num_threads(num_threads); #pragma omp parallel { int i,j,k; int tid = omp_get_thread_num(); int from = (NDIM * tid) / num_threads; int to..
#include #include #include #include "timers.h" #include #include #define MAX_THREADS 32 #define NDIM 100000 typedef struct { int *data; int from; int to; int *max; } thread_args; int num_threads = 0; void* worker(void* arg) { thread_args* args = (thread_args*) arg; int from = args->from; int to = args->to; int *ret = args->max; int *data = args->data; int max = 0; int i; for(i = from ; i < to ; ..