Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix the API to isend detach() and speak about it in ChangeLog
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 5 Jul 2017 23:46:54 +0000 (01:46 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 5 Jul 2017 23:48:22 +0000 (01:48 +0200)
ChangeLog
examples/s4u/dht-chord/node.cpp
include/simgrid/s4u/Actor.hpp
include/simgrid/s4u/Comm.hpp
src/s4u/s4u_actor.cpp
src/s4u/s4u_comm.cpp
teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp
teshsuite/s4u/listen_async/listen_async.cpp

index a7ca01b..34788ca 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 SimGrid (3.17) UNRELEASED (release target: September 22 2017)
 
 SimGrid (3.17) UNRELEASED (release target: September 22 2017)
 
+ S4U
+  - start and forget about isend comms with detach()
+
 SimGrid (3.16) Released June 22. 2017.
 
  The Blooming Spring Release: developments are budding.
 SimGrid (3.16) Released June 22. 2017.
 
  The Blooming Spring Release: developments are budding.
index 02c37e4..8669478 100644 (file)
@@ -389,7 +389,7 @@ void Node::remoteNotify(int notify_id, int predecessor_candidate_id)
   // send a "Notify" request to notify_id
   XBT_DEBUG("Sending a 'Notify' request to %d", notify_id);
   simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(notify_id));
   // send a "Notify" request to notify_id
   XBT_DEBUG("Sending a 'Notify' request to %d", notify_id);
   simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(notify_id));
-  simgrid::s4u::this_actor::dsend(mailbox, message, 10);
+  simgrid::s4u::this_actor::isend(mailbox, message, 10)->detach();
 }
 
 /* This function is called periodically. It checks the immediate successor of the current node. */
 }
 
 /* This function is called periodically. It checks the immediate successor of the current node. */
@@ -431,14 +431,14 @@ void Node::handleMessage(ChordMessage* message)
       message->answer_id = fingers_[0];
       XBT_DEBUG("Sending back a 'Find Successor Answer' to %s (mailbox %s): the successor of %d is %d",
           message->issuer_host_name.c_str(), message->answer_to->name(), message->request_id, message->answer_id);
       message->answer_id = fingers_[0];
       XBT_DEBUG("Sending back a 'Find Successor Answer' to %s (mailbox %s): the successor of %d is %d",
           message->issuer_host_name.c_str(), message->answer_to->name(), message->request_id, message->answer_id);
-      simgrid::s4u::this_actor::dsend(message->answer_to, message, 10);
+      simgrid::s4u::this_actor::isend(message->answer_to, message, 10)->detach();
     } else {
       // otherwise, forward the request to the closest preceding finger in my table
       int closest = closestPrecedingFinger(message->request_id);
       XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d",
           message->request_id, closest);
       simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(closest));
     } else {
       // otherwise, forward the request to the closest preceding finger in my table
       int closest = closestPrecedingFinger(message->request_id);
       XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d",
           message->request_id, closest);
       simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(closest));
-      simgrid::s4u::this_actor::dsend(mailbox, message, 10);
+      simgrid::s4u::this_actor::isend(mailbox, message, 10)->detach();
     }
     break;
 
     }
     break;
 
@@ -448,7 +448,7 @@ void Node::handleMessage(ChordMessage* message)
     message->answer_id = pred_id_;
     XBT_DEBUG("Sending back a 'Get Predecessor Answer' to %s via mailbox '%s': my predecessor is %d",
         message->issuer_host_name.c_str(), message->answer_to->name(), message->answer_id);
     message->answer_id = pred_id_;
     XBT_DEBUG("Sending back a 'Get Predecessor Answer' to %s via mailbox '%s': my predecessor is %d",
         message->issuer_host_name.c_str(), message->answer_to->name(), message->answer_id);
-    simgrid::s4u::this_actor::dsend(message->answer_to, message, 10);
+    simgrid::s4u::this_actor::isend(message->answer_to, message, 10)->detach();
     break;
 
   case NOTIFY:
     break;
 
   case NOTIFY:
@@ -486,7 +486,7 @@ void Node::handleMessage(ChordMessage* message)
     message->type = PREDECESSOR_ALIVE_ANSWER;
     XBT_DEBUG("Sending back a 'Predecessor Alive Answer' to %s (mailbox %s)",
         message->issuer_host_name.c_str(), message->answer_to->name());
     message->type = PREDECESSOR_ALIVE_ANSWER;
     XBT_DEBUG("Sending back a 'Predecessor Alive Answer' to %s (mailbox %s)",
         message->issuer_host_name.c_str(), message->answer_to->name());
-    simgrid::s4u::this_actor::dsend(message->answer_to, message, 10);
+    simgrid::s4u::this_actor::isend(message->answer_to, message, 10)->detach();
     break;
 
   default:
     break;
 
   default:
