Logo AND Algorithmique Numérique Distribuée

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