]> git.somenet.org - pub/jan/parprog.git/blob - openmp/prefix/datapar.c
hillis is broken :(
[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         printf ("par2");
8         unsigned long k;
9         unsigned long kk;
10         unsigned long i;
11
12         for(k=1; k < size; k = kk){
13                 kk = k<<1;
14                 for(i = kk-1; i < size; i+= kk){
15                         x[i] = x[i-k] + x[i];
16                 }
17                 //barrier;
18         }
19
20         for(k=kk>>1; k > 1; k = kk){
21                 kk = k>>1;
22                 for(i = k-1; i < size-kk; i+= k){
23                         x[i+kk] = x[i] + x[i+kk];
24                 }
25                 //barrier;
26         }
27 }