/** 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_; }
/******************************* 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 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_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;
}
/* 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;
* 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"
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);
#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)");
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);
}
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)
- 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).
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); });
}
#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 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.