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 /* needs to be public and without simcall for exceptions and logging events */
17 const char* sg_host_self_get_name()
19 sg_host_t host = sg_host_self();
20 if (host == nullptr || SIMIX_process_self() == simix_global->maestro_process)
23 return host->get_cname();
26 simgrid::kernel::activity::ExecImplPtr
27 SIMIX_execution_parallel_start(std::string name, int host_nb, const sg_host_t* host_list, const double* flops_amount,
28 const double* bytes_amount, double rate, double timeout)
31 /* Check that we are not mixing VMs and PMs in the parallel task */
32 bool is_a_vm = (nullptr != dynamic_cast<simgrid::s4u::VirtualMachine*>(host_list[0]));
33 for (int i = 1; i < host_nb; i++) {
34 bool tmp_is_a_vm = (nullptr != dynamic_cast<simgrid::s4u::VirtualMachine*>(host_list[i]));
35 xbt_assert(is_a_vm == tmp_is_a_vm, "parallel_execute: mixing VMs and PMs is not supported (yet).");
38 /* set surf's synchro */
39 simgrid::kernel::resource::Action* surf_action = nullptr;
40 simgrid::kernel::resource::Action* timeout_detector = nullptr;
41 if (not MC_is_active() && not MC_record_replay_is_active()) {
42 surf_action = surf_host_model->execute_parallel(host_nb, host_list, flops_amount, bytes_amount, rate);
44 timeout_detector = host_list[0]->pimpl_cpu->sleep(timeout);
48 simgrid::kernel::activity::ExecImplPtr exec = simgrid::kernel::activity::ExecImplPtr(
49 new simgrid::kernel::activity::ExecImpl(std::move(name), "", timeout_detector, nullptr));
50 if (surf_action != nullptr) {
51 exec->surf_action_ = surf_action;
52 exec->surf_action_->set_data(exec.get());
54 XBT_DEBUG("Create parallel execute synchro %p", exec.get());