Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'udpor-phase6' into 'master'
[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::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 (_sg_mc_comms_determinism || _sg_mc_send_determinism)
39     explo = std::unique_ptr<Exploration>(create_communication_determinism_checker(argv_copy, cfg_use_DPOR()));
40   else if (_sg_mc_unfolding_checker)
41     explo = std::unique_ptr<Exploration>(create_udpor_checker(argv_copy));
42   else if (_sg_mc_property_file.get().empty())
43     explo = std::unique_ptr<Exploration>(create_dfs_exploration(argv_copy, cfg_use_DPOR()));
44   else
45     explo = std::unique_ptr<Exploration>(create_liveness_checker(argv_copy));
46
47   try {
48     explo->run();
49   } catch (const DeadlockError&) {
50     return SIMGRID_MC_EXIT_DEADLOCK;
51   } catch (const TerminationError&) {
52     return SIMGRID_MC_EXIT_NON_TERMINATION;
53   } catch (const LivenessError&) {
54     return SIMGRID_MC_EXIT_LIVENESS;
55   }
56   return SIMGRID_MC_EXIT_SUCCESS;
57 }