Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
513c99727e191673a51369a2f6de7b7d3bf41905
[simgrid.git] / src / mc / explo / simgrid_mc.cpp
1 /* Copyright (c) 2015-2023. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "src/mc/explo/Exploration.hpp"
7 #include "src/mc/mc_config.hpp"
8 #include "src/mc/mc_exit.hpp"
9 #include "src/simgrid/sg_config.hpp"
10
11 #if HAVE_SMPI
12 #include "smpi/smpi.h"
13 #endif
14
15 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(mc);
16
17 using namespace simgrid::mc;
18
19 int main(int argc, char** argv)
20 {
21   xbt_assert(argc >= 2, "Missing arguments");
22
23   // Currently, we need this before sg_config_init:
24   simgrid::mc::set_model_checking_mode(simgrid::mc::ModelCheckingMode::CHECKER_SIDE);
25
26   // The initialization function can touch argv.
27   // We make a copy of argv before modifying it in order to pass the original value to the model-checked application:
28   std::vector<char*> argv_copy{argv, argv + argc + 1};
29
30   xbt_log_init(&argc, argv);
31 #if HAVE_SMPI
32   smpi_init_options(); // that's OK to call it twice, and we need it ASAP
33 #endif
34   sg_config_init(&argc, argv);
35
36   std::unique_ptr<Exploration> explo;
37
38 #if SIMGRID_HAVE_STATEFUL_MC
39   if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
40     explo = std::unique_ptr<Exploration>(
41         create_communication_determinism_checker(argv_copy, get_model_checking_reduction()));
42   else if (_sg_mc_unfolding_checker)
43     explo = std::unique_ptr<Exploration>(create_udpor_checker(argv_copy));
44   else if (not _sg_mc_property_file.get().empty())
45     explo = std::unique_ptr<Exploration>(create_liveness_checker(argv_copy));
46   else
47 #endif
48     explo = std::unique_ptr<Exploration>(create_dfs_exploration(argv_copy, get_model_checking_reduction()));
49
50   ExitStatus status;
51   try {
52     explo->run();
53     status = ExitStatus::SUCCESS;
54   } catch (const McError& e) {
55     status = e.value;
56   }
57   return static_cast<int>(status);
58 }