+smx_synchro_t SIMIX_process_parallel_execute(const char *name,
+ int host_nb, sg_host_t *host_list,
+ double *flops_amount, double *bytes_amount,
+ double amount, double rate){
+
+ sg_host_t*host_list_cpy = NULL;
+ int i;
+
+ /* alloc structures and initialize */
+ smx_synchro_t synchro = xbt_mallocator_get(simix_global->synchro_mallocator);
+ synchro->type = SIMIX_SYNC_PARALLEL_EXECUTE;
+ synchro->name = xbt_strdup(name);
+ synchro->state = SIMIX_RUNNING;
+ synchro->execution.host = NULL; /* FIXME: do we need the list of hosts? */
+ synchro->category = NULL;
+
+ /* set surf's synchro */
+ host_list_cpy = xbt_new0(sg_host_t, host_nb);
+ for (i = 0; i < host_nb; i++)
+ host_list_cpy[i] = host_list[i];
+
+
+ /* FIXME: what happens if host_list contains VMs and PMs. If
+ * execute_parallel_task() does not change the state of the model, we can mix
+ * them. */
+ surf_model_t ws_model = surf_resource_model(host_list[0], SURF_HOST_LEVEL);
+ for (i = 1; i < host_nb; i++) {
+ surf_model_t ws_model_tmp = surf_resource_model(host_list[i], SURF_HOST_LEVEL);
+ if (ws_model_tmp != ws_model) {
+ XBT_CRITICAL("mixing VMs and PMs is not supported");
+ DIE_IMPOSSIBLE;
+ }
+ }
+
+ /* set surf's synchro */
+ if (!MC_is_active() && !MC_record_replay_is_active()) {
+ synchro->execution.surf_exec =
+ surf_host_model_execute_parallel_task(surf_host_model,
+ host_nb, host_list_cpy, flops_amount, bytes_amount, rate);
+
+ surf_action_set_data(synchro->execution.surf_exec, synchro);
+ }
+ XBT_DEBUG("Create parallel execute synchro %p", synchro);
+
+ return synchro;
+}
+
+void SIMIX_process_execution_destroy(smx_synchro_t synchro){
+ XBT_DEBUG("Destroy synchro %p", synchro);
+
+ if (synchro->execution.surf_exec) {
+ surf_action_unref(synchro->execution.surf_exec);
+ synchro->execution.surf_exec = NULL;
+ }
+ xbt_free(synchro->name);
+ xbt_mallocator_release(simix_global->synchro_mallocator, synchro);
+}
+
+void SIMIX_process_execution_cancel(smx_synchro_t synchro){
+ XBT_DEBUG("Cancel synchro %p", synchro);
+
+ if (synchro->execution.surf_exec)
+ surf_action_cancel(synchro->execution.surf_exec);
+}
+
+double SIMIX_process_execution_get_remains(smx_synchro_t synchro){
+ double result = 0.0;
+
+ if (synchro->state == SIMIX_RUNNING)
+ result = surf_action_get_remains(synchro->execution.surf_exec);
+
+ return result;
+}
+
+e_smx_state_t SIMIX_process_execution_get_state(smx_synchro_t synchro){
+ return synchro->state;
+}
+
+void SIMIX_process_execution_set_priority(smx_synchro_t synchro, double priority){
+
+ if(synchro->execution.surf_exec)
+ surf_action_set_priority(synchro->execution.surf_exec, priority);
+}
+
+void SIMIX_process_execution_set_bound(smx_synchro_t synchro, double bound){
+
+ if(synchro->execution.surf_exec)
+ surf_cpu_action_set_bound(synchro->execution.surf_exec, bound);
+}
+
+void SIMIX_process_execution_set_affinity(smx_synchro_t synchro, sg_host_t host, unsigned long mask){
+ xbt_assert(synchro->type == SIMIX_SYNC_EXECUTE);
+
+ if (synchro->execution.surf_exec) {
+ /* just a double check to confirm that this host is the host where this task is running. */
+ xbt_assert(synchro->execution.host == host);
+ surf_cpu_action_set_affinity(synchro->execution.surf_exec, host, mask);
+ }
+}
+
+void simcall_HANDLER_process_execution_wait(smx_simcall_t simcall, smx_synchro_t synchro){
+
+ XBT_DEBUG("Wait for execution of synchro %p, state %d", synchro, (int)synchro->state);
+
+ /* Associate this simcall to the synchro */
+ xbt_fifo_push(synchro->simcalls, simcall);
+ simcall->issuer->waiting_synchro = synchro;
+
+ /* set surf's synchro */
+ if (MC_is_active() || MC_record_replay_is_active()) {
+ synchro->state = SIMIX_DONE;
+ SIMIX_execution_finish(synchro);
+ return;
+ }
+
+ /* If the synchro is already finished then perform the error handling */
+ if (synchro->state != SIMIX_RUNNING)
+ SIMIX_execution_finish(synchro);
+}
+
+void SIMIX_host_execution_suspend(smx_synchro_t synchro)