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 int _sg_mc_timeout = 0;
39 static void _mc_cfg_cb_check(const char* spec, bool more_check = true)
41 if (_sg_cfg_init_status && not _sg_do_model_check && more_check)
42 xbt_die("You are specifying a %s after the initialization (through MSG_config?), but the program was not run under "
43 "the model-checker (with simgrid-mc)). This won't work, sorry.",
47 void _mc_cfg_cb_timeout(const char *name)
49 _mc_cfg_cb_check("value to enable/disable timeout for wait requests", MC_record_path.empty());
51 _sg_mc_timeout = xbt_cfg_get_boolean(name);
55 int _sg_do_model_check = 0;
56 int _sg_do_model_check_record = 0;
57 int _sg_mc_checkpoint = 0;
58 int _sg_mc_sparse_checkpoint = 0;
60 std::string _sg_mc_property_file;
62 int _sg_mc_max_depth = 1000;
63 int _sg_mc_max_visited_states = 0;
64 std::string _sg_mc_dot_output_file;
65 int _sg_mc_comms_determinism = 0;
66 int _sg_mc_send_determinism = 0;
67 int _sg_mc_snapshot_fds = 0;
68 int _sg_mc_termination = 0;
70 void _mc_cfg_cb_reduce(const char *name)
72 _mc_cfg_cb_check("reduction strategy");
74 std::string val = xbt_cfg_get_string(name);
76 simgrid::mc::reduction_mode = simgrid::mc::ReductionMode::none;
77 else if (val == "dpor")
78 simgrid::mc::reduction_mode = simgrid::mc::ReductionMode::dpor;
80 xbt_die("configuration option %s can only take 'none' or 'dpor' as a value", name);
83 void _mc_cfg_cb_checkpoint(const char *name)
85 _mc_cfg_cb_check("checkpointing value");
87 _sg_mc_checkpoint = xbt_cfg_get_int(name);
90 void _mc_cfg_cb_sparse_checkpoint(const char *name) {
91 _mc_cfg_cb_check("checkpointing value");
93 _sg_mc_sparse_checkpoint = xbt_cfg_get_boolean(name);
96 void _mc_cfg_cb_ksm(const char *name)
98 _mc_cfg_cb_check("KSM value");
100 _sg_mc_ksm = xbt_cfg_get_boolean(name);
103 void _mc_cfg_cb_property(const char *name)
105 _mc_cfg_cb_check("property");
107 _sg_mc_property_file = xbt_cfg_get_string(name);
110 void _mc_cfg_cb_hash(const char *name)
112 _mc_cfg_cb_check("value to enable/disable the use of global hash to speedup state comparaison");
114 _sg_mc_hash = xbt_cfg_get_boolean(name);
117 void _mc_cfg_cb_snapshot_fds(const char *name)
119 _mc_cfg_cb_check("value to enable/disable the use of FD snapshotting");
121 _sg_mc_snapshot_fds = xbt_cfg_get_boolean(name);
124 void _mc_cfg_cb_max_depth(const char *name)
126 _mc_cfg_cb_check("max depth value");
128 _sg_mc_max_depth = xbt_cfg_get_int(name);
131 void _mc_cfg_cb_visited(const char *name)
133 _mc_cfg_cb_check("number of stored visited states");
135 _sg_mc_max_visited_states = xbt_cfg_get_int(name);
138 void _mc_cfg_cb_dot_output(const char *name)
140 _mc_cfg_cb_check("file name for a dot output of graph state");
142 _sg_mc_dot_output_file = xbt_cfg_get_string(name);
145 void _mc_cfg_cb_comms_determinism(const char *name)
147 _mc_cfg_cb_check("value to enable/disable the detection of determinism in the communications schemes");
149 _sg_mc_comms_determinism = xbt_cfg_get_boolean(name);
152 void _mc_cfg_cb_send_determinism(const char *name)
154 _mc_cfg_cb_check("value to enable/disable the detection of send-determinism in the communications schemes");
156 _sg_mc_send_determinism = xbt_cfg_get_boolean(name);
159 void _mc_cfg_cb_termination(const char *name)
161 _mc_cfg_cb_check("value to enable/disable the detection of non progressive cycles");
163 _sg_mc_termination = xbt_cfg_get_boolean(name);