From: Arnaud Giersch Date: Wed, 12 Jan 2011 12:58:26 +0000 (+0100) Subject: Do not call flush automatically in communcator::send... X-Git-Tag: v0.1~188^2~43 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/404a8d5b50296756e0896c1914750fa235720946?ds=sidebyside Do not call flush automatically in communcator::send... ... and insert appropriate calls in process methods. The goal is here to destroy achieved communications as soon as possible, and avoid a bug in SimGrid 3.5 that make the simulation very slow when there are many communications. --- diff --git a/communicator.cpp b/communicator.cpp index 0f9bc7e..753b04a 100644 --- a/communicator.cpp +++ b/communicator.cpp @@ -21,13 +21,10 @@ std::string message::to_string() return oss.str(); } -int communicator::send_count_before_flush = 4; - communicator::communicator() : host((hostdata* )MSG_host_get_data(MSG_host_self())) , mutex(xbt_mutex_init()) , cond(xbt_cond_init()) - , send_counter(0) , ctrl_task(NULL) , ctrl_comm(NULL) , data_task(NULL) @@ -83,11 +80,6 @@ void communicator::send(const char* dest, message* msg) m_task_t task = MSG_task_create("message", 0.0, msg_size, msg); msg_comm_t comm = MSG_task_isend(task, dest); sent_comm.push_back(comm); - - if (++send_counter >= send_count_before_flush) { - flush(false); - send_counter = 0; - } } bool communicator::recv(message*& msg, m_host_t& from, bool wait) diff --git a/communicator.h b/communicator.h index b04301a..a2f94e5 100644 --- a/communicator.h +++ b/communicator.h @@ -59,8 +59,6 @@ private: // List of pending send communications std::list sent_comm; - static int send_count_before_flush; - int send_counter; // Queue of received messages std::queue received; @@ -83,12 +81,6 @@ 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 fd9b8f7..c4ae59a 100644 --- a/options.cpp +++ b/options.cpp @@ -211,9 +211,6 @@ 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", @@ -285,8 +282,6 @@ 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 @@ -376,10 +371,7 @@ 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"; + // std::clog << "\nMiscellaneous low-level parameters\n"; #undef so_list #undef so diff --git a/process.cpp b/process.cpp index 53cbb59..b6afb49 100644 --- a/process.cpp +++ b/process.cpp @@ -227,6 +227,7 @@ void process::send() bind(&process::send1_no_bookkeeping, this, _1)); prev_load_broadcast = load; } + comm.flush(false); } void process::receive(bool wait) @@ -263,6 +264,7 @@ void process::receive(bool wait) delete msg; wait = false; // only wait on first recv } + comm.flush(false); } void process::finalize1(neighbor& nb) @@ -286,8 +288,10 @@ void process::finalize() DEBUG2("wait for CLOSE from %lu neighbor%s", (unsigned long )neigh.size(), ESSE(neigh.size())); - while (may_receive()) + while (may_receive()) { + comm.flush(false); receive(true); + } comm.flush(true); }