]> git.somenet.org - pub/jan/parprog.git/blob - prefix/datapar.c
getopt failure: now fails when reading more than $file.size from $file.
[pub/jan/parprog.git] / 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         }
17
18         for(k=kk>>1; k > 1; k = kk){
19                 kk = k>>1;
20                 #pragma omp parallel for shared(x,k,kk,size) private(i)
21                 for(i = k-1; i < size-kk; i+= k){
22                         x[i+kk] = x[i] + x[i+kk];
23                 }
24         }
25 }