Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
modernize a few simcall_execution_* calls
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 3 Feb 2019 14:18:50 +0000 (15:18 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 3 Feb 2019 15:16:03 +0000 (16:16 +0100)
include/simgrid/s4u/Activity.hpp
include/simgrid/simix.h
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/msg/msg_gos.cpp
src/msg/msg_task.cpp
src/simix/libsmx.cpp

index f9af5ac..d8b4a68 100644 (file)
@@ -90,6 +90,8 @@ public:
   /** Retrieve the user data of the Activity */
   void* get_user_data() { return user_data_; }
 
   /** Retrieve the user data of the Activity */
   void* get_user_data() { return user_data_; }
 
+  simgrid::kernel::activity::ActivityImplPtr get_impl() { return pimpl_; }
+
 #ifndef DOXYGEN
   XBT_ATTRIB_DEPRECATED_v324("Please use Activity::wait_for()") virtual void wait(double timeout) = 0;
   XBT_ATTRIB_DEPRECATED_v323("Please use Activity::get_state()") Activity::State getState() { return state_; }
 #ifndef DOXYGEN
   XBT_ATTRIB_DEPRECATED_v324("Please use Activity::wait_for()") virtual void wait(double timeout) = 0;
   XBT_ATTRIB_DEPRECATED_v323("Please use Activity::get_state()") Activity::State getState() { return state_; }
index 3f1bb78..c0daa91 100644 (file)
@@ -180,15 +180,10 @@ XBT_PUBLIC void SIMIX_comm_finish(smx_activity_t synchro);
 
 /******************************* Host simcalls ********************************/
 #ifdef __cplusplus
 
 /******************************* Host simcalls ********************************/
 #ifdef __cplusplus
-XBT_PUBLIC smx_activity_t simcall_execution_start(std::string name, std::string category, double flops_amount,
-                                                  double priority, double bound, sg_host_t host);
 XBT_PUBLIC smx_activity_t simcall_execution_parallel_start(std::string name, int host_nb, sg_host_t* host_list,
                                                            double* flops_amount, double* bytes_amount, double rate,
                                                            double timeout);
 #endif
 XBT_PUBLIC smx_activity_t simcall_execution_parallel_start(std::string name, int host_nb, sg_host_t* host_list,
                                                            double* flops_amount, double* bytes_amount, double rate,
                                                            double timeout);
 #endif
-XBT_PUBLIC void simcall_execution_cancel(smx_activity_t execution);
-XBT_PUBLIC void simcall_execution_set_priority(smx_activity_t execution, double priority);
-XBT_PUBLIC void simcall_execution_set_bound(smx_activity_t execution, double bound);
 XBT_PUBLIC e_smx_state_t simcall_execution_wait(smx_activity_t execution);
 XBT_PUBLIC e_smx_state_t simcall_execution_test(smx_activity_t execution);
 
 XBT_PUBLIC e_smx_state_t simcall_execution_wait(smx_activity_t execution);
 XBT_PUBLIC e_smx_state_t simcall_execution_test(smx_activity_t execution);
 
index 3cd26b0..8e5fd99 100644 (file)
@@ -78,7 +78,6 @@ double simgrid::kernel::activity::ExecImpl::get_remaining()
   xbt_assert(host_ != nullptr, "Calling remains() on a parallel execution is not allowed. "
                                "We would need to return a vector instead of a scalar. "
                                "Did you mean remainingRatio() instead?");
   xbt_assert(host_ != nullptr, "Calling remains() on a parallel execution is not allowed. "
                                "We would need to return a vector instead of a scalar. "
                                "Did you mean remainingRatio() instead?");
-
   return surf_action_ ? surf_action_->get_remains() : 0;
 }
 
   return surf_action_ ? surf_action_->get_remains() : 0;
 }
 
