X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9d23bfe5e8febe2b55c45e7fcd72d50644fac6ca..3cb644bc04ff9dd4da159790850b6bcfda970cf9:/src/mc/api/ClockVector.hpp diff --git a/src/mc/api/ClockVector.hpp b/src/mc/api/ClockVector.hpp index d4dfa377cd..32e395fa45 100644 --- a/src/mc/api/ClockVector.hpp +++ b/src/mc/api/ClockVector.hpp @@ -9,6 +9,7 @@ #include "simgrid/forward.h" #include +#include #include #include @@ -18,6 +19,28 @@ namespace simgrid::mc { * @brief A multi-dimensional vector used to keep track of * happens-before relation between dependent events in an * execution of DPOR, SDPOR, or ODPOR + * + * Clock vectors permit actors in a distributed system + * to determine whether two events occurred one after the other + * but they may not have); i.e. they permit actors to keep track of "time". + * A clever observation made in the original DPOR paper is that a + * transition-based "happens-before" relation can be computed for + * any particular trace `S` using clock vectors, effectively + * treating dependency like the passing of a message (the context + * in which vector clocks are typically used). + * + * Support, however, needs to be added to clock vectors since + * SimGrid permits the *creation* of new actors during execution. + * Since we don't know this size before-hand, we have to allow + * clock vectors to behave as if they were "infinitely" large. To + * do so, all newly mapped elements, if not assigned a value, are + * defaulted to `0`. This corresponds to the value this actor would + * have had regardless had its creation been known to have evnetually + * occurred: no actions taken by that actor had occurred prior, so + * there's no way the clock vector would have been updated. In other + * words, when comparing clock vectors of different sizes, it's equivalent + * to imagine both of the same size with elements absent in one or + * the other implicitly mapped to zero. */ struct ClockVector final { private: @@ -28,6 +51,7 @@ public: ClockVector(const ClockVector&) = default; ClockVector& operator=(ClockVector const&) = default; ClockVector(ClockVector&&) = default; + ClockVector(std::initializer_list> init) : contents(std::move(init)) {} /** * @brief The number of components in this