delete payload;
XBT_INFO("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
} catch (xbt_ex& e) {
- switch (e.category) {
- case network_error:
- XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
- break;
- default:
- xbt_die("Unexpected behavior");
- }
+ if (e.category != network_error)
+ xbt_die("Unexpected behavior");
+ XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
delete payload;
}
}
XBT_INFO("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
} catch (xbt_ex& e) {
delete payload;
- switch (e.category) {
- case network_error:
- XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
- break;
- default:
- xbt_die("Unexpected behavior");
- }
+ if (e.category != network_error)
+ xbt_die("Unexpected behavior");
+ XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
}
}
break;
}
/* - Otherwise, process the task */
- try {
- XBT_INFO("Start execution...");
- simgrid::s4u::this_actor::execute(comp_size);
- XBT_INFO("Execution complete.");
- delete payload;
- } catch (simgrid::HostFailureException& e) {
- delete payload;
- XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!");
- return -1;
- }
+ XBT_INFO("Start execution...");
+ simgrid::s4u::this_actor::execute(comp_size);
+ XBT_INFO("Execution complete.");
+ delete payload;
} catch (simgrid::HostFailureException& e) {
XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!");
delete payload;
return -1;
} catch (xbt_ex& e) {
- switch (e.category) {
- case network_error:
- XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!");
- break;
- default:
- xbt_die("Unexpected behavior. Category: %s", xbt_ex_catname(e.category));
- }
+ if (e.category != network_error)
+ xbt_die("Unexpected behavior. Category: %s", xbt_ex_catname(e.category));
+ XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!");
}
}
return 0;
XBT_PUBLIC void sg_host_energy_plugin_init();
XBT_PUBLIC void sg_host_energy_update_all();
XBT_PUBLIC double sg_host_get_consumed_energy(sg_host_t host);
+XBT_PUBLIC double sg_host_get_idle_consumption(sg_host_t host);
XBT_PUBLIC double sg_host_get_wattmin_at(sg_host_t host, int pstate);
XBT_PUBLIC double sg_host_get_wattmax_at(sg_host_t host, int pstate);
XBT_PUBLIC double sg_host_get_current_consumption(sg_host_t host);
#ifndef HAVE_SMPI
#define malloc(nbytes) _sampi_malloc(nbytes)
+#define calloc(n_elm,elm_size) _sampi_calloc(n_elm,elm_size)
+#define realloc(ptr,nbytes) _sampi_realloc(ptr,nbytes)
#define free(ptr) _sampi_free(ptr)
#endif
SG_BEGIN_DECL()
XBT_PUBLIC void* _sampi_malloc(size_t size);
+XBT_PUBLIC void* _sampi_calloc(size_t n_elm, size_t elm_size);
+XBT_PUBLIC void* _sampi_realloc(void *ptr, size_t size);
XBT_PUBLIC void _sampi_free(void* ptr);
AMPI_CALL(XBT_PUBLIC int, MPI_Iteration_in, (MPI_Comm comm))
status = MSG_TIMEOUT;
}
catch (xbt_ex& e) {
- switch (e.category) {
- case network_error:
- finished_index = e.value;
- status = MSG_TRANSFER_FAILURE;
- break;
- default:
- throw;
- }
+ if (e.category != network_error)
+ throw;
+ finished_index = e.value;
+ status = MSG_TRANSFER_FAILURE;
}
if (finished_index != -1) {
#endif
#include <xbt/config.hpp>
+#include "src/internal_config.h"
+
#include <boost/algorithm/string.hpp>
+#if HAVE_SMPI
+#include "src/smpi/include/smpi_request.hpp"
+#endif
SIMGRID_REGISTER_PLUGIN(host_dvfs, "Dvfs support", &sg_host_dvfs_plugin_init)
"Which Governor should be used that adapts the CPU frequency?", "performance",
std::map<std::string, std::string>({
+#if HAVE_SMPI
{"adagio", "TODO: Doc"},
+#endif
{"conservative", "TODO: Doc"},
{"ondemand", "TODO: Doc"},
{"performance", "TODO: Doc"},
}
};
+#if HAVE_SMPI
class Adagio : public Governor {
private:
int best_pstate = 0;
double comp_counter = 0;
double comp_timer = 0;
- std::vector<std::vector<double>> rates;
+ std::vector<std::vector<double>> rates; // Each host + all frequencies of that host
unsigned int task_id = 0;
bool iteration_running = false; /*< Are we currently between iteration_in and iteration_out calls? */
explicit Adagio(simgrid::s4u::Host* ptr)
: Governor(ptr), rates(100, std::vector<double>(ptr->get_pstate_count(), 0.0))
{
-#if HAVE_SMPI
simgrid::smpi::plugin::ampi::on_iteration_in.connect([this](simgrid::s4u::ActorPtr actor) {
// Every instance of this class subscribes to this event, so one per host
// This means that for any actor, all 'hosts' are normally notified of these
task_id = 0;
}
});
-#endif
simgrid::kernel::activity::ExecImpl::on_creation.connect([this](simgrid::kernel::activity::ExecImplPtr activity) {
if (activity->host_ == get_host())
pre_task();
comp_timer += activity->surf_action_->get_finish_time() - activity->surf_action_->get_start_time();
}
});
+ // FIXME I think that this fires at the same time for all hosts, so when the src sends something,
+ // the dst will be notified even though it didn't even arrive at the recv yet
simgrid::s4u::Link::on_communicate.connect(
[this](kernel::resource::NetworkAction* action, s4u::Host* src, s4u::Host* dst) {
if ((get_host() == src || get_host() == dst) && iteration_running) {
virtual void update() override {}
};
+#endif
} // namespace dvfs
} // namespace plugin
} // namespace simgrid
} else if (dvfs_governor == "ondemand") {
return std::unique_ptr<simgrid::plugin::dvfs::Governor>(
new simgrid::plugin::dvfs::OnDemand(daemon_proc->get_host()));
- } else if (dvfs_governor == "adagio") {
+ }
+#if HAVE_SMPI
+ else if (dvfs_governor == "adagio") {
return std::unique_ptr<simgrid::plugin::dvfs::Governor>(
new simgrid::plugin::dvfs::Adagio(daemon_proc->get_host()));
- } else if (dvfs_governor == "performance") {
+ }
+#endif
+ else if (dvfs_governor == "performance") {
return std::unique_ptr<simgrid::plugin::dvfs::Governor>(
new simgrid::plugin::dvfs::Performance(daemon_proc->get_host()));
} else if (dvfs_governor == "powersave") {
double get_current_watts_value();
double get_current_watts_value(double cpu_load);
double get_consumed_energy();
+ double get_idle_consumption();
double get_watt_min_at(int pstate);
double get_watt_max_at(int pstate);
void update();
HostEnergy::~HostEnergy() = default;
+double HostEnergy::get_idle_consumption()
+{
+ xbt_assert(not power_range_watts_list_.empty(), "No power range properties specified for host %s",
+ host_->get_cname());
+
+ return power_range_watts_list_[0].idle_;
+}
+
double HostEnergy::get_watt_min_at(int pstate)
{
xbt_assert(not power_range_watts_list_.empty(), "No power range properties specified for host %s",
// In this case, 1core == AllCores
current_power_values.push_back(current_power_values.at(1));
} else { // size == 3
- current_power_values[2] = current_power_values.at(1);
+ current_power_values[1] = current_power_values.at(2);
+ current_power_values[2] = current_power_values.at(2);
static bool displayed_warning = false;
if (not displayed_warning) { // Otherwise we get in the worst case no_pstate*no_hosts warnings
XBT_WARN("Host %s is a single-core machine and part of the power profile is '%s'"
", which is in the 'Idle:OneCore:AllCores' format."
- " Since this is a single-core machine, AllCores and OneCore are identical."
- " Here, only the value for 'OneCore' is used.", host_->get_cname(), current_power_values_str.c_str());
+ " Here, only the value for 'AllCores' is used.", host_->get_cname(), current_power_values_str.c_str());
displayed_warning = true;
}
}
return host->extension<HostEnergy>()->get_consumed_energy();
}
+/** @ingroup plugin_energy
+ * @brief Get the amount of watt dissipated when the host is idling
+ */
+double sg_host_get_idle_consumption(sg_host_t host)
+{
+ xbt_assert(HostEnergy::EXTENSION_ID.valid(),
+ "The Energy plugin is not active. Please call sg_host_energy_plugin_init() during initialization.");
+ return host->extension<HostEnergy>()->get_idle_consumption();
+}
+
/** @ingroup plugin_energy
* @brief Get the amount of watt dissipated at the given pstate when the host is idling
*/
source == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->actor(source)->get_pid(),
simgrid::s4u::this_actor::get_pid(), tag, comm, MPI_REQ_PERSISTENT | MPI_REQ_RECV);
if (smpi_iprobe_sleep > 0) {
- s4u::this_actor::exec_init(/* flops to execute */ nsleeps * smpi_iprobe_sleep * speed * maxrate)
+ /** Compute the number of flops we will sleep **/
+ s4u::this_actor::exec_init(/*nsleeps: See comment above */ nsleeps *
+ /*(in seconds)*/ smpi_iprobe_sleep * speed * maxrate)
->set_name("iprobe")
->start()
->wait();
+/* Copyright (c) 2018. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
#include <simgrid/plugins/load_balancer.h>
#include <simgrid/s4u/Actor.hpp>
#include <src/smpi/include/smpi_comm.hpp>
static std::vector<size_t> memory_size(500, 0); // FIXME cheinrich This needs to be dynamic
static std::map</*address*/ void*, size_t> alloc_table; // Keep track of all allocations
-extern "C" XBT_PUBLIC void* _sampi_malloc(size_t);
+extern "C" XBT_PUBLIC void* _sampi_malloc(size_t); // FIXME Use declarations from sampi.h instead
extern "C" XBT_PUBLIC void _sampi_free(void* ptr);
+extern "C" XBT_PUBLIC void* _sampi_calloc(size_t num_elm, size_t elem_size);
+extern "C" XBT_PUBLIC void* _sampi_realloc(void* ptr, size_t size);
extern "C" void* _sampi_malloc(size_t size)
{
void* result = malloc (size); // We need the space here to prevent recursive substitution
free(ptr);
}
+extern "C" void* _sampi_calloc(size_t num_elm, size_t elem_size)
+{
+ void* result = calloc (num_elm, elem_size); // We need the space here to prevent recursive substitution
+ alloc_table.insert({result, num_elm * elem_size});
+ if (not simgrid::s4u::this_actor::is_maestro()) {
+ memory_size[simgrid::s4u::this_actor::get_pid()] += num_elm * elem_size;
+ }
+ return result;
+}
+extern "C" void* _sampi_realloc(void* ptr, size_t size)
+{
+ void* result = realloc (ptr, size); // We need the space here to prevent recursive substitution
+ int old_size = alloc_table.at(ptr);
+ alloc_table.erase(ptr);
+ alloc_table.insert({result, size});
+ if (not simgrid::s4u::this_actor::is_maestro()) {
+ memory_size[simgrid::s4u::this_actor::get_pid()] += size - old_size;
+ }
+ return result;
+}
+
#include "ampi.hpp"
#include <smpi/sampi.h>
namespace simgrid {
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#ifndef AMPI_HPP
-#define AMPI_HPP
+#ifndef INSTR_AMPI_HPP_
+#define INSTR_AMPI_HPP_
#include <simgrid/s4u.hpp>
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#ifndef INSTR_AMPI_HPP_
-#define INSTR_AMPI_HPP_
+#ifndef INSTR_INSTR_AMPI_HPP_
+#define INSTR_INSTR_AMPI_HPP_
#include "smpi/smpi.h"
#include "src/instr/instr_private.hpp"
namespace plugin {
namespace loadbalancer {
-struct XBT_PRIVATE compare_hosts {
+class XBT_PRIVATE compare_hosts {
+public:
bool operator()(simgrid::s4u::Host* const a, simgrid::s4u::Host* const b) const;
};
for (auto& host : available_hosts) {
std::vector<simgrid::s4u::ActorPtr> actors = host->get_all_actors();
heap_handle update_handle = usable_hosts.push(host); // Required to update elements in the heap
- additional_load[host] = {update_handle, 0}; // Save the handle for later
+ additional_load[host] = {update_handle, 0}; // Save the handle for later
+ const double total_flops_computed = sg_host_get_computed_flops(host);
for (auto& actor : actors) {
- additional_load[host].load += actor_computation[actor->get_pid()];
+ additional_load[host].load += actor_computation[actor->get_pid()] / total_flops_computed; // Normalize load - this allows comparison
+ // even between hosts with different frequencies
XBT_DEBUG("Actor %li -> %f", actor->get_pid(), actor_computation[actor->get_pid()]);
}
+ usable_hosts.increase(update_handle);
XBT_DEBUG("Host %s initialized to %f", host->get_cname(), additional_load[host].load);
}
*/
simgrid::s4u::Host* get_mapping(simgrid::s4u::ActorPtr);
void record_actor_computation(simgrid::s4u::ActorPtr actor, double load);
-private:
};
}
smpi_execute(xbt_os_timer_elapsed(timer));
// Update the process and host mapping in SimGrid.
+ XBT_DEBUG("Migrating process %li from %s to %s", my_proc_id, cur_host->get_cname(), migrate_to_host->get_cname());
TRACE_smpi_process_change_host(my_proc_id, migrate_to_host);
simgrid::s4u::this_actor::migrate(migrate_to_host);
}
void _xbt_throw(char* message, xbt_errcat_t errcat, int value, const char* file, int line, const char* func)
{
- xbt_ex e(simgrid::xbt::ThrowPoint(XBT_THROW_POINT), message);
+ xbt_ex e(simgrid::xbt::ThrowPoint(file, line, func, simgrid::xbt::backtrace(), xbt_procname(), xbt_getpid()),
+ message);
xbt_free(message);
e.category = errcat;
e.value = value;
msg_task_t atask = NULL;
-static int computation_fun(int argc, char* argv[])
+static int computation_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
{
const char* pr_name = MSG_process_get_name(MSG_process_self());
const char* host_name = MSG_host_get_name(MSG_host_self());
return 0;
}
-static int master_main(int argc, char* argv[])
+static int master_main(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
{
msg_host_t pm0 = MSG_host_by_name("Fafard");
msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
* interfaces, but it's not possible ATM).
*/
-static int runner(int argc, char* argv[])
+static int runner(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
{
/* Retrieve the list of all hosts as an array of hosts */
int host_count = MSG_get_host_number();
XBT_LOG_NEW_DEFAULT_CATEGORY(storage, "Messages specific for this simulation");
-static int host(int argc, char* argv[])
+static int host(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
{
const char* host_name = MSG_host_get_name(MSG_host_self());
xbt_dict_free(&props);
}
-static int alice(int argc, char* argv[])
+static int alice(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
{ /* Dump what we have on the current host */
test_host("host1");
return 0;
}
-static int carole(int argc, char* argv[])
+static int carole(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
{ /* Dump what we have on a remote host */
MSG_process_sleep(1); // Wait for alice to be done with its experiment
test_host("host1");
return 0;
}
-static int david(int argc, char* argv[])
+static int david(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
{ /* Dump what we have on a remote host */
MSG_process_sleep(2); // Wait for alice and carole to be done with its experiment
test_host("node-0.simgrid.org");
return 0;
}
-static int bob(int argc, char* argv[])
+static int bob(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
{
/* this host also tests the properties of the AS*/
msg_as_t root = MSG_zone_get_root();
return future;
}
-static int master(int argc, char* argv[])
+static int master(int /*argc*/, char** /*argv*/)
{
// Test the simple immediate execution:
XBT_INFO("Start");