]> git.somenet.org - pub/astra/parallel.git/blob - openmp/prefix/seq.c
rewrote prefix sums (seqential, recursive and dataparallel) - now more modular and...
[pub/astra/parallel.git] / openmp / prefix / seq.c
1
2 #include "seq.h"
3 /**
4  * Sequential algorithm to compute correct values.
5  */
6 void algorithm (numtype in[], unsigned long size, unsigned int ops[]) {
7         numtype out[size];
8         out[1] = in[0];
9         for (unsigned long i = 1; i < size; i++){
10                 out[i+1] = out[i] + in[i];
11         }
12         out[size] = out[size-1] + in[size-1];
13
14         /* Copy out array to in */
15         for (unsigned long i = 0; i < size; i++){
16                 in[i] = out[i+1];
17         }
18 }