-/** \ingroup msg_gos_functions
- * \brief Executes a parallel task and waits for its termination.
- *
- * \param task a #m_task_t to execute on the location on which the agent is running.
- *
- * \return #MSG_OK if the task was successfully completed, #MSG_TASK_CANCELED
- * or #MSG_HOST_FAILURE otherwise
- */
-MSG_error_t MSG_parallel_task_execute(m_task_t task)
-{
- simdata_task_t simdata = NULL;
- e_smx_state_t comp_state;
- simdata_process_t p_simdata;
-
- simdata = task->simdata;
- p_simdata = SIMIX_process_self_get_data(SIMIX_process_self());
-
- xbt_assert((!simdata->compute)
- && (task->simdata->isused == 0),
- "This task is executed somewhere else. Go fix your code!");
-
- xbt_assert(simdata->host_nb,
- "This is not a parallel task. Go to hell.");
-
- XBT_DEBUG("Parallel computing on %s", p_simdata->m_host->name);
-
- simdata->isused=1;
-
- simdata->compute =
- simcall_host_parallel_execute(task->name, simdata->host_nb,
- simdata->host_list,
- simdata->comp_amount,
- simdata->comm_amount, 1.0, -1.0);
- XBT_DEBUG("Parallel execution action created: %p", simdata->compute);
-
- p_simdata->waiting_action = simdata->compute;
- comp_state = simcall_host_execution_wait(simdata->compute);
- p_simdata->waiting_action = NULL;
-
- XBT_DEBUG("Finished waiting for execution of action %p, state = %d", simdata->compute, (int)comp_state);
-
- simdata->isused=0;
-
- if (comp_state == SIMIX_DONE) {
- /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- simdata->computation_amount = 0.0;
- simdata->comm = NULL;
- simdata->compute = NULL;
- MSG_RETURN(MSG_OK);
- } else if (simcall_host_get_state(SIMIX_host_self()) == 0) {
- /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- simdata->comm = NULL;
- simdata->compute = NULL;
- MSG_RETURN(MSG_HOST_FAILURE);
- } else {
- /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- simdata->comm = NULL;
- simdata->compute = NULL;
- MSG_RETURN(MSG_TASK_CANCELED);