1 #include <omp.h>
2 #include <petscsys.h>
3
4 /*
5 See the comments in ex69f.F90
6 */
main(int argc,char ** args)7 int main(int argc, char **args)
8 {
9 double wtime_start, wtime_end, mpiwtime_start, mpiwtime_end;
10 double x[100];
11 int i, maxthreads;
12
13 PetscCall(PetscInitialize(&argc, &args, NULL, NULL));
14 wtime_start = omp_get_wtime();
15 mpiwtime_start = MPI_Wtime();
16 #pragma omp parallel for schedule(static)
17 for (i = 0; i < 100; i++) x[i] = exp(3.0 * i);
18 wtime_end = omp_get_wtime();
19 mpiwtime_end = MPI_Wtime();
20 printf("Wall clock time from MPI_Wtime() %g\n", wtime_end - wtime_start);
21 printf("Wall clock time from omp_get_wtime() %g\n", mpiwtime_end - mpiwtime_start);
22 printf("Value of x(22) %g\n", x[22]);
23 maxthreads = omp_get_max_threads();
24 printf("Number of threads set %d\n", maxthreads);
25 PetscCall(PetscFinalize());
26 return 0;
27 }
28
29 /*TEST
30
31 build:
32 requires: openmp
33
34 test:
35 filter: grep -v "Number of threads"
36
37 TEST*/
38