Commit adfef311025815f18da300936ff86998646191e8
1 parent
c7c188d740
Exists in
master
add n
Showing 4 changed files with 16 additions and 11 deletions Side-by-side Diff
lab1/pi_mpi.c
View file @
adfef31
| 1 | 1 | #include <stdio.h> | 
| 2 | +#include <stdlib.h> | |
| 2 | 3 | #include <string.h> | 
| 4 | + | |
| 5 | + | |
| 3 | 6 | #include <mpi.h> | 
| 4 | -#define N 100000000 | |
| 7 | +#define N 1000000000 | |
| 5 | 8 | |
| 6 | 9 | int main (int argc, char** argv) | 
| 7 | 10 | { | 
| ... | ... | @@ -50,7 +53,7 @@ | 
| 50 | 53 | |
| 51 | 54 | if(rank==0) | 
| 52 | 55 | { | 
| 53 | - printf("Pi=%0.12g\n", total_sum); | |
| 56 | + printf("Pi=%0.20g\n", total_sum); | |
| 54 | 57 | |
| 55 | 58 | } | 
| 56 | 59 | 
lab1/pi_omp.c
View file @
adfef31
| ... | ... | @@ -3,7 +3,8 @@ | 
| 3 | 3 | #include <stdlib.h> | 
| 4 | 4 | #include <omp.h> | 
| 5 | 5 | |
| 6 | -#define N 100000000 | |
| 6 | +#define N 1000000000 | |
| 7 | + | |
| 7 | 8 | int main (int argc, char** argv) | 
| 8 | 9 | { | 
| 9 | 10 | long long int n; | 
| ... | ... | @@ -15,7 +16,7 @@ | 
| 15 | 16 | |
| 16 | 17 | if(argc==2) | 
| 17 | 18 | { | 
| 18 | - n=atol(argv[1]); | |
| 19 | + n=atoll(argv[1]); | |
| 19 | 20 | } | 
| 20 | 21 | |
| 21 | 22 | |
| ... | ... | @@ -32,7 +33,7 @@ | 
| 32 | 33 | |
| 33 | 34 | l_sum *= h; | 
| 34 | 35 | |
| 35 | - printf("N=%lld,PI=%0.12g\n",n, l_sum); | |
| 36 | + printf("N=%lld,PI=%0.20g\n",n, l_sum); | |
| 36 | 37 | |
| 37 | 38 | return 0; | 
| 38 | 39 | } | 
lab1/pi_ser.c
View file @
adfef31
| 1 | 1 | #include <stdio.h> | 
| 2 | 2 | #include <stdlib.h> | 
| 3 | 3 | #include <string.h> | 
| 4 | -#define N 100000000 | |
| 4 | +#define N 1000000000 | |
| 5 | + | |
| 5 | 6 | int main (int argc, char** argv) | 
| 6 | 7 | { | 
| 7 | 8 | long long int n; | 
| 8 | 9 | long long int i; | 
| 9 | - | |
| 10 | 10 | double l_sum, x, h; | 
| 11 | 11 | |
| 12 | 12 | n=N; | 
| 13 | 13 | |
| 14 | 14 | if(argc==2) | 
| 15 | 15 | { | 
| 16 | - n=atol(argv[1]); | |
| 16 | + n=atoll(argv[1]); | |
| 17 | 17 | } | 
| 18 | 18 | |
| 19 | 19 | |
| 20 | + | |
| 20 | 21 | h = 1.0/n; | 
| 21 | 22 | |
| 22 | 23 | l_sum = 0.0; | 
| ... | ... | @@ -29,7 +30,7 @@ | 
| 29 | 30 | |
| 30 | 31 | l_sum *= h; | 
| 31 | 32 | |
| 32 | - printf("N=%lld, PI = %0.12g\n",n ,l_sum); | |
| 33 | + printf("N=%lld, PI = %0.20g\n",n ,l_sum); | |
| 33 | 34 | |
| 34 | 35 | return 0; | 
| 35 | 36 | } | 
lab1/pi_task.c
View file @
adfef31
| ... | ... | @@ -2,7 +2,7 @@ | 
| 2 | 2 | #include <string.h> | 
| 3 | 3 | #include <stdlib.h> | 
| 4 | 4 | |
| 5 | -#define N 100000000 | |
| 5 | +#define N 1000000000 | |
| 6 | 6 | |
| 7 | 7 | int main (int argc, char** argv) | 
| 8 | 8 | { | 
| ... | ... | @@ -43,7 +43,7 @@ | 
| 43 | 43 | |
| 44 | 44 | l_sum *= h; | 
| 45 | 45 | |
| 46 | - printf("Pi=%0.12g\n", l_sum); | |
| 46 | + printf("Pi=%0.20g\n", l_sum); | |
| 47 | 47 | |
| 48 | 48 | return 0; | 
| 49 | 49 | } |