]> git.somenet.org - pub/astra/parallel.git/blob - openmp/prefix/prefix.c
algorithm1 implemented
[pub/astra/parallel.git] / openmp / prefix / prefix.c
1 #include <stdio.h>
2 #include <omp.h>
3 #include "prefix.h"
4 #include "algorithm_1.h"
5 #include "algorithm_2.h"
6 #include "algorithm_3.h"
7
8 #define NUMBERS 800000
9
10 int main (int argc, char* argv[]) {
11         int result = 0;
12         numtype numarray[NUMBERS];
13         int countarray[NUMBERS];
14         int i;
15         double startTime, endTime;
16
17         for (i = 0; i < NUMBERS; i++) {
18                 numarray[i] = 10;
19                 countarray[i] = 0;
20         }
21
22         startTime = omp_get_wtime();
23         printf ("calling algorithm 1:");
24         algorithm_1(numarray, NUMBERS, countarray);
25         printf ("sum: %i\n", numarray[NUMBERS-1]);
26         endTime = omp_get_wtime();
27         printf("took %f seconds.\n", endTime-startTime);
28         
29         startTime = omp_get_wtime();
30         printf ("calling algorithm 2:");
31         result = algorithm_2(numarray, NUMBERS, countarray);
32         printf ("sum: %i\n", result);
33         endTime = omp_get_wtime();
34         printf("took %f seconds.\n", endTime-startTime);
35         
36         startTime = omp_get_wtime();
37         printf ("calling algorithm 3:");
38         result = algorithm_3(numarray, NUMBERS, countarray);
39         printf ("sum: %i\n", result);
40         endTime = omp_get_wtime();
41         printf("took %f seconds.\n", endTime-startTime);
42         
43         return 0;
44 }