1 /* Copyright (c) 2015-2022. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef SIMGRID_MC_TRANSITION_COMM_HPP
8 #define SIMGRID_MC_TRANSITION_COMM_HPP
10 #include "src/kernel/actor/SimcallObserver.hpp"
11 #include "src/mc/api/Transition.hpp"
19 class CommRecvTransition;
20 class CommSendTransition;
21 class CommTestTransition;
23 class CommWaitTransition : public Transition {
32 friend CommRecvTransition;
33 friend CommSendTransition;
34 friend CommTestTransition;
37 CommWaitTransition(aid_t issuer, int times_considered, std::stringstream& stream);
38 std::string to_string(bool verbose) const override;
39 bool depends(const Transition* other) const override;
41 bool get_timeout() const { return timeout_; }
42 /** Address of the corresponding Communication object in the application */
43 uintptr_t get_comm() const { return comm_; }
45 aid_t get_sender() const { return sender_; }
47 aid_t get_receiver() const { return receiver_; }
49 unsigned get_mailbox() const { return mbox_; }
51 uintptr_t get_sbuff() const { return sbuff_; }
52 /** Receiver buffer */
53 uintptr_t get_rbuff() const { return rbuff_; }
55 size_t get_size() const { return size_; }
57 class CommTestTransition : public Transition {
65 friend CommSendTransition;
66 friend CommRecvTransition;
69 CommTestTransition(aid_t issuer, int times_considered, std::stringstream& stream);
70 std::string to_string(bool verbose) const override;
71 bool depends(const Transition* other) const override;
73 /** Address of the corresponding Communication object in the application */
74 uintptr_t get_comm() const { return comm_; }
76 aid_t get_sender() const { return sender_; }
78 aid_t get_receiver() const { return receiver_; }
80 unsigned get_mailbox() const { return mbox_; }
82 uintptr_t get_sbuff() const { return sbuff_; }
83 /** Receiver buffer */
84 uintptr_t get_rbuff() const { return rbuff_; }
86 size_t get_size() const { return size_; }
89 class CommRecvTransition : public Transition {
90 uintptr_t comm_; /* Addr of the CommImpl */
96 CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream);
97 std::string to_string(bool verbose) const override;
98 bool depends(const Transition* other) const override;
100 /** Address of the corresponding Communication object in the application */
101 uintptr_t get_comm() const { return comm_; }
103 unsigned get_mailbox() const { return mbox_; }
104 /** Receiver buffer */
105 uintptr_t get_rbuff() const { return rbuff_; }
106 /** If using SMPI, the tag */
107 int get_tag() const { return tag_; }
110 class CommSendTransition : public Transition {
111 uintptr_t comm_; /* Addr of the CommImpl */
118 CommSendTransition(aid_t issuer, int times_considered, std::stringstream& stream);
119 std::string to_string(bool verbose) const override;
120 bool depends(const Transition* other) const override;
122 /** Address of the corresponding Communication object in the application */
123 uintptr_t get_comm() const { return comm_; }
125 unsigned get_mailbox() const { return mbox_; }
127 uintptr_t get_sbuff() const { return sbuff_; }
129 size_t get_size() const { return size_; }
130 /** If using SMPI, the tag */
131 int get_tag() const { return tag_; }
134 class TestAnyTransition : public Transition {
135 std::vector<Transition*> transitions_;
138 TestAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream);
139 std::string to_string(bool verbose) const override;
140 bool depends(const Transition* other) const override;
142 Transition* get_current_transition() const { return transitions_.at(times_considered_); }
145 class WaitAnyTransition : public Transition {
146 std::vector<Transition*> transitions_;
149 WaitAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream);
150 std::string to_string(bool verbose) const override;
151 bool depends(const Transition* other) const override;
153 Transition* get_current_transition() const { return transitions_.at(times_considered_); }
156 /** Make a new transition from serialized description */
157 Transition* deserialize_transition(aid_t issuer, int times_considered, std::stringstream& stream);
160 } // namespace simgrid