From 2f033b16a27b1d9dab9ae6f442cb9c89464053d2 Mon Sep 17 00:00:00 2001 From: genaud Date: Fri, 26 Jun 2009 10:57:42 +0000 Subject: [PATCH] - corrected mvmul.c to avoid warnings - added MPI_Wtime in bcast example. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6365 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/smpi/bcast.c | 24 +++++++++++++----------- examples/smpi/mvmul.c | 8 ++++---- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/examples/smpi/bcast.c b/examples/smpi/bcast.c index 002061c1e4..27b58eee09 100644 --- a/examples/smpi/bcast.c +++ b/examples/smpi/bcast.c @@ -1,25 +1,27 @@ #include #include -#define INIT_VALUE 3 -#define TARGET_VALUE 42 - int main (int argc, char **argv) { int size, rank; - int value = INIT_VALUE; + int value = 3; + double start_timer; + MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + start_timer = MPI_Wtime(); + if (0 == rank) { - value = TARGET_VALUE; + value = 17; } - fprintf(stderr,"node %d has value %d before broadcast\n", rank, value); + printf("node %d has value %d\n", rank, value); MPI_Bcast(&value, 1, MPI_INT, 0, MPI_COMM_WORLD); - fprintf(stderr,"node %d has value %d after broadcast\n", rank, value); - if (value != TARGET_VALUE) { - fprintf(stderr,"node %d don't have the target value after broadcast!!\n", rank); - exit(1); - } + printf("node %d has value %d\n", rank, value); + + MPI_Barrier( MPI_COMM_WORLD ); + if ( 0 == rank) + printf("Elapsed time on rank %d: %lf s\n", rank, MPI_Wtime()-start_timer); MPI_Finalize(); return 0; } diff --git a/examples/smpi/mvmul.c b/examples/smpi/mvmul.c index aa32e30f22..68f09abe64 100644 --- a/examples/smpi/mvmul.c +++ b/examples/smpi/mvmul.c @@ -168,7 +168,7 @@ int main(int argc, char* argv[]) { printf("prog: blocking, i: %d ", current_iteration); if (i == N) { - printf("ptime: %d us, stime: %d us, speedup: %.3f, nodes: %d, efficiency: %.3f\n", + printf("ptime: %ld us, stime: %ld us, speedup: %.3f, nodes: %d, efficiency: %.3f\n", parallel_usecs, sequential_usecs, (double)sequential_usecs / (double)parallel_usecs, @@ -196,10 +196,10 @@ int main(int argc, char* argv[]) { if(0 == rank) { printf("prog: blocking, "); if(0 < successful_iterations) { - printf("iterations: %d, avg. ptime: %d us, avg. stime: %d us, avg. speedup: %.3f, nodes: %d, avg. efficiency: %.3f\n", + printf("iterations: %d, avg. ptime: %.3f us, avg. stime: %.3f us, avg. speedup: %.3f, nodes: %d, avg. efficiency: %.3f\n", successful_iterations, - parallel_usecs_total / successful_iterations, - sequential_usecs_total / successful_iterations, + (double) parallel_usecs_total / (double) successful_iterations, + (double) sequential_usecs_total / (double) successful_iterations, (double)sequential_usecs_total / (double)parallel_usecs_total, size, (double)sequential_usecs_total / ((double)parallel_usecs_total * (double)size)); -- 2.20.1