]> git.somenet.org - pub/astra/parallel.git/blob - openmp/prefix/datapar.c
now with fileread
[pub/astra/parallel.git] / openmp / prefix / datapar.c
1 #include "datapar.h"
2 /*
3  * Non-recursive, data parallel implementation
4  */
5
6 void algorithm (numtype x[], unsigned long size, unsigned int ops[]) {
7         unsigned long k;
8         unsigned long kk = 1;
9         unsigned long i;
10         for(k=1; k < size; k = kk){
11                 kk = k<<1;
12                 #pragma omp parallel for shared(x,k,kk,size) private(i)
13                 for(i = kk-1; i < size; i+= kk) {
14                         x[i] = x[i-k] + x[i];
15                 }
16                 #pragma omp barrier
17         }
18
19         for(k=kk>>1; k > 1; k = kk){
20                 kk = k>>1;
21                 #pragma omp parallel for shared(x,k,kk,size) private(i)
22                 for(i = k-1; i < size-kk; i+= k){
23                         x[i+kk] = x[i] + x[i+kk];
24                 }
25                 #pragma omp barrier
26         }
27 }