Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a3a59babe1613e48c39f6c3773c2ab95f6c20f88
[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   friend CommRecvTransition;
29   friend CommSendTransition;
30   friend CommTestTransition;
31
32 public:
33   CommWaitTransition(aid_t issuer, int times_considered, bool timeout_, unsigned comm_, aid_t sender_, aid_t receiver_,
34                      unsigned mbox_);
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   /** ID of the corresponding Communication object in the application, or 0 if unknown */
41   unsigned 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 };
49 class CommTestTransition : public Transition {
50   unsigned comm_;
51   unsigned mbox_;
52   aid_t sender_;
53   aid_t receiver_;
54   friend CommSendTransition;
55   friend CommRecvTransition;
56
57 public:
58   CommTestTransition(aid_t issuer, int times_considered, unsigned comm_, aid_t sender_, aid_t receiver_,
59                      unsigned mbox_);
60   CommTestTransition(aid_t issuer, int times_considered, std::stringstream& stream);
61   std::string to_string(bool verbose) const override;
62   bool depends(const Transition* other) const override;
63
64   /** ID of the corresponding Communication object in the application, or 0 if unknown */
65   unsigned get_comm() const { return comm_; }
66   /** Sender ID */
67   aid_t get_sender() const { return sender_; }
68   /** Receiver ID */
69   aid_t get_receiver() const { return receiver_; }
70   /** Mailbox ID */
71   unsigned get_mailbox() const { return mbox_; }
72 };
73
74 class CommRecvTransition : public Transition {
75   unsigned comm_; /* ID of the CommImpl or 0 if not known */
76   unsigned mbox_;
77   int tag_;
78
79 public:
80   CommRecvTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_, int tag_);
81   CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream);
82   std::string to_string(bool verbose) const override;
83   bool depends(const Transition* other) const override;
84
85   /** ID of the corresponding Communication object in the application (or 0 if unknown)*/
86   unsigned get_comm() const { return comm_; }
87   /** Mailbox ID */
88   unsigned get_mailbox() const { return mbox_; }
89   /** If using SMPI, the tag */
90   int get_tag() const { return tag_; }
91 };
92
93 class CommSendTransition : public Transition {
94   unsigned comm_;
95   unsigned mbox_;
96   int tag_;
97
98 public:
99   CommSendTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_, int tag_);
100   CommSendTransition(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   /** If using SMPI, the tag */
109   int get_tag() const { return tag_; }
110 };
111
112 /** Make a new transition from serialized description */
113 Transition* deserialize_transition(aid_t issuer, int times_considered, std::stringstream& stream);
114
115 } // namespace simgrid::mc
116
117 #endif