Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Convert MC config parameters to C++ API, and move their definitions to mc_config...
[simgrid.git] / src / mc / mc_config.cpp
1 /* Copyright (c) 2008-2018. 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 "xbt/config.h"
7 #include "xbt/log.h"
8 #include <xbt/sysdep.h>
9
10 #include "src/mc/mc_replay.hpp"
11 #include <mc/mc.h>
12
13 #include <simgrid/sg_config.hpp>
14
15 #if SIMGRID_HAVE_MC
16 #include "src/mc/mc_private.hpp"
17 #include "src/mc/mc_safety.hpp"
18 #endif
19
20 #include "src/mc/mc_record.hpp"
21
22 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_config, mc, "Configuration of the Model Checker");
23
24 #if SIMGRID_HAVE_MC
25 namespace simgrid {
26 namespace mc {
27 /* Configuration support */
28 simgrid::mc::ReductionMode reduction_mode = simgrid::mc::ReductionMode::unset;
29 }
30 }
31 #endif
32
33 #if !SIMGRID_HAVE_MC
34 #define _sg_do_model_check 0
35 #endif
36
37 static void _mc_cfg_cb_check(const char* spec, bool more_check = true)
38 {
39   if (_sg_cfg_init_status && not _sg_do_model_check && more_check)
40     xbt_die("You are specifying a %s after the initialization (through MSG_config?), but the program was not run under "
41             "the model-checker (with simgrid-mc)). This won't work, sorry.",
42             spec);
43 }
44
45 /* Replay (this part is enabled even if MC it disabled) */
46 static simgrid::config::Flag<std::string> _sg_mc_record_path{
47     "model-check/replay", "Model-check path to replay (as reported by SimGrid when a violation is reported)", "",
48     [](const std::string& value) { MC_record_path = value; }};
49
50 simgrid::config::Flag<bool> _sg_mc_timeout{
51     "model-check/timeout", "Whether to enable timeouts for wait requests", false,
52     [](bool) { _mc_cfg_cb_check("value to enable/disable timeout for wait requests", MC_record_path.empty()); }};
53
54 #if SIMGRID_HAVE_MC
55 int _sg_do_model_check = 0;
56 int _sg_mc_max_visited_states = 0;
57
58 simgrid::config::Flag<bool> _sg_do_model_check_record{"model-check/record", "Record the model-checking paths", false};
59
60 simgrid::config::Flag<int> _sg_mc_checkpoint{
61     "model-check/checkpoint", "Specify the amount of steps between checkpoints during stateful model-checking "
62                               "(default: 0 => stateless verification). If value=1, one checkpoint is saved for each "
63                               "step => faster verification, but huge memory consumption; higher values are good "
64                               "compromises between speed and memory consumption.",
65     0, [](int) { _mc_cfg_cb_check("checkpointing value"); }};
66
67 simgrid::config::Flag<bool> _sg_mc_sparse_checkpoint{"model-check/sparse-checkpoint", "Use sparse per-page snapshots.",
68                                                      false, [](bool) { _mc_cfg_cb_check("checkpointing value"); }};
69
70 simgrid::config::Flag<bool> _sg_mc_ksm{"model-check/ksm", "Kernel same-page merging", false,
71                                        [](bool) { _mc_cfg_cb_check("KSM value"); }};
72
73 simgrid::config::Flag<std::string> _sg_mc_property_file{
74     "model-check/property", "Name of the file containing the property, as formatted by the ltl2ba program.", "",
75     [](const std::string&) { _mc_cfg_cb_check("property"); }};
76
77 simgrid::config::Flag<bool> _sg_mc_comms_determinism{
78     "model-check/communications-determinism",
79     {"model-check/communications_determinism"},
80     "Whether to enable the detection of communication determinism",
81     false,
82     [](bool) {
83       _mc_cfg_cb_check("value to enable/disable the detection of determinism in the communications schemes");
84     }};
85
86 simgrid::config::Flag<bool> _sg_mc_send_determinism{
87     "model-check/send-determinism",
88     {"model-check/send_determinism"},
89     "Enable/disable the detection of send-determinism in the communications schemes",
90     false,
91     [](bool) {
92       _mc_cfg_cb_check("value to enable/disable the detection of send-determinism in the communications schemes");
93     }};
94
95 static simgrid::config::Flag<std::string> _sg_mc_reduce{
96     "model-check/reduction", "Specify the kind of exploration reduction (either none or DPOR)", "dpor",
97     [](const std::string& value) {
98       _mc_cfg_cb_check("reduction strategy");
99
100       if (value == "none")
101         simgrid::mc::reduction_mode = simgrid::mc::ReductionMode::none;
102       else if (value == "dpor")
103         simgrid::mc::reduction_mode = simgrid::mc::ReductionMode::dpor;
104       else
105         xbt_die("configuration option model-check/reduction can only take 'none' or 'dpor' as a value");
106     }};
107
108 simgrid::config::Flag<bool> _sg_mc_hash{
109     "model-check/hash", "Whether to enable state hash for state comparison (experimental)", false,
110     [](bool) { _mc_cfg_cb_check("value to enable/disable the use of global hash to speedup state comparaison"); }};
111
112 simgrid::config::Flag<bool> _sg_mc_snapshot_fds{
113     "model-check/snapshot-fds",
114     {"model-check/snapshot_fds"},
115     "Whether file descriptors must be snapshoted (currently unusable)",
116     false,
117     [](bool) { _mc_cfg_cb_check("value to enable/disable the use of FD snapshotting"); }};
118
119 simgrid::config::Flag<int> _sg_mc_max_depth{"model-check/max-depth",
120                                             {"model-check/max_depth"},
121                                             "Maximal exploration depth (default: 1000)",
122                                             1000,
123                                             [](int) { _mc_cfg_cb_check("max depth value"); }};
124
125 static simgrid::config::Flag<int> _sg_mc_max_visited_states__{
126     "model-check/visited", "Specify the number of visited state stored for state comparison reduction. If value=5, the "
127                            "last 5 visited states are stored. If value=0 (the default), all states are stored.",
128     0, [](int value) {
129       _mc_cfg_cb_check("number of stored visited states");
130       _sg_mc_max_visited_states = value;
131     }};
132
133 simgrid::config::Flag<std::string> _sg_mc_dot_output_file{
134     "model-check/dot-output",
135     {"model-check/dot_output"},
136     "Name of dot output file corresponding to graph state",
137     "",
138     [](const std::string&) { _mc_cfg_cb_check("file name for a dot output of graph state"); }};
139
140 simgrid::config::Flag<bool> _sg_mc_termination{
141     "model-check/termination", "Whether to enable non progressive cycle detection", false,
142     [](bool) { _mc_cfg_cb_check("value to enable/disable the detection of non progressive cycles"); }};
143
144 #endif