Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1bef9c1265848243aa97f1ca4d6a4810f7b09bcd
[simgrid.git] / src / mc / mc_comm_pattern.h
1 /* Copyright (c) 2007-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SIMGRID_MC_COMM_PATTERN_H
8 #define SIMGRID_MC_COMM_PATTERN_H
9
10 #include <cstddef>
11 #include <cstring>
12
13 #include <string>
14 #include <vector>
15
16 #include <simgrid_config.h>
17 #include <xbt/dynar.h>
18
19 #include "src/simix/smx_private.h"
20 #include "src/smpi/private.h"
21 #include <smpi/smpi.h>
22
23 #include "src/mc/mc_state.h"
24
25 namespace simgrid {
26 namespace mc {
27
28 struct PatternCommunication {
29   int num = 0;
30   smx_synchro_t comm_addr;
31   e_smx_comm_type_t type = SIMIX_COMM_SEND;
32   unsigned long src_proc = 0;
33   unsigned long dst_proc = 0;
34   const char *src_host = nullptr;
35   const char *dst_host = nullptr;
36   std::string rdv;
37   std::vector<char> data;
38   int tag = 0;
39   int index = 0;
40
41   PatternCommunication()
42   {
43     std::memset(&comm_addr, 0, sizeof(comm_addr));
44   }
45
46   PatternCommunication dup() const
47   {
48     simgrid::mc::PatternCommunication res;
49     // num?
50     res.comm_addr = this->comm_addr;
51     res.type = this->type;
52     // src_proc?
53     // dst_proc?
54     res.dst_proc = this->dst_proc;
55     res.dst_host = this->dst_host;
56     res.rdv = this->rdv;
57     res.data = this->data;
58     // tag?
59     res.index = this->index;
60     return res;
61   }
62
63 };
64
65 struct PatternCommunicationList {
66   unsigned int index_comm = 0;
67   xbt_dynar_t list = nullptr;
68
69   PatternCommunicationList() {}
70   ~PatternCommunicationList()
71   {
72     xbt_dynar_free(&(this->list));
73   }
74 };
75
76 }
77 }
78
79 SG_BEGIN_DECL()
80
81 /**
82  *  Type: `xbt_dynar_t<mc_list_comm_pattenr_t>`
83  */
84 extern XBT_PRIVATE xbt_dynar_t initial_communications_pattern;
85
86 /**
87  *  Type: `xbt_dynar_t<xbt_dynar_t<simgrid::mc::PatternCommunication*>>`
88  */
89 extern XBT_PRIVATE xbt_dynar_t incomplete_communications_pattern;
90
91 typedef enum {
92   MC_CALL_TYPE_NONE,
93   MC_CALL_TYPE_SEND,
94   MC_CALL_TYPE_RECV,
95   MC_CALL_TYPE_WAIT,
96   MC_CALL_TYPE_WAITANY,
97 } e_mc_call_type_t;
98
99 typedef enum {
100   NONE_DIFF,
101   TYPE_DIFF,
102   RDV_DIFF,
103   TAG_DIFF,
104   SRC_PROC_DIFF,
105   DST_PROC_DIFF,
106   DATA_SIZE_DIFF,
107   DATA_DIFF,
108 } e_mc_comm_pattern_difference_t;
109
110 static inline e_mc_call_type_t MC_get_call_type(smx_simcall_t req)
111 {
112   switch(req->call) {
113   case SIMCALL_COMM_ISEND:
114     return MC_CALL_TYPE_SEND;
115   case SIMCALL_COMM_IRECV:
116     return MC_CALL_TYPE_RECV;
117   case SIMCALL_COMM_WAIT:
118     return MC_CALL_TYPE_WAIT;
119   case SIMCALL_COMM_WAITANY:
120     return MC_CALL_TYPE_WAITANY;
121   default:
122     return MC_CALL_TYPE_NONE;
123   }
124 }
125
126 XBT_PRIVATE void MC_get_comm_pattern(xbt_dynar_t communications_pattern, smx_simcall_t request, e_mc_call_type_t call_type, int backtracking);
127 XBT_PRIVATE void MC_handle_comm_pattern(e_mc_call_type_t call_type, smx_simcall_t request, int value, xbt_dynar_t current_pattern, int backtracking);
128 XBT_PRIVATE void MC_complete_comm_pattern(xbt_dynar_t list, smx_synchro_t comm_addr, unsigned int issuer, int backtracking);
129
130 XBT_PRIVATE void MC_restore_communications_pattern(simgrid::mc::State* state);
131
132 XBT_PRIVATE void MC_state_copy_incomplete_communications_pattern(simgrid::mc::State* state);
133 XBT_PRIVATE void MC_state_copy_index_communications_pattern(simgrid::mc::State* state);
134
135 SG_END_DECL()
136
137 #endif