From: Martin Quinson Date: Wed, 28 Jun 2023 12:32:48 +0000 (+0200) Subject: Merge branch 'master' of framagit.org:simgrid/simgrid X-Git-Tag: v3.35~178 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7ddc46fcc39e6327b6dc919a3bcf25524f735d74?hp=76ed29c06c92ad1a55ed1e781accca864e14f047 Merge branch 'master' of framagit.org:simgrid/simgrid --- diff --git a/MANIFEST.in b/MANIFEST.in index 76abec2d71..f6767fe96c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -484,6 +484,8 @@ include examples/python/platform-failures/platform-failures.py include examples/python/platform-failures/platform-failures.tesh include examples/python/platform-profile/platform-profile.py include examples/python/platform-profile/platform-profile.tesh +include examples/python/plugin-host-load/plugin-host-load.py +include examples/python/plugin-host-load/plugin-host-load.tesh include examples/python/synchro-barrier/synchro-barrier.py include examples/python/synchro-barrier/synchro-barrier.tesh include examples/python/synchro-mutex/synchro-mutex.py @@ -1966,7 +1968,6 @@ include include/simgrid/s4u/Semaphore.hpp include include/simgrid/s4u/Task.hpp include include/simgrid/s4u/VirtualMachine.hpp include include/simgrid/semaphore.h -include include/simgrid/simix.h include include/simgrid/simix.hpp include include/simgrid/version.h.in include include/simgrid/vm.h @@ -2025,7 +2026,6 @@ include src/dag/dax.dtd include src/dag/dax_dtd.c include src/dag/dax_dtd.h include src/dag/loaders.cpp -include src/deprecated.cpp include src/instr/instr_config.cpp include src/instr/instr_interface.cpp include src/instr/instr_paje_containers.cpp diff --git a/docs/source/Doxyfile b/docs/source/Doxyfile index 7237a505fb..4f745520a3 100644 --- a/docs/source/Doxyfile +++ b/docs/source/Doxyfile @@ -66,6 +66,6 @@ PREDEFINED += \ XBT_ATTRIB_NORETURN= \ XBT_ATTRIB_UNUSED= \ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cname,parent,desc)= \ - XBT_ATTRIB_DEPRECATED_v335(mesg)= \ XBT_ATTRIB_DEPRECATED_v336(mesg)= \ - XBT_ATTRIB_DEPRECATED_v338(mesg)= + XBT_ATTRIB_DEPRECATED_v338(mesg)= \ + XBT_ATTRIB_DEPRECATED_v339(mesg)= diff --git a/examples/cpp/task-switch-host/s4u-task-switch-host.cpp b/examples/cpp/task-switch-host/s4u-task-switch-host.cpp index 7023f68b48..eee90e6a4a 100644 --- a/examples/cpp/task-switch-host/s4u-task-switch-host.cpp +++ b/examples/cpp/task-switch-host/s4u-task-switch-host.cpp @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) // Add a function to be called before each firing of comm0 // This function modifies the graph of tasks by adding or removing // successors to comm0 - comm0->on_this_start_cb([comm0, exec1, exec2, jupiter, fafard](sg4::Task*) { + comm0->on_this_start_cb([comm0, exec1, exec2, jupiter, fafard](const sg4::Task*) { static int count = 0; if (count % 2 == 0) { comm0->set_destination(jupiter); diff --git a/examples/python/CMakeLists.txt b/examples/python/CMakeLists.txt index f4afe5bbd7..555cfc15f6 100644 --- a/examples/python/CMakeLists.txt +++ b/examples/python/CMakeLists.txt @@ -5,6 +5,7 @@ foreach(example actor-create actor-daemon actor-join actor-kill actor-migrate ac exec-async exec-basic exec-dvfs exec-remote exec-ptask task-io task-simple task-switch-host task-variable-load platform-comm-serialize platform-profile platform-failures + plugin-host-load network-nonlinear clusters-multicpu io-degradation exec-cpu-nonlinear synchro-barrier synchro-mutex synchro-semaphore) set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.tesh) diff --git a/examples/python/plugin-host-load/plugin-host-load.py b/examples/python/plugin-host-load/plugin-host-load.py new file mode 100644 index 0000000000..3b6156caa3 --- /dev/null +++ b/examples/python/plugin-host-load/plugin-host-load.py @@ -0,0 +1,86 @@ +# Copyright (c) 2006-2023. 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. + + +from argparse import ArgumentParser +import sys +from simgrid import Engine, Host, this_actor, Actor + +def parse(): + parser = ArgumentParser() + parser.add_argument( + '--platform', + type=str, + required=True, + help='path to the platform description' + ) + return parser.parse_args() + +def execute_load_test(): + host = Host.by_name('MyHost1') + this_actor.info(f'Initial peak speed: {host.speed:.0E} flop/s; number of flops computed so far: {host.computed_flops:.0E} (should be 0) and current average load: {host.avg_load} (should be 0)') + + start = Engine.clock + this_actor.info('Sleep for 10 seconds') + this_actor.sleep_for(10) + + speed = host.speed + this_actor.info(f'Done sleeping {Engine.clock - start}s; peak speed: {host.speed:.0E} flop/s; number of flops computed so far: {host.computed_flops:.0E} (nothing should have changed)') + + # Run an activity + start = e.clock + this_actor.info(f'Run an activity of {200E6:.0E} flops at current speed of {host.speed:.0E} flop/s') + this_actor.execute(200E6) + + this_actor.info(f'Done working on my activity; this took {Engine.clock - start}s; current peak speed: {host.speed:.0E} flop/s (when I started the computation, \ +the speed was set to {speed:.0E} flop/s); number of flops computed so \ +far: {host.computed_flops:.0E}, average load as reported by the HostLoad plugin: {host.avg_load:.5f} (should be {200E6 / (10.5 * speed * host.core_count + (Engine.clock - start - 0.5) * host.speed * host.core_count):.5f})') + + # ========= Change power peak ========= + pstate = 1 + host.pstate = pstate + this_actor.info(f'========= Requesting pstate {pstate} (speed should be of {host.pstate_speed(pstate):.0E} flop/s and is of {host.speed:.0E} flop/s, average load is {host.avg_load:.5f})') + + # Run a second activity + start = Engine.clock + this_actor.info(f'Run an activity of {100E6:.0E} flops') + this_actor.execute(100E6) + this_actor.info(f'Done working on my activity; this took {Engine.clock - start}s; current peak speed: {host.speed:.0E} flop/s; number of flops computed so far: {host.computed_flops:.0E}') + Engine + start = Engine.clock + this_actor.info("========= Requesting a reset of the computation and load counters") + host.reset_load() + this_actor.info(f'After reset: {host.computed_flops:.0E} flops computed; load is {host.avg_load}') + this_actor.info('Sleep for 4 seconds') + this_actor.sleep_for(4) + this_actor.info(f'Done sleeping {Engine.clock - start}s; peak speed: {host.speed:.0E} flop/s; number of flops computed so far: {host.computed_flops:.0E}') + + # =========== Turn the other host off ========== + host2 = Host.by_name('MyHost2') + this_actor.info(f'Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed {host2.computed_flops:.0E} flops so far and has an average load of {host2.avg_load}') + host2.turn_off() + start = Engine.clock + this_actor.sleep_for(10) + this_actor.info(f'Done sleeping {Engine.clock - start}s; peak speed: {host.speed:.0E} flop/s; number of flops computed so far: {host.computed_flops:.0E}') + +def change_speed(): + host = Host.by_name('MyHost1') + this_actor.sleep_for(10.5) + this_actor.info("I slept until now, but now I'll change the speed of this host while the other actor is still computing! This should slow the computation down.") + host.pstate = 2 + +if __name__ == '__main__': + args = parse() + Host.sg_host_load_plugin_init() + e = Engine(sys.argv) + e.load_platform(args.platform) + + Actor.create('load_test', e.host_by_name('MyHost1'), execute_load_test) + Actor.create('change_speed', e.host_by_name('MyHost1'), change_speed) + + e.run() + + this_actor.info(f'Total simulation time: {Engine.clock}') + diff --git a/examples/python/plugin-host-load/plugin-host-load.tesh b/examples/python/plugin-host-load/plugin-host-load.tesh new file mode 100644 index 0000000000..ad14d1915e --- /dev/null +++ b/examples/python/plugin-host-load/plugin-host-load.tesh @@ -0,0 +1,21 @@ +#!/usr/bin/env tesh + +p This tests the Host Load plugin (that allows the user to get the current load of a host and the computed flops) + +$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/plugin-host-load.py --platform ${platfdir}/energy_platform.xml +> [MyHost1:load_test:(1) 0.000000] [python/INFO] Initial peak speed: 1E+08 flop/s; number of flops computed so far: 0E+00 (should be 0) and current average load: 0.0 (should be 0) +> [MyHost1:load_test:(1) 0.000000] [python/INFO] Sleep for 10 seconds +> [MyHost1:load_test:(1) 10.000000] [python/INFO] Done sleeping 10.0s; peak speed: 1E+08 flop/s; number of flops computed so far: 0E+00 (nothing should have changed) +> [MyHost1:load_test:(1) 10.000000] [python/INFO] Run an activity of 2E+08 flops at current speed of 1E+08 flop/s +> [MyHost1:change_speed:(2) 10.500000] [python/INFO] I slept until now, but now I'll change the speed of this host while the other actor is still computing! This should slow the computation down. +> [MyHost1:load_test:(1) 18.000000] [python/INFO] Done working on my activity; this took 8.0s; current peak speed: 2E+07 flop/s (when I started the computation, the speed was set to 1E+08 flop/s); number of flops computed so far: 2E+08, average load as reported by the HostLoad plugin: 0.04167 (should be 0.04167) +> [MyHost1:load_test:(1) 18.000000] [python/INFO] ========= Requesting pstate 1 (speed should be of 5E+07 flop/s and is of 5E+07 flop/s, average load is 0.04167) +> [MyHost1:load_test:(1) 18.000000] [python/INFO] Run an activity of 1E+08 flops +> [MyHost1:load_test:(1) 20.000000] [python/INFO] Done working on my activity; this took 2.0s; current peak speed: 5E+07 flop/s; number of flops computed so far: 3E+08 +> [MyHost1:load_test:(1) 20.000000] [python/INFO] ========= Requesting a reset of the computation and load counters +> [MyHost1:load_test:(1) 20.000000] [python/INFO] After reset: 0E+00 flops computed; load is 0.0 +> [MyHost1:load_test:(1) 20.000000] [python/INFO] Sleep for 4 seconds +> [MyHost1:load_test:(1) 24.000000] [python/INFO] Done sleeping 4.0s; peak speed: 5E+07 flop/s; number of flops computed so far: 0E+00 +> [MyHost1:load_test:(1) 24.000000] [python/INFO] Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed 0E+00 flops so far and has an average load of 0.0 +> [MyHost1:load_test:(1) 34.000000] [python/INFO] Done sleeping 10.0s; peak speed: 5E+07 flop/s; number of flops computed so far: 0E+00 +> [34.000000] [python/INFO] Total simulation time: 34.0 diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index f39ff67466..07e7cbcb52 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -229,19 +229,7 @@ using s4u_Disk = simgrid::s4u::Disk; using s4u_NetZone = simgrid::s4u::NetZone; using s4u_VM = simgrid::s4u::VirtualMachine; -using smx_timer_t - XBT_ATTRIB_DEPRECATED_v335("Please use simgrid::kernel::timer::Timer*") = simgrid::kernel::timer::Timer*; -using smx_actor_t - XBT_ATTRIB_DEPRECATED_v335("Please use simgrid::kernel::actor::ActorImpl*") = simgrid::kernel::actor::ActorImpl*; using smx_activity_t = simgrid::kernel::activity::ActivityImpl*; -using smx_cond_t XBT_ATTRIB_DEPRECATED_v335("Please use simgrid::kernel::activity::ConditionVariableImpl*") = - simgrid::kernel::activity::ConditionVariableImpl*; -using smx_mailbox_t XBT_ATTRIB_DEPRECATED_v335("Please use simgrid::kernel::activity::MailboxImpl*") = - simgrid::kernel::activity::MailboxImpl*; -using smx_mutex_t XBT_ATTRIB_DEPRECATED_v335("Please use simgrid::kernel::activity::MutexImpl*") = - simgrid::kernel::activity::MutexImpl*; -using smx_sem_t XBT_ATTRIB_DEPRECATED_v335("Please use simgrid::kernel::activity::SemaphoreImpl*") = - simgrid::kernel::activity::SemaphoreImpl*; #else typedef struct s4u_Actor s4u_Actor; @@ -259,22 +247,13 @@ typedef struct s4u_Disk s4u_Disk; typedef struct s4u_NetZone s4u_NetZone; typedef struct s4u_VM s4u_VM; -XBT_ATTRIB_DEPRECATED_v335("Please stop using this type alias") typedef struct s_smx_timer* smx_timer_t; -XBT_ATTRIB_DEPRECATED_v335("Please stop using this type alias") typedef struct s_smx_actor* smx_actor_t; typedef struct s_smx_activity* smx_activity_t; -XBT_ATTRIB_DEPRECATED_v335("Please stop using this type alias") typedef struct s_smx_cond_t* smx_cond_t; -XBT_ATTRIB_DEPRECATED_v335("Please stop using this type alias") typedef struct s_smx_mailbox* smx_mailbox_t; -XBT_ATTRIB_DEPRECATED_v335("Please stop using this type alias") typedef struct s_smx_mutex* smx_mutex_t; -XBT_ATTRIB_DEPRECATED_v335("Please stop using this type alias") typedef struct s_smx_sem* smx_sem_t; #endif /** Pointer to a SimGrid barrier object */ typedef s4u_Barrier* sg_bar_t; -/** Constant pointer to a SimGrid barrier object */ -XBT_ATTRIB_DEPRECATED_v335("Please stop using this type alias") typedef const s4u_Barrier* const_sg_bar_t; typedef s4u_Comm* sg_comm_t; -XBT_ATTRIB_DEPRECATED_v335("Please stop using this type alias") typedef const s4u_Comm* const_sg_comm_t; typedef s4u_Exec* sg_exec_t; typedef const s4u_Exec* const_sg_exec_t; typedef s4u_ConditionVariable* sg_cond_t; diff --git a/include/simgrid/host.h b/include/simgrid/host.h index e828dced4f..57c0a94f0c 100644 --- a/include/simgrid/host.h +++ b/include/simgrid/host.h @@ -115,9 +115,6 @@ XBT_PUBLIC double sg_host_get_route_latency(const_sg_host_t from, const_sg_host_ XBT_PUBLIC double sg_host_get_route_bandwidth(const_sg_host_t from, const_sg_host_t to); XBT_PUBLIC void sg_host_sendto(sg_host_t from, sg_host_t to, double byte_amount); -XBT_ATTRIB_DEPRECATED_v335("Please manifest if you actually need this function") XBT_PUBLIC - void sg_host_dump(const_sg_host_t ws); - XBT_PUBLIC void sg_host_get_actor_list(const_sg_host_t host, xbt_dynar_t whereto); SG_END_DECL diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index 46f7ae204c..d92987dfa5 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -40,9 +40,6 @@ public: ~Engine(); #endif - /** Finalize the default engine and all its dependencies */ - XBT_ATTRIB_DEPRECATED_v335("Users are not supposed to shutdown the Engine") void shutdown(); - /** Run the simulation until its end */ void run() const; diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h deleted file mode 100644 index aa70ca6b87..0000000000 --- a/include/simgrid/simix.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (c) 2007-2023. 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 SIMGRID_SIMIX_H -#define SIMGRID_SIMIX_H - -#include - -// avoid deprecation warning on include (remove entire file with XBT_ATTRIB_DEPRECATED_v335) -#ifndef SIMIX_H_NO_DEPRECATED_WARNING -#warning simgrid/simix.h is deprecated and will be removed in v3.35. -#endif - -#ifdef __cplusplus - -/******************************************************************************/ -/* SIMIX simcalls */ -/******************************************************************************/ -/* These functions are a system call-like interface to the simulation kernel. */ -/* They can also be called from maestro's context, and they are thread safe. */ -/******************************************************************************/ - -/************************** Communication simcalls ****************************/ - -XBT_ATTRIB_DEPRECATED_v335("Please use s4u::Comm::send()") XBT_PUBLIC - void simcall_comm_send(simgrid::kernel::actor::ActorImpl* sender, simgrid::kernel::activity::MailboxImpl* mbox, - double task_size, double rate, void* src_buff, size_t src_buff_size, - bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), - void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data, - double timeout); - -XBT_ATTRIB_DEPRECATED_v335("Please use s4u::Comm::isend()") XBT_PUBLIC simgrid::kernel::activity::ActivityImplPtr - simcall_comm_isend(simgrid::kernel::actor::ActorImpl* sender, simgrid::kernel::activity::MailboxImpl* mbox, - double task_size, double rate, void* src_buff, size_t src_buff_size, - bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void (*clean_fun)(void*), - void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data, - bool detached); - -XBT_ATTRIB_DEPRECATED_v335("Please use s4u::Comm::recv()") XBT_PUBLIC - void simcall_comm_recv(simgrid::kernel::actor::ActorImpl* receiver, simgrid::kernel::activity::MailboxImpl* mbox, - void* dst_buff, size_t* dst_buff_size, - bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), - void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data, - double timeout, double rate); - -XBT_ATTRIB_DEPRECATED_v335("Please use s4u::Comm::irecv()") XBT_PUBLIC simgrid::kernel::activity::ActivityImplPtr - simcall_comm_irecv(simgrid::kernel::actor::ActorImpl* receiver, simgrid::kernel::activity::MailboxImpl* mbox, - void* dst_buff, size_t* dst_buff_size, - bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), - void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data, - double rate); - -XBT_ATTRIB_DEPRECATED_v335("Please use s4u::Comm::wait_any_for()") XBT_PUBLIC ssize_t - simcall_comm_waitany(simgrid::kernel::activity::CommImpl* comms[], size_t count, double timeout); -XBT_ATTRIB_DEPRECATED_v335("Please use s4u::Comm::wait_for()") XBT_PUBLIC - void simcall_comm_wait(simgrid::kernel::activity::ActivityImpl* comm, double timeout); -XBT_ATTRIB_DEPRECATED_v335("Please use s4u::Comm::test()") XBT_PUBLIC - bool simcall_comm_test(simgrid::kernel::activity::ActivityImpl* comm); -XBT_ATTRIB_DEPRECATED_v335("Please use s4u::Comm::test_any()") XBT_PUBLIC ssize_t - simcall_comm_testany(simgrid::kernel::activity::CommImpl* comms[], size_t count); - -#endif -#endif diff --git a/include/xbt/base.h b/include/xbt/base.h index e17f19da91..a4c062d80e 100644 --- a/include/xbt/base.h +++ b/include/xbt/base.h @@ -42,12 +42,12 @@ #define XBT_ATTRIB_DEPRECATED(mesg) __attribute__((deprecated(mesg))) #endif -#define XBT_ATTRIB_DEPRECATED_v335(mesg) \ - XBT_ATTRIB_DEPRECATED(mesg " (this compatibility wrapper will be dropped after v3.34)") #define XBT_ATTRIB_DEPRECATED_v336(mesg) \ XBT_ATTRIB_DEPRECATED(mesg " (this compatibility wrapper will be dropped after v3.35)") #define XBT_ATTRIB_DEPRECATED_v338(mesg) \ XBT_ATTRIB_DEPRECATED(mesg " (this compatibility wrapper will be dropped after v3.37)") +#define XBT_ATTRIB_DEPRECATED_v339(mesg) \ + XBT_ATTRIB_DEPRECATED(mesg " (this compatibility wrapper will be dropped after v3.38)") /* Work around https://github.com/microsoft/vscode-cpptools/issues/4503 */ #ifdef __INTELLISENSE__ diff --git a/include/xbt/module.h b/include/xbt/module.h index 8d1b027a18..601f7f400b 100644 --- a/include/xbt/module.h +++ b/include/xbt/module.h @@ -8,10 +8,8 @@ #ifndef XBT_MODULE_H #define XBT_MODULE_H -// avoid deprecation warning on include (remove entire file with XBT_ATTRIB_DEPRECATED_v338) -#ifndef XBT_MODULE_H_NO_DEPRECATED_WARNING -#warning xbt/module.h is deprecated and will be removed in v3.37. -#endif +// Deprecation warning on include (remove entire file with XBT_ATTRIB_DEPRECATED_v338) +#warning xbt/module.h is deprecated and will be removed after v3.37. #include #include diff --git a/include/xbt/virtu.h b/include/xbt/virtu.h index 9696e53f4b..53ccfaf1e9 100644 --- a/include/xbt/virtu.h +++ b/include/xbt/virtu.h @@ -11,10 +11,8 @@ #include #include -// avoid deprecation warning on include (remove entire file with XBT_ATTRIB_DEPRECATED_v338) -#ifndef XBT_VIRTU_H_NO_DEPRECATED_WARNING -#warning xbt/virtu.h is deprecated and will be removed in v3.37. -#endif +// Deprecation warning on include (remove entire file with XBT_ATTRIB_DEPRECATED_v338) +#warning xbt/virtu.h is deprecated and will be removed after v3.37. SG_BEGIN_DECL diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index 9f0c715caf..fc4d8d22b4 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -365,6 +365,8 @@ PYBIND11_MODULE(simgrid, m) py::overload_cast(&Host::create_disk), py::call_guard(), "Create a disk") .def("seal", &Host::seal, py::call_guard(), "Seal this host") + .def("turn_off", &Host::turn_off, py::call_guard(), "Turn off this host") + .def("turn_on", &Host::turn_on, py::call_guard(), "Turn on this host") .def_property("pstate", &Host::get_pstate, py::cpp_function(&Host::set_pstate, py::call_guard()), "The current pstate (read/write property).") @@ -400,7 +402,24 @@ PYBIND11_MODULE(simgrid, m) "") .def( "__repr__", [](const Host* h) { return "Host(" + h->get_name() + ")"; }, - "Textual representation of the Host"); + "Textual representation of the Host.") + .def_static( + "sg_host_load_plugin_init", []() { sg_host_load_plugin_init(); }, py::call_guard(), + "Initialize host load plugin.") + .def( + "reset_load", [](const Host* h) { sg_host_load_reset(h); }, py::call_guard(), + "Reset counters of the host load plugin for this host.") + .def_property_readonly( + "current_load", [](const Host* h) { return sg_host_get_current_load(h); }, "Current load of the host.") + .def_property_readonly( + "avg_load", [](const Host* h) { return sg_host_get_avg_load(h); }, "Average load of the host.") + .def_property_readonly( + "idle_time", [](const Host* h) { return sg_host_get_idle_time(h); }, "Idle time of the host") + .def_property_readonly( + "total_idle_time", [](const Host* h) { return sg_host_get_total_idle_time(h); }, + "Total idle time of the host.") + .def_property_readonly( + "computed_flops", [](const Host* h) { return sg_host_get_computed_flops(h); }, "Computed flops of the host."); py::enum_(host, "SharingPolicy") .value("NONLINEAR", simgrid::s4u::Host::SharingPolicy::NONLINEAR) diff --git a/src/dag/loaders.cpp b/src/dag/loaders.cpp index 218aa71b36..8520de548e 100644 --- a/src/dag/loaders.cpp +++ b/src/dag/loaders.cpp @@ -156,7 +156,7 @@ std::vector create_DAG_from_json(const std::string& filename) // Start only Activities with dependencies solved for (auto const& activity: dag) { - if (dynamic_cast(activity.get()) != nullptr and activity->dependencies_solved()) + if (dynamic_cast(activity.get()) != nullptr && activity->dependencies_solved()) activity->start(); } return dag; diff --git a/src/deprecated.cpp b/src/deprecated.cpp deleted file mode 100644 index 0881f549b8..0000000000 --- a/src/deprecated.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* This file only contains deprecated code, and will die with v3.25 */ - -/* Copyright (c) 2010-2023. 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/config.h" -#include "simgrid/modelchecker.h" -#include "src/kernel/EngineImpl.hpp" -#include "src/kernel/activity/CommImpl.hpp" -#include "src/kernel/actor/SimcallObserver.hpp" -#include "src/mc/mc_replay.hpp" -#include - -#define SIMIX_H_NO_DEPRECATED_WARNING // avoid deprecation warning on include (remove with XBT_ATTRIB_DEPRECATED_v335) -#include - -#include - -void simcall_comm_send(simgrid::kernel::actor::ActorImpl* sender, simgrid::kernel::activity::MailboxImpl* mbox, - double task_size, double rate, void* src_buff, size_t src_buff_size, - bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), - void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data, - double timeout) // XBT_ATTRIB_DEPRECATED_v335 -{ - xbt_assert(mbox, "No rendez-vous point defined for send"); - simgrid::s4u::Comm::send(sender, mbox->get_iface(), task_size, rate, src_buff, src_buff_size, match_fun, - copy_data_fun, data, timeout); -} - -simgrid::kernel::activity::ActivityImplPtr -simcall_comm_isend(simgrid::kernel::actor::ActorImpl* sender, simgrid::kernel::activity::MailboxImpl* mbox, - double task_size, double rate, void* src_buff, size_t src_buff_size, - bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void (*clean_fun)(void*), - void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data, - bool detached) // XBT_ATTRIB_DEPRECATED_v335 -{ - /* checking for infinite values */ - xbt_assert(std::isfinite(task_size), "task_size is not finite!"); - xbt_assert(std::isfinite(rate), "rate is not finite!"); - - xbt_assert(mbox, "No rendez-vous point defined for isend"); - - simgrid::kernel::actor::CommIsendSimcall observer(sender, mbox, task_size, rate, - static_cast(src_buff), src_buff_size, match_fun, - clean_fun, copy_data_fun, data, detached); - return simgrid::kernel::actor::simcall_answered( - [&observer] { return simgrid::kernel::activity::CommImpl::isend(&observer); }); -} - -void simcall_comm_recv(simgrid::kernel::actor::ActorImpl* receiver, simgrid::kernel::activity::MailboxImpl* mbox, - void* dst_buff, size_t* dst_buff_size, - bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), - void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data, - double timeout, double rate) // XBT_ATTRIB_DEPRECATED_v335 -{ - xbt_assert(mbox, "No rendez-vous point defined for recv"); - simgrid::s4u::Comm::recv(receiver, mbox->get_iface(), dst_buff, dst_buff_size, match_fun, copy_data_fun, data, - timeout, rate); -} - -simgrid::kernel::activity::ActivityImplPtr -simcall_comm_irecv(simgrid::kernel::actor::ActorImpl* receiver, simgrid::kernel::activity::MailboxImpl* mbox, - void* dst_buff, size_t* dst_buff_size, - bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), - void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data, - double rate) // XBT_ATTRIB_DEPRECATED_v335 -{ - xbt_assert(mbox, "No rendez-vous point defined for irecv"); - - simgrid::kernel::actor::CommIrecvSimcall observer(receiver, mbox, static_cast(dst_buff), - dst_buff_size, match_fun, copy_data_fun, data, rate); - return simgrid::kernel::actor::simcall_answered( - [&observer] { return simgrid::kernel::activity::CommImpl::irecv(&observer); }); -} - -ssize_t simcall_comm_waitany(simgrid::kernel::activity::CommImpl* comms[], size_t count, - double timeout) // XBT_ATTRIB_DEPRECATED_v335 -{ - std::vector activities; - for (size_t i = 0; i < count; i++) - activities.push_back(static_cast(comms[i])); - simgrid::kernel::actor::ActorImpl* issuer = simgrid::kernel::actor::ActorImpl::self(); - simgrid::kernel::actor::ActivityWaitanySimcall observer{issuer, activities, timeout}; - ssize_t changed_pos = simgrid::kernel::actor::simcall_blocking( - [&observer] { - simgrid::kernel::activity::ActivityImpl::wait_any_for(observer.get_issuer(), observer.get_activities(), - observer.get_timeout()); - }, - &observer); - if (changed_pos != -1) - activities.at(changed_pos)->get_iface()->complete(simgrid::s4u::Activity::State::FINISHED); - return changed_pos; -} - -ssize_t simcall_comm_testany(simgrid::kernel::activity::CommImpl* comms[], size_t count) // XBT_ATTRIB_DEPRECATED_v335 -{ - if (count == 0) - return -1; - std::vector activities; - for (size_t i = 0; i < count; i++) - activities.push_back(static_cast(comms[i])); - - simgrid::kernel::actor::ActorImpl* issuer = simgrid::kernel::actor::ActorImpl::self(); - simgrid::kernel::actor::ActivityTestanySimcall observer{issuer, activities}; - ssize_t changed_pos = simgrid::kernel::actor::simcall_blocking( - [&observer] { - simgrid::kernel::activity::ActivityImpl::test_any(observer.get_issuer(), observer.get_activities()); - }, - &observer); - if (changed_pos != -1) - comms[changed_pos]->get_iface()->complete(simgrid::s4u::Activity::State::FINISHED); - return changed_pos; -} - -void simcall_comm_wait(simgrid::kernel::activity::ActivityImpl* comm, double timeout) // XBT_ATTRIB_DEPRECATED_v335 -{ - xbt_assert(std::isfinite(timeout), "timeout is not finite!"); - simgrid::kernel::actor::ActorImpl* issuer = simgrid::kernel::actor::ActorImpl::self(); - simgrid::kernel::actor::simcall_blocking([issuer, comm, timeout] { comm->wait_for(issuer, timeout); }); -} - -bool simcall_comm_test(simgrid::kernel::activity::ActivityImpl* comm) // XBT_ATTRIB_DEPRECATED_v335 -{ - simgrid::kernel::actor::ActorImpl* issuer = simgrid::kernel::actor::ActorImpl::self(); - simgrid::kernel::actor::ActivityTestSimcall observer{issuer, comm}; - if (simgrid::kernel::actor::simcall_blocking([&observer] { observer.get_activity()->test(observer.get_issuer()); }, - &observer)) { - comm->get_iface()->complete(simgrid::s4u::Activity::State::FINISHED); - return true; - } - return false; -} diff --git a/src/mc/api/State.cpp b/src/mc/api/State.cpp index d1919db775..e1e5b8ab55 100644 --- a/src/mc/api/State.cpp +++ b/src/mc/api/State.cpp @@ -183,7 +183,7 @@ std::unordered_set State::get_backtrack_set() const { std::unordered_set actors; for (const auto& [aid, state] : get_actors_list()) { - if (state.is_todo() or state.is_done()) { + if (state.is_todo() || state.is_done()) { actors.insert(aid); } } @@ -291,7 +291,7 @@ void State::do_odpor_unwind() // works with ODPOR in the way we intend it to work. There is not a // good way to perform transition equality in SimGrid; instead, we // effectively simply check for the presence of an actor in the sleep set. - if (!get_actors_list().at(out_transition->aid_).has_more_to_consider()) + if (not get_actors_list().at(out_transition->aid_).has_more_to_consider()) add_sleep_set(std::move(out_transition)); } } diff --git a/src/mc/api/strategy/MaxMatchComm.hpp b/src/mc/api/strategy/MaxMatchComm.hpp index 1f9a826746..7ec0af9361 100644 --- a/src/mc/api/strategy/MaxMatchComm.hpp +++ b/src/mc/api/strategy/MaxMatchComm.hpp @@ -42,52 +42,45 @@ public: std::pair best_transition(bool must_be_todo) const override { - std::pair min_found = std::make_pair(-1, value_of_state_+2); + std::pair min_found = std::make_pair(-1, value_of_state_ + 2); for (auto const& [aid, actor] : actors_to_run_) { if ((not actor.is_todo() && must_be_todo) || not actor.is_enabled() || actor.is_done()) continue; int aid_value = value_of_state_; const Transition* transition = actor.get_transition(actor.get_times_considered()).get(); - - const CommRecvTransition* cast_recv = dynamic_cast(transition); - if (cast_recv != nullptr) { - if (mailbox_.count(cast_recv->get_mailbox()) > 0 and - mailbox_.at(cast_recv->get_mailbox()) > 0) { - aid_value--; // This means we have waiting recv corresponding to this recv - } else { - aid_value++; - } + + if (auto const* cast_recv = dynamic_cast(transition)) { + if (mailbox_.count(cast_recv->get_mailbox()) > 0 && mailbox_.at(cast_recv->get_mailbox()) > 0) { + aid_value--; // This means we have waiting recv corresponding to this recv + } else { + aid_value++; + } } - - const CommSendTransition* cast_send = dynamic_cast(transition); - if (cast_send != nullptr) { - if (mailbox_.count(cast_send->get_mailbox()) > 0 and - mailbox_.at(cast_send->get_mailbox()) < 0) { - aid_value--; // This means we have waiting recv corresponding to this send - }else { - aid_value++; - } + + if (auto const* cast_send = dynamic_cast(transition)) { + if (mailbox_.count(cast_send->get_mailbox()) > 0 && mailbox_.at(cast_send->get_mailbox()) < 0) { + aid_value--; // This means we have waiting recv corresponding to this send + } else { + aid_value++; + } } - + if (aid_value < min_found.second) min_found = std::make_pair(aid, aid_value); } return min_found; } - void execute_next(aid_t aid, RemoteApp& app) override { const Transition* transition = actors_to_run_.at(aid).get_transition(actors_to_run_.at(aid).get_times_considered()).get(); last_transition_ = transition->type_; - const CommRecvTransition* cast_recv = dynamic_cast(transition); - if (cast_recv != nullptr) + if (auto const* cast_recv = dynamic_cast(transition)) last_mailbox_ = cast_recv->get_mailbox(); - const CommSendTransition* cast_send = dynamic_cast(transition); - if (cast_send != nullptr) + if (auto const* cast_send = dynamic_cast(transition)) last_mailbox_ = cast_send->get_mailbox(); } }; diff --git a/src/mc/api/strategy/MinMatchComm.hpp b/src/mc/api/strategy/MinMatchComm.hpp index 607a0a04a3..e8fc1f4f16 100644 --- a/src/mc/api/strategy/MinMatchComm.hpp +++ b/src/mc/api/strategy/MinMatchComm.hpp @@ -46,7 +46,7 @@ public: std::pair best_transition(bool must_be_todo) const override { - std::pair min_found = std::make_pair(-1, value_of_state_+2); + std::pair min_found = std::make_pair(-1, value_of_state_ + 2); for (auto const& [aid, actor] : actors_to_run_) { if ((not actor.is_todo() && must_be_todo) || not actor.is_enabled() || actor.is_done()) continue; @@ -54,23 +54,21 @@ public: int aid_value = value_of_state_; const Transition* transition = actor.get_transition(actor.get_times_considered()).get(); - const CommRecvTransition* cast_recv = dynamic_cast(transition); - if (cast_recv != nullptr) { - if ((mailbox_.count(cast_recv->get_mailbox()) > 0 and - mailbox_.at(cast_recv->get_mailbox()) <= 0) or mailbox_.count(cast_recv->get_mailbox()) == 0) - aid_value--; // This means we don't have waiting recv corresponding to this recv - else - aid_value++; + if (auto const* cast_recv = dynamic_cast(transition)) { + if ((mailbox_.count(cast_recv->get_mailbox()) > 0 && mailbox_.at(cast_recv->get_mailbox()) <= 0) || + mailbox_.count(cast_recv->get_mailbox()) == 0) + aid_value--; // This means we don't have waiting recv corresponding to this recv + else + aid_value++; } - const CommSendTransition* cast_send = dynamic_cast(transition); - if (cast_send != nullptr) { - if ((mailbox_.count(cast_send->get_mailbox()) > 0 and - mailbox_.at(cast_send->get_mailbox()) >= 0) or mailbox_.count(cast_send->get_mailbox()) == 0) - aid_value--; - else - aid_value++; + if (auto const* cast_send = dynamic_cast(transition)) { + if ((mailbox_.count(cast_send->get_mailbox()) > 0 && mailbox_.at(cast_send->get_mailbox()) >= 0) || + mailbox_.count(cast_send->get_mailbox()) == 0) + aid_value--; + else + aid_value++; } - + if (aid_value < min_found.second) min_found = std::make_pair(aid, aid_value); } @@ -83,12 +81,10 @@ public: const Transition* transition = actors_to_run_.at(aid).get_transition(actors_to_run_.at(aid).get_times_considered()).get(); last_transition_ = transition->type_; - const CommRecvTransition* cast_recv = dynamic_cast(transition); - if (cast_recv != nullptr) + if (auto const* cast_recv = dynamic_cast(transition)) last_mailbox_ = cast_recv->get_mailbox(); - const CommSendTransition* cast_send = dynamic_cast(transition); - if (cast_send != nullptr) + if (auto const* cast_send = dynamic_cast(transition)) last_mailbox_ = cast_send->get_mailbox(); } }; diff --git a/src/mc/api/strategy/Strategy.hpp b/src/mc/api/strategy/Strategy.hpp index 96eb753e02..f496ef5b7d 100644 --- a/src/mc/api/strategy/Strategy.hpp +++ b/src/mc/api/strategy/Strategy.hpp @@ -35,7 +35,7 @@ public: virtual std::pair best_transition(bool must_be_todo) const = 0; /** Returns the best transition among those that should be interleaved. */ - std::pair next_transition() { return best_transition(true); } + std::pair next_transition() const { return best_transition(true); } /** Allows for the strategy to update its fields knowing that the actor aid will * be executed and a children strategy will then be created. */ @@ -44,9 +44,9 @@ public: /** Ensure at least one transition is marked as todo among the enabled ones not done. * If required, it marks as todo the best transition according to the strategy. */ void consider_best() { - for (auto& [_, actor] :actors_to_run_) - if (actor.is_todo()) - return; + if (std::any_of(begin(actors_to_run_), end(actors_to_run_), + [](const auto& actor) { return actor.second.is_todo(); })) + return; aid_t best_aid = best_transition(false).first; if (best_aid != -1) actors_to_run_.at(best_aid).mark_todo(); @@ -56,7 +56,7 @@ public: // else raise an error void consider_one(aid_t aid) { - xbt_assert(actors_to_run_.at(aid).is_enabled() and not actors_to_run_.at(aid).is_done(), + xbt_assert(actors_to_run_.at(aid).is_enabled() && not actors_to_run_.at(aid).is_done(), "Tried to mark as TODO actor %ld but it is either not enabled or already done", aid); actors_to_run_.at(aid).mark_todo(); } @@ -66,7 +66,7 @@ public: { unsigned long count = 0; for (auto& [_, actor] : actors_to_run_) - if (actor.is_enabled() and not actor.is_done()) { + if (actor.is_enabled() && not actor.is_done()) { actor.mark_todo(); count++; } diff --git a/src/mc/api/strategy/UniformStrategy.hpp b/src/mc/api/strategy/UniformStrategy.hpp index cc5bd85773..472c571d3a 100644 --- a/src/mc/api/strategy/UniformStrategy.hpp +++ b/src/mc/api/strategy/UniformStrategy.hpp @@ -9,12 +9,12 @@ #include "src/mc/transition/Transition.hpp" #include "xbt/random.hpp" -#define MAX_RAND 100000 - namespace simgrid::mc { /** Guiding strategy that valuate states randomly */ class UniformStrategy : public Strategy { + static constexpr int MAX_RAND = 100000; + std::map valuation; public: @@ -25,7 +25,7 @@ public: } void copy_from(const Strategy* strategy) override { - for (auto& [aid, _] : actors_to_run_) + for (auto const& [aid, _] : actors_to_run_) valuation[aid] = xbt::random::uniform_int(0, MAX_RAND); } @@ -35,7 +35,7 @@ public: // Consider only valid actors for (auto const& [aid, actor] : actors_to_run_) { - if ((actor.is_todo() or not must_be_todo) and (not actor.is_done()) and actor.is_enabled()) + if ((actor.is_todo() || not must_be_todo) && (not actor.is_done()) && actor.is_enabled()) possibilities++; } @@ -48,7 +48,7 @@ public: chosen = xbt::random::uniform_int(0, possibilities-1); for (auto const& [aid, actor] : actors_to_run_) { - if (((not actor.is_todo()) and must_be_todo) or actor.is_done() or (not actor.is_enabled())) + if (((not actor.is_todo()) && must_be_todo) || actor.is_done() || (not actor.is_enabled())) continue; if (chosen == 0) { return std::make_pair(aid, valuation.at(aid)); diff --git a/src/mc/explo/DFSExplorer.cpp b/src/mc/explo/DFSExplorer.cpp index 5bf8cd01c0..3c13ad38e3 100644 --- a/src/mc/explo/DFSExplorer.cpp +++ b/src/mc/explo/DFSExplorer.cpp @@ -300,7 +300,7 @@ void DFSExplorer::run() for (const auto e_race : execution_seq_.get_reversible_races_of(next_E_p)) { State* prev_state = stack_[e_race].get(); const auto choices = execution_seq_.get_missing_source_set_actors_from(e_race, prev_state->get_backtrack_set()); - if (!choices.empty()) { + if (not choices.empty()) { // NOTE: To incorporate the idea of attempting to select the "best" // backtrack point into SDPOR, instead of selecting the `first` initial, // we should instead compute all choices and decide which is best @@ -401,7 +401,7 @@ std::shared_ptr DFSExplorer::next_odpor_state() XBT_DEBUG("\tPerformed ODPOR 'clean-up'. Sleep set has:"); 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()) { + if (not state->has_empty_tree()) { return state; } } @@ -428,8 +428,7 @@ void DFSExplorer::backtrack() XBT_DEBUG("ODPOR: Reversible race detected between events `%u` and `%u`", e, e_prime); State& prev_state = *stack_[e]; if (const auto v = execution_seq_.get_odpor_extension_from(e, e_prime, prev_state); v.has_value()) { - const auto result = prev_state.insert_into_wakeup_tree(v.value(), execution_seq_.get_prefix_before(e)); - switch (result) { + switch (prev_state.insert_into_wakeup_tree(v.value(), execution_seq_.get_prefix_before(e))) { case odpor::WakeupTree::InsertionResult::root: { XBT_DEBUG("ODPOR: Reversible race with `%u` unaccounted for in the wakeup tree for " "the execution prior to event `%u`:", diff --git a/src/mc/explo/odpor/Execution.cpp b/src/mc/explo/odpor/Execution.cpp index ef10e4f45f..3f10062cb4 100644 --- a/src/mc/explo/odpor/Execution.cpp +++ b/src/mc/explo/odpor/Execution.cpp @@ -87,7 +87,7 @@ std::unordered_set Execution::get_racing_events_of(Execu // 2. disqualified_events.count(e_j) > 0 // then e_i --->_E target indirectly (either through // e_j directly, or transitively through e_j) - if (disqualified_events.count(e_j) > 0 and happens_before(e_i, e_j)) { + if (disqualified_events.count(e_j) > 0 && happens_before(e_i, e_j)) { disqualified_events.insert(e_i); break; } @@ -164,7 +164,7 @@ Execution::get_missing_source_set_actors_from(EventHandle e, const std::unordere // happen after `e` is a member of `v`. In addition to marking // the event in `v`, we also "simulate" running the action `v` // from E' - if (not happens_before(e, e_prime) or e_prime == next_E_p) { + if (not happens_before(e, e_prime) || e_prime == next_E_p) { // First, push the transition onto the hypothetical execution E_prime_v.push_transition(get_event_with_handle(e_prime).get_transition()); const EventHandle e_prime_in_E_prime_v = E_prime_v.get_latest_event_handle().value(); @@ -206,7 +206,7 @@ Execution::get_missing_source_set_actors_from(EventHandle e, const std::unordere } } } - xbt_assert(!I_E_prime_v.empty(), + xbt_assert(not I_E_prime_v.empty(), "For any non-empty execution, we know that " "at minimum one actor is an initial since " "some execution is possible with respect to a " @@ -412,10 +412,8 @@ std::optional Execution::get_shortest_odpor_sq_subset_insertio auto w_now = w; for (const auto& next_E_p : v) { - const aid_t p = next_E_p->aid_; - // Is `p in `I_[E](w)`? - if (E_v.is_initial_after_execution_of(w_now, p)) { + if (const aid_t p = next_E_p->aid_; E_v.is_initial_after_execution_of(w_now, p)) { // Remove `p` from w and continue // INVARIANT: If `p` occurs in `w`, it had better refer to the same @@ -487,4 +485,4 @@ bool Execution::happens_before(Execution::EventHandle e1_handle, Execution::Even return false; } -} // namespace simgrid::mc::odpor \ No newline at end of file +} // namespace simgrid::mc::odpor diff --git a/src/mc/explo/odpor/Execution_test.cpp b/src/mc/explo/odpor/Execution_test.cpp index 364d9a0c7c..302ccea031 100644 --- a/src/mc/explo/odpor/Execution_test.cpp +++ b/src/mc/explo/odpor/Execution_test.cpp @@ -160,7 +160,7 @@ TEST_CASE("simgrid::mc::odpor::Execution: Testing Happens-Before") const bool e_j_before_e_k = execution.happens_before(e_j, e_k); const bool e_i_before_e_k = execution.happens_before(e_i, e_k); // Logical equivalent of `e_i_before_e_j ^ e_j_before_e_k --> e_i_before_e_k` - REQUIRE((!(e_i_before_e_j and e_j_before_e_k) or e_i_before_e_k)); + REQUIRE((not(e_i_before_e_j && e_j_before_e_k) || e_i_before_e_k)); } } } diff --git a/src/mc/explo/odpor/ReversibleRaceCalculator.cpp b/src/mc/explo/odpor/ReversibleRaceCalculator.cpp index 105a0f9d85..f2db6b6b9a 100644 --- a/src/mc/explo/odpor/ReversibleRaceCalculator.cpp +++ b/src/mc/explo/odpor/ReversibleRaceCalculator.cpp @@ -100,7 +100,7 @@ bool ReversibleRaceCalculator::is_race_reversible_CommWait(const Execution& E, E // If the other event is a communication event, then we // are not reversible; otherwise we are reversible. const auto e1_action = E.get_transition_for_handle(e1)->type_; - return e1_action != Transition::Type::COMM_ASYNC_SEND and e1_action != Transition::Type::COMM_ASYNC_RECV; + return e1_action != Transition::Type::COMM_ASYNC_SEND && e1_action != Transition::Type::COMM_ASYNC_RECV; } bool ReversibleRaceCalculator::is_race_reversible_CommTest(const Execution&, Execution::EventHandle e1, @@ -143,7 +143,7 @@ bool ReversibleRaceCalculator::is_race_reversible_MutexWait(const Execution& E, { // TODO: Get the semantics correct here const auto e1_action = E.get_transition_for_handle(e1)->type_; - return e1_action != Transition::Type::MUTEX_ASYNC_LOCK and e1_action != Transition::Type::MUTEX_UNLOCK; + return e1_action != Transition::Type::MUTEX_ASYNC_LOCK && e1_action != Transition::Type::MUTEX_UNLOCK; } bool ReversibleRaceCalculator::is_race_reversible_SemAsyncLock(const Execution&, Execution::EventHandle e1, diff --git a/src/mc/explo/odpor/WakeupTree.cpp b/src/mc/explo/odpor/WakeupTree.cpp index 4489dd5666..8898b66bb6 100644 --- a/src/mc/explo/odpor/WakeupTree.cpp +++ b/src/mc/explo/odpor/WakeupTree.cpp @@ -10,6 +10,7 @@ #include #include +#include #include namespace simgrid::mc::odpor { @@ -26,7 +27,7 @@ PartialExecution WakeupTreeNode::get_sequence() const // and instead track this with the iterator PartialExecution seq_; const WakeupTreeNode* cur_node = this; - while (cur_node != nullptr and !cur_node->is_root()) { + while (cur_node != nullptr && not cur_node->is_root()) { seq_.push_front(cur_node->action_); cur_node = cur_node->parent_; } @@ -46,7 +47,7 @@ void WakeupTreeNode::detatch_from_parent() } } -WakeupTree::WakeupTree() : WakeupTree(std::unique_ptr(new WakeupTreeNode({}))) {} +WakeupTree::WakeupTree() : WakeupTree(std::make_unique()) {} WakeupTree::WakeupTree(std::unique_ptr root) : root_(root.get()) { this->insert_node(std::move(root)); @@ -153,7 +154,7 @@ bool WakeupTree::contains(const WakeupTreeNode* node) const WakeupTreeNode* WakeupTree::make_node(std::shared_ptr u) { - auto node = std::unique_ptr(new WakeupTreeNode(std::move(u))); + auto node = std::make_unique(std::move(u)); auto* node_handle = node.get(); this->nodes_[node_handle] = std::move(node); return node_handle; @@ -181,7 +182,7 @@ WakeupTree::InsertionResult WakeupTree::insert(const Execution& E, const Partial shortest_sequence.has_value()) { // Insert the sequence as a child of `node`, but only // if the node is not already a leaf - if (not node->is_leaf() or node == this->root_) { + if (not node->is_leaf() || node == this->root_) { // NOTE: It's entirely possible that the shortest // sequence we are inserting is empty. Consider the // following two cases: diff --git a/src/mc/explo/odpor/WakeupTree.hpp b/src/mc/explo/odpor/WakeupTree.hpp index 0ffcc67021..8247a913b3 100644 --- a/src/mc/explo/odpor/WakeupTree.hpp +++ b/src/mc/explo/odpor/WakeupTree.hpp @@ -35,8 +35,6 @@ namespace simgrid::mc::odpor { */ class WakeupTreeNode { private: - explicit WakeupTreeNode(std::shared_ptr u) : action_(u) {} - WakeupTreeNode* parent_ = nullptr; /** An ordered list of children of for this node in the tree */ @@ -53,6 +51,9 @@ private: friend WakeupTreeIterator; public: + explicit WakeupTreeNode(std::shared_ptr u) : action_(u) {} + + WakeupTreeNode() = default; ~WakeupTreeNode() = default; WakeupTreeNode(const WakeupTreeNode&) = delete; WakeupTreeNode(WakeupTreeNode&&) = default; diff --git a/src/mc/explo/udpor/Configuration.cpp b/src/mc/explo/udpor/Configuration.cpp index 44ec27005f..635d90ad1a 100644 --- a/src/mc/explo/udpor/Configuration.cpp +++ b/src/mc/explo/udpor/Configuration.cpp @@ -32,7 +32,7 @@ Configuration::Configuration(const History& history) : Configuration(history.get Configuration::Configuration(const EventSet& events) : events_(events) { - if (!events_.is_valid_configuration()) { + if (not events_.is_valid_configuration()) { throw std::invalid_argument("The events do not form a valid configuration"); } @@ -67,7 +67,7 @@ void Configuration::add_event(const UnfoldingEvent* e) this->latest_event_mapping[e->get_actor()] = e; // Preserves the property that the configuration is causally closed - if (auto history = History(e); !this->events_.contains(history)) { + if (auto history = History(e); not this->events_.contains(history)) { throw std::invalid_argument("The newly added event has dependencies " "which are missing from this configuration"); } @@ -82,7 +82,7 @@ bool Configuration::is_compatible_with(const UnfoldingEvent* e) const // 2. `e` itself must not conflict with any events of // the configuration; otherwise adding the event would // violate the invariant that a configuration is conflict-free - return contains(e->get_history()) and (not e->conflicts_with_any(this->events_)); + return contains(e->get_history()) && (not e->conflicts_with_any(this->events_)); } bool Configuration::is_compatible_with(const History& history) const diff --git a/src/mc/explo/udpor/Configuration_test.cpp b/src/mc/explo/udpor/Configuration_test.cpp index dc3d900e36..2972ad9e65 100644 --- a/src/mc/explo/udpor/Configuration_test.cpp +++ b/src/mc/explo/udpor/Configuration_test.cpp @@ -969,7 +969,7 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Computing Full Alternatives in Rea // The first alternative that is found is the one that is chosen. Since // traversal over the elements of an unordered_set<> are not guaranteed, // both {e0, e4} and {e0, e7} are valid alternatives - REQUIRE((alternative.value().get_events() == EventSet({e0_handle, e4_handle}) or + REQUIRE((alternative.value().get_events() == EventSet({e0_handle, e4_handle}) || alternative.value().get_events() == EventSet({e0_handle, e7_handle}))); } @@ -1059,8 +1059,8 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Computing Full Alternatives in Rea const auto alternative = C.compute_alternative_to(D_plus_e, U); REQUIRE(alternative.has_value()); - REQUIRE((alternative.value().get_events() == EventSet({e0_handle, e7_handle}) or - alternative.value().get_events() == EventSet({e0_handle, e4_handle, e7_handle}) or + REQUIRE((alternative.value().get_events() == EventSet({e0_handle, e7_handle}) || + alternative.value().get_events() == EventSet({e0_handle, e4_handle, e7_handle}) || alternative.value().get_events() == EventSet({e0_handle, e4_handle, e7_handle, e8_handle}))); } diff --git a/src/mc/explo/udpor/EventSet.cpp b/src/mc/explo/udpor/EventSet.cpp index feef1dd192..8f017f9fc7 100644 --- a/src/mc/explo/udpor/EventSet.cpp +++ b/src/mc/explo/udpor/EventSet.cpp @@ -220,7 +220,7 @@ std::vector EventSet::get_topological_ordering() const temporarily_marked_events.insert(evt); EventSet immediate_causes = evt->get_immediate_causes(); - if (!immediate_causes.empty() && immediate_causes.is_subset_of(temporarily_marked_events)) { + if (not immediate_causes.empty() && immediate_causes.is_subset_of(temporarily_marked_events)) { throw std::invalid_argument("Attempted to perform a topological sort on a configuration " "whose contents contain a cycle. The configuration (and the graph " "connecting all of the events) is an invalid event structure"); @@ -285,4 +285,4 @@ std::vector EventSet::move_into_vector() const&& return contents; } -} // namespace simgrid::mc::udpor \ No newline at end of file +} // namespace simgrid::mc::udpor diff --git a/src/mc/explo/udpor/ExtensionSetCalculator.cpp b/src/mc/explo/udpor/ExtensionSetCalculator.cpp index e2e2e67f8e..0884ee5921 100644 --- a/src/mc/explo/udpor/ExtensionSetCalculator.cpp +++ b/src/mc/explo/udpor/ExtensionSetCalculator.cpp @@ -72,8 +72,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommSend(const Configuration& // Com contains a matching c' = AsyncReceive(m, _) with `action` for (const auto e : C) { const bool transition_type_check = [&]() { - if (const auto* async_send = dynamic_cast(e->get_transition()); - async_send != nullptr) { + if (const auto* async_send = dynamic_cast(e->get_transition())) { return async_send->get_mailbox() == sender_mailbox; } // TODO: Add `TestAny` dependency @@ -152,13 +151,11 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& // whose transition is the `CommRecv` or `CommSend` whose resulting // communication this `CommWait` waits on const auto issuer = std::find_if(C.begin(), C.end(), [&](const UnfoldingEvent* e) { - if (const CommRecvTransition* e_issuer_receive = dynamic_cast(e->get_transition()); - e_issuer_receive != nullptr) { + if (const auto* e_issuer_receive = dynamic_cast(e->get_transition())) { return e_issuer_receive->aid_ == wait_action->aid_ && wait_comm == e_issuer_receive->get_comm(); } - if (const CommSendTransition* e_issuer_send = dynamic_cast(e->get_transition()); - e_issuer_send != nullptr) { + if (const auto* e_issuer_send = dynamic_cast(e->get_transition())) { return e_issuer_send->aid_ == wait_action->aid_ && wait_comm == e_issuer_send->get_comm(); } @@ -192,16 +189,13 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& // as needed to reach the receive/send number that is `issuer`. // ... // ... - if (const CommRecvTransition* e_issuer_receive = - dynamic_cast(e_issuer->get_transition()); - e_issuer_receive != nullptr) { + if (const auto* e_issuer_receive = dynamic_cast(e_issuer->get_transition())) { const unsigned issuer_mailbox = e_issuer_receive->get_mailbox(); // Check from the config -> how many sends have there been const unsigned send_position = std::count_if(config_pre_event.begin(), config_pre_event.end(), [=](const auto e) { - const CommSendTransition* e_send = dynamic_cast(e->get_transition()); - if (e_send != nullptr) { + if (const auto* e_send = dynamic_cast(e->get_transition())) { return e_send->get_mailbox() == issuer_mailbox; } return false; @@ -210,8 +204,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& // Check from e_issuer -> what place is the issuer in? const unsigned receive_position = std::count_if(e_issuer_history.begin(), e_issuer_history.end(), [=](const auto e) { - const CommRecvTransition* e_receive = dynamic_cast(e->get_transition()); - if (e_receive != nullptr) { + if (const auto* e_receive = dynamic_cast(e->get_transition())) { return e_receive->get_mailbox() == issuer_mailbox; } return false; @@ -221,16 +214,13 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& exC.insert(U->discover_event(EventSet({unwrapped_pre_event}), wait_action)); } - } else if (const CommSendTransition* e_issuer_send = - dynamic_cast(e_issuer->get_transition()); - e_issuer_send != nullptr) { + } else if (const auto* e_issuer_send = dynamic_cast(e_issuer->get_transition())) { const unsigned issuer_mailbox = e_issuer_send->get_mailbox(); // Check from e_issuer -> what place is the issuer in? const unsigned send_position = std::count_if(e_issuer_history.begin(), e_issuer_history.end(), [=](const auto e) { - const CommSendTransition* e_send = dynamic_cast(e->get_transition()); - if (e_send != nullptr) { + if (const auto* e_send = dynamic_cast(e->get_transition())) { return e_send->get_mailbox() == issuer_mailbox; } return false; @@ -239,8 +229,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& // Check from the config -> how many sends have there been const unsigned receive_position = std::count_if(config_pre_event.begin(), config_pre_event.end(), [=](const auto e) { - const CommRecvTransition* e_receive = dynamic_cast(e->get_transition()); - if (e_receive != nullptr) { + if (const auto* e_receive = dynamic_cast(e->get_transition())) { return e_receive->get_mailbox() == issuer_mailbox; } return false; @@ -261,8 +250,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& } // 3. foreach event e in C do - if (const CommSendTransition* e_issuer_send = dynamic_cast(e_issuer->get_transition()); - e_issuer_send != nullptr) { + if (const auto* e_issuer_send = dynamic_cast(e_issuer->get_transition())) { for (const auto e : C) { // If the provider of the communication for `CommWait` is a // `CommSend(m)`, then we only care about `e` if `λ(e) == `CommRecv(m)`. @@ -274,8 +262,8 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& } const auto issuer_mailbox = e_issuer_send->get_mailbox(); - const CommRecvTransition* e_recv = dynamic_cast(e->get_transition()); - if (e_recv->get_mailbox() != issuer_mailbox) { + if (const auto* e_recv = dynamic_cast(e->get_transition()); + e_recv->get_mailbox() != issuer_mailbox) { continue; } @@ -291,8 +279,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& // What send # is the issuer const unsigned send_position = std::count_if(e_issuer_history.begin(), e_issuer_history.end(), [=](const auto e) { - const CommSendTransition* e_send = dynamic_cast(e->get_transition()); - if (e_send != nullptr) { + if (const auto* e_send = dynamic_cast(e->get_transition())) { return e_send->get_mailbox() == issuer_mailbox; } return false; @@ -300,8 +287,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& // What receive # is the event `e`? const unsigned receive_position = std::count_if(config_K.begin(), config_K.end(), [=](const auto e) { - const CommRecvTransition* e_receive = dynamic_cast(e->get_transition()); - if (e_receive != nullptr) { + if (const auto* e_receive = dynamic_cast(e->get_transition())) { return e_receive->get_mailbox() == issuer_mailbox; } return false; @@ -311,9 +297,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& exC.insert(U->discover_event(std::move(K), wait_action)); } } - } else if (const CommRecvTransition* e_issuer_recv = - dynamic_cast(e_issuer->get_transition()); - e_issuer_recv != nullptr) { + } else if (const auto* e_issuer_recv = dynamic_cast(e_issuer->get_transition())) { for (const auto e : C) { // If the provider of the communication for `CommWait` is a // `CommRecv(m)`, then we only care about `e` if `λ(e) == `CommSend(m)`. @@ -325,8 +309,8 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& } const auto issuer_mailbox = e_issuer_recv->get_mailbox(); - const CommSendTransition* e_send = dynamic_cast(e->get_transition()); - if (e_send->get_mailbox() != issuer_mailbox) { + if (const auto* e_send = dynamic_cast(e->get_transition()); + e_send->get_mailbox() != issuer_mailbox) { continue; } @@ -342,8 +326,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& // What receive # is the event `e`? const unsigned send_position = std::count_if(config_K.begin(), config_K.end(), [=](const auto e) { - const CommSendTransition* e_send = dynamic_cast(e->get_transition()); - if (e_send != nullptr) { + if (const auto* e_send = dynamic_cast(e->get_transition())) { return e_send->get_mailbox() == issuer_mailbox; } return false; @@ -352,8 +335,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration& // What send # is the issuer const unsigned receive_position = std::count_if(e_issuer_history.begin(), e_issuer_history.end(), [=](const auto e) { - const CommRecvTransition* e_receive = dynamic_cast(e->get_transition()); - if (e_receive != nullptr) { + if (const auto* e_receive = dynamic_cast(e->get_transition())) { return e_receive->get_mailbox() == issuer_mailbox; } return false; @@ -395,13 +377,11 @@ EventSet ExtensionSetCalculator::partially_extend_CommTest(const Configuration& // whose transition is the `CommRecv` or `CommSend` whose resulting // communication this `CommTest` tests on const auto issuer = std::find_if(C.begin(), C.end(), [=](const UnfoldingEvent* e) { - if (const CommRecvTransition* e_issuer_receive = dynamic_cast(e->get_transition()); - e_issuer_receive != nullptr) { + if (const auto* e_issuer_receive = dynamic_cast(e->get_transition())) { return e_issuer_receive->aid_ == test_aid && test_comm == e_issuer_receive->get_comm(); } - if (const CommSendTransition* e_issuer_send = dynamic_cast(e->get_transition()); - e_issuer_send != nullptr) { + if (const auto* e_issuer_send = dynamic_cast(e->get_transition())) { return e_issuer_send->aid_ == test_aid && test_comm == e_issuer_send->get_comm(); } @@ -418,8 +398,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommTest(const Configuration& const History e_issuer_history(e_issuer); // 3. foreach event e in C do - if (const CommSendTransition* e_issuer_send = dynamic_cast(e_issuer->get_transition()); - e_issuer_send != nullptr) { + if (const auto* e_issuer_send = dynamic_cast(e_issuer->get_transition())) { for (const auto e : C) { // If the provider of the communication for `CommTest` is a // `CommSend(m)`, then we only care about `e` if `λ(e) == `CommRecv(m)`. @@ -432,7 +411,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommTest(const Configuration& const auto issuer_mailbox = e_issuer_send->get_mailbox(); - if (const CommRecvTransition* e_recv = dynamic_cast(e->get_transition()); + if (const auto* e_recv = dynamic_cast(e->get_transition()); e_recv->get_mailbox() != issuer_mailbox) { continue; } @@ -449,8 +428,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommTest(const Configuration& // What send # is the issuer const unsigned send_position = std::count_if(e_issuer_history.begin(), e_issuer_history.end(), [=](const auto e) { - const CommSendTransition* e_send = dynamic_cast(e->get_transition()); - if (e_send != nullptr) { + if (const auto* e_send = dynamic_cast(e->get_transition())) { return e_send->get_mailbox() == issuer_mailbox; } return false; @@ -458,8 +436,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommTest(const Configuration& // What receive # is the event `e`? const unsigned receive_position = std::count_if(config_K.begin(), config_K.end(), [=](const auto e) { - const CommRecvTransition* e_receive = dynamic_cast(e->get_transition()); - if (e_receive != nullptr) { + if (const auto* e_receive = dynamic_cast(e->get_transition())) { return e_receive->get_mailbox() == issuer_mailbox; } return false; @@ -469,9 +446,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommTest(const Configuration& exC.insert(U->discover_event(std::move(K), test_action)); } } - } else if (const CommRecvTransition* e_issuer_recv = - dynamic_cast(e_issuer->get_transition()); - e_issuer_recv != nullptr) { + } else if (const auto* e_issuer_recv = dynamic_cast(e_issuer->get_transition())) { for (const auto e : C) { // If the provider of the communication for `CommTest` is a // `CommRecv(m)`, then we only care about `e` if `λ(e) == `CommSend(m)`. @@ -483,8 +458,8 @@ EventSet ExtensionSetCalculator::partially_extend_CommTest(const Configuration& } const auto issuer_mailbox = e_issuer_recv->get_mailbox(); - const CommSendTransition* e_send = dynamic_cast(e->get_transition()); - if (e_send->get_mailbox() != issuer_mailbox) { + if (const auto* e_send = dynamic_cast(e->get_transition()); + e_send->get_mailbox() != issuer_mailbox) { continue; } @@ -500,8 +475,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommTest(const Configuration& // What receive # is the event `e`? const unsigned send_position = std::count_if(config_K.begin(), config_K.end(), [=](const auto e) { - const CommSendTransition* e_send = dynamic_cast(e->get_transition()); - if (e_send != nullptr) { + if (const auto* e_send = dynamic_cast(e->get_transition())) { return e_send->get_mailbox() == issuer_mailbox; } return false; @@ -510,8 +484,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommTest(const Configuration& // What send # is the issuer const unsigned receive_position = std::count_if(e_issuer_history.begin(), e_issuer_history.end(), [=](const auto e) { - const CommRecvTransition* e_receive = dynamic_cast(e->get_transition()); - if (e_receive != nullptr) { + if (const auto* e_receive = dynamic_cast(e->get_transition())) { return e_receive->get_mailbox() == issuer_mailbox; } return false; @@ -553,12 +526,10 @@ EventSet ExtensionSetCalculator::partially_extend_MutexAsyncLock(const Configura // for each event e in C for (const auto e : C) { // Check for other locks on the same mutex - if (const MutexTransition* e_mutex = dynamic_cast(e->get_transition()); - e_mutex != nullptr) { - if (e_mutex->type_ == Transition::Type::MUTEX_ASYNC_LOCK && mutex_lock->get_mutex() == e_mutex->get_mutex()) { - const EventSet K = EventSet({e, pre_event_a_C.value_or(e)}); - exC.insert(U->discover_event(std::move(K), mutex_lock)); - } + if (const auto* e_mutex = dynamic_cast(e->get_transition()); + e_mutex->type_ == Transition::Type::MUTEX_ASYNC_LOCK && mutex_lock->get_mutex() == e_mutex->get_mutex()) { + const EventSet K = EventSet({e, pre_event_a_C.value_or(e)}); + exC.insert(U->discover_event(std::move(K), mutex_lock)); } } return exC; @@ -586,16 +557,14 @@ EventSet ExtensionSetCalculator::partially_extend_MutexUnlock(const Configuratio // for each event e in C for (const auto e : C) { // Check for MutexTest - if (const MutexTransition* e_mutex = dynamic_cast(e->get_transition()); - e_mutex != nullptr) { - if (e_mutex->type_ == Transition::Type::MUTEX_TEST || e_mutex->type_ == Transition::Type::MUTEX_WAIT) { - // TODO: Check if dependent or not - // This entails getting information about - // the relative position of the mutex in the queue, which - // again means we need more context... - const EventSet K = EventSet({e, pre_event_a_C.value_or(e)}); - exC.insert(U->discover_event(std::move(K), mutex_unlock)); - } + if (const auto* e_mutex = dynamic_cast(e->get_transition()); + e_mutex->type_ == Transition::Type::MUTEX_TEST || e_mutex->type_ == Transition::Type::MUTEX_WAIT) { + // TODO: Check if dependent or not + // This entails getting information about + // the relative position of the mutex in the queue, which + // again means we need more context... + const EventSet K = EventSet({e, pre_event_a_C.value_or(e)}); + exC.insert(U->discover_event(std::move(K), mutex_unlock)); } } return exC; @@ -622,7 +591,7 @@ EventSet ExtensionSetCalculator::partially_extend_MutexWait(const Configuration& // for each event e in C for (const auto e : C) { // Check for any unlocks - if (const MutexTransition* e_mutex = dynamic_cast(e->get_transition()); + if (const auto* e_mutex = dynamic_cast(e->get_transition()); e_mutex != nullptr && e_mutex->type_ == Transition::Type::MUTEX_UNLOCK) { // TODO: Check if dependent or not // This entails getting information about @@ -644,7 +613,7 @@ EventSet ExtensionSetCalculator::partially_extend_MutexTest(const Configuration& // for each event e in C // 1. If lambda(e) := pre(a) -> add it. Note that if - // pre_evevnt_a_C.has_value() == false, this implies `C` is + // pre_event_a_C.has_value() == false, this implies `C` is // empty or which we treat as implicitly containing the bottom event if (pre_event_a_C.has_value()) { const auto e_prime = U->discover_event(EventSet({pre_event_a_C.value()}), mutex_test); @@ -657,7 +626,7 @@ EventSet ExtensionSetCalculator::partially_extend_MutexTest(const Configuration& // for each event e in C for (const auto e : C) { // Check for any unlocks - if (const MutexTransition* e_mutex = dynamic_cast(e->get_transition()); + if (const auto* e_mutex = dynamic_cast(e->get_transition()); e_mutex != nullptr && e_mutex->type_ == Transition::Type::MUTEX_UNLOCK) { // TODO: Check if dependent or not // This entails getting information about diff --git a/src/mc/explo/udpor/UnfoldingEvent.cpp b/src/mc/explo/udpor/UnfoldingEvent.cpp index fd4dc2ec36..8b71842e4f 100644 --- a/src/mc/explo/udpor/UnfoldingEvent.cpp +++ b/src/mc/explo/udpor/UnfoldingEvent.cpp @@ -77,7 +77,7 @@ EventSet UnfoldingEvent::get_local_config() const bool UnfoldingEvent::related_to(const UnfoldingEvent* other) const { - return this->in_history_of(other) or other->in_history_of(this); + return this->in_history_of(other) || other->in_history_of(this); } bool UnfoldingEvent::in_history_of(const UnfoldingEvent* other) const @@ -103,7 +103,7 @@ bool UnfoldingEvent::conflicts_with(const UnfoldingEvent* other) const [&](const UnfoldingEvent* e) { return e->is_dependent_with(other); }); const bool conflicts_with_other = std::any_of(unique_to_other.begin(), unique_to_other.end(), [&](const UnfoldingEvent* e) { return e->is_dependent_with(this); }); - return conflicts_with_me or conflicts_with_other; + return conflicts_with_me || conflicts_with_other; } bool UnfoldingEvent::conflicts_with_any(const EventSet& events) const diff --git a/src/mc/explo/udpor/maximal_subsets_iterator.cpp b/src/mc/explo/udpor/maximal_subsets_iterator.cpp index 472855a9cf..3aa7047fa3 100644 --- a/src/mc/explo/udpor/maximal_subsets_iterator.cpp +++ b/src/mc/explo/udpor/maximal_subsets_iterator.cpp @@ -34,7 +34,7 @@ void maximal_subsets_iterator::increment() } const auto next_event_ref = [&]() { - if (!has_started_searching) { + if (not has_started_searching) { has_started_searching = true; return bookkeeper.find_next_candidate_event(topological_ordering.begin(), topological_ordering.end()); } else { diff --git a/src/mc/transition/TransitionAny.hpp b/src/mc/transition/TransitionAny.hpp index b0648119b1..494006b2b8 100644 --- a/src/mc/transition/TransitionAny.hpp +++ b/src/mc/transition/TransitionAny.hpp @@ -26,12 +26,10 @@ public: Transition* get_current_transition() const { return transitions_.at(times_considered_); } bool result() const { - for (Transition* transition : transitions_) { - CommTestTransition* tested_transition = static_cast(transition); - if (tested_transition->get_sender() != -1 and tested_transition->get_receiver() != -1) - return true; - } - return false; + return std::any_of(begin(transitions_), end(transitions_), [](const Transition* transition) { + const auto* tested_transition = static_cast(transition); + return (tested_transition->get_sender() != -1 && tested_transition->get_receiver() != -1); + }); } }; diff --git a/src/plugins/battery.cpp b/src/plugins/battery.cpp index b6cfd2aee6..21d1ceb3c5 100644 --- a/src/plugins/battery.cpp +++ b/src/plugins/battery.cpp @@ -427,7 +427,7 @@ void Battery::update() simgrid::kernel::actor::simcall_answered([this] { double now = simgrid::s4u::Engine::get_clock(); double time_delta_real = now - last_updated_; - if (time_delta_real <= 0 or not is_active()) + if (time_delta_real <= 0 || not is_active()) return; double time_delta_until_event = next_event_ - last_updated_; bool event = next_event_ != -1 and time_delta_until_event <= time_delta_real; diff --git a/src/plugins/photovoltaic.cpp b/src/plugins/photovoltaic.cpp index 923153b56b..9d8a717baa 100644 --- a/src/plugins/photovoltaic.cpp +++ b/src/plugins/photovoltaic.cpp @@ -218,9 +218,9 @@ void Photovoltaic::update() if (now <= last_updated_) return; double power_w = conversion_efficiency_ * area_m2_ * solar_irradiance_w_per_m2_; - if (min_power_w_ > 0 and power_w_ < min_power_w_) + if (min_power_w_ > 0 && power_w_ < min_power_w_) power_w = 0; - if (max_power_w_ > 0 and power_w_ > max_power_w_) + if (max_power_w_ > 0 && power_w_ > max_power_w_) power_w = max_power_w_; power_w_ = power_w; if (eval_cost_) { @@ -288,4 +288,4 @@ double sg_photovoltaic_get_power(const_sg_host_t host) { ensure_plugin_inited(); return host->extension()->get_power(); -} \ No newline at end of file +} diff --git a/src/s4u/s4u_Engine.cpp b/src/s4u/s4u_Engine.cpp index 2aa9dbcf0f..4bb9afddc2 100644 --- a/src/s4u/s4u_Engine.cpp +++ b/src/s4u/s4u_Engine.cpp @@ -86,11 +86,6 @@ const std::vector& Engine::get_cmdline() const return pimpl_->get_cmdline(); } -void Engine::shutdown() // XBT_ATTRIB_DEPRECATED_v335 -{ - delete Engine::instance_; -} - double Engine::get_clock() { if (MC_is_active() || MC_record_replay_is_active()) { diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 91da3536e1..62b4b121b8 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -681,22 +681,6 @@ void sg_host_sendto(sg_host_t from, sg_host_t to, double byte_amount) simgrid::s4u::Comm::sendto(from, to, byte_amount); } -/** @brief Displays debugging information about a host */ -void sg_host_dump(const_sg_host_t host) // XBT_ATTRIB_DEPRECATED_v335 -{ - XBT_INFO("Displaying host %s", host->get_cname()); - XBT_INFO(" - speed: %.0f", host->get_speed()); - XBT_INFO(" - available speed: %.2f", sg_host_get_available_speed(host)); - const std::unordered_map* props = host->get_properties(); - - if (not props->empty()) { - XBT_INFO(" - properties:"); - for (auto const& [key, value] : *props) { - XBT_INFO(" %s->%s", key.c_str(), value.c_str()); - } - } -} - /** @brief Return the list of actors attached to a host. * * @param host a host diff --git a/src/s4u/s4u_Task.cpp b/src/s4u/s4u_Task.cpp index bda7ec170e..9419363f1d 100644 --- a/src/s4u/s4u_Task.cpp +++ b/src/s4u/s4u_Task.cpp @@ -45,9 +45,10 @@ bool Task::ready_to_run() const void Task::receive(Task* source) { XBT_DEBUG("Task %s received a token from %s", name_.c_str(), source->name_.c_str()); - auto source_count = predecessors_[source]++; + auto source_count = predecessors_[source]; + predecessors_[source]++; if (tokens_received_.size() <= queued_firings_ + source_count) - tokens_received_.push_back({}); + tokens_received_.emplace_back(); tokens_received_[queued_firings_ + source_count][source] = source->token_; bool enough_tokens = true; for (auto const& [key, val] : predecessors_) @@ -130,7 +131,7 @@ void Task::fire() { on_start(this); working_ = true; queued_firings_ = std::max(queued_firings_ - 1, 0); - if (tokens_received_.size() > 0) + if (not tokens_received_.empty()) tokens_received_.pop_front(); } diff --git a/src/xbt/utils/iter/powerset.hpp b/src/xbt/utils/iter/powerset.hpp index b83bad77e6..68e0970d7c 100644 --- a/src/xbt/utils/iter/powerset.hpp +++ b/src/xbt/utils/iter/powerset.hpp @@ -74,8 +74,8 @@ template const std::vector& powerset_iterator void powerset_iterator::increment() { - if (!current_subset_iter.has_value() || !current_subset_iter_end.has_value() || !current_subset_iter.has_value() || - !iterator_end.has_value()) { + if (not current_subset_iter.has_value() || not current_subset_iter_end.has_value() || + not current_subset_iter.has_value() || not iterator_end.has_value()) { return; // We've traversed all subsets at this point, or we're the "last" iterator } diff --git a/src/xbt/utils/iter/subsets.hpp b/src/xbt/utils/iter/subsets.hpp index 1abea21900..f948b3868c 100644 --- a/src/xbt/utils/iter/subsets.hpp +++ b/src/xbt/utils/iter/subsets.hpp @@ -73,7 +73,7 @@ subsets_iterator::subsets_iterator(unsigned k, Iterator begin, Iterato template bool subsets_iterator::equal(const subsets_iterator& other) const { - if (this->end == std::nullopt and other.end == std::nullopt) { + if (this->end == std::nullopt && other.end == std::nullopt) { return true; } if (this->k != other.k) { @@ -82,7 +82,7 @@ template bool subsets_iterator::equal(const subset if (this->k == 0) { // this->k == other.k == 0 return true; } - return this->end != std::nullopt and other.end != std::nullopt and this->P[0] == other.P[0]; + return this->end != std::nullopt && other.end != std::nullopt && this->P[0] == other.P[0]; } template const std::vector& subsets_iterator::dereference() const diff --git a/src/xbt/utils/iter/variable_for_loop.hpp b/src/xbt/utils/iter/variable_for_loop.hpp index cbcb0a22cf..f283f6603b 100644 --- a/src/xbt/utils/iter/variable_for_loop.hpp +++ b/src/xbt/utils/iter/variable_for_loop.hpp @@ -51,7 +51,7 @@ public: const auto has_effect = std::none_of(collections.begin(), collections.end(), [](const auto& c) { return c.get().empty(); }); - if (has_effect and (not collections.empty())) { + if (has_effect && (not collections.empty())) { std::transform(collections.begin(), collections.end(), std::back_inserter(current_subset), [](const auto& c) { return c.get().cbegin(); }); underlying_collections = std::move(collections); @@ -76,7 +76,7 @@ template void variable_for_loop::increment { // Termination occurs when `current_subset := the empty set` // or if we have nothing to iterate over - if (current_subset.empty() or underlying_collections.empty()) { + if (current_subset.empty() || underlying_collections.empty()) { return; } diff --git a/teshsuite/xbt/cmdline/cmdline.c b/teshsuite/xbt/cmdline/cmdline.c index 52c7828a36..01e988087a 100644 --- a/teshsuite/xbt/cmdline/cmdline.c +++ b/teshsuite/xbt/cmdline/cmdline.c @@ -6,9 +6,6 @@ #include "simgrid/engine.h" #include -#define SIMIX_H_NO_DEPRECATED_WARNING // avoid deprecation warning on include (remove with XBT_ATTRIB_DEPRECATED_v335) -#include "simgrid/simix.h" // we don't need it, but someone must check that this file is actually usable in plain C - XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to this test"); int main(int argc, char** argv) diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 9b9aaa8e06..20baa0b82e 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -305,8 +305,6 @@ set(NS3_SRC ) set(KERNEL_SRC - src/deprecated.cpp - src/kernel/EngineImpl.cpp src/kernel/EngineImpl.hpp @@ -667,7 +665,6 @@ set(headers_to_install include/simgrid/mailbox.h include/simgrid/modelchecker.h include/simgrid/forward.h - include/simgrid/simix.h include/simgrid/simix.hpp include/simgrid/kernel/ProfileBuilder.hpp include/simgrid/kernel/Timer.hpp