Logo AND Algorithmique Numérique Distribuée

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