Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <time.h>
- #include <stdio.h>
- #include <stdlib.h>
- /* gcc -fopenmp -o aufg3 aufg3.c -lgomp; OMP_NUM_THREADS=7 ./aufg3 */
- int main(int argc, char *argv[])
- {
- int i, N;
- double h, x, sum, PI;
- N = 1999999999;
- h = 1.0/N;
- sum = 0;
- time_t start, end;
- time(&start);
- #pragma omp parallel private (i,x) shared (N,h,sum)
- {
- #pragma omp for reduction (+:sum) schedule (static) nowait
- for ( i=1 ; i<=N ; i++ ) {
- x = h * (i - 0.5);
- sum = sum + 4/( 1 + x*x );
- }
- }
- time(&end);
- printf("Dauer: %.2lf Sekunden", difftime(end, start));
- PI = h * sum;
- printf(" PI = %f\n",PI);
- printf(" woozaaa");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement