From: Arnaud Giersch Date: Fri, 24 Jan 2014 10:13:35 +0000 (+0100) Subject: Rework smpi-compute tests, and hope to make them reproducible. X-Git-Tag: v3_11_beta~120^2~9 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3c0a14501628a82cc844761204585a496d67e06b?hp=a06d371bdabe5d7c00f54b941d31068c01e6d756 Rework smpi-compute tests, and hope to make them reproducible. --- diff --git a/teshsuite/smpi/compute.c b/teshsuite/smpi/compute.c index e67315eead..a586901e31 100644 --- a/teshsuite/smpi/compute.c +++ b/teshsuite/smpi/compute.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2010, 2012. The SimGrid Team. +/* Copyright (c) 2009-2010, 2012, 2014. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -9,11 +9,12 @@ int main(int argc, char *argv[]) { - int i; + int i, n; double d; MPI_Init(&argc, &argv); + n = argc > 1 ? atoi(argv[1]) : 0; d = 2.0; - for (i = 0; i < atoi(argv[1]); i++) { + for (i = 0; i < n; i++) { if (d < 10000) { d = d * d; } else { diff --git a/teshsuite/smpi/compute.tesh b/teshsuite/smpi/compute.tesh index aec5db38fe..d740d94702 100644 --- a/teshsuite/smpi/compute.tesh +++ b/teshsuite/smpi/compute.tesh @@ -1,31 +1,29 @@ p Test compute -! setenv LD_LIBRARY_PATH=../../lib -! output sort ! timeout 5 -$ ../../smpi_script/bin/smpirun -platform ${srcdir:=.}/../../examples/msg/small_platform_with_routers.xml -hostfile ${srcdir:=.}/hostfile -np 2 ./compute 0 -> 0 2.000000 -> 0 2.000000 -> [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s) -> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9' -> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'SMPI' -> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/TCP_gamma' to '4194304' +$ ../../smpi_script/bin/smpirun -platform ${srcdir:=.}/../../examples/msg/small_platform_with_routers.xml -hostfile ${srcdir:=.}/hostfile -np 3 --log=root.thres:warning ./compute 7 +> 7 16.000000 +> 7 16.000000 +> 7 16.000000 + +p Test compute only once +! timeout 5 +$ ../../smpi_script/bin/smpirun -platform ${srcdir:=.}/../../examples/msg/small_platform_with_routers.xml -hostfile ${srcdir:=.}/hostfile -np 3 --log=root.thres:warning ./compute2 7 +> 7 16.000000 p Test compute and bench -! setenv LD_LIBRARY_PATH=../../lib ! output sort ! timeout 45 -$ ../../smpi_script/bin/smpirun -platform ${srcdir:=.}/../../examples/msg/small_platform_with_routers.xml -hostfile ${srcdir:=.}/hostfile -np 2 ./compute3 -> [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s) -> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '1e-9' -> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'SMPI' -> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/TCP_gamma' to '4194304' -> [0] The result of the computation is: 65536.000000 -> [1] The result of the computation is: 2.000000 -> [rank:0] Run the first computation. It's globally benched, and I want no more than 3 benchmarks (thres<0) -> [rank:0] Run the first computation. It's globally benched, and I want no more than 3 benchmarks (thres<0) -> [rank:0] Run the first (locally benched) computation. It's locally benched, and I want the standard error to go below 0.1 second (count is not >0) -> [rank:0] Run the first (locally benched) computation. It's locally benched, and I want the standard error to go below 0.1 second (count is not >0) -> [rank:1] Run the first computation. It's globally benched, and I want no more than 3 benchmarks (thres<0) -> [rank:1] Run the first (locally benched) computation. It's locally benched, and I want the standard error to go below 0.1 second (count is not >0) -> [rank:1] Run the first (locally benched) computation. It's locally benched, and I want the standard error to go below 0.1 second (count is not >0) - +$ ../../smpi_script/bin/smpirun -platform ${srcdir:=.}/../../examples/msg/small_platform_with_routers.xml -hostfile ${srcdir:=.}/hostfile -np 3 --log=root.thres:warning ./compute3 quiet +> (0) Run the first computation. It's globally benched, and I want no more than 4 benchmarks (thres<0) +> (0) Run the first computation. It's globally benched, and I want no more than 4 benchmarks (thres<0) +> (0) Run the first computation. It's globally benched, and I want no more than 4 benchmarks (thres<0) +> (0) Run the first computation. It's globally benched, and I want no more than 4 benchmarks (thres<0) +> (1) [rank:0] Run the first (locally benched) computation. It's locally benched, and I want the standard error to go below 0.1 second (count is not >0) +> (1) [rank:0] Run the first (locally benched) computation. It's locally benched, and I want the standard error to go below 0.1 second (count is not >0) +> (1) [rank:1] Run the first (locally benched) computation. It's locally benched, and I want the standard error to go below 0.1 second (count is not >0) +> (1) [rank:1] Run the first (locally benched) computation. It's locally benched, and I want the standard error to go below 0.1 second (count is not >0) +> (1) [rank:2] Run the first (locally benched) computation. It's locally benched, and I want the standard error to go below 0.1 second (count is not >0) +> (1) [rank:2] Run the first (locally benched) computation. It's locally benched, and I want the standard error to go below 0.1 second (count is not >0) +> (2) [rank:0] Done. +> (2) [rank:1] Done. +> (2) [rank:2] Done. diff --git a/teshsuite/smpi/compute2.c b/teshsuite/smpi/compute2.c index 1720d84c89..ea81081009 100644 --- a/teshsuite/smpi/compute2.c +++ b/teshsuite/smpi/compute2.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2010, 2012. The SimGrid Team. +/* Copyright (c) 2009-2010, 2012, 2014. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -9,12 +9,14 @@ int main(int argc, char *argv[]) { - int i; + int i, n; double d; MPI_Init(&argc, &argv); + n = argc > 1 ? atoi(argv[1]) : 0; d = 2.0; -/* SMPI_DO_ONCE */ { - for (i = 0; i < atoi(argv[1]); i++) { + /* Run it only once across the whole set of processes */ + SMPI_SAMPLE_GLOBAL(1, -1) { + for (i = 0; i < n; i++) { if (d < 10000) { d = d * d; } else { diff --git a/teshsuite/smpi/compute3.c b/teshsuite/smpi/compute3.c index f0445ba537..a501fbbd5b 100644 --- a/teshsuite/smpi/compute3.c +++ b/teshsuite/smpi/compute3.c @@ -4,46 +4,72 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -/* This example should be instructive to learn about SMPI_SAMPLE_LOCAL and +/* This example should be instructive to learn about SMPI_SAMPLE_LOCAL and SMPI_SAMPLE_GLOBAL macros for execution sampling */ #include #include +static double compute(double d0) +{ + double d = d0; + int j; + for (j = 0; j < 100 * 1000 * 1000; j++) { /* 100 kflop */ + if (d < 100000) { + d = d * d; + } else { + d = 2; + } + } + return d; +} + int main(int argc, char *argv[]) { - int i,j; + int verbose; + int i, n; double d; MPI_Init(&argc, &argv); + verbose = argc <= 1; + MPI_Comm_size(MPI_COMM_WORLD, &n); d = 2.0; - for (i=0;i<5;i++) { - SMPI_SAMPLE_GLOBAL(3,-1) { // I want no more than 3 benchs (thres<0) - fprintf(stderr,"[rank:%d] Run the first computation. It's globally benched, and I want no more than 3 benchmarks (thres<0)\n", smpi_process_index()); - - for (j=0;j<100*1000*1000;j++) { // 100 kflop - if (d < 100000) { - d = d * d; - } else { - d = 2; - } - } + for (i = 0; i < 5; i++) { + /* I want no more than n + 1 benchs (thres < 0) */ + SMPI_SAMPLE_GLOBAL(n + 1, -1) { + if (verbose) + fprintf(stderr, "(%12.6f) [rank:%d]", MPI_Wtime(), smpi_process_index()); + else + fprintf(stderr, "(0)"); + fprintf(stderr, " Run the first computation. It's globally benched, " + "and I want no more than %d benchmarks (thres<0)\n", n + 1); + d = compute(2.0); } } - for (i=0;i<5;i++) { - SMPI_SAMPLE_LOCAL(0, 0.1) { // I want the standard error to go below 0.1 second. Two tests at least will be run (count is not >0) - fprintf(stderr,"[rank:%d] Run the first (locally benched) computation. It's locally benched, and I want the standard error to go below 0.1 second (count is not >0)\n", smpi_process_index()); - for (j=0;j<100*1000*1000;j++) { // 100 kflop - if (d < 100000) { - d = d * d; - } else { - d = 2; - } - } + n = 0; + for (i = 0; i < 5; i++) { + /* I want the standard error to go below 0.1 second. + * Two tests at least will be run (count is not > 0) */ + SMPI_SAMPLE_LOCAL(0, 0.1) { + if (verbose || n++ < 2) { + if (verbose) + fprintf(stderr, "(%12.6f)", MPI_Wtime()); + else + fprintf(stderr, "(1)"); + fprintf(stderr, + " [rank:%d] Run the first (locally benched) computation. " + "It's locally benched, and I want the standard error to go " + "below 0.1 second (count is not >0)\n", smpi_process_index()); + } + d = compute(d); } } - - fprintf(stderr,"[%d] The result of the computation is: %f\n", smpi_process_index(), d); + + if (verbose) + fprintf(stderr, "(%12.6f) [rank:%d] The result of the computation is: %f\n", + MPI_Wtime(), smpi_process_index(), d); + else + fprintf(stderr, "(2) [rank:%d] Done.\n", smpi_process_index()); MPI_Finalize(); return 0;