Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Missing include (for uintptr_t).
[simgrid.git] / src / mc / transition / TransitionComm.hpp
1 /* Copyright (c) 2015-2022. 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   uintptr_t comm_;
25   aid_t sender_;
26   aid_t receiver_;
27   unsigned mbox_;
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, std::stringstream& stream);
37   std::string to_string(bool verbose) const override;
38   bool depends(const Transition* other) const override;
39
40   bool get_timeout() const { return timeout_; }
41   /** Address of the corresponding Communication object in the application */
42   uintptr_t get_comm() const { return comm_; }
43   /** Sender ID */
44   aid_t get_sender() const { return sender_; }
45   /** Receiver ID */
46   aid_t get_receiver() const { return receiver_; }
47   /** Mailbox ID */
48   unsigned get_mailbox() const { return mbox_; }
49   /** Sender buffer */
50   uintptr_t get_sbuff() const { return sbuff_; }
51   /** Receiver buffer */
52   uintptr_t get_rbuff() const { return rbuff_; }
53   /** data size */
54   size_t get_size() const { return size_; }
55 };
56 class CommTestTransition : public Transition {
57   uintptr_t comm_;
58   aid_t sender_;
59   aid_t receiver_;
60   unsigned mbox_;
61   uintptr_t sbuff_;
62   uintptr_t rbuff_;
63   size_t size_;
64   friend CommSendTransition;
65   friend CommRecvTransition;
66
67 public:
68   CommTestTransition(aid_t issuer, int times_considered, std::stringstream& stream);
69   std::string to_string(bool verbose) const override;
70   bool depends(const Transition* other) const override;
71
72   /** Address of the corresponding Communication object in the application */
73   uintptr_t get_comm() const { return comm_; }
74   /** Sender ID */
75   aid_t get_sender() const { return sender_; }
76   /** Receiver ID */
77   aid_t get_receiver() const { return receiver_; }
78   /** Mailbox ID */
79   unsigned get_mailbox() const { return mbox_; }
80   /** Sender buffer */
81   uintptr_t get_sbuff() const { return sbuff_; }
82   /** Receiver buffer */
83   uintptr_t get_rbuff() const { return rbuff_; }
84   /** data size */
85   size_t get_size() const { return size_; }
86 };
87
88 class CommRecvTransition : public Transition {
89   uintptr_t comm_; /* Addr of the CommImpl */
90   unsigned mbox_;
91   uintptr_t rbuff_;
92   int tag_;
93
94 public:
95   CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream);
96   std::string to_string(bool verbose) const override;
97   bool depends(const Transition* other) const override;
98
99   /** Address of the corresponding Communication object in the application */
100   uintptr_t get_comm() const { return comm_; }
101   /** Mailbox ID */
102   unsigned get_mailbox() const { return mbox_; }
103   /** Receiver buffer */
104   uintptr_t get_rbuff() const { return rbuff_; }
105   /** If using SMPI, the tag */
106   int get_tag() const { return tag_; }
107 };
108
109 class CommSendTransition : public Transition {
110   uintptr_t comm_; /* Addr of the CommImpl */
111   unsigned mbox_;
112   uintptr_t sbuff_;
113   size_t size_;
114   int tag_;
115
116 public:
117   CommSendTransition(aid_t issuer, int times_considered, std::stringstream& stream);
118   std::string to_string(bool verbose) const override;
119   bool depends(const Transition* other) const override;
120
121   /** Address of the corresponding Communication object in the application */
122   uintptr_t get_comm() const { return comm_; }
123   /** Mailbox ID */
124   unsigned get_mailbox() const { return mbox_; }
125   /** Sender buffer */
126   uintptr_t get_sbuff() const { return sbuff_; }
127   /** data size */
128   size_t get_size() const { return size_; }
129   /** If using SMPI, the tag */
130   int get_tag() const { return tag_; }
131 };
132
133 /** Make a new transition from serialized description */
134 Transition* deserialize_transition(aid_t issuer, int times_considered, std::stringstream& stream);
135
136 } // namespace simgrid::mc
137
138 #endif