1 /* Copyright (c) 2015-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_MC_TRANSITION_COMM_HPP
7 #define SIMGRID_MC_TRANSITION_COMM_HPP
9 #include "src/kernel/actor/SimcallObserver.hpp"
10 #include "src/mc/transition/Transition.hpp"
16 namespace simgrid::mc {
18 class CommRecvTransition;
19 class CommSendTransition;
20 class CommTestTransition;
22 class CommWaitTransition : public Transition {
28 friend CommRecvTransition;
29 friend CommSendTransition;
30 friend CommTestTransition;
33 CommWaitTransition(aid_t issuer, int times_considered, bool timeout_, unsigned comm_, aid_t sender_, aid_t receiver_,
35 CommWaitTransition(aid_t issuer, int times_considered, std::stringstream& stream);
36 std::string to_string(bool verbose) const override;
37 bool depends(const Transition* other) const override;
38 bool reversible_race(const Transition* other) const override;
40 bool get_timeout() const { return timeout_; }
41 /** ID of the corresponding Communication object in the application, or 0 if unknown */
42 unsigned get_comm() const { return comm_; }
44 aid_t get_sender() const { return sender_; }
46 aid_t get_receiver() const { return receiver_; }
48 unsigned get_mailbox() const { return mbox_; }
50 class CommTestTransition : public Transition {
55 friend CommSendTransition;
56 friend CommRecvTransition;
59 CommTestTransition(aid_t issuer, int times_considered, unsigned comm_, aid_t sender_, aid_t receiver_,
61 CommTestTransition(aid_t issuer, int times_considered, std::stringstream& stream);
62 std::string to_string(bool verbose) const override;
63 bool depends(const Transition* other) const override;
64 bool reversible_race(const Transition* other) const override;
66 /** ID of the corresponding Communication object in the application, or 0 if unknown */
67 unsigned get_comm() const { return comm_; }
69 aid_t get_sender() const { return sender_; }
71 aid_t get_receiver() const { return receiver_; }
73 unsigned get_mailbox() const { return mbox_; }
76 class CommRecvTransition : public Transition {
77 unsigned comm_; /* ID of the CommImpl or 0 if not known */
82 CommRecvTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_, int tag_);
83 CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream);
84 std::string to_string(bool verbose) const override;
85 bool depends(const Transition* other) const override;
86 bool reversible_race(const Transition* other) const override;
88 /** ID of the corresponding Communication object in the application (or 0 if unknown)*/
89 unsigned get_comm() const { return comm_; }
91 unsigned get_mailbox() const { return mbox_; }
92 /** If using SMPI, the tag */
93 int get_tag() const { return tag_; }
96 class CommSendTransition : public Transition {
102 CommSendTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_, int tag_);
103 CommSendTransition(aid_t issuer, int times_considered, std::stringstream& stream);
104 std::string to_string(bool verbose) const override;
105 bool depends(const Transition* other) const override;
106 bool reversible_race(const Transition* other) const override;
108 /** ID of the corresponding Communication object in the application, or 0 if unknown */
109 unsigned get_comm() const { return comm_; }
111 unsigned get_mailbox() const { return mbox_; }
112 /** If using SMPI, the tag */
113 int get_tag() const { return tag_; }
116 /** Make a new transition from serialized description */
117 Transition* deserialize_transition(aid_t issuer, int times_considered, std::stringstream& stream);
119 } // namespace simgrid::mc