Also add const qualifiers to pointers and references when possible.
static void server()
{
- auto mb = sg4::Mailbox::by_name("mymailbox");
+ auto* mb = sg4::Mailbox::by_name("mymailbox");
int value_got = -1;
for (int count = 0; count < N; count++) {
int *received = mb->get<int>();
static std::mt19937 gen(42); // remove it from stack, since we need it after this this load_platform function is over
/* setting network factors callbacks */
- auto zone = e.get_netzone_root();
+ auto* zone = e.get_netzone_root();
SegmentedRegression seg = read_json_file("pingpong_ckmeans.json", gen, false);
zone->set_latency_factor_cb(std::bind(&latency_factor_cb, lat_base, seg, std::placeholders::_1, std::placeholders::_2,
static void manager()
{
- auto battery = simgrid::s4u::this_actor::get_host();
+ const auto* battery = simgrid::s4u::this_actor::get_host();
double power = 100;
while (sg_battery_get_state_of_health(battery) > 0) {
XBT_INFO("%f,%f,SoC", simgrid::s4u::Engine::get_clock(), sg_battery_get_state_of_charge(battery));
static void manager()
{
- auto battery = simgrid::s4u::Engine::get_instance()->host_by_name("battery");
- auto host1 = simgrid::s4u::Engine::get_instance()->host_by_name("host1");
- auto host2 = simgrid::s4u::Engine::get_instance()->host_by_name("host2");
+ const auto* battery = simgrid::s4u::Engine::get_instance()->host_by_name("battery");
+ auto* host1 = simgrid::s4u::Engine::get_instance()->host_by_name("host1");
+ auto* host2 = simgrid::s4u::Engine::get_instance()->host_by_name("host2");
XBT_INFO("Initial Battery: SoC: %f SoH: %f Capacity (Total): %fWh Capacity (Usable): %fWh P: %fW",
sg_battery_get_state_of_charge(battery), sg_battery_get_state_of_health(battery),
static void manager()
{
- auto battery = simgrid::s4u::Engine::get_instance()->host_by_name("battery");
+ const auto* battery = simgrid::s4u::Engine::get_instance()->host_by_name("battery");
double consumption_w = 200;
XBT_INFO("Initial Battery: SoC: %f SoH: %f Capacity (Total): %fWh Capacity (Usable): %fWh P: %f",
auto* payload = new std::string(msg_content);
/* Create a communication representing the ongoing communication, and store it in pending_comms */
- auto mbox = sg4::Mailbox::by_name(host->get_name());
+ auto* mbox = sg4::Mailbox::by_name(host->get_name());
mboxes.push_back(mbox);
sg4::CommPtr comm = mbox->put_async(payload, msg_size);
pending_comms.push_back(comm);
public:
void operator()() const
{
- auto mbox = sg4::Mailbox::by_name(sg4::this_actor::get_host()->get_name());
+ auto* mbox = sg4::Mailbox::by_name(sg4::this_actor::get_host()->get_name());
auto received = mbox->get_unique<std::string>();
XBT_INFO("I got a '%s'.", received->c_str());
}
void operator()() const
{
- auto mailbox1 = sg4::Mailbox::by_name(mailbox1_name);
- auto mailbox2 = sg4::Mailbox::by_name(mailbox2_name);
+ auto* mailbox1 = sg4::Mailbox::by_name(mailbox1_name);
+ auto* mailbox2 = sg4::Mailbox::by_name(mailbox2_name);
XBT_INFO("Initiating asynchronous send to %s", mailbox1->get_cname());
auto comm1 = mailbox1->put_async((void*)666, 5);
sg4::Engine e(&argc, argv);
e.load_platform(argv[1]);
- auto tremblay = e.host_by_name("Tremblay");
- auto jupiter = e.host_by_name("Jupiter");
+ auto* tremblay = e.host_by_name("Tremblay");
+ auto* jupiter = e.host_by_name("Jupiter");
// Display the details on vetoed activities
sg4::Exec::on_veto_cb([](sg4::Exec const& exec) {
for (const auto& a : dag) {
if (auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get())) {
- auto pred = dynamic_cast<simgrid::s4u::Exec*>((*comm->get_dependencies().begin()).get());
- auto succ = dynamic_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
+ const auto* pred = dynamic_cast<simgrid::s4u::Exec*>((*comm->get_dependencies().begin()).get());
+ const auto* succ = dynamic_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
comm->set_source(pred->get_host())->set_destination(succ->get_host());
}
}
cursor++;
}
if (auto* comm = dynamic_cast<sg4::Comm*>(a.get())) {
- auto pred = dynamic_cast<sg4::Exec*>((*comm->get_dependencies().begin()).get());
- auto succ = dynamic_cast<sg4::Exec*>(comm->get_successors().front().get());
+ const auto* pred = dynamic_cast<sg4::Exec*>((*comm->get_dependencies().begin()).get());
+ const auto* succ = dynamic_cast<sg4::Exec*>(comm->get_successors().front().get());
comm->set_source(pred->get_host())->set_destination(succ->get_host());
}
}
for (const auto& a : dag) {
if (auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get())) {
- auto pred = dynamic_cast<simgrid::s4u::Exec*>((*comm->get_dependencies().begin()).get());
- auto succ = dynamic_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
+ const auto* pred = dynamic_cast<simgrid::s4u::Exec*>((*comm->get_dependencies().begin()).get());
+ const auto* succ = dynamic_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
comm->set_source(pred->get_host())->set_destination(succ->get_host());
}
}
cursor++;
}
if (auto* comm = dynamic_cast<sg4::Comm*>(a.get())) {
- auto pred = dynamic_cast<sg4::Exec*>((*comm->get_dependencies().begin()).get());
- auto succ = dynamic_cast<sg4::Exec*>(comm->get_successors().front().get());
+ const auto* pred = dynamic_cast<sg4::Exec*>((*comm->get_dependencies().begin()).get());
+ const auto* succ = dynamic_cast<sg4::Exec*>(comm->get_successors().front().get());
comm->set_source(pred->get_host())->set_destination(succ->get_host());
}
}
sg4::Engine e(&argc, argv);
e.load_platform(argv[1]);
- auto bob = e.host_by_name("bob");
- auto carl = e.host_by_name("carl");
+ auto* bob = e.host_by_name("bob");
+ auto* carl = e.host_by_name("carl");
// Display the details on vetoed activities
sg4::Exec::on_veto_cb([](sg4::Exec const& exec) {
std::vector<sg4::Exec*> ready_tasks;
std::map<sg4::Exec*, unsigned int> candidate_execs;
- for (auto& a : dax) {
+ for (const auto& a : dax) {
// Only look at activity that have their dependencies solved but are not assigned
if (a->dependencies_solved() && not a->is_assigned()) {
// if it is an exec, it's ready
for (const auto& parent : exec->get_dependencies()) {
/* normal case */
if (const auto* comm = dynamic_cast<sg4::Comm*>(parent.get())) {
- auto source = comm->get_source();
+ const auto* source = comm->get_source();
XBT_DEBUG("transfer from %s to %s", source->get_cname(), host->get_cname());
/* Estimate the redistribution time from this parent */
double redist_time;
sg4::Exec* selected_task = nullptr;
sg4::Host* selected_host = nullptr;
- for (auto exec : ready_tasks) {
+ for (auto* exec : ready_tasks) {
XBT_DEBUG("%s is ready", exec->get_cname());
double finish_time;
host = get_best_host(exec, &finish_time);
std::set<sg4::Activity*> vetoed;
e.track_vetoed_activities(&vetoed);
- auto fafard = e.host_by_name("Fafard");
+ auto* fafard = e.host_by_name("Fafard");
// Display the details on vetoed activities
sg4::Exec::on_veto_cb([](sg4::Exec const& exec) {
auto* zone = sg4::create_full_zone("world");
std::vector<sg4::Host*> hosts;
- for (auto name : {"Host1", "Host2", "Host3"}) {
+ for (const auto* name : {"Host1", "Host2", "Host3"}) {
auto* host = zone->create_host(name, "1f");
hosts.push_back(host);
}
static void runner()
{
- auto e = sg4::Engine::get_instance();
+ auto* e = sg4::Engine::get_instance();
std::vector<double> comp(2, 1e9);
std::vector<double> comm(4, 0.0);
// Different hosts.
static void runner()
{
- auto e = sg4::Engine::get_instance();
+ auto* e = sg4::Engine::get_instance();
std::vector<double> comp(2, 1e9);
std::vector<double> comm(4, 0.0);
// Different hosts.
XBT_INFO("Computed 2-core activity on two different hosts. Took %g s", e->get_clock() - start_time);
// Add a background task and change ptask on the fly
- auto MyHost1 = e->host_by_name("MyHost1");
+ auto* MyHost1 = e->host_by_name("MyHost1");
sg4::ExecPtr background_task = MyHost1->exec_async(5e9);
XBT_INFO("Start a 1-core background task on the 4-core host.");
static void runner()
{
- auto e = sg4::Engine::get_instance();
+ auto* e = sg4::Engine::get_instance();
sg4::Host* multicore_host = e->host_by_name("MyHost1");
// First test with less than, same number as, and more threads than cores
double start_time = sg4::Engine::get_clock();
}
/* Create a communication representing the ongoing communication */
- auto mbox = sg4::Mailbox::by_name(host->get_name());
+ auto* mbox = sg4::Mailbox::by_name(host->get_name());
auto* payload = new std::string(msg);
mbox->put(payload, static_cast<uint64_t>(size));
}
XBT_INFO("Done dispatching all messages");
/* sending message to stop receivers */
for (const auto* host : hosts_) {
- auto mbox = sg4::Mailbox::by_name(host->get_name());
+ auto* mbox = sg4::Mailbox::by_name(host->get_name());
mbox->put(new std::string("finalize"), 0);
}
}
public:
void operator()() const
{
- auto mbox = sg4::Mailbox::by_name(sg4::this_actor::get_host()->get_name());
+ auto* mbox = sg4::Mailbox::by_name(sg4::this_actor::get_host()->get_name());
// Receiving the message was all we were supposed to do
for (bool cont = true; cont;) {
auto received = mbox->get_unique<std::string>();
e.load_platform(argv[1]);
/* Exchange a message between the 2 stations */
- auto mailbox = sg4::Mailbox::by_name("mailbox");
- auto station1 = e.host_by_name("Station 1");
- auto station2 = e.host_by_name("Station 2");
+ auto* mailbox = sg4::Mailbox::by_name("mailbox");
+ auto* station1 = e.host_by_name("Station 1");
+ auto* station2 = e.host_by_name("Station 2");
sg4::Actor::create("sender", station1, sender, mailbox, 1e7);
sg4::Actor::create("receiver", station2, receiver, mailbox);
/* Declare that the stations are not at the same distance from their AP */
- auto ap = e.link_by_name("AP1");
+ const auto* ap = e.link_by_name("AP1");
ap->set_host_wifi_rate(station1, 1); // The host "Station 1" uses the second level of bandwidths on that AP
ap->set_host_wifi_rate(station2, 0); // This is perfectly useless as level 0 is used by default
static void manager()
{
- auto pv_panel = simgrid::s4u::Engine::get_instance()->host_by_name("pv_panel");
+ const auto* pv_panel = simgrid::s4u::Engine::get_instance()->host_by_name("pv_panel");
std::vector<std::pair<double, double>> solar_irradiance = {{1, 10}, {100, 5}, {200, 20}};
for (auto [t, s] : solar_irradiance) {
simgrid::s4u::this_actor::sleep_until(t);
static void sender(const std::string& mailbox, uint64_t msg_size)
{
- auto mbox = sg4::Mailbox::by_name(mailbox);
+ auto* mbox = sg4::Mailbox::by_name(mailbox);
static int payload = 42;
mbox->put(&payload, msg_size);
}
static void receiver(const std::string& mailbox)
{
- auto mbox = sg4::Mailbox::by_name(mailbox);
+ auto* mbox = sg4::Mailbox::by_name(mailbox);
mbox->get<int>();
}
static void execute_load_test()
{
- auto host0 = sg4::Host::by_name("node-0.simgrid.org");
- auto host1 = sg4::Host::by_name("node-1.simgrid.org");
+ auto* host0 = sg4::Host::by_name("node-0.simgrid.org");
+ auto* host1 = sg4::Host::by_name("node-1.simgrid.org");
sg4::this_actor::sleep_for(1);
run_transfer(host0, host1, "1", 1000 * 1000 * 1000);
static void monitor()
{
- auto link_backbone = sg4::Link::by_name("cluster0_backbone");
- auto link_host0 = sg4::Link::by_name("cluster0_link_0_UP");
- auto link_host1 = sg4::Link::by_name("cluster0_link_1_DOWN");
+ const auto* link_backbone = sg4::Link::by_name("cluster0_backbone");
+ const auto* link_host0 = sg4::Link::by_name("cluster0_link_0_UP");
+ const auto* link_host1 = sg4::Link::by_name("cluster0_link_1_DOWN");
XBT_INFO("Tracking desired links");
sg_link_load_track(link_backbone);
auto cv = sg4::ConditionVariable::create();
auto ready = std::make_shared<bool>(false);
- auto host = sg4::this_actor::get_host();
+ auto* host = sg4::this_actor::get_host();
for (int i = 0; i < 10; ++i)
sg4::Actor::create("competitor", host, competitor, i, cv, mtx, ready);
sg4::Actor::create("go", host, go, cv, mtx, ready);
simgrid::plugins::Task::init();
// Retrieve hosts
- auto bob = e.host_by_name("bob");
- auto carl = e.host_by_name("carl");
+ auto* bob = e.host_by_name("bob");
+ auto* carl = e.host_by_name("carl");
// Create tasks
auto exec1 = simgrid::plugins::ExecTask::init("exec1", 1e9, bob);
simgrid::plugins::Task::init();
// Retrieve hosts
- auto tremblay = e.host_by_name("Tremblay");
- auto jupiter = e.host_by_name("Jupiter");
+ auto* tremblay = e.host_by_name("Tremblay");
+ auto* jupiter = e.host_by_name("Jupiter");
// Create tasks
auto exec1 = simgrid::plugins::ExecTask::init("exec1", 1e9, tremblay);
simgrid::plugins::Task::init();
// Retreive hosts
- auto tremblay = e.host_by_name("Tremblay");
- auto jupiter = e.host_by_name("Jupiter");
+ auto* tremblay = e.host_by_name("Tremblay");
+ auto* jupiter = e.host_by_name("Jupiter");
// Create tasks
auto comm = simgrid::plugins::CommTask::init("comm", 1e7, tremblay, jupiter);
static void master()
{
- auto mbox = sg4::Mailbox::by_name("master_mailbox");
+ auto* mbox = sg4::Mailbox::by_name("master_mailbox");
for (int i = 0; i < 10; i++) {
Task task;
if (i % 2)
static void worker()
{
- auto mbox = sg4::Mailbox::by_name("master_mailbox");
+ auto* mbox = sg4::Mailbox::by_name("master_mailbox");
while (true) {
auto task = mbox->get_unique<Task>();
if (task->name == "finalize") {
long communication_cost = std::stol(args[3]);
size_t workers_count = args.size() - 4;
const auto& my_host = sg4::this_actor::get_host()->get_name();
- auto mailbox = sg4::Mailbox::by_name("master_mailbox");
+ auto* mailbox = sg4::Mailbox::by_name("master_mailbox");
XBT_DEBUG("Got %zu workers and %ld tasks to process", workers_count, tasks_count);
xbt_assert(args.size() == 1, "The worker expects no argument");
const auto& my_host = sg4::this_actor::get_host()->get_name();
- auto mailbox = sg4::Mailbox::by_name("master_mailbox");
+ auto* mailbox = sg4::Mailbox::by_name("master_mailbox");
simgrid::instr::set_host_variable(my_host, "is_worker", 1);
simgrid::instr::set_host_variable(my_host, "task_computation", 0);
/* The guy we will move from host to host. It move alone and then is moved by policeman back */
static void emigrant()
{
- auto mailbox = sg4::Mailbox::by_name("master_mailbox");
+ auto* mailbox = sg4::Mailbox::by_name("master_mailbox");
sg4::this_actor::sleep_for(2);
// I am the master of emigrant actor,
// I tell it where it must emigrate to.
auto destinations = {"Tremblay", "Jupiter", "Fafard", "Ginette", "Bourassa", "Fafard", "Tremblay", "Ginette", ""};
- auto mailbox = sg4::Mailbox::by_name("master_mailbox");
+ auto* mailbox = sg4::Mailbox::by_name("master_mailbox");
for (auto const& destination : destinations) {
mailbox->put_init(new std::string(destination), 0)->set_tracing_category("migration_order")->wait();
const auto& linkname = "link_" + node_name;
sg4::NetZone* node = create_node(supernode, node_name, nb_cpu);
- const auto router = node->create_router("router_" + node_name);
+ auto* router = node->create_router("router_" + node_name);
node->seal();
const sg4::Link* l = supernode->create_split_duplex_link(linkname, BW_NODE)->set_latency(LAT_NODE)->seal();
const auto& linkname = "link_" + supernode_name;
sg4::NetZone* supernode = create_supernode(cluster, supernode_name, nb_nodes, nb_cpu);
- const auto router = supernode->create_router("router_" + supernode_name);
+ auto* router = supernode->create_router("router_" + supernode_name);
supernode->seal();
const sg4::Link* l = cluster->create_split_duplex_link(linkname, BW_NETWORK)->set_latency(LAT_NETWORK)->seal();
int main(int argc, char* argv[])
{
- auto properties = simgrid::s4u::Actor::self()->get_properties();
+ const auto* properties = simgrid::s4u::Actor::self()->get_properties();
const char* instance_id = properties->at("instance_id").c_str();
const int rank = static_cast<int>(xbt_str_parse_int(properties->at("rank").c_str(), "Cannot parse rank"));
if (TRACE_actor_is_enabled()) {
s4u::Actor::on_creation_cb(on_actor_creation);
s4u::Actor::on_destruction_cb([](s4u::Actor const& actor) {
- auto container = Container::by_name_or_null(instr_pid(actor));
- if (container != nullptr)
+ if (auto* container = Container::by_name_or_null(instr_pid(actor)))
container->remove_from_parent();
});
s4u::Actor::on_suspend_cb([](s4u::Actor const& actor) {
}
XBT_DEBUG("Looking for next event in all models");
- for (auto model : models_) {
+ for (auto* model : models_) {
if (not model->next_occurring_event_is_idempotent())
continue;
double next_event_date = profile::future_evt_set.next_date();
XBT_DEBUG("Next TRACE event: %f", next_event_date);
- for (auto model : models_) {
+ for (auto* model : models_) {
/* Skip all idempotent models, they were already treated above
* NS3 is the one to handled here */
if (model->next_occurring_event_is_idempotent())
void SemAcquisitionImpl::cancel()
{
/* Remove myself from the list of interested parties */
- auto issuer = get_issuer();
+ auto* issuer = get_issuer();
auto it = std::find_if(semaphore_->ongoing_acquisitions_.begin(), semaphore_->ongoing_acquisitions_.end(),
[issuer](SemAcquisitionImplPtr acqui) { return acqui->get_issuer() == issuer; });
xbt_assert(it != semaphore_->ongoing_acquisitions_.end(),
throw_exception(std::make_exception_ptr(
HostFailureException(XBT_THROW_POINT, "Host " + host_->get_name() + " failed, you cannot sleep there.")));
- auto sleep_activity = new activity::SleepImpl();
+ auto* sleep_activity = new activity::SleepImpl();
sleep_activity->set_name("sleep").set_host(host_).set_duration(duration).start();
return activity::SleepImplPtr(sleep_activity);
}
}
static void serialize_activity_test(const activity::ActivityImpl* act, std::stringstream& stream)
{
- if (auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
+ if (const auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
stream << " " << (short)mc::Transition::Type::COMM_TEST;
stream << ' ' << (uintptr_t)comm;
stream << ' ' << (comm->src_actor_ != nullptr ? comm->src_actor_->get_pid() : -1);
}
static std::string to_string_activity_test(const activity::ActivityImpl* act)
{
- if (auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
+ if (const auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
const std::string src_buff_id = ptr_to_id<unsigned char>(comm->src_buff_);
const std::string dst_buff_id = ptr_to_id<unsigned char>(comm->dst_buff_);
return "CommTest(comm_id:" + ptr_to_id<activity::CommImpl const>(comm) +
}
static void serialize_activity_wait(const activity::ActivityImpl* act, bool timeout, std::stringstream& stream)
{
- if (auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
+ if (const auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
stream << (short)mc::Transition::Type::COMM_WAIT << ' ';
stream << timeout << ' ' << (uintptr_t)comm;
}
static std::string to_string_activity_wait(const activity::ActivityImpl* act)
{
- if (auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
+ if (const auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
const std::string src_buff_id = ptr_to_id<unsigned char>(comm->src_buff_);
const std::string dst_buff_id = ptr_to_id<unsigned char>(comm->dst_buff_);
return "CommWait(comm_id:" + ptr_to_id<activity::CommImpl const>(comm) +
static void simcall(simgrid::kernel::actor::Simcall::Type call, std::function<void()> const& code,
simgrid::kernel::actor::SimcallObserver* observer)
{
- auto self = simgrid::kernel::actor::ActorImpl::self();
+ auto* self = simgrid::kernel::actor::ActorImpl::self();
self->simcall_.call_ = call;
self->simcall_.code_ = &code;
self->simcall_.observer_ = observer;
void simcall_run_object_access(std::function<void()> const& code, simgrid::kernel::actor::ObjectAccessSimcallItem* item)
{
- auto self = simgrid::kernel::actor::ActorImpl::self();
+ auto* self = simgrid::kernel::actor::ActorImpl::self();
// We only need a simcall if the order of the setters is important (parallel run or MC execution).
// Otherwise, just call the function with no simcall
s4u::Disk* HostImpl::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
{
- auto disk = piface_.get_netpoint()->get_englobing_zone()->get_disk_model()->create_disk(name, read_bandwidth,
- write_bandwidth);
+ auto* disk = piface_.get_netpoint()->get_englobing_zone()->get_disk_model()->create_disk(name, read_bandwidth,
+ write_bandwidth);
if (sealed_)
disk->seal();
return disk->set_host(&piface_)->get_iface();
static s4u::VirtualMachine* get_vm_from_activity(s4u::Activity const& act)
{
- auto* exec = dynamic_cast<kernel::activity::ExecImpl const*>(act.get_impl());
+ const auto* exec = dynamic_cast<kernel::activity::ExecImpl const*>(act.get_impl());
return exec != nullptr ? dynamic_cast<s4u::VirtualMachine*>(exec->get_host()) : nullptr;
}
Action* VMModel::execute_thread(const s4u::Host* host, double flops_amount, int thread_count)
{
- auto cpu = host->get_cpu();
+ auto* cpu = host->get_cpu();
return cpu->execution_start(thread_count * flops_amount, thread_count, -1);
}
Action* HostCLM03Model::io_stream(s4u::Host* src_host, DiskImpl* src_disk, s4u::Host* dst_host, DiskImpl* dst_disk,
double size)
{
- auto net_model = src_host->get_englobing_zone()->get_network_model();
- auto system = net_model->get_maxmin_system();
+ auto* net_model = src_host->get_englobing_zone()->get_network_model();
+ auto* system = net_model->get_maxmin_system();
auto* action = net_model->communicate(src_host, dst_host, size, -1, true);
// We don't want to apply the network model bandwidth factor to the I/O constraints
Action* HostCLM03Model::execute_thread(const s4u::Host* host, double flops_amount, int thread_count)
{
- auto cpu = host->get_cpu();
+ auto* cpu = host->get_cpu();
/* Create a single action whose cost is thread_count * flops_amount and that requests thread_count cores. */
return cpu->execution_start(thread_count * flops_amount, thread_count, -1);
}
StandardLinkImpl* NetworkCm02Model::create_link(const std::string& name, const std::vector<double>& bandwidths)
{
xbt_assert(bandwidths.size() == 1, "Non-WIFI links must use only 1 bandwidth.");
- auto link = new NetworkCm02Link(name, bandwidths[0], get_maxmin_system());
+ auto* link = new NetworkCm02Link(name, bandwidths[0], get_maxmin_system());
link->set_model(this);
return link;
}
StandardLinkImpl* NetworkCm02Model::create_wifi_link(const std::string& name, const std::vector<double>& bandwidths)
{
- auto link = new WifiLinkImpl(name, bandwidths, get_maxmin_system());
+ auto* link = new WifiLinkImpl(name, bandwidths, get_maxmin_system());
link->set_model(this);
return link;
}
set_maxmin_system(sys);
auto net_model = std::make_shared<NetworkL07Model>("Network_Ptask", this, sys);
- auto engine = EngineImpl::get_instance();
+ auto* engine = EngineImpl::get_instance();
engine->add_model(net_model);
engine->get_netzone_root()->set_network_model(net_model);
StandardLinkImpl* NetworkL07Model::create_link(const std::string& name, const std::vector<double>& bandwidths)
{
xbt_assert(bandwidths.size() == 1, "Non WIFI link must have only 1 bandwidth.");
- auto link = new LinkL07(name, bandwidths[0], get_maxmin_system());
+ auto* link = new LinkL07(name, bandwidths[0], get_maxmin_system());
link->set_model(this);
return link;
}
MockedResource daResource;
simgrid::kernel::profile::FutureEvtSet fes;
- simgrid::kernel::profile::Event* insertedIt = trace->schedule(&fes, &daResource);
+ const simgrid::kernel::profile::Event* insertedIt = trace->schedule(&fes, &daResource);
while (fes.next_date() <= 20.0 && fes.next_date() >= 0) {
MockedResource::the_date = fes.next_date();
continue;
std::vector<std::string> tokens;
boost::split(tokens, remote_disk_str, boost::is_any_of(":"));
- simgrid::s4u::Host* remote_host = simgrid::s4u::Host::by_name_or_null(tokens[2]);
+ const simgrid::s4u::Host* remote_host = simgrid::s4u::Host::by_name_or_null(tokens[2]);
xbt_assert(remote_host, "You're trying to access a host that does not exist. Please check your platform file");
const simgrid::s4u::Disk* disk = nullptr;
for (auto const& [trace, name] : trace_connect_list_host_avail) {
simgrid_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
"<trace_connect kind=\"HOST_AVAIL\">: Trace " + trace + " undefined.");
- auto profile = traces_set_list.at(trace);
+ auto* profile = traces_set_list.at(trace);
- auto host = engine->host_by_name_or_null(name);
+ auto* host = engine->host_by_name_or_null(name);
simgrid_parse_assert(host, "<trace_connect kind=\"HOST_AVAIL\">: Host " + name + " undefined.");
host->set_state_profile(profile);
}
for (auto const& [trace, name] : trace_connect_list_host_speed) {
simgrid_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
"<trace_connect kind=\"SPEED\">: Trace " + trace + " undefined.");
- auto profile = traces_set_list.at(trace);
+ auto* profile = traces_set_list.at(trace);
- auto host = engine->host_by_name_or_null(name);
+ auto* host = engine->host_by_name_or_null(name);
simgrid_parse_assert(host, "<trace_connect kind=\"SPEED\">: Host " + name + " undefined.");
host->set_speed_profile(profile);
}
for (auto const& [trace, name] : trace_connect_list_link_avail) {
simgrid_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
"<trace_connect kind=\"LINK_AVAIL\">: Trace " + trace + " undefined.");
- auto profile = traces_set_list.at(trace);
+ auto* profile = traces_set_list.at(trace);
- auto link = engine->link_by_name_or_null(name);
+ auto* link = engine->link_by_name_or_null(name);
simgrid_parse_assert(link, "<trace_connect kind=\"LINK_AVAIL\">: Link " + name + " undefined.");
link->set_state_profile(profile);
}
for (auto const& [trace, name] : trace_connect_list_link_bw) {
simgrid_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
"<trace_connect kind=\"BANDWIDTH\">: Trace " + trace + " undefined.");
- auto profile = traces_set_list.at(trace);
+ auto* profile = traces_set_list.at(trace);
- auto link = engine->link_by_name_or_null(name);
+ auto* link = engine->link_by_name_or_null(name);
simgrid_parse_assert(link, "<trace_connect kind=\"BANDWIDTH\">: Link " + name + " undefined.");
link->set_bandwidth_profile(profile);
}
for (auto const& [trace, name] : trace_connect_list_link_lat) {
simgrid_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
"<trace_connect kind=\"LATENCY\">: Trace " + trace + " undefined.");
- auto profile = traces_set_list.at(trace);
+ auto* profile = traces_set_list.at(trace);
- auto link = engine->link_by_name_or_null(name);
+ auto* link = engine->link_by_name_or_null(name);
simgrid_parse_assert(link, "<trace_connect kind=\"LATENCY\">: Link " + name + " undefined.");
link->set_latency_profile(profile);
}
/* For each actor in the previous sleep set, keep it if it is not dependent with current transition.
* And if we kept it and the actor is enabled in this state, mark the actor as already done, so that
* it is not explored*/
- for (auto& [aid, transition] : parent_state_->get_sleep_set()) {
+ for (const auto& [aid, transition] : parent_state_->get_sleep_set()) {
if (not incoming_transition_->depends(transition.get())) {
sleep_set_.try_emplace(aid, transition);
if (strategy_->actors_to_run_.count(aid) != 0) {
std::vector<unsigned> communication_indices_;
static simgrid::xbt::Extension<simgrid::mc::State, StateCommDet> EXTENSION_ID;
- explicit StateCommDet(CommDetExtension& checker, RemoteApp const& remote_app)
+ explicit StateCommDet(CommDetExtension const& checker, RemoteApp const& remote_app)
{
const unsigned long maxpid = remote_app.get_maxpid();
for (unsigned long i = 0; i < maxpid; i++) {
pattern->index = initial_pattern.index_comm + incomplete_pattern.size();
if (transition->type_ == Transition::Type::COMM_ASYNC_SEND) {
- auto* send = static_cast<const CommSendTransition*>(transition);
+ const auto* send = static_cast<const CommSendTransition*>(transition);
pattern->type = PatternCommunicationType::send;
pattern->comm_addr = send->get_comm();
// FIXME: Detached sends should be enforced when the receive is waited
} else if (transition->type_ == Transition::Type::COMM_ASYNC_RECV) {
- auto* recv = static_cast<const CommRecvTransition*>(transition);
+ const auto* recv = static_cast<const CommRecvTransition*>(transition);
pattern->type = PatternCommunicationType::receive;
pattern->comm_addr = recv->get_comm();
XBT_DEBUG("********* Start communication determinism verification *********");
- auto base = new DFSExplorer(args, mode, true);
- auto extension = new CommDetExtension(*base);
+ auto* base = new DFSExplorer(args, mode, true);
+ auto* extension = new CommDetExtension(*base);
DFSExplorer::on_exploration_start([extension](RemoteApp const&) {
XBT_INFO("Check communication determinism");
if (_sg_mc_sleep_set && XBT_LOG_ISENABLED(mc_dfs, xbt_log_priority_verbose)) {
XBT_VERB("Sleep set actually containing:");
- for (auto& [aid, transition] : state->get_sleep_set())
+ for (const auto& [aid, transition] : state->get_sleep_set())
XBT_VERB(" <%ld,%s>", aid, transition->to_string().c_str());
}
const auto& state = *iter;
state->do_odpor_unwind();
XBT_DEBUG("\tPerformed ODPOR 'clean-up'. Sleep set has:");
- for (auto& [aid, transition] : state->get_sleep_set())
+ for (const auto& [aid, transition] : state->get_sleep_set())
XBT_DEBUG("\t <%ld,%s>", aid, transition->to_string().c_str());
if (!state->has_empty_tree()) {
return state;
} else {
XBT_DEBUG("ODPOR: Ignoring race: `sleep(E')` intersects `WI_[E'](v := notdep(%u, E))`", e);
XBT_DEBUG("Sleep set contains:");
- for (auto& [aid, transition] : prev_state.get_sleep_set())
+ for (const auto& [aid, transition] : prev_state.get_sleep_set())
XBT_DEBUG(" <%ld,%s>", aid, transition->to_string().c_str());
}
}
EventSet UdporChecker::compute_enC(const Configuration& C, const EventSet& exC) const
{
EventSet enC;
- for (const auto e : exC) {
+ for (const auto* e : exC) {
if (C.is_compatible_with(e)) {
enC.insert(e);
}
{Action::TESTANY, &ReversibleRaceCalculator::is_race_reversible_TestAny},
{Action::WAITANY, &ReversibleRaceCalculator::is_race_reversible_WaitAny}};
- const auto e2_action = E.get_transition_for_handle(e2);
+ const auto* e2_action = E.get_transition_for_handle(e2);
if (const auto handler = handlers.find(e2_action->type_); handler != handlers.end()) {
return handler->second(E, e1, e2_action);
} else {
return false;
}
-} // namespace simgrid::mc::odpor
\ No newline at end of file
+} // namespace simgrid::mc::odpor
std::list<WakeupTreeNode*> subtree_contents{root};
std::list<WakeupTreeNode*> frontier{root};
while (not frontier.empty()) {
- auto node = frontier.front();
+ const auto* node = frontier.front();
frontier.pop_front();
for (const auto& child : node->get_ordered_children()) {
frontier.push_back(child);
}
}
-bool WakeupTree::contains(WakeupTreeNode* node) const
+bool WakeupTree::contains(const WakeupTreeNode* node) const
{
return std::find_if(this->nodes_.begin(), this->nodes_.end(), [=](const auto& pair) { return pair.first == node; }) !=
this->nodes_.end();
}
}
-} // namespace simgrid::mc::odpor
\ No newline at end of file
+} // namespace simgrid::mc::odpor
void insert_node(std::unique_ptr<WakeupTreeNode> node);
void insert_sequence_after(WakeupTreeNode* node, const PartialExecution& w);
void remove_node(WakeupTreeNode* node);
- bool contains(WakeupTreeNode* node) const;
+ bool contains(const WakeupTreeNode* node) const;
/**
* @brief Removes the node `root` and all of its descendants from
std::for_each(ordered_events.begin(), ordered_events.end(), [&events_seen](const UnfoldingEvent* e) {
History history(e);
- for (auto* e_hist : history) {
+ for (const auto* e_hist : history) {
// In this demo, we want to make sure that
// we don't mark not yet seeing `e` as an error.
// The history of `e` traverses `e` itself. All
std::for_each(ordered_events.begin(), ordered_events.end(), [&events_seen](const UnfoldingEvent* e) {
History history(e);
- for (auto* e_hist : history) {
+ for (const auto* e_hist : history) {
// Unlike the test above, we DO want to ensure
// that `e` itself ALSO isn't yet seen
auto e0 = std::make_unique<UnfoldingEvent>(
EventSet(), std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 0));
- auto e0_handle = e0.get();
+ auto* e0_handle = e0.get();
auto e1 = std::make_unique<UnfoldingEvent>(EventSet({e0_handle}),
std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 0));
- auto e1_handle = e1.get();
+ auto* e1_handle = e1.get();
auto e2 = std::make_unique<UnfoldingEvent>(
EventSet({e1_handle}), std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1));
- auto e2_handle = e2.get();
+ auto* e2_handle = e2.get();
auto e3 = std::make_unique<UnfoldingEvent>(
EventSet({e1_handle}), std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 2));
- auto e3_handle = e3.get();
+ auto* e3_handle = e3.get();
auto e4 = std::make_unique<UnfoldingEvent>(
EventSet({e0_handle}), std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1));
- auto e4_handle = e4.get();
+ auto* e4_handle = e4.get();
auto e5 = std::make_unique<UnfoldingEvent>(EventSet({e4_handle}),
std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 0));
- auto e5_handle = e5.get();
+ auto* e5_handle = e5.get();
auto e6 = std::make_unique<UnfoldingEvent>(
EventSet({e5_handle}), std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 2));
- auto e6_handle = e6.get();
+ auto* e6_handle = e6.get();
auto e7 = std::make_unique<UnfoldingEvent>(
EventSet({e0_handle}), std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 2));
- auto e7_handle = e7.get();
+ auto* e7_handle = e7.get();
auto e8 = std::make_unique<UnfoldingEvent>(EventSet({e4_handle, e7_handle}),
std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 0));
- auto e8_handle = e8.get();
+ auto* e8_handle = e8.get();
auto e9 = std::make_unique<UnfoldingEvent>(EventSet({e7_handle}),
std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 0));
- auto e9_handle = e9.get();
+ auto* e9_handle = e9.get();
auto e10 = std::make_unique<UnfoldingEvent>(
EventSet({e9_handle}), std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1));
- auto e10_handle = e10.get();
+ auto* e10_handle = e10.get();
SECTION("Alternative computation call 1")
{
std::for_each(ordered_events.begin(), ordered_events.end(), [&](const UnfoldingEvent* e) {
History history(e);
- for (auto* e_hist : history) {
+ for (const auto* e_hist : history) {
if (e_hist == e)
continue;
REQUIRE_FALSE(invalid_events.contains(e_hist));
std::for_each(ordered_events.begin(), ordered_events.end(), [&events_seen](const UnfoldingEvent* e) {
History history(e);
- for (auto* e_hist : history) {
+ for (const auto* e_hist : history) {
// Unlike the test above, we DO want to ensure
// that `e` itself ALSO isn't yet seen
// NOTE: If `preEvt(a, C)` doesn't exist, we're effectively asking
// about `config({})`
if (pre_event_a_C.has_value()) {
- const auto e_prime = U->discover_event(EventSet({pre_event_a_C.value()}), send_action);
+ const auto* e_prime = U->discover_event(EventSet({pre_event_a_C.value()}), send_action);
exC.insert(e_prime);
} else {
- const auto e_prime = U->discover_event(EventSet(), send_action);
+ const auto* e_prime = U->discover_event(EventSet(), send_action);
exC.insert(e_prime);
}
// 2. foreach e ∈ C s.t. λ(e) ∈ {AsyncSend(m, _), TestAny(Com)} where
// Com contains a matching c' = AsyncReceive(m, _) with a
- for (const auto e : C) {
+ for (const auto* e : C) {
const bool transition_type_check = [&]() {
if (const auto* async_send = dynamic_cast<const CommSendTransition*>(e->get_transition());
async_send != nullptr) {
// TODO: Check D_K(a, lambda(e))
if (true) {
- const auto e_prime = U->discover_event(std::move(K), send_action);
+ const auto* e_prime = U->discover_event(std::move(K), send_action);
exC.insert(e_prime);
}
}
// 1. Create `e' := <a, config(preEvt(a, C))>` and add `e'` to `ex(C)`
if (pre_event_a_C.has_value()) {
- const auto e_prime = U->discover_event(EventSet({pre_event_a_C.value()}), recv_action);
+ const auto* e_prime = U->discover_event(EventSet({pre_event_a_C.value()}), recv_action);
exC.insert(e_prime);
} else {
- const auto e_prime = U->discover_event(EventSet(), recv_action);
+ const auto* e_prime = U->discover_event(EventSet(), recv_action);
exC.insert(e_prime);
}
// 2. foreach e ∈ C s.t. λ(e) ∈ {AsyncSend(m, _), TestAny(Com)} where
// Com contains a matching c' = AsyncReceive(m, _) with a
- for (const auto e : C) {
+ for (const auto* e : C) {
const bool transition_type_check = [&]() {
if (const auto* async_recv = dynamic_cast<const CommRecvTransition*>(e->get_transition());
async_recv != nullptr && async_recv->get_mailbox() == recv_mailbox) {
// TODO: Check D_K(a, lambda(e))
if (true) {
- const auto e_prime = U->discover_event(std::move(K), recv_action);
+ const auto* e_prime = U->discover_event(std::move(K), recv_action);
exC.insert(e_prime);
}
}
// First, if `pre_event_a_C == std::nullopt`, then there is nothing to
// do: `CommWait` will never be enabled in the empty configuration (at
// least two actions must be executed before)
- if (pre_event_a_C.has_value(); const auto unwrapped_pre_event = pre_event_a_C.value()) {
+ if (pre_event_a_C.has_value(); const auto* unwrapped_pre_event = pre_event_a_C.value()) {
// A necessary condition is that the issuer be present in
// config({preEvt(a, C)}); otherwise, the `CommWait` could not
// be enabled since the communication on which it waits would not
}
// 3. foreach event e in C do
- for (const auto e : C) {
+ for (const auto* e : C) {
if (const CommSendTransition* e_issuer_send = dynamic_cast<const CommSendTransition*>(e_issuer->get_transition());
e_issuer_send != nullptr) {
// If the provider of the communication for `CommWait` is a
void Unfolding::mark_finished(const EventSet& events)
{
- for (const auto e : events) {
+ for (const auto* e : events) {
mark_finished(e);
}
}
// Note, though, that in this case we must move the event in `G` into
// `U`: we've inserted `e` into the unfolding, so we expect it to be in `U`
if (auto loc = std::find_if(G.begin(), G.end(), [=](const auto e_i) { return *e_i == *handle; }); loc != G.end()) {
- const auto e_equiv = *loc;
+ const auto* e_equiv = *loc;
G.remove(e_equiv);
U.insert(e_equiv);
return e_equiv;
EventSet Unfolding::get_immediate_conflicts_of(const UnfoldingEvent* e) const
{
EventSet immediate_conflicts;
- for (const auto event : U) {
+ for (const auto* event : U) {
if (event->immediately_conflicts_with(e)) {
immediate_conflicts.insert(event);
}
EventSet(), std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 0));
auto e2 =
std::make_unique<UnfoldingEvent>(EventSet(), std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 1));
- const auto e1_handle = e1.get();
- const auto e2_handle = e2.get();
+ auto* e1_handle = e1.get();
+ auto* e2_handle = e2.get();
unfolding.insert(std::move(e1));
REQUIRE(unfolding.size() == 1);
REQUIRE_FALSE(unfolding.empty());
}
-TEST_CASE("simgrid::mc::udpor::Unfolding: Checking all immediate conflicts restricted to an unfolding") {}
\ No newline at end of file
+TEST_CASE("simgrid::mc::udpor::Unfolding: Checking all immediate conflicts restricted to an unfolding") {}
void maximal_subsets_iterator::Bookkeeper::mark_included_in_maximal_set(const UnfoldingEvent* e)
{
const auto e_local_config = e->get_local_config();
- for (const auto e_hist : e_local_config) {
+ for (const auto* e_hist : e_local_config) {
event_counts[e_hist]++;
}
}
void maximal_subsets_iterator::Bookkeeper::mark_removed_from_maximal_set(const UnfoldingEvent* e)
{
const auto e_local_config = e->get_local_config();
- for (const auto e_hist : e_local_config) {
+ for (const auto* e_hist : e_local_config) {
xbt_assert(event_counts.find(e_hist) != event_counts.end(),
"Invariant Violation: Attempted to remove an event which was not previously added");
xbt_assert(event_counts[e_hist] > 0, "Invariant Violation: An event `e` had a count of `0` at this point "
socket_event_ = event_new(
base, get_channel().get_socket(), EV_READ | EV_PERSIST,
[](evutil_socket_t, short events, void* arg) {
- auto checker = static_cast<simgrid::mc::CheckerSide*>(arg);
+ auto* checker = static_cast<simgrid::mc::CheckerSide*>(arg);
if (events == EV_READ) {
do {
std::array<char, MC_MESSAGE_LENGTH> buffer;
signal_event_ = event_new(
base, SIGCHLD, EV_SIGNAL | EV_PERSIST,
[](evutil_socket_t sig, short events, void* arg) {
- auto checker = static_cast<simgrid::mc::CheckerSide*>(arg);
+ auto* checker = static_cast<simgrid::mc::CheckerSide*>(arg);
if (events == EV_SIGNAL) {
if (sig == SIGCHLD)
checker->handle_waitpid();
return true; // DEP with other send transitions
}
- if (auto* wait = dynamic_cast<const CommWaitTransition*>(other)) {
+ if (const auto* wait = dynamic_cast<const CommWaitTransition*>(other)) {
if (wait->timeout_)
return true;
if (o->type_ < type_)
return o->depends(this);
- if (auto* other = dynamic_cast<const BarrierTransition*>(o)) {
+ if (const auto* other = dynamic_cast<const BarrierTransition*>(o)) {
if (bar_ != other->bar_)
return false;
// type_ <= other->type_ in MUTEX_LOCK, MUTEX_TEST, MUTEX_TRYLOCK, MUTEX_UNLOCK, MUTEX_WAIT,
- if (auto* other = dynamic_cast<const MutexTransition*>(o)) {
+ if (const auto* other = dynamic_cast<const MutexTransition*>(o)) {
// Theorem 4.4.7: Any pair of synchronization actions of distinct actors concerning distinct mutexes are independent
if (mutex_ != other->mutex_)
return false;
if (o->type_ < type_)
return o->depends(this);
- if (auto* other = dynamic_cast<const SemaphoreTransition*>(o)) {
+ if (const auto* other = dynamic_cast<const SemaphoreTransition*>(o)) {
if (sem_ != other->sem_)
return false;
static void sg_chaos_monkey_plugin_run()
{
- auto engine = sg4::Engine::get_instance();
+ auto* engine = sg4::Engine::get_instance();
auto hosts = engine->get_all_hosts();
auto links = engine->get_all_links();
* (because the user changed the pstate, or because of external trace events) ("onSpeedChange") */
static void on_host_change(simgrid::s4u::Host const& h)
{
- auto* host = &h;
+ const auto* host = &h;
if (const auto* vm = dynamic_cast<simgrid::s4u::VirtualMachine const*>(host)) // Take the PM of virtual machines
host = vm->get_pm();
static void on_activity_suspend_resume(simgrid::s4u::Activity const& activity)
{
- if (auto* action = dynamic_cast<simgrid::kernel::resource::CpuAction*>(activity.get_impl()->model_action_);
- action != nullptr)
+ if (const auto* action = dynamic_cast<simgrid::kernel::resource::CpuAction*>(activity.get_impl()->model_action_))
on_action_state_change(*action, /*ignored*/ action->get_state());
}
double sg_host_get_consumed_energy(const_sg_host_t host)
{
ensure_plugin_inited();
- auto host_energy = host->extension<HostEnergy>();
+ auto* host_energy = host->extension<HostEnergy>();
xbt_assert(host_energy->has_pstate_power_values(), "No power range properties specified for host %s",
host->get_cname());
return host_energy->get_consumed_energy();
double sg_host_get_current_consumption(const_sg_host_t host)
{
ensure_plugin_inited();
- auto host_energy = host->extension<HostEnergy>();
+ auto* host_energy = host->extension<HostEnergy>();
xbt_assert(host_energy->has_pstate_power_values(), "No power range properties specified for host %s",
host->get_cname());
return host_energy->get_current_watts_value();
// This loop updates the flops that the host executed for the ongoing computations
auto iter = begin(current_activities);
while (iter != end(current_activities)) {
- auto& activity = iter->first; // Just an alias
+ const auto& activity = iter->first; // Just an alias
auto& remaining_cost_after_last_update = iter->second; // Just an alias
auto& action = activity->model_action_;
auto current_iter = iter;
static void on_communication(const simgrid::s4u::Comm& comm)
{
- auto* pimpl = static_cast<simgrid::kernel::activity::CommImpl*>(comm.get_impl());
+ const auto* pimpl = static_cast<simgrid::kernel::activity::CommImpl*>(comm.get_impl());
for (auto const* link : pimpl->get_traversed_links()) {
if (link != nullptr && link->get_sharing_policy() != simgrid::s4u::Link::SharingPolicy::WIFI) {
XBT_DEBUG("Update %s on Comm Start/End", link->get_cname());
/* **************************** events callback *************************** */
static void on_communication(const simgrid::s4u::Comm& comm)
{
- auto* pimpl = static_cast<simgrid::kernel::activity::CommImpl*>(comm.get_impl());
+ const auto* pimpl = static_cast<simgrid::kernel::activity::CommImpl*>(comm.get_impl());
for (auto const* link : pimpl->get_traversed_links()) {
if (link != nullptr && link->get_sharing_policy() == simgrid::s4u::Link::SharingPolicy::WIFI) {
auto* link_energy = link->extension<LinkEnergyWifi>();
/* **************************** events callback *************************** */
static void on_communication(const simgrid::s4u::Comm& comm)
{
- auto* pimpl = static_cast<simgrid::kernel::activity::CommImpl*>(comm.get_impl());
+ const auto* pimpl = static_cast<simgrid::kernel::activity::CommImpl*>(comm.get_impl());
for (auto const* link : pimpl->get_traversed_links()) {
if (link != nullptr && link->get_sharing_policy() != simgrid::s4u::Link::SharingPolicy::WIFI) {
auto* link_load = link->extension<LinkLoad>();
simgrid::s4u::Link::on_onoff_cb([](simgrid::s4u::Link const& link) {
if (link.get_sharing_policy() != simgrid::s4u::Link::SharingPolicy::WIFI) {
- auto link_load = link.extension<LinkLoad>();
+ auto* link_load = link.extension<LinkLoad>();
if (link_load->is_tracked())
link_load->update();
}
simgrid::kernel::resource::Action::State /* previous */) {
for (auto const* link : action.get_links()) {
if (link != nullptr && link->get_sharing_policy() != simgrid::s4u::Link::SharingPolicy::WIFI) {
- auto link_load = link->get_iface()->extension<LinkLoad>();
+ auto* link_load = link->get_iface()->extension<LinkLoad>();
if (link_load->is_tracked())
link_load->update();
}
static void on_exec_creation(simgrid::s4u::Exec const& e)
{
- auto exec = static_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
+ auto* exec = static_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
if (vm == nullptr)
return;
void Comm::wait_all(const std::vector<CommPtr>& comms)
{
// TODO: this should be a simcall or something
- for (auto& comm : comms)
+ for (const auto& comm : comms)
comm->wait();
}
Engine* Engine::get_instance(int* argc, char** argv)
{
if (Engine::instance_ == nullptr) {
- auto e = new Engine(argc, argv);
+ auto* e = new Engine(argc, argv);
xbt_assert(Engine::instance_ == e);
}
return Engine::instance_;
kernel::routing::NetPoint* Engine::netpoint_by_name(const std::string& name) const
{
- auto netp = netpoint_by_name_or_null(name);
+ auto* netp = netpoint_by_name_or_null(name);
if (netp == nullptr) {
throw std::invalid_argument("Netpoint not found: " + name);
}
std::vector<NetZone*> NetZone::get_children() const
{
std::vector<NetZone*> res;
- for (auto child : pimpl_->get_children())
+ for (auto* child : pimpl_->get_children())
res.push_back(child->get_iface());
return res;
}
smpi_bench_end();
CHECK_COMM(1)
XBT_WARN("MPI_Abort was called, something went probably wrong in this simulation ! Killing all processes sharing the same MPI_COMM_WORLD");
- auto myself = simgrid::kernel::actor::ActorImpl::self();
+ auto* myself = simgrid::kernel::actor::ActorImpl::self();
for (int i = 0; i < comm->size(); i++){
- auto actor = simgrid::kernel::EngineImpl::get_instance()->get_actor_by_pid(comm->group()->actor(i));
+ auto* actor = simgrid::kernel::EngineImpl::get_instance()->get_actor_by_pid(comm->group()->actor(i));
if (actor != nullptr && actor != myself)
simgrid::kernel::actor::simcall_answered([actor] { actor->exit(); });
}
if (not TRACE_smpi_is_enabled())
return;
- auto self = simgrid::s4u::Actor::self();
+ auto* self = simgrid::s4u::Actor::self();
TRACE_smpi_setup_container(pid, sg_host_self());
simgrid::s4u::this_actor::on_exit([self](bool) { smpi_container(self->get_pid())->remove_from_parent(); });
static void smpi_get_executable_global_size()
{
- auto* binary_name = simgrid::kernel::EngineImpl::get_instance()->get_cmdline().front().c_str();
+ const auto* binary_name = simgrid::kernel::EngineImpl::get_instance()->get_cmdline().front().c_str();
char* buffer = realpath(binary_name, nullptr);
xbt_assert(buffer != nullptr, "Could not resolve real path of binary file '%s'", binary_name);
std::string full_name = buffer;
while (i < n && __asan_address_is_poisoned(psrc + i))
++i;
if (i < n) {
- char* p = static_cast<char*>(__asan_region_is_poisoned(psrc + i, n - i));
+ const char* p = static_cast<char*>(__asan_region_is_poisoned(psrc + i, n - i));
size_t j = p ? (p - psrc) : n;
memcpy(pdest + i, psrc + i, j - i);
i = j;
{
for (auto const& [_, reqs] : store) {
aid_t my_proc_id = simgrid::s4u::this_actor::get_pid();
- for (auto& req: reqs){
+ for (const auto& req : reqs) {
if (req != MPI_REQUEST_NULL && (req->src() == my_proc_id || req->dst() == my_proc_id)) {
vec.push_back(req);
req->print_request("MM");
unsigned int i=0;
for (auto const& [_, reqs] : storage[simgrid::s4u::this_actor::get_pid()].get_store()) {
- for (auto& req : reqs) {
+ for (const auto& req : reqs) {
requests[i] = req; // FIXME: overwritten at each iteration?
}
i++;
bool Request::match_recv(void* a, void* b, simgrid::kernel::activity::CommImpl*)
{
- auto ref = static_cast<MPI_Request>(a);
- auto req = static_cast<MPI_Request>(b);
+ auto* ref = static_cast<MPI_Request>(a);
+ auto* req = static_cast<MPI_Request>(b);
bool match = match_common(req, req, ref);
if (not match || ref->comm_ == MPI_COMM_UNINITIALIZED || ref->comm_->is_smp_comm())
return match;
bool Request::match_send(void* a, void* b, simgrid::kernel::activity::CommImpl*)
{
- auto ref = static_cast<MPI_Request>(a);
- auto req = static_cast<MPI_Request>(b);
+ auto* ref = static_cast<MPI_Request>(a);
+ auto* req = static_cast<MPI_Request>(b);
return match_common(req, ref, req);
}
MPI_Request Request::ibsend(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
{
- auto request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
- dst != MPI_PROC_NULL ? comm->group()->actor(dst) : MPI_PROC_NULL, tag, comm,
- MPI_REQ_NON_PERSISTENT | MPI_REQ_ISEND | MPI_REQ_SEND | MPI_REQ_BSEND);
+ auto* request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
+ dst != MPI_PROC_NULL ? comm->group()->actor(dst) : MPI_PROC_NULL, tag, comm,
+ MPI_REQ_NON_PERSISTENT | MPI_REQ_ISEND | MPI_REQ_SEND | MPI_REQ_BSEND);
if(dst != MPI_PROC_NULL)
request->start();
return request;
MPI_Request Request::isend(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
{
- auto request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
- dst != MPI_PROC_NULL ? comm->group()->actor(dst) : MPI_PROC_NULL, tag, comm,
- MPI_REQ_NON_PERSISTENT | MPI_REQ_ISEND | MPI_REQ_SEND);
+ auto* request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
+ dst != MPI_PROC_NULL ? comm->group()->actor(dst) : MPI_PROC_NULL, tag, comm,
+ MPI_REQ_NON_PERSISTENT | MPI_REQ_ISEND | MPI_REQ_SEND);
if(dst != MPI_PROC_NULL)
request->start();
return request;
MPI_Request Request::issend(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
{
- auto request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
- dst != MPI_PROC_NULL ? comm->group()->actor(dst) : MPI_PROC_NULL, tag, comm,
- MPI_REQ_NON_PERSISTENT | MPI_REQ_ISEND | MPI_REQ_SSEND | MPI_REQ_SEND);
+ auto* request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
+ dst != MPI_PROC_NULL ? comm->group()->actor(dst) : MPI_PROC_NULL, tag, comm,
+ MPI_REQ_NON_PERSISTENT | MPI_REQ_ISEND | MPI_REQ_SSEND | MPI_REQ_SEND);
if(dst != MPI_PROC_NULL)
request->start();
return request;
source = MPI_ANY_SOURCE;
else if (src != MPI_PROC_NULL)
source = comm->group()->actor(src);
- auto request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, source,
- simgrid::s4u::this_actor::get_pid(), tag, comm, MPI_REQ_NON_PERSISTENT | MPI_REQ_RECV);
+ auto* request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, source,
+ simgrid::s4u::this_actor::get_pid(), tag, comm, MPI_REQ_NON_PERSISTENT | MPI_REQ_RECV);
if(src != MPI_PROC_NULL)
request->start();
return request;
void Request::bsend(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
{
- auto request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
- dst != MPI_PROC_NULL ? comm->group()->actor(dst) : MPI_PROC_NULL, tag, comm,
- MPI_REQ_NON_PERSISTENT | MPI_REQ_SEND | MPI_REQ_BSEND);
+ auto* request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
+ dst != MPI_PROC_NULL ? comm->group()->actor(dst) : MPI_PROC_NULL, tag, comm,
+ MPI_REQ_NON_PERSISTENT | MPI_REQ_SEND | MPI_REQ_BSEND);
if(dst != MPI_PROC_NULL)
request->start();
void Request::send(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
{
- auto request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
- dst != MPI_PROC_NULL ? comm->group()->actor(dst) : MPI_PROC_NULL, tag, comm,
- MPI_REQ_NON_PERSISTENT | MPI_REQ_SEND);
+ auto* request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
+ dst != MPI_PROC_NULL ? comm->group()->actor(dst) : MPI_PROC_NULL, tag, comm,
+ MPI_REQ_NON_PERSISTENT | MPI_REQ_SEND);
if(dst != MPI_PROC_NULL)
request->start();
wait(&request, MPI_STATUS_IGNORE);
void Request::ssend(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
{
- auto request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
- dst != MPI_PROC_NULL ? comm->group()->actor(dst) : MPI_PROC_NULL, tag, comm,
- MPI_REQ_NON_PERSISTENT | MPI_REQ_SSEND | MPI_REQ_SEND);
+ auto* request = new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
+ dst != MPI_PROC_NULL ? comm->group()->actor(dst) : MPI_PROC_NULL, tag, comm,
+ MPI_REQ_NON_PERSISTENT | MPI_REQ_SSEND | MPI_REQ_SEND);
if(dst != MPI_PROC_NULL)
request->start();
static int nsleeps = 1;
double speed = s4u::this_actor::get_host()->get_speed();
double maxrate = smpi_cfg_iprobe_cpu_usage();
- auto request =
+ auto* request =
new Request(nullptr, 0, MPI_CHAR, source == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->actor(source),
simgrid::s4u::this_actor::get_pid(), tag, comm, MPI_REQ_PERSISTENT | MPI_REQ_RECV | MPI_REQ_PROBE);
if (smpi_iprobe_sleep > 0) {
return 1;
}
- auto properties = simgrid::s4u::Actor::self()->get_properties();
+ const auto* properties = simgrid::s4u::Actor::self()->get_properties();
if (properties->find("smpi_replay") == properties->end()) {
XBT_ERROR("invalid smpireplaymain execution. Please use smpirun -replay instead.");
return 1;
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_cfg);
xbt_log_threshold_set(&_XBT_LOGV(xbt_cfg), xbt_log_priority_critical);
- auto temp = simgrid_config;
+ auto* temp = simgrid_config;
simgrid_config = nullptr;
simgrid::config::declare_flag<int>("speed", "description", 0);
simgrid::config::alias("speed", {"velocity"});
try {
std::string name = boost::core::demangle(typeid(exception).name());
- auto* with_context = dynamic_cast<const simgrid::Exception*>(&exception);
+ const auto* with_context = dynamic_cast<const simgrid::Exception*>(&exception);
if (with_context != nullptr) {
XBT_LOG(prio, "%s %s by %s/%ld: %s", context, name.c_str(), with_context->throw_point().procname_.c_str(),
with_context->throw_point().pid_, exception.what());
try {
// Do we have a nested exception?
- auto* with_nested = dynamic_cast<const std::nested_exception*>(&exception);
+ const auto* with_nested = dynamic_cast<const std::nested_exception*>(&exception);
if (with_nested != nullptr && with_nested->nested_ptr() != nullptr)
with_nested->rethrow_nested();
} catch (const std::exception& nested_exception) {
/** @brief Main function of a worker thread */
template <typename T> void Parmap<T>::worker_main(ThreadData* data)
{
- auto engine = simgrid::kernel::EngineImpl::get_instance();
+ const auto* engine = simgrid::kernel::EngineImpl::get_instance();
Parmap<T>& parmap = data->parmap;
unsigned round = 0;
kernel::context::Context* context = engine->get_context_factory()->create_context(std::function<void()>(), nullptr);
SECTION("Each element of each subset is distinct")
{
for (unsigned k = 0; static_cast<size_t>(k) < example_vec.size(); k++) {
- for (auto& subset : make_k_subsets_iter(k, example_vec)) {
+ for (const auto& subset : make_k_subsets_iter(k, example_vec)) {
// Each subset must have size `k`
REQUIRE(subset.size() == k);
std::unordered_map<int, int> element_counts(k);
- for (auto& subset : make_powerset_iter(example_vec)) {
+ for (const auto& subset : make_powerset_iter(example_vec)) {
// Each subset must be comprised only of distinct elements
std::unordered_set<int> elements_seen(k);
for (const auto& element_ptr : subset) {
return variable;
}
-static simgrid::mc::Member* find_member(simgrid::mc::Type& type, const char* name)
+static const simgrid::mc::Member* find_member(const simgrid::mc::Type& type, const char* name)
{
- for (simgrid::mc::Member& member : type.members)
+ for (const simgrid::mc::Member& member : type.members)
if(member.name == name)
return &member;
return nullptr;
static int receiver(const char* box_name)
{
- auto mb = simgrid::s4u::Mailbox::by_name(box_name);
+ auto* mb = simgrid::s4u::Mailbox::by_name(box_name);
std::unique_ptr<int> payload;
payload = mb->get_unique<int>();
static int sender(const char* box_name, simgrid::s4u::MutexPtr mutex, int value)
{
auto* payload = new int(value);
- auto mb = simgrid::s4u::Mailbox::by_name(box_name);
+ auto* mb = simgrid::s4u::Mailbox::by_name(box_name);
std::unique_lock<simgrid::s4u::Mutex> lock;
if (mutex)
});
simgrid::s4u::this_actor::yield();
- auto link = simgrid::s4u::Engine::get_instance()->link_by_name("link1");
+ auto* link = simgrid::s4u::Engine::get_instance()->link_by_name("link1");
link->turn_off();
link->turn_on();
});
simgrid::s4u::this_actor::sleep_for(2);
- auto link = simgrid::s4u::Engine::get_instance()->link_by_name("link1");
+ auto* link = simgrid::s4u::Engine::get_instance()->link_by_name("link1");
link->turn_off();
link->turn_on();
simgrid::s4u::Actor::create("killer", all_hosts[0], []() {
simgrid::s4u::this_actor::sleep_for(5);
XBT_VERB("Killer!");
- auto link = simgrid::s4u::Engine::get_instance()->link_by_name("link1");
+ auto* link = simgrid::s4u::Engine::get_instance()->link_by_name("link1");
link->turn_off();
link->turn_on();
});
void operator()() const
{
XBT_INFO("Starting.");
- auto mailbox = simgrid::s4u::Mailbox::by_name("receiver");
+ auto* mailbox = simgrid::s4u::Mailbox::by_name("receiver");
int data = *mailbox->get<int>();
XBT_INFO("Got %d at the end", data);
}
simgrid::s4u::this_actor::sleep_for(10);
XBT_INFO("Sending a message to the receiver...");
- auto mailbox = simgrid::s4u::Mailbox::by_name("receiver");
+ auto* mailbox = simgrid::s4u::Mailbox::by_name("receiver");
static int data = 42;
mailbox->put(&data, 4);
simgrid::s4u::Engine e(&argc, argv);
e.load_platform(argv[1]);
- auto host = e.host_by_name("cpu0");
+ auto* host = e.host_by_name("cpu0");
/* creation of the tasks and their dependencies */
simgrid::s4u::ExecPtr Init = simgrid::s4u::Exec::init()->set_name("Init")->set_flops_amount(0)->start();
simgrid::s4u::CommPtr A = simgrid::s4u::Comm::sendto_init()->set_name("A")->set_payload_size(1e9)->start();
{
XBT_INFO(" Start RX");
try {
- auto payload = simgrid::s4u::Mailbox::by_name("comm")->get<std::string>();
+ auto* payload = simgrid::s4u::Mailbox::by_name("comm")->get<std::string>();
XBT_INFO(" Receive message: %s", payload->c_str());
} catch (const simgrid::HostFailureException&) {
XBT_INFO(" Receive message: HOST_FAILURE");
static void runner()
{
- auto e = simgrid::s4u::Engine::get_instance();
+ auto* e = simgrid::s4u::Engine::get_instance();
simgrid::s4u::Host* host0 = e->host_by_name("c1_0");
simgrid::s4u::Host* host1 = e->host_by_name("c2_0");
for (const auto* host : hosts_) {
auto* payload = new std::string(msg_content);
/* Create a communication representing the ongoing communication, and store it in pending_comms */
- auto mbox = sg4::Mailbox::by_name(host->get_name());
+ auto* mbox = sg4::Mailbox::by_name(host->get_name());
mboxes.push_back(mbox);
sg4::CommPtr comm = mbox->put_async(payload, msg_size);
pending_comms.push_back(comm);
public:
void operator()() const
{
- auto mbox = sg4::Mailbox::by_name(sg4::this_actor::get_host()->get_name());
+ auto* mbox = sg4::Mailbox::by_name(sg4::this_actor::get_host()->get_name());
auto received = mbox->get_unique<std::string>();
XBT_INFO("I got a '%s'.", received->c_str());
static void worker()
{
- auto mbox = simgrid::s4u::Mailbox::by_name("meh");
+ auto* mbox = simgrid::s4u::Mailbox::by_name("meh");
int input1 = 42;
int input2 = 51;
static void worker()
{
- auto mbox = simgrid::s4u::Mailbox::by_name("meh");
+ auto* mbox = simgrid::s4u::Mailbox::by_name("meh");
int input1 = 42;
int input2 = 51;