static void monitor(simgrid::s4u::ExecPtr activity)
{
- while (activity->getRemains() > 0) { // FIXME: use a test() here once that function is implemented
+ while (not activity->test()) {
XBT_INFO("activity remaining duration: %g (%.0f%%)", activity->getRemains(), 100 * activity->getRemainingRatio());
simgrid::s4u::this_actor::sleep_for(5);
}
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);
/**************************** Process simcalls ********************************/
SG_BEGIN_DECL()
this->start();
}
+ if (simcall_execution_test(pimpl_)) {
+ state_ = finished;
+ return true;
+ }
+
return false;
}
return (e_smx_state_t) simcall_BODY_execution_wait(execution);
}
+e_smx_state_t simcall_execution_test(smx_activity_t execution)
+{
+ return (e_smx_state_t)simcall_BODY_execution_test(execution);
+}
+
/**
* \ingroup simix_process_management
* \brief Kills all SIMIX processes.
simgrid::simix::marshal<int>(simcall->result, result);
}
+static inline boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>
+simcall_execution_test__get__execution(smx_simcall_t simcall)
+{
+ return simgrid::simix::unmarshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall->args[0]);
+}
+static inline simgrid::kernel::activity::ActivityImpl* simcall_execution_test__getraw__execution(smx_simcall_t simcall)
+{
+ return simgrid::simix::unmarshal_raw<simgrid::kernel::activity::ActivityImpl*>(simcall->args[0]);
+}
+static inline void
+simcall_execution_test__set__execution(smx_simcall_t simcall,
+ boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> arg)
+{
+ simgrid::simix::marshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall->args[0], arg);
+}
+static inline int simcall_execution_test__get__result(smx_simcall_t simcall)
+{
+ return simgrid::simix::unmarshal<int>(simcall->result);
+}
+static inline int simcall_execution_test__getraw__result(smx_simcall_t simcall)
+{
+ return simgrid::simix::unmarshal_raw<int>(simcall->result);
+}
+static inline void simcall_execution_test__set__result(smx_simcall_t simcall, int result)
+{
+ simgrid::simix::marshal<int>(simcall->result, result);
+}
+
static inline smx_actor_t simcall_process_on_exit__get__process(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]);
simcall_HANDLER_execution_start(smx_simcall_t simcall, const char* name, double flops_amount, double priority,
double bound, sg_host_t host);
XBT_PRIVATE void simcall_HANDLER_execution_wait(smx_simcall_t simcall, boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> execution);
+XBT_PRIVATE void
+simcall_HANDLER_execution_test(smx_simcall_t simcall,
+ boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> execution);
XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_HANDLER_comm_iprobe(smx_simcall_t simcall, smx_mailbox_t mbox, int type, simix_match_func_t match_fun, void* data);
XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout);
XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, int detached);
return simcall<int, boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(SIMCALL_EXECUTION_WAIT, execution);
}
+inline static int simcall_BODY_execution_test(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> execution)
+{
+ if (0) /* Go to that function to follow the code flow through the simcall barrier */
+ simcall_HANDLER_execution_test(&SIMIX_process_self()->simcall, execution);
+ return simcall<int, boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(SIMCALL_EXECUTION_TEST, execution);
+}
+
inline static void simcall_BODY_process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void* data)
{
if (0) /* Go to that function to follow the code flow through the simcall barrier */
SIMCALL_EXECUTION_START,
SIMCALL_EXECUTION_PARALLEL_START,
SIMCALL_EXECUTION_WAIT,
+ SIMCALL_EXECUTION_TEST,
SIMCALL_PROCESS_ON_EXIT,
SIMCALL_COMM_IPROBE,
SIMCALL_COMM_SEND,
"SIMCALL_EXECUTION_START",
"SIMCALL_EXECUTION_PARALLEL_START",
"SIMCALL_EXECUTION_WAIT",
+ "SIMCALL_EXECUTION_TEST",
"SIMCALL_PROCESS_ON_EXIT",
"SIMCALL_COMM_IPROBE",
"SIMCALL_COMM_SEND",
simcall_HANDLER_execution_wait(simcall, simgrid::simix::unmarshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall->args[0]));
break;
+case SIMCALL_EXECUTION_TEST:
+ simcall_HANDLER_execution_test(
+ simcall,
+ simgrid::simix::unmarshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall->args[0]));
+ break;
+
case SIMCALL_PROCESS_ON_EXIT:
SIMIX_process_on_exit(simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]), simgrid::simix::unmarshal<int_f_pvoid_pvoid_t>(simcall->args[1]), simgrid::simix::unmarshal<void*>(simcall->args[2]));
SIMIX_simcall_answer(simcall);
boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl> execution_start(const char* name, double flops_amount, double priority, double bound, sg_host_t host);
boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl> execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, double rate, double timeout) [[nohandler]];
int execution_wait(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> execution) [[block]];
+int execution_test(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> execution) [[block]];
void process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void* data) [[nohandler]];
/* set surf's synchro */
if (MC_is_active() || MC_record_replay_is_active()) {
synchro->state = SIMIX_DONE;
- SIMIX_execution_finish(exec);
+ SIMIX_execution_finish(synchro);
return;
}
/* If the synchro is already finished then perform the error handling */
if (synchro->state != SIMIX_RUNNING)
- SIMIX_execution_finish(exec);
+ SIMIX_execution_finish(synchro);
}
-void SIMIX_execution_finish(simgrid::kernel::activity::ExecImplPtr exec)
+void simcall_HANDLER_execution_test(smx_simcall_t simcall, smx_activity_t synchro)
{
- for (smx_simcall_t const& simcall : exec->simcalls) {
+ simgrid::kernel::activity::ExecImplPtr exec =
+ boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro);
+
+ simcall_execution_test__set__result(simcall, (synchro->state != SIMIX_WAITING && synchro->state != SIMIX_RUNNING));
+ if (simcall_execution_test__get__result(simcall)) {
+ synchro->simcalls.push_back(simcall);
+ SIMIX_execution_finish(synchro);
+ } else {
+ SIMIX_simcall_answer(simcall);
+ }
+ /* If the synchro is already finished then perform the error handling */
+ if (synchro->state != SIMIX_RUNNING)
+ SIMIX_execution_finish(synchro);
+}
+
+void SIMIX_execution_finish(smx_activity_t synchro)
+{
+ simgrid::kernel::activity::ExecImplPtr exec =
+ boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro);
+
+ while (not synchro->simcalls.empty()) {
+ smx_simcall_t simcall = synchro->simcalls.front();
+ synchro->simcalls.pop_front();
switch (exec->state) {
case SIMIX_DONE:
XBT_PRIVATE void SIMIX_host_autorestart(sg_host_t host);
-XBT_PRIVATE void SIMIX_execution_finish(simgrid::kernel::activity::ExecImplPtr exec);
+XBT_PRIVATE void SIMIX_execution_finish(smx_activity_t synchro);
XBT_PRIVATE void SIMIX_set_category(smx_activity_t synchro, const char* category);
}