Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Use RAII std::string for s_mc_comm_pattern::rdv
[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
15 #include <simgrid_config.h>
16 #include <xbt/dynar.h>
17
18 #include "src/simix/smx_private.h"
19 #include "src/smpi/private.h"
20 #include <smpi/smpi.h>
21
22 #include "src/mc/mc_state.h"
23
24 SG_BEGIN_DECL()
25
26 typedef struct s_mc_comm_pattern{
27   int num = 0;
28   smx_synchro_t comm_addr;
29   e_smx_comm_type_t type = SIMIX_COMM_SEND;
30   unsigned long src_proc = 0;
31   unsigned long dst_proc = 0;
32   const char *src_host = nullptr;
33   const char *dst_host = nullptr;
34   std::string rdv;
35   ssize_t data_size = 0;
36   void *data = nullptr;
37   int tag = 0;
38   int index = 0;
39
40   s_mc_comm_pattern()
41   {
42     std::memset(&comm_addr, 0, sizeof(comm_addr));
43   }
44   ~s_mc_comm_pattern()
45   {
46     xbt_free(this->data);
47   }
48
49   // No copy:
50   s_mc_comm_pattern(s_mc_comm_pattern const&) = delete;
51   s_mc_comm_pattern& operator=(s_mc_comm_pattern const&) = delete;
52
53 } s_mc_comm_pattern_t, *mc_comm_pattern_t;
54
55 typedef struct s_mc_list_comm_pattern{
56   unsigned int index_comm;
57   xbt_dynar_t list;
58 }s_mc_list_comm_pattern_t, *mc_list_comm_pattern_t;
59
60 /**
61  *  Type: `xbt_dynar_t<mc_list_comm_pattenr_t>`
62  */
63 extern XBT_PRIVATE xbt_dynar_t initial_communications_pattern;
64
65 /**
66  *  Type: `xbt_dynar_t<xbt_dynar_t<mc_comm_pattern_t>>`
67  */
68 extern XBT_PRIVATE xbt_dynar_t incomplete_communications_pattern;
69
70 typedef enum {
71   MC_CALL_TYPE_NONE,
72   MC_CALL_TYPE_SEND,
73   MC_CALL_TYPE_RECV,
74   MC_CALL_TYPE_WAIT,
75   MC_CALL_TYPE_WAITANY,
76 } e_mc_call_type_t;
77
78 typedef enum {
79   NONE_DIFF,
80   TYPE_DIFF,
81   RDV_DIFF,
82   TAG_DIFF,
83   SRC_PROC_DIFF,
84   DST_PROC_DIFF,
85   DATA_SIZE_DIFF,
86   DATA_DIFF,
87 } e_mc_comm_pattern_difference_t;
88
89 static inline e_mc_call_type_t MC_get_call_type(smx_simcall_t req)
90 {
91   switch(req->call) {
92   case SIMCALL_COMM_ISEND:
93     return MC_CALL_TYPE_SEND;
94   case SIMCALL_COMM_IRECV:
95     return MC_CALL_TYPE_RECV;
96   case SIMCALL_COMM_WAIT:
97     return MC_CALL_TYPE_WAIT;
98   case SIMCALL_COMM_WAITANY:
99     return MC_CALL_TYPE_WAITANY;
100   default:
101     return MC_CALL_TYPE_NONE;
102   }
103 }
104
105 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);
106 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);
107 XBT_PRIVATE void MC_comm_pattern_free_voidp(void *p);
108 XBT_PRIVATE void MC_list_comm_pattern_free_voidp(void *p);
109 XBT_PRIVATE void MC_complete_comm_pattern(xbt_dynar_t list, smx_synchro_t comm_addr, unsigned int issuer, int backtracking);
110
111 XBT_PRIVATE void MC_restore_communications_pattern(simgrid::mc::State* state);
112
113 XBT_PRIVATE mc_comm_pattern_t MC_comm_pattern_dup(mc_comm_pattern_t comm);
114 XBT_PRIVATE xbt_dynar_t MC_comm_patterns_dup(xbt_dynar_t state);
115
116 XBT_PRIVATE void MC_state_copy_incomplete_communications_pattern(simgrid::mc::State* state);
117 XBT_PRIVATE void MC_state_copy_index_communications_pattern(simgrid::mc::State* state);
118
119 XBT_PRIVATE void MC_comm_pattern_free(mc_comm_pattern_t p);
120
121 SG_END_DECL()
122
123 #endif