examples/msg/trace-platform/trace-platform
examples/msg/trace-host-user-variables/trace-host-user-variables
examples/s4u/app-masterworker/s4u_app-masterworker
+examples/s4u/app-pingpong/s4u_app-pingpong
examples/s4u/app-token-ring/s4u_app-token-ring
examples/s4u/actions-comm/s4u_actions-comm
examples/s4u/actions-storage/s4u_actions-storage
examples/s4u/actor-create/s4u_actor-create
+examples/s4u/actor-daemon/s4u_actor-daemon
examples/s4u/actor-kill/s4u_actor-kill
examples/s4u/actor-migration/s4u_actor-migration
examples/s4u/actor-suspend/s4u_actor-suspend
teshsuite/smpi/type-vector/type-vector
teshsuite/s4u/actor/actor
teshsuite/s4u/comm-pt2pt/comm-pt2pt
+teshsuite/s4u/comm-waitany/comm-waitany
teshsuite/s4u/concurrent_rw/concurrent_rw
teshsuite/s4u/host_on_off_wait/host_on_off_wait
teshsuite/s4u/listen_async/listen_async
create();
joinSuccess = true;
} else {
- int knownId = Integer.valueOf(args[1]);
- deadline = Integer.valueOf(args[3]);
+ int knownId = Integer.parseInt(args[1]);
+ deadline = Integer.parseInt(args[3]);
Msg.debug("Hey! Let's join the system with the id " + id + ".");
joinSuccess = join(knownId);
}
catch (MsgException e) {
commReceive = null;
- stop = true;
}
}
catch (MsgException e) {
# C examples
-foreach(x actions-comm actions-storage app-masterworker app-pingpong app-token-ring async-wait async-waitall
+foreach(x app-masterworker app-pingpong app-token-ring async-wait async-waitall
async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks
dht-pastry energy-consumption energy-onoff energy-pstate energy-ptask energy-vm platform-failures
io-file io-remote io-storage task-priority
set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/${file}.c ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/${file}.h)
endforeach()
-foreach (file actions-comm actions-storage app-bittorrent app-chainsend app-masterworker app-pingpong async-wait
+foreach (file app-bittorrent app-chainsend app-masterworker app-pingpong async-wait
async-waitall async-waitany dht-kademlia dht-pastry io-remote platform-properties process-yield
task-priority)
set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/${file}/${file}_d.xml)
endforeach()
-set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/README.doc
- ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/actions-comm.txt
- ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/actions-comm_split_p0.txt
- ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/actions-comm_split_p1.txt
- ${CMAKE_CURRENT_SOURCE_DIR}/actions-storage/actions-storage.txt PARENT_SCOPE)
+set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/README.doc PARENT_SCOPE)
set(bin_files ${bin_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/generate.py
${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/generate.py
${CMAKE_CURRENT_SOURCE_DIR}/dht-pastry/generate.py PARENT_SCOPE)
${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-multicore.tesh
${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-vivaldi.tesh
${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/network-ns3.tesh PARENT_SCOPE)
-set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/actions-comm_split_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-multicore_d.xml
+set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-multicore_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-vivaldi_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait2_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait3_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/process-startkilltime/start_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/process-startkilltime/start_kill_d.xml PARENT_SCOPE)
-foreach(x actions-comm actions-storage app-bittorrent app-chainsend app-masterworker app-pingpong app-token-ring
+foreach(x app-bittorrent app-chainsend app-masterworker app-pingpong app-token-ring
async-wait async-waitall async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple
cloud-two-tasks dht-pastry dht-kademlia platform-failures io-file io-remote io-storage task-priority
process-create process-daemon process-join process-kill process-migration process-startkilltime process-suspend process-yield
- @ref msg_ex_models
- @ref msg_ex_ns3
- @ref msg_ex_io
- - @ref msg_ex_actions
- @ref msg_ex_apps
- @ref msg_ex_misc
-
+
@section msg_ex_basics Basic examples and features
- <b>Ping Pong</b>: @ref examples/msg/app-pingpong/app-pingpong.c\n
It's hard to think of a simpler example: it is just sending one
message back and forth.
The tesh file laying in the directory show how to start the
- simulator binary, enlighting how to pass options to the simulators
+ simulator binary, highlighting how to pass options to the simulators
(as detailed in Section \ref options).
- <b>Token Ring</b>.
I/O operations can also be done in a remote, i.e. when the
accessed disk is not mounted on the caller's host.
-@section msg_ex_actions Following Workload Traces
-
-This section details how to run trace-driven simulations. It is very
-handy when you want to test an algorithm or protocol that only react
-to external events. For example, many P2P protocols react to user
-requests, but do nothing if there is no such event.
-
-In such situations, you should write your protocol in C, and separate
-the workload that you want to play onto your protocol in a separate
-text file. Declare a function handling each type of the events in your
-trace, register them using @ref xbt_replay_action_register in your
-main, and then use @ref MSG_action_trace_run to launch the simulation.
-
-Then, you can either have one trace file containing all your events,
-or a file per simulated process: the former may be easier to work
-with, but the second is more efficient on very large traces. Check
-also the tesh files in the example directories for details.
-
- - <b>Communication replay</b>.
- @ref examples/msg/actions-comm/actions-comm.c \n
- Presents a set of event handlers reproducing classical communication
- primitives (synchronous and asynchronous send/receive, broadcast,
- barrier, etc).
-
- - <b>I/O replay</b>.
- @ref examples/msg/actions-storage/actions-storage.c \n
- Presents a set of event handlers reproducing classical I/O
- primitives (open, read, write, close, etc).
-
-
@section msg_ex_misc Miscellaneous
- <b>Task priorities</b>.
/**
-@example examples/msg/app-pingpong/app-pingpong.c
-@example examples/msg/app-token-ring/app-token-ring.c
+@example examples/msg/app-pingpong/app-pingpong.c
+@example examples/msg/app-token-ring/app-token-ring.c
@example examples/msg/app-masterworker/app-masterworker.c
@example examples/msg/async-wait/async-wait.c
@example examples/msg/io-file/io-file.c
@example examples/msg/io-remote/io-remote.c
-@example examples/msg/actions-comm/actions-comm.c
-@example examples/msg/actions-storage/actions-storage.c
-
@example examples/msg/task-priority/task-priority.c
@example examples/msg/platform-properties/platform-properties.c
-
+
*/
#include "simgrid/msg.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(mag_app_pingpong,"Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_app_pingpong, "Messages specific for this msg example");
static int pinger(int argc, char *argv[])
{
msg_host_t host = MSG_host_by_name("MyHost1");
XBT_INFO("Energetic profile: %s",MSG_host_get_property_value(host,"watt_per_state"));
- XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", MSG_host_get_current_power_peak(host),
+ XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", MSG_host_get_speed(host),
sg_host_get_consumed_energy(host));
double start = MSG_get_clock();
XBT_INFO("Sleep for 10 seconds");
MSG_process_sleep(10);
- XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E; Energy dissipated=%.2f J", MSG_get_clock()-start,
- MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
+ XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E; Energy dissipated=%.2f J",
+ MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_consumed_energy(host));
// Run a task
start = MSG_get_clock();
MSG_task_execute (task1);
MSG_task_destroy(task1);
XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW"
- " depending on load; Energy dissipated=%.0f J", MSG_get_clock()-start,
- MSG_host_get_current_power_peak(host), sg_host_get_wattmin_at(host,MSG_host_get_pstate(host)),
- sg_host_get_wattmax_at(host,MSG_host_get_pstate(host)), sg_host_get_consumed_energy(host));
+ " depending on load; Energy dissipated=%.0f J",
+ MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_wattmin_at(host, MSG_host_get_pstate(host)),
+ sg_host_get_wattmax_at(host, MSG_host_get_pstate(host)), sg_host_get_consumed_energy(host));
// ========= Change power peak =========
int pstate=2;
MSG_host_set_pstate(host, pstate);
- XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)",
- pstate, MSG_host_get_power_peak_at(host, pstate), MSG_host_get_current_power_peak(host));
+ XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)", pstate,
+ MSG_host_get_power_peak_at(host, pstate), MSG_host_get_speed(host));
// Run a second task
start = MSG_get_clock();
MSG_task_execute (task1);
MSG_task_destroy(task1);
XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
- MSG_get_clock()-start, MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
+ MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_consumed_energy(host));
start = MSG_get_clock();
XBT_INFO("Sleep for 4 seconds");
MSG_process_sleep(4);
XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
- MSG_get_clock()-start, MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
+ MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_consumed_energy(host));
// =========== Turn the other host off ==========
XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 dissipated %.0f J so far.",
start = MSG_get_clock();
MSG_process_sleep(10);
XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
- MSG_get_clock()-start, MSG_host_get_current_power_peak(host), sg_host_get_consumed_energy(host));
+ MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_consumed_energy(host));
return 0;
}
msg_host_t host1 = MSG_host_by_name("MyHost1");
XBT_INFO("Energetic profile: %s", MSG_host_get_property_value(host1,"watt_per_state"));
- XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J",
- MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
+ XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", MSG_host_get_speed(host1),
+ sg_host_get_consumed_energy(host1));
XBT_INFO("Sleep for 10 seconds");
MSG_process_sleep(10);
- XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
- MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
+ XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J", MSG_host_get_speed(host1),
+ sg_host_get_consumed_energy(host1));
simulate_shutdown(host1);
- XBT_INFO("Host1 is now OFF. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
- MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
+ XBT_INFO("Host1 is now OFF. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", MSG_host_get_speed(host1),
+ sg_host_get_consumed_energy(host1));
XBT_INFO("Sleep for 10 seconds");
MSG_process_sleep(10);
- XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
- MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
+ XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J", MSG_host_get_speed(host1),
+ sg_host_get_consumed_energy(host1));
simulate_bootup(host1);
- XBT_INFO("Host1 is now ON again. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
- MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));
+ XBT_INFO("Host1 is now ON again. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", MSG_host_get_speed(host1),
+ sg_host_get_consumed_energy(host1));
return 0;
}
int nb = MSG_host_get_nb_pstates(host);
XBT_INFO("Count of Processor states=%d", nb);
- double current_peak = MSG_host_get_current_power_peak(host);
+ double current_peak = MSG_host_get_speed(host);
XBT_INFO("Current power peak=%f", current_peak);
// Run a task
MSG_host_set_pstate(host, new_pstate);
- current_peak = MSG_host_get_current_power_peak(host);
+ current_peak = MSG_host_get_speed(host);
XBT_INFO("Current power peak=%f", current_peak);
// Run a second task
int nb2 = MSG_host_get_nb_pstates(host);
XBT_INFO("Count of Processor states=%d", nb2);
- double current_peak2 = MSG_host_get_current_power_peak(host);
+ double current_peak2 = MSG_host_get_speed(host);
XBT_INFO("Current power peak=%f", current_peak2);
return 0;
}
xbt_dynar_free(&hosts);
int res = MSG_main();
- XBT_INFO("Simulation time %g", MSG_get_clock());
+ XBT_INFO("Simulation time %.6f", MSG_get_clock());
return res != MSG_OK;
}
> [ 0.008326] (3:host@carl) Have written 110000 in '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'. Size now is: 110000
> [ 0.008326] (3:host@carl) Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' is stored on: 37020686 / 536870912000
> [ 0.008326] (3:host@carl) Close file '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
-> [ 0.008326] (0:maestro@) Simulation time 0.00832645
+> [ 0.008326] (0:maestro@) Simulation time 0.008326
msg_host_t host = MSG_host_by_name("MyHost1");
XBT_INFO("Initial peak speed: %.0E flop/s; number of flops computed so far: %.0E (should be 0)",
- MSG_host_get_current_power_peak(host), MSG_host_get_computed_flops(host));
+ MSG_host_get_speed(host), sg_host_get_computed_flops(host));
double start = MSG_get_clock();
XBT_INFO("Sleep for 10 seconds");
XBT_INFO("Done sleeping %.2fs; peak speed: %.0E flop/s; number of flops computed so far: %.0E (nothing should have "
"changed)",
- MSG_get_clock() - start, MSG_host_get_current_power_peak(host), MSG_host_get_computed_flops(host));
+ MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
// Run a task
start = MSG_get_clock();
XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
"far: %.0E",
- MSG_get_clock() - start, MSG_host_get_current_power_peak(host), MSG_host_get_computed_flops(host));
+ MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
// ========= Change power peak =========
int pstate = 2;
- MSG_host_set_pstate(host, pstate);
+ sg_host_set_pstate(host, pstate);
XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)", pstate,
- MSG_host_get_power_peak_at(host, pstate), MSG_host_get_current_power_peak(host));
+ MSG_host_get_power_peak_at(host, pstate), MSG_host_get_speed(host));
// Run a second task
start = MSG_get_clock();
MSG_task_destroy(task1);
XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
"far: %.0E",
- MSG_get_clock() - start, MSG_host_get_current_power_peak(host), MSG_host_get_computed_flops(host));
+ MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
start = MSG_get_clock();
XBT_INFO("========= Requesting a reset of the computation counter");
XBT_INFO("Sleep for 4 seconds");
MSG_process_sleep(4);
XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
- MSG_get_clock() - start, MSG_host_get_current_power_peak(host), MSG_host_get_computed_flops(host));
+ MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
// =========== Turn the other host off ==========
XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed %.0f flops so far.",
start = MSG_get_clock();
MSG_process_sleep(10);
XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
- MSG_get_clock() - start, MSG_host_get_current_power_peak(host), MSG_host_get_computed_flops(host));
+ MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
return 0;
}
foreach (example actions-comm actions-storage actor-create actor-daemon actor-kill actor-migration actor-suspend
- app-masterworker app-token-ring io mutex )
+ app-masterworker app-pingpong app-token-ring plugin-hostload io mutex )
add_executable (s4u_${example} ${example}/s4u_${example}.cpp)
target_link_libraries(s4u_${example} simgrid)
set_target_properties(s4u_${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
${CMAKE_CURRENT_SOURCE_DIR}/README.doc PARENT_SCOPE)
foreach(example actions-comm actions-storage actor-create actor-daemon actor-kill actor-migration actor-suspend
- app-masterworker app-token-ring dht-chord io mutex )
+ app-masterworker app-pingpong app-token-ring dht-chord plugin-hostload io mutex )
ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example} s4u_${example}.tesh)
endforeach()
@ref examples/s4u/actor-create/s4u_actor-create_d.xml \n
Shows how to start your actors to populate your simulation.
+ - <b>Ping Pong</b>: @ref examples/s4u/app-pingpong/s4u_app-pingpong.c\n
+ It's hard to think of a simpler example: it is just sending one message back and forth.
+ The tesh file laying in the directory show how to start the simulator binary, highlighting how to pass options to
+ the simulators (as detailed in Section \ref options).
+
- <b>Token ring:</b> @ref examples/s4u/app-token-ring/s4u_app-token-ring.cpp \n
Shows how to implement a classical communication pattern, where a token is exchanged along a ring to reach every
participant.
@ref examples/s4u/actor-create/s4u_actor-create.cpp \n
Most actors are started from the deployment XML file, but they exist other methods.
+ - <b>Daemonize actors</b>
+ @ref examples/s4u/actor-daemon/s4u_actor-daemon.cpp \n
+ Some actors may be intended to simulate daemons that run in background. This example show how to transform a regular
+ actor into a daemon that will be automatically killed once the simulation is over.
+
- <b>Suspend and Resume actors</b>.
@ref examples/s4u/actor-suspend/s4u_actor-suspend.cpp \n
Actors can be suspended and resumed during their executions
@example examples/s4u/actions-storage/s4u_actions-storage.cpp
@example examples/s4u/actor-create/s4u_actor-create.cpp
@example examples/s4u/actor-create/s4u_actor-create_d.xml
+@example examples/s4u/actor-daemon/s4u_actor-daemon.cpp
@example examples/s4u/actor-kill/s4u_actor-kill.cpp
@example examples/s4u/actor-migration/s4u_actor-migration.cpp
@example examples/s4u/actor-suspend/s4u_actor-suspend.cpp
@example examples/s4u/app-token-ring/s4u_app-token-ring.cpp
@example examples/s4u/app-masterworker/s4u_app-masterworker.cpp
+@example examples/s4u/app-pingpong/s4u_app-pingpong.cpp
@example examples/s4u/mutex/s4u_mutex.cpp
--- /dev/null
+/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "simgrid/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_pingpong, "Messages specific for this s4u example");
+
+static void pinger(std::vector<std::string> args)
+{
+ xbt_assert(args.size() == 1, "The pinger function one argument from the XML deployment file");
+ XBT_INFO("Ping -> %s", args[0].c_str());
+ xbt_assert(simgrid::s4u::Host::by_name_or_null(args[0]) != nullptr, "Unknown host %s. Stopping Now! ",
+ args[0].c_str());
+
+ /* - Do the ping with a 1-Byte task (latency bound) ... */
+ double* payload = new double();
+ *payload = simgrid::s4u::Engine::getClock();
+
+ simgrid::s4u::Mailbox::byName(args[0])->put(payload, 1);
+ /* - ... then wait for the (large) pong */
+ double* sender_time =
+ static_cast<double*>(simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::getHost()->getName())->get());
+
+ double communication_time = simgrid::s4u::Engine::getClock() - *sender_time;
+ XBT_INFO("Task received : large communication (bandwidth bound)");
+ XBT_INFO("Pong time (bandwidth bound): %.3f", communication_time);
+ delete sender_time;
+}
+
+static void ponger(std::vector<std::string> args)
+{
+ xbt_assert(args.size() == 1, "The ponger function one argument from the XML deployment file");
+ XBT_INFO("Pong -> %s", args[0].c_str());
+ xbt_assert(simgrid::s4u::Host::by_name_or_null(args[0]) != nullptr, "Unknown host %s. Stopping Now! ",
+ args[0].c_str());
+
+ /* - Receive the (small) ping first ....*/
+ double* sender_time =
+ static_cast<double*>(simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::getHost()->getName())->get());
+ double communication_time = simgrid::s4u::Engine::getClock() - *sender_time;
+ XBT_INFO("Task received : small communication (latency bound)");
+ XBT_INFO(" Ping time (latency bound) %f", communication_time);
+ delete sender_time;
+
+ /* - ... Then send a 1GB pong back (bandwidth bound) */
+ double* payload = new double();
+ *payload = simgrid::s4u::Engine::getClock();
+ XBT_INFO("task_bw->data = %.3f", *payload);
+
+ simgrid::s4u::Mailbox::byName(args[0])->put(payload, 1e9);
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+
+ e->loadPlatform(argv[1]);
+ std::vector<std::string> args;
+ args.push_back("Jupiter");
+ simgrid::s4u::Actor::createActor("pinger", simgrid::s4u::Host::by_name("Tremblay"), pinger, args);
+
+ args.pop_back();
+ args.push_back("Tremblay");
+
+ simgrid::s4u::Actor::createActor("ponger", simgrid::s4u::Host::by_name("Jupiter"), ponger, args);
+
+ e->run();
+
+ XBT_INFO("Total simulation time: %.3f", e->getClock());
+ delete e;
+
+ return 0;
+}
--- /dev/null
+#! ./tesh
+
+p Testing with default compound
+
+$ $SG_TEST_EXENV ${bindir:=.}/s4u_app-pingpong$EXEEXT ${srcdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (1:pinger@Tremblay) Ping -> Jupiter
+> [ 0.000000] (2:ponger@Jupiter) Pong -> Tremblay
+> [ 0.019014] (2:ponger@Jupiter) Task received : small communication (latency bound)
+> [ 0.019014] (2:ponger@Jupiter) Ping time (latency bound) 0.019014
+> [ 0.019014] (2:ponger@Jupiter) task_bw->data = 0.019
+> [150.178356] (1:pinger@Tremblay) Task received : large communication (bandwidth bound)
+> [150.178356] (1:pinger@Tremblay) Pong time (bandwidth bound): 150.159
+> [150.178356] (0:maestro@) Total simulation time: 150.178
+
+p Testing the deprecated CM02 network model
+
+$ $SG_TEST_EXENV ${bindir:=.}/s4u_app-pingpong$EXEEXT ${srcdir:=.}/small_platform.xml --cfg=cpu/model:Cas01 --cfg=network/model:CM02 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (0:maestro@) Configuration change: Set 'cpu/model' to 'Cas01'
+> [ 0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'CM02'
+> [ 0.000000] (1:pinger@Tremblay) Ping -> Jupiter
+> [ 0.000000] (2:ponger@Jupiter) Pong -> Tremblay
+> [ 0.001462] (2:ponger@Jupiter) Task received : small communication (latency bound)
+> [ 0.001462] (2:ponger@Jupiter) Ping time (latency bound) 0.001462
+> [ 0.001462] (2:ponger@Jupiter) task_bw->data = 0.001
+> [145.639041] (1:pinger@Tremblay) Task received : large communication (bandwidth bound)
+> [145.639041] (1:pinger@Tremblay) Pong time (bandwidth bound): 145.638
+> [145.639041] (0:maestro@) Total simulation time: 145.639
+
+p Testing the surf network Reno fairness model using lagrangian approach
+
+$ $SG_TEST_EXENV ${bindir:=.}/s4u_app-pingpong$EXEEXT ${srcdir:=.}/small_platform.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Reno" --log=surf_lagrange.thres=critical "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (0:maestro@) Configuration change: Set 'host/model' to 'compound'
+> [ 0.000000] (0:maestro@) Configuration change: Set 'cpu/model' to 'Cas01'
+> [ 0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'Reno'
+> [ 0.000000] (1:pinger@Tremblay) Ping -> Jupiter
+> [ 0.000000] (2:ponger@Jupiter) Pong -> Tremblay
+> [ 0.019014] (2:ponger@Jupiter) Task received : small communication (latency bound)
+> [ 0.019014] (2:ponger@Jupiter) Ping time (latency bound) 0.019014
+> [ 0.019014] (2:ponger@Jupiter) task_bw->data = 0.019
+> [150.178356] (1:pinger@Tremblay) Task received : large communication (bandwidth bound)
+> [150.178356] (1:pinger@Tremblay) Pong time (bandwidth bound): 150.159
+> [150.178356] (0:maestro@) Total simulation time: 150.178
+
+p Testing the surf network Vegas fairness model using lagrangian approach
+
+$ $SG_TEST_EXENV ${bindir:=.}/s4u_app-pingpong$EXEEXT ${srcdir:=.}/small_platform.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Vegas" "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (0:maestro@) Configuration change: Set 'host/model' to 'compound'
+> [ 0.000000] (0:maestro@) Configuration change: Set 'cpu/model' to 'Cas01'
+> [ 0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'Vegas'
+> [ 0.000000] (1:pinger@Tremblay) Ping -> Jupiter
+> [ 0.000000] (2:ponger@Jupiter) Pong -> Tremblay
+> [ 0.019014] (2:ponger@Jupiter) Task received : small communication (latency bound)
+> [ 0.019014] (2:ponger@Jupiter) Ping time (latency bound) 0.019014
+> [ 0.019014] (2:ponger@Jupiter) task_bw->data = 0.019
+> [150.178356] (1:pinger@Tremblay) Task received : large communication (bandwidth bound)
+> [150.178356] (1:pinger@Tremblay) Pong time (bandwidth bound): 150.159
+> [150.178356] (0:maestro@) Total simulation time: 150.178
--- /dev/null
+/* Copyright (c) 2007-2010, 2013-2015. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "simgrid/s4u.hpp"
+#include "simgrid/plugins/load.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+
+static void execute_load_test()
+{
+ s4u_Host* host = simgrid::s4u::Host::by_name("MyHost1");
+
+ XBT_INFO("Initial peak speed: %.0E flop/s; number of flops computed so far: %.0E (should be 0)", host->getSpeed(),
+ sg_host_get_computed_flops(host));
+
+ double start = simgrid::s4u::Engine::getClock();
+ XBT_INFO("Sleep for 10 seconds");
+ simgrid::s4u::this_actor::sleep_for(10);
+
+ XBT_INFO("Done sleeping %.2fs; peak speed: %.0E flop/s; number of flops computed so far: %.0E (nothing should have "
+ "changed)",
+ simgrid::s4u::Engine::getClock() - start, host->getSpeed(), sg_host_get_computed_flops(host));
+
+ // Run a task
+ start = simgrid::s4u::Engine::getClock();
+ XBT_INFO("Run a task of %.0E flops", 100E6);
+ simgrid::s4u::this_actor::execute(100E6);
+
+ XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
+ "far: %.0E",
+ simgrid::s4u::Engine::getClock() - start, host->getSpeed(), sg_host_get_computed_flops(host));
+
+ // ========= Change power peak =========
+ int pstate = 2;
+ host->setPstate(pstate);
+ XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)", pstate,
+ host->getPstateSpeed(pstate), host->getSpeed());
+
+ // Run a second task
+ start = simgrid::s4u::Engine::getClock();
+ XBT_INFO("Run a task of %.0E flops", 100E6);
+ simgrid::s4u::this_actor::execute(100E6);
+ XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
+ "far: %.0E",
+ simgrid::s4u::Engine::getClock() - start, host->getSpeed(), sg_host_get_computed_flops(host));
+
+ start = simgrid::s4u::Engine::getClock();
+ XBT_INFO("========= Requesting a reset of the computation counter");
+ sg_host_load_reset(host);
+ XBT_INFO("Sleep for 4 seconds");
+ simgrid::s4u::this_actor::sleep_for(4);
+ XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
+ simgrid::s4u::Engine::getClock() - start, host->getSpeed(), sg_host_get_computed_flops(host));
+
+ // =========== Turn the other host off ==========
+ s4u_Host* host2 = simgrid::s4u::Host::by_name("MyHost2");
+ XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed %.0f flops so far.",
+ sg_host_get_computed_flops(host2));
+ host2->turnOff();
+ start = simgrid::s4u::Engine::getClock();
+ simgrid::s4u::this_actor::sleep_for(10);
+ XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
+ simgrid::s4u::Engine::getClock() - start, host->getSpeed(), sg_host_get_computed_flops(host));
+}
+
+int main(int argc, char* argv[])
+{
+ sg_host_load_plugin_init();
+ simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+
+ xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
+ e->loadPlatform(argv[1]);
+
+ simgrid::s4u::Actor::createActor("load_test", simgrid::s4u::Host::by_name("MyHost1"), execute_load_test);
+
+ e->run();
+
+ XBT_INFO("Total simulation time: %.2f", simgrid::s4u::Engine::getClock());
+
+ delete e;
+ return 0;
+}
--- /dev/null
+#! ./tesh
+
+p This tests the HostLoad plugin (this allows the user to get the current load of a host and the computed flops)
+
+$ ${bindir:=.}/s4u_plugin-hostload$EXEEXT ${srcdir:=.}/../platforms/energy_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (1:load_test@MyHost1) Initial peak speed: 1E+08 flop/s; number of flops computed so far: 0E+00 (should be 0)
+> [ 0.000000] (1:load_test@MyHost1) Sleep for 10 seconds
+> [ 10.000000] (1:load_test@MyHost1) Done sleeping 10.00s; peak speed: 1E+08 flop/s; number of flops computed so far: 0E+00 (nothing should have changed)
+> [ 10.000000] (1:load_test@MyHost1) Run a task of 1E+08 flops
+> [ 11.000000] (1:load_test@MyHost1) Done working on my task; this took 1.00s; current peak speed: 1E+08 flop/s; number of flops computed so far: 1E+08
+> [ 11.000000] (1:load_test@MyHost1) ========= Requesting pstate 2 (speed should be of 2E+07 flop/s and is of 2E+07 flop/s)
+> [ 11.000000] (1:load_test@MyHost1) Run a task of 1E+08 flops
+> [ 16.000000] (1:load_test@MyHost1) Done working on my task; this took 5.00s; current peak speed: 2E+07 flop/s; number of flops computed so far: 2E+08
+> [ 16.000000] (1:load_test@MyHost1) ========= Requesting a reset of the computation counter
+> [ 16.000000] (1:load_test@MyHost1) Sleep for 4 seconds
+> [ 20.000000] (1:load_test@MyHost1) Done sleeping 4.00 s; peak speed: 2E+07 flop/s; number of flops computed so far: 0E+00
+> [ 20.000000] (1:load_test@MyHost1) Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed 0 flops so far.
+> [ 30.000000] (1:load_test@MyHost1) Done sleeping 10.00 s; peak speed: 2E+07 flop/s; number of flops computed so far: 0E+00
+> [ 30.000000] (0:maestro@) Total simulation time: 30.00
XBT_PUBLIC(void) MC_ignore(void *addr, size_t size);
XBT_PUBLIC(void) MC_ignore_heap(void* address, size_t size);
-XBT_PUBLIC(void) MC_remove_ignore_heap(void* address, size_t size);
+XBT_PUBLIC(void) MC_unignore_heap(void* address, size_t size);
XBT_PUBLIC(void) MC_ignore_local_variable(const char* var_name, const char* frame);
XBT_PUBLIC(void) MC_ignore_global_variable(const char* var_name);
XBT_PUBLIC(void) MSG_zone_set_property_value(msg_netzone_t netzone, const char* name, char* value);
XBT_PUBLIC(void) MSG_zone_get_hosts(msg_netzone_t zone, xbt_dynar_t whereto);
-/* Deprecated forms of the previous functions */
-static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_get_root since v3.16")
- msg_netzone_t MSG_environment_get_routing_root() {
+static inline XBT_ATTRIB_DEPRECATED_v319(
+ "Use MSG_zone_get_root() instead: v3.19 will remove MSG_environment_get_routing_root() completely.") msg_netzone_t
+ MSG_environment_get_routing_root()
+{
return MSG_zone_get_root();
}
-static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_get_name since v3.16")
- const char* MSG_environment_as_get_name(msg_netzone_t zone) {
+static inline XBT_ATTRIB_DEPRECATED_v319(
+ "Use MSG_zone_get_name() instead: v3.19 will remove MSG_environment_as_get_name() completely.") const
+ char* MSG_environment_as_get_name(msg_netzone_t zone)
+{
return MSG_zone_get_name(zone);
}
-static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_get_by_name since v3.16")
- msg_netzone_t MSG_environment_as_get_by_name(const char* name) {
+static inline XBT_ATTRIB_DEPRECATED_v319(
+ "Use MSG_zone_get_by_name() instead: v3.19 will remove MSG_environment_as_get_by_name() completely.") msg_netzone_t
+ MSG_environment_as_get_by_name(const char* name)
+{
return MSG_zone_get_by_name(name);
}
-static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_get_sons since v3.16")
- xbt_dict_t MSG_environment_as_get_routing_sons(msg_netzone_t zone) {
+static inline XBT_ATTRIB_DEPRECATED_v319(
+ "Use MSG_zone_get_sons() instead: v3.19 will remove MSG_environment_as_get_routing_sons() completely.") xbt_dict_t
+ MSG_environment_as_get_routing_sons(msg_netzone_t zone)
+{
xbt_dict_t res = xbt_dict_new_homogeneous(NULL);
MSG_zone_get_sons(zone, res);
return res;
}
-static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_get_property_value since v3.16")
- const char* MSG_environment_as_get_property_value(msg_netzone_t zone, const char* name) {
+static inline XBT_ATTRIB_DEPRECATED_v319(
+ "Use MSG_zone_get_property_value() instead: v3.19 will remove MSG_environment_as_get_property_value() completely.")
+ const char* MSG_environment_as_get_property_value(msg_netzone_t zone, const char* name)
+{
return MSG_zone_get_property_value(zone, name);
}
-static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_set_property_value since v3.16")
- void MSG_environment_as_set_property_value(msg_netzone_t zone, const char* name, char* value) {
+static inline XBT_ATTRIB_DEPRECATED_v319(
+ "Use MSG_zone_set_property_value() instead: v3.19 will remove MSG_environment_as_set_property_value() "
+ "completely.") void MSG_environment_as_set_property_value(msg_netzone_t zone, const char* name, char* value)
+{
MSG_zone_set_property_value(zone, name, value);
}
-static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_get_hosts since v3.16")
- xbt_dynar_t MSG_environment_as_get_hosts(msg_netzone_t zone) {
+static inline XBT_ATTRIB_DEPRECATED_v319(
+ "Use MSG_zone_get_hosts() instead: v3.19 will remove MSG_environment_as_get_hosts() completely.") xbt_dynar_t
+ MSG_environment_as_get_hosts(msg_netzone_t zone)
+{
xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), NULL);
MSG_zone_get_hosts(zone, res);
return res;
XBT_PUBLIC(int) MSG_host_is_on(msg_host_t h);
XBT_PUBLIC(int) MSG_host_is_off(msg_host_t h);
-XBT_PUBLIC(double) MSG_get_host_speed(msg_host_t h); /* deprecated */
+static inline double
+ XBT_ATTRIB_DEPRECATED_v319("Use MSG_host_get_speed(): v3.19 will drop MSG_get_host_speed() completely.")
+ MSG_get_host_speed(msg_host_t host)
+{
+ return MSG_host_get_speed(host);
+}
+static inline double XBT_ATTRIB_DEPRECATED_v320(
+ "Use MSG_host_get_speed(): v3.20 will drop MSG_host_get_current_power_peak() completely.")
+ MSG_host_get_current_power_peak(msg_host_t host)
+{
+ return MSG_host_get_speed(host);
+}
XBT_PUBLIC(double) MSG_host_get_power_peak_at(msg_host_t h, int pstate);
-#define MSG_host_get_current_power_peak(h) MSG_host_get_speed(h) /* deprecated */
XBT_PUBLIC(int) MSG_host_get_nb_pstates(msg_host_t h);
-#define MSG_host_get_pstate(h) sg_host_get_pstate(h) /* deprecated */
-#define MSG_host_set_pstate(h, pstate) sg_host_set_pstate(h, pstate) /* deprecated */
+#define MSG_host_get_pstate(h) sg_host_get_pstate(h) /* users don't know that MSG is the C version of SimGrid */
+#define MSG_host_set_pstate(h, pstate) sg_host_set_pstate(h, pstate) /* (same here) */
XBT_PUBLIC(xbt_dynar_t) MSG_hosts_as_dynar();
XBT_PUBLIC(int) MSG_get_host_number();
XBT_PUBLIC(xbt_dict_t) MSG_host_get_mounted_storage_list(msg_host_t host);
this_actor::sleep_until(timeout_native.time_since_epoch().count());
}
- XBT_ATTRIB_DEPRECATED("Use sleep_for()")
- inline void sleep(double duration)
+ XBT_ATTRIB_DEPRECATED_v320("Use sleep_for(): v3.20 will drop sleep() completely.") inline void sleep(double duration)
{
return sleep_for(duration);
}
*
* See \ref Comm for the full communication API (including non blocking communications).
*/
- XBT_PUBLIC(void*) XBT_ATTRIB_DEPRECATED("Please use Mailbox::get") recv(MailboxPtr chan); // 3.17
- XBT_PUBLIC(void*) XBT_ATTRIB_DEPRECATED("Please use Mailbox::get") recv(MailboxPtr chan, double timeout); // 3.17
+ XBT_PUBLIC(void*)
+ XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::get(): v3.20 will remove Actor::recv() completely.") recv(MailboxPtr chan);
+ XBT_PUBLIC(void*)
+ XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::get(): v3.20 will remove Actor::recv() completely.")
+ recv(MailboxPtr chan, double timeout);
XBT_PUBLIC(CommPtr)
- XBT_ATTRIB_DEPRECATED("Please use Mailbox::recv_async") irecv(MailboxPtr chan, void** data); // 3.17
+ XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::recv_async(): v3.20 will remove Actor::irecv() completely.")
+ irecv(MailboxPtr chan, void** data);
/** Block the actor until it delivers a message of the given simulated size to the given mailbox
*
* See \ref Comm for the full communication API (including non blocking communications).
*/
XBT_PUBLIC(void)
- XBT_ATTRIB_DEPRECATED("Please use Mailbox::put") send(MailboxPtr chan, void* payload, double simulatedSize); // 3.17
+ XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::put(): v3.20 will remove Actor::send() completely.")
+ send(MailboxPtr chan, void* payload, double simulatedSize); // 3.17
XBT_PUBLIC(void)
- XBT_ATTRIB_DEPRECATED("Please use Mailbox::put")
- send(MailboxPtr chan, void* payload, double simulatedSize, double timeout); // 3.17
+ XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::put(): v3.20 will remove Actor::send() completely.")
+ send(MailboxPtr chan, void* payload, double simulatedSize, double timeout); // 3.17
XBT_PUBLIC(CommPtr)
- XBT_ATTRIB_DEPRECATED("Please use Mailbox::put_async") isend(MailboxPtr chan, void* payload, double simulatedSize);
+ XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::put_async(): v3.20 will remove Actor::isend() completely.")
+ isend(MailboxPtr chan, void* payload, double simulatedSize);
/** @brief Returns the actor ID of the current actor (same as pid). */
XBT_PUBLIC(aid_t) getPid();
-/* Copyright (c) 2006-2016. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2017. 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/forward.h>
#include <simgrid/s4u/Activity.hpp>
-#include <simgrid/s4u/Mailbox.hpp> // DEPRECATED 3.17
+#include <simgrid/s4u/Mailbox.hpp> // DEPRECATED 3.20
#include <simgrid/s4u/forward.hpp>
#include <vector>
return idx;
}
/** Creates (but don't start) an async send to the mailbox @p dest */
- static CommPtr XBT_ATTRIB_DEPRECATED("please use Mailbox::put_init") // 3.17
+ static CommPtr XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::put_init(): v3.20 will remove Comm::send_init() completely.")
send_init(MailboxPtr dest)
{
return dest->put_init();
}
/** Creates (but don't start) an async send to the mailbox @p dest */
- static CommPtr XBT_ATTRIB_DEPRECATED("please use Mailbox::put_init") // 3.17
+ static CommPtr XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::put_init(): v3.20 will remove Comm::send_init() completely.")
send_init(MailboxPtr dest, void* data, int simulatedByteAmount)
{
return dest->put_init(data, simulatedByteAmount);
}
/** Creates and start an async send to the mailbox @p dest */
- static CommPtr XBT_ATTRIB_DEPRECATED("please use Mailbox::put_async") // 3.17
+ static CommPtr XBT_ATTRIB_DEPRECATED_v320(
+ "Use Mailbox::put_async(): v3.20 will remove Comm::send_async() completely.")
send_async(MailboxPtr dest, void* data, int simulatedByteAmount)
{
return dest->put_async(data, simulatedByteAmount);
}
/** Creates (but don't start) an async recv onto the mailbox @p from */
- static CommPtr XBT_ATTRIB_DEPRECATED("please use Mailbox::get_init") // 3.17
+ static CommPtr XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::get_init(): v3.20 will remove Comm::recv_init() completely.")
recv_init(MailboxPtr from)
{
return from->get_init();
}
/** Creates and start an async recv to the mailbox @p from */
- static CommPtr XBT_ATTRIB_DEPRECATED("please use Mailbox::get_async") // 3.17
+ static CommPtr XBT_ATTRIB_DEPRECATED_v320(
+ "Use Mailbox::get_async(): v3.20 will remove Comm::recv_async() completely.")
recv_async(MailboxPtr from, void** data)
{
return from->get_async(data);
void notify_one();
void notify_all();
- XBT_ATTRIB_DEPRECATED("Use notify_one() instead")
- void notify() { notify_one(); }
+ XBT_ATTRIB_DEPRECATED_v319("Use notify_one(): v3.19 will remove notify() completely.") void notify() { notify_one(); }
};
using ConditionVariablePtr = ConditionVariable::Ptr;
/** Simulates a write action. Returns the size of data actually written. */
sg_size_t write(sg_size_t size);
- sg_size_t write(sg_size_t size, sg_host_t host);
/** Allows to store user data on that host */
void setUserdata(void* data) { userdata_ = data; }
XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
/***************************** File **********************************/
-XBT_PUBLIC(sg_size_t) simcall_file_read(surf_file_t fd, sg_size_t size, sg_host_t host);
-XBT_PUBLIC(sg_size_t) simcall_file_write(surf_file_t fd, sg_size_t size, sg_host_t host);
+XBT_PUBLIC(sg_size_t) simcall_file_read(surf_file_t fd, sg_size_t size);
+XBT_PUBLIC(sg_size_t) simcall_file_write(surf_file_t fd, sg_size_t size);
/************************** MC simcalls **********************************/
XBT_PUBLIC(int) simcall_mc_random(int min, int max);
/* xbt.h - Public interface to the xbt (simgrid's toolbox) */
-/* Copyright (c) 2004-2015. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2017. 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. */
#define XBT_ATTRIB_NORETURN __attribute__((noreturn))
#define XBT_ATTRIB_UNUSED __attribute__((unused))
-#define XBT_ATTRIB_DEPRECATED(m) __attribute__((deprecated(m)))
+#define XBT_ATTRIB_DEPRECATED_v319(msg) __attribute__((deprecated(msg))) /* Will be dropped in v3.19 */
+#define XBT_ATTRIB_DEPRECATED_v320(msg) __attribute__((deprecated(msg))) /* Will be dropped in v3.20 */
/* Constructor priorities exist since gcc 4.3. Apparently, they are however not
* supported on Macs. */
typedef void *(*pvoid_f_pvoid_t) (void *);
typedef void (*void_f_void_t) (void);
-typedef int (*int_f_void_t) (void);
typedef int (*int_f_pvoid_t) (void*);
typedef int (*int_f_pvoid_pvoid_t) (void *, void *);
char noarg[] = {'\0'};
const int argc = args_->size();
std::vector<std::string> args = *args_;
- std::unique_ptr<char*[]> argv(new char*[argc + 1]);
- for (int i = 0; i != argc; ++i)
- argv[i] = args[i].empty() ? noarg : &args[i].front();
- argv[argc] = nullptr;
- code_(argc, argv.get());
+ if (not args.empty()) {
+ std::unique_ptr<char* []> argv(new char*[argc + 1]);
+ for (int i = 0; i != argc; ++i)
+ argv[i] = args[i].empty() ? noarg : &args[i].front();
+ argv[argc] = nullptr;
+ code_(argc, argv.get());
+ } else
+ code_(argc, nullptr);
}
};
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentPowerPeak(JNIEnv* env, jobject jhost)
{
msg_host_t host = jhost_get_native(env, jhost);
- return MSG_host_get_current_power_peak(host);
+ return MSG_host_get_speed(host);
}
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getPowerPeakAt(JNIEnv* env, jobject jhost, jint pstate)
{
/* Actually build the MSG process */
jstring jname = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
const char* name = env->GetStringUTFChars(jname, 0);
- msg_process_t process = MSG_process_create_from_stdfunc(
- name, [jprocess]() -> void { simgrid::kernel::context::java_main_jprocess(jprocess); },
- /*data*/ nullptr, jhost_get_native(env, jhost), /* properties*/ nullptr);
+ msg_process_t process =
+ MSG_process_create_from_stdfunc(name, [jprocess]() { simgrid::kernel::context::java_main_jprocess(jprocess); },
+ /*data*/ nullptr, jhost_get_native(env, jhost), /* properties*/ nullptr);
env->ReleaseStringUTFChars(jname, name);
/* bind the java process instance to the native process */
}
/**
- * The main function of the process (to implement).
+ * The main function of the process (to implement by the user).
*
* @param args
* @throws MsgException
#include "simgrid/datatypes.h"
#include "simgrid/forward.h"
-SG_BEGIN_DECL()
-/* Actions and models are highly connected structures... */
-
-/* user-visible parameters */
-extern XBT_PRIVATE double sg_tcp_gamma;
-extern XBT_PRIVATE double sg_sender_gap;
-extern XBT_PRIVATE double sg_latency_factor;
-extern XBT_PRIVATE double sg_bandwidth_factor;
-extern XBT_PRIVATE double sg_weight_S_parameter;
-extern XBT_PRIVATE int sg_network_crosstraffic;
#ifdef __cplusplus
namespace simgrid {
namespace surf {
-
class Model;
class CpuModel;
class HostModel;
typedef simgrid::surf::StorageModel surf_StorageModel;
typedef simgrid::surf::Resource surf_Resource;
typedef simgrid::surf::Action surf_Action;
-typedef simgrid::surf::FileImpl surf_File;
#else
typedef struct surf_Resource surf_Resource;
typedef struct surf_Host surf_Host;
typedef struct surf_Action surf_Action;
-typedef struct surf_File surf_File;
#endif
+SG_BEGIN_DECL()
+/* Actions and models are highly connected structures... */
+
+/* user-visible parameters */
+extern XBT_PRIVATE double sg_tcp_gamma;
+extern XBT_PRIVATE double sg_sender_gap;
+extern XBT_PRIVATE double sg_latency_factor;
+extern XBT_PRIVATE double sg_bandwidth_factor;
+extern XBT_PRIVATE double sg_weight_S_parameter;
+extern XBT_PRIVATE int sg_network_crosstraffic;
+
/** @ingroup SURF_c_bindings
* \brief Model datatype
*
typedef surf_HostModel *surf_host_model_t;
typedef surf_NetworkModel *surf_network_model_t;
typedef surf_StorageModel *surf_storage_model_t;
-typedef surf_File* surf_file_t;
/** @ingroup SURF_c_bindings
* \brief Action structure
*/
class AddressSpace {
private:
- Process* process_;
+ RemoteClient* process_;
+
public:
- explicit AddressSpace(Process* process) : process_(process) {}
+ explicit AddressSpace(RemoteClient* process) : process_(process) {}
virtual ~AddressSpace() = default;
- /** The process of this addres space
+ /** The process of this address space
*
* This is where we can get debug informations, memory layout, etc.
*/
- simgrid::mc::Process* process() const { return process_; }
+ simgrid::mc::RemoteClient* process() const { return process_; }
/** Read data from the address space
*
ChunkedData(ChunkedData const& that)
: store_ (that.store_)
, pagenos_(that.pagenos_)
-
+
{
for (std::size_t pageno : pagenos_)
store_->ref_page(pageno);
-/* Copyright (c) 2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2015-2017. 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. */
static const std::size_t max_size = 64;
private:
// Values of the stack (the top is stack_[size_ - 1]):
- uintptr_t stack_[max_size];
+ uintptr_t stack_[max_size] {0};
size_t size_;
public:
ExpressionStack() : size_(0) {}
namespace simgrid {
namespace mc {
-ModelChecker::ModelChecker(std::unique_ptr<Process> process) :
- base_(nullptr),
- socket_event_(nullptr),
- signal_event_(nullptr),
- page_store_(500),
- process_(std::move(process)),
- parent_snapshot_(nullptr)
+ModelChecker::ModelChecker(std::unique_ptr<RemoteClient> process)
+ : base_(nullptr)
+ , socket_event_(nullptr)
+ , signal_event_(nullptr)
+ , page_store_(500)
+ , process_(std::move(process))
+ , parent_snapshot_(nullptr)
{
}
void ModelChecker::setup_ignore()
{
- Process& process = this->process();
+ RemoteClient& process = this->process();
for (std::pair<const char*, const char*> const& var :
ignored_local_variables)
process.ignore_local_variable(var.first, var.second);
{
XBT_DEBUG("Shuting down model-checker");
- simgrid::mc::Process* process = &this->process();
+ simgrid::mc::RemoteClient* process = &this->process();
if (process->running()) {
XBT_DEBUG("Killing process");
kill(process->pid(), SIGTERM);
}
}
-void ModelChecker::resume(simgrid::mc::Process& process)
+void ModelChecker::resume(simgrid::mc::RemoteClient& process)
{
int res = process.getChannel().send(MC_MESSAGE_CONTINUE);
if (res)
bool ModelChecker::handle_message(char* buffer, ssize_t size)
{
- s_mc_message_t base_message;
+ mc_message_t base_message;
if (size < (ssize_t) sizeof(base_message))
xbt_die("Broken message");
memcpy(&base_message, buffer, sizeof(base_message));
case MC_MESSAGE_IGNORE_HEAP:
{
- s_mc_ignore_heap_message_t message;
- if (size != sizeof(message))
- xbt_die("Broken messsage");
- memcpy(&message, buffer, sizeof(message));
-
- IgnoredHeapRegion region;
- region.block = message.block;
- region.fragment = message.fragment;
- region.address = message.address;
- region.size = message.size;
- process().ignore_heap(region);
- break;
+ s_mc_message_ignore_heap_t message;
+ if (size != sizeof(message))
+ xbt_die("Broken messsage");
+ memcpy(&message, buffer, sizeof(message));
+
+ IgnoredHeapRegion region;
+ region.block = message.block;
+ region.fragment = message.fragment;
+ region.address = message.address;
+ region.size = message.size;
+ process().ignore_heap(region);
+ break;
}
case MC_MESSAGE_UNIGNORE_HEAP:
{
- s_mc_ignore_memory_message_t message;
- if (size != sizeof(message))
- xbt_die("Broken messsage");
- memcpy(&message, buffer, sizeof(message));
- process().unignore_heap(
- (void *)(std::uintptr_t) message.addr, message.size);
- break;
+ s_mc_message_ignore_memory_t message;
+ if (size != sizeof(message))
+ xbt_die("Broken messsage");
+ memcpy(&message, buffer, sizeof(message));
+ process().unignore_heap((void*)(std::uintptr_t)message.addr, message.size);
+ break;
}
case MC_MESSAGE_IGNORE_MEMORY:
{
- s_mc_ignore_memory_message_t message;
- if (size != sizeof(message))
- xbt_die("Broken messsage");
- memcpy(&message, buffer, sizeof(message));
- this->process().ignore_region(message.addr, message.size);
- break;
+ s_mc_message_ignore_memory_t message;
+ if (size != sizeof(message))
+ xbt_die("Broken messsage");
+ memcpy(&message, buffer, sizeof(message));
+ this->process().ignore_region(message.addr, message.size);
+ break;
}
case MC_MESSAGE_STACK_REGION:
{
- s_mc_stack_region_message_t message;
- if (size != sizeof(message))
- xbt_die("Broken messsage");
- memcpy(&message, buffer, sizeof(message));
- this->process().stack_areas().push_back(message.stack_region);
+ s_mc_message_stack_region_t message;
+ if (size != sizeof(message))
+ xbt_die("Broken messsage");
+ memcpy(&message, buffer, sizeof(message));
+ this->process().stack_areas().push_back(message.stack_region);
}
break;
case MC_MESSAGE_REGISTER_SYMBOL:
{
- s_mc_register_symbol_message_t message;
- if (size != sizeof(message))
- xbt_die("Broken message");
- memcpy(&message, buffer, sizeof(message));
- if (message.callback)
- xbt_die("Support for client-side function proposition is not implemented.");
- XBT_DEBUG("Received symbol: %s", message.name);
-
- if (simgrid::mc::property_automaton == nullptr)
- simgrid::mc::property_automaton = xbt_automaton_new();
-
- simgrid::mc::Process* process = &this->process();
- simgrid::mc::RemotePtr<int> address
- = simgrid::mc::remote((int*) message.data);
- simgrid::xbt::add_proposition(simgrid::mc::property_automaton,
- message.name,
- [process, address]() { return process->read(address); }
- );
-
- break;
+ s_mc_message_register_symbol_t message;
+ if (size != sizeof(message))
+ xbt_die("Broken message");
+ memcpy(&message, buffer, sizeof(message));
+ if (message.callback)
+ xbt_die("Support for client-side function proposition is not implemented.");
+ XBT_DEBUG("Received symbol: %s", message.name);
+
+ if (simgrid::mc::property_automaton == nullptr)
+ simgrid::mc::property_automaton = xbt_automaton_new();
+
+ simgrid::mc::RemoteClient* process = &this->process();
+ simgrid::mc::RemotePtr<int> address = simgrid::mc::remote((int*)message.data);
+ simgrid::xbt::add_proposition(simgrid::mc::property_automaton, message.name,
+ [process, address]() { return process->read(address); });
+
+ break;
}
case MC_MESSAGE_WAITING:
}
}
-void ModelChecker::wait_client(simgrid::mc::Process& process)
+void ModelChecker::wait_for_requests()
{
- this->resume(process);
+ this->resume(process());
if (this->process().running())
event_base_dispatch(base_);
}
void ModelChecker::handle_simcall(Transition const& transition)
{
- s_mc_simcall_handle_message m;
+ s_mc_message_simcall_handle m;
memset(&m, 0, sizeof(m));
m.type = MC_MESSAGE_SIMCALL_HANDLE;
m.pid = transition.pid;
int res;
if ((res = this->process().getChannel().send(MC_MESSAGE_DEADLOCK_CHECK)))
xbt_die("Could not check deadlock state");
- s_mc_int_message_t message;
+ mc_message_int_t message;
ssize_t s = mc_model_checker->process().getChannel().receive(message);
if (s == -1)
xbt_die("Could not receive message");
#include <sys/types.h>
#include "src/mc/PageStore.hpp"
-#include "src/mc/Process.hpp"
#include "src/mc/Transition.hpp"
#include "src/mc/mc_forward.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
#include "src/mc/remote/mc_protocol.h"
namespace simgrid {
std::set<std::string> hostnames_;
// This is the parent snapshot of the current state:
PageStore page_store_;
- std::unique_ptr<Process> process_;
+ std::unique_ptr<RemoteClient> process_;
Checker* checker_ = nullptr;
public:
std::shared_ptr<simgrid::mc::Snapshot> parent_snapshot_;
public:
ModelChecker(ModelChecker const&) = delete;
ModelChecker& operator=(ModelChecker const&) = delete;
- explicit ModelChecker(std::unique_ptr<Process> process);
+ explicit ModelChecker(std::unique_ptr<RemoteClient> process);
~ModelChecker();
- Process& process()
- {
- return *process_;
- }
+ RemoteClient& process() { return *process_; }
PageStore& page_store()
{
return page_store_;
void start();
void shutdown();
- void resume(simgrid::mc::Process& process);
+ void resume(simgrid::mc::RemoteClient& process);
void loop();
void handle_events(int fd, short events);
- void wait_client(simgrid::mc::Process& process);
+ void wait_for_requests();
void handle_simcall(Transition const& transition);
- void wait_for_requests()
- {
- mc_model_checker->wait_client(mc_model_checker->process());
- }
void exit(int status);
bool checkDeadlock();
std::vector<simgrid::xbt::VmMap> const& maps, const char* name);
/** Augment the current module with informations about the other ones */
-XBT_PRIVATE void postProcessObjectInformation(
- simgrid::mc::Process* process, simgrid::mc::ObjectInformation* info);
-
+XBT_PRIVATE void postProcessObjectInformation(simgrid::mc::RemoteClient* process, simgrid::mc::ObjectInformation* info);
}
}
RegionSnapshot sparse_region(RegionType region_type,
void *start_addr, void* permanent_addr, size_t size)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
assert(process != nullptr);
xbt_assert((((uintptr_t)start_addr) & (xbt_pagesize-1)) == 0,
Session::Session(pid_t pid, int socket)
{
- std::unique_ptr<simgrid::mc::Process> process(new simgrid::mc::Process(pid, socket));
+ std::unique_ptr<simgrid::mc::RemoteClient> process(new simgrid::mc::RemoteClient(pid, socket));
// TODO, automatic detection of the config from the process
process->privatized(smpi_privatize_global_variables != SMPI_PRIVATIZE_NONE);
modelChecker_ = std::unique_ptr<ModelChecker>(
Session* Session::fork(std::function<void()> code)
{
// Create a AF_LOCAL socketpair used for exchanging messages
- // bewteen the model-checker process (ourselves) and the model-checked
+ // between the model-checker process (ourselves) and the model-checked
// process:
int res;
int sockets[2];
#include "xbt/log.h"
#include "xbt/sysdep.h"
-#include "src/mc/mc_comm_pattern.h"
+#include "src/mc/VisitedState.hpp"
+#include "src/mc/mc_comm_pattern.hpp"
#include "src/mc/mc_private.h"
-#include "src/mc/Process.hpp"
#include "src/mc/mc_smx.h"
-#include "src/mc/VisitedState.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_VisitedState, mc, "Logging specific to state equality detection mechanisms");
/** @brief Save the current state */
VisitedState::VisitedState(unsigned long state_number)
{
- simgrid::mc::Process* process = &(mc_model_checker->process());
+ simgrid::mc::RemoteClient* process = &(mc_model_checker->process());
this->heap_bytes_used = mmalloc_get_bytes_used_remote(
process->get_heap()->heaplimit,
process->get_malloc_info());
-/* Copyright (c) 2016. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2016-2017. 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 "src/mc/VisitedState.hpp"
#include "src/mc/checker/Checker.hpp"
-#include "src/mc/mc_comm_pattern.h"
+#include "src/mc/mc_comm_pattern.hpp"
#include "src/mc/mc_forward.hpp"
#ifndef SIMGRID_MC_COMMUNICATION_DETERMINISM_CHECKER_HPP
std::shared_ptr<const std::vector<int>> atomic_propositions,
std::shared_ptr<simgrid::mc::State> graph_state)
{
- simgrid::mc::Process* process = &(mc_model_checker->process());
+ simgrid::mc::RemoteClient* process = &(mc_model_checker->process());
this->graph_state = std::move(graph_state);
if(this->graph_state->system_state == nullptr)
#include "src/mc/Session.hpp"
#include "src/mc/checker/Checker.hpp"
#include "src/mc/mc_base.h"
-#include "src/mc/mc_comm_pattern.h"
+#include "src/mc/mc_comm_pattern.hpp"
#include "src/mc/mc_exit.h"
#include "src/mc/mc_private.h"
#include "src/mc/mc_safety.h"
int mmalloc_compare_heap(
simgrid::mc::StateComparator& state, simgrid::mc::Snapshot* snapshot1, simgrid::mc::Snapshot* snapshot2)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
/* Start comparison */
size_t i1;
HeapLocationPairs* previous, int size,
int check_ignore)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
mc_mem_region_t heap_region1 = MC_get_heap_region(snapshot1);
mc_mem_region_t heap_region2 = MC_get_heap_region(snapshot2);
HeapLocationPairs* previous,
simgrid::mc::Type* type, int pointer_level)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
int res_compare;
ssize_t block1;
void* real_area2, simgrid::mc::Snapshot* snapshot2, mc_mem_region_t region2,
simgrid::mc::Type* type, int pointer_level)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
simgrid::mc::Type* subtype;
simgrid::mc::Type* subsubtype;
(char *) current_var.address);
return 1;
}
-
}
return 0;
-
}
static int compare_local_variables(simgrid::mc::StateComparator& state,
unsigned int cursor = 0;
local_variable_t current_var1, current_var2;
- int res;
while (cursor < stack1->local_variables.size()) {
current_var1 = &stack1->local_variables[cursor];
current_var2 = &stack1->local_variables[cursor];
// TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
simgrid::mc::Type* subtype = current_var1->type;
- res =
- compare_areas_with_type(state, process_index,
- current_var1->address, snapshot1, mc_get_snapshot_region(current_var1->address, snapshot1, process_index),
- current_var2->address, snapshot2, mc_get_snapshot_region(current_var2->address, snapshot2, process_index),
- subtype, 0);
-
- if (res == 1) {
- // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
- XBT_VERB
- ("Local variable %s (%p - %p) in frame %s "
- "is different between snapshots",
- current_var1->name.c_str(),
- current_var1->address,
- current_var2->address,
- current_var1->subprogram->name.c_str());
- return res;
+ int res = compare_areas_with_type(
+ state, process_index, current_var1->address, snapshot1,
+ mc_get_snapshot_region(current_var1->address, snapshot1, process_index), current_var2->address, snapshot2,
+ mc_get_snapshot_region(current_var2->address, snapshot2, process_index), subtype, 0);
+
+ if (res == 1) {
+ // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
+ XBT_VERB("Local variable %s (%p - %p) in frame %s "
+ "is different between snapshots",
+ current_var1->name.c_str(), current_var1->address, current_var2->address,
+ current_var1->subprogram->name.c_str());
+ return res;
}
cursor++;
}
else
state_comparator->clear();
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
int errors = 0;
* Only WAIT operations (on comm, on mutex, etc) can ever return false because they could lock the MC exploration.
* Wait operations are OK and return true in only two situations:
* - if the wait will succeed immediately (if both peer of the comm are there already or if the mutex is available)
- * - if a timeout is provided, because we can fire the timeout if the transition is not ready without blocking in this transition for ever.
+ * - if a timeout is provided, because we can fire the timeout if the transition is not ready without blocking in this
+ * transition for ever.
*
*/
// Called from both MCer and MCed:
-bool request_is_enabled(smx_simcall_t req)
+bool actor_is_enabled(smx_actor_t actor)
{
+ smx_simcall_t req = &actor->simcall;
// TODO, add support for the subtypes?
switch (req->call) {
- case SIMCALL_NONE:
- return false;
+ case SIMCALL_NONE:
+ return false;
- case SIMCALL_COMM_WAIT:
- {
- /* FIXME: check also that src and dst processes are not suspended */
- simgrid::kernel::activity::CommImpl* act =
- static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req));
+ case SIMCALL_COMM_WAIT: {
+ /* FIXME: check also that src and dst processes are not suspended */
+ simgrid::kernel::activity::CommImpl* act =
+ static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req));
#if SIMGRID_HAVE_MC
- // Fetch from MCed memory:
- // HACK, type puning
- if (mc_model_checker != nullptr) {
- simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
- mc_model_checker->process().read(temp_comm, remote(act));
- act = static_cast<simgrid::kernel::activity::CommImpl*>(temp_comm.getBuffer());
- }
+ // Fetch from MCed memory:
+ // HACK, type puning
+ if (mc_model_checker != nullptr) {
+ simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
+ mc_model_checker->process().read(temp_comm, remote(act));
+ act = static_cast<simgrid::kernel::activity::CommImpl*>(temp_comm.getBuffer());
+ }
#endif
- if (act->src_timeout || act->dst_timeout) {
- /* If it has a timeout it will be always be enabled (regardless of who declared the timeout),
- * because even if the communication is not ready, it can timeout and won't block. */
- if (_sg_mc_timeout == 1)
- return true;
- }
- /* On the other hand if it hasn't a timeout, check if the comm is ready.*/
- else if (act->detached && act->src_proc == nullptr
- && act->type == SIMIX_COMM_READY)
+ if (act->src_timeout || act->dst_timeout) {
+ /* If it has a timeout it will be always be enabled (regardless of who declared the timeout),
+ * because even if the communication is not ready, it can timeout and won't block. */
+ if (_sg_mc_timeout == 1)
+ return true;
+ }
+ /* On the other hand if it hasn't a timeout, check if the comm is ready.*/
+ else if (act->detached && act->src_proc == nullptr && act->type == SIMIX_COMM_READY)
return (act->dst_proc != nullptr);
- return (act->src_proc && act->dst_proc);
- }
+ return (act->src_proc && act->dst_proc);
+ }
- case SIMCALL_COMM_WAITANY: {
- xbt_dynar_t comms;
- simgrid::kernel::activity::CommImpl* act =
- static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req));
+ case SIMCALL_COMM_WAITANY: {
+ xbt_dynar_t comms;
+ simgrid::kernel::activity::CommImpl* act =
+ static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req));
#if SIMGRID_HAVE_MC
- s_xbt_dynar_t comms_buffer;
- size_t buffer_size = 0;
- if (mc_model_checker != nullptr) {
- // Read dynar:
- mc_model_checker->process().read(
- &comms_buffer, remote(simcall_comm_waitany__get__comms(req)));
- assert(comms_buffer.elmsize == sizeof(act));
- buffer_size = comms_buffer.elmsize * comms_buffer.used;
- comms = &comms_buffer;
- } else
- comms = simcall_comm_waitany__get__comms(req);
-
- // Read all the dynar buffer:
- char buffer[buffer_size];
- if (mc_model_checker != nullptr)
- mc_model_checker->process().read_bytes(buffer, sizeof(buffer),
- remote(comms->data));
+ s_xbt_dynar_t comms_buffer;
+ size_t buffer_size = 0;
+ if (mc_model_checker != nullptr) {
+ // Read dynar:
+ mc_model_checker->process().read(&comms_buffer, remote(simcall_comm_waitany__get__comms(req)));
+ assert(comms_buffer.elmsize == sizeof(act));
+ buffer_size = comms_buffer.elmsize * comms_buffer.used;
+ comms = &comms_buffer;
+ } else
+ comms = simcall_comm_waitany__get__comms(req);
+
+ // Read all the dynar buffer:
+ char buffer[buffer_size];
+ if (mc_model_checker != nullptr)
+ mc_model_checker->process().read_bytes(buffer, sizeof(buffer), remote(comms->data));
#else
- comms = simcall_comm_waitany__get__comms(req);
+ comms = simcall_comm_waitany__get__comms(req);
#endif
- for (unsigned int index = 0; index < comms->used; ++index) {
+ for (unsigned int index = 0; index < comms->used; ++index) {
#if SIMGRID_HAVE_MC
- // Fetch act from MCed memory:
- // HACK, type puning
- simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
- if (mc_model_checker != nullptr) {
- memcpy(&act, buffer + comms->elmsize * index, sizeof(act));
- mc_model_checker->process().read(temp_comm, remote(act));
- act = static_cast<simgrid::kernel::activity::CommImpl*>(temp_comm.getBuffer());
- }
- else
+ // Fetch act from MCed memory:
+ // HACK, type puning
+ simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
+ if (mc_model_checker != nullptr) {
+ memcpy(&act, buffer + comms->elmsize * index, sizeof(act));
+ mc_model_checker->process().read(temp_comm, remote(act));
+ act = static_cast<simgrid::kernel::activity::CommImpl*>(temp_comm.getBuffer());
+ } else
#endif
- act = xbt_dynar_get_as(comms, index, simgrid::kernel::activity::CommImpl*);
- if (act->src_proc && act->dst_proc)
- return true;
+ act = xbt_dynar_get_as(comms, index, simgrid::kernel::activity::CommImpl*);
+ if (act->src_proc && act->dst_proc)
+ return true;
+ }
+ return false;
}
- return false;
- }
- case SIMCALL_MUTEX_LOCK: {
- smx_mutex_t mutex = simcall_mutex_lock__get__mutex(req);
+ case SIMCALL_MUTEX_LOCK: {
+ smx_mutex_t mutex = simcall_mutex_lock__get__mutex(req);
#if SIMGRID_HAVE_MC
- simgrid::mc::Remote<simgrid::simix::MutexImpl> temp_mutex;
- if (mc_model_checker != nullptr) {
- mc_model_checker->process().read(temp_mutex.getBuffer(), remote(mutex));
- mutex = temp_mutex.getBuffer();
- }
+ simgrid::mc::Remote<simgrid::simix::MutexImpl> temp_mutex;
+ if (mc_model_checker != nullptr) {
+ mc_model_checker->process().read(temp_mutex.getBuffer(), remote(mutex));
+ mutex = temp_mutex.getBuffer();
+ }
#endif
- if(mutex->owner == nullptr)
- return true;
+ if (mutex->owner == nullptr)
+ return true;
#if SIMGRID_HAVE_MC
- else if (mc_model_checker != nullptr) {
- simgrid::mc::Process& modelchecked = mc_model_checker->process();
- // TODO, *(mutex->owner) :/
- return modelchecked.resolveActor(simgrid::mc::remote(mutex->owner))->pid ==
- modelchecked.resolveActor(simgrid::mc::remote(req->issuer))->pid;
- }
+ else if (mc_model_checker != nullptr) {
+ simgrid::mc::RemoteClient& modelchecked = mc_model_checker->process();
+ // TODO, *(mutex->owner) :/
+ return modelchecked.resolveActor(simgrid::mc::remote(mutex->owner))->pid ==
+ modelchecked.resolveActor(simgrid::mc::remote(req->issuer))->pid;
+ }
#endif
- else
- return mutex->owner->pid == req->issuer->pid;
+ else
+ return mutex->owner->pid == req->issuer->pid;
}
case SIMCALL_SEM_ACQUIRE: {
namespace simgrid {
namespace mc {
-/** Can this requests can be executed?
- *
- * Most requests are always enabled but WAIT and WAITANY
- * are not always enabled: a WAIT where the communication does not
- * have both a source and a destination yet is not enabled
- * (unless timeout is enabled in the wait and enabeld in SimGridMC).
- */
-XBT_PRIVATE bool request_is_enabled(smx_simcall_t req);
-
/** Execute everything which is invisible
*
* Execute all the processes that are ready to run and all invisible simcalls
/** Execute a given simcall */
XBT_PRIVATE void handle_simcall(smx_simcall_t req, int req_num);
+/** Is the process ready to execute its simcall?
+ *
+ * This is true if the request associated with the process is ready.
+ *
+ * Most requests are always enabled but WAIT and WAITANY
+ * are not always enabled: a WAIT where the communication does not
+ * have both a source and a destination yet is not enabled
+ * (unless timeout is enabled in the wait and enabeld in SimGridMC).
+ */
+XBT_PRIVATE bool actor_is_enabled(smx_actor_t process);
+
/** Check if the given simcall is visible
*
* \return `TRUE` or `FALSE`
return;
}
-static void get_memory_regions(simgrid::mc::Process* process, simgrid::mc::Snapshot* snapshot)
+static void get_memory_regions(simgrid::mc::RemoteClient* process, simgrid::mc::Snapshot* snapshot)
{
const size_t n = process->object_infos.size();
snapshot->snapshot_regions.resize(n + 1);
int process_index,
std::vector<s_local_variable>& result)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
if (not scope || not scope->range.contain(stack_frame->ip))
return;
static std::vector<s_mc_stack_frame_t> unwind_stack_frames(simgrid::mc::UnwindContext* stack_context)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
std::vector<s_mc_stack_frame_t> result;
unw_cursor_t c = stack_context->cursor();
{
XBT_DEBUG("Taking snapshot %i", num_state);
- simgrid::mc::Process* mc_process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* mc_process = &mc_model_checker->process();
std::shared_ptr<simgrid::mc::Snapshot> snapshot = std::make_shared<simgrid::mc::Snapshot>(mc_process, num_state);
}
#if HAVE_SMPI
- // TODO, send a message to implement this in the MCed process
if(snapshot->privatization_index >= 0) {
// Fix the privatization mmap:
- s_mc_restore_message message;
- message.type = MC_MESSAGE_RESTORE;
- message.index = snapshot->privatization_index;
+ s_mc_message_restore message{MC_MESSAGE_RESTORE, snapshot->privatization_index};
mc_model_checker->process().getChannel().send(message);
}
#endif
/** @brief Register a stack in the model checker
*
- * The stacks are allocated in the heap. The MC handle them especially
+ * The stacks are allocated in the heap. The MC handle them specifically
* when we analyze/compare the content of the heap so it must be told where
* they are with this function.
*
- * @param stack
- * @param process Process owning the stack
- * @param context
+ * @param stack Where the stack is
+ * @param actor Actor owning the stack
+ * @param context The context associated to that stack
* @param size Size of the stack
*/
-void MC_register_stack_area(void *stack, smx_actor_t process, ucontext_t* context, size_t size)
+void MC_register_stack_area(void* stack, smx_actor_t actor, ucontext_t* context, size_t size)
{
xbt_assert(mc_model_checker == nullptr);
if (not MC_is_active())
return;
- simgrid::mc::Client::get()->declareStack(stack, size, process, context);
+ simgrid::mc::Client::get()->declareStack(stack, size, actor, context);
}
void MC_ignore_global_variable(const char *name)
simgrid::mc::Client::get()->ignoreHeap(address, size);
}
-void MC_remove_ignore_heap(void *address, size_t size)
+void MC_unignore_heap(void* address, size_t size)
{
xbt_assert(mc_model_checker == nullptr);
if (not MC_is_active())
#include "xbt/sysdep.h"
#include <xbt/dynar.hpp>
-#include "src/mc/mc_comm_pattern.h"
+#include "src/mc/checker/CommunicationDeterminismChecker.hpp"
+#include "src/mc/mc_comm_pattern.hpp"
#include "src/mc/mc_smx.h"
#include "src/mc/mc_xbt.hpp"
-#include "src/mc/checker/CommunicationDeterminismChecker.hpp"
using simgrid::mc::remote;
unsigned int index_comm = 0;
std::vector<std::unique_ptr<simgrid::mc::PatternCommunication>> list;
};
-
}
}
static inline e_mc_call_type_t MC_get_call_type(smx_simcall_t req)
{
- switch(req->call) {
- case SIMCALL_COMM_ISEND:
- return MC_CALL_TYPE_SEND;
- case SIMCALL_COMM_IRECV:
- return MC_CALL_TYPE_RECV;
- case SIMCALL_COMM_WAIT:
- return MC_CALL_TYPE_WAIT;
- case SIMCALL_COMM_WAITANY:
- return MC_CALL_TYPE_WAITANY;
- default:
- return MC_CALL_TYPE_NONE;
+ switch (req->call) {
+ case SIMCALL_COMM_ISEND:
+ return MC_CALL_TYPE_SEND;
+ case SIMCALL_COMM_IRECV:
+ return MC_CALL_TYPE_RECV;
+ case SIMCALL_COMM_WAIT:
+ return MC_CALL_TYPE_WAIT;
+ case SIMCALL_COMM_WAITANY:
+ return MC_CALL_TYPE_WAITANY;
+ default:
+ return MC_CALL_TYPE_NONE;
}
}
-XBT_PRIVATE void MC_handle_comm_pattern(e_mc_call_type_t call_type, smx_simcall_t request, int value, xbt_dynar_t current_pattern, int backtracking);
+XBT_PRIVATE void MC_handle_comm_pattern(e_mc_call_type_t call_type, smx_simcall_t request, int value,
+ xbt_dynar_t current_pattern, int backtracking);
XBT_PRIVATE void MC_restore_communications_pattern(simgrid::mc::State* state);
#include "src/mc/mc_private.h"
#include "src/mc/mc_dwarf.hpp"
-#include "src/mc/Process.hpp"
#include "src/mc/ObjectInformation.hpp"
#include "src/mc/Variable.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_dwarf, mc, "DWARF processing");
/*************************************************************************/
-void postProcessObjectInformation(simgrid::mc::Process* process, simgrid::mc::ObjectInformation* info)
+void postProcessObjectInformation(simgrid::mc::RemoteClient* process, simgrid::mc::ObjectInformation* info)
{
for (auto& i : info->types) {
class ChunkedData;
class ModelChecker;
class AddressSpace;
-class Process;
+class RemoteClient;
class Snapshot;
class ObjectInformation;
class Member;
#include "src/simix/ActorImpl.hpp"
#if SIMGRID_HAVE_MC
-#include <libunwind.h>
-#include "src/mc/mc_comm_pattern.h"
+#include "src/mc/checker/Checker.hpp"
+#include "src/mc/mc_comm_pattern.hpp"
+#include "src/mc/mc_private.h"
#include "src/mc/mc_request.h"
#include "src/mc/mc_safety.h"
+#include "src/mc/mc_smx.h"
#include "src/mc/mc_snapshot.h"
-#include "src/mc/mc_private.h"
#include "src/mc/mc_unw.h"
-#include "src/mc/mc_smx.h"
-#include "src/mc/checker/Checker.hpp"
+#include <libunwind.h>
#endif
#include "src/mc/Transition.hpp"
* @param page_count Number of pages of the region
* @param pagenos
*/
-void mc_restore_page_snapshot_region(simgrid::mc::Process* process,
- void* start_addr, simgrid::mc::ChunkedData const& pages_copy)
+void mc_restore_page_snapshot_region(simgrid::mc::RemoteClient* process, void* start_addr,
+ simgrid::mc::ChunkedData const& pages_copy)
{
for (size_t i = 0; i != pages_copy.page_count(); ++i) {
// Otherwise, copy the page:
// ***** High level API
-void mc_region_restore_sparse(simgrid::mc::Process* process, mc_mem_region_t reg)
+void mc_region_restore_sparse(simgrid::mc::RemoteClient* process, mc_mem_region_t reg)
{
xbt_assert(((reg->permanent_address().address()) & (xbt_pagesize-1)) == 0,
"Not at the beginning of a page");
// Choose a request:
smx_actor_t process = SIMIX_process_from_PID(transition.pid);
if (not process)
- xbt_die("Unexpected process.");
+ xbt_die("Unexpected process (pid:%d).", transition.pid);
smx_simcall_t simcall = &(process->simcall);
if (not simcall || simcall->call == SIMCALL_NONE)
- xbt_die("No simcall for this process.");
- if (not simgrid::mc::request_is_visible(simcall) || not simgrid::mc::request_is_enabled(simcall))
+ xbt_die("No simcall for process %d.", transition.pid);
+ if (not simgrid::mc::request_is_visible(simcall) || not simgrid::mc::actor_is_enabled(process))
xbt_die("Unexpected simcall.");
// Execute the request:
-/* Copyright (c) 2008-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2008-2017. 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 <cassert>
+#include "src/include/mc/mc.h"
#include "src/mc/ModelChecker.hpp"
#include "src/mc/mc_request.h"
#include "src/mc/mc_smx.h"
std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid::mc::RequestType request_type)
{
- xbt_assert(mc_model_checker != nullptr);
+ xbt_assert(mc_model_checker != nullptr, "Must be called from MCer");
bool use_remote_comm = true;
switch(request_type) {
return comm->src_proc && comm->dst_proc;
}
-bool actor_is_enabled(smx_actor_t actor)
-{
- return simgrid::mc::request_is_enabled(&actor->simcall);
-}
static const char* colors[] = {
"blue",
XBT_PRIVATE bool request_is_enabled_by_idx(smx_simcall_t req, unsigned int idx);
-/** Is the process ready to execute its simcall?
- *
- * This is true if the request associated with the process is ready.
- */
-XBT_PRIVATE bool actor_is_enabled(smx_actor_t process);
-
XBT_PRIVATE std::string request_get_dot_output(smx_simcall_t req, int value);
}
* @param target Local vector (to be filled with copies of `s_smx_actor_t`)
* @param remote_swag Address of the process SWAG in the remote list
*/
-static void MC_process_refresh_simix_process_list(simgrid::mc::Process* process,
+static void MC_process_refresh_simix_process_list(simgrid::mc::RemoteClient* process,
std::vector<simgrid::mc::ActorInformation>& target,
simgrid::mc::RemotePtr<s_xbt_swag_t> remote_swag)
{
assert(i == swag.count);
}
-static void MC_process_refresh_simix_actor_dynar(simgrid::mc::Process* process,
+static void MC_process_refresh_simix_actor_dynar(simgrid::mc::RemoteClient* process,
std::vector<simgrid::mc::ActorInformation>& target,
simgrid::mc::RemotePtr<s_xbt_dynar_t> remote_dynar)
{
namespace simgrid {
namespace mc {
-void Process::refresh_simix()
+void RemoteClient::refresh_simix()
{
- if (this->cache_flags_ & Process::cache_simix_processes)
+ if (this->cache_flags_ & RemoteClient::cache_simix_processes)
return;
// TODO, avoid to reload `&simix_global`, `simix_global`, `*simix_global`
MC_process_refresh_simix_process_list(this, this->smx_dead_actors_infos,
remote(simix_global.getBuffer()->process_to_destroy));
- this->cache_flags_ |= Process::cache_simix_processes;
+ this->cache_flags_ |= RemoteClient::cache_simix_processes;
}
}
if (mc_model_checker == nullptr)
return actor->host->getCname();
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
/* HACK, Horrible hack to find the offset of the id in the simgrid::s4u::Host.
const char* MC_smx_actor_get_name(smx_actor_t actor)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
if (mc_model_checker == nullptr)
return actor->name.c_str();
#ifndef SIMGRID_MC_SMX_H
#define SIMGRID_MC_SMX_H
-#include "src/mc/Process.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
/** @file
* @brief (Cross-process, MCer/MCed) Access to SMX structures
namespace simgrid {
namespace mc {
-Snapshot::Snapshot(Process* process, int _num_state)
+Snapshot::Snapshot(RemoteClient* process, int _num_state)
: AddressSpace(process)
, num_state(_num_state)
, heap_bytes_used(0)
xbt_assert(xbt_pagesize == getpagesize());
xbt_assert(1 << xbt_pagebits == xbt_pagesize);
- std::unique_ptr<simgrid::mc::Process> process(new simgrid::mc::Process(getpid(), -1));
+ std::unique_ptr<simgrid::mc::RemoteClient> process(new simgrid::mc::RemoteClient(getpid(), -1));
process->init();
mc_model_checker = new ::simgrid::mc::ModelChecker(std::move(process));
// ***** Snapshot region
-XBT_PRIVATE void mc_region_restore_sparse(simgrid::mc::Process* process, mc_mem_region_t reg);
+XBT_PRIVATE void mc_region_restore_sparse(simgrid::mc::RemoteClient* process, mc_mem_region_t reg);
static XBT_ALWAYS_INLINE void* mc_translate_address_region_chunked(uintptr_t addr, mc_mem_region_t region)
{
class XBT_PRIVATE Snapshot final : public AddressSpace {
public:
- Snapshot(Process* process, int num_state);
+ Snapshot(RemoteClient* process, int num_state);
~Snapshot() = default;
const void* read_bytes(void* buffer, std::size_t size,
RemotePtr<void> address, int process_index = ProcessIndexAny,
extern "C" {
-XBT_PRIVATE void mc_restore_page_snapshot_region(
- simgrid::mc::Process* process,
- void* start_addr, simgrid::mc::ChunkedData const& pagenos);
+XBT_PRIVATE void mc_restore_page_snapshot_region(simgrid::mc::RemoteClient* process, void* start_addr,
+ simgrid::mc::ChunkedData const& pagenos);
const void* MC_region_read_fragmented(
mc_mem_region_t region, void* target, const void* addr, std::size_t size);
#include "xbt/log.h"
#include "xbt/sysdep.h"
-#include "src/simix/smx_private.h"
-#include "src/mc/mc_state.h"
-#include "src/mc/mc_request.h"
+#include "src/mc/Transition.hpp"
+#include "src/mc/mc_comm_pattern.hpp"
#include "src/mc/mc_private.h"
-#include "src/mc/mc_comm_pattern.h"
+#include "src/mc/mc_request.h"
#include "src/mc/mc_smx.h"
+#include "src/mc/mc_state.h"
#include "src/mc/mc_xbt.hpp"
-#include "src/mc/Transition.hpp"
+#include "src/simix/smx_private.h"
using simgrid::mc::remote;
state->transition.argument = -1;
state->executed_req.call = SIMCALL_NONE;
- if (not procstate->isTodo())
- return nullptr; // Not considered by the checker algorithm
if (not simgrid::mc::actor_is_enabled(actor))
return nullptr; // Not executable in the application
smx_simcall_t MC_state_get_request(simgrid::mc::State* state)
{
for (auto& actor : mc_model_checker->process().actors()) {
+ /* Only consider the actors that were marked as interleaving by the checker algorithm */
+ if (not state->actorStates[actor.copy.getBuffer()->pid].isTodo())
+ continue;
+
smx_simcall_t res = MC_state_get_request_for_process(state, actor.copy.getBuffer());
if (res)
return res;
#include <libunwind.h>
-#include "src/mc/Process.hpp"
-#include "src/mc/mc_unw.h"
#include "src/mc/Frame.hpp"
+#include "src/mc/mc_unw.h"
+#include "src/mc/remote/RemoteClient.hpp"
using simgrid::mc::remote;
process_ = nullptr;
}
-void UnwindContext::initialize(simgrid::mc::Process* process, unw_context_t* c)
+void UnwindContext::initialize(simgrid::mc::RemoteClient* process, unw_context_t* c)
{
clear();
*/
#include "src/mc/mc_forward.hpp"
+#include "xbt/base.h"
#include <libunwind.h>
+#include <stdio.h>
#include <sys/types.h>
namespace simgrid {
class UnwindContext {
simgrid::mc::AddressSpace* addressSpace_ = nullptr;
- simgrid::mc::Process* process_ = nullptr;
+ simgrid::mc::RemoteClient* process_ = nullptr;
unw_context_t unwindContext_;
public:
UnwindContext() = default;
~UnwindContext() { clear(); }
- void initialize(simgrid::mc::Process* process, unw_context_t* c);
+ void initialize(simgrid::mc::RemoteClient* process, unw_context_t* c);
void clear();
unw_cursor_t cursor();
#include <libunwind.h>
#include <libunwind-ptrace.h>
-#include "src/mc/Process.hpp"
#include "src/mc/mc_unw.h"
+#include "src/mc/remote/RemoteClient.hpp"
/** \file
* Libunwind namespace implementation using process_vm_readv.
namespace simgrid {
namespace mc {
-std::unique_ptr<Client> Client::client_;
+std::unique_ptr<Client> Client::instance_;
Client* Client::initialize()
{
return nullptr;
// Do not break if we are called multiple times:
- if (client_)
- return client_.get();
+ if (instance_)
+ return instance_.get();
_sg_do_model_check = 1;
xbt_die("Unexpected socket type %i", type);
XBT_DEBUG("Model-checked application found expected socket type");
- client_ = std::unique_ptr<Client>(new simgrid::mc::Client(fd));
+ instance_ = std::unique_ptr<Client>(new simgrid::mc::Client(fd));
// Wait for the model-checker:
errno = 0;
if (errno != 0 || raise(SIGSTOP) != 0)
xbt_die("Could not wait for the model-checker");
- client_->handleMessages();
- return client_.get();
+ instance_->handleMessages();
+ return instance_.get();
+}
+
+void Client::handleDeadlockCheck(mc_message_t* msg)
+{
+ bool deadlock = false;
+ if (not simix_global->process_list.empty()) {
+ deadlock = true;
+ for (auto kv : simix_global->process_list)
+ if (simgrid::mc::actor_is_enabled(kv.second)) {
+ deadlock = false;
+ break;
+ }
+ }
+
+ // Send result:
+ mc_message_int_t answer{MC_MESSAGE_DEADLOCK_CHECK_REPLY, deadlock};
+ xbt_assert(channel_.send(answer) == 0, "Could not send response");
+}
+void Client::handleContinue(mc_message_t* msg)
+{
+ /* Nothing to do */
+}
+void Client::handleSimcall(s_mc_message_simcall_handle_t* message)
+{
+ smx_actor_t process = SIMIX_process_from_PID(message->pid);
+ if (not process)
+ xbt_die("Invalid pid %lu", (unsigned long)message->pid);
+ SIMIX_simcall_handle(&process->simcall, message->value);
+ if (channel_.send(MC_MESSAGE_WAITING))
+ xbt_die("Could not send MESSAGE_WAITING to model-checker");
+}
+void Client::handleRestore(s_mc_message_restore_t* message)
+{
+#if HAVE_SMPI
+ smpi_really_switch_data_segment(message->index);
+#endif
}
void Client::handleMessages()
XBT_DEBUG("Waiting messages from model-checker");
char message_buffer[MC_MESSAGE_LENGTH];
- ssize_t received_size;
+ ssize_t received_size = channel_.receive(&message_buffer, sizeof(message_buffer));
- if ((received_size = channel_.receive(&message_buffer, sizeof(message_buffer))) < 0)
+ if (received_size < 0)
xbt_die("Could not receive commands from the model-checker");
- s_mc_message_t message;
- if ((size_t)received_size < sizeof(message))
- xbt_die("Received message is too small");
- memcpy(&message, message_buffer, sizeof(message));
- switch (message.type) {
-
- case MC_MESSAGE_DEADLOCK_CHECK: {
- // Check deadlock:
- bool deadlock = false;
- if (not simix_global->process_list.empty()) {
- deadlock = true;
- for (auto kv : simix_global->process_list)
- if (simgrid::mc::actor_is_enabled(kv.second)) {
- deadlock = false;
- break;
- }
- }
-
- // Send result:
- s_mc_int_message_t answer;
- answer.type = MC_MESSAGE_DEADLOCK_CHECK_REPLY;
- answer.value = deadlock;
- xbt_assert(channel_.send(answer) == 0, "Could not send response");
- } break;
+ mc_message_t* message = (mc_message_t*)message_buffer;
+ switch (message->type) {
+
+ case MC_MESSAGE_DEADLOCK_CHECK:
+ xbt_assert(received_size == sizeof(mc_message_t), "Unexpected size for DEADLOCK_CHECK (%zu != %zu)",
+ received_size, sizeof(mc_message_t));
+ handleDeadlockCheck(message);
+ break;
case MC_MESSAGE_CONTINUE:
+ xbt_assert(received_size == sizeof(mc_message_t), "Unexpected size for MESSAGE_CONTINUE (%zu != %zu)",
+ received_size, sizeof(mc_message_t));
+ handleContinue(message);
return;
- case MC_MESSAGE_SIMCALL_HANDLE: {
- s_mc_simcall_handle_message_t message;
- if (received_size != sizeof(message))
- xbt_die("Unexpected size for SIMCALL_HANDLE");
- memcpy(&message, message_buffer, sizeof(message));
- smx_actor_t process = SIMIX_process_from_PID(message.pid);
- if (not process)
- xbt_die("Invalid pid %lu", (unsigned long)message.pid);
- SIMIX_simcall_handle(&process->simcall, message.value);
- if (channel_.send(MC_MESSAGE_WAITING))
- xbt_die("Could not send MESSAGE_WAITING to model-checker");
- } break;
-
- case MC_MESSAGE_RESTORE: {
- s_mc_restore_message_t message;
- if (received_size != sizeof(message))
- xbt_die("Unexpected size for SIMCALL_HANDLE");
- memcpy(&message, message_buffer, sizeof(message));
-#if HAVE_SMPI
- smpi_really_switch_data_segment(message.index);
-#endif
- } break;
+ case MC_MESSAGE_SIMCALL_HANDLE:
+ xbt_assert(received_size == sizeof(s_mc_message_simcall_handle_t),
+ "Unexpected size for SIMCALL_HANDLE (%zu != %zu)", received_size,
+ sizeof(s_mc_message_simcall_handle_t));
+ handleSimcall((s_mc_message_simcall_handle_t*)message_buffer);
+ break;
+
+ case MC_MESSAGE_RESTORE:
+ xbt_assert(received_size == sizeof(mc_message_t), "Unexpected size for MESSAGE_RESTORE (%zu != %zu)",
+ received_size, sizeof(mc_message_t));
+ handleRestore((s_mc_message_restore_t*)message_buffer);
+ break;
default:
- xbt_die("Received unexpected message %s (%i)", MC_message_type_name(message.type), message.type);
+ xbt_die("Received unexpected message %s (%i)", MC_message_type_name(message->type), message->type);
+ break;
}
}
}
void Client::ignoreMemory(void* addr, std::size_t size)
{
- s_mc_ignore_memory_message_t message;
+ s_mc_message_ignore_memory_t message;
message.type = MC_MESSAGE_IGNORE_MEMORY;
message.addr = (std::uintptr_t)addr;
message.size = size;
{
xbt_mheap_t heap = mmalloc_get_current_heap();
- s_mc_ignore_heap_message_t message;
+ s_mc_message_ignore_heap_t message;
message.type = MC_MESSAGE_IGNORE_HEAP;
message.address = address;
message.size = size;
void Client::unignoreHeap(void* address, std::size_t size)
{
- s_mc_ignore_memory_message_t message;
+ s_mc_message_ignore_memory_t message;
message.type = MC_MESSAGE_UNIGNORE_HEAP;
message.addr = (std::uintptr_t)address;
message.size = size;
void Client::declareSymbol(const char* name, int* value)
{
- s_mc_register_symbol_message_t message;
+ s_mc_message_register_symbol_t message;
message.type = MC_MESSAGE_REGISTER_SYMBOL;
if (strlen(name) + 1 > sizeof(message.name))
xbt_die("Symbol is too long");
#endif
region.process_index = -1;
- s_mc_stack_region_message_t message;
+ s_mc_message_stack_region_t message;
message.type = MC_MESSAGE_STACK_REGION;
message.stack_region = region;
if (channel_.send(message))
private:
bool active_ = false;
Channel channel_;
- static std::unique_ptr<Client> client_;
+ static std::unique_ptr<Client> instance_;
public:
Client();
explicit Client(int fd) : active_(true), channel_(fd) {}
void handleMessages();
+
+private:
+ void handleDeadlockCheck(mc_message_t* msg);
+ void handleContinue(mc_message_t* msg);
+ void handleSimcall(s_mc_message_simcall_handle_t* message);
+ void handleRestore(s_mc_message_restore_t* msg);
+
+public:
Channel const& getChannel() const { return channel_; }
Channel& getChannel() { return channel_; }
void mainLoop();
// Singleton :/
// TODO, remove the singleton antipattern.
static Client* initialize();
- static Client* get() { return client_.get(); }
+ static Client* get() { return instance_.get(); }
};
}
}
#define _FILE_OFFSET_BITS 64 /* needed for pread_whole to work as expected on 32bits */
#include <assert.h>
+#include <errno.h>
#include <stddef.h>
#include <stdint.h>
-#include <errno.h>
#include <sys/ptrace.h>
#include <cstdio>
-#include <sys/types.h>
#include <fcntl.h>
-#include <unistd.h>
#include <regex.h>
#include <sys/mman.h> // PROT_*
+#include <sys/types.h>
+#include <unistd.h>
#include <pthread.h>
#include <libgen.h>
-#include <libunwind.h>
#include <libunwind-ptrace.h>
+#include <libunwind.h>
#include "xbt/base.h"
#include "xbt/log.h"
#include <xbt/mmalloc.h>
-#include "src/mc/mc_unw.h"
-#include "src/mc/mc_snapshot.h"
#include "src/mc/mc_smx.h"
+#include "src/mc/mc_snapshot.h"
+#include "src/mc/mc_unw.h"
-#include "src/mc/Process.hpp"
#include "src/mc/AddressSpace.hpp"
#include "src/mc/ObjectInformation.hpp"
#include "src/mc/Variable.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
using simgrid::mc::remote;
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_process, mc,
- "MC process information");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_process, mc, "MC process information");
// ***** Helper stuff
static bool is_filtered_lib(const char* libname)
{
for (const char* filtered_lib : filtered_libraries)
- if (strcmp(libname, filtered_lib)==0)
+ if (strcmp(libname, filtered_lib) == 0)
return true;
return false;
}
char* map_basename = xbt_basename(pathname);
regmatch_t match;
- if(regexec(&res->so_re, map_basename, 1, &match, 0)) {
+ if (regexec(&res->so_re, map_basename, 1, &match, 0)) {
free(map_basename);
return nullptr;
}
// Strip the version suffix:
if (libname && not regexec(&res->version_re, libname, 1, &match, 0)) {
char* temp = libname;
- libname = strndup(temp, match.rm_so);
+ libname = strndup(temp, match.rm_so);
free(temp);
}
return libname;
}
-static ssize_t pread_whole(int fd, void *buf, size_t count, off_t offset)
+static ssize_t pread_whole(int fd, void* buf, size_t count, off_t offset)
{
- char* buffer = (char*) buf;
+ char* buffer = (char*)buf;
ssize_t real_count = count;
while (count) {
ssize_t res = pread(fd, buffer, count, offset);
if (res > 0) {
- count -= res;
+ count -= res;
buffer += res;
offset += res;
- } else if (res==0)
+ } else if (res == 0)
return -1;
else if (errno != EINTR) {
perror("pread_whole");
return real_count;
}
-static ssize_t pwrite_whole(int fd, const void *buf, size_t count, off_t offset)
+static ssize_t pwrite_whole(int fd, const void* buf, size_t count, off_t offset)
{
- const char* buffer = (const char*) buf;
+ const char* buffer = (const char*)buf;
ssize_t real_count = count;
while (count) {
ssize_t res = pwrite(fd, buffer, count, offset);
if (res > 0) {
- count -= res;
+ count -= res;
buffer += res;
offset += res;
- } else if (res==0)
+ } else if (res == 0)
return -1;
else if (errno != EINTR)
return -1;
static void zero_buffer_init()
{
int fd = open("/dev/zero", O_RDONLY);
- if (fd<0)
+ if (fd < 0)
xbt_die("Could not open /dev/zero");
zero_buffer = mmap(nullptr, zero_buffer_size, PROT_READ, MAP_SHARED, fd, 0);
if (zero_buffer == MAP_FAILED)
{
const size_t buffer_size = 30;
char buffer[buffer_size];
- int res = snprintf(buffer, buffer_size, "/proc/%lli/mem", (long long) pid);
- if (res < 0 || (size_t) res >= buffer_size) {
+ int res = snprintf(buffer, buffer_size, "/proc/%lli/mem", (long long)pid);
+ if (res < 0 || (size_t)res >= buffer_size) {
errno = ENAMETOOLONG;
return -1;
}
// ***** Process
-Process::Process(pid_t pid, int sockfd) :
- AddressSpace(this), pid_(pid), channel_(sockfd), running_(true)
-{}
+RemoteClient::RemoteClient(pid_t pid, int sockfd) : AddressSpace(this), pid_(pid), channel_(sockfd), running_(true)
+{
+}
-void Process::init()
+void RemoteClient::init()
{
this->memory_map_ = simgrid::xbt::get_memory_map(this->pid_);
this->init_memory_map_info();
int fd = open_vm(this->pid_, O_RDWR);
- if (fd<0)
+ if (fd < 0)
xbt_die("Could not open file for process virtual address space");
this->memory_file = fd;
xbt_die("No heap information in the target process");
if (not std_heap_var->address)
xbt_die("No constant address for this variable");
- this->read_bytes(&this->heap_address, sizeof(struct mdesc*),
- remote(std_heap_var->address),
- simgrid::mc::ProcessIndexDisabled);
+ this->read_bytes(&this->heap_address, sizeof(struct mdesc*), remote(std_heap_var->address),
+ simgrid::mc::ProcessIndexDisabled);
this->smx_actors_infos.clear();
this->smx_dead_actors_infos.clear();
- this->unw_addr_space = simgrid::mc::UnwindContext::createUnwindAddressSpace();
+ this->unw_addr_space = simgrid::mc::UnwindContext::createUnwindAddressSpace();
this->unw_underlying_addr_space = simgrid::unw::create_addr_space();
- this->unw_underlying_context = simgrid::unw::create_context(
- this->unw_underlying_addr_space, this->pid_);
+ this->unw_underlying_context = simgrid::unw::create_context(this->unw_underlying_addr_space, this->pid_);
}
-Process::~Process()
+RemoteClient::~RemoteClient()
{
if (this->memory_file >= 0)
close(this->memory_file);
* Do not use directly, this is used by the getters when appropriate
* in order to have fresh data.
*/
-void Process::refresh_heap()
+void RemoteClient::refresh_heap()
{
// Read/dereference/refresh the std_heap pointer:
if (not this->heap)
this->heap = std::unique_ptr<s_xbt_mheap_t>(new s_xbt_mheap_t());
- this->read_bytes(this->heap.get(), sizeof(struct mdesc),
- remote(this->heap_address), simgrid::mc::ProcessIndexDisabled);
- this->cache_flags_ |= Process::cache_heap;
+ this->read_bytes(this->heap.get(), sizeof(struct mdesc), remote(this->heap_address),
+ simgrid::mc::ProcessIndexDisabled);
+ this->cache_flags_ |= RemoteClient::cache_heap;
}
/** Refresh the information about the process
* Do not use direclty, this is used by the getters when appropriate
* in order to have fresh data.
* */
-void Process::refresh_malloc_info()
+void RemoteClient::refresh_malloc_info()
{
// Refresh process->heapinfo:
- if (this->cache_flags_ & Process::cache_malloc)
+ if (this->cache_flags_ & RemoteClient::cache_malloc)
return;
size_t count = this->heap->heaplimit + 1;
if (this->heap_info.size() < count)
this->heap_info.resize(count);
- this->read_bytes(this->heap_info.data(), count * sizeof(malloc_info),
- remote(this->heap->heapinfo), simgrid::mc::ProcessIndexDisabled);
- this->cache_flags_ |= Process::cache_malloc;
+ this->read_bytes(this->heap_info.data(), count * sizeof(malloc_info), remote(this->heap->heapinfo),
+ simgrid::mc::ProcessIndexDisabled);
+ this->cache_flags_ |= RemoteClient::cache_malloc;
}
/** @brief Finds the range of the different memory segments and binary paths */
-void Process::init_memory_map_info()
+void RemoteClient::init_memory_map_info()
{
XBT_DEBUG("Get debug information ...");
this->maestro_stack_start_ = nullptr;
- this->maestro_stack_end_ = nullptr;
+ this->maestro_stack_end_ = nullptr;
this->object_infos.resize(0);
- this->binary_info = nullptr;
+ this->binary_info = nullptr;
this->libsimgrid_info = nullptr;
struct s_mc_memory_map_re res;
- if(regcomp(&res.so_re, SO_RE, 0) || regcomp(&res.version_re, VERSION_RE, 0))
+ if (regcomp(&res.so_re, SO_RE, 0) || regcomp(&res.version_re, VERSION_RE, 0))
xbt_die(".so regexp did not compile");
std::vector<simgrid::xbt::VmMap> const& maps = this->memory_map_;
this->object_infos.clear();
- for (size_t i=0; i < maps.size(); i++) {
+ for (size_t i = 0; i < maps.size(); i++) {
simgrid::xbt::VmMap const& reg = maps[i];
- const char* pathname = maps[i].pathname.c_str();
+ const char* pathname = maps[i].pathname.c_str();
// Nothing to do
if (maps[i].pathname.empty()) {
if (pathname[0] == '[') {
if ((reg.prot & PROT_WRITE) && not memcmp(pathname, "[stack]", 7)) {
this->maestro_stack_start_ = remote(reg.start_addr);
- this->maestro_stack_end_ = remote(reg.end_addr);
+ this->maestro_stack_end_ = remote(reg.end_addr);
}
current_name = nullptr;
continue;
}
- if (current_name && strcmp(current_name, pathname)==0)
+ if (current_name && strcmp(current_name, pathname) == 0)
continue;
current_name = pathname;
continue;
const bool is_executable = not i;
- char* libname = nullptr;
+ char* libname = nullptr;
if (not is_executable) {
libname = get_lib_name(pathname, &res);
if (not libname)
}
std::shared_ptr<simgrid::mc::ObjectInformation> info =
- simgrid::mc::createObjectInformation(this->memory_map_, pathname);
+ simgrid::mc::createObjectInformation(this->memory_map_, pathname);
this->object_infos.push_back(info);
if (is_executable)
this->binary_info = info;
XBT_DEBUG("Get debug information done !");
}
-std::shared_ptr<simgrid::mc::ObjectInformation> Process::find_object_info(RemotePtr<void> addr) const
+std::shared_ptr<simgrid::mc::ObjectInformation> RemoteClient::find_object_info(RemotePtr<void> addr) const
{
for (auto const& object_info : this->object_infos)
- if (addr.address() >= (std::uint64_t)object_info->start
- && addr.address() <= (std::uint64_t)object_info->end)
+ if (addr.address() >= (std::uint64_t)object_info->start && addr.address() <= (std::uint64_t)object_info->end)
return object_info;
return nullptr;
}
-std::shared_ptr<ObjectInformation> Process::find_object_info_exec(RemotePtr<void> addr) const
+std::shared_ptr<ObjectInformation> RemoteClient::find_object_info_exec(RemotePtr<void> addr) const
{
for (std::shared_ptr<ObjectInformation> const& info : this->object_infos)
- if (addr.address() >= (std::uint64_t) info->start_exec
- && addr.address() <= (std::uint64_t) info->end_exec)
+ if (addr.address() >= (std::uint64_t)info->start_exec && addr.address() <= (std::uint64_t)info->end_exec)
return info;
return nullptr;
}
-std::shared_ptr<ObjectInformation> Process::find_object_info_rw(RemotePtr<void> addr) const
+std::shared_ptr<ObjectInformation> RemoteClient::find_object_info_rw(RemotePtr<void> addr) const
{
for (std::shared_ptr<ObjectInformation> const& info : this->object_infos)
- if (addr.address() >= (std::uint64_t)info->start_rw
- && addr.address() <= (std::uint64_t)info->end_rw)
+ if (addr.address() >= (std::uint64_t)info->start_rw && addr.address() <= (std::uint64_t)info->end_rw)
return info;
return nullptr;
}
-simgrid::mc::Frame* Process::find_function(RemotePtr<void> ip) const
+simgrid::mc::Frame* RemoteClient::find_function(RemotePtr<void> ip) const
{
std::shared_ptr<simgrid::mc::ObjectInformation> info = this->find_object_info_exec(ip);
- return info ? info->find_function((void*) ip.address()) : nullptr;
+ return info ? info->find_function((void*)ip.address()) : nullptr;
}
/** Find (one occurrence of) the named variable definition
*/
-simgrid::mc::Variable* Process::find_variable(const char* name) const
+simgrid::mc::Variable* RemoteClient::find_variable(const char* name) const
{
// First lookup the variable in the executable shared object.
// A global variable used directly by the executable code from a library
// We need to look up the variable in the executable first.
if (this->binary_info) {
std::shared_ptr<simgrid::mc::ObjectInformation> const& info = this->binary_info;
- simgrid::mc::Variable* var = info->find_variable(name);
+ simgrid::mc::Variable* var = info->find_variable(name);
if (var)
return var;
}
return nullptr;
}
-void Process::read_variable(const char* name, void* target, size_t size) const
+void RemoteClient::read_variable(const char* name, void* target, size_t size) const
{
simgrid::mc::Variable* var = this->find_variable(name);
xbt_assert(var->address, "No simple location for this variable");
this->read_bytes(target, size, remote(var->address));
}
-std::string Process::read_string(RemotePtr<char> address) const
+std::string RemoteClient::read_string(RemotePtr<char> address) const
{
if (not address)
return {};
off_t off = 0;
while (1) {
- ssize_t c = pread(this->memory_file, res.data() + off, res.size() - off, (off_t) address.address() + off);
+ ssize_t c = pread(this->memory_file, res.data() + off, res.size() - off, (off_t)address.address() + off);
if (c == -1) {
if (errno == EINTR)
continue;
else
xbt_die("Could not read from from remote process");
}
- if (c==0)
+ if (c == 0)
xbt_die("Could not read string from remote process");
void* p = memchr(res.data() + off, '\0', c);
return std::string(res.data());
off += c;
- if (off == (off_t) res.size())
+ if (off == (off_t)res.size())
res.resize(res.size() * 2);
}
}
-const void *Process::read_bytes(void* buffer, std::size_t size,
- RemotePtr<void> address, int process_index,
- ReadOptions options) const
+const void* RemoteClient::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, int process_index,
+ ReadOptions options) const
{
if (process_index != simgrid::mc::ProcessIndexDisabled) {
- std::shared_ptr<simgrid::mc::ObjectInformation> const& info =
- this->find_object_info_rw((void*)address.address());
- // Segment overlap is not handled.
+ std::shared_ptr<simgrid::mc::ObjectInformation> const& info = this->find_object_info_rw((void*)address.address());
+// Segment overlap is not handled.
#if HAVE_SMPI
if (info.get() && this->privatized(*info)) {
if (process_index < 0)
xbt_die("Missing process index");
- if (process_index >= (int) MC_smpi_process_count())
+ if (process_index >= (int)MC_smpi_process_count())
xbt_die("Invalid process index");
// Read smpi_privatization_regions from MCed:
smpi_privatization_region_t remote_smpi_privatization_regions =
- mc_model_checker->process().read_variable<smpi_privatization_region_t>(
- "smpi_privatization_regions");
+ mc_model_checker->process().read_variable<smpi_privatization_region_t>("smpi_privatization_regions");
s_smpi_privatization_region_t privatization_region =
- mc_model_checker->process().read<s_smpi_privatization_region_t>(
- remote(remote_smpi_privatization_regions + process_index));
+ mc_model_checker->process().read<s_smpi_privatization_region_t>(
+ remote(remote_smpi_privatization_regions + process_index));
// Address translation in the privatization segment:
size_t offset = address.address() - (std::uint64_t)info->start_rw;
- address = remote((char*)privatization_region.address + offset);
+ address = remote((char*)privatization_region.address + offset);
}
#endif
}
- if (pread_whole(this->memory_file, buffer, size, (size_t) address.address()) < 0)
+ if (pread_whole(this->memory_file, buffer, size, (size_t)address.address()) < 0)
xbt_die("Read at %p from process %lli failed", (void*)address.address(), (long long)this->pid_);
return buffer;
}
* @param len data size
* @param address target process memory address (target)
*/
-void Process::write_bytes(const void* buffer, size_t len, RemotePtr<void> address)
+void RemoteClient::write_bytes(const void* buffer, size_t len, RemotePtr<void> address)
{
- if (pwrite_whole(this->memory_file, buffer, len, (size_t)address.address()) < 0)
- xbt_die("Write to process %lli failed", (long long) this->pid_);
+ if (pwrite_whole(this->memory_file, buffer, len, (size_t)address.address()) < 0)
+ xbt_die("Write to process %lli failed", (long long)this->pid_);
}
-void Process::clear_bytes(RemotePtr<void> address, size_t len)
+void RemoteClient::clear_bytes(RemotePtr<void> address, size_t len)
{
pthread_once(&zero_buffer_flag, zero_buffer_init);
while (len) {
size_t s = len > zero_buffer_size ? zero_buffer_size : len;
this->write_bytes(zero_buffer, s, address);
- address = remote((char*) address.address() + s);
+ address = remote((char*)address.address() + s);
len -= s;
}
}
-void Process::ignore_region(std::uint64_t addr, std::size_t size)
+void RemoteClient::ignore_region(std::uint64_t addr, std::size_t size)
{
IgnoredRegion region;
region.addr = addr;
return;
}
- unsigned int cursor = 0;
+ unsigned int cursor = 0;
IgnoredRegion* current_region = nullptr;
int start = 0;
- int end = ignored_regions_.size() - 1;
+ int end = ignored_regions_.size() - 1;
while (start <= end) {
- cursor = (start + end) / 2;
+ cursor = (start + end) / 2;
current_region = &ignored_regions_[cursor];
if (current_region->addr == addr) {
if (current_region->size == size)
position = cursor + 1;
else
position = cursor;
- ignored_regions_.insert(
- ignored_regions_.begin() + position, region);
+ ignored_regions_.insert(ignored_regions_.begin() + position, region);
}
-void Process::ignore_heap(IgnoredHeapRegion const& region)
+void RemoteClient::ignore_heap(IgnoredHeapRegion const& region)
{
if (ignored_heap_.empty()) {
ignored_heap_.push_back(std::move(region));
typedef std::vector<IgnoredHeapRegion>::size_type size_type;
size_type start = 0;
- size_type end = ignored_heap_.size() - 1;
+ size_type end = ignored_heap_.size() - 1;
// Binary search the position of insertion:
size_type cursor;
while (start <= end) {
- cursor = start + (end - start) / 2;
+ cursor = start + (end - start) / 2;
auto& current_region = ignored_heap_[cursor];
if (current_region.address == region.address)
return;
// Insert it mc_heap_ignore_region_t:
if (ignored_heap_[cursor].address < region.address)
++cursor;
- ignored_heap_.insert( ignored_heap_.begin() + cursor, region);
+ ignored_heap_.insert(ignored_heap_.begin() + cursor, region);
}
-void Process::unignore_heap(void *address, size_t size)
+void RemoteClient::unignore_heap(void* address, size_t size)
{
typedef std::vector<IgnoredHeapRegion>::size_type size_type;
size_type start = 0;
- size_type end = ignored_heap_.size() - 1;
+ size_type end = ignored_heap_.size() - 1;
// Binary search:
size_type cursor;
while (start <= end) {
- cursor = (start + end) / 2;
+ cursor = (start + end) / 2;
auto& region = ignored_heap_[cursor];
if (region.address == address) {
ignored_heap_.erase(ignored_heap_.begin() + cursor);
return;
} else if (region.address < address)
start = cursor + 1;
- else if ((char *) region.address <= ((char *) address + size)) {
+ else if ((char*)region.address <= ((char*)address + size)) {
ignored_heap_.erase(ignored_heap_.begin() + cursor);
return;
} else if (cursor != 0)
}
}
-void Process::ignore_local_variable(const char *var_name, const char *frame_name)
+void RemoteClient::ignore_local_variable(const char* var_name, const char* frame_name)
{
if (frame_name != nullptr && strcmp(frame_name, "*") == 0)
frame_name = nullptr;
- for (std::shared_ptr<simgrid::mc::ObjectInformation> const& info :
- this->object_infos)
+ for (std::shared_ptr<simgrid::mc::ObjectInformation> const& info : this->object_infos)
info->remove_local_variable(var_name, frame_name);
}
-std::vector<simgrid::mc::ActorInformation>& Process::actors()
+std::vector<simgrid::mc::ActorInformation>& RemoteClient::actors()
{
this->refresh_simix();
return smx_actors_infos;
}
-std::vector<simgrid::mc::ActorInformation>& Process::dead_actors()
+std::vector<simgrid::mc::ActorInformation>& RemoteClient::dead_actors()
{
this->refresh_simix();
return smx_dead_actors_infos;
}
-void Process::dumpStack()
+void RemoteClient::dumpStack()
{
unw_addr_space_t as = unw_create_addr_space(&_UPT_accessors, BYTE_ORDER);
if (as == nullptr) {
unw_destroy_addr_space(as);
return;
}
-
}
}
-/* Copyright (c) 2008-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2008-2017. 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_MC_PROCESS_H
#define SIMGRID_MC_PROCESS_H
-#include <cstdint>
#include <cstddef>
+#include <cstdint>
-#include <type_traits>
-#include <vector>
#include <memory>
#include <string>
+#include <type_traits>
+#include <vector>
#include <sys/types.h>
#include "src/mc/remote/Channel.hpp"
#include "src/mc/remote/RemotePtr.hpp"
-#include <simgrid/simix.h>
#include "src/simix/popping_private.h"
#include "src/simix/smx_private.h"
+#include <simgrid/simix.h>
#include "src/xbt/memory_map.hpp"
void clear()
{
name.clear();
- address = nullptr;
+ address = nullptr;
hostname = nullptr;
}
};
struct IgnoredHeapRegion {
int block;
int fragment;
- void *address;
+ void* address;
std::size_t size;
};
-/** Representation of a process
+/** The Model-Checked process, seen from the MCer perspective
*
* This class is mixing a lot of different responsibilities and is tied
* to SIMIX. It should probably be split into different classes.
* - stack unwinding;
* - etc.
*/
-class Process final : public AddressSpace {
+class RemoteClient final : public AddressSpace {
private:
// Those flags are used to track down which cached information
// is still up to date and which information needs to be updated.
- static constexpr int cache_none = 0;
- static constexpr int cache_heap = 1;
- static constexpr int cache_malloc = 2;
+ static constexpr int cache_none = 0;
+ static constexpr int cache_heap = 1;
+ static constexpr int cache_malloc = 2;
static constexpr int cache_simix_processes = 4;
+
public:
- Process(pid_t pid, int sockfd);
- ~Process();
+ RemoteClient(pid_t pid, int sockfd);
+ ~RemoteClient();
void init();
- Process(Process const&) = delete;
- Process(Process &&) = delete;
- Process& operator=(Process const&) = delete;
- Process& operator=(Process &&) = delete;
+ RemoteClient(RemoteClient const&) = delete;
+ RemoteClient(RemoteClient&&) = delete;
+ RemoteClient& operator=(RemoteClient const&) = delete;
+ RemoteClient& operator=(RemoteClient&&) = delete;
// Read memory:
- const void* read_bytes(void* buffer, std::size_t size,
- RemotePtr<void> address, int process_index = ProcessIndexAny,
- ReadOptions options = ReadOptions::none()) const override;
+ const void* read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, int process_index = ProcessIndexAny,
+ ReadOptions options = ReadOptions::none()) const override;
void read_variable(const char* name, void* target, size_t size) const;
- template<class T> void read_variable(const char* name, T* target) const
+ template <class T> void read_variable(const char* name, T* target) const
{
read_variable(name, target, sizeof(*target));
}
- template<class T>
- Remote<T> read_variable(const char *name) const
+ template <class T> Remote<T> read_variable(const char* name) const
{
Remote<T> res;
read_variable(name, res.getBuffer(), sizeof(T));
// Heap access:
xbt_mheap_t get_heap()
{
- if (not(this->cache_flags_ & Process::cache_heap))
+ if (not(this->cache_flags_ & RemoteClient::cache_heap))
this->refresh_heap();
return this->heap.get();
}
const malloc_info* get_malloc_info()
{
- if (not(this->cache_flags_ & Process::cache_malloc))
+ if (not(this->cache_flags_ & RemoteClient::cache_malloc))
this->refresh_malloc_info();
return this->heap_info.data();
}
- void clear_cache()
- {
- this->cache_flags_ = Process::cache_none;
- }
+ void clear_cache() { this->cache_flags_ = RemoteClient::cache_none; }
Channel const& getChannel() const { return channel_; }
Channel& getChannel() { return channel_; }
- std::vector<IgnoredRegion> const& ignored_regions() const
- {
- return ignored_regions_;
- }
+ std::vector<IgnoredRegion> const& ignored_regions() const { return ignored_regions_; }
void ignore_region(std::uint64_t address, std::size_t size);
pid_t pid() const { return pid_; }
return p >= this->maestro_stack_start_ && p < this->maestro_stack_end_;
}
- bool running() const
- {
- return running_;
- }
+ bool running() const { return running_; }
- void terminate()
- {
- running_ = false;
- }
+ void terminate() { running_ = false; }
- bool privatized(ObjectInformation const& info) const
- {
- return privatized_ && info.executable();
- }
- bool privatized() const
- {
- return privatized_;
- }
+ bool privatized(ObjectInformation const& info) const { return privatized_ && info.executable(); }
+ bool privatized() const { return privatized_; }
void privatized(bool privatized) { privatized_ = privatized; }
void ignore_global_variable(const char* name)
{
- for (std::shared_ptr<simgrid::mc::ObjectInformation> const& info :
- this->object_infos)
+ for (std::shared_ptr<simgrid::mc::ObjectInformation> const& info : this->object_infos)
info->remove_global_variable(name);
}
- std::vector<s_stack_region_t>& stack_areas()
- {
- return stack_areas_;
- }
- std::vector<s_stack_region_t> const& stack_areas() const
- {
- return stack_areas_;
- }
+ std::vector<s_stack_region_t>& stack_areas() { return stack_areas_; }
+ std::vector<s_stack_region_t> const& stack_areas() const { return stack_areas_; }
- std::vector<IgnoredHeapRegion> const& ignored_heap() const
- {
- return ignored_heap_;
- }
+ std::vector<IgnoredHeapRegion> const& ignored_heap() const { return ignored_heap_; }
void ignore_heap(IgnoredHeapRegion const& region);
- void unignore_heap(void *address, size_t size);
+ void unignore_heap(void* address, size_t size);
- void ignore_local_variable(const char *var_name, const char *frame_name);
+ void ignore_local_variable(const char* var_name, const char* frame_name);
std::vector<simgrid::mc::ActorInformation>& actors();
std::vector<simgrid::mc::ActorInformation>& dead_actors();
std::shared_ptr<simgrid::mc::ObjectInformation> binary_info;
public: // Copies of MCed SMX data structures
- /** Copy of `simix_global->process_list`
- *
- * See mc_smx.c.
- */
+ /** Copy of `simix_global->process_list`
+ *
+ * See mc_smx.c.
+ */
std::vector<ActorInformation> smx_actors_infos;
/** Copy of `simix_global->process_to_destroy`
private:
/** State of the cache (which variables are up to date) */
- int cache_flags_ = Process::cache_none;
+ int cache_flags_ = RemoteClient::cache_none;
public:
/** Address of the heap structure in the MCed process. */
* This is not used if the process is the current one:
* use `get_heap_info()` in order to use it.
*/
- std::unique_ptr<s_xbt_mheap_t> heap;
+ std::unique_ptr<s_xbt_mheap_t> heap;
/** Copy of the allocation info structure
*
std::vector<malloc_info> heap_info;
public: // Libunwind-data
-
- /** Full-featured MC-aware libunwind address space for the process
- *
- * This address space is using a simgrid::mc::UnwindContext*
- * (with simgrid::mc::Process* / simgrid::mc::AddressSpace*
- * and unw_context_t).
- */
+ /** Full-featured MC-aware libunwind address space for the process
+ *
+ * This address space is using a simgrid::mc::UnwindContext*
+ * (with simgrid::mc::Process* / simgrid::mc::AddressSpace*
+ * and unw_context_t).
+ */
unw_addr_space_t unw_addr_space;
/** Underlying libunwind address-space
/** Open a FD to a remote process memory (`/dev/$pid/mem`)
*/
XBT_PRIVATE int open_vm(pid_t pid, int flags);
-
}
}
*
* Moreover the protocol is not stable. The same version of the library should be used
* for the client and the server.
- *
- * This is the basic structure shared by all messages: all message start with a message
- * type.
*/
+
+/* Basic structure: all message start with a message type */
struct s_mc_message {
e_mc_message_type type;
};
-typedef struct s_mc_message s_mc_message_t;
-typedef struct s_mc_message* mc_message_t;
+typedef struct s_mc_message mc_message_t;
-struct s_mc_int_message {
+struct s_mc_message_int {
e_mc_message_type type;
uint64_t value;
};
-typedef struct s_mc_int_message s_mc_int_message_t;
-typedef struct s_mc_int_message* mc_int_message_t;
+typedef struct s_mc_message_int mc_message_int_t;
-struct s_mc_ignore_heap_message {
+/* Client->Server */
+struct s_mc_message_ignore_heap {
e_mc_message_type type;
int block;
int fragment;
void* address;
size_t size;
};
-typedef struct s_mc_ignore_heap_message s_mc_ignore_heap_message_t;
-typedef struct s_mc_ignore_heap_message* mc_ignore_heap_message_t;
+typedef struct s_mc_message_ignore_heap s_mc_message_ignore_heap_t;
-struct s_mc_ignore_memory_message {
+struct s_mc_message_ignore_memory {
e_mc_message_type type;
uint64_t addr;
size_t size;
};
-typedef struct s_mc_ignore_memory_message s_mc_ignore_memory_message_t;
-typedef struct s_mc_ignore_memory_message* mc_ignore_memory_message_t;
+typedef struct s_mc_message_ignore_memory s_mc_message_ignore_memory_t;
-struct s_mc_stack_region_message {
+struct s_mc_message_stack_region {
e_mc_message_type type;
s_stack_region_t stack_region;
};
-typedef struct s_mc_stack_region_message s_mc_stack_region_message_t;
-typedef struct s_mc_stack_region_message* mc_stack_region_message_t;
-
-struct s_mc_simcall_handle_message {
- e_mc_message_type type;
- unsigned long pid;
- int value;
-};
-typedef struct s_mc_simcall_handle_message s_mc_simcall_handle_message_t;
-typedef struct s_mc_simcall_handle_message* mc_simcall_handle_message;
+typedef struct s_mc_message_stack_region s_mc_message_stack_region_t;
-struct s_mc_register_symbol_message {
+struct s_mc_message_register_symbol {
e_mc_message_type type;
char name[128];
int (*callback)(void*);
void* data;
};
-typedef struct s_mc_register_symbol_message s_mc_register_symbol_message_t;
-typedef struct s_mc_register_symbol_message* mc_register_symbol_message_t;
+typedef struct s_mc_message_register_symbol s_mc_message_register_symbol_t;
+
+/* Server -> client */
+struct s_mc_message_simcall_handle {
+ e_mc_message_type type;
+ unsigned long pid;
+ int value;
+};
+typedef struct s_mc_message_simcall_handle s_mc_message_simcall_handle_t;
-struct s_mc_restore_message {
+struct s_mc_message_restore {
e_mc_message_type type;
int index;
};
-typedef struct s_mc_restore_message s_mc_restore_message_t;
-typedef struct s_mc_restore_message* mc_restore_message_t;
+typedef struct s_mc_message_restore s_mc_message_restore_t;
XBT_PRIVATE const char* MC_message_type_name(e_mc_message_type type);
return host->getSpeed();
}
-/** \ingroup m_host_management
- * \brief Return the speed of the processor (in flop/s), regardless of the current load on the machine.
- * Deprecated: use MSG_host_get_speed
- */
-double MSG_get_host_speed(msg_host_t host) {
- XBT_WARN("MSG_get_host_speed is deprecated: use MSG_host_get_speed");
- return MSG_host_get_speed(host);
-}
-
/** \ingroup m_host_management
* \brief Return the number of cores.
*
/* Create file on remote host, write it and close it */
msg_file_t fd = new simgrid::s4u::File(fullpath, dst_host, nullptr);
- fd->write(read_size, dst_host);
+ fd->write(read_size);
delete fd;
return MSG_OK;
}
static void start_dirty_page_tracking(msg_vm_t vm)
{
vm->pimpl_vm_->dp_enabled = 1;
- if (not vm->pimpl_vm_->dp_objs)
+ if (vm->pimpl_vm_->dp_objs.empty())
return;
- char *key = nullptr;
- xbt_dict_cursor_t cursor = nullptr;
- dirty_page_t dp = nullptr;
- xbt_dict_foreach (vm->pimpl_vm_->dp_objs, cursor, key, dp) {
+ for (auto elm : vm->pimpl_vm_->dp_objs) {
+ dirty_page_t dp = elm.second;
double remaining = MSG_task_get_flops_amount(dp->task);
dp->prev_clock = MSG_get_clock();
dp->prev_remaining = remaining;
-
- // XBT_INFO("%s@%s remaining %f", key, sg_host_name(vm), remaining);
+ XBT_DEBUG("%s@%s remaining %f", elm.first.c_str(), vm->getCname(), remaining);
}
}
vm->pimpl_vm_->dp_enabled = 0;
}
-static double get_computed(char *key, msg_vm_t vm, dirty_page_t dp, double remaining, double clock)
+static double get_computed(const char* key, msg_vm_t vm, dirty_page_t dp, double remaining, double clock)
{
double computed = dp->prev_remaining - remaining;
double duration = clock - dp->prev_clock;
{
double total = 0;
- char *key = nullptr;
- xbt_dict_cursor_t cursor = nullptr;
- dirty_page_t dp = nullptr;
- xbt_dict_foreach (vm->pimpl_vm_->dp_objs, cursor, key, dp) {
+ for (auto elm : vm->pimpl_vm_->dp_objs) {
+ const char* key = elm.first.c_str();
+ dirty_page_t dp = elm.second;
double remaining = MSG_task_get_flops_amount(dp->task);
double clock = MSG_get_clock();
dp->prev_clock = MSG_get_clock();
dp->prev_remaining = remaining;
}
- if (not vm->pimpl_vm_->dp_objs)
- vm->pimpl_vm_->dp_objs = xbt_dict_new_homogeneous(nullptr);
- xbt_assert(xbt_dict_get_or_null(vm->pimpl_vm_->dp_objs, key) == nullptr);
- xbt_dict_set(vm->pimpl_vm_->dp_objs, key, dp, nullptr);
+ vm->pimpl_vm_->dp_objs.insert({key, dp});
XBT_DEBUG("add %s on %s (remaining %f, dp_enabled %d)", key, host->getCname(), remaining, vm->pimpl_vm_->dp_enabled);
xbt_free(key);
return;
char *key = bprintf("%s-%p", task->name, task);
- dirty_page_t dp = (dirty_page_t)(vm->pimpl_vm_->dp_objs ? xbt_dict_get_or_null(vm->pimpl_vm_->dp_objs, key) : NULL);
- xbt_assert(dp->task == task);
+ dirty_page_t dp = nullptr;
+ if (vm->pimpl_vm_->dp_objs.find(key) != vm->pimpl_vm_->dp_objs.end())
+ dp = vm->pimpl_vm_->dp_objs.at(key);
+ xbt_assert(dp && dp->task == task);
/* If we are in the middle of dirty page tracking, we record how much computation has been done until now, and keep
* the information for the lookup_() function that will called soon. */
vm->pimpl_vm_->dp_updated_by_deleted_tasks += updated;
}
- if (vm->pimpl_vm_->dp_objs)
- xbt_dict_remove(vm->pimpl_vm_->dp_objs, key);
+
+ vm->pimpl_vm_->dp_objs.erase(key);
xbt_free(dp);
XBT_DEBUG("del %s on %s", key, host->getCname());
allVms_.erase(iter);
/* dirty page tracking */
- unsigned int size = xbt_dict_size(dp_objs);
+ unsigned int size = dp_objs.size();
static bool already_warned = false;
if (size > 0 && not already_warned) {
- xbt_dict_cursor_t cursor = nullptr;
- xbt_dict_cursor_first(dp_objs, &cursor);
+ auto front = dp_objs.begin();
XBT_WARN("Dirty page tracking: %u pending task(s) on a destroyed VM (first one is %s).\n"
"If you don't understand why your task was not properly removed, please report that bug.\n"
"This is a known bug if you turned the host off during the VM execution.\n"
"Please remind us of that problem at some point: our code base is not ready to fix this harmless issue in "
"2016, sorry.",
- size, (xbt_log_no_loc ? "(name hidden)" : xbt_dict_cursor_get_key(cursor)));
- xbt_dict_cursor_free(&cursor);
+ size, (xbt_log_no_loc ? "(name hidden)" : front->first.c_str()));
already_warned = true;
}
- xbt_dict_free(&dp_objs);
/* Free the cpu_action of the VM. */
XBT_ATTRIB_UNUSED int ret = action_->unref();
#include "src/surf/HostImpl.hpp"
#include <algorithm>
#include <deque>
+#include <unordered_map>
#ifndef VM_INTERFACE_HPP_
#define VM_INTERFACE_HPP_
#define GUESTOS_NOISE 100 // This value corresponds to the cost of the global action associated to the VM
// It corresponds to the cost of a VM running no tasks.
+typedef struct dirty_page* dirty_page_t;
+
namespace simgrid {
namespace vm {
surf::Action* action_ = nullptr;
/* Dirty pages stuff */
+ std::unordered_map<std::string, dirty_page_t> dp_objs;
int dp_enabled = 0;
- xbt_dict_t dp_objs = nullptr;
double dp_updated_by_deleted_tasks = 0;
protected:
sg_size_t File::read(sg_size_t size)
{
- return simcall_file_read(pimpl_, size, Host::current());
+ return simcall_file_read(pimpl_, size);
}
sg_size_t File::write(sg_size_t size)
{
- return simcall_file_write(pimpl_,size, Host::current());
-}
-
-sg_size_t File::write(sg_size_t size, sg_host_t host)
-{
- return simcall_file_write(pimpl_, size, host);
+ return simcall_file_write(pimpl_, size);
}
sg_size_t File::size()
const char* Storage::getProperty(const char* key)
{
- return static_cast<const char*>(xbt_dict_get_or_null(this->getProperties(), key));
+ return this->pimpl_->getProperty(key);
}
void Storage::setProperty(const char* key, char* value)
{
- xbt_dict_set(this->getProperties(), key, value, nullptr);
+ simgrid::simix::kernelImmediate([this, key, value] { this->pimpl_->setProperty(key, value); });
}
std::map<std::string, sg_size_t>* Storage::getContent()
* \ingroup simix_file_management
*
*/
-sg_size_t simcall_file_read(surf_file_t fd, sg_size_t size, sg_host_t host)
+sg_size_t simcall_file_read(surf_file_t fd, sg_size_t size)
{
- return simcall_BODY_file_read(fd, size, host);
+ return simcall_BODY_file_read(fd, size);
}
/**
* \ingroup simix_file_management
*
*/
-sg_size_t simcall_file_write(surf_file_t fd, sg_size_t size, sg_host_t host)
+sg_size_t simcall_file_write(surf_file_t fd, sg_size_t size)
{
- return simcall_BODY_file_write(fd, size, host);
+ return simcall_BODY_file_write(fd, size);
}
void simcall_run_kernel(std::function<void()> const& code)
{
simgrid::simix::marshal<sg_size_t>(simcall->args[1], arg);
}
-static inline sg_host_t simcall_file_read__get__host(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<sg_host_t>(simcall->args[2]);
-}
-static inline sg_host_t simcall_file_read__getraw__host(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<sg_host_t>(simcall->args[2]);
-}
-static inline void simcall_file_read__set__host(smx_simcall_t simcall, sg_host_t arg)
-{
- simgrid::simix::marshal<sg_host_t>(simcall->args[2], arg);
-}
static inline sg_size_t simcall_file_read__get__result(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<sg_size_t>(simcall->result);
{
simgrid::simix::marshal<sg_size_t>(simcall->args[1], arg);
}
-static inline sg_host_t simcall_file_write__get__host(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<sg_host_t>(simcall->args[2]);
-}
-static inline sg_host_t simcall_file_write__getraw__host(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<sg_host_t>(simcall->args[2]);
-}
-static inline void simcall_file_write__set__host(smx_simcall_t simcall, sg_host_t arg)
-{
- simgrid::simix::marshal<sg_host_t>(simcall->args[2], arg);
-}
static inline sg_size_t simcall_file_write__get__result(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<sg_size_t>(simcall->result);
XBT_PRIVATE void simcall_HANDLER_sem_acquire(smx_simcall_t simcall, smx_sem_t sem);
XBT_PRIVATE void simcall_HANDLER_sem_acquire_timeout(smx_simcall_t simcall, smx_sem_t sem, double timeout);
XBT_PRIVATE int simcall_HANDLER_sem_get_capacity(smx_simcall_t simcall, smx_sem_t sem);
-XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host);
-XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host);
+XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size);
+XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size);
XBT_PRIVATE int simcall_HANDLER_mc_random(smx_simcall_t simcall, int min, int max);
\ No newline at end of file
return simcall<int, smx_sem_t>(SIMCALL_SEM_GET_CAPACITY, sem);
}
- inline static sg_size_t simcall_BODY_file_read(surf_file_t fd, sg_size_t size, sg_host_t host)
+ inline static sg_size_t simcall_BODY_file_read(surf_file_t fd, sg_size_t size)
{
/* Go to that function to follow the code flow through the simcall barrier */
- if (0) simcall_HANDLER_file_read(&SIMIX_process_self()->simcall, fd, size, host);
- return simcall<sg_size_t, surf_file_t, sg_size_t, sg_host_t>(SIMCALL_FILE_READ, fd, size, host);
+ if (0)
+ simcall_HANDLER_file_read(&SIMIX_process_self()->simcall, fd, size);
+ return simcall<sg_size_t, surf_file_t, sg_size_t>(SIMCALL_FILE_READ, fd, size);
}
- inline static sg_size_t simcall_BODY_file_write(surf_file_t fd, sg_size_t size, sg_host_t host)
+ inline static sg_size_t simcall_BODY_file_write(surf_file_t fd, sg_size_t size)
{
/* Go to that function to follow the code flow through the simcall barrier */
- if (0) simcall_HANDLER_file_write(&SIMIX_process_self()->simcall, fd, size, host);
- return simcall<sg_size_t, surf_file_t, sg_size_t, sg_host_t>(SIMCALL_FILE_WRITE, fd, size, host);
+ if (0)
+ simcall_HANDLER_file_write(&SIMIX_process_self()->simcall, fd, size);
+ return simcall<sg_size_t, surf_file_t, sg_size_t>(SIMCALL_FILE_WRITE, fd, size);
}
inline static int simcall_BODY_mc_random(int min, int max) {
case SIMCALL_FILE_READ:
simcall_HANDLER_file_read(simcall, simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]),
- simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]),
- simgrid::simix::unmarshal<sg_host_t>(simcall->args[2]));
+ simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]));
break;
case SIMCALL_FILE_WRITE:
simcall_HANDLER_file_write(simcall, simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]),
- simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]),
- simgrid::simix::unmarshal<sg_host_t>(simcall->args[2]));
+ simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]));
break;
case SIMCALL_MC_RANDOM:
void sem_acquire_timeout(smx_sem_t sem, double timeout) [[block]];
int sem_get_capacity(smx_sem_t sem);
-sg_size_t file_read(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]];
-sg_size_t file_write(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]];
+sg_size_t file_read(surf_file_t fd, sg_size_t size) [[block]];
+sg_size_t file_write(surf_file_t fd, sg_size_t size) [[block]];
int mc_random(int min, int max);
void set_category(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> synchro, const char* category) [[nohandler]];
*/
smx_timer_t SIMIX_timer_set(double date, void (*callback)(void*), void *arg)
{
- smx_timer_t timer = new s_smx_timer_t(date, [=](){ callback(arg); });
+ smx_timer_t timer = new s_smx_timer_t(date, [callback, arg]() { callback(arg); });
xbt_heap_push(simix_timers, timer, date);
return timer;
}
if (boost::dynamic_pointer_cast<simgrid::kernel::activity::IoImpl>(process->waiting_synchro) != nullptr)
synchro_description = "I/O";
-
- /*
- switch (process->waiting_synchro->type) {
- case SIMIX_SYNC_PARALLEL_EXECUTE:
- synchro_description = "parallel execution";
- break;
-
- case SIMIX_SYNC_JOIN:
- synchro_description = "joining";
- break;
-*/
-
XBT_INFO("Process %lu (%s@%s): waiting for %s synchro %p (%s) in state %d to finish", process->pid,
process->cname(), process->host->getCname(), synchro_description, process->waiting_synchro.get(),
process->waiting_synchro->name.c_str(), (int)process->waiting_synchro->state);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)");
//SIMIX FILE READ
-void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host)
+void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size)
{
- smx_activity_t synchro = SIMIX_file_read(fd, size, host);
+ smx_activity_t synchro = SIMIX_file_read(fd, size);
synchro->simcalls.push_back(simcall);
simcall->issuer->waiting_synchro = synchro;
}
-smx_activity_t SIMIX_file_read(surf_file_t file, sg_size_t size, sg_host_t host)
+smx_activity_t SIMIX_file_read(surf_file_t file, sg_size_t size)
{
- /* check if the host is active */
- if (host->isOff())
- THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->getCname());
-
simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl();
synchro->surf_io = file->read(size);
}
//SIMIX FILE WRITE
-void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host)
+void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size)
{
- smx_activity_t synchro = SIMIX_file_write(fd, size, host);
+ smx_activity_t synchro = SIMIX_file_write(fd, size);
synchro->simcalls.push_back(simcall);
simcall->issuer->waiting_synchro = synchro;
}
-smx_activity_t SIMIX_file_write(surf_file_t file, sg_size_t size, sg_host_t host)
+smx_activity_t SIMIX_file_write(surf_file_t file, sg_size_t size)
{
- if (host->isOff())
- THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->getCname());
-
simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl();
synchro->surf_io = file->write(size);
synchro->surf_io->setData(synchro);
#include "simgrid/simix.h"
#include "popping_private.h"
-XBT_PRIVATE smx_activity_t SIMIX_file_read(surf_file_t fd, sg_size_t size, sg_host_t host);
-XBT_PRIVATE smx_activity_t SIMIX_file_write(surf_file_t fd, sg_size_t size, sg_host_t host);
+XBT_PRIVATE smx_activity_t SIMIX_file_read(surf_file_t fd, sg_size_t size);
+XBT_PRIVATE smx_activity_t SIMIX_file_write(surf_file_t fd, sg_size_t size);
XBT_PRIVATE void SIMIX_io_destroy(smx_activity_t synchro);
XBT_PRIVATE void SIMIX_io_finish(smx_activity_t synchro);
smpi_process()->set_comm_intra(comm_intra);
}
- int is_uniform = 1;
-
// Are the nodes uniform ? = same number of process/node
int my_local_size=comm_intra->size();
if(comm_intra->rank()==0) {
+ int is_uniform = 1;
int* non_uniform_map = xbt_new0(int,leader_group_size);
Coll_allgather_mpich::allgather(&my_local_size, 1, MPI_INT,
non_uniform_map, 1, MPI_INT, leader_comm);
namespace simgrid {
namespace surf {
-
-class XBT_PRIVATE HostModel;
-class XBT_PRIVATE HostImpl;
class XBT_PRIVATE HostAction;
}
}
* @brief SURF Host model interface class
* @details A model is an object which handle the interactions between its Resources and its Actions
*/
-class HostModel : public Model {
+class XBT_PRIVATE HostModel : public Model {
public:
HostModel() : Model() {}
* @brief SURF Host interface class
* @details An host represents a machine with a aggregation of a Cpu, a RoutingEdge and a Storage
*/
-class HostImpl : public simgrid::surf::PropertyHolder {
+class XBT_PRIVATE HostImpl : public simgrid::surf::PropertyHolder {
public:
explicit HostImpl(s4u::Host* host);
/**********
* Action *
**********/
-StorageAction::StorageAction(Model* model, double cost, bool failed, StorageImpl* storage,
- e_surf_action_storage_type_t type)
- : Action(model, cost, failed), type_(type), storage_(storage), file_(nullptr)
-{
- progress_ = 0;
-};
-
-StorageAction::StorageAction(Model* model, double cost, bool failed, lmm_variable_t var, StorageImpl* storage,
- e_surf_action_storage_type_t type)
- : Action(model, cost, failed, var), type_(type), storage_(storage), file_(nullptr)
-{
- progress_ = 0;
-}
-
void StorageAction::setState(Action::State state)
{
Action::State old = getState();
* @param storage The Storage associated to this StorageAction
* @param type [description]
*/
- StorageAction(Model* model, double cost, bool failed, StorageImpl* storage, e_surf_action_storage_type_t type);
+ StorageAction(Model* model, double cost, bool failed, StorageImpl* storage, e_surf_action_storage_type_t type)
+ : Action(model, cost, failed), type_(type), storage_(storage){};
/**
* @brief StorageAction constructor
* @param type [description]
*/
StorageAction(Model* model, double cost, bool failed, lmm_variable_t var, StorageImpl* storage,
- e_surf_action_storage_type_t type);
+ e_surf_action_storage_type_t type)
+ : Action(model, cost, failed, var), type_(type), storage_(storage){};
void setState(simgrid::surf::Action::State state) override;
e_surf_action_storage_type_t type_;
StorageImpl* storage_;
- FileImpl* file_;
- double progress_;
+ FileImpl* file_ = nullptr;
};
}
}
void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double value)
{
int i;
- double weight;
sys->modified = 1;
lmm_check_concurrency(sys);
//We need to check that increasing value of the element does not cross the concurrency limit
if (var->sharing_weight) {
if(lmm_concurrency_slack(cnst)<lmm_element_concurrency(&var->cnsts[i])){
- weight = var->sharing_weight;
+ double weight = var->sharing_weight;
lmm_disable_var(sys,var);
for (int j = 0; j < var->cnsts_number; j++)
lmm_on_disabled_var(sys,var->cnsts[j].constraint);
StorageAction *action = static_cast<StorageAction*>(&*it);
- if (action->type_ == WRITE) {
- // Update the disk usage
- // Update the file size
- // For each action of type write
- double current_progress = delta * lmm_variable_getvalue(action->getVariable());
- long int incr = current_progress;
-
- XBT_DEBUG("%s:\n\t progress = %.2f, current_progress = %.2f, incr = %ld, lrint(1) = %ld, lrint(2) = %ld",
- action->file_->cname(), action->progress_, current_progress, incr,
- lrint(action->progress_ + current_progress), lrint(action->progress_) + incr);
-
- /* take care of rounding error accumulation */
- if (lrint(action->progress_ + current_progress) > lrint(action->progress_) + incr)
- incr++;
+ double current_progress = lrint(lmm_variable_getvalue(action->getVariable()) * delta);
- action->progress_ += current_progress;
-
- action->storage_->usedSize_ += incr; // disk usage
- action->file_->incrPosition(incr); // current_position
- // which becomes the new file size
+ action->updateRemains(current_progress);
+ if (action->type_ == WRITE) {
+ action->storage_->usedSize_ += current_progress;
+ action->file_->incrPosition(current_progress);
action->file_->setSize(action->file_->tell());
action->storage_->getContent()->erase(action->file_->cname());
action->storage_->getContent()->insert({action->file_->cname(), action->file_->size()});
}
- action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
-
if (action->getMaxDuration() > NO_MAX_DURATION)
action->updateMaxDuration(delta);
StorageN11(StorageModel* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
const char* type_id, char* content_name, sg_size_t size, char* attach);
virtual ~StorageN11() = default;
- StorageAction *open(const char* mount, const char* path);
- StorageAction *ls(const char *path);
StorageAction* read(sg_size_t size);
StorageAction* write(sg_size_t size);
- void rename(const char *src, const char *dest);
};
/**********
double surf_solve(double max_date)
{
double time_delta = -1.0; /* duration */
- double next_event_date = -1.0;
double model_next_action_end = -1.0;
double value = -1.0;
simgrid::surf::Resource *resource = nullptr;
XBT_DEBUG("Looking for next trace event");
while (1) { // Handle next occurring events until none remains
- next_event_date = future_evt_set->next_date();
+ double next_event_date = future_evt_set->next_date();
XBT_DEBUG("Next TRACE event: %f", next_event_date);
if (not surf_network_model->nextOccuringEventIsIdempotent()) { // NS3, I see you
double_update(&maxDuration_, delta, sg_surf_precision);
//FIXME: duplicated code
- if ((remains_ <= 0) &&
- (lmm_get_variable_weight(getVariable()) > 0)) {
- finish();
- setState(Action::State::done);
- heapRemove(getModel()->getActionHeap());
- } else if (((maxDuration_ != NO_MAX_DURATION)
- && (maxDuration_ <= 0))) {
+ if (((remains_ <= 0) && (lmm_get_variable_weight(getVariable()) > 0)) ||
+ ((maxDuration_ > NO_MAX_DURATION) && (maxDuration_ <= 0))) {
finish();
setState(Action::State::done);
heapRemove(getModel()->getActionHeap());
XBT_PUBLIC(double) surf_parse_get_bandwidth(const char *string, const char *entity_kind, const char *name);
XBT_PUBLIC(double) surf_parse_get_speed(const char *string, const char *entity_kind, const char *name);
-XBT_PUBLIC_DATA(int_f_void_t) surf_parse; /* Entry-point to the parser. Set this to your function. */
+XBT_PUBLIC(int) surf_parse(); /* Entry-point to the parser */
SG_END_DECL()
}
}
-/* Call the lexer to parse the currently opened file. This pointer to function enables bypassing of the parser */
-static int _surf_parse() {
+/* Call the lexer to parse the currently opened file */
+int surf_parse()
+{
return surf_parse_lex();
}
-int_f_void_t surf_parse = &_surf_parse;
-
SG_END_DECL()
xbt_test_test_t test;
xbt_test_log_t log;
- unsigned int it_test;
-
if (suite == nullptr)
return 0;
unit->func();
/* iterate through all performed tests to determine status */
+ unsigned int it_test;
xbt_dynar_foreach(unit->tests, it_test, test) {
if (test->ignored) {
unit->test_ignore++;
*/
extern "C" void xbt_dynar_remove_n_at(xbt_dynar_t const dynar, const unsigned int n, const int idx)
{
- unsigned long nb_shift;
- unsigned long offset;
-
if (not n)
return;
}
}
- nb_shift = dynar->used - n - idx;
+ unsigned long nb_shift = dynar->used - n - idx;
if (nb_shift) {
- offset = nb_shift * dynar->elmsize;
+ unsigned long offset = nb_shift * dynar->elmsize;
memmove(_xbt_dynar_elm(dynar, idx), _xbt_dynar_elm(dynar, idx + n), offset);
}
xbt_abort();
memreg.prot = 0;
-
for (i = 0; i < 3; i++){
switch(lfields[1][i]){
case 'r':
if (memreg.prot == 0)
memreg.prot |= PROT_NONE;
+ memreg.flags = 0;
if (lfields[1][3] == 'p') {
memreg.flags |= MAP_PRIVATE;
} else {
/* Return memory to the heap. */
void mfree(struct mdesc *mdp, void *ptr)
{
- int type;
- size_t block, frag_nb;
+ size_t frag_nb;
size_t i;
int it;
if (ptr == NULL)
return;
- block = BLOCK(ptr);
+ size_t block = BLOCK(ptr);
if ((char *) ptr < (char *) mdp->heapbase || block > mdp->heapsize) {
fprintf(stderr,"Ouch, this pointer is not mine, I refuse to free it. Give me valid pointers, or give me death!!\n");
abort();
}
- type = mdp->heapinfo[block].type;
+ int type = mdp->heapinfo[block].type;
switch (type) {
case MMALLOC_TYPE_HEAPINFO:
mdp -> heapstats.bytes_free +=
mdp -> heapinfo[block].busy_block.size * BLOCKSIZE;
- if(MC_is_active()){
- if(mdp->heapinfo[block].busy_block.ignore > 0)
- MC_remove_ignore_heap(ptr, mdp -> heapinfo[block].busy_block.busy_size);
- }
+ if (MC_is_active() && mdp->heapinfo[block].busy_block.ignore > 0)
+ MC_unignore_heap(ptr, mdp->heapinfo[block].busy_block.busy_size);
/* Find the free cluster previous to this one in the free list.
Start searching at the last block referenced; this may benefit
THROWF(system_error, 0, "Asked to free a fragment that is already free. I'm puzzled\n");
}
- if(MC_is_active()){
- if(mdp->heapinfo[block].busy_frag.ignore[frag_nb] > 0)
- MC_remove_ignore_heap(ptr, mdp->heapinfo[block].busy_frag.frag_size[frag_nb]);
- }
+ if (MC_is_active() && mdp->heapinfo[block].busy_frag.ignore[frag_nb] > 0)
+ MC_unignore_heap(ptr, mdp->heapinfo[block].busy_frag.frag_size[frag_nb]);
/* Set size used in the fragment to -1 */
mdp->heapinfo[block].busy_frag.frag_size[frag_nb] = -1;
unsuccessful for some reason. */
struct mdesc newmd;
- struct mdesc *mdptr = NULL, *mdptemp = NULL;
+ struct mdesc* mdptr = NULL;
+ struct mdesc* mdptemp = NULL;
if (lseek(fd, 0L, SEEK_SET) != 0)
return NULL;
}
}
- /* NULL is not a valid baseaddr as we cannot map anything there.
- C'mon, user. Think! */
+ /* NULL is not a valid baseaddr as we cannot map anything there. C'mon, user. Think! */
if (baseaddr == NULL)
return (NULL);
- /* We start off with the malloc descriptor allocated on the stack, until
- we build it up enough to call _mmalloc_mmap_morecore() to allocate the
- first page of the region and copy it there. Ensure that it is zero'd and
- then initialize the fields that we know values for. */
+ /* We start off with the malloc descriptor allocated on the stack, until we build it up enough to
+ * call _mmalloc_mmap_morecore() to allocate the first page of the region and copy it there. Ensure that it is
+ * zero'd and then initialize the fields that we know values for. */
mdp = &mtemp;
memset((char *) mdp, 0, sizeof(mtemp));
/* If we have not been passed a valid open file descriptor for the file
to map to, then open /dev/zero and use that to map to. */
- /* Now try to map in the first page, copy the malloc descriptor structure
- there, and arrange to return a pointer to this new copy. If the mapping
- fails, then close the file descriptor if it was opened by us, and arrange
- to return a NULL. */
+ /* Now try to map in the first page, copy the malloc descriptor structure there, and arrange to return a pointer to
+ * this new copy. If the mapping fails, then close the file descriptor if it was opened by us, and arrange to return
+ * a NULL. */
if ((mbase = mmorecore(mdp, sizeof(mtemp))) != NULL) {
memcpy(mbase, mdp, sizeof(mtemp));
}
}
-/** Terminate access to a mmalloc managed region by unmapping all memory pages
- associated with the region, and closing the file descriptor if it is one
- that we opened.
+/** Terminate access to a mmalloc managed region by unmapping all memory pages associated with the region, and closing
+ * the file descriptor if it is one that we opened.
Returns NULL on success.
- Returns the malloc descriptor on failure, which can subsequently be used
- for further action, such as obtaining more information about the nature of
- the failure.
+ Returns the malloc descriptor on failure, which can subsequently be used for further action, such as obtaining more
+ information about the nature of the failure.
- Note that the malloc descriptor that we are using is currently located in
- region we are about to unmap, so we first make a local copy of it on the
- stack and use the copy. */
+ Note that the malloc descriptor that we are using is currently located in region we are about to unmap, so we first
+ make a local copy of it on the stack and use the copy. */
void *xbt_mheap_destroy(xbt_mheap_t mdp)
{
- struct mdesc mtemp, *mdptemp;
-
if (mdp != NULL) {
/* Remove the heap from the linked list of heaps attached by mmalloc */
- mdptemp = __mmalloc_default_mdp;
+ struct mdesc* mdptemp = __mmalloc_default_mdp;
while(mdptemp->next_mdesc != mdp )
mdptemp = mdptemp->next_mdesc;
mdptemp->next_mdesc = mdp->next_mdesc;
xbt_mheap_destroy_no_free(mdp);
- mtemp = *mdp;
+ struct mdesc mtemp = *mdp;
/* Now unmap all the pages associated with this region by asking for a
negative increment equal to the current size of the region. */
if (mmorecore(&mtemp, (char *)mtemp.base - (char *)mtemp.breakval) == NULL) {
- /* Deallocating failed. Update the original malloc descriptor
- with any changes */
+ /* Deallocating failed. Update the original malloc descriptor with any changes */
*mdp = mtemp;
} else {
if (mtemp.flags & MMALLOC_DEVZERO) {
}
/* Safety gap from the heap's break address.
- * Try to increase this first if you experience strange errors under
- * valgrind. */
+ * Try to increase this first if you experience strange errors under valgrind. */
#define HEAP_OFFSET (128UL<<20)
xbt_mheap_t mmalloc_get_default_md(void)
/** @brief Join a set of strings as a single string */
char *xbt_str_join(xbt_dynar_t dyn, const char *sep)
{
- int len = 1, dyn_len = xbt_dynar_length(dyn);
+ int len = 1;
+ int dyn_len = xbt_dynar_length(dyn);
unsigned int cpt;
char* cursor;
#include "src/mc/mc_private.h"
-#include "src/mc/Process.hpp"
-#include "src/mc/Type.hpp"
#include "src/mc/ObjectInformation.hpp"
+#include "src/mc/Type.hpp"
#include "src/mc/Variable.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
-static simgrid::mc::Process* process;
+static simgrid::mc::RemoteClient* process;
static
uintptr_t eval_binary_operation(
}
int main(int argc, char** argv) {
- process = new simgrid::mc::Process(getpid(), -1);
+ process = new simgrid::mc::RemoteClient(getpid(), -1);
process->init();
simgrid::dwarf::ExpressionContext state;
#include "mc/datatypes.h"
#include "src/mc/mc_private.h"
-#include "src/mc/Process.hpp"
-#include "src/mc/Type.hpp"
#include "src/mc/ObjectInformation.hpp"
+#include "src/mc/Type.hpp"
#include "src/mc/Variable.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
int test_some_array[4][5][6];
struct some_struct {
xbt_assert(location.address() == address, "Bad resolution of local variable %s of %s", variable, function);
}
-static simgrid::mc::Variable* test_global_variable(
- simgrid::mc::Process& process, simgrid::mc::ObjectInformation* info,
- const char* name, void* address, long byte_size)
+static simgrid::mc::Variable* test_global_variable(simgrid::mc::RemoteClient& process,
+ simgrid::mc::ObjectInformation* info, const char* name,
+ void* address, long byte_size)
{
simgrid::mc::Variable* variable = info->find_variable(name);
xbt_assert(variable, "Global variable %s was not found", name);
typedef struct foo {int i;} s_foo;
-static void test_type_by_name(simgrid::mc::Process& process, s_foo my_foo)
+static void test_type_by_name(simgrid::mc::RemoteClient& process, s_foo my_foo)
{
assert(process.binary_info->full_types_by_name.find("struct foo") != process.binary_info->full_types_by_name.end());
}
simgrid::mc::Variable* var;
simgrid::mc::Type* type;
- simgrid::mc::Process process(getpid(), -1);
+ simgrid::mc::RemoteClient process(getpid(), -1);
process.init();
test_global_variable(process, process.binary_info.get(), "some_local_variable", &some_local_variable, sizeof(int));
# C examples
-foreach(x cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes trace_integration)
+foreach(x actions-comm actions-storage cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes
+ trace_integration)
add_executable (${x} ${x}/${x}.c)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
set(teshsuite_src ${teshsuite_src} PARENT_SCOPE)
set(tesh_files ${tesh_files} PARENT_SCOPE)
-set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1.0-hbp1.0-hbp1.0.xml
+set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/actions-comm.txt
+ ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/actions-comm_split_p0.txt
+ ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/actions-comm_split_p1.txt
+ ${CMAKE_CURRENT_SOURCE_DIR}/actions-storage/actions-storage.txt PARENT_SCOPE)
+set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/actions-comm_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/actions-comm_split_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/actions-storage/actions-storage_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1.0-hbp1.0-hbp1.0.xml
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1.0-hbp3.0-hbp4.0.xml
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1.5-hbp1.5.xml
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1-c0s0-c0s1.xml
ADD_TESH_FACTORIES(tesh-msg-${x} "thread;boost;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x} --cd ${CMAKE_BINARY_DIR}/teshsuite/msg/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}/${x}.tesh)
endforeach()
-
+foreach(x actions-comm actions-storage)
+ ADD_TESH_FACTORIES(tesh-msg-${x} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/msg/${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x} ${x}.tesh)
+endforeach()
# One context factory is enough for these ones
foreach(x cloud-sharing)
XBT_LOG_NEW_DEFAULT_CATEGORY(actions, "Messages specific for this msg example");
int communicator_size = 0;
-static void action_Isend(const char *const *action);
+static void action_Isend(const char* const* action);
typedef struct {
int last_Irecv_sender_id;
int bcast_counter;
- xbt_dynar_t isends; /* of msg_comm_t */
+ xbt_dynar_t isends; /* of msg_comm_t */
/* Used to implement irecv+wait */
- xbt_dynar_t irecvs; /* of msg_comm_t */
- xbt_dynar_t tasks; /* of msg_task_t */
+ xbt_dynar_t irecvs; /* of msg_comm_t */
+ xbt_dynar_t tasks; /* of msg_task_t */
} s_process_globals_t;
-typedef s_process_globals_t *process_globals_t;
+typedef s_process_globals_t* process_globals_t;
/* Helper function */
-static double parse_double(const char *string)
+static double parse_double(const char* string)
{
double value;
- char *endptr;
+ char* endptr;
value = strtod(string, &endptr);
if (*endptr != '\0')
return value;
}
-#define ACT_DEBUG(...) \
- if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose)) { \
- char *NAME = xbt_str_join_array(action, " "); \
- XBT_DEBUG(__VA_ARGS__); \
- xbt_free(NAME); \
- } else ((void)0)
+#define ACT_DEBUG(...) \
+ if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose)) { \
+ char* NAME = xbt_str_join_array(action, " "); \
+ XBT_DEBUG(__VA_ARGS__); \
+ xbt_free(NAME); \
+ } else \
+ ((void)0)
-static void log_action(const char *const *action, double date)
+static void log_action(const char* const* action, double date)
{
if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose)) {
- char *name = xbt_str_join_array(action, " ");
+ char* name = xbt_str_join_array(action, " ");
XBT_VERB("%s %f", name, date);
xbt_free(name);
}
static void asynchronous_cleanup(void)
{
- process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self());
+ process_globals_t globals = (process_globals_t)MSG_process_get_data(MSG_process_self());
/* Destroy any isend which correspond to completed communications */
msg_comm_t comm;
- while (1/*true*/) {
+ while (1 /*true*/) {
int pos_found = MSG_comm_testany(globals->isends);
if (pos_found == -1) /* none remaining */
break;
}
/* My actions */
-static void action_send(const char *const *action)
+static void action_send(const char* const* action)
{
char to[250];
- const char *size_str = action[3];
- double size = parse_double(size_str);
- double clock = MSG_get_clock();
+ const char* size_str = action[3];
+ double size = parse_double(size_str);
+ double clock = MSG_get_clock();
- snprintf(to,249, "%s_%s", MSG_process_get_name(MSG_process_self()), action[2]);
+ snprintf(to, 249, "%s_%s", MSG_process_get_name(MSG_process_self()), action[2]);
ACT_DEBUG("Entering Send: %s (size: %g)", NAME, size);
if (size < 65536) {
asynchronous_cleanup();
}
-static void action_Isend(const char *const *action)
+static void action_Isend(const char* const* action)
{
char to[250];
- const char *size = action[3];
- double clock = MSG_get_clock();
- process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self());
+ const char* size = action[3];
+ double clock = MSG_get_clock();
+ process_globals_t globals = (process_globals_t)MSG_process_get_data(MSG_process_self());
- snprintf(to,249, "%s_%s", MSG_process_get_name(MSG_process_self()), action[2]);
+ snprintf(to, 249, "%s_%s", MSG_process_get_name(MSG_process_self()), action[2]);
msg_comm_t comm = MSG_task_isend(MSG_task_create(to, 0, parse_double(size), NULL), to);
xbt_dynar_push(globals->isends, &comm);
asynchronous_cleanup();
}
-static void action_recv(const char *const *action)
+static void action_recv(const char* const* action)
{
char mailbox_name[250];
msg_task_t task = NULL;
- double clock = MSG_get_clock();
+ double clock = MSG_get_clock();
- snprintf(mailbox_name,249, "%s_%s", action[2], MSG_process_get_name(MSG_process_self()));
+ snprintf(mailbox_name, 249, "%s_%s", action[2], MSG_process_get_name(MSG_process_self()));
ACT_DEBUG("Receiving: %s", NAME);
msg_error_t res = MSG_task_receive(&task, mailbox_name);
asynchronous_cleanup();
}
-static void action_Irecv(const char *const *action)
+static void action_Irecv(const char* const* action)
{
char mailbox[250];
- double clock = MSG_get_clock();
- process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self());
+ double clock = MSG_get_clock();
+ process_globals_t globals = (process_globals_t)MSG_process_get_data(MSG_process_self());
XBT_DEBUG("Irecv on %s", MSG_process_get_name(MSG_process_self()));
- snprintf(mailbox,249, "%s_%s", action[2], MSG_process_get_name(MSG_process_self()));
+ snprintf(mailbox, 249, "%s_%s", action[2], MSG_process_get_name(MSG_process_self()));
msg_task_t t = NULL;
xbt_dynar_push(globals->tasks, &t);
msg_comm_t c = MSG_task_irecv(xbt_dynar_get_ptr(globals->tasks, xbt_dynar_length(globals->tasks) - 1), mailbox);
asynchronous_cleanup();
}
-static void action_wait(const char *const *action)
+static void action_wait(const char* const* action)
{
msg_task_t task = NULL;
msg_comm_t comm;
- double clock = MSG_get_clock();
- process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self());
+ double clock = MSG_get_clock();
+ process_globals_t globals = (process_globals_t)MSG_process_get_data(MSG_process_self());
xbt_assert(xbt_dynar_length(globals->irecvs), "action wait not preceded by any irecv: %s",
xbt_str_join_array(action, " "));
}
/* FIXME: that's a poor man's implementation: we should take the message exchanges into account */
-static void action_barrier(const char *const *action)
+static void action_barrier(const char* const* action)
{
static msg_bar_t barrier = NULL;
static int processes_arrived_sofar = 0;
ACT_DEBUG("Exiting barrier: %s", NAME);
processes_arrived_sofar--;
- if (processes_arrived_sofar<=0) {
+ if (processes_arrived_sofar <= 0) {
MSG_barrier_destroy(barrier);
barrier = NULL;
}
}
-static void action_bcast(const char *const *action)
+static void action_bcast(const char* const* action)
{
char mailbox[80];
double comm_size = parse_double(action[2]);
- msg_task_t task = NULL;
- double clock = MSG_get_clock();
+ msg_task_t task = NULL;
+ double clock = MSG_get_clock();
- process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self());
+ process_globals_t counters = (process_globals_t)MSG_process_get_data(MSG_process_self());
xbt_assert(communicator_size, "Size of Communicator is not defined, can't use collective operations");
- const char * process_name = MSG_process_get_name(MSG_process_self());
+ const char* process_name = MSG_process_get_name(MSG_process_self());
- char *bcast_identifier = bprintf("bcast_%d", counters->bcast_counter);
+ char* bcast_identifier = bprintf("bcast_%d", counters->bcast_counter);
counters->bcast_counter++;
if (!strcmp(process_name, "p0")) {
XBT_DEBUG("%s: %s is the Root", bcast_identifier, process_name);
- msg_comm_t *comms = xbt_new0(msg_comm_t, communicator_size - 1);
+ msg_comm_t* comms = xbt_new0(msg_comm_t, communicator_size - 1);
for (int i = 1; i < communicator_size; i++) {
- snprintf(mailbox,79, "%s_p0_p%d", bcast_identifier, i);
+ snprintf(mailbox, 79, "%s_p0_p%d", bcast_identifier, i);
comms[i - 1] = MSG_task_isend(MSG_task_create(mailbox, 0, comm_size, NULL), mailbox);
}
MSG_comm_waitall(comms, communicator_size - 1, -1);
XBT_DEBUG("%s: all messages sent by %s have been received", bcast_identifier, process_name);
} else {
- snprintf(mailbox,79, "%s_p0_%s", bcast_identifier, process_name);
+ snprintf(mailbox, 79, "%s_p0_%s", bcast_identifier, process_name);
MSG_task_receive(&task, mailbox);
MSG_task_destroy(task);
XBT_DEBUG("%s: %s has received", bcast_identifier, process_name);
xbt_free(bcast_identifier);
}
-static void action_comm_size(const char *const *action)
+static void action_comm_size(const char* const* action)
{
- const char *size = action[2];
- double clock = MSG_get_clock();
+ const char* size = action[2];
+ double clock = MSG_get_clock();
communicator_size = parse_double(size);
log_action(action, MSG_get_clock() - clock);
}
-static void action_compute(const char *const *action)
+static void action_compute(const char* const* action)
{
- const char *amount = action[2];
- msg_task_t task = MSG_task_create("task", parse_double(amount), 0, NULL);
- double clock = MSG_get_clock();
+ const char* amount = action[2];
+ msg_task_t task = MSG_task_create("task", parse_double(amount), 0, NULL);
+ double clock = MSG_get_clock();
ACT_DEBUG("Entering %s", NAME);
MSG_task_execute(task);
log_action(action, MSG_get_clock() - clock);
}
-static void action_init(const char *const *action)
+static void action_init(const char* const* action)
{
XBT_DEBUG("Initialize the counters");
- process_globals_t globals = (process_globals_t) calloc(1, sizeof(s_process_globals_t));
- globals->isends = xbt_dynar_new(sizeof(msg_comm_t), NULL);
- globals->irecvs = xbt_dynar_new(sizeof(msg_comm_t), NULL);
- globals->tasks = xbt_dynar_new(sizeof(msg_task_t), NULL);
+ process_globals_t globals = (process_globals_t)calloc(1, sizeof(s_process_globals_t));
+ globals->isends = xbt_dynar_new(sizeof(msg_comm_t), NULL);
+ globals->irecvs = xbt_dynar_new(sizeof(msg_comm_t), NULL);
+ globals->tasks = xbt_dynar_new(sizeof(msg_task_t), NULL);
MSG_process_set_data(MSG_process_self(), globals);
}
-static void action_finalize(const char *const *action)
+static void action_finalize(const char* const* action)
{
- process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self());
+ process_globals_t globals = (process_globals_t)MSG_process_get_data(MSG_process_self());
if (globals) {
asynchronous_cleanup();
xbt_dynar_free_container(&(globals->isends));
}
}
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
/* Check the given arguments */
MSG_init(&argc, argv);
/* Explicit initialization of the action module is required now*/
MSG_action_init();
- xbt_assert(argc > 2,
- "Usage: %s platform_file deployment_file [action_files]\n"
- "\t# if all actions are in the same file\n"
- "\tExample: %s msg_platform.xml msg_deployment.xml actions\n"
- "\t# if actions are in separate files, specified in deployment\n"
- "\tExample: %s msg_platform.xml msg_deployment.xml ",
- argv[0],argv[0],argv[0]);
+ xbt_assert(argc > 2, "Usage: %s platform_file deployment_file [action_files]\n"
+ "\t# if all actions are in the same file\n"
+ "\tExample: %s msg_platform.xml msg_deployment.xml actions\n"
+ "\t# if actions are in separate files, specified in deployment\n"
+ "\tExample: %s msg_platform.xml msg_deployment.xml ",
+ argv[0], argv[0], argv[0]);
MSG_create_environment(argv[1]);
MSG_launch_application(argv[2]);
static xbt_dict_t opened_files = NULL;
-#define ACT_DEBUG(...) \
- if (XBT_LOG_ISENABLED(storage_actions, xbt_log_priority_verbose)) { \
- char *NAME = xbt_str_join_array(action, " "); \
- XBT_DEBUG(__VA_ARGS__); \
- xbt_free(NAME); \
- } else ((void)0)
-
-static void log_action(const char *const *action, double date)
+#define ACT_DEBUG(...) \
+ if (XBT_LOG_ISENABLED(storage_actions, xbt_log_priority_verbose)) { \
+ char* NAME = xbt_str_join_array(action, " "); \
+ XBT_DEBUG(__VA_ARGS__); \
+ xbt_free(NAME); \
+ } else \
+ ((void)0)
+
+static void log_action(const char* const* action, double date)
{
if (XBT_LOG_ISENABLED(storage_actions, xbt_log_priority_verbose)) {
- char *name = xbt_str_join_array(action, " ");
+ char* name = xbt_str_join_array(action, " ");
XBT_VERB("%s %f", name, date);
xbt_free(name);
}
}
-static msg_file_t get_file_descriptor(const char *file_name){
+static msg_file_t get_file_descriptor(const char* file_name)
+{
char full_name[1024];
- snprintf(full_name,1023, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name);
+ snprintf(full_name, 1023, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name);
msg_file_t file = (msg_file_t)xbt_dict_get_or_null(opened_files, full_name);
return file;
}
-static sg_size_t parse_size(const char *string){
+static sg_size_t parse_size(const char* string)
+{
sg_size_t size;
- char *endptr;
+ char* endptr;
size = strtoul(string, &endptr, 10);
if (*endptr != '\0')
return size;
}
-static void action_open(const char *const *action) {
- const char *file_name = action[2];
+static void action_open(const char* const* action)
+{
+ const char* file_name = action[2];
char full_name[1024];
msg_file_t file = NULL;
- double clock = MSG_get_clock();
+ double clock = MSG_get_clock();
- snprintf(full_name,1023, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name);
+ snprintf(full_name, 1023, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name);
ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name);
file = MSG_file_open(file_name, NULL);
log_action(action, MSG_get_clock() - clock);
}
-static void action_read(const char *const *action) {
- const char *file_name = action[2];
- const char *size_str = action[3];
- sg_size_t size = parse_size(size_str);
+static void action_read(const char* const* action)
+{
+ const char* file_name = action[2];
+ const char* size_str = action[3];
+ sg_size_t size = parse_size(size_str);
double clock = MSG_get_clock();
log_action(action, MSG_get_clock() - clock);
}
-static void action_close(const char *const *action) {
- const char *file_name = action[2];
+static void action_close(const char* const* action)
+{
+ const char* file_name = action[2];
msg_file_t file;
double clock = MSG_get_clock();
log_action(action, MSG_get_clock() - clock);
}
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[])
+{
MSG_init(&argc, argv);
/* Explicit initialization of the action module is required */
MSG_action_init();
- xbt_assert(argc > 3,"Usage: %s platform_file deployment_file [action_files]\n"
+ xbt_assert(argc > 3,
+ "Usage: %s platform_file deployment_file [action_files]\n"
"\texample: %s platform.xml deployment.xml actions # if all actions are in the same file\n"
"\texample: %s platform.xml deployment.xml # if actions are in separate files, specified in deployment\n",
argv[0], argv[0], argv[0]);
/* Explicit finalization of the action module is required now*/
MSG_action_exit();
- return res!=MSG_OK;
+ return res != MSG_OK;
}
/* 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 "xbt/sysdep.h"
+#include "simgrid/msg.h"
+#include "src/surf/surf_interface.hpp"
#include "surf/maxmin.h"
#include "xbt/log.h"
#include "xbt/module.h"
+#include "xbt/sysdep.h"
#include <math.h>
-#include "src/surf/surf_interface.hpp"
XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
xbt_free(A);
}
-int main()
+int main(int argc, char** argv)
{
+ MSG_init(&argc, argv);
XBT_INFO("***** Test 1 (Max-Min)");
test1(MAXMIN);
XBT_INFO("***** Test 1 (Lagrange - Vegas)");
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "surf/maxmin.h"
+#include "simgrid/msg.h"
#include "xbt/module.h"
+#include "xbt/sysdep.h" /* time manipulation for benchmarking */
#include "xbt/xbt_os_time.h"
-#include "xbt/sysdep.h" /* time manipulation for benchmarking */
#define MYRANDMAX 1000
int main(int argc, char **argv)
{
+ MSG_init(&argc, argv);
+
float rate_no_limit=0.2;
float acc_date=0;
float acc_date2=0;
int main(int argc, char **argv)
{
- double now = -1.0;
int running;
surf_init(&argc, argv); /* Initialize some common structures */
surf_action_t action = nullptr;
running = 0;
- now = surf_get_clock();
+ double now = surf_get_clock();
XBT_INFO("Next Event : %g", now);
for (auto model: *all_existing_models) {
#include <math.h>
#include <xbt/xbt_os_time.h>
+#include "simgrid/msg.h"
#include "xbt/heap.h"
#include "xbt/sysdep.h"
xbt_heap_free(heap);
}
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
- int size;
- for (size = 100; size < 10000; size *= 10) {
+ MSG_init(&argc, argv);
+
+ for (int size = 100; size < 10000; size *= 10) {
test_heap_validity(size);
test_heap_mean_operation(size);
}
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt.h"
+#include <simgrid/msg.h>
XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logs of this example");
int main(int argc, char *argv[])
{
+ MSG_init(&argc, argv);
char *tmp = bprintf("\n%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s",
1, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n",
2, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n",
9, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n",
0, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n");
- xbt_init(&argc, argv);
-
XBT_INFO("This is a very large message:\n0%s1%s2%s3%s4%s5%s6%s7%s8%s9%s",
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp);
XBT_INFO("Done (strlen>%d)", (int) (10 * strlen(tmp)));
src/mc/remote/Channel.hpp
src/mc/remote/Client.cpp
src/mc/remote/Client.hpp
+ src/mc/remote/RemoteClient.hpp
+ src/mc/remote/RemoteClient.cpp
src/mc/remote/RemotePtr.hpp
src/mc/remote/mc_protocol.h
src/mc/remote/mc_protocol.cpp
src/mc/Type.hpp
src/mc/Variable.hpp
src/mc/mc_forward.hpp
- src/mc/Process.hpp
- src/mc/Process.cpp
src/mc/Session.cpp
src/mc/Session.hpp
src/mc/mc_unw.h
src/mc/mc_snapshot.h
src/mc/mc_snapshot.cpp
src/mc/mc_page_snapshot.cpp
- src/mc/mc_comm_pattern.h
src/mc/mc_comm_pattern.cpp
+ src/mc/mc_comm_pattern.hpp
src/mc/compare.cpp
src/mc/mc_dwarf.hpp
src/mc/mc_dwarf.cpp