#include "src/mc/transition/TransitionAny.hpp"
#include "src/mc/transition/TransitionComm.hpp"
#include "src/mc/transition/TransitionRandom.hpp"
+#include "src/mc/transition/TransitionSynchro.hpp"
#endif
#include <sstream>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_transition, mc, "Logging specific to MC transitions");
-namespace simgrid {
-namespace mc {
+namespace simgrid::mc {
unsigned long Transition::executed_transitions_ = 0;
unsigned long Transition::replayed_transitions_ = 0;
{
return "";
}
-std::string Transition::dot_label() const
+std::string Transition::dot_string() const
{
- return xbt::string_printf("[(%ld)] %s", aid_, Transition::to_c_str(type_));
+ static constexpr std::array<const char*, 13> colors{{"blue", "red", "green3", "goldenrod", "brown", "purple",
+ "magenta", "turquoise4", "gray25", "forestgreen", "hotpink",
+ "lightblue", "tan"}};
+ const char* color = colors[(aid_ - 1) % colors.size()];
+
+ return xbt::string_printf("label = \"[(%ld)] %s\", color = %s, fontcolor = %s", aid_, Transition::to_c_str(type_),
+ color, color);
}
void Transition::replay() const
{
#if SIMGRID_HAVE_MC
short type;
xbt_assert(stream >> type);
- xbt_assert(type >= 0 && type <= static_cast<short>(Transition::Type::UNKNOWN), "Invalid transition type %d received",
- type);
- auto simcall = static_cast<Transition::Type>(type);
+ switch (auto simcall = static_cast<Transition::Type>(type)) {
+ case Transition::Type::BARRIER_LOCK:
+ case Transition::Type::BARRIER_WAIT:
+ return new BarrierTransition(issuer, times_considered, simcall, stream);
- switch (simcall) {
case Transition::Type::COMM_RECV:
return new CommRecvTransition(issuer, times_considered, stream);
case Transition::Type::COMM_SEND:
case Transition::Type::RANDOM:
return new RandomTransition(issuer, times_considered, stream);
+ case Transition::Type::MUTEX_TRYLOCK:
+ case Transition::Type::MUTEX_LOCK:
+ case Transition::Type::MUTEX_TEST:
+ case Transition::Type::MUTEX_WAIT:
+ case Transition::Type::MUTEX_UNLOCK:
+ return new MutexTransition(issuer, times_considered, simcall, stream);
+
+ case Transition::Type::SEM_LOCK:
+ case Transition::Type::SEM_UNLOCK:
+ case Transition::Type::SEM_WAIT:
+ return new SemaphoreTransition(issuer, times_considered, simcall, stream);
+
case Transition::Type::UNKNOWN:
return new Transition(Transition::Type::UNKNOWN, issuer, times_considered);
+
+ default:
+ break;
}
- THROW_IMPOSSIBLE; // Some compilers don't detect that each branch of the above switch has a return
+ xbt_die("Invalid transition type %d received", type);
#else
xbt_die("Deserializing transitions is only interesting in MC mode.");
#endif
}
-} // namespace mc
-} // namespace simgrid
+} // namespace simgrid::mc