X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c312320c2e43da49b536c51a9d19b6ad6d66e489..3f9b311ec56db95ec539001a860ae3c838c48312:/src/mc/transition/TransitionComm.cpp diff --git a/src/mc/transition/TransitionComm.cpp b/src/mc/transition/TransitionComm.cpp index 029548dd63..d23cd86fb8 100644 --- a/src/mc/transition/TransitionComm.cpp +++ b/src/mc/transition/TransitionComm.cpp @@ -18,24 +18,27 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_trans_comm, mc_transition, namespace simgrid::mc { +CommWaitTransition::CommWaitTransition(aid_t issuer, int times_considered, bool timeout_, unsigned comm_, aid_t sender_, + aid_t receiver_, unsigned mbox_) + : Transition(Type::COMM_WAIT, issuer, times_considered) + , timeout_(timeout_) + , comm_(comm_) + , mbox_(mbox_) + , sender_(sender_) + , receiver_(receiver_) +{ +} CommWaitTransition::CommWaitTransition(aid_t issuer, int times_considered, std::stringstream& stream) : Transition(Type::COMM_WAIT, issuer, times_considered) { - xbt_assert(stream >> timeout_ >> comm_ >> sender_ >> receiver_ >> mbox_ >> sbuff_ >> rbuff_ >> size_); - XBT_DEBUG("CommWaitTransition %s comm:%" PRIxPTR ", sender:%ld receiver:%ld mbox:%u sbuff:%" PRIxPTR - " rbuff:%" PRIxPTR " size:%zu", - (timeout_ ? "timeout" : "no-timeout"), comm_, sender_, receiver_, mbox_, sbuff_, rbuff_, size_); + xbt_assert(stream >> timeout_ >> comm_ >> sender_ >> receiver_ >> mbox_ >> call_location_); + XBT_DEBUG("CommWaitTransition %s comm:%u, sender:%ld receiver:%ld mbox:%u call_loc:%s", + (timeout_ ? "timeout" : "no-timeout"), comm_, sender_, receiver_, mbox_, call_location_.c_str()); } std::string CommWaitTransition::to_string(bool verbose) const { - auto res = xbt::string_printf("WaitComm(from %ld to %ld, mbox=%u, %s", sender_, receiver_, mbox_, - (timeout_ ? "timeout" : "no timeout")); - if (verbose) { - res += ", sbuff=" + xbt::string_printf("%" PRIxPTR, sbuff_) + ", size=" + std::to_string(size_); - res += ", rbuff=" + xbt::string_printf("%" PRIxPTR, rbuff_); - } - res += ")"; - return res; + return xbt::string_printf("WaitComm(from %ld to %ld, mbox=%u, %s)", sender_, receiver_, mbox_, + (timeout_ ? "timeout" : "no timeout")); } bool CommWaitTransition::depends(const Transition* other) const { @@ -49,36 +52,40 @@ bool CommWaitTransition::depends(const Transition* other) const if (const auto* wait = dynamic_cast(other)) { if (timeout_ || wait->timeout_) return true; // Timeouts are not considered by the independence theorem, thus assumed dependent - - if (sbuff_ == wait->sbuff_ && rbuff_ == wait->rbuff_) - return false; - if (sbuff_ != 0 && rbuff_ != 0 && wait->sbuff_ != 0 && wait->rbuff_ != 0 && rbuff_ != wait->sbuff_ && - rbuff_ != wait->rbuff_ && rbuff_ != sbuff_) - return false; - - return true; } return false; // Comm transitions are INDEP with non-comm transitions } + +bool CommWaitTransition::reversible_race(const Transition* other) const +{ + xbt_assert(type_ == Type::COMM_WAIT, "Unexpected transition type %s", to_c_str(type_)); + + // If the other event is a communication event, then we are not reversible; otherwise we are reversible. + return other->type_ != Transition::Type::COMM_ASYNC_SEND && other->type_ != Transition::Type::COMM_ASYNC_RECV; +} + +CommTestTransition::CommTestTransition(aid_t issuer, int times_considered, unsigned comm_, aid_t sender_, + aid_t receiver_, unsigned mbox_) + : Transition(Type::COMM_TEST, issuer, times_considered) + , comm_(comm_) + , mbox_(mbox_) + , sender_(sender_) + , receiver_(receiver_) +{ +} CommTestTransition::CommTestTransition(aid_t issuer, int times_considered, std::stringstream& stream) : Transition(Type::COMM_TEST, issuer, times_considered) { - xbt_assert(stream >> comm_ >> sender_ >> receiver_ >> mbox_ >> sbuff_ >> rbuff_ >> size_); - XBT_DEBUG("CommTestTransition comm:%" PRIxPTR ", sender:%ld receiver:%ld mbox:%u sbuff:%" PRIxPTR " rbuff:%" PRIxPTR - " size:%zu", - comm_, sender_, receiver_, mbox_, sbuff_, rbuff_, size_); + xbt_assert(stream >> comm_ >> sender_ >> receiver_ >> mbox_ >> call_location_); + XBT_DEBUG("CommTestTransition comm:%u, sender:%ld receiver:%ld mbox:%u call_loc:%s", comm_, sender_, receiver_, mbox_, + call_location_.c_str()); } std::string CommTestTransition::to_string(bool verbose) const { - auto res = xbt::string_printf("TestComm(from %ld to %ld, mbox=%u", sender_, receiver_, mbox_); - if (verbose) { - res += ", sbuff=" + xbt::string_printf("%" PRIxPTR, sbuff_) + ", size=" + std::to_string(size_); - res += ", rbuff=" + xbt::string_printf("%" PRIxPTR, rbuff_); - } - res += ")"; - return res; + return xbt::string_printf("TestComm(from %ld to %ld, mbox=%u)", sender_, receiver_, mbox_); } + bool CommTestTransition::depends(const Transition* other) const { if (other->type_ < type_) @@ -102,18 +109,25 @@ bool CommTestTransition::depends(const Transition* other) const return false; // Comm transitions are INDEP with non-comm transitions } +bool CommTestTransition::reversible_race(const Transition* other) const +{ + xbt_assert(type_ == Type::COMM_TEST, "Unexpected transition type %s", to_c_str(type_)); + return true; // CommTest is always enabled +} + +CommRecvTransition::CommRecvTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_, int tag_) + : Transition(Type::COMM_ASYNC_RECV, issuer, times_considered), comm_(comm_), mbox_(mbox_), tag_(tag_) +{ +} CommRecvTransition::CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream) : Transition(Type::COMM_ASYNC_RECV, issuer, times_considered) { - xbt_assert(stream >> comm_ >> mbox_ >> rbuff_ >> tag_); + xbt_assert(stream >> comm_ >> mbox_ >> tag_ >> call_location_); + XBT_DEBUG("CommRecvTransition comm:%u, mbox:%u tag:%d call_loc:%s", comm_, mbox_, tag_, call_location_.c_str()); } std::string CommRecvTransition::to_string(bool verbose) const { - auto res = xbt::string_printf("iRecv(mbox=%u", mbox_); - if (verbose) - res += ", rbuff=" + xbt::string_printf("%" PRIxPTR, rbuff_); - res += ")"; - return res; + return xbt::string_printf("iRecv(mbox=%u)", mbox_); } bool CommRecvTransition::depends(const Transition* other) const { @@ -134,20 +148,30 @@ bool CommRecvTransition::depends(const Transition* other) const if (mbox_ != test->mbox_) return false; - if ((aid_ != test->sender_) && (aid_ != test->receiver_) && (test->rbuff_ != rbuff_)) + if ((aid_ != test->sender_) && (aid_ != test->receiver_)) + return false; + + // If the test is checking a paired comm already, we're independent! + // If we happen to make up that pair, then we're dependent... + if (test->comm_ != comm_) return false; return true; // DEP with other send transitions } - if (auto* wait = dynamic_cast(other)) { + if (const auto* wait = dynamic_cast(other)) { if (wait->timeout_) return true; if (mbox_ != wait->mbox_) return false; - if ((aid_ != wait->sender_) && (aid_ != wait->receiver_) && (wait->rbuff_ != rbuff_)) + if ((aid_ != wait->sender_) && (aid_ != wait->receiver_)) + return false; + + // If the wait is waiting on a paired comm already, we're independent! + // If we happen to make up that pair, then we're dependent... + if ((aid_ != wait->aid_) && wait->comm_ != comm_) return false; return true; // DEP with other wait transitions @@ -156,19 +180,26 @@ bool CommRecvTransition::depends(const Transition* other) const return false; // Comm transitions are INDEP with non-comm transitions } +bool CommRecvTransition::reversible_race(const Transition* other) const +{ + xbt_assert(type_ == Type::COMM_ASYNC_RECV, "Unexpected transition type %s", to_c_str(type_)); + + return true; // CommRecv is always enabled +} + +CommSendTransition::CommSendTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_, int tag_) + : Transition(Type::COMM_ASYNC_SEND, issuer, times_considered), comm_(comm_), mbox_(mbox_), tag_(tag_) +{ +} CommSendTransition::CommSendTransition(aid_t issuer, int times_considered, std::stringstream& stream) : Transition(Type::COMM_ASYNC_SEND, issuer, times_considered) { - xbt_assert(stream >> comm_ >> mbox_ >> sbuff_ >> size_ >> tag_); - XBT_DEBUG("SendTransition comm:%" PRIxPTR " mbox:%u sbuff:%" PRIxPTR " size:%zu", comm_, mbox_, sbuff_, size_); + xbt_assert(stream >> comm_ >> mbox_ >> tag_ >> call_location_); + XBT_DEBUG("SendTransition comm:%u mbox:%u tag:%d call_loc:%s", comm_, mbox_, tag_, call_location_.c_str()); } std::string CommSendTransition::to_string(bool verbose = false) const { - auto res = xbt::string_printf("iSend(mbox=%u", mbox_); - if (verbose) - res += ", sbuff=" + xbt::string_printf("%" PRIxPTR, sbuff_) + ", size=" + std::to_string(size_); - res += ")"; - return res; + return xbt::string_printf("iSend(mbox=%u)", mbox_); } bool CommSendTransition::depends(const Transition* other) const @@ -190,7 +221,12 @@ bool CommSendTransition::depends(const Transition* other) const if (mbox_ != test->mbox_) return false; - if ((aid_ != test->sender_) && (aid_ != test->receiver_) && (test->sbuff_ != sbuff_)) + if ((aid_ != test->sender_) && (aid_ != test->receiver_)) + return false; + + // If the test is checking a paired comm already, we're independent! + // If we happen to make up that pair, then we're dependent... + if (test->comm_ != comm_) return false; return true; // DEP with other test transitions @@ -203,7 +239,12 @@ bool CommSendTransition::depends(const Transition* other) const if (mbox_ != wait->mbox_) return false; - if ((aid_ != wait->sender_) && (aid_ != wait->receiver_) && (wait->sbuff_ != sbuff_)) + if ((aid_ != wait->sender_) && (aid_ != wait->receiver_)) + return false; + + // If the wait is waiting on a paired comm already, we're independent! + // If we happen to make up that pair, then we're dependent... + if ((aid_ != wait->aid_) && wait->comm_ != comm_) return false; return true; // DEP with other wait transitions @@ -212,4 +253,11 @@ bool CommSendTransition::depends(const Transition* other) const return false; // Comm transitions are INDEP with non-comm transitions } +bool CommSendTransition::reversible_race(const Transition* other) const +{ + xbt_assert(type_ == Type::COMM_ASYNC_SEND, "Unexpected transition type %s", to_c_str(type_)); + + return true; // CommSend is always enabled +} + } // namespace simgrid::mc