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
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
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
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)=
// 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);
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)
--- /dev/null
+# 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}')
+
--- /dev/null
+#!/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
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;
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;
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
~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;
+++ /dev/null
-/* 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 <simgrid/forward.h>
-
-// 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
#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__
#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 <simgrid/engine.h>
#include <xbt/base.h>
#include <simgrid/actor.h>
#include <xbt/base.h>
-// 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
py::overload_cast<const std::string&, const std::string&, const std::string&>(&Host::create_disk),
py::call_guard<py::gil_scoped_release>(), "Create a disk")
.def("seal", &Host::seal, py::call_guard<py::gil_scoped_release>(), "Seal this host")
+ .def("turn_off", &Host::turn_off, py::call_guard<py::gil_scoped_release>(), "Turn off this host")
+ .def("turn_on", &Host::turn_on, py::call_guard<py::gil_scoped_release>(), "Turn on this host")
.def_property("pstate", &Host::get_pstate,
py::cpp_function(&Host::set_pstate, py::call_guard<py::gil_scoped_release>()),
"The current pstate (read/write property).")
"")
.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<py::gil_scoped_release>(),
+ "Initialize host load plugin.")
+ .def(
+ "reset_load", [](const Host* h) { sg_host_load_reset(h); }, py::call_guard<py::gil_scoped_release>(),
+ "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_<simgrid::s4u::Host::SharingPolicy>(host, "SharingPolicy")
.value("NONLINEAR", simgrid::s4u::Host::SharingPolicy::NONLINEAR)
// Start only Activities with dependencies solved
for (auto const& activity: dag) {
- if (dynamic_cast<Exec*>(activity.get()) != nullptr and activity->dependencies_solved())
+ if (dynamic_cast<Exec*>(activity.get()) != nullptr && activity->dependencies_solved())
activity->start();
}
return dag;
+++ /dev/null
-/* 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 <simgrid/s4u/Activity.hpp>
-
-#define SIMIX_H_NO_DEPRECATED_WARNING // avoid deprecation warning on include (remove with XBT_ATTRIB_DEPRECATED_v335)
-#include <simgrid/simix.h>
-
-#include <cmath>
-
-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<unsigned char*>(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<unsigned char*>(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<simgrid::kernel::activity::ActivityImpl*> activities;
- for (size_t i = 0; i < count; i++)
- activities.push_back(static_cast<simgrid::kernel::activity::ActivityImpl*>(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<simgrid::kernel::activity::ActivityImpl*> activities;
- for (size_t i = 0; i < count; i++)
- activities.push_back(static_cast<simgrid::kernel::activity::ActivityImpl*>(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;
-}
{
std::unordered_set<aid_t> 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);
}
}
// 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));
}
}
std::pair<aid_t, int> best_transition(bool must_be_todo) const override
{
- std::pair<aid_t, int> min_found = std::make_pair(-1, value_of_state_+2);
+ std::pair<aid_t, int> 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<CommRecvTransition const*>(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<CommRecvTransition const*>(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<CommSendTransition const*>(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<CommSendTransition const*>(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<CommRecvTransition const*>(transition);
- if (cast_recv != nullptr)
+ if (auto const* cast_recv = dynamic_cast<CommRecvTransition const*>(transition))
last_mailbox_ = cast_recv->get_mailbox();
- const CommSendTransition* cast_send = dynamic_cast<CommSendTransition const*>(transition);
- if (cast_send != nullptr)
+ if (auto const* cast_send = dynamic_cast<CommSendTransition const*>(transition))
last_mailbox_ = cast_send->get_mailbox();
}
};
std::pair<aid_t, int> best_transition(bool must_be_todo) const override
{
- std::pair<aid_t, int> min_found = std::make_pair(-1, value_of_state_+2);
+ std::pair<aid_t, int> 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<CommRecvTransition const*>(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<CommRecvTransition const*>(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<CommSendTransition const*>(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<CommSendTransition const*>(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);
}
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<CommRecvTransition const*>(transition);
- if (cast_recv != nullptr)
+ if (auto const* cast_recv = dynamic_cast<CommRecvTransition const*>(transition))
last_mailbox_ = cast_recv->get_mailbox();
- const CommSendTransition* cast_send = dynamic_cast<CommSendTransition const*>(transition);
- if (cast_send != nullptr)
+ if (auto const* cast_send = dynamic_cast<CommSendTransition const*>(transition))
last_mailbox_ = cast_send->get_mailbox();
}
};
virtual std::pair<aid_t, int> best_transition(bool must_be_todo) const = 0;
/** Returns the best transition among those that should be interleaved. */
- std::pair<aid_t, int> next_transition() { return best_transition(true); }
+ std::pair<aid_t, int> 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. */
/** 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();
// 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();
}
{
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++;
}
#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<aid_t, int> valuation;
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);
}
// 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++;
}
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));
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
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;
}
}
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`:",
// 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;
}
// 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();
}
}
}
- 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 "
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
return false;
}
-} // namespace simgrid::mc::odpor
\ No newline at end of file
+} // namespace simgrid::mc::odpor
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));
}
}
}
// 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,
{
// 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,
#include <algorithm>
#include <exception>
+#include <memory>
#include <queue>
namespace simgrid::mc::odpor {
// 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_;
}
}
}
-WakeupTree::WakeupTree() : WakeupTree(std::unique_ptr<WakeupTreeNode>(new WakeupTreeNode({}))) {}
+WakeupTree::WakeupTree() : WakeupTree(std::make_unique<WakeupTreeNode>()) {}
WakeupTree::WakeupTree(std::unique_ptr<WakeupTreeNode> root) : root_(root.get())
{
this->insert_node(std::move(root));
WakeupTreeNode* WakeupTree::make_node(std::shared_ptr<Transition> u)
{
- auto node = std::unique_ptr<WakeupTreeNode>(new WakeupTreeNode(std::move(u)));
+ auto node = std::make_unique<WakeupTreeNode>(std::move(u));
auto* node_handle = node.get();
this->nodes_[node_handle] = std::move(node);
return node_handle;
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:
*/
class WakeupTreeNode {
private:
- explicit WakeupTreeNode(std::shared_ptr<Transition> u) : action_(u) {}
-
WakeupTreeNode* parent_ = nullptr;
/** An ordered list of children of for this node in the tree */
friend WakeupTreeIterator;
public:
+ explicit WakeupTreeNode(std::shared_ptr<Transition> u) : action_(u) {}
+
+ WakeupTreeNode() = default;
~WakeupTreeNode() = default;
WakeupTreeNode(const WakeupTreeNode&) = delete;
WakeupTreeNode(WakeupTreeNode&&) = default;
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");
}
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");
}
// 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
// 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})));
}
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})));
}
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");
return contents;
}
-} // namespace simgrid::mc::udpor
\ No newline at end of file
+} // namespace simgrid::mc::udpor
// 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<const CommSendTransition*>(e->get_transition());
- async_send != nullptr) {
+ if (const auto* async_send = dynamic_cast<const CommSendTransition*>(e->get_transition())) {
return async_send->get_mailbox() == sender_mailbox;
}
// TODO: Add `TestAny` dependency
// 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<const CommRecvTransition*>(e->get_transition());
- e_issuer_receive != nullptr) {
+ if (const auto* e_issuer_receive = dynamic_cast<const CommRecvTransition*>(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<const CommSendTransition*>(e->get_transition());
- e_issuer_send != nullptr) {
+ if (const auto* e_issuer_send = dynamic_cast<const CommSendTransition*>(e->get_transition())) {
return e_issuer_send->aid_ == wait_action->aid_ && wait_comm == e_issuer_send->get_comm();
}
// as needed to reach the receive/send number that is `issuer`.
// ...
// ...
- if (const CommRecvTransition* e_issuer_receive =
- dynamic_cast<const CommRecvTransition*>(e_issuer->get_transition());
- e_issuer_receive != nullptr) {
+ if (const auto* e_issuer_receive = dynamic_cast<const CommRecvTransition*>(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<const CommSendTransition*>(e->get_transition());
- if (e_send != nullptr) {
+ if (const auto* e_send = dynamic_cast<const CommSendTransition*>(e->get_transition())) {
return e_send->get_mailbox() == issuer_mailbox;
}
return false;
// 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<const CommRecvTransition*>(e->get_transition());
- if (e_receive != nullptr) {
+ if (const auto* e_receive = dynamic_cast<const CommRecvTransition*>(e->get_transition())) {
return e_receive->get_mailbox() == issuer_mailbox;
}
return false;
exC.insert(U->discover_event(EventSet({unwrapped_pre_event}), wait_action));
}
- } else if (const CommSendTransition* e_issuer_send =
- dynamic_cast<const CommSendTransition*>(e_issuer->get_transition());
- e_issuer_send != nullptr) {
+ } else if (const auto* e_issuer_send = dynamic_cast<const CommSendTransition*>(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<const CommSendTransition*>(e->get_transition());
- if (e_send != nullptr) {
+ if (const auto* e_send = dynamic_cast<const CommSendTransition*>(e->get_transition())) {
return e_send->get_mailbox() == issuer_mailbox;
}
return false;
// 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<const CommRecvTransition*>(e->get_transition());
- if (e_receive != nullptr) {
+ if (const auto* e_receive = dynamic_cast<const CommRecvTransition*>(e->get_transition())) {
return e_receive->get_mailbox() == issuer_mailbox;
}
return false;
}
// 3. foreach event e in C do
- if (const CommSendTransition* e_issuer_send = dynamic_cast<const CommSendTransition*>(e_issuer->get_transition());
- e_issuer_send != nullptr) {
+ if (const auto* e_issuer_send = dynamic_cast<const CommSendTransition*>(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)`.
}
const auto issuer_mailbox = e_issuer_send->get_mailbox();
- const CommRecvTransition* e_recv = dynamic_cast<const CommRecvTransition*>(e->get_transition());
- if (e_recv->get_mailbox() != issuer_mailbox) {
+ if (const auto* e_recv = dynamic_cast<const CommRecvTransition*>(e->get_transition());
+ e_recv->get_mailbox() != issuer_mailbox) {
continue;
}
// 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<const CommSendTransition*>(e->get_transition());
- if (e_send != nullptr) {
+ if (const auto* e_send = dynamic_cast<const CommSendTransition*>(e->get_transition())) {
return e_send->get_mailbox() == issuer_mailbox;
}
return false;
// 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<const CommRecvTransition*>(e->get_transition());
- if (e_receive != nullptr) {
+ if (const auto* e_receive = dynamic_cast<const CommRecvTransition*>(e->get_transition())) {
return e_receive->get_mailbox() == issuer_mailbox;
}
return false;
exC.insert(U->discover_event(std::move(K), wait_action));
}
}
- } else if (const CommRecvTransition* e_issuer_recv =
- dynamic_cast<const CommRecvTransition*>(e_issuer->get_transition());
- e_issuer_recv != nullptr) {
+ } else if (const auto* e_issuer_recv = dynamic_cast<const CommRecvTransition*>(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)`.
}
const auto issuer_mailbox = e_issuer_recv->get_mailbox();
- const CommSendTransition* e_send = dynamic_cast<const CommSendTransition*>(e->get_transition());
- if (e_send->get_mailbox() != issuer_mailbox) {
+ if (const auto* e_send = dynamic_cast<const CommSendTransition*>(e->get_transition());
+ e_send->get_mailbox() != issuer_mailbox) {
continue;
}
// 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<const CommSendTransition*>(e->get_transition());
- if (e_send != nullptr) {
+ if (const auto* e_send = dynamic_cast<const CommSendTransition*>(e->get_transition())) {
return e_send->get_mailbox() == issuer_mailbox;
}
return false;
// 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<const CommRecvTransition*>(e->get_transition());
- if (e_receive != nullptr) {
+ if (const auto* e_receive = dynamic_cast<const CommRecvTransition*>(e->get_transition())) {
return e_receive->get_mailbox() == issuer_mailbox;
}
return false;
// 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<const CommRecvTransition*>(e->get_transition());
- e_issuer_receive != nullptr) {
+ if (const auto* e_issuer_receive = dynamic_cast<const CommRecvTransition*>(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<const CommSendTransition*>(e->get_transition());
- e_issuer_send != nullptr) {
+ if (const auto* e_issuer_send = dynamic_cast<const CommSendTransition*>(e->get_transition())) {
return e_issuer_send->aid_ == test_aid && test_comm == e_issuer_send->get_comm();
}
const History e_issuer_history(e_issuer);
// 3. foreach event e in C do
- if (const CommSendTransition* e_issuer_send = dynamic_cast<const CommSendTransition*>(e_issuer->get_transition());
- e_issuer_send != nullptr) {
+ if (const auto* e_issuer_send = dynamic_cast<const CommSendTransition*>(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)`.
const auto issuer_mailbox = e_issuer_send->get_mailbox();
- if (const CommRecvTransition* e_recv = dynamic_cast<const CommRecvTransition*>(e->get_transition());
+ if (const auto* e_recv = dynamic_cast<const CommRecvTransition*>(e->get_transition());
e_recv->get_mailbox() != issuer_mailbox) {
continue;
}
// 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<const CommSendTransition*>(e->get_transition());
- if (e_send != nullptr) {
+ if (const auto* e_send = dynamic_cast<const CommSendTransition*>(e->get_transition())) {
return e_send->get_mailbox() == issuer_mailbox;
}
return false;
// 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<const CommRecvTransition*>(e->get_transition());
- if (e_receive != nullptr) {
+ if (const auto* e_receive = dynamic_cast<const CommRecvTransition*>(e->get_transition())) {
return e_receive->get_mailbox() == issuer_mailbox;
}
return false;
exC.insert(U->discover_event(std::move(K), test_action));
}
}
- } else if (const CommRecvTransition* e_issuer_recv =
- dynamic_cast<const CommRecvTransition*>(e_issuer->get_transition());
- e_issuer_recv != nullptr) {
+ } else if (const auto* e_issuer_recv = dynamic_cast<const CommRecvTransition*>(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)`.
}
const auto issuer_mailbox = e_issuer_recv->get_mailbox();
- const CommSendTransition* e_send = dynamic_cast<const CommSendTransition*>(e->get_transition());
- if (e_send->get_mailbox() != issuer_mailbox) {
+ if (const auto* e_send = dynamic_cast<const CommSendTransition*>(e->get_transition());
+ e_send->get_mailbox() != issuer_mailbox) {
continue;
}
// 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<const CommSendTransition*>(e->get_transition());
- if (e_send != nullptr) {
+ if (const auto* e_send = dynamic_cast<const CommSendTransition*>(e->get_transition())) {
return e_send->get_mailbox() == issuer_mailbox;
}
return false;
// 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<const CommRecvTransition*>(e->get_transition());
- if (e_receive != nullptr) {
+ if (const auto* e_receive = dynamic_cast<const CommRecvTransition*>(e->get_transition())) {
return e_receive->get_mailbox() == issuer_mailbox;
}
return false;
// 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<const MutexTransition*>(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<const MutexTransition*>(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;
// for each event e in C
for (const auto e : C) {
// Check for MutexTest
- if (const MutexTransition* e_mutex = dynamic_cast<const MutexTransition*>(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<const MutexTransition*>(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;
// for each event e in C
for (const auto e : C) {
// Check for any unlocks
- if (const MutexTransition* e_mutex = dynamic_cast<const MutexTransition*>(e->get_transition());
+ if (const auto* e_mutex = dynamic_cast<const MutexTransition*>(e->get_transition());
e_mutex != nullptr && e_mutex->type_ == Transition::Type::MUTEX_UNLOCK) {
// TODO: Check if dependent or not
// This entails getting information about
// 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);
// for each event e in C
for (const auto e : C) {
// Check for any unlocks
- if (const MutexTransition* e_mutex = dynamic_cast<const MutexTransition*>(e->get_transition());
+ if (const auto* e_mutex = dynamic_cast<const MutexTransition*>(e->get_transition());
e_mutex != nullptr && e_mutex->type_ == Transition::Type::MUTEX_UNLOCK) {
// TODO: Check if dependent or not
// This entails getting information about
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
[&](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
}
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 {
Transition* get_current_transition() const { return transitions_.at(times_considered_); }
bool result() const
{
- for (Transition* transition : transitions_) {
- CommTestTransition* tested_transition = static_cast<CommTestTransition*>(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<const CommTestTransition*>(transition);
+ return (tested_transition->get_sender() != -1 && tested_transition->get_receiver() != -1);
+ });
}
};
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;
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_) {
{
ensure_plugin_inited();
return host->extension<Photovoltaic>()->get_power();
-}
\ No newline at end of file
+}
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()) {
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<std::string, std::string>* 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
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_)
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();
}
template <typename Iterator> void powerset_iterator<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
}
template <typename Iterator> bool subsets_iterator<Iterator>::equal(const subsets_iterator<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) {
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 <typename Iterator> const std::vector<Iterator>& subsets_iterator<Iterator>::dereference() const
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);
{
// 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;
}
#include "simgrid/engine.h"
#include <xbt.h>
-#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)
)
set(KERNEL_SRC
- src/deprecated.cpp
-
src/kernel/EngineImpl.cpp
src/kernel/EngineImpl.hpp
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