+ auto* ref = static_cast<MPI_Request>(a);
+ auto* req = static_cast<MPI_Request>(b);
+ bool match = match_common(req, req, ref);
+ if (not match || ref->comm_ == MPI_COMM_UNINITIALIZED || ref->comm_->is_smp_comm())
+ return match;
+
+ if (ref->comm_->get_received_messages_count(ref->comm_->group()->rank(req->src_),
+ ref->comm_->group()->rank(req->dst_), req->tag_) == req->message_id_) {
+ if (((ref->flags_ & MPI_REQ_PROBE) == 0) && ((req->flags_ & MPI_REQ_PROBE) == 0)) {
+ XBT_DEBUG("increasing count in comm %p, which was %u from pid %ld, to pid %ld with tag %d", ref->comm_,
+ ref->comm_->get_received_messages_count(ref->comm_->group()->rank(req->src_),
+ ref->comm_->group()->rank(req->dst_), req->tag_),
+ req->src_, req->dst_, req->tag_);
+ ref->comm_->increment_received_messages_count(ref->comm_->group()->rank(req->src_),
+ ref->comm_->group()->rank(req->dst_), req->tag_);
+ if (ref->real_size_ > req->real_size_) {
+ ref->real_size_ = req->real_size_;
+ }
+ }
+ } else {
+ match = false;
+ req->flags_ &= ~MPI_REQ_MATCHED;
+ ref->detached_sender_ = nullptr;
+ XBT_DEBUG("Refusing to match message, as its ID is not the one I expect. in comm %p, %u != %u, "
+ "from pid %ld to pid %ld, with tag %d",
+ ref->comm_,
+ ref->comm_->get_received_messages_count(ref->comm_->group()->rank(req->src_),
+ ref->comm_->group()->rank(req->dst_), req->tag_),
+ req->message_id_, req->src_, req->dst_, req->tag_);
+ }
+ return match;