]> git.somenet.org - pub/astra/parallel.git/blob - openmp/prefix/prefix.c
rewrote prefix sums (seqential, recursive and dataparallel) - now more modular and...
[pub/astra/parallel.git] / openmp / prefix / prefix.c
1 #include <stdio.h>
2 #include <omp.h>
3 #include "prefix.h"
4
5 /* TODO: Replace with file read. */
6 #define NUMBERS 5
7
8 int main (int argc, char* argv[]) {
9         numtype numarray[NUMBERS];
10         unsigned long size;
11         //unsigned int countarray[NUMBERS];
12         double startTime;
13
14 //TODO: read num file here.
15 //first value in file = numcount
16         for (size = 0; size < NUMBERS; size++) {
17                 numarray[size] = 10;
18         }
19
20         /* might want to comment this out, if numarray is big */
21         printf ("array details\n[%li", numarray[0]);
22         for (unsigned long i = 1; i < size; i++) {
23                 printf (", %li", numarray[i]);
24         }
25         printf ("]\n");
26
27         printf("init done starting algorithm. size: %li\n", size);
28         startTime = omp_get_wtime();
29         algorithm(numarray, size, NULL);
30         printf("DONE. took %f seconds.\n", omp_get_wtime()-startTime);
31         printf ("result: %li\n", numarray[(size-1)]);
32
33         /* might want to comment this out, if numarray is big */
34         printf ("array details\n[%li", numarray[0]);
35         for (unsigned long i = 1; i < size; i++) {
36                 printf (", %li", numarray[i]);
37         }
38         printf ("]\n");
39
40         return 0;
41 }