]> git.somenet.org - pub/jan/parprog.git/blob - openmp/prefix/datapar.c
set new number of cores
[pub/jan/parprog.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
11         for(k=1; k < size; k = kk){
12                 kk = k<<1;
13                 for(i = kk-1; i < size; i+= kk){
14                         x[i] = x[i-k] + x[i];
15                 }
16                 //barrier;
17         }
18
19         for(k=kk>>1; k > 1; k = kk){
20                 kk = k>>1;
21                 for(i = k-1; i < size-kk; i+= k){
22                         x[i+kk] = x[i] + x[i+kk];
23                 }
24                 //barrier;
25         }
26 }