1 /* Copyright (c) 2007-2023. 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 #ifndef SIMGRID_MC_ODPOR_EXECUTION_HPP
7 #define SIMGRID_MC_ODPOR_EXECUTION_HPP
9 #include "src/mc/api/ClockVector.hpp"
10 #include "src/mc/transition/Transition.hpp"
12 #include <unordered_set>
15 namespace simgrid::mc::odpor {
18 * @brief An ordered sequence of actions
20 class ExecutionSequence : public std::list<const Transition*> {};
21 using Hypothetical = ExecutionSequence;
24 * @brief The occurrence of a transition in an execution
27 std::pair<const Transition*, ClockVector> contents_;
31 Event(Event&&) = default;
32 Event(const Event&) = default;
33 Event& operator=(const Event&) = default;
34 Event& operator=(const Event&&) = default;
36 explicit Event(std::pair<const Transition*, ClockVector> pair) : contents_(std::move(pair)) {}
38 const Transition* get_transition() const { return contents_.get<0>(); }
39 const ClockVector& get_clock_vector() const { return contents_.get<1>(); }
43 * @brief An ordered sequence of transitions which describe
44 * the evolution of a process undergoing model checking
46 * Executions are conceived based on the following papers:
47 * 1. "Source Sets: A Foundation for Optimal Dynamic Partial Order Reduction"
50 * In addition to representing an actual steps taken,
51 * an execution keeps track of the "happens-before"
52 * relation among the transitions in the execution
53 * by following the procedure outlined in the
54 * original DPOR paper with clock vectors
56 * @note: For more nuanced happens-before relations, clock
57 * vectors may not always suffice. Clock vectors work
58 * well with transition-based dependencies like that used in
59 * SimGrid; but to have a more refined independence relation,
60 * an event-based dependency approach is needed. See the section 2
61 * in the ODPOR paper [1] concerning event-based dependencies and
62 * how the happens-before relation can be refined in a
63 * computation model much like that of SimGrid. In fact, the same issue
64 * arrises with UDPOR with context-sensitive dependencies:
65 * the two concepts are analogous if not identical
70 * @brief The actual steps that are taken by the process
73 std::list<Event> contents_;
76 Execution() = default;
77 Execution(const Execution&) = default;
78 Execution& operator=(Execution const&) = default;
79 Execution(Execution&&) = default;
80 explicit Execution(ExecutionSequence&& seq);
81 explicit Execution(const ExecutionSequence& seq);
83 std::unordered_set<aid_t> get_initials_after(const Hypothetical& w) const;
84 std::unordered_set<aid_t> get_weak_initials_after(const Hypothetical& w) const;
86 bool is_initial(aid_t p, const Hypothetical& w) const;
87 bool is_weak_initial(aid_t p, const Hypothetical& w) const;
89 void take_action(const Transition*);
92 } // namespace simgrid::mc::odpor