Last active
December 20, 2015 09:29
-
-
Save niklasfi/6107879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <omp.h> | |
int main(){ | |
//Algorithm alg(double* m) uses m to calculate result | |
double sum=0; | |
int i; | |
#pragma omp parallel for | |
for(i=0; i < 1000; ++i) | |
double* m = malloc(sizeof(double) * 20); | |
sum+=alg(m); | |
free(m); | |
} | |
//Algorithm alg(double* m) uses m to calculate result | |
double sum=0; | |
int i; | |
double* m = malloc(sizeof(double) * 20 * omp_num_threads()); | |
#pragma omp parallel for | |
for(i=0; i < 1000; ++i) | |
sum+=alg(m+20*omp_thread_num()); | |
} | |
free(m); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment