From: Arnaud Giersch Date: Fri, 7 Jan 2011 10:17:35 +0000 (+0100) Subject: Allow changing communicator::send_count_before_flush at run-time. X-Git-Tag: v0.1~193 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/9d8b4da8a4727dbaaad640bd72136cf03614c637?ds=inline;hp=-c Allow changing communicator::send_count_before_flush at run-time. --- 9d8b4da8a4727dbaaad640bd72136cf03614c637 diff --git a/communicator.cpp b/communicator.cpp index 94cdb04..6570b01 100644 --- a/communicator.cpp +++ b/communicator.cpp @@ -21,7 +21,7 @@ std::string message::to_string() return oss.str(); } -const int communicator::send_count_before_flush = 4; +int communicator::send_count_before_flush = 4; communicator::communicator() : host((hostdata* )MSG_host_get_data(MSG_host_self())) diff --git a/communicator.h b/communicator.h index ba4b86e..b04301a 100644 --- a/communicator.h +++ b/communicator.h @@ -9,6 +9,14 @@ #include #include "hostdata.h" +// Cannot include "options.h" without error, so only declare the +// needed functions. +namespace opt { + bool parse_args(int* argc, char* argv[]); + void print(); + void usage(); +} + class message { public: enum message_type { INFO, CREDIT, LOAD, CTRL_CLOSE, DATA_CLOSE }; @@ -51,7 +59,7 @@ private: // List of pending send communications std::list sent_comm; - static const int send_count_before_flush; + static int send_count_before_flush; int send_counter; // Queue of received messages @@ -75,6 +83,12 @@ private: // Used to test if a communication is over, and to destroy it if it is static bool comm_test_n_destroy(msg_comm_t comm); + + // Make opt::* functions our friends to provide them an access to + // send_count_before_flush + friend bool opt::parse_args(int*, char* []); + friend void opt::print(); + friend void opt::usage(); }; #endif // !COMMUNICATOR_H diff --git a/options.cpp b/options.cpp index 56049ed..fd9b8f7 100644 --- a/options.cpp +++ b/options.cpp @@ -170,7 +170,7 @@ bool opt::parse_args(int* argc, char* argv[]) int c; opterr = 0; - while ((c = getopt(*argc, argv, "a:bc:C:ehi:I:l:L:N:T:vV")) != -1) { + while ((c = getopt(*argc, argv, "a:bc:C:ehi:I:l:L:N:s:T:vV")) != -1) { switch (c) { case 'a': opt::loba_algo = optarg; @@ -211,6 +211,9 @@ bool opt::parse_args(int* argc, char* argv[]) case 'N': std::istringstream(optarg) >> opt::auto_depl::nhosts; break; + case 's': + std::istringstream(optarg) >> communicator::send_count_before_flush; + break; case 'T': opt::auto_depl::topology = optarg; result = opt_helper::nol_find_prefix(opt::topologies, "topology", @@ -282,6 +285,8 @@ void opt::print() DESCR("maximum number of lb. iterations", "%s", h.val_or_string(lb_maxiter, "infinity")); DESCR("exit on close", "%s", h.on_off(exit_on_close)); + DESCR("send count before flush", "%d", + communicator::send_count_before_flush); INFO0("`----"); #undef DESCR @@ -371,6 +376,11 @@ void opt::usage() << " proc : messages from base process class\n" << " loba : messages from load-balancer\n"; + std::clog << "\nMiscellaneous low-level parameters\n"; + std::clog << o("-s count") + << "check for finished comm. every `count' send operation" + << " (" << communicator::send_count_before_flush << ")\n"; + #undef so_list #undef so #undef o