From 0befec203894d82083b822231559556ec1fd85e0 Mon Sep 17 00:00:00 2001 From: jfayaz Date: Tue, 31 Jul 2018 13:21:36 -0700 Subject: [PATCH 1/2] pi.c initial import --- Code/Parallel/mpi/pi.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Code/Parallel/mpi/pi.c diff --git a/Code/Parallel/mpi/pi.c b/Code/Parallel/mpi/pi.c new file mode 100644 index 0000000..9be0f2b --- /dev/null +++ b/Code/Parallel/mpi/pi.c @@ -0,0 +1,34 @@ +#include +#include +#include + +int main(int argc, char **argv) +{ + int i, intervals = 10000000; + double truePi = 3.141592653589793238462643; + double x, dx, f, sum, pi; + double time2; + + time_t time1 = clock(); + + printf("Number of intervals: %d\n", intervals); + + sum = 0.0; + dx = 1.0 / (double) intervals; + + for (i = 1; i <= intervals; i++) { + x = dx * ((double) (i - 0.5)); + f = 4.0 / (1.0 + x*x); + sum = sum + f; + } + + pi = dx*sum; + + time2 = (clock() - time1) / (double) CLOCKS_PER_SEC; + + printf("Computed PI %f\n", pi); + printf("The true PI %f\n\n", truePi); + printf("Elapsed time (s) = %f\n", time2); + + return 0; +} From 6b65f2457c63569c2623f5948802b5a3b51057ef Mon Sep 17 00:00:00 2001 From: jfayaz Date: Thu, 2 Aug 2018 09:46:37 -0700 Subject: [PATCH 2/2] my pi --- Code/Parallel/mpi/{pi.c => my_pi.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Code/Parallel/mpi/{pi.c => my_pi.c} (100%) diff --git a/Code/Parallel/mpi/pi.c b/Code/Parallel/mpi/my_pi.c similarity index 100% rename from Code/Parallel/mpi/pi.c rename to Code/Parallel/mpi/my_pi.c