X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5afd75483d80ccf2c678e50f82613b3556c7ca97..196b543c8e909828b40e851eaf4443ee28f76c70:/src/mc/api.hpp diff --git a/src/mc/api.hpp b/src/mc/api.hpp index 23b9043a15..88b2e0c802 100644 --- a/src/mc/api.hpp +++ b/src/mc/api.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2020-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2020-2022. 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. */ @@ -10,28 +10,16 @@ #include #include "simgrid/forward.h" +#include "src/mc/Session.hpp" +#include "src/mc/api/State.hpp" #include "src/mc/mc_forward.hpp" #include "src/mc/mc_record.hpp" -#include "src/mc/mc_state.hpp" #include "xbt/automaton.hpp" #include "xbt/base.h" -namespace simgrid { -namespace mc { +namespace simgrid::mc { -XBT_DECLARE_ENUM_CLASS(CheckerAlgorithm, Safety, UDPOR, Liveness, CommDeterminism); - -/** - * @brief Maintains the transition's information. - */ -struct s_transition_detail { - simgrid::simix::Simcall call_ = simgrid::simix::Simcall::NONE; - long issuer_id = -1; - RemotePtr mbox_remote_addr {}; // used to represent mailbox remote address for isend and ireceive transitions - RemotePtr comm_remote_addr {}; // the communication this transition concerns (to be used only for isend, ireceive, wait and test) -}; - -using transition_detail_t = std::unique_ptr; +XBT_DECLARE_ENUM_CLASS(ExplorationAlgorithm, Safety, UDPOR, Liveness, CommDeterminism); /* ** This class aimes to implement FACADE APIs for simgrid. The FACADE layer sits between the CheckerSide @@ -52,11 +40,7 @@ private: } }; - simgrid::kernel::activity::CommImpl* get_comm_or_nullptr(smx_simcall_t const r) const; - bool request_depend_asymmetric(smx_simcall_t r1, smx_simcall_t r2) const; - simgrid::mc::ActorInformation* actor_info_cast(smx_actor_t actor) const; - std::string get_actor_string(smx_actor_t actor) const; - std::string get_actor_dot_label(smx_actor_t actor) const; + std::unique_ptr session_; public: // No copy: @@ -69,77 +53,33 @@ public: return api; } - simgrid::mc::Checker* initialize(char** argv, simgrid::mc::CheckerAlgorithm algo) const; + simgrid::mc::Exploration* initialize(char** argv, simgrid::mc::ExplorationAlgorithm algo); // ACTOR APIs std::vector& get_actors() const; unsigned long get_maxpid() const; - int get_actors_size() const; - - // COMMUNICATION APIs - RemotePtr get_comm_isend_raw_addr(smx_simcall_t request) const; - RemotePtr get_comm_waitany_raw_addr(smx_simcall_t request, int value) const; - std::string get_pattern_comm_rdv(RemotePtr const& addr) const; - unsigned long get_pattern_comm_src_proc(RemotePtr const& addr) const; - unsigned long get_pattern_comm_dst_proc(RemotePtr const& addr) const; - std::vector get_pattern_comm_data(RemotePtr const& addr) const; - xbt::string const& get_actor_name(smx_actor_t actor) const; - xbt::string const& get_actor_host_name(smx_actor_t actor) const; -#if HAVE_SMPI - bool check_send_request_detached(smx_simcall_t const& simcall) const; -#endif - smx_actor_t get_src_actor(RemotePtr const& comm_addr) const; - smx_actor_t get_dst_actor(RemotePtr const& comm_addr) const; // REMOTE APIs std::size_t get_remote_heap_bytes() const; // MODEL CHECKER APIs void mc_inc_visited_states() const; - void mc_inc_executed_trans() const; unsigned long mc_get_visited_states() const; - unsigned long mc_get_executed_trans() const; - void mc_check_deadlock() const; - bool mc_is_null() const; - Checker* mc_get_checker() const; - void handle_simcall(Transition const& transition) const; - void mc_wait_for_requests() const; XBT_ATTRIB_NORETURN void mc_exit(int status) const; - void dump_record_path() const; - smx_simcall_t mc_state_choose_request(simgrid::mc::State* state) const; - - // UDPOR APIs - std::list get_enabled_transitions(simgrid::mc::State* state) const; - - // SIMCALL APIs - std::string request_to_string(smx_simcall_t req, int value) const; - std::string request_get_dot_output(smx_simcall_t req, int value) const; - smx_actor_t simcall_get_issuer(s_smx_simcall const* req) const; - long simcall_get_actor_id(s_smx_simcall const* req) const; - RemotePtr get_mbox_remote_addr(smx_simcall_t const req) const; - RemotePtr get_comm_remote_addr(smx_simcall_t const req) const; - bool simcall_check_dependency(smx_simcall_t const req1, smx_simcall_t const req2) const; - -#if HAVE_SMPI - int get_smpi_request_tag(smx_simcall_t const& simcall, simgrid::simix::Simcall type) const; -#endif // STATE APIs - void restore_state(std::shared_ptr system_state) const; - void log_state() const; + void restore_state(const Snapshot* system_state) const; // SNAPSHOT APIs bool snapshot_equal(const Snapshot* s1, const Snapshot* s2) const; - simgrid::mc::Snapshot* take_snapshot(int num_state) const; + simgrid::mc::Snapshot* take_snapshot(long num_state) const; // SESSION APIs - void s_close() const; - void execute(Transition& transition, smx_simcall_t simcall) const; + simgrid::mc::Session const& get_session() const { return *session_; } + void s_close(); -// AUTOMATION APIs -#if SIMGRID_HAVE_MC + // AUTOMATION APIs void automaton_load(const char* file) const; -#endif std::vector automaton_propositional_symbol_evaluate() const; std::vector get_automaton_state() const; int compare_automaton_exp_label(const xbt_automaton_exp_label* l) const; @@ -148,18 +88,10 @@ public: { return DerefAndCompareByActorsCountAndUsedHeap(); } - inline int automaton_state_compare(const_xbt_automaton_state_t const& s1, const_xbt_automaton_state_t const& s2) const - { - return xbt_automaton_state_compare(s1, s2); - } xbt_automaton_exp_label_t get_automaton_transition_label(xbt_dynar_t const& dynar, int index) const; xbt_automaton_state_t get_automaton_transition_dst(xbt_dynar_t const& dynar, int index) const; - - // DYNAR APIs - inline unsigned long get_dynar_length(const_xbt_dynar_t const& dynar) const { return xbt_dynar_length(dynar); } }; -} // namespace mc -} // namespace simgrid +} // namespace simgrid::mc #endif