Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
back to normal ... keep progressing towards modern simcalls for all
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Sat, 5 Feb 2022 17:56:24 +0000 (18:56 +0100)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Sat, 5 Feb 2022 17:56:24 +0000 (18:56 +0100)
src/kernel/activity/CommImpl.cpp
src/kernel/actor/SimcallObserver.hpp
src/smpi/mpi/smpi_request.cpp

index 1539a20..f8f4db7 100644 (file)
@@ -320,11 +320,6 @@ CommImpl::isend(actor::ActorImpl* sender, MailboxImpl* mbox, double task_size, d
   else
     other_comm->start();
 
-  if (auto* observer = dynamic_cast<actor::CommIsendSimcall*>(sender->simcall_.observer_)) {
-    observer->set_result(detached ? nullptr : other_comm);
-    sender->simcall_answer();
-  }
-
   return (detached ? nullptr : other_comm);
 }
 
@@ -394,13 +389,9 @@ ActivityImplPtr CommImpl::irecv(actor::ActorImpl* receiver, MailboxImpl* mbox, u
   }
   other_comm->start();
 
-  if (auto* observer = dynamic_cast<actor::CommIrecvSimcall*>(receiver->simcall_.observer_)) {
-    observer->set_result(other_comm);
-    receiver->simcall_answer();
-  }
-
   return other_comm;
 }
+
 bool CommImpl::test(actor::ActorImpl* issuer)
 {
   if ((MC_is_active() || MC_record_replay_is_active()) && src_actor_ && dst_actor_)
index 69dc11d..ad6e824 100644 (file)
@@ -244,7 +244,7 @@ public:
   int get_value() const { return next_value_; }
 };
 
-class CommIsendSimcall : public ResultingSimcall<activity::ActivityImplPtr> {
+class CommIsendSimcall : public SimcallObserver {
   activity::MailboxImpl* mbox_;
   double payload_size_;
   double rate_;
@@ -263,7 +263,7 @@ public:
                    void (*clean_fun)(void*), // used to free the synchro in case of problem after a detached send
                    void (*copy_data_fun)(activity::CommImpl*, void*, size_t), // used to copy data if not default one
                    void* payload, bool detached)
-      : ResultingSimcall(actor, nullptr)
+      : SimcallObserver(actor)
       , mbox_(mbox)
       , payload_size_(payload_size)
       , rate_(rate)
@@ -297,7 +297,7 @@ public:
   bool is_detached() const { return detached_; }
 };
 
-class CommIrecvSimcall : public ResultingSimcall<activity::ActivityImplPtr> {
+class CommIrecvSimcall : public SimcallObserver {
   activity::MailboxImpl* mbox_;
   unsigned char* dst_buff_;
   size_t* dst_buff_size_;
@@ -311,7 +311,7 @@ public:
   CommIrecvSimcall(ActorImpl* actor, activity::MailboxImpl* mbox, unsigned char* dst_buff, size_t* dst_buff_size,
                    bool (*match_fun)(void*, void*, activity::CommImpl*),
                    void (*copy_data_fun)(activity::CommImpl*, void*, size_t), void* payload, double rate)
-      : ResultingSimcall(actor, nullptr)
+      : SimcallObserver(actor)
       , mbox_(mbox)
       , dst_buff_(dst_buff)
       , dst_buff_size_(dst_buff_size)
index 3dfd3c5..b8e9e61 100644 (file)
@@ -510,28 +510,23 @@ void Request::start()
     }
     if(!is_probe)
       flags_ &= ~MPI_REQ_PROBE;
-    action_   = simcall_comm_irecv(
-        process->get_actor()->get_impl(), mailbox->get_impl(), buf_, &real_size_, &match_recv,
-        process->replaying() ? &smpi_comm_null_copy_buffer_callback : smpi_comm_copy_data_callback, this, -1.0);
-
-    //    kernel::actor::CommIrecvSimcall observer{process->get_actor()->get_impl(),
-    //                                             mailbox->get_impl(),
-    //                                             static_cast<unsigned char*>(buf_),
-    //                                             &real_size_,
-    //                                             &match_recv,
-    //                                             process->replaying() ? &smpi_comm_null_copy_buffer_callback
-    //                                                                  : smpi_comm_copy_data_callback,
-    //                                             this,
-    //                                             -1.0};
-    //
-    //    action_ = kernel::actor::simcall_blocking(
-    //        [&observer] {
-    //          return kernel::activity::CommImpl::irecv(
-    //              observer.get_issuer(), observer.get_mailbox(), observer.get_dst_buff(),
-    //              observer.get_dst_buff_size(), observer.match_fun_, observer.copy_data_fun_, observer.get_payload(),
-    //              observer.get_rate());
-    //        },
-    //        &observer);
+    kernel::actor::CommIrecvSimcall observer{process->get_actor()->get_impl(),
+                                             mailbox->get_impl(),
+                                             static_cast<unsigned char*>(buf_),
+                                             &real_size_,
+                                             &match_recv,
+                                             process->replaying() ? &smpi_comm_null_copy_buffer_callback
+                                                                  : smpi_comm_copy_data_callback,
+                                             this,
+                                             -1.0};
+
+    action_ = kernel::actor::simcall(
+        [&observer] {
+          return kernel::activity::CommImpl::irecv(
+              observer.get_issuer(), observer.get_mailbox(), observer.get_dst_buff(), observer.get_dst_buff_size(),
+              observer.match_fun_, observer.copy_data_fun_, observer.get_payload(), observer.get_rate());
+        },
+        &observer);
 
     XBT_DEBUG("recv simcall posted");
 
@@ -628,28 +623,21 @@ void Request::start()
     }
 
     size_t payload_size_ = size_ + 16;//MPI enveloppe size (tag+dest+communicator)