index a61160f..333bd9c 100644 (file)
@@ -318,7 +318,6 @@ template <class Rep, class Period> inline void sleep_for(std::chrono::duration<R
   XBT_PUBLIC(void) send(MailboxPtr chan, void* payload, double simulatedSize, double timeout);
 
   XBT_PUBLIC(CommPtr) isend(MailboxPtr chan, void* payload, double simulatedSize);
   XBT_PUBLIC(void) send(MailboxPtr chan, void* payload, double simulatedSize, double timeout);
 
   XBT_PUBLIC(CommPtr) isend(MailboxPtr chan, void* payload, double simulatedSize);
-  XBT_PUBLIC(void) dsend(MailboxPtr chan, void* payload, double simulatedSize);
 
   /** @brief Returns the actor ID of the current actor (same as pid). */
   XBT_PUBLIC(aid_t) pid();
 
   /** @brief Returns the actor ID of the current actor (same as pid). */
   XBT_PUBLIC(aid_t) pid();
index f577980..1975d6e 100644 (file)
@@ -60,14 +60,14 @@ public:
   static CommPtr recv_init(MailboxPtr from);
   /** Creates and start an async recv to the mailbox @p from */
   static CommPtr recv_async(MailboxPtr from, void** data);
   static CommPtr recv_init(MailboxPtr from);
   /** Creates and start an async recv to the mailbox @p from */
   static CommPtr recv_async(MailboxPtr from, void** data);
-  /** Creates and start a detached send to the mailbox @p dest
-   *  TODO: make it possible to detach an already created comm */
-  static void send_detached(MailboxPtr dest, void* data, int simulatedSize);
 
   void start() override;
   void wait() override;
   void wait(double timeout) override;
 
 
   void start() override;
   void wait() override;
   void wait(double timeout) override;
 
+  /** Start the comm, and ignore its result. It can be completely forgotten after that. */
+  void detach();
+
   /** Sets the maximal communication rate (in byte/sec). Must be done before start */
   void setRate(double rate);
 
   /** Sets the maximal communication rate (in byte/sec). Must be done before start */
   void setRate(double rate);
 
index bfc88d3..71cff82 100644 (file)
@@ -259,11 +259,6 @@ CommPtr isend(MailboxPtr chan, void* payload, double simulatedSize)
   return Comm::send_async(chan, payload, simulatedSize);
 }
 
   return Comm::send_async(chan, payload, simulatedSize);
 }
 
-void dsend(MailboxPtr chan, void* payload, double simulatedSize)
-{
-  Comm::send_detached(chan, payload, simulatedSize);
-}
-
 CommPtr irecv(MailboxPtr chan, void** data)
 {
   return Comm::recv_async(chan, data);
 CommPtr irecv(MailboxPtr chan, void** data)
 {
   return Comm::recv_async(chan, data);
index 17a66b6..6ab47ce 100644 (file)
@@ -141,14 +141,11 @@ void Comm::wait(double timeout) {
   state_ = finished;
 }
 
   state_ = finished;
 }
 
-void Comm::send_detached(MailboxPtr dest, void* data, int simulatedSize)
+void Comm::detach()
 {
 {
-  s4u::CommPtr res = CommPtr(s4u::Comm::send_init(dest));
-  res->setRemains(simulatedSize);
-  res->srcBuff_     = data;
-  res->srcBuffSize_ = sizeof(void*);
-  res->detached_    = true;
-  res->start();
+  xbt_assert(state_ == inited, "You cannot detach communications once they are started.");
+  xbt_assert(srcBuff_ != nullptr && srcBuffSize_ != 0, "You can only detach sends, not recvs");
+  detached_ = true;
 }
 
 s4u::CommPtr Comm::send_async(MailboxPtr dest, void* data, int simulatedSize)
 }
 
 s4u::CommPtr Comm::send_async(MailboxPtr dest, void* data, int simulatedSize)
index ac41a68..bad54f1 100644 (file)
@@ -76,12 +76,12 @@ static void sender(std::vector<std::string> args)
 
       case 'd':
         XBT_INFO("Test %d: d (detached send)", test);
 
       case 'd':
         XBT_INFO("Test %d: d (detached send)", test);
-        simgrid::s4u::this_actor::dsend(mbox, (void*)mboxName, 42.0);
+        simgrid::s4u::this_actor::isend(mbox, (void*)mboxName, 42.0)->detach();
         break;
       case 'D':
         XBT_INFO("Test %d: D (sleep + detached send)", test);
         simgrid::s4u::this_actor::sleep_for(0.5);
         break;
       case 'D':
         XBT_INFO("Test %d: D (sleep + detached send)", test);
         simgrid::s4u::this_actor::sleep_for(0.5);
-        simgrid::s4u::this_actor::dsend(mbox, (void*)mboxName, 42.0);
+        simgrid::s4u::this_actor::isend(mbox, (void*)mboxName, 42.0)->detach();
         break;
       default:
         xbt_die("Unknown sender spec for test %d: '%c'", test, args[0][test - 1]);
         break;
       default:
         xbt_die("Unknown sender spec for test %d: '%c'", test, args[0][test - 1]);
index c1a0364..c4ad656 100644 (file)
@@ -31,7 +31,7 @@ static void server()
   simgrid::s4u::MailboxPtr mailbox2 = simgrid::s4u::Mailbox::byName("mailbox2");
   mailbox2->setReceiver(simgrid::s4u::Actor::self());
 
   simgrid::s4u::MailboxPtr mailbox2 = simgrid::s4u::Mailbox::byName("mailbox2");
   mailbox2->setReceiver(simgrid::s4u::Actor::self());
 
-  simgrid::s4u::this_actor::dsend(mailbox2, xbt_strdup("More data"), 0);
+  simgrid::s4u::this_actor::isend(mailbox2, xbt_strdup("More data"), 0)->detach();
 
   xbt_assert(mailbox2->listen()); // used to break.
   XBT_INFO("Task listen works on asynchronous mailboxes");
 
   xbt_assert(mailbox2->listen()); // used to break.
   XBT_INFO("Task listen works on asynchronous mailboxes");