Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
first attempt (ongoing WIP)
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 6 Jun 2017 06:16:34 +0000 (08:16 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 13 Jun 2017 20:18:11 +0000 (22:18 +0200)
24 files changed:
include/simgrid/forward.h
include/simgrid/s4u/Activity.hpp
src/kernel/activity/MailboxImpl.cpp
src/kernel/activity/MailboxImpl.hpp
src/kernel/activity/SynchroIo.cpp
src/kernel/activity/SynchroIo.hpp
src/kernel/activity/SynchroRaw.cpp
src/kernel/activity/SynchroRaw.hpp
src/mc/checker/CommunicationDeterminismChecker.cpp
src/mc/mc_base.cpp
src/mc/mc_state.h
src/msg/msg_gos.cpp
src/msg/msg_private.h
src/s4u/s4u_comm.cpp
src/simix/ActorImpl.cpp
src/simix/libsmx.cpp
src/simix/smx_global.cpp
src/simix/smx_host.cpp
src/simix/smx_host_private.h
src/simix/smx_io.cpp
src/simix/smx_network.cpp
src/simix/smx_synchro.cpp
src/smpi/smpi_global.cpp
src/smpi/smpi_request.cpp

index 64730e0..f4fede1 100644 (file)
@@ -17,8 +17,20 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
   class ActivityImpl;
+  using ActivityImplPtr = boost::intrusive_ptr<ActivityImpl>;
   XBT_PUBLIC(void) intrusive_ptr_add_ref(ActivityImpl* activity);
   XBT_PUBLIC(void) intrusive_ptr_release(ActivityImpl* activity);
+
+  class CommImpl;
+  using CommImplPtr = boost::intrusive_ptr<CommImpl>;
+  class ExecImpl;
+  using ExecImplPtr = boost::intrusive_ptr<ExecImpl>;
+  class IoImpl;
+  using IoImplPtr = boost::intrusive_ptr<IoImpl>;
+  class RawImpl;
+  using RawImplPtr = boost::intrusive_ptr<RawImpl>;
+  class SleepImpl;
+  using SleepImplPtr = boost::intrusive_ptr<SleepImpl>;
 }
 namespace routing {
   class NetPoint;
@@ -46,7 +58,7 @@ typedef simgrid::s4u::Link s4u_Link;
 typedef simgrid::s4u::File s4u_File;
 typedef simgrid::s4u::Storage s4u_Storage;
 typedef simgrid::s4u::NetZone s4u_NetZone;
-typedef simgrid::kernel::activity::ActivityImpl* smx_activity_t;
+typedef boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> smx_activity_t;
 typedef simgrid::kernel::routing::NetPoint routing_NetPoint;
 typedef simgrid::surf::Resource surf_Resource;
 typedef simgrid::trace_mgr::trace tmgr_Trace;
index aaa9e38..57ab037 100644 (file)
@@ -61,7 +61,7 @@ public:
   void *getUserData() { return userData_; }
 
 private:
-  simgrid::kernel::activity::ActivityImpl *pimpl_ = nullptr;
+  simgrid::kernel::activity::ActivityImplPtr pimpl_ = nullptr;
   e_s4u_activity_state_t state_ = inited;
   double remains_ = 0;
   void *userData_ = nullptr;
index 8c66d35..9c7ef04 100644 (file)
@@ -53,7 +53,7 @@ void MailboxImpl::setReceiver(s4u::ActorPtr actor)
 /** @brief Pushes a communication activity into a mailbox
  *  @param comm What to add
  */
-void MailboxImpl::push(activity::CommImpl* comm)
+void MailboxImpl::push(activity::CommImplPtr comm)
 {
   this->comm_queue.push_back(comm);
   comm->mbox = this;
@@ -64,7 +64,8 @@ void MailboxImpl::push(activity::CommImpl* comm)
  */
 void MailboxImpl::remove(smx_activity_t activity)
 {
-  simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(activity);
+  simgrid::kernel::activity::CommImplPtr comm =
+      boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(activity);
 
   comm->mbox = nullptr;
   for (auto it = this->comm_queue.begin(); it != this->comm_queue.end(); it++)
index ea9b272..6f13daa 100644 (file)
@@ -31,7 +31,7 @@ public:
   static MailboxImpl* byNameOrNull(const char* name);
   static MailboxImpl* byNameOrCreate(const char* name);
   void setReceiver(s4u::ActorPtr actor);
-  void push(activity::CommImpl* comm);
+  void push(activity::CommImplPtr comm);
   void remove(smx_activity_t activity);
   simgrid::s4u::Mailbox piface_; // Our interface
   char* name_;
index cef2ced..012165b 100644 (file)
@@ -7,19 +7,19 @@
 #include "src/surf/surf_interface.hpp"
 #include "src/simix/smx_private.h"
 
-void simgrid::kernel::activity::Io::suspend()
+void simgrid::kernel::activity::IoImpl::suspend()
 {
   if (surf_io)
     surf_io->suspend();
 }
 
-void simgrid::kernel::activity::Io::resume()
+void simgrid::kernel::activity::IoImpl::resume()
 {
   if (surf_io)
     surf_io->resume();
 }
 
-void simgrid::kernel::activity::Io::post()
+void simgrid::kernel::activity::IoImpl::post()
 {
   for (smx_simcall_t simcall : simcalls) {
     switch (simcall->call) {
index b9c405d..7a229bf 100644 (file)
@@ -13,14 +13,15 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
-  XBT_PUBLIC_CLASS Io : public ActivityImpl {
-  public:
-    void suspend() override;
-    void resume() override;
-    void post() override;
-
-    sg_host_t host = nullptr;
-    surf_action_t surf_io = nullptr;
+XBT_PUBLIC_CLASS IoImpl : public ActivityImpl
+{
+public:
+  void suspend() override;
+  void resume() override;
+  void post() override;
+
+  sg_host_t host        = nullptr;
+  surf_action_t surf_io = nullptr;
   };
 
 }}} // namespace simgrid::kernel::activity
index 0f9e29f..509c41d 100644 (file)
@@ -9,21 +9,21 @@
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_synchro);
 
-simgrid::kernel::activity::Raw::~Raw()
+simgrid::kernel::activity::RawImpl::~RawImpl()
 {
   sleep->unref();
 }
-void simgrid::kernel::activity::Raw::suspend()
+void simgrid::kernel::activity::RawImpl::suspend()
 {
   /* The suspension of raw synchros is delayed to when the process is rescheduled. */
 }
 
-void simgrid::kernel::activity::Raw::resume()
+void simgrid::kernel::activity::RawImpl::resume()
 {
   /* I cannot resume raw synchros directly. This is delayed to when the process is rescheduled at
    * the end of the synchro. */
 }
-void simgrid::kernel::activity::Raw::post()
+void simgrid::kernel::activity::RawImpl::post()
 {
   XBT_IN("(%p)",this);
   if (sleep->getState() == simgrid::surf::Action::State::failed)
index b85e06f..f5ef90d 100644 (file)
@@ -14,14 +14,15 @@ namespace kernel {
 namespace activity {
 
   /** Used to implement mutexes, semaphores and conditions */
-  XBT_PUBLIC_CLASS Raw : public ActivityImpl {
-  public:
-    ~Raw() override;
-    void suspend() override;
-    void resume() override;
-    void post() override;
-
-    surf_action_t sleep = nullptr;
+XBT_PUBLIC_CLASS RawImpl : public ActivityImpl
+{
+public:
+  ~RawImpl() override;
+  void suspend() override;
+  void resume() override;
+  void post() override;
+
+  surf_action_t sleep = nullptr;
   };
 
 }}} // namespace simgrid::kernel::activity
index 2410b9d..bd712ee 100644 (file)
@@ -185,7 +185,7 @@ void CommunicationDeterminismChecker::get_comm_pattern(xbt_dynar_t list, smx_sim
   if (call_type == MC_CALL_TYPE_SEND) {
     /* Create comm pattern */
     pattern->type = simgrid::mc::PatternCommunicationType::send;
-    pattern->comm_addr = simcall_comm_isend__get__result(request);
+    pattern->comm_addr = &*simcall_comm_isend__get__result(request);
 
     simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
     mc_model_checker->process().read(temp_synchro,
index ee5098e..f1b7d80 100644 (file)
@@ -79,7 +79,7 @@ bool request_is_enabled(smx_simcall_t req)
   {
     /* FIXME: check also that src and dst processes are not suspended */
     simgrid::kernel::activity::CommImpl* act =
-        static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__get__comm(req));
+        static_cast<simgrid::kernel::activity::CommImpl*>(&*simcall_comm_wait__get__comm(req));
 
 #if SIMGRID_HAVE_MC
     // Fetch from MCed memory:
@@ -107,7 +107,7 @@ bool request_is_enabled(smx_simcall_t req)
   case SIMCALL_COMM_WAITANY: {
     xbt_dynar_t comms;
     simgrid::kernel::activity::CommImpl* act =
-        static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__get__comm(req));
+        static_cast<simgrid::kernel::activity::CommImpl*>(&*simcall_comm_wait__get__comm(req));
 
 #if SIMGRID_HAVE_MC
     s_xbt_dynar_t comms_buffer;
index e4eb0d9..d6ee814 100644 (file)
@@ -24,7 +24,7 @@ enum class PatternCommunicationType {
 
 struct PatternCommunication {
   int num = 0;
-  smx_activity_t comm_addr;
+  simgrid::kernel::activity::CommImpl* comm_addr;
   PatternCommunicationType type = PatternCommunicationType::send;
   unsigned long src_proc = 0;
   unsigned long dst_proc = 0;
index 77c1b3d..27fd37d 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <xbt/ex.hpp>
 
+#include "src/kernel/activity/ExecImpl.hpp"
 #include "src/msg/msg_private.h"
 #include "src/simix/smx_private.h" /* MSG_task_listen looks inside the rdv directly. Not clean. */
 
@@ -66,12 +67,13 @@ msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeo
     simdata->setUsed();
 
     if (simdata->host_nb > 0) {
-      simdata->compute = static_cast<simgrid::kernel::activity::ExecImpl*>(simcall_execution_parallel_start(
-          task->name, simdata->host_nb, simdata->host_list, simdata->flops_parallel_amount,
-          simdata->bytes_parallel_amount, 1.0, -1.0, timeout));
+      simdata->compute =
+          boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(simcall_execution_parallel_start(
+              task->name, simdata->host_nb, simdata->host_list, simdata->flops_parallel_amount,
+              simdata->bytes_parallel_amount, 1.0, -1.0, timeout));
       XBT_DEBUG("Parallel execution action created: %p", simdata->compute);
     } else {
-      simdata->compute = static_cast<simgrid::kernel::activity::ExecImpl*>(
+      simdata->compute = boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(
           simcall_execution_start(task->name, simdata->flops_amount, simdata->priority, simdata->bound));
     }
     simcall_set_category(simdata->compute, task->category);
@@ -315,7 +317,7 @@ static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *al
   /* Send it by calling SIMIX network layer */
   smx_activity_t act = simcall_comm_isend(myself->getImpl(), mailbox->getImpl(), t_simdata->bytes_amount, t_simdata->rate,
                                          task, sizeof(void *), match_fun, cleanup, nullptr, match_data,detached);
-  t_simdata->comm = static_cast<simgrid::kernel::activity::CommImpl*>(act);
+  t_simdata->comm = boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(act);
 
   msg_comm_t comm = nullptr;
   if (not detached) {
@@ -522,7 +524,7 @@ int MSG_comm_testany(xbt_dynar_t comms)
   int finished_index = -1;
 
   /* Create the equivalent array with SIMIX objects: */
-  std::vector<simgrid::kernel::activity::ActivityImpl*> s_comms;
+  std::vector<simgrid::kernel::activity::ActivityImplPtr> s_comms;
   s_comms.reserve(xbt_dynar_length(comms));
   msg_comm_t comm;
   unsigned int cursor;
@@ -710,7 +712,8 @@ msg_task_t MSG_comm_get_task(msg_comm_t comm)
  */
 void MSG_comm_copy_data_from_SIMIX(smx_activity_t synchro, void* buff, size_t buff_size)
 {
-  simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+  simgrid::kernel::activity::CommImplPtr comm =
+      boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
 
   SIMIX_comm_copy_pointer_callback(comm, buff, buff_size);
 
@@ -797,7 +800,7 @@ msg_error_t MSG_task_send_with_timeout(msg_task_t task, const char *alias, doubl
                               t_simdata->rate, task, sizeof(void *), nullptr, nullptr, nullptr, task, 0);
     if (TRACE_is_enabled())
       simcall_set_category(comm, task->category);
-    t_simdata->comm = static_cast<simgrid::kernel::activity::CommImpl*>(comm);
+    t_simdata->comm = boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(comm);
     simcall_comm_wait(comm, timeout);
     comm->unref();
   }
@@ -868,7 +871,8 @@ int MSG_task_listen(const char *alias)
 int MSG_task_listen_from(const char *alias)
 {
   simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName(alias);
-  simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(mbox->front());
+  simgrid::kernel::activity::CommImplPtr comm =
+      boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(mbox->front());
 
   if (not comm)
     return -1;
index b083103..00164db 100644 (file)
@@ -42,8 +42,8 @@ typedef struct simdata_task {
     this->isused = false;
   }
 
-  simgrid::kernel::activity::ExecImpl* compute = nullptr; /* SIMIX modeling of computation */
-  simgrid::kernel::activity::CommImpl* comm = nullptr; /* SIMIX modeling of communication */
+  simgrid::kernel::activity::ExecImplPtr compute = nullptr; /* SIMIX modeling of computation */
+  simgrid::kernel::activity::CommImplPtr comm    = nullptr; /* SIMIX modeling of communication */
   double bytes_amount = 0.0; /* Data size */
   double flops_amount = 0.0; /* Computation size */
   msg_process_t sender = nullptr;
index c168cff..8340bd3 100644 (file)
@@ -177,7 +177,8 @@ s4u::CommPtr Comm::recv_async(MailboxPtr dest, void** data)
 
 void Comm::cancel()
 {
-  simgrid::kernel::activity::CommImpl* commPimpl = static_cast<simgrid::kernel::activity::CommImpl*>(pimpl_);
+  simgrid::kernel::activity::CommImplPtr commPimpl =
+      boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(pimpl_);
   commPimpl->cancel();
 }
 
index 2c59aab..d105dff 100644 (file)
@@ -95,7 +95,8 @@ void SIMIX_process_cleanup(smx_actor_t process)
   /* cancel non-blocking communications */
   smx_activity_t synchro = static_cast<smx_activity_t>(process->comms.front());
   while (not process->comms.empty()) {
-    simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+    simgrid::kernel::activity::CommImplPtr comm =
+        boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
 
     /* make sure no one will finish the comm after this process is destroyed,
      * because src_proc or dst_proc would be an invalid pointer */
@@ -423,14 +424,16 @@ void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer) {
   /* destroy the blocking synchro if any */
   if (process->waiting_synchro) {
 
-    simgrid::kernel::activity::ExecImpl* exec =
-        dynamic_cast<simgrid::kernel::activity::ExecImpl*>(process->waiting_synchro);
-    simgrid::kernel::activity::CommImpl* comm =
-        dynamic_cast<simgrid::kernel::activity::CommImpl*>(process->waiting_synchro);
-    simgrid::kernel::activity::SleepImpl* sleep =
-        dynamic_cast<simgrid::kernel::activity::SleepImpl*>(process->waiting_synchro);
-    simgrid::kernel::activity::Raw *raw = dynamic_cast<simgrid::kernel::activity::Raw*>(process->waiting_synchro);
-    simgrid::kernel::activity::Io *io = dynamic_cast<simgrid::kernel::activity::Io*>(process->waiting_synchro);
+    simgrid::kernel::activity::ExecImplPtr exec =
+        boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(process->waiting_synchro);
+    simgrid::kernel::activity::CommImplPtr comm =
+        boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(process->waiting_synchro);
+    simgrid::kernel::activity::SleepImplPtr sleep =
+        boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(process->waiting_synchro);
+    simgrid::kernel::activity::RawImplPtr raw =
+        boost::dynamic_pointer_cast<simgrid::kernel::activity::RawImpl>(process->waiting_synchro);
+    simgrid::kernel::activity::IoImplPtr io =
+        boost::dynamic_pointer_cast<simgrid::kernel::activity::IoImpl>(process->waiting_synchro);
 
     if (exec != nullptr) {
       exec->unref();
@@ -448,7 +451,7 @@ void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer) {
 
     } else if (raw != nullptr) {
       SIMIX_synchro_stop_waiting(process, &process->simcall);
-      delete process->waiting_synchro;
+      process->waiting_synchro->unref();
 
     } else if (io != nullptr) {
       SIMIX_io_destroy(process->waiting_synchro);
@@ -485,21 +488,21 @@ void SIMIX_process_throw(smx_actor_t process, xbt_errcat_t cat, int value, const
   /* cancel the blocking synchro if any */
   if (process->waiting_synchro) {
 
-    simgrid::kernel::activity::ExecImpl* exec =
-        dynamic_cast<simgrid::kernel::activity::ExecImpl*>(process->waiting_synchro);
+    simgrid::kernel::activity::ExecImplPtr exec =
+        boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(process->waiting_synchro);
     if (exec != nullptr) {
       SIMIX_execution_cancel(process->waiting_synchro);
     }
 
-    simgrid::kernel::activity::CommImpl* comm =
-        dynamic_cast<simgrid::kernel::activity::CommImpl*>(process->waiting_synchro);
+    simgrid::kernel::activity::CommImplPtr comm =
+        boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(process->waiting_synchro);
     if (comm != nullptr) {
       process->comms.remove(comm);
       comm->cancel();
     }
 
-    simgrid::kernel::activity::SleepImpl* sleep =
-        dynamic_cast<simgrid::kernel::activity::SleepImpl*>(process->waiting_synchro);
+    simgrid::kernel::activity::SleepImplPtr sleep =
+        boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(process->waiting_synchro);
     if (sleep != nullptr) {
       SIMIX_process_sleep_destroy(process->waiting_synchro);
       if (not xbt_dynar_member(simix_global->process_to_run, &(process)) && process != SIMIX_process_self()) {
@@ -508,12 +511,14 @@ void SIMIX_process_throw(smx_actor_t process, xbt_errcat_t cat, int value, const
       }
     }
 
-    simgrid::kernel::activity::Raw *raw = dynamic_cast<simgrid::kernel::activity::Raw*>(process->waiting_synchro);
+    simgrid::kernel::activity::RawImplPtr raw =
+        boost::dynamic_pointer_cast<simgrid::kernel::activity::RawImpl>(process->waiting_synchro);
     if (raw != nullptr) {
       SIMIX_synchro_stop_waiting(process, &process->simcall);
     }
 
-    simgrid::kernel::activity::Io *io = dynamic_cast<simgrid::kernel::activity::Io*>(process->waiting_synchro);
+    simgrid::kernel::activity::IoImplPtr io =
+        boost::dynamic_pointer_cast<simgrid::kernel::activity::IoImpl>(process->waiting_synchro);
     if (io != nullptr) {
       SIMIX_io_destroy(process->waiting_synchro);
     }
@@ -694,7 +699,8 @@ void simcall_HANDLER_process_join(smx_simcall_t simcall, smx_actor_t process, do
   simcall->issuer->waiting_synchro = sync;
 }
 
-static int SIMIX_process_join_finish(smx_process_exit_status_t status, smx_activity_t synchro){
+static int SIMIX_process_join_finish(smx_process_exit_status_t status, void* synchro)
+{
   simgrid::kernel::activity::SleepImpl* sleep = static_cast<simgrid::kernel::activity::SleepImpl*>(synchro);
 
   if (sleep->surf_sleep) {
@@ -724,14 +730,14 @@ static int SIMIX_process_join_finish(smx_process_exit_status_t status, smx_activ
 smx_activity_t SIMIX_process_join(smx_actor_t issuer, smx_actor_t process, double timeout)
 {
   smx_activity_t res = SIMIX_process_sleep(issuer, timeout);
-  static_cast<simgrid::kernel::activity::ActivityImpl*>(res)->ref();
+  (&*res)->ref();
   /* We are leaking the process here, but if we don't take the ref, we get a "use after free".
    * The correct solution would be to derivate the type SynchroSleep into a SynchroProcessJoin,
    * but the code is not clean enough for now for this.
    * The C API should first be properly replaced with the C++ one, which is a fair amount of work.
    */
   intrusive_ptr_add_ref(process);
-  SIMIX_process_on_exit(process, (int_f_pvoid_pvoid_t)SIMIX_process_join_finish, res);
+  SIMIX_process_on_exit(process, (int_f_pvoid_pvoid_t)SIMIX_process_join_finish, &*res);
   return res;
 }
 
@@ -757,7 +763,7 @@ smx_activity_t SIMIX_process_sleep(smx_actor_t process, double duration)
 
   simgrid::kernel::activity::SleepImpl* synchro = new simgrid::kernel::activity::SleepImpl();
   synchro->host = host;
-  synchro->surf_sleep                       = host->pimpl_cpu->sleep(duration);
+  synchro->surf_sleep                           = host->pimpl_cpu->sleep(duration);
   synchro->surf_sleep->setData(synchro);
   XBT_DEBUG("Create sleep synchronization %p", synchro);
 
@@ -767,7 +773,8 @@ smx_activity_t SIMIX_process_sleep(smx_actor_t process, double duration)
 void SIMIX_process_sleep_destroy(smx_activity_t synchro)
 {
   XBT_DEBUG("Destroy synchro %p", synchro);
-  simgrid::kernel::activity::SleepImpl* sleep = static_cast<simgrid::kernel::activity::SleepImpl*>(synchro);
+  simgrid::kernel::activity::SleepImplPtr sleep =
+      boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(synchro);
 
   if (sleep->surf_sleep) {
     sleep->surf_sleep->unref();
index ddb760a..5c1ee87 100644 (file)
@@ -459,7 +459,8 @@ smx_activity_t simcall_comm_iprobe(smx_mailbox_t mbox, int type, int src, int ta
 void simcall_comm_cancel(smx_activity_t synchro)
 {
   simgrid::simix::kernelImmediate([synchro] {
-    simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+    simgrid::kernel::activity::CommImplPtr comm =
+        boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
     comm->cancel();
   });
 }
index 6511f0c..808f19a 100644 (file)
@@ -356,7 +356,7 @@ static void SIMIX_wake_processes()
     XBT_DEBUG("Handling the processes whose action failed (if any)");
     while ((action = surf_model_extract_failed_action_set(model))) {
       XBT_DEBUG("   Handling Action %p",action);
-      SIMIX_simcall_exit((smx_activity_t) action->getData());
+      SIMIX_simcall_exit(static_cast<simgrid::kernel::activity::ActivityImpl*>(action->getData()));
     }
     XBT_DEBUG("Handling the processes whose action terminated normally (if any)");
     while ((action = surf_model_extract_done_action_set(model))) {
@@ -364,7 +364,7 @@ static void SIMIX_wake_processes()
       if (action->getData() == nullptr)
         XBT_DEBUG("probably vcpu's action %p, skip", action);
       else
-        SIMIX_simcall_exit((smx_activity_t) action->getData());
+        SIMIX_simcall_exit(static_cast<simgrid::kernel::activity::ActivityImpl*>(action->getData()));
     }
   }
 }
@@ -653,19 +653,19 @@ void SIMIX_display_process_status()
 
       const char* synchro_description = "unknown";
 
-      if (dynamic_cast<simgrid::kernel::activity::ExecImpl*>(process->waiting_synchro) != nullptr)
+      if (boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(process->waiting_synchro) != nullptr)
         synchro_description = "execution";
 
-      if (dynamic_cast<simgrid::kernel::activity::CommImpl*>(process->waiting_synchro) != nullptr)
+      if (boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(process->waiting_synchro) != nullptr)
         synchro_description = "communication";
 
-      if (dynamic_cast<simgrid::kernel::activity::SleepImpl*>(process->waiting_synchro) != nullptr)
+      if (boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(process->waiting_synchro) != nullptr)
         synchro_description = "sleeping";
 
-      if (dynamic_cast<simgrid::kernel::activity::Raw*>(process->waiting_synchro) != nullptr)
+      if (boost::dynamic_pointer_cast<simgrid::kernel::activity::RawImpl>(process->waiting_synchro) != nullptr)
         synchro_description = "synchronization";
 
-      if (dynamic_cast<simgrid::kernel::activity::Io*>(process->waiting_synchro) != nullptr)
+      if (boost::dynamic_pointer_cast<simgrid::kernel::activity::IoImpl>(process->waiting_synchro) != nullptr)
         synchro_description = "I/O";
 
 
index e459249..6fd7c62 100644 (file)
@@ -215,7 +215,8 @@ smx_activity_t SIMIX_execution_parallel_start(const char* name, int host_nb, sg_
 void SIMIX_execution_cancel(smx_activity_t synchro)
 {
   XBT_DEBUG("Cancel synchro %p", synchro);
-  simgrid::kernel::activity::ExecImpl* exec = static_cast<simgrid::kernel::activity::ExecImpl*>(synchro);
+  simgrid::kernel::activity::ExecImplPtr exec =
+      boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro);
 
   if (exec->surf_exec)
     exec->surf_exec->cancel();
@@ -223,21 +224,24 @@ void SIMIX_execution_cancel(smx_activity_t synchro)
 
 void SIMIX_execution_set_priority(smx_activity_t synchro, double priority)
 {
-  simgrid::kernel::activity::ExecImpl* exec = static_cast<simgrid::kernel::activity::ExecImpl*>(synchro);
+  simgrid::kernel::activity::ExecImplPtr exec =
+      boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro);
   if(exec->surf_exec)
     exec->surf_exec->setPriority(priority);
 }
 
 void SIMIX_execution_set_bound(smx_activity_t synchro, double bound)
 {
-  simgrid::kernel::activity::ExecImpl* exec = static_cast<simgrid::kernel::activity::ExecImpl*>(synchro);
+  simgrid::kernel::activity::ExecImplPtr exec =
+      boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro);
   if(exec->surf_exec)
     static_cast<simgrid::surf::CpuAction*>(exec->surf_exec)->setBound(bound);
 }
 
 void simcall_HANDLER_execution_wait(smx_simcall_t simcall, smx_activity_t synchro)
 {
-  simgrid::kernel::activity::ExecImpl* exec = static_cast<simgrid::kernel::activity::ExecImpl*>(synchro);
+  simgrid::kernel::activity::ExecImplPtr exec =
+      boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro);
   XBT_DEBUG("Wait for execution of synchro %p, state %d", synchro, (int)synchro->state);
 
   /* Associate this simcall to the synchro */
@@ -256,7 +260,7 @@ void simcall_HANDLER_execution_wait(smx_simcall_t simcall, smx_activity_t synchr
     SIMIX_execution_finish(exec);
 }
 
-void SIMIX_execution_finish(simgrid::kernel::activity::ExecImpl* exec)
+void SIMIX_execution_finish(simgrid::kernel::activity::ExecImplPtr exec)
 {
   for (smx_simcall_t simcall : exec->simcalls) {
     switch (exec->state) {
@@ -304,13 +308,15 @@ void SIMIX_set_category(smx_activity_t synchro, const char *category)
   if (synchro->state != SIMIX_RUNNING)
     return;
 
-  simgrid::kernel::activity::ExecImpl* exec = dynamic_cast<simgrid::kernel::activity::ExecImpl*>(synchro);
+  simgrid::kernel::activity::ExecImplPtr exec =
+      boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro);
   if (exec != nullptr) {
     exec->surf_exec->setCategory(category);
     return;
   }
 
-  simgrid::kernel::activity::CommImpl* comm = dynamic_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+  simgrid::kernel::activity::CommImplPtr comm =
+      boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
   if (comm != nullptr) {
     comm->surf_comm->setCategory(category);
   }
index 91149d1..7537eb4 100644 (file)
@@ -57,7 +57,7 @@ XBT_PRIVATE void SIMIX_execution_cancel(smx_activity_t synchro);
 XBT_PRIVATE void SIMIX_execution_set_priority(smx_activity_t synchro, double priority);
 XBT_PRIVATE void SIMIX_execution_set_bound(smx_activity_t synchro, double bound);
 
-XBT_PRIVATE void SIMIX_execution_finish(simgrid::kernel::activity::ExecImpl* exec);
+XBT_PRIVATE void SIMIX_execution_finish(simgrid::kernel::activity::ExecImplPtr exec);
 
 XBT_PRIVATE void SIMIX_set_category(smx_activity_t synchro, const char *category);
 
index 9ba2b7e..4371b8d 100644 (file)
@@ -33,7 +33,7 @@ smx_activity_t SIMIX_file_read(smx_file_t fd, sg_size_t size, sg_host_t host)
   if (host->isOff())
     THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname());
 
-  simgrid::kernel::activity::Io *synchro = new simgrid::kernel::activity::Io();
+  simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl();
   synchro->host = host;
   synchro->surf_io = surf_host_read(host, fd->surf_file, size);
 
@@ -56,7 +56,7 @@ smx_activity_t SIMIX_file_write(smx_file_t fd, sg_size_t size, sg_host_t host)
   if (host->isOff())
     THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname());
 
-  simgrid::kernel::activity::Io *synchro = new simgrid::kernel::activity::Io();
+  simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl();
   synchro->host = host;
   synchro->surf_io = surf_host_write(host, fd->surf_file, size);
   synchro->surf_io->setData(synchro);
@@ -78,7 +78,7 @@ smx_activity_t SIMIX_file_open(const char* fullpath, sg_host_t host)
   if (host->isOff())
     THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname());
 
-  simgrid::kernel::activity::Io *synchro = new simgrid::kernel::activity::Io();
+  simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl();
   synchro->host = host;
   synchro->surf_io = surf_host_open(host, fullpath);
   synchro->surf_io->setData(synchro);
@@ -100,7 +100,7 @@ smx_activity_t SIMIX_file_close(smx_file_t fd, sg_host_t host)
   if (host->isOff())
     THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname());
 
-  simgrid::kernel::activity::Io *synchro = new simgrid::kernel::activity::Io();
+  simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl();
   synchro->host = host;
   synchro->surf_io = surf_host_close(host, fd->surf_file);
   synchro->surf_io->setData(synchro);
@@ -178,11 +178,11 @@ int SIMIX_file_move(smx_actor_t process, smx_file_t file, const char* fullpath)
 
 void SIMIX_io_destroy(smx_activity_t synchro)
 {
-  simgrid::kernel::activity::Io *io = static_cast<simgrid::kernel::activity::Io*>(synchro);
+  simgrid::kernel::activity::IoImplPtr io = boost::static_pointer_cast<simgrid::kernel::activity::IoImpl>(synchro);
   XBT_DEBUG("Destroy synchro %p", synchro);
   if (io->surf_io)
     io->surf_io->unref();
-  delete io;
+  io->unref();
 }
 
 void SIMIX_io_finish(smx_activity_t synchro)
index 1fbcb08..09b33a8 100644 (file)
@@ -27,7 +27,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_network, simix, "SIMIX network-related syn
 static void SIMIX_waitany_remove_simcall_from_actions(smx_simcall_t simcall);
 static void SIMIX_comm_copy_data(smx_activity_t comm);
 static void SIMIX_comm_start(smx_activity_t synchro);
-static simgrid::kernel::activity::CommImpl*
+static simgrid::kernel::activity::CommImplPtr
 _find_matching_comm(boost::circular_buffer_space_optimized<smx_activity_t>* deque, e_smx_comm_type_t type,
                     int (*match_fun)(void*, void*, smx_activity_t), void* user_data, smx_activity_t my_synchro,
                     bool remove_matching);
@@ -37,7 +37,7 @@ _find_matching_comm(boost::circular_buffer_space_optimized<smx_activity_t>* dequ
  *  \param type The type of communication we are looking for (comm_send, comm_recv)
  *  \return The communication activity if found, nullptr otherwise
  */
-static simgrid::kernel::activity::CommImpl*
+static simgrid::kernel::activity::CommImplPtr
 _find_matching_comm(boost::circular_buffer_space_optimized<smx_activity_t>* deque, e_smx_comm_type_t type,
                     int (*match_fun)(void*, void*, smx_activity_t), void* this_user_data, smx_activity_t my_synchro,
                     bool remove_matching)
@@ -46,7 +46,8 @@ _find_matching_comm(boost::circular_buffer_space_optimized<smx_activity_t>* dequ
 
   for(auto it = deque->begin(); it != deque->end(); it++){
     smx_activity_t synchro = *it;
-    simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+    simgrid::kernel::activity::CommImplPtr comm =
+        boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
 
     if (comm->type == SIMIX_COMM_SEND) {
       other_user_data = comm->src_data;
@@ -105,7 +106,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx
    * ourself so that the other side also gets a chance of choosing if it wants to match with us.
    *
    * If it is not found then push our communication into the rendez-vous point */
-  simgrid::kernel::activity::CommImpl* other_comm =
+  simgrid::kernel::activity::CommImplPtr other_comm =
       _find_matching_comm(&mbox->comm_queue, SIMIX_COMM_RECEIVE, match_fun, data, this_comm, /*remove_matching*/ true);
 
   if (not other_comm) {
@@ -185,10 +186,11 @@ smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void *
     void (*copy_data_fun)(smx_activity_t, void*, size_t), // used to copy data if not default one
     void *data, double rate)
 {
-  simgrid::kernel::activity::CommImpl* this_synchro = new simgrid::kernel::activity::CommImpl(SIMIX_COMM_RECEIVE);
+  simgrid::kernel::activity::CommImplPtr this_synchro =
+      simgrid::kernel::activity::CommImplPtr(new simgrid::kernel::activity::CommImpl(SIMIX_COMM_RECEIVE));
   XBT_DEBUG("recv from %p %p. this_synchro=%p", mbox, &mbox->comm_queue, this_synchro);
 
-  simgrid::kernel::activity::CommImpl* other_comm;
+  simgrid::kernel::activity::CommImplPtr other_comm;
   //communication already done, get it inside the list of completed comms
   if (mbox->permanent_receiver != nullptr && not mbox->done_comm_queue.empty()) {
 
@@ -230,8 +232,6 @@ smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void *
     } else {
       XBT_DEBUG("Match my %p with the existing %p", this_synchro, other_comm);
 
-      other_comm = static_cast<simgrid::kernel::activity::CommImpl*>(other_comm);
-
       other_comm->state = SIMIX_READY;
       other_comm->type = SIMIX_COMM_READY;
       this_synchro->unref();
@@ -318,7 +318,8 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_activity_t synchro, do
       if (timeout < 0.0)
         THROW_IMPOSSIBLE;
 
-      simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+      simgrid::kernel::activity::CommImplPtr comm =
+          boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
       if (comm->src_proc == simcall->issuer)
         comm->state = SIMIX_SRC_TIMEOUT;
       else
@@ -335,9 +336,10 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_activity_t synchro, do
     SIMIX_comm_finish(synchro);
   } else { /* if (timeout >= 0) { we need a surf sleep action even when there is no timeout, otherwise surf won't tell us when the host fails */
     surf_action_t sleep = simcall->issuer->host->pimpl_cpu->sleep(timeout);
-    sleep->setData(synchro);
+    sleep->setData(&*synchro);
 
-    simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+    simgrid::kernel::activity::CommImplPtr comm =
+        boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
     if (simcall->issuer == comm->src_proc)
       comm->src_timeout = sleep;
     else
@@ -347,7 +349,8 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_activity_t synchro, do
 
 void simcall_HANDLER_comm_test(smx_simcall_t simcall, smx_activity_t synchro)
 {
-  simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+  simgrid::kernel::activity::CommImplPtr comm =
+      boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
 
   if (MC_is_active() || MC_record_replay_is_active()){
     simcall_comm_test__set__result(simcall, comm->src_proc && comm->dst_proc);
@@ -370,8 +373,8 @@ void simcall_HANDLER_comm_test(smx_simcall_t simcall, smx_activity_t synchro)
   }
 }
 
-void simcall_HANDLER_comm_testany(
-  smx_simcall_t simcall, simgrid::kernel::activity::ActivityImpl* comms[], size_t count)
+void simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activity::ActivityImplPtr comms[],
+                                  size_t count)
 {
   // The default result is -1 -- this means, "nothing is ready".
   // It can be changed below, but only if something matches.
@@ -382,7 +385,7 @@ void simcall_HANDLER_comm_testany(
     if(idx == -1){
       SIMIX_simcall_answer(simcall);
     }else{
-      simgrid::kernel::activity::ActivityImpl* synchro = comms[idx];
+      simgrid::kernel::activity::ActivityImplPtr synchro = comms[idx];
       simcall_comm_testany__set__result(simcall, idx);
       synchro->simcalls.push_back(simcall);
       synchro->state = SIMIX_DONE;
@@ -392,7 +395,7 @@ void simcall_HANDLER_comm_testany(
   }
 
   for (std::size_t i = 0; i != count; ++i) {
-    simgrid::kernel::activity::ActivityImpl* synchro = comms[i];
+    simgrid::kernel::activity::ActivityImplPtr synchro = comms[i];
     if (synchro->state != SIMIX_WAITING && synchro->state != SIMIX_RUNNING) {
       simcall_comm_testany__set__result(simcall, i);
       synchro->simcalls.push_back(simcall);
@@ -462,7 +465,8 @@ void SIMIX_waitany_remove_simcall_from_actions(smx_simcall_t simcall)
  */
 static inline void SIMIX_comm_start(smx_activity_t synchro)
 {
-  simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+  simgrid::kernel::activity::CommImplPtr comm =
+      boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
 
   /* If both the sender and the receiver are already there, start the communication */
   if (synchro->state == SIMIX_READY) {
@@ -471,7 +475,7 @@ static inline void SIMIX_comm_start(smx_activity_t synchro)
     simgrid::s4u::Host* receiver = comm->dst_proc->host;
 
     comm->surf_comm = surf_network_model->communicate(sender, receiver, comm->task_size, comm->rate);
-    comm->surf_comm->setData(synchro);
+    comm->surf_comm->setData(&*synchro);
     comm->state = SIMIX_RUNNING;
 
     XBT_DEBUG("Starting communication %p from '%s' to '%s' (surf_action: %p)", synchro, sender->cname(),
@@ -508,7 +512,8 @@ static inline void SIMIX_comm_start(smx_activity_t synchro)
  */
 void SIMIX_comm_finish(smx_activity_t synchro)
 {
-  simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+  simgrid::kernel::activity::CommImplPtr comm =
+      boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
 
   while (not synchro->simcalls.empty()) {
     smx_simcall_t simcall = synchro->simcalls.front();
@@ -666,7 +671,8 @@ void SIMIX_comm_set_copy_data_callback(void (*callback) (smx_activity_t, void*,
 
 void SIMIX_comm_copy_pointer_callback(smx_activity_t synchro, void* buff, size_t buff_size)
 {
-  simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+  simgrid::kernel::activity::CommImplPtr comm =
+      boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
 
   xbt_assert((buff_size == sizeof(void *)), "Cannot copy %zu bytes: must be sizeof(void*)", buff_size);
   *(void **) (comm->dst_buff) = buff;
@@ -674,7 +680,8 @@ void SIMIX_comm_copy_pointer_callback(smx_activity_t synchro, void* buff, size_t
 
 void SIMIX_comm_copy_buffer_callback(smx_activity_t synchro, void* buff, size_t buff_size)
 {
-  simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+  simgrid::kernel::activity::CommImplPtr comm =
+      boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
 
   XBT_DEBUG("Copy the data over");
   memcpy(comm->dst_buff, buff, buff_size);
@@ -690,7 +697,8 @@ void SIMIX_comm_copy_buffer_callback(smx_activity_t synchro, void* buff, size_t
  */
 void SIMIX_comm_copy_data(smx_activity_t synchro)
 {
-  simgrid::kernel::activity::CommImpl* comm = static_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+  simgrid::kernel::activity::CommImplPtr comm =
+      boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
 
   size_t buff_size = comm->src_buff_size;
   /* If there is no data to copy then return */
index c063d08..8ea26ce 100644 (file)
@@ -27,9 +27,10 @@ static smx_activity_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout)
 {
   XBT_IN("(%p, %f)",smx_host,timeout);
 
-  simgrid::kernel::activity::Raw *sync = new simgrid::kernel::activity::Raw();
+  simgrid::kernel::activity::RawImplPtr sync =
+      simgrid::kernel::activity::RawImplPtr(new simgrid::kernel::activity::RawImpl());
   sync->sleep                          = smx_host->pimpl_cpu->sleep(timeout);
-  sync->sleep->setData(sync);
+  sync->sleep->setData(&*sync);
   XBT_OUT();
   return sync;
 }
@@ -89,7 +90,7 @@ void SIMIX_synchro_finish(smx_activity_t synchro)
 
   SIMIX_synchro_stop_waiting(simcall->issuer, simcall);
   simcall->issuer->waiting_synchro = nullptr;
-  delete synchro;
+  synchro->unref();
   SIMIX_simcall_answer(simcall);
   XBT_OUT();
 }
@@ -175,7 +176,7 @@ void MutexImpl::unlock(smx_actor_t issuer)
   if (xbt_swag_size(this->sleeping) > 0) {
     /*process to wake up */
     smx_actor_t p = (smx_actor_t) xbt_swag_extract(this->sleeping);
-    delete p->waiting_synchro;
+    p->waiting_synchro->unref();
     p->waiting_synchro = nullptr;
     this->owner = p;
     SIMIX_simcall_answer(&p->simcall);
@@ -318,7 +319,7 @@ void SIMIX_cond_signal(smx_cond_t cond)
   if ((proc = (smx_actor_t) xbt_swag_extract(cond->sleeping))) {
 
     /* Destroy waiter's synchronization */
-    delete proc->waiting_synchro;
+    proc->waiting_synchro->unref();
     proc->waiting_synchro = nullptr;
 
     /* Now transform the cond wait simcall into a mutex lock one */
@@ -431,7 +432,7 @@ void SIMIX_sem_release(smx_sem_t sem)
 
   XBT_DEBUG("Sem release semaphore %p", sem);
   if ((proc = (smx_actor_t) xbt_swag_extract(sem->sleeping))) {
-    delete proc->waiting_synchro;
+    proc->waiting_synchro->unref();
     proc->waiting_synchro = nullptr;
     SIMIX_simcall_answer(&proc->simcall);
   } else {
index ad0834c..66a8f26 100644 (file)
@@ -144,7 +144,8 @@ static void check_blocks(std::vector<std::pair<size_t, size_t>> &private_blocks,
 
 void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t buff_size)
 {
-  simgrid::kernel::activity::CommImpl* comm = dynamic_cast<simgrid::kernel::activity::CommImpl*>(synchro);
+  simgrid::kernel::activity::CommImplPtr comm =
+      boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
   int src_shared                        = 0;
   int dst_shared                        = 0;
   size_t src_offset                     = 0;
index 27d5142..a20b4af 100644 (file)
@@ -544,7 +544,7 @@ int Request::testsome(int incount, MPI_Request requests[], int *indices, MPI_Sta
 
 int Request::testany(int count, MPI_Request requests[], int *index, MPI_Status * status)
 {
-  std::vector<simgrid::kernel::activity::ActivityImpl*> comms;
+  std::vector<simgrid::kernel::activity::ActivityImplPtr> comms;
   comms.reserve(count);
 
   int i;
@@ -652,8 +652,8 @@ void Request::iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status*
   }
 
   if (request->action_ != nullptr){
-    simgrid::kernel::activity::CommImpl* sync_comm =
-        static_cast<simgrid::kernel::activity::CommImpl*>(request->action_);
+    simgrid::kernel::activity::CommImplPtr sync_comm =
+        boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(request->action_);
     MPI_Request req                            = static_cast<MPI_Request>(sync_comm->src_data);
     *flag = 1;
     if(status != MPI_STATUS_IGNORE && (req->flags_ & PREPARED) == 0) {