1 /* Copyright (c) 2008-2018. The SimGrid Team. All rights reserved. */
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. */
6 #include "xbt/config.h"
8 #include <xbt/sysdep.h>
10 #include "src/mc/mc_replay.hpp"
13 #include <simgrid/sg_config.hpp>
16 #include "src/mc/mc_private.hpp"
17 #include "src/mc/mc_safety.hpp"
20 #include "src/mc/mc_record.hpp"
22 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_config, mc, "Configuration of the Model Checker");
27 /* Configuration support */
28 simgrid::mc::ReductionMode reduction_mode = simgrid::mc::ReductionMode::unset;
34 #define _sg_do_model_check 0
37 static void _mc_cfg_cb_check(const char* spec, bool more_check = true)
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.",
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)", ""};
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()); }};
54 int _sg_do_model_check = 0;
55 int _sg_mc_max_visited_states = 0;
57 simgrid::config::Flag<bool> _sg_do_model_check_record{"model-check/record", "Record the model-checking paths", false};
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"); }};
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"); }};
69 simgrid::config::Flag<bool> _sg_mc_ksm{"model-check/ksm", "Kernel same-page merging", false,
70 [](bool) { _mc_cfg_cb_check("KSM value"); }};
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"); }};
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",
82 _mc_cfg_cb_check("value to enable/disable the detection of determinism in the communications schemes");
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",
91 _mc_cfg_cb_check("value to enable/disable the detection of send-determinism in the communications schemes");
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");
100 simgrid::mc::reduction_mode = simgrid::mc::ReductionMode::none;
101 else if (value == "dpor")
102 simgrid::mc::reduction_mode = simgrid::mc::ReductionMode::dpor;
104 xbt_die("configuration option model-check/reduction can only take 'none' or 'dpor' as a value");
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"); }};
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)",
116 [](bool) { _mc_cfg_cb_check("value to enable/disable the use of FD snapshotting"); }};
118 simgrid::config::Flag<int> _sg_mc_max_depth{"model-check/max-depth",
119 {"model-check/max_depth"},
120 "Maximal exploration depth (default: 1000)",
122 [](int) { _mc_cfg_cb_check("max depth value"); }};
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.",
128 _mc_cfg_cb_check("number of stored visited states");
129 _sg_mc_max_visited_states = value;
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",
137 [](const std::string&) { _mc_cfg_cb_check("file name for a dot output of graph state"); }};
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"); }};