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