1 /* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "smx_private.hpp"
8 #include "src/kernel/activity/CommImpl.hpp"
9 #include "src/kernel/activity/ExecImpl.hpp"
10 #include "src/mc/mc_replay.hpp"
11 #include "src/plugins/vm/VirtualMachineImpl.hpp"
12 #include "src/simix/smx_host_private.hpp"
14 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_host, simix, "SIMIX hosts");
16 simgrid::kernel::activity::ExecImplPtr
17 SIMIX_execution_parallel_start(std::string name, int host_nb, const sg_host_t* host_list, const double* flops_amount,
18 const double* bytes_amount, double rate, double timeout)
21 /* Check that we are not mixing VMs and PMs in the parallel task */
22 bool is_a_vm = (nullptr != dynamic_cast<simgrid::s4u::VirtualMachine*>(host_list[0]));
23 for (int i = 1; i < host_nb; i++) {
24 bool tmp_is_a_vm = (nullptr != dynamic_cast<simgrid::s4u::VirtualMachine*>(host_list[i]));
25 xbt_assert(is_a_vm == tmp_is_a_vm, "parallel_execute: mixing VMs and PMs is not supported (yet).");
28 /* set surf's synchro */
29 simgrid::kernel::resource::Action* surf_action = nullptr;
30 simgrid::kernel::resource::Action* timeout_detector = nullptr;
31 if (not MC_is_active() && not MC_record_replay_is_active()) {
32 surf_action = surf_host_model->execute_parallel(host_nb, host_list, flops_amount, bytes_amount, rate);
34 timeout_detector = host_list[0]->pimpl_cpu->sleep(timeout);
38 simgrid::kernel::activity::ExecImplPtr exec = simgrid::kernel::activity::ExecImplPtr(
39 new simgrid::kernel::activity::ExecImpl(std::move(name), "", timeout_detector, nullptr));
40 if (surf_action != nullptr) {
41 exec->surf_action_ = surf_action;
42 exec->surf_action_->set_data(exec.get());
44 XBT_DEBUG("Create parallel execute synchro %p", exec.get());