CommWaitTransition::CommWaitTransition(aid_t issuer, int times_considered, std::stringstream& stream)
: Transition(Type::COMM_WAIT, issuer, times_considered)
{
- stream >> timeout_ >> comm_ >> sender_ >> receiver_ >> mbox_ >> src_buff_ >> dst_buff_ >> size_;
- XBT_DEBUG("CommWaitTransition %s comm:%p, sender:%ld receiver:%ld mbox:%u sbuff:%p rbuff:%p size:%zu",
- (timeout_ ? "timeout" : "no-timeout"), comm_, sender_, receiver_, mbox_, src_buff_, dst_buff_, size_);
+ xbt_assert(stream >> timeout_ >> comm_ >> sender_ >> receiver_ >> mbox_ >> sbuff_ >> rbuff_ >> size_);
+ XBT_DEBUG("CommWaitTransition %s comm:%lx, sender:%ld receiver:%ld mbox:%u sbuff:%lx rbuff:%lx size:%zu",
+ (timeout_ ? "timeout" : "no-timeout"), comm_, sender_, receiver_, mbox_, sbuff_, rbuff_, size_);
}
std::string CommWaitTransition::to_string(bool verbose) const
{
auto res = xbt::string_printf("%ld: WaitComm(from %ld to %ld, mbox=%u, %s", aid_, sender_, receiver_, mbox_,
(timeout_ ? "timeout" : "no timeout"));
if (verbose) {
- res += ", src_buff=" + xbt::string_printf("%p", src_buff_) + ", size=" + std::to_string(size_);
- res += ", dst_buff=" + xbt::string_printf("%p", dst_buff_);
+ res += ", sbuff=" + xbt::string_printf("%lx", sbuff_) + ", size=" + std::to_string(size_);
+ res += ", rbuff=" + xbt::string_printf("%lx", rbuff_);
}
res += ")";
return res;
if (aid_ == other->aid_)
return false;
- if (dynamic_cast<const RandomTransition*>(other) != nullptr)
- return false; // Random is indep with any transition
-
- if (auto* recv = dynamic_cast<const CommRecvTransition*>(other))
- return recv->depends(this);
-
- if (auto* send = dynamic_cast<const CommSendTransition*>(other))
- return send->depends(this);
-
- if (auto* test = dynamic_cast<const CommTestTransition*>(other))
- return test->depends(this);
+ if (other->type_ < type_)
+ return other->depends(this);
if (const auto* wait = dynamic_cast<const CommWaitTransition*>(other)) {
if (timeout_ || wait->timeout_)
return true; // Timeouts are not considered by the independence theorem, thus assumed dependent
- if (src_buff_ == wait->src_buff_ && dst_buff_ == wait->dst_buff_)
+ if (sbuff_ == wait->sbuff_ && rbuff_ == wait->rbuff_)
return false;
- if (src_buff_ != nullptr && dst_buff_ != nullptr && wait->src_buff_ != nullptr && wait->dst_buff_ != nullptr &&
- dst_buff_ != wait->src_buff_ && dst_buff_ != wait->dst_buff_ && dst_buff_ != src_buff_)
+ if (sbuff_ != 0 && rbuff_ != 0 && wait->sbuff_ != 0 && wait->rbuff_ != 0 && rbuff_ != wait->sbuff_ &&
+ rbuff_ != wait->rbuff_ && rbuff_ != sbuff_)
return false;
}
CommTestTransition::CommTestTransition(aid_t issuer, int times_considered, std::stringstream& stream)
: Transition(Type::COMM_TEST, issuer, times_considered)
{
- stream >> comm_ >> sender_ >> receiver_ >> mbox_ >> src_buff_ >> dst_buff_ >> size_;
- XBT_DEBUG("CommTestTransition comm:%p, sender:%ld receiver:%ld mbox:%u sbuff:%p rbuff:%p size:%zu", comm_, sender_,
- receiver_, mbox_, src_buff_, dst_buff_, size_);
+ xbt_assert(stream >> comm_ >> sender_ >> receiver_ >> mbox_ >> sbuff_ >> rbuff_ >> size_);
+ XBT_DEBUG("CommTestTransition comm:%lx, sender:%ld receiver:%ld mbox:%u sbuff:%lx rbuff:%lx size:%zu", comm_, sender_,
+ receiver_, mbox_, sbuff_, rbuff_, size_);
}
std::string CommTestTransition::to_string(bool verbose) const
{
auto res = xbt::string_printf("%ld: TestComm(from %ld to %ld, mbox=%u", aid_, sender_, receiver_, mbox_);
if (verbose) {
- res += ", src_buff=" + xbt::string_printf("%p", src_buff_) + ", size=" + std::to_string(size_);
- res += ", dst_buff=" + xbt::string_printf("%p", dst_buff_);
+ res += ", sbuff=" + xbt::string_printf("%lx", sbuff_) + ", size=" + std::to_string(size_);
+ res += ", rbuff=" + xbt::string_printf("%lx", rbuff_);
}
res += ")";
return res;
if (aid_ == other->aid_)
return false;
- if (dynamic_cast<const RandomTransition*>(other) != nullptr)
- return false; // Test & Random are independent (Random is independent with anything)
-
- if (auto* recv = dynamic_cast<const CommRecvTransition*>(other))
- return recv->depends(this); // Recv < Test (alphabetical ordering)
-
- if (auto* send = dynamic_cast<const CommSendTransition*>(other))
- return send->depends(this); // Send < Test (alphabetical ordering)
+ if (other->type_ < type_)
+ return other->depends(this);
if (dynamic_cast<const CommTestTransition*>(other) != nullptr)
return false; // Test & Test are independent
CommRecvTransition::CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream)
: Transition(Type::COMM_RECV, issuer, times_considered)
{
- stream >> mbox_ >> dst_buff_;
+ xbt_assert(stream >> comm_ >> mbox_ >> rbuff_);
}
std::string CommRecvTransition::to_string(bool verbose) const
{
auto res = xbt::string_printf("%ld: iRecv(mbox=%u", aid_, mbox_);
if (verbose)
- res += ", buff=" + xbt::string_printf("%p", dst_buff_);
+ res += ", rbuff=" + xbt::string_printf("%lx", rbuff_);
res += ")";
return res;
}
if (aid_ == other->aid_)
return false;
- if (dynamic_cast<const RandomTransition*>(other) != nullptr)
- return false; // Random is indep with any transition
+ if (other->type_ < type_)
+ return other->depends(this);
if (const auto* recv = dynamic_cast<const CommRecvTransition*>(other))
return mbox_ == recv->mbox_;
if (mbox_ != test->mbox_)
return false;
- if ((aid_ != test->sender_) && (aid_ != test->receiver_) && (test->dst_buff_ != dst_buff_))
+ if ((aid_ != test->sender_) && (aid_ != test->receiver_) && (test->rbuff_ != rbuff_))
return false;
}
if (mbox_ != wait->mbox_)
return false;
- if ((aid_ != wait->sender_) && (aid_ != wait->receiver_) && (wait->dst_buff_ != dst_buff_))
+ if ((aid_ != wait->sender_) && (aid_ != wait->receiver_) && (wait->rbuff_ != rbuff_))
return false;
}
CommSendTransition::CommSendTransition(aid_t issuer, int times_considered, std::stringstream& stream)
: Transition(Type::COMM_SEND, issuer, times_considered)
{
- stream >> mbox_ >> src_buff_ >> size_;
- XBT_DEBUG("SendTransition mbox:%u buff:%p size:%zu", mbox_, src_buff_, size_);
+ xbt_assert(stream >> comm_ >> mbox_ >> sbuff_ >> size_);
+ XBT_DEBUG("SendTransition comm:%lx mbox:%u sbuff:%lx size:%zu", comm_, mbox_, sbuff_, size_);
}
std::string CommSendTransition::to_string(bool verbose = false) const
{
auto res = xbt::string_printf("%ld: iSend(mbox=%u", aid_, mbox_);
if (verbose)
- res += ", buff=" + xbt::string_printf("%p", src_buff_) + ", size=" + std::to_string(size_);
+ res += ", sbuff=" + xbt::string_printf("%lx", sbuff_) + ", size=" + std::to_string(size_);
res += ")";
return res;
}
TestAnyTransition::TestAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream)
+ : Transition(Type::TESTANY, issuer, times_considered)
{
int size;
- stream >> size;
+ xbt_assert(stream >> size);
for (int i = 0; i < size; i++) {
-
- Transition* t = recv_transition(issuer, 0, stream);
+ Transition* t = deserialize_transition(issuer, 0, stream);
+ XBT_DEBUG("TestAny received a transition %s", t->to_string(true).c_str());
transitions_.push_back(t);
}
}
}
bool TestAnyTransition::depends(const Transition* other) const
{
- return true;
+ return transitions_[times_considered_]->depends(other);
+}
+WaitAnyTransition::WaitAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream)
+ : Transition(Type::WAITANY, issuer, times_considered)
+{
+ int size;
+ xbt_assert(stream >> size);
+ for (int i = 0; i < size; i++) {
+ Transition* t = deserialize_transition(issuer, 0, stream);
+ transitions_.push_back(t);
+ }
+}
+std::string WaitAnyTransition::to_string(bool verbose) const
+{
+ auto res = xbt::string_printf("%ld: WaitAny{ ", aid_);
+ for (auto const* t : transitions_)
+ res += t->to_string(verbose);
+ res += "}";
+ return res;
+}
+bool WaitAnyTransition::depends(const Transition* other) const
+{
+ return transitions_[times_considered_]->depends(other);
}
bool CommSendTransition::depends(const Transition* other) const
if (aid_ == other->aid_)
return false;
- if (dynamic_cast<const RandomTransition*>(other) != nullptr)
- return false; // Random is indep with any transition
+ if (other->type_ < type_)
+ return other->depends(this);
if (const auto* other_isend = dynamic_cast<const CommSendTransition*>(other))
return mbox_ == other_isend->mbox_;
if (mbox_ != test->mbox_)
return false;
- if ((aid_ != test->sender_) && (aid_ != test->receiver_) && (test->src_buff_ != src_buff_))
+ if ((aid_ != test->sender_) && (aid_ != test->receiver_) && (test->sbuff_ != sbuff_))
return false;
}
if (mbox_ != wait->mbox_)
return false;
- if ((aid_ != wait->sender_) && (aid_ != wait->receiver_) && (wait->src_buff_ != src_buff_))
+ if ((aid_ != wait->sender_) && (aid_ != wait->receiver_) && (wait->sbuff_ != sbuff_))
return false;
}
return true;
}
-Transition* recv_transition(aid_t issuer, int times_considered, std::stringstream& stream)
+Transition* deserialize_transition(aid_t issuer, int times_considered, std::stringstream& stream)
{
short type;
- stream >> type;
+ xbt_assert(stream >> type);
xbt_assert(type >= 0 && type <= static_cast<short>(Transition::Type::UNKNOWN), "Invalid transition type %d received",
type);
- Transition::Type simcall = static_cast<Transition::Type>(type);
+ auto simcall = static_cast<Transition::Type>(type);
switch (simcall) {
case Transition::Type::COMM_RECV:
case Transition::Type::TESTANY:
return new TestAnyTransition(issuer, times_considered, stream);
+ case Transition::Type::WAITANY:
+ return new WaitAnyTransition(issuer, times_considered, stream);
case Transition::Type::RANDOM:
return new RandomTransition(issuer, times_considered, stream);