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;