From 2bc69b40779f2a3b41d5ecc385dc94628bc73996 Mon Sep 17 00:00:00 2001 From: Benjamin BOUVIER Date: Tue, 18 Sep 2012 22:11:13 -0400 Subject: [PATCH] MPI Distrib exp: switch for choosing whether workers should print the waiting time or not. --- eo/test/mpi/t-mpi-distrib-exp.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/eo/test/mpi/t-mpi-distrib-exp.cpp b/eo/test/mpi/t-mpi-distrib-exp.cpp index 6f5b9db6f..8f6750234 100644 --- a/eo/test/mpi/t-mpi-distrib-exp.cpp +++ b/eo/test/mpi/t-mpi-distrib-exp.cpp @@ -53,13 +53,22 @@ typedef SerializableBase type; */ struct Wait : public eoUF< type &, void > { + Wait( bool print ) : _print( print ) + { + // empty + } + void operator()( type & milliseconds ) { - std::cout << "Sleeping for " << milliseconds << "ms..." << std::endl; + if( _print ) + std::cout << "Sleeping for " << milliseconds << "ms..." << std::endl; // usleep takes an input in microseconds usleep( milliseconds * 1000 ); } -} wait; + + private: + bool _print; +}; /** * @brief Represents a distribution of processing times. @@ -241,6 +250,7 @@ int main( int argc, char** argv ) // General parameters for the experimentation unsigned size = parser.createParam( 10U, "size", "Number of elements to distribute.", 's', "Distribution").value(); unsigned packet_size = parser.createParam( 1U, "packet-size", "Number of elements to distribute at each time for a single worker.", 'p', "Parallelization").value(); + bool worker_print_waiting_time = parser.createParam( false, "print-waiting-time", "Do the workers need to print the time they wait?", '\0', "Parallelization").value(); std::vector distribs; distribs.push_back( &uniformDistribution ); @@ -281,6 +291,7 @@ int main( int argc, char** argv ) Distribution& distrib = *pdistrib; distrib.fill( size ); + Wait wait( worker_print_waiting_time ); ParallelApplyStore< type > store( wait, DEFAULT_MASTER, packet_size ); store.data( distrib ); DynamicAssignmentAlgorithm scheduling;