]> git.somenet.org - pub/astra/parallel.git/blob - openmp/prefix/prefix.c
code cleanup in prefix.c
[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, endTime;
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 #ifdef DEBUG
30         /* might want to comment this out, if numarray is big */
31         array_contents(numarray, size);
32 #endif
33
34         printf("init done starting algorithm. size: %li\n", size);
35         startTime = omp_get_wtime();
36         algorithm(numarray, size, NULL);
37         endTime = omp_get_wtime();
38         printf("DONE. took %f seconds.\n", endTime-startTime);
39         printf ("result: %li\n", numarray[size-1]);
40
41 #ifdef DEBUG
42         /* might want to comment this out, if numarray is big */
43         array_contents(numarray, size);
44 #endif
45
46         return 0;
47 }