Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
4aab5a0854529f7345d03be8ae552a03c31d29c5
[simgrid.git] / src / mc / mc_comm_pattern.hpp
1 /* Copyright (c) 2007-2019. 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_COMM_PATTERN_H
7 #define SIMGRID_MC_COMM_PATTERN_H
8
9 #include <vector>
10
11 #include "smpi/smpi.h"
12 #include "xbt/dynar.h"
13
14 #include "src/mc/mc_state.hpp"
15
16 namespace simgrid {
17 namespace mc {
18
19 struct PatternCommunicationList {
20   unsigned int index_comm = 0;
21   std::vector<std::unique_ptr<simgrid::mc::PatternCommunication>> list;
22 };
23 }
24 }
25
26 /**
27  *  Type: `xbt_dynar_t<mc_list_comm_pattern_t>`
28  */
29 extern XBT_PRIVATE xbt_dynar_t initial_communications_pattern;
30
31 /**
32  *  Type: `xbt_dynar_t<xbt_dynar_t<simgrid::mc::PatternCommunication*>>`
33  */
34 extern XBT_PRIVATE xbt_dynar_t incomplete_communications_pattern;
35
36 enum e_mc_call_type_t {
37   MC_CALL_TYPE_NONE,
38   MC_CALL_TYPE_SEND,
39   MC_CALL_TYPE_RECV,
40   MC_CALL_TYPE_WAIT,
41   MC_CALL_TYPE_WAITANY,
42 };
43
44 enum e_mc_comm_pattern_difference_t {
45   NONE_DIFF,
46   TYPE_DIFF,
47   RDV_DIFF,
48   TAG_DIFF,
49   SRC_PROC_DIFF,
50   DST_PROC_DIFF,
51   DATA_SIZE_DIFF,
52   DATA_DIFF,
53 };
54
55 static inline e_mc_call_type_t MC_get_call_type(smx_simcall_t req)
56 {
57   switch (req->call) {
58     case SIMCALL_COMM_ISEND:
59       return MC_CALL_TYPE_SEND;
60     case SIMCALL_COMM_IRECV:
61       return MC_CALL_TYPE_RECV;
62     case SIMCALL_COMM_WAIT:
63       return MC_CALL_TYPE_WAIT;
64     case SIMCALL_COMM_WAITANY:
65       return MC_CALL_TYPE_WAITANY;
66     default:
67       return MC_CALL_TYPE_NONE;
68   }
69 }
70
71 XBT_PRIVATE void MC_handle_comm_pattern(e_mc_call_type_t call_type, smx_simcall_t request, int value,
72                                         xbt_dynar_t current_pattern, int backtracking);
73
74 XBT_PRIVATE void MC_restore_communications_pattern(simgrid::mc::State* state);
75
76 XBT_PRIVATE void MC_state_copy_incomplete_communications_pattern(simgrid::mc::State* state);
77 XBT_PRIVATE void MC_state_copy_index_communications_pattern(simgrid::mc::State* state);
78
79 #endif