Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Inline another stupid function
[simgrid.git] / src / mc / mc_pattern.hpp
1 /* Copyright (c) 2007-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_PATTERN_H
7 #define SIMGRID_MC_PATTERN_H
8
9 #include "src/kernel/activity/CommImpl.hpp"
10 #include "src/mc/remote/RemotePtr.hpp"
11
12 namespace simgrid {
13 namespace mc {
14
15 enum class PatternCommunicationType {
16   none    = 0,
17   send    = 1,
18   receive = 2,
19 };
20
21 class PatternCommunication {
22 public:
23   int num = 0;
24   RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr{nullptr};
25   PatternCommunicationType type = PatternCommunicationType::send;
26   unsigned long src_proc        = 0;
27   unsigned long dst_proc        = 0;
28   const xbt::string* src_host   = nullptr;
29   const xbt::string* dst_host   = nullptr;
30   std::string rdv;
31   std::vector<char> data;
32   int tag   = 0;
33   int index = 0;
34
35   PatternCommunication dup() const
36   {
37     simgrid::mc::PatternCommunication res;
38     // num?
39     res.comm_addr = this->comm_addr;
40     res.type      = this->type;
41     // src_proc?
42     // dst_proc?
43     res.dst_proc = this->dst_proc;
44     res.dst_host = this->dst_host;
45     res.rdv      = this->rdv;
46     res.data     = this->data;
47     // tag?
48     res.index = this->index;
49     return res;
50   }
51 };
52
53 /* On every state, each actor has an entry of the following type.
54  * This represents both the actor and its transition because
55  *   an actor cannot have more than one enabled transition at a given time.
56  */
57 class ActorState {
58   /* Possible exploration status of an actor transition in a state.
59    * Either the checker did not consider the transition, or it was considered and still to do, or considered and done.
60    */
61   enum class InterleavingType {
62     /** This actor transition is not considered by the checker (yet?) */
63     disabled = 0,
64     /** The checker algorithm decided that this actor transitions should be done at some point */
65     todo,
66     /** The checker algorithm decided that this should be done, but it was done in the meanwhile */
67     done,
68   };
69
70   /** Exploration control information */
71   InterleavingType state_ = InterleavingType::disabled;
72
73   /** Number of times that the process was considered to be executed */
74   unsigned int times_considered_ = 0;
75
76 public:
77   unsigned int get_times_considered() const { return times_considered_; }
78   unsigned int get_times_considered_and_inc() { return times_considered_++; }
79
80   bool is_disabled() const { return this->state_ == InterleavingType::disabled; }
81   bool is_done() const { return this->state_ == InterleavingType::done; }
82   bool is_todo() const { return this->state_ == InterleavingType::todo; }
83   /** Mark that we should try executing this process at some point in the future of the checker algorithm */
84   void mark_todo()
85   {
86     this->state_            = InterleavingType::todo;
87     this->times_considered_ = 0;
88   }
89   void set_done() { this->state_ = InterleavingType::done; }
90 };
91
92 } // namespace mc
93 } // namespace simgrid
94
95 #endif