From cb39db61ce4c19c0b75355bb2bbd02abc7871e6a Mon Sep 17 00:00:00 2001 From: Johannes Winklehner Date: Sat, 18 Jun 2016 17:16:40 +0200 Subject: [PATCH] Benchmarking mit -b --- hpc_mpi/src/hpc_mpi.c | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/hpc_mpi/src/hpc_mpi.c b/hpc_mpi/src/hpc_mpi.c index d224b07..3b8f4ab 100644 --- a/hpc_mpi/src/hpc_mpi.c +++ b/hpc_mpi/src/hpc_mpi.c @@ -91,7 +91,51 @@ int main(int argc, char* argv[]) { //fill(a, size, sizeof(int)); if (benchmark) { + int *red; + MPI_Alloc_mem(size * sizeof(int), MPI_INFO_NULL, &red); + double start, end, global_end; + MPI_Barrier(MPI_COMM_WORLD); + start = MPI_Wtime(); + MPI_Reduce(a, red, size, MPI_INT, op, 0, MPI_COMM_WORLD); + end = MPI_Wtime(); + MPI_Reduce(&end, &global_end, 1, MPI_DOUBLE, MPI_MAX, 0, + MPI_COMM_WORLD); + if (r == 0) { + printf("%f, ", global_end - start); + } + + MPI_Barrier(MPI_COMM_WORLD); + start = MPI_Wtime(); + Fib_Reduce(a, red, size, MPI_INT, op, 0, MPI_COMM_WORLD); + end = MPI_Wtime(); + MPI_Reduce(&end, &global_end, 1, MPI_DOUBLE, MPI_MAX, 0, + MPI_COMM_WORLD); + if (r == 0) { + printf("%f, ", global_end - start); + } + + MPI_Barrier(MPI_COMM_WORLD); + start = MPI_Wtime(); + Bin_Reduce(a, red, size, MPI_INT, op, 0, MPI_COMM_WORLD); + end = MPI_Wtime(); + MPI_Reduce(&end, &global_end, 1, MPI_DOUBLE, MPI_MAX, 0, + MPI_COMM_WORLD); + if (r == 0) { + printf("%f, ", global_end - start); + } + + MPI_Barrier(MPI_COMM_WORLD); + start = MPI_Wtime(); + Binom_Reduce(a, red, size, MPI_INT, op, 0, MPI_COMM_WORLD); + end = MPI_Wtime(); + MPI_Reduce(&end, &global_end, 1, MPI_DOUBLE, MPI_MAX, 0, + MPI_COMM_WORLD); + if (r == 0) { + printf("%f\n", global_end - start); + } + + MPI_Free_mem(red); } else { int *red; int *rfib;