SimGrid (3.32.1) not released yet (target december 22)
General:
+ - SimGrid now requires a compiler with C++17 support for public headers too.
+ Sibling projects should upgrade their FindSimGrid.cmake
- Remove the MSG API: its EOL was scheduled for 2020.
- Remove the Java bindings: they were limited to the MSG interface.
- On Windows, you now need to install WSL2 as the native builds are now disabled.
It was not really working anyway.
- Support for 32bits architecture is not tested anymore on our CI infrastructure.
It may break in the future, but we think that nobody's using SimGrid on 32 bits.
- - Remove the surf module. It was replaced by the kernel/models module, and that
+ - Remove the surf module. It was replaced by the kernel/models module, and that
refactoring took almost 10 years to properly complete.
S4U:
- Synchronize the MBI tests with upstream.
- Show the full actor bactraces when replaying a MC trace (with model-check/replay)
and the status of all actors on deadlocks in MC mode.
- - The safety/stateless aspects of the MC are now enabled by default in all simgrid builds.
- Liveness and stateful aspects are still controled by the enabling_model-checking
+ - The safety/stateless aspects of the MC are now enabled by default in all simgrid builds.
+ Liveness and stateful aspects are still controled by the enabling_model-checking
configuration option.
- Stateless model-checking is now usable on any system, including Mac OSX and ARM processors.
Important user-visible changes:
- SimGrid now requires a compiler with C++14 support.
- Sibling projects should upgrade their FindSimgrid.cmake
+ Sibling projects should upgrade their FindSimGrid.cmake
- Surf precision default value is now 1e-9, instead of 1e-5. This was changed as
several users had difficulties to understand issues when using high bandwidth or
small latency events. The new value was already the default for SMPI and
# (code to use with SimGrid v3.19+)
# #endif
#
-# Since SimGrid header files require C++14, so we set CMAKE_CXX_STANDARD to 14.
+# Since SimGrid header files require C++17, so we set CMAKE_CXX_STANDARD to 17.
# Change this variable in your own file if you need a later standard.
#
cmake_minimum_required(VERSION 2.8.12)
-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_path(SimGrid_INCLUDE_DIR
INTERFACE_COMPILE_FEATURES cxx_alias_templates
IMPORTED_LOCATION ${SimGrid_LIBRARY}
)
- # We need C++14, so check for it just in case the user removed it since compiling SimGrid
+ # We need C++17, so check for it just in case the user removed it since compiling SimGrid
if (NOT CMAKE_VERSION VERSION_LESS 3.8)
- # 3.8+ allows us to simply require C++14 (or higher)
- set_property(TARGET SimGrid::SimGrid PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_14)
- elseif (NOT CMAKE_VERSION VERSION_LESS 3.1)
- # 3.1+ is similar but for certain features. We pick just one
- set_property(TARGET SimGrid::SimGrid PROPERTY INTERFACE_COMPILE_FEATURES cxx_attribute_deprecated)
+ # 3.8+ allows us to simply require C++17 (or higher)
+ set_property(TARGET SimGrid::SimGrid PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_17)
else ()
- # Old CMake can't do much. Just check the CXX_FLAGS and inform the user when a C++14 feature does not work
+ # Old CMake can't do much. Just check the CXX_FLAGS and inform the user when a C++17 feature does not work
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS}")
check_cxx_source_compiles("
-#if __cplusplus < 201402L
+#if __cplusplus < 201703L
#error
#else
int main(){}
#endif
-" _SIMGRID_CXX14_ENABLED)
- if (NOT _SIMGRID_CXX14_ENABLED)
- message(WARNING "C++14 is required to use SimGrid. Enable it with e.g. -std=c++14")
+" _SIMGRID_CXX17_ENABLED)
+ if (NOT _SIMGRID_CXX17_ENABLED)
+ message(WARNING "C++17 is required to use SimGrid. Enable it with e.g. -std=c++17")
endif ()
unset(_SIMGRID_CXX14_ENABLED CACHE)
endif ()
include examples/cpp/network-ns3/s4u-network-ns3.cpp
include examples/cpp/network-wifi/s4u-network-wifi.cpp
include examples/cpp/network-wifi/s4u-network-wifi.tesh
+include examples/cpp/operation-io/s4u-operation-io.cpp
+include examples/cpp/operation-io/s4u-operation-io.tesh
include examples/cpp/operation-simple/s4u-operation-simple.cpp
include examples/cpp/operation-simple/s4u-operation-simple.tesh
include examples/cpp/operation-switch-host/s4u-operation-switch-host.cpp
@code{cpp}
template<class F>
-typename std::result_of<F()>::type kernelImmediate(F&& code)
+typename std::result_of_t<F()> kernelImmediate(F&& code)
{
// If we are in the simulation kernel, we take the fast path and
// execute the code directly without simcall
// If we are in the application, pass the code to the simulation
// kernel which executes it for us and reports the result:
- typedef typename std::result_of<F()>::type R;
+ typedef typename std::result_of_t<F()> R;
simgrid::xbt::Result<R> result;
simcall_run_kernel([&]{
xbt_assert(SIMIX_is_maestro(), "Not in maestro");
cmake_minimum_required(VERSION 2.8.12)
project(MyFirstSimulator)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
find_package(SimGrid REQUIRED)
If you wish to develop your plugin or modify SimGrid using
Eclipse. You have to run cmake and import it as a Makefile project.
-Next, you have to activate C++14 in your build settings, add -std=c++14
+Next, you have to activate C++17 in your build settings, add -std=c++17
in the CDT GCC Built-in compiler settings.
.. image:: /img/eclipseScreenShot.png
cmake_minimum_required(VERSION 2.8.12)
project(tuto_disk)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/" "../../../")
find_package(SimGrid REQUIRED)
cmake_minimum_required(VERSION 2.8.12)
project(tuto_network)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/" "../../../")
find_package(SimGrid REQUIRED)
mc-bugged1 mc-bugged1-liveness mc-bugged2 mc-bugged2-liveness mc-centralized-mutex mc-electric-fence mc-failing-assert
network-ns3 network-ns3-wifi network-wifi
io-async io-priority io-degradation io-file-system io-file-remote io-disk-raw io-dependent
- operation-simple operation-variable-load operation-switch-host
+ operation-io operation-simple operation-variable-load operation-switch-host
platform-comm-serialize platform-failures platform-profile platform-properties
plugin-host-load plugin-link-load plugin-prodcons
replay-comm replay-io
--setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
--cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-nodpor.tesh)
- endif()
+ endif()
set(tesh_files ${tesh_files} ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-statequality.tesh)
set(tesh_files ${tesh_files} ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-nodpor.tesh)
endforeach()
(a.dependencies_solved() ? "solved" : "NOT solved"), (a.is_assigned() ? "assigned" : "NOT assigned"));
});
- sg4::Activity::on_completion_cb([](sg4::Activity const& activity) {
- if (const auto* exec = dynamic_cast<sg4::Exec const*>(&activity))
- XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec->get_cname(), exec->get_start_time(),
- exec->get_finish_time());
- if (const auto* comm = dynamic_cast<sg4::Comm const*>(&activity))
- XBT_INFO("Activity '%s' is complete", comm->get_cname());
+ sg4::Exec::on_completion_cb([](sg4::Exec const& exec) {
+ XBT_INFO("Exec '%s' is complete (start time: %f, finish time: %f)", exec.get_cname(), exec.get_start_time(),
+ exec.get_finish_time());
+ });
+ sg4::Comm::on_completion_cb([](sg4::Comm const& comm) {
+ XBT_INFO("Comm '%s' is complete", comm.get_cname());
});
// Create a small DAG: parent->transfer->child
> [ 0.000000] (0:maestro@) Activity 'transfer' vetoed. Dependencies: NOT solved; Ressources: NOT assigned
> [ 0.000000] (0:maestro@) Activity 'child' vetoed. Dependencies: NOT solved; Ressources: assigned
> [ 0.000000] (0:maestro@) Activity 'transfer' vetoed. Dependencies: NOT solved; Ressources: assigned
-> [ 1.000000] (0:maestro@) Activity 'parent' is complete (start time: 0.000000, finish time: 1.000000)
+> [ 1.000000] (0:maestro@) Exec 'parent' is complete (start time: 0.000000, finish time: 1.000000)
> [ 1.000000] (0:maestro@) Remove a dependency from 'parent' on 'transfer'
> [ 1.000000] (0:maestro@) 'transfer' is assigned to a resource and all dependencies are solved. Let's start
-> [ 2.083775] (0:maestro@) Activity 'transfer' is complete
+> [ 2.083775] (0:maestro@) Comm 'transfer' is complete
> [ 2.083775] (0:maestro@) Remove a dependency from 'transfer' on 'child'
> [ 2.083775] (0:maestro@) 'child' is assigned to a resource and all dependencies are solved. Let's start
-> [ 3.083775] (0:maestro@) Activity 'child' is complete (start time: 2.083775, finish time: 3.083775)
+> [ 3.083775] (0:maestro@) Exec 'child' is complete (start time: 2.083775, finish time: 3.083775)
> [ 3.083775] (0:maestro@) Simulation time 3.08378
auto* faulty = e.host_by_name("Faulty Host");
auto* safe = e.host_by_name("Safe Host");
- sg4::Activity::on_completion_cb([](sg4::Activity const& activity) {
- const auto* exec = dynamic_cast<sg4::Exec const*>(&activity);
- if (exec == nullptr) // Only Execs are concerned here
- return;
- if (exec->get_state() == sg4::Activity::State::FINISHED)
- XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec->get_cname(), exec->get_start_time(),
- exec->get_finish_time());
- if (exec->get_state() == sg4::Activity::State::FAILED) {
- if (exec->is_parallel())
- XBT_INFO("Activity '%s' has failed. %.f %% remain to be done", exec->get_cname(),
- 100 * exec->get_remaining_ratio());
+ sg4::Exec::on_completion_cb([](sg4::Exec const& exec) {
+ if (exec.get_state() == sg4::Activity::State::FINISHED)
+ XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec.get_cname(), exec.get_start_time(),
+ exec.get_finish_time());
+ if (exec.get_state() == sg4::Activity::State::FAILED) {
+ if (exec.is_parallel())
+ XBT_INFO("Activity '%s' has failed. %.f %% remain to be done", exec.get_cname(),
+ 100 * exec.get_remaining_ratio());
else
- XBT_INFO("Activity '%s' has failed. %.f flops remain to be done", exec->get_cname(), exec->get_remaining());
+ XBT_INFO("Activity '%s' has failed. %.f flops remain to be done", exec.get_cname(), exec.get_remaining());
}
});
}
}
- simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
- XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(),
- activity.get_start_time(), activity.get_finish_time());
+ simgrid::s4u::Exec::on_completion_cb([](simgrid::s4u::Exec const& exec) {
+ XBT_INFO("Exec '%s' is complete (start time: %f, finish time: %f)", exec.get_cname(),
+ exec.get_start_time(), exec.get_finish_time());
+ });
+
+ simgrid::s4u::Comm::on_completion_cb([](simgrid::s4u::Comm const& comm) {
+ XBT_INFO("Comm '%s' is complete (start time: %f, finish time: %f)", comm.get_cname(),
+ comm.get_start_time(), comm.get_finish_time());
});
e.run();
#!/usr/bin/env tesh
$ ${bindir:=.}/s4u-dag-from-dax-simple --log=no_loc ${platfdir}/small_platform.xml ${srcdir:=.}/dag.xml
-> [0.000000] [dag_from_dax_simple/INFO] Activity 'root' is complete (start time: 0.000000, finish time: 0.000000)
-> [33.394394] [dag_from_dax_simple/INFO] Activity 'root_i2_2@c2' is complete (start time: 0.000000, finish time: 33.394394)
-> [39.832311] [dag_from_dax_simple/INFO] Activity 'root_i1_1@c1' is complete (start time: 0.000000, finish time: 39.832311)
-> [467.988690] [dag_from_dax_simple/INFO] Activity '1@c1' is complete (start time: 39.832311, finish time: 467.988690)
-> [543.077868] [dag_from_dax_simple/INFO] Activity '1@c1_o1_3@c3' is complete (start time: 467.988690, finish time: 543.077868)
-> [2785.832267] [dag_from_dax_simple/INFO] Activity '2@c2' is complete (start time: 33.394394, finish time: 2785.832267)
-> [3886.807417] [dag_from_dax_simple/INFO] Activity '3@c3' is complete (start time: 2785.832267, finish time: 3886.807417)
-> [3887.221639] [dag_from_dax_simple/INFO] Activity '3@c3_o3_end' is complete (start time: 3886.807417, finish time: 3887.221639)
-> [3887.221639] [dag_from_dax_simple/INFO] Activity 'end' is complete (start time: 3887.221639, finish time: 3887.221639)
\ No newline at end of file
+> [0.000000] [dag_from_dax_simple/INFO] Exec 'root' is complete (start time: 0.000000, finish time: 0.000000)
+> [33.394394] [dag_from_dax_simple/INFO] Comm 'root_i2_2@c2' is complete (start time: 0.000000, finish time: 33.394394)
+> [39.832311] [dag_from_dax_simple/INFO] Comm 'root_i1_1@c1' is complete (start time: 0.000000, finish time: 39.832311)
+> [467.988690] [dag_from_dax_simple/INFO] Exec '1@c1' is complete (start time: 39.832311, finish time: 467.988690)
+> [543.077868] [dag_from_dax_simple/INFO] Comm '1@c1_o1_3@c3' is complete (start time: 467.988690, finish time: 543.077868)
+> [2785.832267] [dag_from_dax_simple/INFO] Exec '2@c2' is complete (start time: 33.394394, finish time: 2785.832267)
+> [3886.807417] [dag_from_dax_simple/INFO] Exec '3@c3' is complete (start time: 2785.832267, finish time: 3886.807417)
+> [3887.221639] [dag_from_dax_simple/INFO] Comm '3@c3_o3_end' is complete (start time: 3886.807417, finish time: 3887.221639)
+> [3887.221639] [dag_from_dax_simple/INFO] Exec 'end' is complete (start time: 3887.221639, finish time: 3887.221639)
\ No newline at end of file
}
}
- simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
- XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(),
- activity.get_start_time(), activity.get_finish_time());
+ simgrid::s4u::Exec::on_completion_cb([](simgrid::s4u::Exec const& exec) {
+ XBT_INFO("Exec '%s' is complete (start time: %f, finish time: %f)", exec.get_cname(),
+ exec.get_start_time(), exec.get_finish_time());
+ });
+
+ simgrid::s4u::Comm::on_completion_cb([](simgrid::s4u::Comm const& comm) {
+ XBT_INFO("Comm '%s' is complete (start time: %f, finish time: %f)", comm.get_cname(),
+ comm.get_start_time(), comm.get_finish_time());
});
e.run();
#!/usr/bin/env tesh
$ ${bindir:=.}/s4u-dag-from-dot-simple --log=no_loc ${platfdir}/small_platform.xml ${srcdir:=.}/dag.dot
-> [0.000000] [dag_from_dot_simple/INFO] Activity 'root' is complete (start time: 0.000000, finish time: 0.000000)
-> [33.394394] [dag_from_dot_simple/INFO] Activity 'root->c2' is complete (start time: 0.000000, finish time: 33.394394)
-> [39.832311] [dag_from_dot_simple/INFO] Activity 'root->c1' is complete (start time: 0.000000, finish time: 39.832311)
-> [50.026511] [dag_from_dot_simple/INFO] Activity 'c1' is complete (start time: 39.832311, finish time: 50.026511)
-> [98.928629] [dag_from_dot_simple/INFO] Activity 'c2' is complete (start time: 33.394394, finish time: 98.928629)
-> [125.115689] [dag_from_dot_simple/INFO] Activity 'c1->c3' is complete (start time: 50.026511, finish time: 125.115689)
-> [151.329383] [dag_from_dot_simple/INFO] Activity 'c3' is complete (start time: 125.115689, finish time: 151.329383)
-> [151.743605] [dag_from_dot_simple/INFO] Activity 'c3->end' is complete (start time: 151.329383, finish time: 151.743605)
-> [151.743605] [dag_from_dot_simple/INFO] Activity 'end' is complete (start time: 151.743605, finish time: 151.743605)
\ No newline at end of file
+> [0.000000] [dag_from_dot_simple/INFO] Exec 'root' is complete (start time: 0.000000, finish time: 0.000000)
+> [33.394394] [dag_from_dot_simple/INFO] Comm 'root->c2' is complete (start time: 0.000000, finish time: 33.394394)
+> [39.832311] [dag_from_dot_simple/INFO] Comm 'root->c1' is complete (start time: 0.000000, finish time: 39.832311)
+> [50.026511] [dag_from_dot_simple/INFO] Exec 'c1' is complete (start time: 39.832311, finish time: 50.026511)
+> [98.928629] [dag_from_dot_simple/INFO] Exec 'c2' is complete (start time: 33.394394, finish time: 98.928629)
+> [125.115689] [dag_from_dot_simple/INFO] Comm 'c1->c3' is complete (start time: 50.026511, finish time: 125.115689)
+> [151.329383] [dag_from_dot_simple/INFO] Exec 'c3' is complete (start time: 125.115689, finish time: 151.329383)
+> [151.743605] [dag_from_dot_simple/INFO] Comm 'c3->end' is complete (start time: 151.329383, finish time: 151.743605)
+> [151.743605] [dag_from_dot_simple/INFO] Exec 'end' is complete (start time: 151.743605, finish time: 151.743605)
\ No newline at end of file
std::vector<simgrid::s4u::ActivityPtr> dag = simgrid::s4u::create_DAG_from_json(argv[2]);
- simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
- XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(),
- activity.get_start_time(), activity.get_finish_time());
+ simgrid::s4u::Exec::on_completion_cb([](simgrid::s4u::Exec const& exec) {
+ XBT_INFO("Exec '%s' is complete (start time: %f, finish time: %f)", exec.get_cname(),
+ exec.get_start_time(), exec.get_finish_time());
+ });
+
+ simgrid::s4u::Comm::on_completion_cb([](simgrid::s4u::Comm const& comm) {
+ XBT_INFO("Comm '%s' is complete (start time: %f, finish time: %f)", comm.get_cname(),
+ comm.get_start_time(), comm.get_finish_time());
});
e.run();
#!/usr/bin/env tesh
$ ${bindir:=.}/s4u-dag-from-json-simple --log=no_loc ${platfdir}/small_platform.xml ${srcdir:=.}/dag.json
-> [10.194200] [dag_from_json_simple/INFO] Activity 'c1' is complete (start time: 0.000000, finish time: 10.194200)
-> [65.534235] [dag_from_json_simple/INFO] Activity 'c2' is complete (start time: 0.000000, finish time: 65.534235)
-> [85.283378] [dag_from_json_simple/INFO] Activity 't1' is complete (start time: 10.194200, finish time: 85.283378)
-> [111.497072] [dag_from_json_simple/INFO] Activity 'c3' is complete (start time: 85.283378, finish time: 111.497072)
\ No newline at end of file
+> [10.194200] [dag_from_json_simple/INFO] Exec 'c1' is complete (start time: 0.000000, finish time: 10.194200)
+> [65.534235] [dag_from_json_simple/INFO] Exec 'c2' is complete (start time: 0.000000, finish time: 65.534235)
+> [85.283378] [dag_from_json_simple/INFO] Comm 't1' is complete (start time: 10.194200, finish time: 85.283378)
+> [111.497072] [dag_from_json_simple/INFO] Exec 'c3' is complete (start time: 85.283378, finish time: 111.497072)
\ No newline at end of file
(a.dependencies_solved() ? "solved" : "NOT solved"), (a.is_assigned() ? "assigned" : "NOT assigned"));
});
- sg4::Activity::on_completion_cb([](sg4::Activity const& activity) {
- const auto* exec = dynamic_cast<sg4::Exec const*>(&activity);
- if (exec == nullptr) // Only Execs are concerned here
- return;
- XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec->get_cname(), exec->get_start_time(),
- exec->get_finish_time());
+ sg4::Exec::on_completion_cb([](sg4::Exec const& exec) {
+ XBT_INFO("Exec '%s' is complete (start time: %f, finish time: %f)", exec.get_cname(), exec.get_start_time(),
+ exec.get_finish_time());
});
// Create a small DAG: parent->write_output->read_input->child
> [ 0.000000] (0:maestro@) Activity 'write' vetoed. Dependencies: NOT solved; Ressources: assigned
> [ 0.000000] (0:maestro@) Activity 'read' vetoed. Dependencies: NOT solved; Ressources: assigned
> [ 0.000000] (0:maestro@) Activity 'child' vetoed. Dependencies: NOT solved; Ressources: assigned
-> [ 1.000000] (0:maestro@) Activity 'parent' is complete (start time: 0.000000, finish time: 1.000000)
+> [ 1.000000] (0:maestro@) Exec 'parent' is complete (start time: 0.000000, finish time: 1.000000)
> [ 1.000000] (0:maestro@) Remove a dependency from 'parent' on 'write'
> [ 1.000000] (0:maestro@) 'write' is assigned to a resource and all dependencies are solved. Let's start
> [ 26.000000] (0:maestro@) Remove a dependency from 'write' on 'read'
> [ 26.000000] (0:maestro@) 'read' is assigned to a resource and all dependencies are solved. Let's start
> [ 36.000000] (0:maestro@) Remove a dependency from 'read' on 'child'
> [ 36.000000] (0:maestro@) 'child' is assigned to a resource and all dependencies are solved. Let's start
-> [ 37.000000] (0:maestro@) Activity 'child' is complete (start time: 36.000000, finish time: 37.000000)
+> [ 37.000000] (0:maestro@) Exec 'child' is complete (start time: 36.000000, finish time: 37.000000)
> [ 37.000000] (0:maestro@) Simulation time 37
std::set<sg4::Activity*> vetoed;
e.track_vetoed_activities(&vetoed);
- sg4::Activity::on_completion_cb([](sg4::Activity const& activity) {
+ sg4::Exec::on_completion_cb([](sg4::Exec const& exec) {
// when an Exec completes, we need to set the potential start time of all its ouput comms
- const auto* exec = dynamic_cast<sg4::Exec const*>(&activity);
- if (exec == nullptr) // Only Execs are concerned here
- return;
- for (const auto& succ : exec->get_successors()) {
+ for (const auto& succ : exec.get_successors()) {
auto* comm = dynamic_cast<sg4::Comm*>(succ.get());
if (comm != nullptr) {
- auto* finish_time = new double(exec->get_finish_time());
+ auto* finish_time = new double(exec.get_finish_time());
// We use the user data field to store the finish time of the predecessor of the comm, i.e., its potential start
// time
comm->set_data(finish_time);
(exec.is_assigned() ? "assigned" : "NOT assigned"));
});
- sg4::Activity::on_completion_cb([](sg4::Activity const& activity) {
- const auto* exec = dynamic_cast<sg4::Exec const*>(&activity);
- if (exec == nullptr) // Only Execs are concerned here
- return;
- XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec->get_cname(), exec->get_start_time(),
- exec->get_finish_time());
+ sg4::Exec::on_completion_cb([](sg4::Exec const& exec) {
+ XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec.get_cname(), exec.get_start_time(),
+ exec.get_finish_time());
});
// Define an amount of work that should take 1 second to execute.
c1->start();
c2->start();
- simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
- XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", activity.get_cname(),
- activity.get_start_time(), activity.get_finish_time());
+ simgrid::s4u::Exec::on_completion_cb([](simgrid::s4u::Exec const& exec) {
+ XBT_INFO("Exec '%s' is complete (start time: %f, finish time: %f)", exec.get_cname(),
+ exec.get_start_time(), exec.get_finish_time());
+ });
+ simgrid::s4u::Comm::on_completion_cb([](simgrid::s4u::Comm const& comm) {
+ XBT_INFO("Comm '%s' is complete (start time: %f, finish time: %f)", comm.get_cname(),
+ comm.get_start_time(), comm.get_finish_time());
});
e.run();
#!/usr/bin/env tesh
$ ${bindir:=.}/s4u-dag-tuto --log=no_loc ${platfdir}/small_platform.xml
-> [10.194200] [dag_tuto/INFO] Activity 'c1' is complete (start time: 0.000000, finish time: 10.194200)
-> [65.534235] [dag_tuto/INFO] Activity 'c2' is complete (start time: 0.000000, finish time: 65.534235)
-> [85.283378] [dag_tuto/INFO] Activity 't1' is complete (start time: 10.194200, finish time: 85.283378)
-> [111.497072] [dag_tuto/INFO] Activity 'c3' is complete (start time: 85.283378, finish time: 111.497072)
\ No newline at end of file
+> [10.194200] [dag_tuto/INFO] Exec 'c1' is complete (start time: 0.000000, finish time: 10.194200)
+> [65.534235] [dag_tuto/INFO] Exec 'c2' is complete (start time: 0.000000, finish time: 65.534235)
+> [85.283378] [dag_tuto/INFO] Comm 't1' is complete (start time: 10.194200, finish time: 85.283378)
+> [111.497072] [dag_tuto/INFO] Exec 'c3' is complete (start time: 85.283378, finish time: 111.497072)
\ No newline at end of file
--- /dev/null
+/* Copyright (c) 2017-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. */
+
+/* This example demonstrate basic use of the operation plugin.
+ *
+ * We model the following graph:
+ *
+ * exec1 -> comm -> exec2
+ *
+ * exec1 and exec2 are execution operations.
+ * comm is a communication operation.
+ */
+
+#include <simgrid/plugins/file_system.h>
+#include "simgrid/plugins/operation.hpp"
+#include "simgrid/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(operation_simple, "Messages specific for this operation example");
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine e(&argc, argv);
+ sg_storage_file_system_init();
+ e.load_platform(argv[1]);
+ simgrid::plugins::Operation::init();
+
+ // Retrieve hosts
+ auto bob = e.host_by_name("bob");
+ auto carl = e.host_by_name("carl");
+
+ // Create operations
+ auto exec1 = simgrid::plugins::ExecOp::init("exec1", 1e9, bob);
+ auto exec2 = simgrid::plugins::ExecOp::init("exec2", 1e9, carl);
+ auto write = simgrid::plugins::IoOp::init("write", 1e7, bob->get_disks().front(), simgrid::s4u::Io::OpType::WRITE);
+ auto read = simgrid::plugins::IoOp::init("read", 1e7, carl->get_disks().front(), simgrid::s4u::Io::OpType::READ);
+
+ // Create the graph by defining dependencies between operations
+ exec1->add_successor(write);
+ write->add_successor(read);
+ read->add_successor(exec2);
+
+ // Add a function to be called when operations end for log purpose
+ simgrid::plugins::Operation::on_end_cb([](const simgrid::plugins::Operation* op) {
+ XBT_INFO("Operation %s finished (%d)", op->get_name().c_str(), op->get_count());
+ });
+
+ // Enqueue two executions for operation exec1
+ exec1->enqueue_execs(2);
+
+ // Start the simulation
+ e.run();
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-operation-io ${platfdir}/hosts_with_disks.xml
+> [1.000000] [operation_simple/INFO] Operation exec1 finished (1)
+> [1.250000] [operation_simple/INFO] Operation write finished (1)
+> [1.350000] [operation_simple/INFO] Operation read finished (1)
+> [2.000000] [operation_simple/INFO] Operation exec1 finished (2)
+> [2.250000] [operation_simple/INFO] Operation write finished (2)
+> [2.350000] [operation_simple/INFO] Operation exec2 finished (1)
+> [2.350000] [operation_simple/INFO] Operation read finished (2)
+> [3.350000] [operation_simple/INFO] Operation exec2 finished (2)
> %EndEventDef
> 0 1 0 HOST
> 6 0.000000 1 1 0 "Tremblay"
+> 2 2 1 HOST_STATE
+> 5 3 2 receive "1 0 0"
+> 5 4 2 send "0 0 1"
+> 5 5 2 execute "0 1 1"
> 6 0.000000 2 1 0 "Jupiter"
> 6 0.000000 3 1 0 "Fafard"
> 6 0.000000 4 1 0 "Ginette"
> 6 0.000000 5 1 0 "Bourassa"
> 6 0.000000 6 1 0 "Jacquelin"
> 6 0.000000 7 1 0 "Boivin"
-> 0 2 0 LINK
-> 6 0.000000 8 2 0 "6"
-> 6 0.000000 9 2 0 "3"
-> 6 0.000000 10 2 0 "7"
-> 6 0.000000 11 2 0 "9"
-> 6 0.000000 12 2 0 "2"
-> 6 0.000000 13 2 0 "8"
-> 6 0.000000 14 2 0 "1"
-> 6 0.000000 15 2 0 "4"
-> 6 0.000000 16 2 0 "0"
-> 6 0.000000 17 2 0 "5"
-> 6 0.000000 18 2 0 "145"
-> 6 0.000000 19 2 0 "10"
-> 6 0.000000 20 2 0 "11"
-> 6 0.000000 21 2 0 "16"
-> 6 0.000000 22 2 0 "17"
-> 6 0.000000 23 2 0 "44"
-> 6 0.000000 24 2 0 "47"
-> 6 0.000000 25 2 0 "54"
-> 6 0.000000 26 2 0 "56"
-> 6 0.000000 27 2 0 "59"
-> 6 0.000000 28 2 0 "78"
-> 6 0.000000 29 2 0 "79"
-> 6 0.000000 30 2 0 "80"
-> 6 0.000000 31 2 0 "loopback"
-> 4 3 0 2 2 0-LINK2-LINK2
-> 4 4 0 1 2 0-HOST1-LINK2
-> 4 5 0 2 1 0-LINK2-HOST1
-> 15 0.000000 3 0 topology 12 0
-> 16 0.000000 3 0 topology 16 0
-> 15 0.000000 3 0 topology 9 1
-> 16 0.000000 3 0 topology 16 1
-> 15 0.000000 3 0 topology 16 2
-> 16 0.000000 3 0 topology 14 2
-> 15 0.000000 3 0 topology 21 3
-> 16 0.000000 3 0 topology 19 3
-> 15 0.000000 3 0 topology 8 4
-> 16 0.000000 3 0 topology 19 4
-> 15 0.000000 3 0 topology 19 5
-> 16 0.000000 3 0 topology 20 5
-> 15 0.000000 3 0 topology 8 6
-> 16 0.000000 3 0 topology 20 6
-> 15 0.000000 3 0 topology 27 7
-> 16 0.000000 3 0 topology 18 7
-> 15 0.000000 4 0 topology 5 8
-> 16 0.000000 4 0 topology 18 8
-> 15 0.000000 4 0 topology 4 9
-> 16 0.000000 4 0 topology 18 9
-> 15 0.000000 4 0 topology 2 10
-> 16 0.000000 4 0 topology 18 10
-> 15 0.000000 3 0 topology 16 11
-> 16 0.000000 3 0 topology 21 11
-> 15 0.000000 3 0 topology 21 12
-> 16 0.000000 3 0 topology 22 12
-> 15 0.000000 3 0 topology 9 13
-> 16 0.000000 3 0 topology 12 13
-> 15 0.000000 3 0 topology 15 14
-> 16 0.000000 3 0 topology 9 14
-> 15 0.000000 4 0 topology 1 15
-> 16 0.000000 4 0 topology 9 15
-> 15 0.000000 3 0 topology 20 16
-> 16 0.000000 3 0 topology 23 16
-> 15 0.000000 3 0 topology 23 17
-> 16 0.000000 3 0 topology 24 17
-> 15 0.000000 4 0 topology 5 18
-> 16 0.000000 4 0 topology 24 18
-> 15 0.000000 4 0 topology 4 19
-> 16 0.000000 4 0 topology 24 19
-> 15 0.000000 4 0 topology 2 20
-> 16 0.000000 4 0 topology 24 20
-> 15 0.000000 3 0 topology 11 21
-> 16 0.000000 3 0 topology 15 21
-> 15 0.000000 4 0 topology 1 22
-> 16 0.000000 4 0 topology 15 22
-> 15 0.000000 3 0 topology 12 23
-> 16 0.000000 3 0 topology 17 23
-> 15 0.000000 3 0 topology 9 24
-> 16 0.000000 3 0 topology 17 24
-> 15 0.000000 3 0 topology 22 25
-> 16 0.000000 3 0 topology 25 25
-> 15 0.000000 3 0 topology 12 26
-> 16 0.000000 3 0 topology 25 26
-> 15 0.000000 3 0 topology 25 27
-> 16 0.000000 3 0 topology 26 27
-> 15 0.000000 3 0 topology 26 28
-> 16 0.000000 3 0 topology 27 28
-> 15 0.000000 3 0 topology 14 29
-> 16 0.000000 3 0 topology 8 29
-> 15 0.000000 3 0 topology 13 30
-> 16 0.000000 3 0 topology 8 30
-> 15 0.000000 3 0 topology 11 31
-> 16 0.000000 3 0 topology 8 31
-> 15 0.000000 3 0 topology 8 32
-> 16 0.000000 3 0 topology 10 32
-> 15 0.000000 3 0 topology 30 33
-> 16 0.000000 3 0 topology 28 33
-> 15 0.000000 4 0 topology 3 34
-> 16 0.000000 4 0 topology 28 34
-> 15 0.000000 3 0 topology 28 35
-> 16 0.000000 3 0 topology 29 35
-> 15 0.000000 4 0 topology 3 36
-> 16 0.000000 4 0 topology 30 36
-> 15 0.000000 3 0 topology 14 37
-> 16 0.000000 3 0 topology 13 37
-> 15 0.000000 3 0 topology 29 38
-> 16 0.000000 3 0 topology 11 38
-> 15 0.000000 4 0 topology 1 39
-> 16 0.000000 4 0 topology 11 39
-> 15 0.000000 5 0 topology 24 40
-> 16 0.000000 5 0 topology 7 40
-> 15 0.000000 5 0 topology 10 41
-> 16 0.000000 5 0 topology 5 41
-> 15 0.000000 5 0 topology 13 42
-> 16 0.000000 5 0 topology 3 42
-> 15 0.000000 5 0 topology 17 43
-> 16 0.000000 5 0 topology 4 43
-> 15 0.000000 5 0 topology 18 44
-> 16 0.000000 5 0 topology 6 44
-> 15 0.000000 5 0 topology 11 45
-> 16 0.000000 5 0 topology 2 45
-> 0 6 1 ACTOR
-> 6 0.000000 32 6 3 "emigrant-1"
-> 2 7 6 ACTOR_STATE
-> 5 8 7 suspend "1 0 1"
-> 5 9 7 sleep "1 1 0"
-> 5 10 7 receive "1 0 0"
-> 5 11 7 send "0 0 1"
-> 5 12 7 execute "0 1 1"
-> 4 13 0 6 6 ACTOR_LINK
-> 6 0.000000 33 6 1 "policeman-2"
-> 12 0.000000 7 32 9
-> 12 0.000000 7 33 11
-> 13 2.000000 7 32
-> 12 2.000000 7 32 10
-> 13 2.025708 7 33
-> 12 2.025708 7 33 11
-> 13 2.025708 7 32
-> 15 2.025708 13 0 M 32 0
-> 7 2.025708 6 32
-> 6 2.025708 34 6 1 "emigrant-1"
-> 16 2.025708 13 0 M 34 0
-> 12 2.025708 7 34 9
-> 13 4.025708 7 34
-> 12 4.025708 7 34 10
-> 13 4.025903 7 33
-> 12 4.025903 7 33 11
-> 13 4.025903 7 34
-> 15 4.025903 13 0 M 34 1
-> 7 4.025903 6 34
-> 6 4.025903 35 6 2 "emigrant-1"
-> 16 4.025903 13 0 M 35 1
-> 12 4.025903 7 35 9
-> 13 6.025903 7 35
-> 12 6.025903 7 35 10
-> 13 6.044918 7 33
-> 12 6.044918 7 33 11
-> 13 6.044918 7 35
-> 15 6.044918 13 0 M 35 2
-> 7 6.044918 6 35
-> 6 6.044918 36 6 3 "emigrant-1"
-> 16 6.044918 13 0 M 36 2
-> 12 6.044918 7 36 9
-> 13 8.044918 7 36
-> 12 8.044918 7 36 10
-> 13 8.070626 7 33
-> 12 8.070626 7 33 11
-> 13 8.070626 7 36
-> 15 8.070626 13 0 M 36 3
-> 7 8.070626 6 36
-> 6 8.070626 37 6 4 "emigrant-1"
-> 16 8.070626 13 0 M 37 3
-> 12 8.070626 7 37 9
-> 13 10.070626 7 37
-> 12 10.070626 7 37 10
-> 13 10.087178 7 33
-> 12 10.087178 7 33 11
-> 13 10.087178 7 37
-> 15 10.087178 13 0 M 37 4
-> 7 10.087178 6 37
-> 6 10.087178 38 6 5 "emigrant-1"
-> 16 10.087178 13 0 M 38 4
-> 12 10.087178 7 38 9
-> 13 12.087178 7 38
-> 12 12.087178 7 38 10
-> 13 12.112617 7 33
-> 12 12.112617 7 33 11
-> 13 12.112617 7 38
-> 15 12.112617 13 0 M 38 5
-> 7 12.112617 6 38
-> 6 12.112617 39 6 3 "emigrant-1"
-> 16 12.112617 13 0 M 39 5
-> 12 12.112617 7 39 9
-> 13 14.112617 7 39
-> 12 14.112617 7 39 10
-> 13 14.138325 7 33
-> 12 14.138325 7 33 11
-> 13 14.138325 7 39
-> 15 14.138325 13 0 M 39 6
-> 7 14.138325 6 39
-> 6 14.138325 40 6 1 "emigrant-1"
-> 16 14.138325 13 0 M 40 6
-> 12 14.138325 7 40 9
-> 13 16.138325 7 40
-> 12 16.138325 7 40 10
-> 13 16.138521 7 33
-> 12 16.138521 7 33 11
-> 13 16.138521 7 40
-> 15 16.138521 13 0 M 40 7
-> 7 16.138521 6 40
-> 6 16.138521 41 6 4 "emigrant-1"
-> 16 16.138521 13 0 M 41 7
-> 12 16.138521 7 41 9
-> 13 18.138521 7 41
-> 12 18.138521 7 41 10
-> 13 18.155073 7 33
-> 13 18.155073 7 41
-> 7 18.155073 6 33
-> 7 18.155073 6 41
-> 7 18.155073 2 16
-> 7 18.155073 2 14
-> 7 18.155073 2 19
-> 7 18.155073 2 20
-> 7 18.155073 2 18
-> 7 18.155073 2 21
-> 7 18.155073 2 22
-> 7 18.155073 2 12
-> 7 18.155073 2 9
-> 7 18.155073 2 15
-> 7 18.155073 2 23
-> 7 18.155073 2 24
-> 7 18.155073 2 17
-> 7 18.155073 2 25
-> 7 18.155073 2 26
-> 7 18.155073 2 27
-> 7 18.155073 2 8
-> 7 18.155073 2 10
-> 7 18.155073 2 28
-> 7 18.155073 2 29
-> 7 18.155073 2 13
-> 7 18.155073 2 30
-> 7 18.155073 2 11
+> 0 6 0 LINK
+> 6 0.000000 8 6 0 "6"
+> 6 0.000000 9 6 0 "3"
+> 6 0.000000 10 6 0 "7"
+> 6 0.000000 11 6 0 "9"
+> 6 0.000000 12 6 0 "2"
+> 6 0.000000 13 6 0 "8"
+> 6 0.000000 14 6 0 "1"
+> 6 0.000000 15 6 0 "4"
+> 6 0.000000 16 6 0 "0"
+> 6 0.000000 17 6 0 "5"
+> 6 0.000000 18 6 0 "145"
+> 6 0.000000 19 6 0 "10"
+> 6 0.000000 20 6 0 "11"
+> 6 0.000000 21 6 0 "16"
+> 6 0.000000 22 6 0 "17"
+> 6 0.000000 23 6 0 "44"
+> 6 0.000000 24 6 0 "47"
+> 6 0.000000 25 6 0 "54"
+> 6 0.000000 26 6 0 "56"
+> 6 0.000000 27 6 0 "59"
+> 6 0.000000 28 6 0 "78"
+> 6 0.000000 29 6 0 "79"
+> 6 0.000000 30 6 0 "80"
+> 6 0.000000 31 6 0 "loopback"
+> 4 7 0 6 6 0-LINK6-LINK6
+> 4 8 0 1 6 0-HOST1-LINK6
+> 4 9 0 6 1 0-LINK6-HOST1
+> 15 0.000000 7 0 topology 12 0
+> 16 0.000000 7 0 topology 16 0
+> 15 0.000000 7 0 topology 9 1
+> 16 0.000000 7 0 topology 16 1
+> 15 0.000000 7 0 topology 16 2
+> 16 0.000000 7 0 topology 14 2
+> 15 0.000000 7 0 topology 21 3
+> 16 0.000000 7 0 topology 19 3
+> 15 0.000000 7 0 topology 8 4
+> 16 0.000000 7 0 topology 19 4
+> 15 0.000000 7 0 topology 19 5
+> 16 0.000000 7 0 topology 20 5
+> 15 0.000000 7 0 topology 8 6
+> 16 0.000000 7 0 topology 20 6
+> 15 0.000000 7 0 topology 27 7
+> 16 0.000000 7 0 topology 18 7
+> 15 0.000000 8 0 topology 5 8
+> 16 0.000000 8 0 topology 18 8
+> 15 0.000000 8 0 topology 4 9
+> 16 0.000000 8 0 topology 18 9
+> 15 0.000000 8 0 topology 2 10
+> 16 0.000000 8 0 topology 18 10
+> 15 0.000000 7 0 topology 16 11
+> 16 0.000000 7 0 topology 21 11
+> 15 0.000000 7 0 topology 21 12
+> 16 0.000000 7 0 topology 22 12
+> 15 0.000000 7 0 topology 9 13
+> 16 0.000000 7 0 topology 12 13
+> 15 0.000000 7 0 topology 15 14
+> 16 0.000000 7 0 topology 9 14
+> 15 0.000000 8 0 topology 1 15
+> 16 0.000000 8 0 topology 9 15
+> 15 0.000000 7 0 topology 20 16
+> 16 0.000000 7 0 topology 23 16
+> 15 0.000000 7 0 topology 23 17
+> 16 0.000000 7 0 topology 24 17
+> 15 0.000000 8 0 topology 5 18
+> 16 0.000000 8 0 topology 24 18
+> 15 0.000000 8 0 topology 4 19
+> 16 0.000000 8 0 topology 24 19
+> 15 0.000000 8 0 topology 2 20
+> 16 0.000000 8 0 topology 24 20
+> 15 0.000000 7 0 topology 11 21
+> 16 0.000000 7 0 topology 15 21
+> 15 0.000000 8 0 topology 1 22
+> 16 0.000000 8 0 topology 15 22
+> 15 0.000000 7 0 topology 12 23
+> 16 0.000000 7 0 topology 17 23
+> 15 0.000000 7 0 topology 9 24
+> 16 0.000000 7 0 topology 17 24
+> 15 0.000000 7 0 topology 22 25
+> 16 0.000000 7 0 topology 25 25
+> 15 0.000000 7 0 topology 12 26
+> 16 0.000000 7 0 topology 25 26
+> 15 0.000000 7 0 topology 25 27
+> 16 0.000000 7 0 topology 26 27
+> 15 0.000000 7 0 topology 26 28
+> 16 0.000000 7 0 topology 27 28
+> 15 0.000000 7 0 topology 14 29
+> 16 0.000000 7 0 topology 8 29
+> 15 0.000000 7 0 topology 13 30
+> 16 0.000000 7 0 topology 8 30
+> 15 0.000000 7 0 topology 11 31
+> 16 0.000000 7 0 topology 8 31
+> 15 0.000000 7 0 topology 8 32
+> 16 0.000000 7 0 topology 10 32
+> 15 0.000000 7 0 topology 30 33
+> 16 0.000000 7 0 topology 28 33
+> 15 0.000000 8 0 topology 3 34
+> 16 0.000000 8 0 topology 28 34
+> 15 0.000000 7 0 topology 28 35
+> 16 0.000000 7 0 topology 29 35
+> 15 0.000000 8 0 topology 3 36
+> 16 0.000000 8 0 topology 30 36
+> 15 0.000000 7 0 topology 14 37
+> 16 0.000000 7 0 topology 13 37
+> 15 0.000000 7 0 topology 29 38
+> 16 0.000000 7 0 topology 11 38
+> 15 0.000000 8 0 topology 1 39
+> 16 0.000000 8 0 topology 11 39
+> 15 0.000000 9 0 topology 24 40
+> 16 0.000000 9 0 topology 7 40
+> 15 0.000000 9 0 topology 10 41
+> 16 0.000000 9 0 topology 5 41
+> 15 0.000000 9 0 topology 13 42
+> 16 0.000000 9 0 topology 3 42
+> 15 0.000000 9 0 topology 17 43
+> 16 0.000000 9 0 topology 4 43
+> 15 0.000000 9 0 topology 18 44
+> 16 0.000000 9 0 topology 6 44
+> 15 0.000000 9 0 topology 11 45
+> 16 0.000000 9 0 topology 2 45
+> 0 10 1 ACTOR
+> 6 0.000000 32 10 3 "emigrant-1"
+> 2 11 10 ACTOR_STATE
+> 5 12 11 suspend "1 0 1"
+> 5 13 11 sleep "1 1 0"
+> 5 14 11 receive "1 0 0"
+> 5 15 11 send "0 0 1"
+> 5 16 11 execute "0 1 1"
+> 4 17 0 10 10 ACTOR_LINK
+> 6 0.000000 33 10 1 "policeman-2"
+> 12 0.000000 11 32 13
+> 12 0.000000 11 33 15
+> 13 2.000000 11 32
+> 12 2.000000 11 32 14
+> 13 2.025708 11 33
+> 12 2.025708 11 33 15
+> 13 2.025708 11 32
+> 15 2.025708 17 0 M 32 0
+> 7 2.025708 10 32
+> 6 2.025708 34 10 1 "emigrant-1"
+> 16 2.025708 17 0 M 34 0
+> 12 2.025708 11 34 13
+> 13 4.025708 11 34
+> 12 4.025708 11 34 14
+> 13 4.025903 11 33
+> 12 4.025903 11 33 15
+> 13 4.025903 11 34
+> 15 4.025903 17 0 M 34 1
+> 7 4.025903 10 34
+> 6 4.025903 35 10 2 "emigrant-1"
+> 16 4.025903 17 0 M 35 1
+> 12 4.025903 11 35 13
+> 13 6.025903 11 35
+> 12 6.025903 11 35 14
+> 13 6.044918 11 33
+> 12 6.044918 11 33 15
+> 13 6.044918 11 35
+> 15 6.044918 17 0 M 35 2
+> 7 6.044918 10 35
+> 6 6.044918 36 10 3 "emigrant-1"
+> 16 6.044918 17 0 M 36 2
+> 12 6.044918 11 36 13
+> 13 8.044918 11 36
+> 12 8.044918 11 36 14
+> 13 8.070626 11 33
+> 12 8.070626 11 33 15
+> 13 8.070626 11 36
+> 15 8.070626 17 0 M 36 3
+> 7 8.070626 10 36
+> 6 8.070626 37 10 4 "emigrant-1"
+> 16 8.070626 17 0 M 37 3
+> 12 8.070626 11 37 13
+> 13 10.070626 11 37
+> 12 10.070626 11 37 14
+> 13 10.087178 11 33
+> 12 10.087178 11 33 15
+> 13 10.087178 11 37
+> 15 10.087178 17 0 M 37 4
+> 7 10.087178 10 37
+> 6 10.087178 38 10 5 "emigrant-1"
+> 16 10.087178 17 0 M 38 4
+> 12 10.087178 11 38 13
+> 13 12.087178 11 38
+> 12 12.087178 11 38 14
+> 13 12.112617 11 33
+> 12 12.112617 11 33 15
+> 13 12.112617 11 38
+> 15 12.112617 17 0 M 38 5
+> 7 12.112617 10 38
+> 6 12.112617 39 10 3 "emigrant-1"
+> 16 12.112617 17 0 M 39 5
+> 12 12.112617 11 39 13
+> 13 14.112617 11 39
+> 12 14.112617 11 39 14
+> 13 14.138325 11 33
+> 12 14.138325 11 33 15
+> 13 14.138325 11 39
+> 15 14.138325 17 0 M 39 6
+> 7 14.138325 10 39
+> 6 14.138325 40 10 1 "emigrant-1"
+> 16 14.138325 17 0 M 40 6
+> 12 14.138325 11 40 13
+> 13 16.138325 11 40
+> 12 16.138325 11 40 14
+> 13 16.138521 11 33
+> 12 16.138521 11 33 15
+> 13 16.138521 11 40
+> 15 16.138521 17 0 M 40 7
+> 7 16.138521 10 40
+> 6 16.138521 41 10 4 "emigrant-1"
+> 16 16.138521 17 0 M 41 7
+> 12 16.138521 11 41 13
+> 13 18.138521 11 41
+> 12 18.138521 11 41 14
+> 13 18.155073 11 33
+> 13 18.155073 11 41
+> 7 18.155073 10 33
+> 7 18.155073 10 41
+> 7 18.155073 6 16
+> 7 18.155073 6 14
+> 7 18.155073 6 19
+> 7 18.155073 6 20
+> 7 18.155073 6 18
+> 7 18.155073 6 21
+> 7 18.155073 6 22
+> 7 18.155073 6 12
+> 7 18.155073 6 9
+> 7 18.155073 6 15
+> 7 18.155073 6 23
+> 7 18.155073 6 24
+> 7 18.155073 6 17
+> 7 18.155073 6 25
+> 7 18.155073 6 26
+> 7 18.155073 6 27
+> 7 18.155073 6 8
+> 7 18.155073 6 10
+> 7 18.155073 6 28
+> 7 18.155073 6 29
+> 7 18.155073 6 13
+> 7 18.155073 6 30
+> 7 18.155073 6 11
> 7 18.155073 1 7
> 7 18.155073 1 5
> 7 18.155073 1 3
> 7 18.155073 1 6
> 7 18.155073 1 2
> 7 18.155073 1 1
-> 7 18.155073 2 31
+> 7 18.155073 6 31
$ rm -f procmig.trace
#include <set>
#include <string>
-namespace simgrid {
-namespace instr {
+namespace simgrid::instr {
/* User-variables related functions*/
/* for host variables */
XBT_PUBLIC void declare_host_variable(const std::string& variable, const std::string& color = "");
XBT_PUBLIC void platform_graph_export_graphviz(const std::string& output_filename);
/* Function used by graphicator (transform a SimGrid platform file in a CSV file with the network topology) */
XBT_PUBLIC void platform_graph_export_csv(const std::string& output_filename);
-} // namespace instr
-} // namespace simgrid
+} // namespace simgrid::instr
#endif
SG_BEGIN_DECL
#include <simgrid/forward.h>
#include <functional>
-namespace simgrid {
-namespace kernel {
-namespace profile {
-
+namespace simgrid::kernel::profile {
/** @brief Modeling of the availability profile (due to an external load) or the churn
*
static Profile* from_callback(const std::string& name, const std::function<UpdateCb>& cb, double repeat_delay);
};
-} // namespace profile
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::profile
#endif /* SIMGRID_KERNEL_PROFILEBUILDER_HPP */
#include <boost/heap/fibonacci_heap.hpp>
-namespace simgrid {
-namespace kernel {
-namespace timer {
+namespace simgrid::kernel::timer {
inline auto& kernel_timers() // avoid static initialization order fiasco
{
static bool execute_all();
};
-} // namespace timer
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::timer
#endif /* SRC_KERNEL_TIMER_TIMER_HPP_ */
static constexpr double NO_MAX_DURATION = -1.0;
-namespace simgrid {
-namespace kernel {
-namespace resource {
+namespace simgrid::kernel::resource {
using heap_element_type = std::pair<double, Action*>;
using heap_type =
void set_suspend_state(Action::SuspendStates state) { suspended_ = state; }
};
-} // namespace resource
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::resource
#endif
#include <simgrid/kernel/resource/Action.hpp>
#include <unordered_map>
-namespace simgrid {
-namespace kernel {
-namespace resource {
+namespace simgrid::kernel::resource {
class XBT_PUBLIC Model {
public:
ActionHeap action_heap_;
};
-} // namespace resource
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::resource
#endif
#include <unordered_map>
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
/**
* @brief Placeholder for old ClusterZone class
return node_pos_with_loopback(id) + (has_limiter_ ? 1 : 0);
}
};
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing
#endif /* SIMGRID_ROUTING_CLUSTER_HPP_ */
#include <simgrid/kernel/routing/RoutedZone.hpp>
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
/** @ingroup ROUTING_API
* @brief NetZone with an explicit routing computed on need with Dijkstra
void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
const std::vector<s4u::LinkInRoute>& link_list, bool symmetrical) override;
};
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing
#endif /* SIMGRID_ROUTING_DIJKSTRA_HPP_ */
#include <simgrid/kernel/routing/ClusterZone.hpp>
#include <simgrid/s4u/Link.hpp>
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
class DragonflyRouter {
public:
unsigned int num_links_per_link_ = 1; // splitduplex -> 2, only for local link
std::vector<DragonflyRouter> routers_;
};
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing
#endif
#include <simgrid/kernel/routing/NetZoneImpl.hpp>
#include <xbt/asserts.h>
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
/** @ingroup ROUTING_API
* @brief NetZone with no routing, useful with the constant network model
void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t, std::less<>>* /*nodes*/,
std::map<std::string, xbt_edge_t, std::less<>>* /*edges*/) override;
};
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing
#endif /* SIMGRID_ROUTING_NONE_HPP_ */
#include <simgrid/kernel/routing/ClusterZone.hpp>
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
class XBT_PRIVATE FatTreeLink;
void build_upper_levels(const s4u::ClusterCallbacks& set_callbacks);
void generate_dot_file(const std::string& filename = "fat_tree.dot") const;
};
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing
#endif
#include <simgrid/kernel/routing/RoutedZone.hpp>
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
/** @ingroup ROUTING_API
* @brief NetZone with an explicit routing computed at initialization with Floyd-Warshal
void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
const std::vector<s4u::LinkInRoute>& link_list, bool symmetrical) override;
};
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing
#endif /* SIMGRID_ROUTING_FLOYD_HPP_ */
#include <simgrid/kernel/routing/RoutedZone.hpp>
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
/** @ingroup ROUTING_API
* @brief NetZone with an explicit routing provided by the user
void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
const std::vector<s4u::LinkInRoute>& link_list, bool symmetrical) override;
};
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing
#endif /* SIMGRID_ROUTING_FULL_HPP_ */
extern template class XBT_PUBLIC xbt::Extendable<kernel::routing::NetPoint>;
-namespace kernel {
-namespace routing {
+namespace kernel::routing {
/** @ingroup ROUTING_API
* @brief Network cards are the vertices in the graph representing the network, used to compute paths between nodes.
NetPoint::Type component_type_;
NetZoneImpl* englobing_zone_ = nullptr;
};
-} // namespace routing
-} // namespace kernel
+} // namespace kernel::routing
} // namespace simgrid
XBT_PUBLIC simgrid::kernel::routing::NetPoint* sg_netpoint_by_name_or_null(const char* name);
#include <unordered_set>
#include <vector>
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
class Route {
public:
virtual resource::StandardLinkImpl* do_create_link(const std::string& name, const std::vector<double>& bandwidths);
void add_child(NetZoneImpl* new_zone);
};
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing
#endif /* SIMGRID_ROUTING_NETZONEIMPL_HPP */
#include <simgrid/kernel/routing/NetZoneImpl.hpp>
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
/** @ingroup ROUTING_API
* @brief NetZone with an explicit routing (abstract class)
void add_route_check_params(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
const std::vector<s4u::LinkInRoute>& link_list, bool symmetrical) const;
};
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing
#endif /* SIMGRID_ROUTING_GENERIC_HPP_ */
#include <unordered_map>
#include <unordered_set>
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
/** @ingroup ROUTING_API
* @brief NetZone where components are connected following a star topology
bool symmetrical) const;
std::unordered_map<unsigned long, StarRoute> routes_;
};
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing
#endif /* SIMGRID_KERNEL_ROUTING_STARZONE_HPP_ */
#include <vector>
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
/** @ingroup ROUTING_API
* @brief NetZone using a Torus topology
static std::vector<unsigned long> parse_topo_parameters(const std::string& topo_parameters);
};
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing
#endif
#include <simgrid/kernel/routing/StarZone.hpp>
#include <xbt/Extendable.hpp>
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
/** @ingroup ROUTING_API
* @brief NetZone modeling peers connected to the cloud through a private link
std::vector<double> coords;
};
} // namespace vivaldi
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing
#endif /* SIMGRID_ROUTING_VIVALDI_HPP_ */
#include <simgrid/kernel/routing/RoutedZone.hpp>
-namespace simgrid {
-namespace kernel {
-namespace routing {
+namespace simgrid::kernel::routing {
/** @ingroup ROUTING_API
* @brief NetZone modeling a Wifi zone
void get_local_route(const NetPoint* src, const NetPoint* dst, Route* into, double* latency) override;
NetPoint* get_access_point() const { return access_point_; }
};
-} // namespace routing
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::routing
#endif /* SIMGRID_ROUTING_WIFI_HPP_ */
/** Stock implementation of a generic monitored queue to solve the producer-consumer problem */
-namespace simgrid {
-namespace plugin {
+namespace simgrid::plugin {
template <typename T> class ProducerConsumer;
template <typename T> using ProducerConsumerPtr = boost::intrusive_ptr<ProducerConsumer<T>>;
*/
ProducerConsumer* set_max_queue_size(unsigned int max_queue_size)
{
- const std::lock_guard<s4u::Mutex> lock(*mutex_);
+ const std::scoped_lock lock(*mutex_);
max_queue_size_ = max_queue_size;
return this;
}
}
};
-} // namespace plugin
-} // namespace simgrid
+} // namespace simgrid::plugin
#endif // SIMGRID_PLUGIN_PRODUCERCONSUMER_HPP
#define SIMGRID_PLUGINS_OPERATION_H_
#include <simgrid/s4u/Activity.hpp>
+#include <simgrid/s4u/Io.hpp>
#include <xbt/Extendable.hpp>
#include <atomic>
using CommOpPtr = boost::intrusive_ptr<CommOp>;
XBT_PUBLIC void intrusive_ptr_release(CommOp* c);
XBT_PUBLIC void intrusive_ptr_add_ref(CommOp* c);
+class IoOp;
+using IoOpPtr = boost::intrusive_ptr<IoOp>;
+XBT_PUBLIC void intrusive_ptr_release(IoOp* i);
+XBT_PUBLIC void intrusive_ptr_add_ref(IoOp* i);
struct ExtendedAttributeActivity {
static simgrid::xbt::Extension<simgrid::s4u::Activity, ExtendedAttributeActivity> EXTENSION_ID;
};
class Operation {
-private:
static bool inited_;
std::set<Operation*> successors_ = {};
std::map<Operation*, unsigned int> predecessors_ = {};
int count_ = 0;
bool working_ = false;
s4u::ActivityPtr current_activity_;
- std::function<void(Operation*)> end_func_;
- std::function<void(Operation*)> start_func_;
+ std::vector<std::function<void(Operation*)>> end_func_handlers_;
+ std::vector<std::function<void(Operation*)>> start_func_handlers_;
explicit Operation(const std::string& name);
virtual ~Operation() = default;
virtual void execute() = 0;
};
class ExecOp : public Operation {
-private:
s4u::Host* host_;
explicit ExecOp(const std::string& name);
};
class CommOp : public Operation {
-private:
s4u::Host* source_;
s4u::Host* destination_;
friend void inline intrusive_ptr_release(CommOp* c) { intrusive_ptr_release(static_cast<Operation*>(c)); }
friend void inline intrusive_ptr_add_ref(CommOp* c) { intrusive_ptr_add_ref(static_cast<Operation*>(c)); }
};
+
+class IoOp : public Operation {
+ s4u::Disk* disk_;
+ s4u::Io::OpType type_;
+ explicit IoOp(const std::string& name);
+ void execute() override;
+
+public:
+ static IoOpPtr init(const std::string& name);
+ static IoOpPtr init(const std::string& name, double bytes, s4u::Disk* disk, s4u::Io::OpType type);
+ IoOpPtr set_disk(s4u::Disk* disk);
+ IoOpPtr set_bytes(double bytes);
+ IoOpPtr set_op_type(s4u::Io::OpType type);
+
+ friend void inline intrusive_ptr_release(IoOp* i) { intrusive_ptr_release(static_cast<Operation*>(i)); }
+ friend void inline intrusive_ptr_add_ref(IoOp* i) { intrusive_ptr_add_ref(static_cast<Operation*>(i)); }
+};
} // namespace simgrid::plugins
#endif
bool has_no_successor() const { return successors_.empty(); }
const std::set<ActivityPtr>& get_dependencies() const { return dependencies_; }
const std::vector<ActivityPtr>& get_successors() const { return successors_; }
+ virtual void fire_this_completion() const = 0;
protected:
Activity() = default;
private:
static xbt::signal<void(Activity&)> on_veto;
- static xbt::signal<void(Activity const&)> on_completion;
static xbt::signal<void(Activity const&)> on_suspend;
static xbt::signal<void(Activity const&)> on_resume;
/*! Add a callback fired each time that the activity fails to start because of a veto (e.g., unsolved dependency or no
* resource assigned) */
static void on_veto_cb(const std::function<void(Activity&)>& cb) { on_veto.connect(cb); }
- /*! Add a callback fired when the activity completes (either normally, cancelled or failed) */
- static void on_completion_cb(const std::function<void(Activity const&)>& cb) { on_completion.connect(cb); }
/*! Add a callback fired when the activity is suspended */
static void on_suspend_cb(const std::function<void(Activity const&)>& cb)
{
// released by the on_completion() callbacks.
ActivityPtr keepalive(this);
state_ = state;
- on_completion(*this);
+ fire_this_completion();
if (state == State::FINISHED)
release_dependencies();
}
std::string tracing_category_ = "";
public:
+ inline static xbt::signal<void(AnyActivity const&)> on_completion;
+ /*! Add a callback fired when the activity completes (either normally, cancelled or failed) */
+ static void on_completion_cb(const std::function<void(AnyActivity const&)>& cb) { on_completion.connect(cb); }
+
AnyActivity* add_successor(ActivityPtr a)
{
Activity::add_successor(a);
AnyActivity* set_tracing_category(const std::string& category)
{
- xbt_assert(get_state() == State::INITED, "Cannot change the tracing category of an activity after its start");
+ xbt_assert(get_state() == State::INITED || get_state() == State::STARTING,
+ "Cannot change the tracing category of an activity after its start");
tracing_category_ = category;
return static_cast<AnyActivity*>(this);
}
AnyActivity* cancel() { return static_cast<AnyActivity*>(Activity::cancel()); }
AnyActivity* wait() { return wait_for(-1.0); }
- virtual AnyActivity* wait_for(double timeout) { return static_cast<AnyActivity*>(Activity::wait_for(timeout)); }
+ virtual AnyActivity* wait_for(double timeout) {
+ return static_cast<AnyActivity*>(Activity::wait_for(timeout));
+ }
#ifndef DOXYGEN
/* The refcounting is done in the ancestor class, Activity, but we want each of the classes benefiting of the CRTP
#include <atomic>
#include <future>
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
class XBT_PUBLIC Barrier {
kernel::activity::BarrierImpl* pimpl_;
friend XBT_PUBLIC void intrusive_ptr_release(Barrier* barrier);
#endif
};
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
#endif
#include <string>
#include <vector>
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
/** @brief Communication async
*
* Represents all asynchronous communications, that you can test or wait onto.
static void on_send_cb(const std::function<void(Comm const&)>& cb) { on_send.connect(cb); }
static void on_recv_cb(const std::function<void(Comm const&)>& cb) { on_recv.connect(cb); }
static void on_start_cb(const std::function<void(Comm const&)>& cb) { on_start.connect(cb); }
+ void fire_this_completion() const override { on_completion(*this); }
/* More callbacks */
CommPtr set_copy_data_callback(const std::function<void(kernel::activity::CommImpl*, void*, size_t)>& callback);
XBT_ATTRIB_DEPRECATED_v337("Please manifest if you actually need this function") static void copy_buffer_callback(
* occurs). */
static size_t wait_all_for(const std::vector<CommPtr>& comms, double timeout);
};
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
#endif /* SIMGRID_S4U_COMM_HPP */
#include <future>
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
/**
* @beginrst
void notify_all();
};
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
#endif
#include <utility>
#include <vector>
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
/** @brief Simulation engine
*
* This is a singleton containing all the main functions of the simulation.
/** @brief Retrieves all netzones of the type indicated by the template argument */
template <class T> std::vector<T*> get_filtered_netzones() const
{
- static_assert(std::is_base_of<kernel::routing::NetZoneImpl, T>::value,
+ static_assert(std::is_base_of_v<kernel::routing::NetZoneImpl, T>,
"Filtering netzones is only possible for subclasses of kernel::routing::NetZoneImpl");
std::vector<T*> res;
get_filtered_netzones_recursive(get_netzone_root(), &res);
template <class T>
XBT_PRIVATE void get_filtered_netzones_recursive(const s4u::NetZone* current, std::vector<T*>* whereto)
{
- static_assert(std::is_base_of<kernel::routing::NetZoneImpl, T>::value,
+ static_assert(std::is_base_of_v<kernel::routing::NetZoneImpl, T>,
"Filtering netzones is only possible for subclasses of kernel::routing::NetZoneImpl");
for (auto const& elem : current->get_children()) {
get_filtered_netzones_recursive(elem, whereto);
}
}
#endif
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
#endif /* SIMGRID_S4U_ENGINE_HPP */
#include <simgrid/s4u/Actor.hpp>
#include <xbt/ex.h>
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
/** Computation Activity, representing the asynchronous executions.
*
#endif
/*! Signal fired each time that an execution actually starts (no veto) */
static void on_start_cb(const std::function<void(Exec const&)>& cb) { on_start.connect(cb); }
+ void fire_this_completion() const override { on_completion(*this); }
static ExecPtr init();
bool is_assigned() const override;
};
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
#endif /* SIMGRID_S4U_EXEC_HPP */
#include <string>
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
/** I/O Activity, representing the asynchronous disk access.
*
enum class OpType { READ, WRITE };
static void on_start_cb(const std::function<void(Io const&)>& cb) { on_start.connect(cb); }
+ void fire_this_completion() const override{ on_completion(*this); }
static IoPtr init();
/*! take a vector of s4u::IoPtr and return when one of them is finished.
bool is_assigned() const override;
};
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
#endif /* SIMGRID_S4U_IO_HPP */
#include <memory>
#include <string>
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
/** @brief Mailboxes: Network rendez-vous points. */
class XBT_PUBLIC Mailbox {
get_async<T>(&res)->wait_for(timeout);
return res;
}
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
#endif /* SIMGRID_S4U_MAILBOX_HPP */
#include <simgrid/forward.h>
#include <xbt/asserts.h>
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
/** @brief A classical mutex, but blocking in the simulation world.
*
bool try_lock();
};
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
#endif /* SIMGRID_S4U_MUTEX_HPP */
#include <utility>
#include <vector>
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
/** @brief Networking Zones
*
const DragonflyParams& parameters, const ClusterCallbacks& set_callbacks,
double bandwidth, double latency, Link::SharingPolicy sharing_policy);
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
#endif /* SIMGRID_S4U_NETZONE_HPP */
#include <simgrid/forward.h>
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
/** @brief A classical semaphore, but blocking in the simulation world
*
bool would_block() const;
};
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
#endif /* SIMGRID_S4U_SEMAPHORE_HPP */
#include <simgrid/s4u/Host.hpp>
#include <xbt/utility.hpp>
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
/** @brief Host extension for the VMs */
class VmHostExt {
on_migration_end.connect(cb);
}
};
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
#endif
XBT_PUBLIC void simcall_run_object_access(std::function<void()> const& code,
simgrid::kernel::actor::ObjectAccessSimcallItem* item);
-namespace simgrid {
-namespace kernel {
-namespace actor {
+namespace simgrid::kernel::actor {
/** Execute some code in kernel context on behalf of the user code.
*
simcall_blocking(std::forward<F>(code), static_cast<SimcallObserver*>(observer));
return observer->get_result();
}
-// compact namespaces are C++17 and this is a public header file so let's stick to C++14
-} // namespace actor
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::actor
#endif
#ifdef __cplusplus
#include <boost/intrusive_ptr.hpp>
-namespace simgrid {
-namespace smpi {
+namespace simgrid::smpi {
class Colls;
class Comm;
class Topo_Dist_Graph;
class Win;
-}
-}
+} // namespace simgrid::smpi
using SMPI_Comm = simgrid::smpi::Comm;
using SMPI_Datatype = simgrid::smpi::Datatype;
#include <limits>
#include <vector>
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
template<class T, class U> class Extension;
template<class T> class Extendable;
// Initialized with a first element, to save space for void* user data
template <class T> std::vector<std::function<void(void*)>> Extendable<T>::deleters_{1};
-}
-}
+} // namespace simgrid::xbt
#endif
#include <string>
#include <unordered_map>
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
/** @brief a PropertyHolder can be given a set of textual properties
*
template <class Assoc> void set_properties(const Assoc& properties);
};
-} // namespace xbt
-} // namespace simgrid
+} // namespace simgrid::xbt
#endif
#include <xbt/automaton.h>
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
/** Add a proposition to an automaton (the C++ way)
*
a, id, [](auto* cb) -> int { return (*(F*)cb)(); }, callback, [](auto* cb) -> void { delete (F*)cb; });
}
-}
-}
+} // namespace simgrid::xbt
#endif
XBT_PUBLIC void xbt_backtrace_display_current();
SG_END_DECL
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
class BacktraceImpl;
/** A backtrace
void display() const;
};
-}
-}
+} // namespace simgrid::xbt
#endif
#include <xbt/sysdep.h>
#include <xbt/utility.hpp>
-namespace simgrid {
-namespace config {
+namespace simgrid::config {
class Config;
*/
// F is a checker, F : T& -> ()
template <class T, class F>
-typename std::enable_if_t<std::is_same<void, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>
+typename std::enable_if_t<std::is_same_v<void, decltype(std::declval<F>()(std::declval<const T&>()))>, void>
bind_flag(T& value, const char* name, const char* description, F callback)
{
declare_flag(name, description, value, std::function<void(const T&)>([&value, callback](const T& val) {
}
template <class T, class F>
-typename std::enable_if_t<std::is_same<void, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>
+typename std::enable_if_t<std::is_same_v<void, decltype(std::declval<F>()(std::declval<const T&>()))>, void>
bind_flag(T& value, const char* name, std::initializer_list<const char*> aliases, const char* description, F callback)
{
bind_flag(value, name, description, std::move(callback));
}
template <class F>
-typename std::enable_if_t<std::is_same<void, decltype(std::declval<F>()(std::declval<const std::string&>()))>::value,
- void>
+typename std::enable_if_t<std::is_same_v<void, decltype(std::declval<F>()(std::declval<const std::string&>()))>, void>
bind_flag(std::string& value, const char* name, const char* description,
const std::map<std::string, std::string, std::less<>>& valid_values, F callback)
{
mesg += std::string("Possible values for option ") + name + ":\n";
else
mesg += "Invalid value '" + val + "' for option " + name + ". Possible values:\n";
- for (auto const& kv : valid_values)
- mesg += " - '" + kv.first + "': " + kv.second + (kv.first == value ? " <=== DEFAULT" : "") + "\n";
+ for (auto const& [v, descr] : valid_values)
+ mesg += " - '" + v + "': " + descr + (v == value ? " <=== DEFAULT" : "") + "\n";
xbt_die("%s", mesg.c_str());
}));
}
template <class F>
-typename std::enable_if_t<std::is_same<void, decltype(std::declval<F>()(std::declval<const std::string&>()))>::value,
- void>
+typename std::enable_if_t<std::is_same_v<void, decltype(std::declval<F>()(std::declval<const std::string&>()))>, void>
bind_flag(std::string& value, const char* name, std::initializer_list<const char*> aliases, const char* description,
const std::map<std::string, std::string, std::less<>>& valid_values, F callback)
{
*/
// F is a predicate, F : T const& -> bool
template <class T, class F>
-typename std::enable_if_t<std::is_same<bool, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>
+typename std::enable_if_t<std::is_same_v<bool, decltype(std::declval<F>()(std::declval<const T&>()))>, void>
bind_flag(T& value, const char* name, const char* description, F callback)
{
declare_flag(name, description, value, std::function<void(const T&)>([&value, callback](const T& val) {
XBT_PUBLIC void show_aliases();
XBT_PUBLIC void help();
-} // namespace config
-} // namespace simgrid
+} // namespace simgrid::config
#endif
#include <vector>
#include <xbt/base.h>
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
void path_push(std::string const& str);
void path_pop();
private:
std::string path_;
};
-}}
+} // namespace simgrid::xbt
#endif /* XBT_FILE_HPP */
#include <utility>
#include <vector>
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
template <class F> class MainFunction {
F code_;
* @endcode
**/
template <class F, class Tuple>
-constexpr auto apply(F&& f, Tuple&& t) -> decltype(
- simgrid::xbt::bits::apply(std::forward<F>(f), std::forward<Tuple>(t),
- std::make_index_sequence<std::tuple_size<typename std::decay_t<Tuple>>::value>()))
+constexpr auto apply(F&& f, Tuple&& t)
+ -> decltype(simgrid::xbt::bits::apply(std::forward<F>(f), std::forward<Tuple>(t),
+ std::make_index_sequence<std::tuple_size_v<typename std::decay_t<Tuple>>>()))
{
return simgrid::xbt::bits::apply(std::forward<F>(f), std::forward<Tuple>(t),
- std::make_index_sequence<std::tuple_size<typename std::decay_t<Tuple>>::value>());
+ std::make_index_sequence<std::tuple_size_v<typename std::decay_t<Tuple>>>());
}
template<class T> class Task;
return code(std::forward<Args>(args)...);
},
// Destroy:
- std::is_trivially_destructible<F>::value ?
+ std::is_trivially_destructible_v<F> ?
static_cast<destroy_function>(nullptr) :
[](TaskUnion& buffer) {
auto* code = reinterpret_cast<F*>(&buffer);
return Task<decltype(code(std::move(args)...))()>(std::move(task));
}
-} // namespace xbt
-} // namespace simgrid
+} // namespace simgrid::xbt
#endif
#include <simgrid/Exception.hpp>
#include <xbt/log.h>
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
/** Display information about an exception
*
XBT_PUBLIC void install_exception_handler();
-} // namespace xbt
-} // namespace simgrid
+} // namespace simgrid::xbt
-#endif
\ No newline at end of file
+#endif
#include <utility>
#include <xbt/ex.h>
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
/** A value or an exception (or nothing)
*
{
fulfill_promise(promise, [&future] { return std::forward<F>(future).get(); });
}
-}
-}
+} // namespace simgrid::xbt
#endif
#include <random>
#include <string>
-namespace simgrid {
-namespace xbt {
-namespace random {
+namespace simgrid::xbt::random {
/** A random number generator.
*
* @param sd Standard deviation of the normal distribution
*/
double normal(double mean, double sd);
-} // namespace random
-} // namespace xbt
-} // namespace simgrid
+} // namespace simgrid::xbt::random
#endif
#include <algorithm>
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
/** Describes a contiguous inclusive-exclusive [a,b) range of values */
template<class T> class Range {
bool contain(T const& x) const { return begin_ <= x && end_ > x; }
};
-}
-}
+} // namespace simgrid::xbt
#endif
#include <queue>
#include <unordered_map>
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
/* To split the file if a unique one is given (specific variable for the other case live in runner()) */
using ReplayAction = std::vector<std::string>;
* xbt_replay_set_tracefile(). If trace_filename is not nullptr, then it's not shared and this trace file is for this
* actor only */
XBT_PUBLIC int replay_runner(const char* actor_name, const char* trace_filename = nullptr);
-}
-}
+} // namespace simgrid::xbt
using action_fun = std::function<void(simgrid::xbt::ReplayAction&)>;
XBT_PUBLIC void xbt_replay_action_register(const char* action_name, const action_fun& function);
#include <map>
#include <utility>
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
template <class S> class signal;
/** Fire that signal, invoking all callbacks */
R operator()(P... args) const
{
- for (auto const& handler : handlers_)
- handler.second(args...);
+ for (auto const& [_, callback] : handlers_)
+ callback(args...);
}
/** Remove a callback */
void disconnect(unsigned int id) { handlers_.erase(id); }
/** Remove all callbacks */
void disconnect_slots() { handlers_.clear(); }
};
-}
-}
+} // namespace simgrid::xbt
#endif
#include <cstdlib>
#include <string>
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
/** Create a C++ string from a C-style format
*
*/
XBT_PUBLIC std::string string_vprintf(const char* fmt, va_list ap) XBT_ATTRIB_PRINTF(1, 0);
-} // namespace xbt
-}
-#endif
\ No newline at end of file
+} // namespace simgrid::xbt
+#endif
#ifndef SIMGRID_MC_SYSTEM_ERROR_HPP
#define SIMGRID_MC_SYSTEM_ERROR_HPP
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
/** A `error_category` suitable to be used with `errno`
*
return std::system_error(errno_code(), what);
}
-}
-}
+} // namespace simgrid::xbt
#endif
} \
enum class EnumType { __VA_ARGS__ } /* defined here to handle trailing semicolon */
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
/** @brief Replacement for C++20's std::type_identity_t
*/
list.erase(list.iterator_to(elem));
}
-} // namespace xbt
-} // namespace simgrid
+} // namespace simgrid::xbt
#endif
# Disable some rules on some files
-sonar.issue.ignore.multicriteria=c1,c2a,c2b,c3,c5a,c5b,c6a,c6b,c7,c8,c9,c10a,c10b,c10c,cex1a,cex1b,cex2a,cex2b,cex3,cex4,cxx17a,cxx17b,cxx17c,cxx17d,cxx17e,cxx17f,cxx17g,f1,p1,s1,s2,s3,s4,s5
+sonar.issue.ignore.multicriteria=c1,c2a,c2b,c3,c5a,c5b,c6a,c6b,c7,c8,c9,c10a,c10b,c10c,cex1a,cex1b,cex2a,cex2b,cex3,cex4,f1,p1,s1,s2,s3,s4,s5
# Pointers should not be cast to integral types
# But we need that for smpi and other places
sonar.issue.ignore.multicriteria.cex4.ruleKey=c:S995
sonar.issue.ignore.multicriteria.cex4.resourceKey=examples/**/*.c
-# Ignore these C++17 rules in public headers, where we still support C++14
-
-# C++17: Concise syntax should be used for concatenatable namespaces
-sonar.issue.ignore.multicriteria.cxx17a.ruleKey=cpp:S5812
-sonar.issue.ignore.multicriteria.cxx17a.resourceKey=include/**/*
-# C++17: "if","switch", and range-based for loop initializer should be used to reduce scope of variables
-sonar.issue.ignore.multicriteria.cxx17b.ruleKey=cpp:S6004
-sonar.issue.ignore.multicriteria.cxx17b.resourceKey=include/**/*.hpp
-# C++17: Structured binding should be used
-sonar.issue.ignore.multicriteria.cxx17c.ruleKey=cpp:S6005
-sonar.issue.ignore.multicriteria.cxx17c.resourceKey=include/**/*.hpp
-# C++17: "std::string_view" should be used to pass a read-only string to a function
-sonar.issue.ignore.multicriteria.cxx17d.ruleKey=cpp:S6009
-sonar.issue.ignore.multicriteria.cxx17d.resourceKey=include/**/*.hpp
-# C++17: Redundant class template arguments should not be used
-sonar.issue.ignore.multicriteria.cxx17e.ruleKey=cpp:S6012
-sonar.issue.ignore.multicriteria.cxx17e.resourceKey=include/**/*.hpp
-# C++17: The "_t" and "_v" version of type traits should be used instead of "::type" and "::value"
-sonar.issue.ignore.multicriteria.cxx17f.ruleKey=cpp:S6020
-sonar.issue.ignore.multicriteria.cxx17f.resourceKey=include/**/*.hpp
-# C++17: "std::scoped_lock" should be used instead of "std::lock_guard"
-sonar.issue.ignore.multicriteria.cxx17g.ruleKey=cpp:S5997
-sonar.issue.ignore.multicriteria.cxx17g.resourceKey=include/**/*.hpp
-
# "reinterpret_cast" should not be used
# But we need this to interface C and Fortran
sonar.issue.ignore.multicriteria.f1.ruleKey=cpp:S3630
root->get_type()->by_name_or_create("MIGRATE_LINK", mpi, mpi);
mpi->by_name_or_create<StateType>("MIGRATE_STATE");
}
+
+ if (TRACE_actor_is_enabled()) {
+ auto* host_type = container->get_type();
+ auto* state = host_type->by_name_or_create<StateType>("HOST_STATE");
+ state->set_calling_container(container);
+ state->add_entity_value("receive", "1 0 0");
+ state->add_entity_value("send", "0 0 1");
+ state->add_entity_value("execute", "0 1 1");
+ }
}
static void on_action_state_change(kernel::resource::Action const& action,
});
s4u::Actor::on_wake_up_cb(
[](s4u::Actor const& actor) { Container::by_name(instr_pid(actor))->get_state("ACTOR_STATE")->pop_event(); });
- s4u::Exec::on_start_cb([](s4u::Exec const&) {
- Container::by_name(instr_pid(*s4u::Actor::self()))->get_state("ACTOR_STATE")->push_event("execute");
+
+ s4u::Exec::on_start_cb([](s4u::Exec const& e) {
+ std::string pid = instr_pid(*s4u::Actor::self());
+ if (pid == "-0") //Exec is launched directly by Maestro, use the host as container
+ Container::by_name(e.get_host()->get_name())->get_state("HOST_STATE")->push_event("execute");
+ else
+ Container::by_name(pid)->get_state("ACTOR_STATE")->push_event("execute");
});
- s4u::Activity::on_completion_cb([](const s4u::Activity&) {
- Container::by_name(instr_pid(*s4u::Actor::self()))->get_state("ACTOR_STATE")->pop_event();
+
+ s4u::Exec::on_completion_cb([](const s4u::Exec& e) {
+ std::string pid = instr_pid(*s4u::Actor::self());
+ if (pid == "-0") //Exec is launched directly by Maestro, use the host as container
+ Container::by_name(e.get_host()->get_name())->get_state("HOST_STATE")->pop_event();
+ else
+ Container::by_name(pid)->get_state("ACTOR_STATE")->pop_event();
+ });
+
+ s4u::Comm::on_completion_cb([](const s4u::Comm& c) {
+ std::string pid = instr_pid(*s4u::Actor::self());
+ if (pid == "-0") { //Comm is launched directly by Maestro, use the host as container
+ Container::by_name(c.get_source()->get_name())->get_state("HOST_STATE")->pop_event();
+ Container::by_name(c.get_destination()->get_name())->get_state("HOST_STATE")->pop_event();
+ } else
+ Container::by_name(pid)->get_state("ACTOR_STATE")->pop_event();
});
- s4u::Comm::on_send_cb([](s4u::Comm const&) {
- Container::by_name(instr_pid(*s4u::Actor::self()))->get_state("ACTOR_STATE")->push_event("send");
+ s4u::Comm::on_send_cb([](s4u::Comm const& c) {
+ std::string pid = instr_pid(*s4u::Actor::self());
+ if (pid == "-0") //Comm is launched directly by Maestro, use the host as container
+ Container::by_name(c.get_source()->get_name())->get_state("HOST_STATE")->push_event("send");
+ else
+ Container::by_name(pid)->get_state("ACTOR_STATE")->push_event("send");
});
- s4u::Comm::on_recv_cb([](s4u::Comm const&) {
- Container::by_name(instr_pid(*s4u::Actor::self()))->get_state("ACTOR_STATE")->push_event("receive");
+ s4u::Comm::on_recv_cb([](s4u::Comm const& c) {
+ std::string pid = instr_pid(*s4u::Actor::self());
+ if (pid == "-0") //Comm is launched directly by Maestro, use the host as container
+ Container::by_name(c.get_destination()->get_name())->get_state("HOST_STATE")->push_event("receive");
+ else
+ Container::by_name(pid)->get_state("ACTOR_STATE")->push_event("receive");
});
s4u::Actor::on_host_change_cb(on_actor_host_change);
}
->get_state("MPI_STATE")
->push_event("computing", new CpuTIData("compute", exec.get_cost()));
});
- s4u::Activity::on_completion_cb([](const s4u::Activity&) {
+ s4u::Exec::on_completion_cb([](const s4u::Exec&) {
Container::by_name("rank-" + std::to_string(s4u::Actor::self()->get_pid()))->get_state("MPI_STATE")->pop_event();
});
}
{
std::stringstream debug;
std::copy(container.begin(), container.end(),
- std::ostream_iterator<typename std::remove_reference<decltype(container)>::type::value_type>(debug, " "));
+ std::ostream_iterator<typename std::remove_reference_t<decltype(container)>::value_type>(debug, " "));
return debug.str();
}
}
}
-static void remove_active_exec(s4u::Activity const& task)
+static void remove_active_exec(s4u::Exec const& exec)
{
- const auto* exec = dynamic_cast<s4u::Exec const*>(&task);
- if (exec == nullptr)
+ if (not exec.is_assigned())
return;
- if (not exec->is_assigned())
- return;
- const s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(exec->get_host());
+ const s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(exec.get_host());
if (vm != nullptr) {
VirtualMachineImpl* vm_impl = vm->get_vm_impl();
- for (int i = 1; i <= exec->get_thread_count(); i++)
+ for (int i = 1; i <= exec.get_thread_count(); i++)
vm_impl->remove_active_exec();
vm_impl->update_action_weight();
}
{
s4u::Host::on_state_change_cb(host_state_change);
s4u::Exec::on_start_cb(add_active_exec);
- s4u::Activity::on_completion_cb(remove_active_exec);
+ s4u::Exec::on_completion_cb(remove_active_exec);
s4u::Activity::on_resume_cb(add_active_activity);
s4u::Activity::on_suspend_cb(remove_active_activity);
}
#include "src/kernel/resource/NetworkModel.hpp"
#include "src/kernel/resource/StandardLinkImpl.hpp"
-namespace simgrid ::kernel::resource {
+namespace simgrid::kernel::resource {
class NetworkNS3Model : public NetworkModel {
public:
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_torus, ker_platform, "Kernel Torus Routing");
namespace simgrid {
-namespace kernel ::routing {
+namespace kernel::routing {
void TorusZone::create_torus_links(unsigned long id, int rank, unsigned long position)
{
std::size_t get_buffer_size() const { return sizeof(T); }
operator T() const
{
- static_assert(std::is_trivial<T>::value, "Cannot convert non trivial type");
+ static_assert(std::is_trivial_v<T>, "Cannot convert non trivial type");
return *get_buffer();
}
void clear() { std::memset(&buffer, 0, sizeof buffer); }
#include "src/mc/sosp/PageStore.hpp"
-using simgrid::mc::PageStore;
-
/***********************************/
// a class to hold the variable used in the test cases
-class helper_tests {
-public:
- static std::size_t pagesize;
- static std::unique_ptr<PageStore> store;
- static void* data;
- static std::array<size_t, 4> pageno;
- static int value;
+class pstore_test_helper {
+ const size_t pagesize = getpagesize();
+ simgrid::mc::PageStore store{50};
+ std::byte* data =
+ static_cast<std::byte*>(mmap(nullptr, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
+ std::array<size_t, 4> pageno = {0, 0, 0, 0};
+ int value = 0;
+
+ void new_content(std::byte* buf, size_t size);
+public:
// member functions used by the test suite(s)
- static void Init();
- static void store_page_once();
- static void store_same_page();
- static void store_new_page();
- static void unref_pages();
- static void reallocate_page();
-
- static void new_content(void* buf, std::size_t size);
+ void init();
+ void store_page_once();
+ void store_same_page();
+ void store_new_page();
+ void unref_pages();
+ void reallocate_page();
};
-// static member data initialization
-std::size_t helper_tests::pagesize = 0;
-std::unique_ptr<PageStore> helper_tests::store = nullptr;
-void* helper_tests::data = nullptr;
-std::array<size_t, 4> helper_tests::pageno = {{0, 0, 0, 0}};
-int helper_tests::value = 0;
-
-void helper_tests::Init()
+void pstore_test_helper::init()
{
- pagesize = (size_t)getpagesize();
- store = std::make_unique<simgrid::mc::PageStore>(50);
- data = mmap(nullptr, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- REQUIRE(store->size() == 0);
+ REQUIRE(data != nullptr);
+ REQUIRE(store.size() == 0);
}
-void helper_tests::store_page_once()
+void pstore_test_helper::store_page_once()
{
new_content(data, pagesize);
- pageno[0] = store->store_page(data);
- REQUIRE(store->get_ref(pageno[0]) == 1);
- const void* copy = store->get_page(pageno[0]);
+ pageno[0] = store.store_page(data);
+ REQUIRE(store.get_ref(pageno[0]) == 1);
+ const auto* copy = store.get_page(pageno[0]);
REQUIRE(::memcmp(data, copy, pagesize) == 0); // The page data should be the same
- REQUIRE(store->size() == 1);
+ REQUIRE(store.size() == 1);
}
-void helper_tests::store_same_page()
+void pstore_test_helper::store_same_page()
{
- pageno[1] = store->store_page(data);
+ pageno[1] = store.store_page(data);
REQUIRE(pageno[0] == pageno[1]); // Page should be the same
- REQUIRE(store->get_ref(pageno[0]) == 2);
- REQUIRE(store->size() == 1);
+ REQUIRE(store.get_ref(pageno[0]) == 2);
+ REQUIRE(store.size() == 1);
}
-void helper_tests::store_new_page()
+void pstore_test_helper::store_new_page()
{
new_content(data, pagesize);
- pageno[2] = store->store_page(data);
+ pageno[2] = store.store_page(data);
REQUIRE(pageno[0] != pageno[2]); // The new page should be different
- REQUIRE(store->size() == 2);
+ REQUIRE(store.size() == 2);
}
-void helper_tests::unref_pages()
+void pstore_test_helper::unref_pages()
{
- store->unref_page(pageno[0]);
- REQUIRE(store->get_ref(pageno[0]) == 1);
- REQUIRE(store->size() == 2);
+ store.unref_page(pageno[0]);
+ REQUIRE(store.get_ref(pageno[0]) == 1);
+ REQUIRE(store.size() == 2);
- store->unref_page(pageno[1]);
- REQUIRE(store->size() == 1);
+ store.unref_page(pageno[1]);
+ REQUIRE(store.size() == 1);
}
-void helper_tests::reallocate_page()
+void pstore_test_helper::reallocate_page()
{
new_content(data, pagesize);
- pageno[3] = store->store_page(data);
+ pageno[3] = store.store_page(data);
REQUIRE(pageno[0] == pageno[3]); // The old page should be reused
- REQUIRE(store->get_ref(pageno[3]) == 1);
- REQUIRE(store->size() == 2);
+ REQUIRE(store.get_ref(pageno[3]) == 1);
+ REQUIRE(store.size() == 2);
}
-void helper_tests::new_content(void* buf, std::size_t size)
+void pstore_test_helper::new_content(std::byte* buf, size_t size)
{
value++;
- ::memset(buf, value, size);
+ std::fill_n(buf, size, static_cast<std::byte>(value));
}
TEST_CASE("MC page store, used during checkpoint", "MC::PageStore")
{
- helper_tests::Init();
+ pstore_test_helper pstore_test;
+ pstore_test.init();
+
INFO("Store page once");
- helper_tests::store_page_once();
+ pstore_test.store_page_once();
INFO("Store the same page");
- helper_tests::store_same_page();
+ pstore_test.store_same_page();
INFO("Store a new page");
- helper_tests::store_new_page();
+ pstore_test.store_new_page();
INFO("Unref pages");
- helper_tests::unref_pages();
+ pstore_test.unref_pages();
INFO("Reallocate pages");
- helper_tests::reallocate_page();
+ pstore_test.reallocate_page();
}
#include <sys/mman.h>
#include <xbt/random.hpp>
-/**************** Class BOOST_tests *************************/
-using simgrid::mc::Region;
class snap_test_helper {
simgrid::mc::PageStore page_store_{500};
simgrid::mc::RemoteProcessMemory memory_{getpid(), nullptr};
size_t size;
std::byte* src;
std::byte* dstn;
- std::unique_ptr<Region> region0;
- std::unique_ptr<Region> region;
+ std::unique_ptr<simgrid::mc::Region> region0;
+ std::unique_ptr<simgrid::mc::Region> region;
};
prologue_return prologue(int n); // common to the below 5 fxs
+ static void init_memory(std::byte* mem, size_t size);
+
public:
void read_whole_region();
void read_region_parts();
void compare_region_parts();
void read_pointer();
- static void init_memory(std::byte* mem, size_t size);
static void basic_requirements();
};
if (activity.get_host() == get_host())
pre_task();
});
- simgrid::s4u::Activity::on_completion_cb([this](simgrid::s4u::Activity const& activity) {
- const auto* exec = dynamic_cast<simgrid::s4u::Exec const*>(&activity);
- if (exec == nullptr) // Only Execs are concerned here
- return;
+ simgrid::s4u::Exec::on_completion_cb([this](simgrid::s4u::Exec const& exec) {
// For more than one host (not yet supported), we can access the host via
// simcalls_.front()->issuer->get_iface()->get_host()
- if (exec->get_host() == get_host() && iteration_running) {
- comp_timer += exec->get_finish_time() - exec->get_start_time();
+ if (exec.get_host() == get_host() && iteration_running) {
+ comp_timer += exec.get_finish_time() - exec.get_start_time();
}
});
// FIXME I think that this fires at the same time for all hosts, so when the src sends something,
XBT_WARN("HostLoad plugin currently does not support executions on several hosts");
}
});
- simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
- const auto* exec = dynamic_cast<simgrid::s4u::Exec const*>(&activity);
- if (exec == nullptr) // Only Execs are concerned here
- return;
- if (exec->get_host_number() == 1) { // We only run on one host
- simgrid::s4u::Host* host = exec->get_host();
+ simgrid::s4u::Exec::on_completion_cb([](simgrid::s4u::Exec const& exec) {
+ if (exec.get_host_number() == 1) { // We only run on one host
+ simgrid::s4u::Host* host = exec.get_host();
if (const auto* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host))
host = vm->get_pm();
xbt_assert(host != nullptr);
#include <simgrid/plugins/operation.hpp>
#include <simgrid/s4u/Comm.hpp>
#include <simgrid/s4u/Exec.hpp>
+#include <simgrid/s4u/Io.hpp>
#include <simgrid/simix.hpp>
#include "src/simgrid/module.hpp"
working_ = false;
count_++;
});
- if (end_func_)
- end_func_(this);
+ for (auto end_func : end_func_handlers_)
+ end_func(this);
Operation::on_end(this);
for (auto const& op : successors_)
op->receive(this);
return;
Operation::inited_ = true;
ExtendedAttributeActivity::EXTENSION_ID = simgrid::s4u::Activity::extension_create<ExtendedAttributeActivity>();
- simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
- activity.extension<ExtendedAttributeActivity>()->operation_->complete();
+ simgrid::s4u::Exec::on_completion_cb([](simgrid::s4u::Exec const& exec) {
+ exec.extension<ExtendedAttributeActivity>()->operation_->complete();
+ });
+ simgrid::s4u::Comm::on_completion_cb([](simgrid::s4u::Comm const& comm) {
+ comm.extension<ExtendedAttributeActivity>()->operation_->complete();
+ });
+ simgrid::s4u::Io::on_completion_cb([](simgrid::s4u::Io const& io) {
+ io.extension<ExtendedAttributeActivity>()->operation_->complete();
});
}
*/
void Operation::on_this_start(const std::function<void(Operation*)>& func)
{
- simgrid::kernel::actor::simcall_answered([this, &func] { start_func_ = func; });
+ simgrid::kernel::actor::simcall_answered([this, &func] { start_func_handlers_.push_back(func); });
}
/** @ingroup plugin_operation
*/
void Operation::on_this_end(const std::function<void(Operation*)>& func)
{
- simgrid::kernel::actor::simcall_answered([this, &func] { end_func_ = func; });
+ simgrid::kernel::actor::simcall_answered([this, &func] { end_func_handlers_.push_back(func); });
}
/** @ingroup plugin_operation
*/
void ExecOp::execute()
{
- if (start_func_)
- start_func_(this);
+ for (auto start_func : start_func_handlers_)
+ start_func(this);
Operation::on_start(this);
kernel::actor::simcall_answered([this] {
working_ = true;
*/
void CommOp::execute()
{
- if (start_func_)
- start_func_(this);
+ for (auto start_func : start_func_handlers_)
+ start_func(this);
Operation::on_start(this);
kernel::actor::simcall_answered([this] {
working_ = true;
return this;
}
+/**
+ * @brief Default constructor.
+ */
+IoOp::IoOp(const std::string& name) : Operation(name) {}
+
+/** @ingroup plugin_operation
+ * @brief Smart Constructor.
+ */
+IoOpPtr IoOp::init(const std::string& name)
+{
+ return IoOpPtr(new IoOp(name));
+}
+
+/** @ingroup plugin_operation
+ * @brief Smart Constructor.
+ */
+IoOpPtr IoOp::init(const std::string& name, double bytes, s4u::Disk* disk, s4u::Io::OpType type)
+{
+ return init(name)->set_bytes(bytes)->set_disk(disk)->set_op_type(type);
+}
+
+/** @ingroup plugin_operation
+ * @param disk The disk to set.
+ * @brief Set a new disk.
+ */
+IoOpPtr IoOp::set_disk(s4u::Disk* disk)
+{
+ kernel::actor::simcall_answered([this, disk] { disk_ = disk; });
+ return this;
+}
+
+/** @ingroup plugin_operation
+ * @param bytes The amount of bytes to set.
+ */
+IoOpPtr IoOp::set_bytes(double bytes)
+{
+ kernel::actor::simcall_answered([this, bytes] { amount_ = bytes; });
+ return this;
+}
+
+/** @ingroup plugin_operation
+ * @param bytes The amount of bytes to set.
+ */
+IoOpPtr IoOp::set_op_type(s4u::Io::OpType type)
+{
+ kernel::actor::simcall_answered([this, type] { type_ = type; });
+ return this;
+}
+
+void IoOp::execute()
+{
+ for (auto start_func : start_func_handlers_)
+ start_func(this);
+ Operation::on_start(this);
+ kernel::actor::simcall_answered([this] {
+ working_ = true;
+ queued_execs_ = std::max(queued_execs_ - 1, 0);
+ });
+ s4u::IoPtr io = s4u::Io::init();
+ io->set_name(name_);
+ io->set_size(amount_);
+ io->set_disk(disk_);
+ io->set_op_type(type_);
+ io->start();
+ io->extension_set(new ExtendedAttributeActivity());
+ io->extension<ExtendedAttributeActivity>()->operation_ = this;
+ kernel::actor::simcall_answered([this, io] { current_activity_ = io; });
+}
+
+
} // namespace simgrid::plugins
simgrid::xbt::Extension<simgrid::s4u::Activity, simgrid::plugins::ExtendedAttributeActivity>
}
}
-static void on_exec_completion(const simgrid::s4u::Activity& e)
+static void on_exec_completion(const simgrid::s4u::Exec& e)
{
const auto* exec = dynamic_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
if (exec == nullptr)
simgrid::kernel::resource::VirtualMachineImpl::extension_create<DirtyPageTrackingExt>();
simgrid::s4u::VirtualMachine::on_creation_cb(&on_virtual_machine_creation);
simgrid::s4u::Exec::on_start_cb(&on_exec_creation);
- simgrid::s4u::Activity::on_completion_cb(&on_exec_completion);
+ simgrid::s4u::Exec::on_completion_cb(&on_exec_completion);
}
}
namespace s4u {
xbt::signal<void(Activity&)> Activity::on_veto;
-xbt::signal<void(Activity const&)> Activity::on_completion;
xbt::signal<void(Activity const&)> Activity::on_suspend;
xbt::signal<void(Activity const&)> Activity::on_resume;
xbt_assert(src_buff_ == nullptr && dst_buff_ == nullptr,
"Direct host-to-host communications cannot carry any data.");
XBT_DEBUG("host-to-host Comm. Pimpl already created and set, just start it.");
+ on_send(*this);
+ on_recv(*this);
kernel::actor::simcall_answered([this] {
pimpl_->set_state(kernel::activity::State::READY);
boost::static_pointer_cast<kernel::activity::CommImpl>(pimpl_)->start();
}
// Recursive template code derived from Matthieu M.
-template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1> class HashValueImpl {
+template <class Tuple, size_t Index = std::tuple_size_v<Tuple> - 1> class HashValueImpl {
public:
static void apply(size_t& seed, Tuple const& tuple)
{
xbt_assert(argc > 1, "Usage: %s platform_file\n\nExample: %s two_clusters.xml", argv[0], argv[0]);
engine.load_platform(argv[1]);
- simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
- const auto* exec = dynamic_cast<simgrid::s4u::Exec const*>(&activity);
- if (exec == nullptr) // Only Execs are concerned here
- return;
- XBT_INFO("Exec '%s' start time: %f, finish time: %f", exec->get_cname(), exec->get_start_time(),
- exec->get_finish_time());
+ simgrid::s4u::Exec::on_completion_cb([](simgrid::s4u::Exec const& exec) {
+ XBT_INFO("Exec '%s' start time: %f, finish time: %f", exec.get_cname(), exec.get_start_time(),
+ exec.get_finish_time());
});
/* creation of the activities and their dependencies */