From 7d0481c2f6eeb622daf1ab8b29f154563806eb61 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 12 Feb 2022 00:26:41 +0100 Subject: [PATCH] Fix the depends of iSend/iRecv vs. WaitComm to fix the bugged2 example --- examples/cpp/mc-bugged2/s4u-mc-bugged2.cpp | 19 ++++++++----------- src/mc/api/TransitionComm.cpp | 11 ++--------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/examples/cpp/mc-bugged2/s4u-mc-bugged2.cpp b/examples/cpp/mc-bugged2/s4u-mc-bugged2.cpp index df2b83f602..1f6d3c3abc 100644 --- a/examples/cpp/mc-bugged2/s4u-mc-bugged2.cpp +++ b/examples/cpp/mc-bugged2/s4u-mc-bugged2.cpp @@ -20,25 +20,25 @@ static void server() received1 = simgrid::s4u::Mailbox::by_name("mymailbox")->get(); long val1 = *received1; - received1 = nullptr; - XBT_INFO("Received %ld", val1); + delete received1; received2 = simgrid::s4u::Mailbox::by_name("mymailbox")->get(); long val2 = *received2; - received2 = nullptr; - XBT_INFO("Received %ld", val2); + delete received2; - MC_assert(std::min(val1, val2) == 1); + XBT_INFO("First pair received: %ld %ld", val1, val2); + + MC_assert(std::min(val1, val2) == 1); // if the two messages of the second client arrive first, this is violated. received1 = simgrid::s4u::Mailbox::by_name("mymailbox")->get(); val1 = *received1; - XBT_INFO("Received %ld", val1); + delete received1; received2 = simgrid::s4u::Mailbox::by_name("mymailbox")->get(); val2 = *received2; - XBT_INFO("Received %ld", val2); + delete received2; - XBT_INFO("OK"); + XBT_INFO("Second pair received: %ld %ld", val1, val2); } static void client(int id) @@ -46,10 +46,7 @@ static void client(int id) auto* payload1 = new int(id); auto* payload2 = new int(id); - XBT_INFO("Send %d", id); simgrid::s4u::Mailbox::by_name("mymailbox")->put(payload1, 10000); - - XBT_INFO("Send %d", id); simgrid::s4u::Mailbox::by_name("mymailbox")->put(payload2, 10000); } diff --git a/src/mc/api/TransitionComm.cpp b/src/mc/api/TransitionComm.cpp index 1e38480abe..6fa6730217 100644 --- a/src/mc/api/TransitionComm.cpp +++ b/src/mc/api/TransitionComm.cpp @@ -103,10 +103,7 @@ bool CommRecvTransition::depends(const Transition* other) const if (mbox_ != wait->mbox_) return false; - if ((aid_ != wait->sender_) && (aid_ != wait->receiver_)) - return false; - - if (wait->dst_buff_ != dst_buff_) + if ((aid_ != wait->sender_) && (aid_ != wait->receiver_) && (wait->dst_buff_ != dst_buff_)) return false; } @@ -146,7 +143,6 @@ bool CommSendTransition::depends(const Transition* other) const if (const auto* other_isend = dynamic_cast(other)) return mbox_ == other_isend->mbox_; - // FIXME: Not in the former dependency check because of the ordering but seems logical to add it if (dynamic_cast(other) != nullptr) return false; @@ -157,10 +153,7 @@ bool CommSendTransition::depends(const Transition* other) const if (mbox_ != wait->mbox_) return false; - if ((aid_ != wait->sender_) && (aid_ != wait->receiver_)) - return false; - - if (wait->src_buff_ != src_buff_) + if ((aid_ != wait->sender_) && (aid_ != wait->receiver_) && (wait->src_buff_ != src_buff_)) return false; } -- 2.20.1