Augustin Degomme <adegomme@gmail.com> <augustin.degomme@imag.fr>
Augustin Degomme <adegomme@gmail.com> <augustin.degomme@unibas.ch>
Augustin Degomme <adegomme@gmail.com> <degomme@debian.localdomain>
+Augustin Degomme <adegomme@gmail.com> <degomme@idpann>
Augustin Degomme <adegomme@gmail.com> <degomme@idpann.imag.fr>
Augustin Degomme <adegomme@gmail.com> <degomme@localhost.localdomain>
Augustin Degomme <adegomme@gmail.com> <degomme@wasabi>
SimGrid (3.21) NOT RELEASED (Release Target: September 23. 2018, 1:54 UTC)
+S4U new features:
+ - s4u::Io: IOs go asynchronous as activities. This comes with new methods in the
+ s4u::Storage class:
+ - io_init(sg_size_t, s4u::Io::OpType) to create a READ or WRITE asynchronous
+ IO operations that can be started, waited for, or canceled as a regular
+ activity.
+ - read_async(sg_size_t) and write_async(sg_size_t) which are wrappers on
+ io_init() + start()
+
Tracing:
- Rename 'power' and 'power_used' variables into 'speed' and 'speed_used'
- New host variable: 'core_count'
-
+
XBT:
- Remove xbt_os_thread_specific features
- Remove portability wrapper to condition variables
energy-exec energy-boot energy-link energy-vm
engine-filtering
exec-async exec-basic exec-dvfs exec-monitor exec-ptask exec-remote
- io-file-system io-file-remote io-storage-raw
+ io-async io-file-system io-file-remote io-storage-raw
mutex
platform-failures platform-properties plugin-hostload
replay-comm replay-storage
target_link_libraries(s4u-app-masterworkers-${variant} simgrid)
set_target_properties(s4u-app-masterworkers-${variant} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-masterworkers)
- set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/masterworkers-fun/s4u-masterworkers-${variant}.cpp)
+ set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
endforeach()
-set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/masterworkers-fun/s4u-masterworkers.tesh)
+set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers.tesh)
# CHORD EXAMPLE
engine-filtering
exec-async exec-basic exec-dvfs exec-monitor exec-ptask exec-remote
platform-properties plugin-hostload mutex
- io-file-system io-file-remote io-storage-raw
+ io-async io-file-system io-file-remote io-storage-raw
replay-comm replay-storage
routing-get-clusters
)
--- /dev/null
+/* Copyright (c) 2007-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/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+
+static void test(sg_size_t size)
+{
+ simgrid::s4u::Storage* storage = simgrid::s4u::Storage::by_name("Disk1");
+ XBT_INFO("Hello! read %llu bytes from Storage %s", size, storage->get_cname());
+
+ simgrid::s4u::IoPtr activity = storage->io_init(size, simgrid::s4u::Io::OpType::READ);
+ activity->start();
+ activity->wait();
+
+ XBT_INFO("Goodbye now!");
+}
+
+static void test_cancel(sg_size_t size)
+{
+ simgrid::s4u::Storage* storage = simgrid::s4u::Storage::by_name("Disk2");
+ XBT_INFO("Hello! write %llu bytes from Storage %s", size, storage->get_cname());
+
+ simgrid::s4u::IoPtr activity = storage->write_async(size);
+ simgrid::s4u::this_actor::sleep_for(0.5);
+ XBT_INFO("I changed my mind, cancel!");
+ activity->cancel();
+
+ XBT_INFO("Goodbye now!");
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine e(&argc, argv);
+ e.load_platform(argv[1]);
+ simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("bob"), test, 2e7);
+ simgrid::s4u::Actor::create("test_cancel", simgrid::s4u::Host::by_name("alice"), test_cancel, 5e7);
+
+ e.run();
+
+ XBT_INFO("Simulation time %g", e.get_clock());
+
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-io-async$EXEEXT ${platfdir}/storage/storage.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (1:test@bob) Hello! read 20000000 bytes from Storage Disk1
+> [ 0.000000] (2:test_cancel@alice) Hello! write 50000000 bytes from Storage Disk2
+> [ 0.200000] (1:test@bob) Goodbye now!
+> [ 0.500000] (2:test_cancel@alice) I changed my mind, cancel!
+> [ 0.500000] (2:test_cancel@alice) Goodbye now!
+> [ 0.500000] (0:maestro@) Simulation time 0.5
+++ /dev/null
-p Workload with two mixed jobs (not at the same time, but on the same resources)
-! timeout 120
-! output sort 19
-$ ./replay_multiple_manual ${srcdir:=.}/../../platforms/small_platform_with_routers.xml ${srcdir:=.}/workload_mixed2_same_resources --log=smpi.:info --cfg=smpi/host-speed:100 "--log=root.fmt:[%11.6r]%e(%P@%h)%e%m%n" 0 0
-> [ 0.000000] (maestro@) Configuration change: Set 'smpi/host-speed' to '100'
-> [ 0.000000] (maestro@) Job read: app='job0', file='mixed.txt', size=2, start=0, alloc='0,1'
-> [ 0.000000] (maestro@) Job read: app='job1', file='mixed.txt', size=2, start=1000, alloc='0,1'
-> [ 0.000000] (workload_executor@Bourassa) Launching the job executor of job 0 (app 'job0')
-> [ 0.000000] (job_job0@Bourassa) Executing job 0 (smpi_app 'job0')
-> [ 0.000000] (workload_executor@Bourassa) Sleeping 1000 seconds (waiting for job 1000, app 'job1')
-> [ 0.000000] (0_0@Bourassa) Replaying rank 0 of job 0 (smpi_app 'job0')
-> [ 0.000000] (0_1@Fafard) Replaying rank 1 of job 0 (smpi_app 'job0')
-> [ 737.001374] (0_0@Bourassa) Simulation time 737.001374
-> [ 737.001374] (0_0@Bourassa) Finished replaying rank 0 of job 0 (smpi_app 'job0')
-> [ 737.001374] (0_1@Fafard) Finished replaying rank 1 of job 0 (smpi_app 'job0')
-> [ 737.001374] (job_job0@Bourassa) Finished job 0 (smpi_app 'job0')
-> [1000.000000] (workload_executor@Bourassa) Launching the job executor of job 1 (app 'job1')
-> [1000.000000] (job_job1@Bourassa) Executing job 1 (smpi_app 'job1')
-> [1000.000000] (1_0@Bourassa) Replaying rank 0 of job 1 (smpi_app 'job1')
-> [1000.000000] (1_1@Fafard) Replaying rank 1 of job 1 (smpi_app 'job1')
-> [1737.001374] (1_0@Bourassa) Simulation time 737.001374
-> [1737.001374] (1_0@Bourassa) Finished replaying rank 0 of job 1 (smpi_app 'job1')
-> [1737.001374] (1_1@Fafard) Finished replaying rank 1 of job 1 (smpi_app 'job1')
-> [1737.001374] (job_job1@Bourassa) Finished job 1 (smpi_app 'job1')
-> [1737.001374] (maestro@) Simulation finished! Final time: 1737
+++ /dev/null
-p Workload with two mixed jobs (not at the same time, but on the same resources)
-! timeout 120
-! output sort 19
-$ ./replay_multiple_manual ${srcdir:=.}/../../platforms/small_platform_with_routers.xml ${srcdir:=.}/workload_mixed2_same_resources --log=smpi.:info --cfg=smpi/host-speed:100 "--log=root.fmt:[%11.6r]%e(%P@%h)%e%m%n" 7 13
-> [ 0.000000] (maestro@) Configuration change: Set 'smpi/host-speed' to '100'
-> [ 0.000000] (maestro@) Job read: app='job0', file='mixed.txt', size=2, start=0, alloc='0,1'
-> [ 0.000000] (maestro@) Job read: app='job1', file='mixed.txt', size=2, start=1000, alloc='0,1'
-> [ 0.000000] (workload_executor@Bourassa) Launching the job executor of job 0 (app 'job0')
-> [ 0.000000] (job_job0@Bourassa) Executing job 0 (smpi_app 'job0')
-> [ 0.000000] (workload_executor@Bourassa) Sleeping 1000 seconds (waiting for job 1000, app 'job1')
-> [ 0.000000] (0_0@Bourassa) Replaying rank 0 of job 0 (smpi_app 'job0')
-> [ 0.000000] (0_1@Fafard) Replaying rank 1 of job 0 (smpi_app 'job0')
-> [ 737.001374] (0_0@Bourassa) Simulation time 737.001374
-> [ 737.001374] (0_0@Bourassa) Finished replaying rank 0 of job 0 (smpi_app 'job0')
-> [ 737.001374] (0_1@Fafard) Finished replaying rank 1 of job 0 (smpi_app 'job0')
-> [ 737.001374] (job_job0@Bourassa) Finished job 0 (smpi_app 'job0')
-> [1000.000000] (workload_executor@Bourassa) Launching the job executor of job 1 (app 'job1')
-> [1000.000000] (job_job1@Bourassa) Executing job 1 (smpi_app 'job1')
-> [1000.000000] (1_0@Bourassa) Replaying rank 0 of job 1 (smpi_app 'job1')
-> [1000.000000] (1_1@Fafard) Replaying rank 1 of job 1 (smpi_app 'job1')
-> [1737.001374] (1_0@Bourassa) Simulation time 737.001374
-> [1737.001374] (1_0@Bourassa) Finished replaying rank 0 of job 1 (smpi_app 'job1')
-> [1737.001374] (1_1@Fafard) Finished replaying rank 1 of job 1 (smpi_app 'job1')
-> [1737.001374] (job_job1@Bourassa) Finished job 1 (smpi_app 'job1')
-> [1737.001374] (maestro@) Simulation finished! Final time: 1737
+++ /dev/null
-Two jobs not at the same time but using the same resources
-job0 mixed.txt 2 0 0,1
-job1 mixed.txt 2 1000 0,1
IoPtr io_init(sg_size_t size, s4u::Io::OpType type);
+ IoPtr read_async(sg_size_t size);
sg_size_t read(sg_size_t size);
+
+ IoPtr write_async(sg_size_t size);
sg_size_t write(sg_size_t size);
surf::StorageImpl* get_impl() { return pimpl_; }
XBT_PRIVATE void TRACE_smpi_init(int rank);
XBT_PRIVATE void TRACE_smpi_finalize(int rank);
/* SMPI + LB (load balancer) */
-XBT_PRIVATE void TRACE_smpi_send_process_data_in(int rank);
-XBT_PRIVATE void TRACE_smpi_send_process_data_out(int rank);
XBT_PRIVATE void TRACE_smpi_process_change_host(int rank, sg_host_t new_host);
class smpi_trace_call_location_t {
#include "simgrid/plugins/dvfs.h"
#include "simgrid/plugins/load.h"
+#include "simgrid/s4u/Engine.hpp"
+#include "src/kernel/activity/ExecImpl.hpp"
#include "src/plugins/vm/VirtualMachineImpl.hpp"
+#include "src/smpi/plugins/ampi/ampi.hpp"
#include <xbt/config.hpp>
#include <boost/algorithm/string.hpp>
"Which Governor should be used that adapts the CPU frequency?", "performance",
std::map<std::string, std::string>({
+ {"adagio", "TODO: Doc"},
{"conservative", "TODO: Doc"},
{"ondemand", "TODO: Doc"},
{"performance", "TODO: Doc"},
{"powersave", "TODO: Doc"},
}),
- [](std::string val){if (val != "performance") sg_host_dvfs_plugin_init();});
+ [](std::string val) { if (val != "performance") sg_host_dvfs_plugin_init(); });
+
+static simgrid::config::Flag<int> cfg_min_pstate("plugin/dvfs/min-pstate", {"plugin/dvfs/min_pstate"},
+ "Which pstate is the minimum (and hence fastest) pstate for this governor?", 0,
+ [](int index) {});
+
+static const int max_pstate_not_limited = -1;
+static simgrid::config::Flag<int> cfg_max_pstate("plugin/dvfs/max-pstate", {"plugin/dvfs/max_pstate"},
+ "Which pstate is the maximum (and hence slowest) pstate for this governor?", max_pstate_not_limited,
+ [](int index) {});
/** @addtogroup SURF_plugin_load
*/
class Governor {
-protected:
+private:
simgrid::s4u::Host* const host_;
double sampling_rate_;
+ int min_pstate; //< Never use a pstate less than this one
+ int max_pstate; //< Never use a pstate larger than this one
public:
-
- explicit Governor(simgrid::s4u::Host* ptr) : host_(ptr) { init(); }
+ explicit Governor(simgrid::s4u::Host* ptr)
+ : host_(ptr)
+ , min_pstate(cfg_min_pstate)
+ , max_pstate(cfg_max_pstate == max_pstate_not_limited ? host_->get_pstate_count() - 1 : cfg_max_pstate)
+ {
+ init();
+ }
virtual ~Governor() = default;
- virtual std::string get_name() = 0;
+ virtual std::string get_name() const = 0;
simgrid::s4u::Host* get_host() const { return host_; }
+ int get_min_pstate() const { return min_pstate; }
+ int get_max_pstate() const { return max_pstate; }
void init()
{
const char* local_sampling_rate_config = host_->get_property(cfg_sampling_rate.get_name());
- double global_sampling_rate_config = cfg_sampling_rate;
if (local_sampling_rate_config != nullptr) {
sampling_rate_ = std::stod(local_sampling_rate_config);
} else {
- sampling_rate_ = global_sampling_rate_config;
+ sampling_rate_ = cfg_sampling_rate;
+ }
+ const char* local_min_pstate_config = host_->get_property(cfg_min_pstate.get_name());
+ if (local_min_pstate_config != nullptr) {
+ min_pstate = std::stoi(local_min_pstate_config);
+ }
+
+ const char* local_max_pstate_config = host_->get_property(cfg_max_pstate.get_name());
+ if (local_max_pstate_config != nullptr) {
+ max_pstate = std::stod(local_max_pstate_config);
}
+ xbt_assert(max_pstate <= host_->get_pstate_count() - 1, "Value for max_pstate too large!");
+ xbt_assert(min_pstate <= max_pstate, "min_pstate is larger than max_pstate!");
+ xbt_assert(0 <= min_pstate, "min_pstate is negative!");
}
virtual void update() = 0;
- double get_sampling_rate() { return sampling_rate_; }
+ double get_sampling_rate() const { return sampling_rate_; }
};
/**
class Performance : public Governor {
public:
explicit Performance(simgrid::s4u::Host* ptr) : Governor(ptr) {}
- std::string get_name() override { return "Performance"; }
+ std::string get_name() const override { return "Performance"; }
- void update() override { get_host()->set_pstate(0); }
+ void update() override { get_host()->set_pstate(get_min_pstate()); }
};
/**
class Powersave : public Governor {
public:
explicit Powersave(simgrid::s4u::Host* ptr) : Governor(ptr) {}
- std::string get_name() override { return "Powersave"; }
+ std::string get_name() const override { return "Powersave"; }
- void update() override { get_host()->set_pstate(get_host()->get_pstate_count() - 1); }
+ void update() override { get_host()->set_pstate(get_max_pstate()); }
};
/**
public:
explicit OnDemand(simgrid::s4u::Host* ptr) : Governor(ptr) {}
- std::string get_name() override { return "OnDemand"; }
+ std::string get_name() const override { return "OnDemand"; }
void update() override
{
sg_host_load_reset(get_host()); // Only consider the period between two calls to this method!
if (load > freq_up_threshold_) {
- get_host()->set_pstate(0); /* Run at max. performance! */
- XBT_INFO("Load: %f > threshold: %f --> changed to pstate %i", load, freq_up_threshold_, 0);
+ get_host()->set_pstate(get_min_pstate()); /* Run at max. performance! */
+ XBT_INFO("Load: %f > threshold: %f --> changed to pstate %i", load, freq_up_threshold_, get_min_pstate());
} else {
/* The actual implementation uses a formula here: (See Kernel file cpufreq_ondemand.c:158)
*
* So they assume that frequency increases by 100 MHz. We will just use
* lowest_pstate - load*pstatesCount()
*/
- int max_pstate = get_host()->get_pstate_count() - 1;
// Load is now < freq_up_threshold; exclude pstate 0 (the fastest)
// because pstate 0 can only be selected if load > freq_up_threshold_
- int new_pstate = max_pstate - load * (max_pstate + 1);
+ int new_pstate = get_max_pstate() - load * (get_max_pstate() + 1);
+ if (new_pstate < get_min_pstate())
+ new_pstate = get_min_pstate();
get_host()->set_pstate(new_pstate);
XBT_DEBUG("Load: %f < threshold: %f --> changed to pstate %i", load, freq_up_threshold_, new_pstate);
public:
explicit Conservative(simgrid::s4u::Host* ptr) : Governor(ptr) {}
- virtual std::string get_name() override { return "Conservative"; }
+ virtual std::string get_name() const override { return "Conservative"; }
virtual void update() override
{
sg_host_load_reset(get_host()); // Only consider the period between two calls to this method!
if (load > freq_up_threshold_) {
- if (pstate != 0) {
+ if (pstate != get_min_pstate()) {
get_host()->set_pstate(pstate - 1);
XBT_INFO("Load: %f > threshold: %f -> increasing performance to pstate %d", load, freq_up_threshold_,
pstate - 1);
freq_up_threshold_, pstate);
}
} else if (load < freq_down_threshold_) {
- int max_pstate = get_host()->get_pstate_count() - 1;
- if (pstate != max_pstate) { // Are we in the slowest pstate already?
+ if (pstate != get_max_pstate()) { // Are we in the slowest pstate already?
get_host()->set_pstate(pstate + 1);
XBT_INFO("Load: %f < threshold: %f -> slowing down to pstate %d", load, freq_down_threshold_, pstate + 1);
} else {
}
};
+class Adagio : public Governor {
+private:
+ int best_pstate = 0;
+ double start_time = 0;
+ double comp_counter = 0;
+ double comp_timer = 0;
+
+ std::vector<std::vector<double>> rates;
+
+ unsigned int task_id = 0;
+ bool iteration_running = false; /*< Are we currently between iteration_in and iteration_out calls? */
+
+public:
+ explicit Adagio(simgrid::s4u::Host* ptr)
+ : Governor(ptr), rates(100, std::vector<double>(ptr->get_pstate_count(), 0.0))
+ {
+ 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
+ // changes, even those who don't currently run the actor 'proc_id'.
+ // -> Let's check if this signal call is for us!
+ if (get_host() == actor->get_host()) {
+ iteration_running = true;
+ }
+ });
+ simgrid::smpi::plugin::ampi::on_iteration_out.connect([this](simgrid::s4u::ActorPtr actor) {
+ if (get_host() == actor->get_host()) {
+ iteration_running = false;
+ task_id = 0;
+ }
+ });
+ simgrid::kernel::activity::ExecImpl::on_creation.connect([this](simgrid::kernel::activity::ExecImplPtr activity) {
+ if (activity->host_ == get_host())
+ pre_task();
+ });
+ simgrid::kernel::activity::ExecImpl::on_completion.connect([this](simgrid::kernel::activity::ExecImplPtr activity) {
+ // For more than one host (not yet supported), we can access the host via
+ // simcalls_.front()->issuer->iface()->get_host()
+ if (activity->host_ == get_host() && iteration_running) {
+ comp_timer += activity->surf_action_->get_finish_time() - activity->surf_action_->get_start_time();
+ }
+ });
+ 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) {
+ post_task();
+ }
+ });
+ }
+
+ virtual std::string get_name() const override { return "Adagio"; }
+
+ void pre_task()
+ {
+ sg_host_load_reset(get_host());
+ comp_counter = sg_host_get_computed_flops(get_host()); // Should be 0 because of the reset
+ comp_timer = 0;
+ start_time = simgrid::s4u::Engine::get_clock();
+ if (rates.size() <= task_id)
+ rates.resize(task_id + 5, std::vector<double>(get_host()->get_pstate_count(), 0.0));
+ if (rates[task_id][best_pstate] == 0)
+ best_pstate = 0;
+ get_host()->set_pstate(best_pstate); // Load our schedule
+ XBT_DEBUG("Set pstate to %i", best_pstate);
+ }
+
+ void post_task()
+ {
+ double computed_flops = sg_host_get_computed_flops(get_host()) - comp_counter;
+ double target_time = (simgrid::s4u::Engine::get_clock() - start_time);
+ target_time =
+ target_time *
+ static_cast<double>(99.0 / 100.0); // FIXME We account for t_copy arbitrarily with 1% -- this needs to be fixed
+
+ bool is_initialized = rates[task_id][best_pstate] != 0;
+ rates[task_id][best_pstate] = computed_flops / comp_timer;
+ if (not is_initialized) {
+ for (int i = 1; i < get_host()->get_pstate_count(); i++) {
+ rates[task_id][i] = rates[task_id][0] * (get_host()->get_pstate_speed(i) / get_host()->get_speed());
+ }
+ is_initialized = true;
+ }
+
+ for (int pstate = get_host()->get_pstate_count() - 1; pstate >= 0; pstate--) {
+ if (computed_flops / rates[task_id][pstate] <= target_time) {
+ // We just found the pstate we want to use!
+ best_pstate = pstate;
+ break;
+ }
+ }
+ task_id++;
+ }
+
+ virtual void update() override {}
+};
} // 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") {
+ return std::unique_ptr<simgrid::plugin::dvfs::Governor>(
+ new simgrid::plugin::dvfs::Adagio(daemon_proc->get_host()));
} else if (dvfs_governor == "performance") {
return std::unique_ptr<simgrid::plugin::dvfs::Governor>(
new simgrid::plugin::dvfs::Performance(daemon_proc->get_host()));
return res;
}
+IoPtr Storage::read_async(sg_size_t size)
+{
+
+ IoPtr res = io_init(size, Io::OpType::READ);
+ res->start();
+ return res;
+}
+
sg_size_t Storage::read(sg_size_t size)
{
IoPtr i = io_init(size, Io::OpType::READ);
return i->get_performed_ioops();
}
+IoPtr Storage::write_async(sg_size_t size)
+{
+
+ IoPtr res = io_init(size, Io::OpType::WRITE);
+ res->start();
+ return res;
+}
+
sg_size_t Storage::write(sg_size_t size)
{
IoPtr i = io_init(size, Io::OpType::WRITE);
}
/**************** Functions to trace the migration of tasks. *****************/
-void TRACE_smpi_send_process_data_in(int rank)
-{
- if (not TRACE_smpi_is_enabled()) return;
-
- smpi_container(rank)->get_state("MIGRATE_STATE")->add_entity_value("migration", instr_find_color("migration"));
- smpi_container(rank)->get_state("MIGRATE_STATE")->push_event("migration");
-}
-
-void TRACE_smpi_send_process_data_out(int rank)
-{
- if (not TRACE_smpi_is_enabled()) return;
-
- /* Clean the process state. */
- smpi_container(rank)->get_state("MIGRATE_STATE")->pop_event();
-}
-
void TRACE_smpi_process_change_host(int rank, sg_host_t new_host)
{
if (not TRACE_smpi_is_enabled()) return;
cont = smpi_container(rank); // This points to the newly created container
simgrid::instr::Container::get_root()->get_link("MIGRATE_LINK")->end_event(cont, "M", key);
}
-
namespace loadbalancer {
struct XBT_PRIVATE compare_hosts {
- bool operator()(const simgrid::s4u::Host* a, const simgrid::s4u::Host* b) const;
+ bool operator()(simgrid::s4u::Host* const a, simgrid::s4u::Host* const b) const;
};
typedef boost::heap::fibonacci_heap<simgrid::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
{
double load;
};
-static std::map<const simgrid::s4u::Host*, pair_handle_load> additional_load;
+static std::map<simgrid::s4u::Host* const, pair_handle_load> additional_load;
-bool compare_hosts::operator()(const simgrid::s4u::Host* a, const simgrid::s4u::Host* b) const {
- return /*sg_host_get_avg_load(a) +*/ additional_load[a].load > /*sg_host_get_avg_load(b) +*/ additional_load[b].load;
+bool compare_hosts::operator()(simgrid::s4u::Host* const a, simgrid::s4u::Host* const b) const {
+ return additional_load[a].load > additional_load[b].load;
}
}
}
-simgrid::s4u::Host* LoadBalancer::get_mapping()
+simgrid::s4u::Host* LoadBalancer::get_mapping(simgrid::s4u::ActorPtr actor)
{
- return new_mapping.get_host(simgrid::s4u::Actor::self());
+ return new_mapping.get_host(actor);
}
void LoadBalancer::record_actor_computation(simgrid::s4u::ActorPtr actor, double load)
+/* Copyright (c) 2006-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. */
#ifndef HAVE_SG_PLUGIN_LB
#define HAVE_SG_PLUGIN_LB
/**
* FIXME These are functions used for testing and should be re-written or removed
*/
- simgrid::s4u::Host* get_mapping();
+ simgrid::s4u::Host* get_mapping(simgrid::s4u::ActorPtr);
void record_actor_computation(simgrid::s4u::ActorPtr actor, double load);
private:
};
smpilb_bar.wait();
was_executed = false; // Must stay behind this barrier so that all processes have passed the if clause
- migrate_to_host = lb.get_mapping();
+ migrate_to_host = lb.get_mapping(simgrid::s4u::Actor::self());
if (cur_host != migrate_to_host) { // Origin and dest are not the same -> migrate
sg_host_t migration_hosts[2] = {cur_host, migrate_to_host};
// Changing this to double[2] ... will cause trouble with parallel_execute, because that fct is trying to call free().
XBT_LOG_NEW_DEFAULT_CATEGORY(dsend,"the dsend test");
-int main(int argc, char *argv[]) {
+int main()
+{
int rank;
int32_t data=11;