From 95fc03c7e0bcc12f90d48e3756166df69ade0806 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Wed, 12 May 2021 10:22:34 +0200 Subject: Debug energy --- src/simulator.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/simulator.cc') diff --git a/src/simulator.cc b/src/simulator.cc index afc6f74..de22a6b 100644 --- a/src/simulator.cc +++ b/src/simulator.cc @@ -115,6 +115,7 @@ static void obs_node(std::vector args) { if(i.is_sender){ Payload *p=new Payload(); p->DedicatedMailbox="dedicated"+selfName; + // Add hint informations to the payload if(i.use_hint && i.HasNext()){ p->HasHint=i.use_hint; p->duration=i.GetNextDuration(); @@ -122,19 +123,24 @@ static void obs_node(std::vector args) { } MODE_ON(); try { - TRACK_UPTIME(m->put(p,0,uptime)); // Send instantaneous message + // First we send and instantaneous message + // This allow first to detect if their is a receiver + // (to not cause deadlock for the extended mode) and second + // to inform the receiver if he should get a hint first + TRACK_UPTIME(m->put(p,0,uptime)); simgrid::s4u::Mailbox *m_ded= simgrid::s4u::Mailbox::by_name(p->DedicatedMailbox); // First send hint if it is required + MODE_TX(); if(p->HasHint){ TRACK_UPTIME(m_ded->put(p,i.hint_size,uptime)); XBT_INFO("%s sent a hint successfully",selfName.c_str()); } // Then try sending the data - MODE_TX(); if(i.extended) m_ded->put(p,i.data_size); else m_ded->put(p,i.data_size,uptime); + // If we reach here, data has been sent successfully XBT_INFO("%s sent data successfully",selfName.c_str()); nSend++; i.is_sender=(nSend<(i.n_nodes-1)); @@ -151,18 +157,21 @@ static void obs_node(std::vector args) { bool hintReceived=false; MODE_ON(); try { - TRACK_UPTIME(p=m->get(uptime)); // Get the instantaneous message + // Get the instantaneous message + TRACK_UPTIME(p=m->get(uptime)); simgrid::s4u::Mailbox *m_ded= simgrid::s4u::Mailbox::by_name(p->DedicatedMailbox); + // Start receiving data + MODE_RX(); if(p->HasHint){ TRACK_UPTIME(p=m_ded->get(uptime)); XBT_INFO("%s received a hint successfully",selfName.c_str()); hintReceived=true; } - MODE_RX(); if(i.extended) - p=m_ded->get(); // Fetch data + p=m_ded->get(); // Fetch data until sended else - p=m_ded->get(uptime); // Fetch data + p=m_ded->get(uptime); // Fetch data until sended or uptime expire + // If we reach here, data has been received successfully XBT_INFO("%s received data successfully",selfName.c_str()); nDataRcv++; isObserver=true; -- cgit v1.2.3