Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'fix-wakeup-tree-iterator' into 'master'
[simgrid.git] / src / mc / transition / TransitionComm.hpp
1 /* Copyright (c) 2015-2023. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #ifndef SIMGRID_MC_TRANSITION_COMM_HPP
7 #define SIMGRID_MC_TRANSITION_COMM_HPP
8
9 #include "src/kernel/actor/SimcallObserver.hpp"
10 #include "src/mc/transition/Transition.hpp"
11
12 #include <cstdint>
13 #include <sstream>
14 #include <string>
15
16 namespace simgrid::mc {
17
18 class CommRecvTransition;
19 class CommSendTransition;
20 class CommTestTransition;
21
22 class CommWaitTransition : public Transition {
23   bool timeout_;
24   unsigned comm_;
25   unsigned mbox_;
26   aid_t sender_;
27   aid_t receiver_;
28   uintptr_t sbuff_;
29   uintptr_t rbuff_;
30   size_t size_;
31   friend CommRecvTransition;
32   friend CommSendTransition;
33   friend CommTestTransition;
34
35 public:
36   CommWaitTransition(aid_t issuer, int times_considered, bool timeout_, unsigned comm_, aid_t sender_, aid_t receiver_,
37                      unsigned mbox_, uintptr_t sbuff_, uintptr_t rbuff_, size_t size_);
38   CommWaitTransition(aid_t issuer, int times_considered, std::stringstream& stream);
39   std::string to_string(bool verbose) const override;
40   bool depends(const Transition* other) const override;
41
42   bool get_timeout() const { return timeout_; }
43   /** ID of the corresponding Communication object in the application, or 0 if unknown */
44   unsigned get_comm() const { return comm_; }
45   /** Sender ID */
46   aid_t get_sender() const { return sender_; }
47   /** Receiver ID */
48   aid_t get_receiver() const { return receiver_; }
49   /** Mailbox ID */
50   unsigned get_mailbox() const { return mbox_; }
51   /** Sender buffer */
52   uintptr_t get_sbuff() const { return sbuff_; }
53   /** Receiver buffer */
54   uintptr_t get_rbuff() const { return rbuff_; }
55   /** data size */
56   size_t get_size() const { return size_; }
57 };
58 class CommTestTransition : public Transition {
59   unsigned comm_;
60   unsigned mbox_;
61   aid_t sender_;
62   aid_t receiver_;
63   uintptr_t sbuff_;
64   uintptr_t rbuff_;
65   size_t size_;
66   friend CommSendTransition;
67   friend CommRecvTransition;
68
69 public:
70   CommTestTransition(aid_t issuer, int times_considered, unsigned comm_, aid_t sender_, aid_t receiver_, unsigned mbox_,
71                      uintptr_t sbuff_, uintptr_t rbuff_, size_t size_);
72   CommTestTransition(aid_t issuer, int times_considered, std::stringstream& stream);
73   std::string to_string(bool verbose) const override;
74   bool depends(const Transition* other) const override;
75
76   /** ID of the corresponding Communication object in the application, or 0 if unknown */
77   unsigned get_comm() const { return comm_; }
78   /** Sender ID */
79   aid_t get_sender() const { return sender_; }
80   /** Receiver ID */
81   aid_t get_receiver() const { return receiver_; }
82   /** Mailbox ID */
83   unsigned get_mailbox() const { return mbox_; }
84   /** Sender buffer */
85   uintptr_t get_sbuff() const { return sbuff_; }
86   /** Receiver buffer */
87   uintptr_t get_rbuff() const { return rbuff_; }
88   /** data size */
89   size_t get_size() const { return size_; }
90 };
91
92 class CommRecvTransition : public Transition {
93   unsigned comm_; /* ID of the CommImpl or 0 if not known */
94   unsigned mbox_;
95   uintptr_t rbuff_;
96   int tag_;
97
98 public:
99   CommRecvTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_, uintptr_t rbuff_, int tag_);
100   CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream);
101   std::string to_string(bool verbose) const override;
102   bool depends(const Transition* other) const override;
103
104   /** ID of the corresponding Communication object in the application (or 0 if unknown)*/
105   unsigned get_comm() const { return comm_; }
106   /** Mailbox ID */
107   unsigned get_mailbox() const { return mbox_; }
108   /** Receiver buffer */
109   uintptr_t get_rbuff() const { return rbuff_; }
110   /** If using SMPI, the tag */
111   int get_tag() const { return tag_; }
112 };
113
114 class CommSendTransition : public Transition {
115   unsigned comm_;
116   unsigned mbox_;
117   uintptr_t sbuff_;
118   size_t size_;
119   int tag_;
120
121 public:
122   CommSendTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_, uintptr_t sbuff_, size_t size_,
123                      int tag_);
124   CommSendTransition(aid_t issuer, int times_considered, std::stringstream& stream);
125   std::string to_string(bool verbose) const override;
126   bool depends(const Transition* other) const override;
127
128   /** ID of the corresponding Communication object in the application, or 0 if unknown */
129   unsigned get_comm() const { return comm_; }
130   /** Mailbox ID */
131   unsigned get_mailbox() const { return mbox_; }
132   /** Sender buffer */
133   uintptr_t get_sbuff() const { return sbuff_; }
134   /** data size */
135   size_t get_size() const { return size_; }
136   /** If using SMPI, the tag */
137   int get_tag() const { return tag_; }
138 };
139
140 /** Make a new transition from serialized description */
141 Transition* deserialize_transition(aid_t issuer, int times_considered, std::stringstream& stream);
142
143 } // namespace simgrid::mc
144
145 #endif