Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Use std::vector for State::incomplete_comm_pattern (dexbtification)
[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 PatternCommunicationList {
29   unsigned int index_comm = 0;
30   xbt_dynar_t list = nullptr;
31
32   PatternCommunicationList() {}
33   ~PatternCommunicationList()
34   {
35     xbt_dynar_free(&(this->list));
36   }
37 };
38
39 }
40 }
41
42 SG_BEGIN_DECL()
43
44 /**
45  *  Type: `xbt_dynar_t<mc_list_comm_pattenr_t>`
46  */
47 extern XBT_PRIVATE xbt_dynar_t initial_communications_pattern;
48
49 /**
50  *  Type: `xbt_dynar_t<xbt_dynar_t<simgrid::mc::PatternCommunication*>>`
51  */
52 extern XBT_PRIVATE xbt_dynar_t incomplete_communications_pattern;
53
54 typedef enum {
55   MC_CALL_TYPE_NONE,
56   MC_CALL_TYPE_SEND,
57   MC_CALL_TYPE_RECV,
58   MC_CALL_TYPE_WAIT,
59   MC_CALL_TYPE_WAITANY,
60 } e_mc_call_type_t;
61
62 typedef enum {
63   NONE_DIFF,
64   TYPE_DIFF,
65   RDV_DIFF,
66   TAG_DIFF,
67   SRC_PROC_DIFF,
68   DST_PROC_DIFF,
69   DATA_SIZE_DIFF,
70   DATA_DIFF,
71 } e_mc_comm_pattern_difference_t;
72
73 static inline e_mc_call_type_t MC_get_call_type(smx_simcall_t req)
74 {
75   switch(req->call) {
76   case SIMCALL_COMM_ISEND:
77     return MC_CALL_TYPE_SEND;
78   case SIMCALL_COMM_IRECV:
79     return MC_CALL_TYPE_RECV;
80   case SIMCALL_COMM_WAIT:
81     return MC_CALL_TYPE_WAIT;
82   case SIMCALL_COMM_WAITANY:
83     return MC_CALL_TYPE_WAITANY;
84   default:
85     return MC_CALL_TYPE_NONE;
86   }
87 }
88
89 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);
90 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);
91 XBT_PRIVATE void MC_complete_comm_pattern(xbt_dynar_t list, smx_synchro_t comm_addr, unsigned int issuer, int backtracking);
92
93 XBT_PRIVATE void MC_restore_communications_pattern(simgrid::mc::State* state);
94
95 XBT_PRIVATE void MC_state_copy_incomplete_communications_pattern(simgrid::mc::State* state);
96 XBT_PRIVATE void MC_state_copy_index_communications_pattern(simgrid::mc::State* state);
97
98 SG_END_DECL()
99
100 #endif