* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/kernel/activity/MailboxImpl.hpp"
-#include "src/mc/Session.hpp"
-#include "src/mc/explo/SafetyChecker.hpp"
+#include "src/mc/explo/DFSExplorer.hpp"
#include "src/mc/mc_config.hpp"
#include "src/mc/mc_exit.hpp"
#include "src/mc/mc_forward.hpp"
#include <cstdint>
-using api = simgrid::mc::Api;
-
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_comm_determinism, mc, "Logging specific to MC communication determinism detection");
namespace simgrid {
void exploration_start()
{
- const unsigned long maxpid = api::get().get_maxpid();
+ const unsigned long maxpid = Api::get().get_maxpid();
initial_communications_pattern.resize(maxpid);
incomplete_communications_pattern.resize(maxpid);
/********** State Extension ***********/
class StateCommDet {
- CommDetExtension* checker_;
-
public:
std::vector<std::vector<simgrid::mc::PatternCommunication>> incomplete_comm_pattern_;
std::vector<unsigned> communication_indices_;
static simgrid::xbt::Extension<simgrid::mc::State, StateCommDet> EXTENSION_ID;
- explicit StateCommDet(CommDetExtension* checker) : checker_(checker)
+ explicit StateCommDet(CommDetExtension* checker)
{
- const unsigned long maxpid = api::get().get_maxpid();
+ const unsigned long maxpid = Api::get().get_maxpid();
for (unsigned long i = 0; i < maxpid; i++) {
std::vector<simgrid::mc::PatternCommunication> res;
- for (auto const& comm : checker_->incomplete_communications_pattern[i])
+ for (auto const& comm : checker->incomplete_communications_pattern[i])
res.push_back(comm->dup());
incomplete_comm_pattern_.push_back(std::move(res));
}
- for (auto const& list_process_comm : checker_->initial_communications_pattern)
+ for (auto const& list_process_comm : checker->initial_communications_pattern)
this->communication_indices_.push_back(list_process_comm.index_comm);
}
};
initial_communications_pattern[i].index_comm =
state->extension<simgrid::mc::StateCommDet>()->communication_indices_[i];
- const unsigned long maxpid = api::get().get_maxpid();
+ const unsigned long maxpid = Api::get().get_maxpid();
for (unsigned long i = 0; i < maxpid; i++) {
incomplete_communications_pattern[i].clear();
for (simgrid::mc::PatternCommunication const& comm :
XBT_INFO("***** Non-send-deterministic communications pattern *****");
XBT_INFO("*********************************************************");
XBT_INFO("%s", send_diff.c_str());
- session_singleton->log_state();
- api::get().mc_exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
+ Api::get().get_session().log_state();
+ Api::get().mc_exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
} else if (_sg_mc_comms_determinism && (not send_deterministic && not recv_deterministic)) {
XBT_INFO("****************************************************");
XBT_INFO("***** Non-deterministic communications pattern *****");
XBT_INFO("%s", send_diff.c_str());
if (not recv_diff.empty())
XBT_INFO("%s", recv_diff.c_str());
- session_singleton->log_state();
- api::get().mc_exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
+ Api::get().get_session().log_state();
+ Api::get().mc_exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
}
}
}
switch (transition->type_) {
case Transition::Type::COMM_SEND:
- get_comm_pattern(transition);
- break;
case Transition::Type::COMM_RECV:
get_comm_pattern(transition);
break;
auto extension = new CommDetExtension();
- SafetyChecker::on_exploration_start([extension]() {
+ DFSExplorer::on_exploration_start([extension]() {
XBT_INFO("Check communication determinism");
extension->exploration_start();
});
- SafetyChecker::on_backtracking([extension]() { extension->initial_communications_pattern_done = true; });
- SafetyChecker::on_state_creation([extension](State* state) { state->extension_set(new StateCommDet(extension)); });
+ DFSExplorer::on_backtracking([extension]() { extension->initial_communications_pattern_done = true; });
+ DFSExplorer::on_state_creation([extension](State* state) { state->extension_set(new StateCommDet(extension)); });
- SafetyChecker::on_restore_system_state(
- [extension](State* state) { extension->restore_communications_pattern(state); });
+ DFSExplorer::on_restore_system_state([extension](State* state) { extension->restore_communications_pattern(state); });
- SafetyChecker::on_restore_initial_state([extension]() {
- const unsigned long maxpid = api::get().get_maxpid();
+ DFSExplorer::on_restore_initial_state([extension]() {
+ const unsigned long maxpid = Api::get().get_maxpid();
assert(maxpid == extension->incomplete_communications_pattern.size());
assert(maxpid == extension->initial_communications_pattern.size());
for (unsigned long j = 0; j < maxpid; j++) {
}
});
- SafetyChecker::on_transition_replay([extension](Transition* t) { extension->handle_comm_pattern(t); });
- SafetyChecker::on_transition_execute([extension](Transition* t) { extension->handle_comm_pattern(t); });
+ DFSExplorer::on_transition_replay([extension](Transition* t) { extension->handle_comm_pattern(t); });
+ DFSExplorer::on_transition_execute([extension](Transition* t) { extension->handle_comm_pattern(t); });
- SafetyChecker::on_log_state([extension]() {
+ DFSExplorer::on_log_state([extension]() {
if (_sg_mc_comms_determinism) {
if (extension->send_deterministic && not extension->recv_deterministic) {
XBT_INFO("*******************************************************");
delete extension;
});
- return new SafetyChecker(session);
+ return new DFSExplorer(session);
}
} // namespace mc