21 #include <spot/misc/common.hh>
22 #include <spot/misc/_config.h>
28 #include <spot/kripke/kripke.hh>
29 #include <spot/mc/mc.hh>
30 #include <spot/mc/lpar13.hh>
31 #include <spot/mc/deadlock.hh>
32 #include <spot/mc/cndfs.hh>
33 #include <spot/mc/bloemen.hh>
34 #include <spot/mc/bloemen_ec.hh>
35 #include <spot/misc/timer.hh>
40 #if defined(__cpp_concepts) && __cpp_concepts >= 201907L
45 concept is_a_mc_algorithm = requires(T u)
50 { u->finisher() } -> std::same_as<bool>;
51 { u->states() } -> std::same_as<unsigned>;
52 { u->transitions() } -> std::same_as<unsigned>;
53 { u->walltime() } -> std::same_as<unsigned>;
54 { u->name() } -> std::same_as<std::string>;
55 { u->sccs() } -> std::same_as<int>;
56 { u->result() } -> std::same_as<mc_rvalue>;
57 { u->trace() } -> std::same_as<std::string>;
62 template<
typename algo_name,
typename kripke_ptr,
typename State,
63 typename Iterator,
typename Hash,
typename Equal>
69 std::atomic<bool> stop(
false);
70 unsigned nbth = sys->get_threads();
72 typename algo_name::shared_map map;
73 std::vector<algo_name*> swarmed(nbth);
76 using struct_name =
typename algo_name::shared_struct;
77 std::vector<struct_name*> ss(nbth);
79 tm.
start(
"Initialisation");
80 for (
unsigned i = 0; i < nbth; ++i)
82 ss[i] = algo_name::make_shared_structure(map, i);
83 swarmed[i] =
new algo_name(*sys, prop, map, ss[i], i, stop);
85 #if defined(__cpp_concepts) && __cpp_concepts >= 201907L
86 static_assert(spot::is_a_mc_algorithm<decltype(&*swarmed[i])>,
87 "error: does not match the mc_algorithm requirements");
91 tm.
stop(
"Initialisation");
95 std::atomic<bool> barrier(
true);
96 std::vector<std::thread> threads(nbth);
97 for (
unsigned i = 0; i < nbth; ++i)
99 threads[i] = std::thread ([&swarmed, &iomutex, i, &barrier]
101 #ifdef SPOT_HAVE_SCHED_GETCPU
103 std::lock_guard<std::mutex> iolock(iomutex);
104 std::cout <<
"Thread #" << i
105 <<
": on CPU " << sched_getcpu() <<
'\n';
115 #ifdef SPOT_PTHREAD_SETAFFINITY_NP
120 int rc = pthread_setaffinity_np(threads[i].native_handle(),
121 sizeof(cpu_set_t), &cpuset);
124 std::lock_guard<std::mutex> iolock(iomutex);
125 std::cerr <<
"Error calling pthread_setaffinity_np: " << rc <<
'\n';
131 barrier.store(
false);
133 for (
auto& t: threads)
139 for (
unsigned i = 0; i < nbth; ++i)
141 result.name.emplace_back(swarmed[i]->name());
142 result.walltime.emplace_back(swarmed[i]->walltime());
143 result.states.emplace_back(swarmed[i]->states());
144 result.transitions.emplace_back(swarmed[i]->transitions());
145 result.sccs.emplace_back(swarmed[i]->sccs());
146 result.value.emplace_back(swarmed[i]->result());
147 result.finisher.emplace_back(swarmed[i]->finisher());
153 for (
unsigned i = 0; i < nbth && go_on; ++i)
159 switch (result.value[i])
164 result.trace = swarmed[i]->trace();
178 for (
unsigned i = 0; i < nbth; ++i)
188 typename Iterator,
typename Hash,
typename Equal>
196 SPOT_ASSERT(prop !=
nullptr);
197 SPOT_ASSERT(sys->ap().size() == prop->ap().size());
198 for (
unsigned int i = 0; i < sys->ap().size(); ++i)
199 SPOT_ASSERT(sys->ap()[i].compare(prop->ap()[i]) == 0);
205 return instanciate<spot::swarmed_bloemen<State, Iterator, Hash, Equal>,
206 kripke_ptr, State, Iterator, Hash, Equal> (sys, prop, trace);
210 instanciate<spot::swarmed_bloemen_ec<State, Iterator, Hash, Equal>,
211 kripke_ptr, State, Iterator, Hash, Equal> (sys, prop, trace);
214 return instanciate<spot::swarmed_cndfs<State, Iterator, Hash, Equal>,
215 kripke_ptr, State, Iterator, Hash, Equal> (sys, prop, trace);
220 kripke_ptr, State, Iterator, Hash, Equal> (sys, prop, trace);
225 kripke_ptr, State, Iterator, Hash, Equal> (sys, prop, trace);
228 return instanciate<spot::lpar13<State, Iterator, Hash, Equal>,
229 kripke_ptr, State, Iterator, Hash, Equal> (sys, prop, trace);
This class aims to explore a model to detect whether it contains a deadlock. This deadlock detection ...
Definition: deadlock.hh:47
A map of timer, where each timer has a name.
Definition: timer.hh:231
void stop(const std::string &name)
Stop timer name.
Definition: timer.hh:251
void start(const std::string &name)
Start a timer with name name.
Definition: timer.hh:240
std::shared_ptr< kripke > kripke_ptr
Definition: fwd.hh:33
std::shared_ptr< twacube > twacube_ptr
Definition: fwd.hh:25
Definition: automata.hh:26
mc_algorithm
The list of parallel model-checking algorithms available.
Definition: mc.hh:39
@ CNDFS
Evangelista.12.atva emptiness check.
@ REACHABILITY
Only perform a reachability algorithm.
@ SWARMING
Holzmann.11.ieee applied to renault.13.lpar.
@ DEADLOCK
Check whether there is a deadlock.
@ BLOEMEN_SCC
Bloemen.16.ppopp SCC computation.
@ BLOEMEN_EC
Bloemen.16.hvc emptiness check.
@ NOT_EMPTY
The product is not empty.
@ NO_DEADLOCK
No deadlock has been found.
@ FAILURE
The algorithm finished abnormally.
@ DEADLOCK
A deadlock has been found.
@ EMPTY
The product is empty.
@ SUCCESS
The algorithm finished normally.