index 6ea0231..4ed1ab7 100644 (file)
@@ -33,6 +33,7 @@ public:
 
   /* The host where the execution takes place. nullptr means this is a parallel exec (and only surf knows the hosts) */
   s4u::Host* host_ = nullptr;
 
   /* The host where the execution takes place. nullptr means this is a parallel exec (and only surf knows the hosts) */
   s4u::Host* host_ = nullptr;
+
 private:
   resource::Action* timeout_detector_ = nullptr;
 
 private:
   resource::Action* timeout_detector_ = nullptr;
 
index 422ba8d..10e43af 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/Exception.hpp"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/Exception.hpp"
+#include <cmath>
 
 #include "simgrid/s4u/Mailbox.hpp"
 #include "src/instr/instr_private.hpp"
 
 #include "simgrid/s4u/Mailbox.hpp"
 #include "src/instr/instr_private.hpp"
@@ -68,9 +69,17 @@ msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeo
       if (task->category != nullptr)
         simcall_set_category(simdata->compute, task->category);
     } else {
       if (task->category != nullptr)
         simcall_set_category(simdata->compute, task->category);
     } else {
-      simdata->compute = boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(
-          simcall_execution_start(task->name ?: "", task->category ?: "", simdata->flops_amount, simdata->priority,
-                                  simdata->bound, MSG_process_get_host(MSG_process_self())));
+      sg_host_t host   = MSG_process_get_host(MSG_process_self());
+      simdata->compute = simgrid::simix::simcall([task, host] {
+        return simgrid::kernel::activity::ExecImplPtr(
+            new simgrid::kernel::activity::ExecImpl(task->name ?: "", task->category ?: "",
+                                                    /*timeout_detector*/ nullptr, host));
+      });
+      /* checking for infinite values */
+      xbt_assert(std::isfinite(simdata->flops_amount), "flops_amount is not finite!");
+      xbt_assert(std::isfinite(simdata->priority), "priority is not finite!");
+
+      simdata->compute->start(simdata->flops_amount, simdata->priority, simdata->bound);
     }
 
     comp_state = simcall_execution_wait(simdata->compute);
     }
 
     comp_state = simcall_execution_wait(simdata->compute);
index 14b3ce6..bf8de7e 100644 (file)
@@ -6,6 +6,7 @@
 #include "msg_private.hpp"
 #include "src/simix/smx_private.hpp"
 #include <algorithm>
 #include "msg_private.hpp"
 #include "src/simix/smx_private.hpp"
 #include <algorithm>
+#include <cmath>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, "Logging specific to MSG (task)");
 
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, "Logging specific to MSG (task)");
 
@@ -186,7 +187,7 @@ msg_error_t MSG_task_cancel(msg_task_t task)
 
   simdata_task_t simdata = task->simdata;
   if (simdata->compute) {
 
   simdata_task_t simdata = task->simdata;
   if (simdata->compute) {
-    simcall_execution_cancel(simdata->compute);
+    simgrid::simix::simcall([simdata] { simdata->compute->cancel(); });
   } else if (simdata->comm) {
     simcall_comm_cancel(simdata->comm);
   }
   } else if (simdata->comm) {
     simcall_comm_cancel(simdata->comm);
   }
