simgrid::mc::Exploration* explo;
switch (algo) {
case ExplorationAlgorithm::CommDeterminism:
- explo = simgrid::mc::create_communication_determinism_checker(remote_app_.get());
+ explo = simgrid::mc::create_communication_determinism_checker(*(remote_app_.get()));
break;
case ExplorationAlgorithm::UDPOR:
- explo = simgrid::mc::create_udpor_checker(remote_app_.get());
+ explo = simgrid::mc::create_udpor_checker(*(remote_app_.get()));
break;
case ExplorationAlgorithm::Safety:
- explo = simgrid::mc::create_dfs_exploration(remote_app_.get());
+ explo = simgrid::mc::create_dfs_exploration(*(remote_app_.get()));
break;
case ExplorationAlgorithm::Liveness:
- explo = simgrid::mc::create_liveness_checker(remote_app_.get());
+ explo = simgrid::mc::create_liveness_checker(*(remote_app_.get()));
break;
default:
return explo;
}
-unsigned long Api::get_maxpid() const
-{
- return mc_model_checker->get_remote_process().get_maxpid();
-}
std::size_t Api::get_remote_heap_bytes() const
{
simgrid::mc::Exploration* initialize(char** argv, const std::unordered_map<std::string, std::string>& env,
simgrid::mc::ExplorationAlgorithm algo);
- // ACTOR APIs
- unsigned long get_maxpid() const;
-
// REMOTE APIs
std::size_t get_remote_heap_bytes() const;
}
}
+unsigned long RemoteApp::get_maxpid() const
+{
+ return model_checker_->get_remote_process().get_maxpid();
+}
+
void RemoteApp::get_actors_status(std::map<aid_t, ActorState>& whereto)
{
s_mc_message_t msg;
void log_state() const;
+ /** Retrieve the max PID of the running actors */
+ unsigned long get_maxpid() const;
+
+ /* Get the list of actors that are ready to run at that step. Usually shorter than maxpid */
void get_actors_status(std::map<aid_t, ActorState>& whereto);
};
} // namespace simgrid::mc
std::string send_diff;
std::string recv_diff;
- void exploration_start()
+ void exploration_start(RemoteApp& remote_app)
{
- const unsigned long maxpid = Api::get().get_maxpid();
+ const unsigned long maxpid = remote_app.get_maxpid();
initial_communications_pattern.resize(maxpid);
incomplete_communications_pattern.resize(maxpid);
}
- void restore_communications_pattern(const simgrid::mc::State* state);
+ void restore_communications_pattern(const simgrid::mc::State* state, RemoteApp& remote_app);
void enforce_deterministic_pattern(aid_t process, const PatternCommunication* comm);
void get_comm_pattern(const Transition* transition);
void complete_comm_pattern(const CommWaitTransition* transition);
std::vector<unsigned> communication_indices_;
static simgrid::xbt::Extension<simgrid::mc::State, StateCommDet> EXTENSION_ID;
- explicit StateCommDet(CommDetExtension* checker)
+ explicit StateCommDet(CommDetExtension& checker, RemoteApp& remote_app)
{
- const unsigned long maxpid = Api::get().get_maxpid();
+ const unsigned long maxpid = remote_app.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);
}
};
return CommPatternDifference::NONE;
}
-void CommDetExtension::restore_communications_pattern(const simgrid::mc::State* state)
+void CommDetExtension::restore_communications_pattern(const simgrid::mc::State* state, RemoteApp& remote_app)
{
for (size_t i = 0; i < initial_communications_pattern.size(); i++)
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 = remote_app.get_maxpid();
for (unsigned long i = 0; i < maxpid; i++) {
incomplete_communications_pattern[i].clear();
for (simgrid::mc::PatternCommunication const& comm :
}
*/
-Exploration* create_communication_determinism_checker(RemoteApp* remote_app)
+Exploration* create_communication_determinism_checker(RemoteApp& remote_app)
{
CommDetExtension::EXTENSION_ID = simgrid::mc::Exploration::extension_create<CommDetExtension>();
StateCommDet::EXTENSION_ID = simgrid::mc::State::extension_create<StateCommDet>();
auto extension = new CommDetExtension();
- DFSExplorer::on_exploration_start([extension]() {
+ DFSExplorer::on_exploration_start([extension, &remote_app]() {
XBT_INFO("Check communication determinism");
- extension->exploration_start();
+ extension->exploration_start(remote_app);
});
DFSExplorer::on_backtracking([extension]() { extension->initial_communications_pattern_done = true; });
- DFSExplorer::on_state_creation([extension](State* state) { state->extension_set(new StateCommDet(extension)); });
+ DFSExplorer::on_state_creation(
+ [extension, &remote_app](State* state) { state->extension_set(new StateCommDet(*extension, remote_app)); });
- DFSExplorer::on_restore_system_state([extension](State* state) { extension->restore_communications_pattern(state); });
+ DFSExplorer::on_restore_system_state(
+ [extension, &remote_app](State* state) { extension->restore_communications_pattern(state, remote_app); });
- DFSExplorer::on_restore_initial_state([extension]() {
- const unsigned long maxpid = Api::get().get_maxpid();
+ DFSExplorer::on_restore_initial_state([extension, &remote_app]() {
+ const unsigned long maxpid = remote_app.get_maxpid();
assert(maxpid == extension->incomplete_communications_pattern.size());
assert(maxpid == extension->initial_communications_pattern.size());
for (unsigned long j = 0; j < maxpid; j++) {
}
}
-DFSExplorer::DFSExplorer(RemoteApp* remote_app) : Exploration(remote_app)
+DFSExplorer::DFSExplorer(RemoteApp& remote_app) : Exploration(remote_app)
{
reductionMode_ = reduction_mode;
if (_sg_mc_termination)
stack_.push_back(std::move(initial_state));
}
-Exploration* create_dfs_exploration(RemoteApp* remote_app)
+Exploration* create_dfs_exploration(RemoteApp& remote_app)
{
return new DFSExplorer(remote_app);
}
static xbt::signal<void()> on_log_state_signal;
public:
- explicit DFSExplorer(RemoteApp* remote_app);
+ explicit DFSExplorer(RemoteApp& remote_app);
void run() override;
RecordTrace get_record_trace() override;
std::vector<std::string> get_textual_trace() override;
* `RemoteApp` interface (that is currently not perfectly sufficient to that extend). */
// abstract
class Exploration : public xbt::Extendable<Exploration> {
- RemoteApp* remote_app_;
+ RemoteApp& remote_app_;
public:
- explicit Exploration(RemoteApp* remote_app) : remote_app_(remote_app) {}
+ explicit Exploration(RemoteApp& remote_app) : remote_app_(remote_app) {}
// No copy:
Exploration(Exploration const&) = delete;
/** Log additional information about the state of the model-checker */
virtual void log_state() = 0;
- RemoteApp& get_remote_app() { return *remote_app_; }
+ RemoteApp& get_remote_app() { return remote_app_; }
};
// External constructors so that the types (and the types of their content) remain hidden
-XBT_PUBLIC Exploration* create_liveness_checker(RemoteApp* remote_app);
-XBT_PUBLIC Exploration* create_dfs_exploration(RemoteApp* remote_app);
-XBT_PUBLIC Exploration* create_communication_determinism_checker(RemoteApp* remote_app);
-XBT_PUBLIC Exploration* create_udpor_checker(RemoteApp* remote_app);
+XBT_PUBLIC Exploration* create_liveness_checker(RemoteApp& remote_app);
+XBT_PUBLIC Exploration* create_dfs_exploration(RemoteApp& remote_app);
+XBT_PUBLIC Exploration* create_communication_determinism_checker(RemoteApp& remote_app);
+XBT_PUBLIC Exploration* create_udpor_checker(RemoteApp& remote_app);
} // namespace simgrid::mc
}
}
-LivenessChecker::LivenessChecker(RemoteApp* remote_app) : Exploration(remote_app) {}
+LivenessChecker::LivenessChecker(RemoteApp& remote_app) : Exploration(remote_app) {}
RecordTrace LivenessChecker::get_record_trace() // override
{
log_state();
}
-Exploration* create_liveness_checker(RemoteApp* remote_app)
+Exploration* create_liveness_checker(RemoteApp& remote_app)
{
return new LivenessChecker(remote_app);
}
class XBT_PRIVATE LivenessChecker : public Exploration {
public:
- explicit LivenessChecker(RemoteApp* remote_app);
+ explicit LivenessChecker(RemoteApp& remote_app);
void run() override;
RecordTrace get_record_trace() override;
std::vector<std::string> get_textual_trace() override;
namespace simgrid::mc {
-UdporChecker::UdporChecker(RemoteApp* remote_app) : Exploration(remote_app) {}
+UdporChecker::UdporChecker(RemoteApp& remote_app) : Exploration(remote_app) {}
void UdporChecker::run() {}
void UdporChecker::log_state() {}
-Exploration* create_udpor_checker(RemoteApp* remote_app)
+Exploration* create_udpor_checker(RemoteApp& remote_app)
{
return new UdporChecker(remote_app);
}
class XBT_PRIVATE UdporChecker : public Exploration {
public:
- explicit UdporChecker(RemoteApp* remote_app);
+ explicit UdporChecker(RemoteApp& remote_app);
void run() override;
RecordTrace get_record_trace() override;
std::vector<std::string> get_textual_trace() override;