]> git.somenet.org - pub/astra/parallel.git/blob - openmp/prefix/prefix.c
fixed hillis algorithm
[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 16
7
8 void array_contents(numtype array[], unsigned long size) {
9         printf ("[%li", array[0]);
10         for (unsigned long i = 1; i < size; i++) {
11                 printf (", %li", array[i]);
12         }
13         printf ("]\n");
14 }
15
16
17 int main (int argc, char* argv[]) {
18         numtype numarray[NUMBERS];
19         unsigned long size;
20         //unsigned int countarray[NUMBERS];
21         double startTime;
22
23 //TODO: read num file here.
24 //first value in file = numcount
25         for (size = 0; size < NUMBERS; size++) {
26                 numarray[size] = 10;
27         }
28
29         /* might want to comment this out, if numarray is big */
30         array_contents(numarray, size);
31
32         printf("init done starting algorithm. size: %li\n", size);
33         startTime = omp_get_wtime();
34         algorithm(numarray, size, NULL);
35         printf("DONE. took %f seconds.\n", omp_get_wtime()-startTime);
36         printf ("result: %li\n", numarray[(size-1)]);
37
38         /* might want to comment this out, if numarray is big */
39         array_contents(numarray, size);
40
41         return 0;
42 }