include examples/platforms/two_peers.xml
include examples/platforms/vivaldi.xml
include examples/platforms/wifi.xml
+include examples/platforms/wifi_decay_2STA.xml
include examples/python/CMakeLists.txt
include examples/python/actor-create/actor-create_d.xml
include examples/python/actor-lifetime/actor-lifetime_d.xml
XBT_INFO("Storage info on %s:", sg_host_self_get_name());
for (unsigned int i = 0; i < disk_count; i++) {
- const sg_disk_t d = disks[i];
+ const_sg_disk_t d = disks[i];
// Retrieve disk's information
XBT_INFO(" %s (%s) Used: %llu; Free: %llu; Total: %llu.", sg_disk_name(d), sg_disk_get_mount_point(d),
sg_disk_get_size_used(d), sg_disk_get_size_free(d), sg_disk_get_size(d));
namespace instr {
EntityValue::EntityValue(const std::string& name, const std::string& color, Type* father)
- : id_(instr_new_paje_id()), name_(name), color_(color), father_(father)
+ : name_(name), color_(color), father_(father)
{
+ id_ = instr_new_paje_id();
on_creation(*this);
}
} // namespace instr
std::string display_size() override { return "NA"; }
};
-}
-}
+} // namespace instr
+} // namespace simgrid
XBT_PRIVATE std::string instr_pid(simgrid::s4u::Actor const& proc);
XBT_PRIVATE std::string TRACE_get_filename();
-
#endif
namespace smpi {
namespace plugin {
namespace ampi {
-simgrid::xbt::signal<void(simgrid::s4u::Actor const&)> on_iteration_in;
-simgrid::xbt::signal<void(simgrid::s4u::Actor const&)> on_iteration_out;
-}
-}
-}
-}
+xbt::signal<void(s4u::Actor const&)> on_iteration_in;
+xbt::signal<void(s4u::Actor const&)> on_iteration_out;
+} // namespace ampi
+} // namespace plugin
+} // namespace smpi
+} // namespace simgrid
/* FIXME The following contains several times "rank() + 1". This works for one
* instance, but we need to find a way to deal with this for several instances and
namespace smpi {
namespace plugin {
namespace ampi {
-extern simgrid::xbt::signal<void(simgrid::s4u::Actor const&)> on_iteration_out;
-extern simgrid::xbt::signal<void(simgrid::s4u::Actor const&)> on_iteration_in;
-}
-}
-}
-}
+extern xbt::signal<void(s4u::Actor const&)> on_iteration_out;
+extern xbt::signal<void(s4u::Actor const&)> on_iteration_in;
+} // namespace ampi
+} // namespace plugin
+} // namespace smpi
+} // namespace simgrid
#endif
class XBT_PRIVATE compare_hosts {
public:
- bool operator()(simgrid::s4u::Host* const a, simgrid::s4u::Host* const b) const;
+ bool operator()(s4u::Host* const a, s4u::Host* const b) const;
};
-typedef boost::heap::fibonacci_heap<simgrid::s4u::Host*, boost::heap::compare<compare_hosts>>::handle_type heap_handle;
+typedef boost::heap::fibonacci_heap<s4u::Host*, boost::heap::compare<compare_hosts>>::handle_type heap_handle;
-/**
- * Structure that imitates a std::pair, but it allows us
- * to use meaningful names instead of .first and .second
- */
+/** Structure that imitates a std::pair, but it allows us to use meaningful names instead of .first and .second */
struct XBT_PRIVATE pair_handle_load
{
heap_handle update_handle;
double load;
};
-static std::map<simgrid::s4u::Host* const, pair_handle_load> additional_load;
+static std::map<s4u::Host* const, pair_handle_load> additional_load;
-bool compare_hosts::operator()(simgrid::s4u::Host* const a, simgrid::s4u::Host* const b) const {
+bool compare_hosts::operator()(s4u::Host* const a, s4u::Host* const b) const
+{
return additional_load[a].load > additional_load[b].load;
}
-
void LoadBalancer::run()
{
- simgrid::s4u::Engine* engine = simgrid::s4u::Engine::get_instance();
- std::vector<simgrid::s4u::Host*> available_hosts =
- engine->get_filtered_hosts([](const simgrid::s4u::Host* host) { return host->is_on(); });
+ s4u::Engine* engine = s4u::Engine::get_instance();
+ std::vector<s4u::Host*> available_hosts =
+ engine->get_filtered_hosts([](const s4u::Host* host) { return host->is_on(); });
xbt_assert(available_hosts.size() > 0, "No hosts available; are they all switched off?");
// TODO: Account for daemon background load (-> use especially the availability file)
- std::vector<simgrid::s4u::ActorPtr> all_actors =
- engine->get_filtered_actors([](simgrid::s4u::ActorPtr actor) { return not actor->is_daemon(); });
+ std::vector<s4u::ActorPtr> all_actors =
+ engine->get_filtered_actors([](s4u::ActorPtr actor) { return not actor->is_daemon(); });
for (auto const& actor : all_actors) {
new_mapping.assign(actor, actor->get_host());
}
// Sort the actors, from highest to lowest load; we then just iterate over these actors
- std::sort(all_actors.begin(), all_actors.end(), [this](simgrid::s4u::ActorPtr a, simgrid::s4u::ActorPtr b) {
+ std::sort(all_actors.begin(), all_actors.end(), [this](s4u::ActorPtr a, s4u::ActorPtr b) {
return actor_computation[a->get_pid()] > actor_computation[b->get_pid()];
});
// std::priorityQueue is immutable and hence doesn't work for us.
//
// This heap contains the least loaded host at the top
- boost::heap::fibonacci_heap<simgrid::s4u::Host*, boost::heap::compare<compare_hosts>> usable_hosts;
+ boost::heap::fibonacci_heap<s4u::Host*, boost::heap::compare<compare_hosts>> usable_hosts;
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
- const double total_flops_computed = sg_host_get_computed_flops(host);
+ std::vector<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
+ const double total_flops_computed = sg_host_get_computed_flops(host);
for (auto const& actor : actors) {
additional_load[host].load += actor_computation[actor->get_pid()] / total_flops_computed; // Normalize load - this allows comparison
// even between hosts with different frequencies
// Implementation of the Greedy algorithm
for (auto const& actor : all_actors) {
- simgrid::s4u::Host* target_host = usable_hosts.top(); // This is the host with the lowest load
+ s4u::Host* target_host = usable_hosts.top(); // This is the host with the lowest load
- simgrid::s4u::Host* cur_mapped_host = new_mapping.get_host(actor);
+ s4u::Host* cur_mapped_host = new_mapping.get_host(actor);
if (target_host != cur_mapped_host
&& additional_load[target_host].load + actor_computation[actor->get_pid()] < additional_load[cur_mapped_host].load
&& new_mapping.count_actors(cur_mapped_host) > 1) {
}
while (!usable_hosts.empty()) {
- simgrid::s4u::Host* host = usable_hosts.top();
+ s4u::Host* host = usable_hosts.top();
usable_hosts.pop();
sg_host_load_reset(host); // Reset host load for next iterations
/* Debug messages that allow us to verify the load for each host */
XBT_DEBUG("Host: %s, load total: %f", host->get_cname(), additional_load[host].load);
double load_verif = 0.0;
- new_mapping.for_each_actor(host,
- [this, &load_verif](simgrid::s4u::ActorPtr actor) {
- load_verif += actor_computation[actor->get_pid()];
- XBT_DEBUG(" %li (load: %f)", actor->get_pid(), actor_computation[actor->get_pid()]);
+ new_mapping.for_each_actor(host, [this, &load_verif](s4u::ActorPtr actor) {
+ load_verif += actor_computation[actor->get_pid()];
+ XBT_DEBUG(" %li (load: %f)", actor->get_pid(), actor_computation[actor->get_pid()]);
});
XBT_DEBUG("Host load verification: %f", load_verif);
}
}
}
-simgrid::s4u::Host* LoadBalancer::get_mapping(simgrid::s4u::ActorPtr actor)
+s4u::Host* LoadBalancer::get_mapping(s4u::ActorPtr actor)
{
return new_mapping.get_host(actor);
}
-void LoadBalancer::record_actor_computation(simgrid::s4u::Actor const& actor, double load)
+void LoadBalancer::record_actor_computation(s4u::Actor const& actor, double load)
{
actor_computation[actor.get_pid()] += load;
}
-}
-}
-}
+} // namespace loadbalancer
+} // namespace plugin
+} // namespace simgrid
class XBT_PRIVATE Mapping {
public:
/** Each host can have an arbitrary number of actors -> multimap **/
- typedef std::unordered_multimap<simgrid::s4u::Host*, simgrid::s4u::ActorPtr> host_to_actors_map_t;
+ typedef std::unordered_multimap<s4u::Host*, s4u::ActorPtr> host_to_actors_map_t;
host_to_actors_map_t host_to_actors;
/** Each actor gets assigned to exactly one host -> map **/
- std::map<simgrid::s4u::ActorPtr, simgrid::s4u::Host*> actor_to_host;
+ std::map<s4u::ActorPtr, s4u::Host*> actor_to_host;
- void assign(simgrid::s4u::ActorPtr actor, simgrid::s4u::Host* host)
+ void assign(s4u::ActorPtr actor, s4u::Host* host)
{
/* Remove "actor" from its old host -> get all elements that have the current host as key **/
auto range = host_to_actors.equal_range(/* current host */actor_to_host[actor]);
host_to_actors.insert({host, actor});
}
- simgrid::s4u::Host* get_host(simgrid::s4u::ActorPtr actor) { return actor_to_host[actor]; }
+ s4u::Host* get_host(s4u::ActorPtr actor) { return actor_to_host[actor]; }
- unsigned int count_actors(simgrid::s4u::Host* host)
+ unsigned int count_actors(s4u::Host* host)
{
return host_to_actors.count(host); // TODO This is linear in the size of the map. Maybe replace by constant lookup through another map?
}
- void for_each_actor(simgrid::s4u::Host* host, const std::function<void(simgrid::s4u::ActorPtr)>& callback)
+ void for_each_actor(s4u::Host* host, const std::function<void(s4u::ActorPtr)>& callback)
{
auto range = host_to_actors.equal_range(host);
std::for_each(range.first, range.second,
public:
void run();
- void assign(simgrid::s4u::ActorPtr actor, simgrid::s4u::Host* host);
-
- /**
- * FIXME These are functions used for testing and should be re-written or removed
- */
- simgrid::s4u::Host* get_mapping(simgrid::s4u::ActorPtr);
- void record_actor_computation(simgrid::s4u::Actor const& actor, double load);
+ void assign(s4u::ActorPtr actor, s4u::Host* host);
+
+ /** FIXME These are functions used for testing and should be re-written or removed */
+ s4u::Host* get_mapping(s4u::ActorPtr);
+ void record_actor_computation(s4u::Actor const& actor, double load);
};
-}
-}
-}
+} // namespace loadbalancer
+} // namespace plugin
+} // namespace simgrid
#endif
static simgrid::plugin::loadbalancer::LoadBalancer lb;
-class MigrateParser : public simgrid::smpi::replay::ActionArgParser {
+class MigrateParser : public replay::ActionArgParser {
public:
double memory_consumption;
- void parse(simgrid::xbt::ReplayAction& action, const std::string&)
+ void parse(xbt::ReplayAction& action, const std::string&)
{
// The only parameter is the amount of memory used by the current process.
CHECK_ACTION_PARAMS(action, 1, 0);
}
};
-/* This function simulates what happens when the original application calls
- * (A)MPI_Migrate. It executes the load balancing heuristics, makes the necessary
- * migrations and updates the task mapping in the load balancer.
+/* This function simulates what happens when the original application calls (A)MPI_Migrate. It executes the load
+ * balancing heuristics, makes the necessary migrations and updates the task mapping in the load balancer.
*/
-class MigrateAction : public simgrid::smpi::replay::ReplayAction<simgrid::smpi::plugin::MigrateParser> {
+class MigrateAction : public replay::ReplayAction<smpi::plugin::MigrateParser> {
public:
explicit MigrateAction() : ReplayAction("Migrate") {}
- void kernel(simgrid::xbt::ReplayAction&)
+ void kernel(xbt::ReplayAction&)
{
- static std::map<simgrid::s4u::ActorPtr, int> migration_call_counter;
- static simgrid::s4u::Barrier smpilb_bar(smpi_get_universe_size());
- simgrid::s4u::Host* cur_host = simgrid::s4u::this_actor::get_host();
- simgrid::s4u::Host* migrate_to_host;
+ static std::map<s4u::ActorPtr, int> migration_call_counter;
+ static s4u::Barrier smpilb_bar(smpi_get_universe_size());
+ s4u::Host* cur_host = s4u::this_actor::get_host();
+ s4u::Host* migrate_to_host;
TRACE_migration_call(get_pid(), nullptr);
// We only migrate every "cfg_migration_frequency"-times, not at every call
- migration_call_counter[simgrid::s4u::Actor::self()]++;
- if ((migration_call_counter[simgrid::s4u::Actor::self()] % simgrid::config::get_value<int>(cfg_migration_frequency.get_name())) != 0) {
+ migration_call_counter[s4u::Actor::self()]++;
+ if ((migration_call_counter[s4u::Actor::self()] % config::get_value<int>(cfg_migration_frequency.get_name())) !=
+ 0) {
return;
}
migrate_to_host = lb.get_mapping(simgrid::s4u::Actor::self());
if (cur_host != migrate_to_host) { // Origin and dest are not the same -> migrate
- std::vector<simgrid::s4u::Host*> migration_hosts = {cur_host, migrate_to_host};
+ std::vector<s4u::Host*> migration_hosts = {cur_host, migrate_to_host};
std::vector<double> comp_amount = {0, 0};
std::vector<double> comm_amount = {0, /*must not be 0*/ std::max(get_args().memory_consumption, 1.0), 0, 0};
xbt_os_timer_t timer = smpi_process()->timer();
xbt_os_threadtimer_start(timer);
- simgrid::s4u::this_actor::parallel_execute(migration_hosts, comp_amount, comm_amount);
+ s4u::this_actor::parallel_execute(migration_hosts, comp_amount, comm_amount);
xbt_os_threadtimer_stop(timer);
smpi_execute(xbt_os_timer_elapsed(timer));
// Update the process and host mapping in SimGrid.
XBT_DEBUG("Migrating process %li from %s to %s", get_pid(), cur_host->get_cname(), migrate_to_host->get_cname());
TRACE_smpi_process_change_host(get_pid(), migrate_to_host);
- simgrid::s4u::this_actor::set_host(migrate_to_host);
+ s4u::this_actor::set_host(migrate_to_host);
}
smpilb_bar.wait();
******************************************************************************/
// FIXME Move declaration
-XBT_PRIVATE void action_iteration_in(simgrid::xbt::ReplayAction& action);
-void action_iteration_in(simgrid::xbt::ReplayAction& action)
+XBT_PRIVATE void action_iteration_in(xbt::ReplayAction& action);
+void action_iteration_in(xbt::ReplayAction& action)
{
CHECK_ACTION_PARAMS(action, 0, 0)
- TRACE_Iteration_in(simgrid::s4u::this_actor::get_pid(), nullptr);
- simgrid::smpi::plugin::ampi::on_iteration_in(*MPI_COMM_WORLD->group()->actor(std::stol(action[0])));
+ TRACE_Iteration_in(s4u::this_actor::get_pid(), nullptr);
+ smpi::plugin::ampi::on_iteration_in(*MPI_COMM_WORLD->group()->actor(std::stol(action[0])));
}
-XBT_PRIVATE void action_iteration_out(simgrid::xbt::ReplayAction& action);
-void action_iteration_out(simgrid::xbt::ReplayAction& action)
+XBT_PRIVATE void action_iteration_out(xbt::ReplayAction& action);
+void action_iteration_out(xbt::ReplayAction& action)
{
CHECK_ACTION_PARAMS(action, 0, 0)
- TRACE_Iteration_out(simgrid::s4u::this_actor::get_pid(), nullptr);
- simgrid::smpi::plugin::ampi::on_iteration_out(*MPI_COMM_WORLD->group()->actor(std::stol(action[0])));
-}
-}
-}
+ TRACE_Iteration_out(s4u::this_actor::get_pid(), nullptr);
+ ampi::on_iteration_out(*MPI_COMM_WORLD->group()->actor(std::stol(action[0])));
}
+} // namespace plugin
+} // namespace smpi
+} // namespace simgrid
/** @ingroup plugin_loadbalancer
* @brief Initializes the load balancer plugin