Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sanitize the OOP of kernel::profile
[simgrid.git] / src / mc / mc_config.cpp
1 /* Copyright (c) 2008-2019. 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.hpp"
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 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
49 simgrid::config::Flag<bool> _sg_mc_timeout{
50     "model-check/timeout", "Whether to enable timeouts for wait requests", false,
51     [](bool) { _mc_cfg_cb_check("value to enable/disable timeout for wait requests", MC_record_path.empty()); }};
52
53 #if SIMGRID_HAVE_MC
54 int _sg_do_model_check = 0;
55 int _sg_mc_max_visited_states = 0;
56
57 simgrid::config::Flag<bool> _sg_do_model_check_record{"model-check/record", "Record the model-checking paths", false};
58
59 simgrid::config::Flag<int> _sg_mc_checkpoint{
60     "model-check/checkpoint", "Specify the amount of steps between checkpoints during stateful model-checking "
61                               "(default: 0 => stateless verification). If value=1, one checkpoint is saved for each "
62                               "step => faster verification, but huge memory consumption; higher values are good "
63                               "compromises between speed and memory consumption.",
64     0, [](int) { _mc_cfg_cb_check("checkpointing value"); }};
65
66 simgrid::config::Flag<bool> _sg_mc_sparse_checkpoint{"model-check/sparse-checkpoint", "Use sparse per-page snapshots.",
67                                                      false, [](bool) { _mc_cfg_cb_check("checkpointing value"); }};
68
69 simgrid::config::Flag<bool> _sg_mc_ksm{"model-check/ksm", "Kernel same-page merging", false,
70                                        [](bool) { _mc_cfg_cb_check("KSM value"); }};
71
72 simgrid::config::Flag<std::string> _sg_mc_property_file{
73     "model-check/property", "Name of the file containing the property, as formatted by the ltl2ba program.", "",
74     [](const std::string&) { _mc_cfg_cb_check("property"); }};
75
76 simgrid::config::Flag<bool> _sg_mc_comms_determinism{
77     "model-check/communications-determinism",
78     {"model-check/communications_determinism"},
79     "Whether to enable the detection of communication determinism",
80     false,
81     [](bool) {
82       _mc_cfg_cb_check("value to enable/disable the detection of determinism in the communications schemes");
83     }};
84
85 simgrid::config::Flag<bool> _sg_mc_send_determinism{
86     "model-check/send-determinism",
87     {"model-check/send_determinism"},
88     "Enable/disable the detection of send-determinism in the communications schemes",
89     false,
90     [](bool) {
91       _mc_cfg_cb_check("value to enable/disable the detection of send-determinism in the communications schemes");
92     }};
93
94 static simgrid::config::Flag<std::string> _sg_mc_reduce{
95     "model-check/reduction", "Specify the kind of exploration reduction (either none or DPOR)", "dpor",
96     [](const std::string& value) {
97       _mc_cfg_cb_check("reduction strategy");
98
99       if (value == "none")
100         simgrid::mc::reduction_mode = simgrid::mc::ReductionMode::none;
101       else if (value == "dpor")
102         simgrid::mc::reduction_mode = simgrid::mc::ReductionMode::dpor;
103       else
104         xbt_die("configuration option model-check/reduction can only take 'none' or 'dpor' as a value");
105     }};
106
107 simgrid::config::Flag<bool> _sg_mc_hash{
108     "model-check/hash", "Whether to enable state hash for state comparison (experimental)", false,
109     [](bool) { _mc_cfg_cb_check("value to enable/disable the use of global hash to speedup state comparaison"); }};
110
111 simgrid::config::Flag<bool> _sg_mc_snapshot_fds{
112     "model-check/snapshot-fds",
113     {"model-check/snapshot_fds"},
114     "Whether file descriptors must be snapshoted (currently unusable)",
115     false,
116     [](bool) { _mc_cfg_cb_check("value to enable/disable the use of FD snapshotting"); }};
117
118 simgrid::config::Flag<int> _sg_mc_max_depth{"model-check/max-depth",
119                                             {"model-check/max_depth"},
120                                             "Maximal exploration depth (default: 1000)",
121                                             1000,
122                                             [](int) { _mc_cfg_cb_check("max depth value"); }};
123
124 static simgrid::config::Flag<int> _sg_mc_max_visited_states__{
125     "model-check/visited", "Specify the number of visited state stored for state comparison reduction. If value=5, the "
126                            "last 5 visited states are stored. If value=0 (the default), all states are stored.",
127     0, [](int value) {
128       _mc_cfg_cb_check("number of stored visited states");
129       _sg_mc_max_visited_states = value;
130     }};
131
132 simgrid::config::Flag<std::string> _sg_mc_dot_output_file{
133     "model-check/dot-output",
134     {"model-check/dot_output"},
135     "Name of dot output file corresponding to graph state",
136     "",
137     [](const std::string&) { _mc_cfg_cb_check("file name for a dot output of graph state"); }};
138
139 simgrid::config::Flag<bool> _sg_mc_termination{
140     "model-check/termination", "Whether to enable non progressive cycle detection", false,
141     [](bool) { _mc_cfg_cb_check("value to enable/disable the detection of non progressive cycles"); }};
142
143 #endif