-    action_              = simcall_comm_isend(
-                     simgrid::kernel::actor::ActorImpl::by_pid(src_), mailbox->get_impl(), payload_size_, -1.0, buf, real_size_,
-                     &match_send,
-                     &xbt_free_f, // how to free the userdata if a detached send fails
+    kernel::actor::CommIsendSimcall observer{
+        simgrid::kernel::actor::ActorImpl::by_pid(src_), mailbox->get_impl(), static_cast<double>(payload_size_), -1,
+        static_cast<unsigned char*>(buf), real_size_, &match_send,
+        &xbt_free_f, // how to free the userdata if a detached send fails
         process->replaying() ? &smpi_comm_null_copy_buffer_callback : smpi_comm_copy_data_callback, this,
-                     // detach if msg size < eager/rdv switch limit
-                     detached_);
-    //      kernel::actor::CommIsendSimcall observer{
-    //        simgrid::kernel::actor::ActorImpl::by_pid(src_), mailbox->get_impl(), payload_size_, -1,
-    //        static_cast<unsigned char*>(buf), real_size_, &match_send,
-    //        &xbt_free_f, // how to free the userdata if a detached send fails
-    //        process->replaying() ? &smpi_comm_null_copy_buffer_callback : smpi_comm_copy_data_callback, this,
-    //        // detach if msg size < eager/rdv switch limit
-    //        detached_};
-    //    action_ = kernel::actor::simcall_blocking(
-    //        [&observer] {
-    //          return kernel::activity::CommImpl::isend(
-    //              observer.get_issuer(), observer.get_mailbox(), observer.get_payload_size(), observer.get_rate(),
-    //              observer.get_src_buff(), observer.get_src_buff_size(), observer.match_fun_, observer.clean_fun_,
-    //              observer.copy_data_fun_, observer.get_payload(), observer.is_detached());
-    //        },
-    //        &observer);
+        // detach if msg size < eager/rdv switch limit
+        detached_};
+    action_ = kernel::actor::simcall(
+        [&observer] {
+          return kernel::activity::CommImpl::isend(
+              observer.get_issuer(), observer.get_mailbox(), observer.get_payload_size(), observer.get_rate(),
+              observer.get_src_buff(), observer.get_src_buff_size(), observer.match_fun_, observer.clean_fun_,
+              observer.copy_data_fun_, observer.get_payload(), observer.is_detached());
+        },
+        &observer);
     XBT_DEBUG("send simcall posted");
 
     /* FIXME: detached sends are not traceable (action_ == nullptr) */