@@ -275,8 +276,9 @@ double MSG_task_get_bytes_amount(msg_task_t task)
 void MSG_task_set_priority(msg_task_t task, double priority)
 {
   task->simdata->priority = 1 / priority;
 void MSG_task_set_priority(msg_task_t task, double priority)
 {
   task->simdata->priority = 1 / priority;
+  xbt_assert(std::isfinite(task->simdata->priority), "priority is not finite!");
   if (task->simdata->compute)
   if (task->simdata->compute)
-    simcall_execution_set_priority(task->simdata->compute, task->simdata->priority);
+    simgrid::simix::simcall([task] { task->simdata->compute->set_priority(task->simdata->priority); });
 }
 
 /** @brief Changes the maximum CPU utilization of a computation task (in flops/s).
 }
 
 /** @brief Changes the maximum CPU utilization of a computation task (in flops/s).
@@ -290,5 +292,5 @@ void MSG_task_set_bound(msg_task_t task, double bound)
 
   task->simdata->bound = bound;
   if (task->simdata->compute)
 
   task->simdata->bound = bound;
   if (task->simdata->compute)
-    simcall_execution_set_bound(task->simdata->compute, task->simdata->bound);
+    simgrid::simix::simcall([task, bound] { task->simdata->compute->set_bound(bound); });
 }
 }
index 7269508..4907a95 100644 (file)
@@ -26,33 +26,6 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
 
 #include "popping_bodies.cpp"
 
 
 #include "popping_bodies.cpp"
 
-/**
- * @ingroup simix_process_management
- * @brief Creates a synchro that executes some computation of a host.
- *
- * This function creates a SURF action and allocates the data necessary
- * to create the SIMIX synchro. It can raise a HostFailureException exception if the host crashed.
- *
- * @param name Name of the execution synchro to create
- * @param category Tracing category
- * @param flops_amount amount Computation amount (in flops)
- * @param priority computation priority
- * @param bound Maximal speed for this execution (in flops) or -1 if no limit
- * @param host host where the synchro will be executed
- * @return A new SIMIX execution synchronization
- */
-smx_activity_t simcall_execution_start(std::string name, std::string category, double flops_amount, double priority,
-                                       double bound, simgrid::s4u::Host* host)
-{
-  /* checking for infinite values */
-  xbt_assert(std::isfinite(flops_amount), "flops_amount is not finite!");
-  xbt_assert(std::isfinite(priority), "priority is not finite!");
-
-  return simgrid::simix::simcall([name, category, flops_amount, priority, bound, host] {
-    return SIMIX_execution_start(name, category, flops_amount, priority, bound, host);
-  });
-}
-
 /**
  * @ingroup simix_process_management
  * @brief Creates a synchro that may involve parallel computation on
 /**
  * @ingroup simix_process_management
  * @brief Creates a synchro that may involve parallel computation on
@@ -90,59 +63,6 @@ smx_activity_t simcall_execution_parallel_start(std::string name, int host_nb, s
   });
 }
 
   });
 }
 
-/**
- * @ingroup simix_process_management
- * @brief Cancels an execution synchro.
- *
- * This functions stops the execution. It calls a surf function.
- * @param execution The execution synchro to cancel
- */
-void simcall_execution_cancel(smx_activity_t execution)
-{
-  simgrid::kernel::activity::ExecImplPtr exec =
-      boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(execution);
-  if (exec->surf_action_ == nullptr) // FIXME: One test fails if I remove this, but I don't get why...
-    return;
-  simgrid::simix::simcall([exec] { exec->cancel(); });
-}
-
-/**
- * @ingroup simix_process_management
- * @brief Changes the priority of an execution synchro.
- *
- * This functions changes the priority only. It calls a surf function.
- * @param execution The execution synchro
- * @param priority The new priority
- */
-void simcall_execution_set_priority(smx_activity_t execution, double priority)
-{
-  /* checking for infinite values */
-  xbt_assert(std::isfinite(priority), "priority is not finite!");
-  simgrid::simix::simcall([execution, priority] {
-
-    simgrid::kernel::activity::ExecImplPtr exec =
-        boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(execution);
-    exec->set_priority(priority);
-  });
-}
-
-/**
- * @ingroup simix_process_management
- * @brief Changes the capping (the maximum CPU utilization) of an execution synchro.
- *
- * This functions changes the capping only. It calls a surf function.
- * @param execution The execution synchro
- * @param bound The new bound
- */
-void simcall_execution_set_bound(smx_activity_t execution, double bound)
-{
-  simgrid::simix::simcall([execution, bound] {
-    simgrid::kernel::activity::ExecImplPtr exec =
-        boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(execution);
-    exec->set_bound(bound);
-  });
-}
-
 /**
  * @ingroup simix_host_management
  * @brief Waits for the completion of an execution synchro and destroy it.
 /**
  * @ingroup simix_host_management
  * @brief Waits for the completion of an execution synchro and destroy it.