Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
first step towards asynchronous executions
[simgrid.git] / src / s4u / s4u_actor.cpp
index 86ea2e2..be0a900 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "simgrid/s4u/Actor.hpp"
 #include "simgrid/s4u/Comm.hpp"
+#include "simgrid/s4u/Exec.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Mailbox.hpp"
 
@@ -61,6 +62,11 @@ void Actor::join() {
   simcall_process_join(this->pimpl_, -1);
 }
 
+void Actor::join(double timeout)
+{
+  simcall_process_join(this->pimpl_, timeout);
+}
+
 void Actor::setAutoRestart(bool autorestart) {
   simgrid::simix::kernelImmediate([this, autorestart]() { pimpl_->auto_restart = autorestart; });
 }
@@ -173,6 +179,11 @@ void Actor::killAll(int resetPid)
   simcall_process_killall(resetPid);
 }
 
+std::map<std::string, std::string>* Actor::getProperties()
+{
+  return simgrid::simix::kernelImmediate([this] { return this->pimpl_->getProperties(); });
+}
+
 /** Retrieve the property value (or nullptr if not set) */
 const char* Actor::getProperty(const char* key)
 {
@@ -189,6 +200,22 @@ Actor* Actor::restart()
   return simgrid::simix::kernelImmediate([this]() { return pimpl_->restart(); });
 }
 
+ExecPtr Actor::exec_init(double flops_amount)
+{
+  ExecPtr res        = ExecPtr(new Exec());
+  res->runner_       = SIMIX_process_self();
+  res->flops_amount_ = flops_amount;
+  res->setRemains(flops_amount);
+  return res;
+}
+
+ExecPtr Actor::exec_async(double flops)
+{
+  ExecPtr res = exec_init(flops);
+  res->start();
+  return res;
+}
+
 // ***** this_actor *****
 
 namespace this_actor {
@@ -232,12 +259,25 @@ void execute(double flops)
   simcall_execution_wait(s);
 }
 
-void execute(double flops,double priority)
+void execute(double flops, double priority)
 {
   smx_activity_t s = simcall_execution_start(nullptr,flops,1 / priority/*priority*/,0./*bound*/);
   simcall_execution_wait(s);
 }
 
+void parallel_execute(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, double timeout)
+{
+  smx_activity_t s =
+      simcall_execution_parallel_start(nullptr, host_nb, host_list, flops_amount, bytes_amount, -1, timeout);
+  simcall_execution_wait(s);
+}
+
+void parallel_execute(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount)
+{
+  smx_activity_t s = simcall_execution_parallel_start(nullptr, host_nb, host_list, flops_amount, bytes_amount, -1, -1);
+  simcall_execution_wait(s);
+}
+
 void* recv(MailboxPtr chan) // deprecated
 {
   return chan->get();