1 /* Copyright (c) 2007-2015. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #ifndef SIMGRID_MC_COMM_PATTERN_H
8 #define SIMGRID_MC_COMM_PATTERN_H
16 #include <simgrid_config.h>
17 #include <xbt/dynar.h>
19 #include "src/simix/smx_private.h"
20 #include "src/smpi/private.h"
21 #include <smpi/smpi.h>
23 #include "src/mc/mc_state.h"
28 struct PatternCommunication {
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;
37 std::vector<char> data;
41 PatternCommunication()
43 std::memset(&comm_addr, 0, sizeof(comm_addr));
47 PatternCommunication(PatternCommunication const&) = delete;
48 PatternCommunication& operator=(PatternCommunication const&) = delete;
52 struct PatternCommunicationList {
53 unsigned int index_comm = 0;
54 xbt_dynar_t list = nullptr;
56 PatternCommunicationList() {}
57 ~PatternCommunicationList()
59 xbt_dynar_free(&(this->list));
69 * Type: `xbt_dynar_t<mc_list_comm_pattenr_t>`
71 extern XBT_PRIVATE xbt_dynar_t initial_communications_pattern;
74 * Type: `xbt_dynar_t<xbt_dynar_t<simgrid::mc::PatternCommunication*>>`
76 extern XBT_PRIVATE xbt_dynar_t incomplete_communications_pattern;
95 } e_mc_comm_pattern_difference_t;
97 static inline e_mc_call_type_t MC_get_call_type(smx_simcall_t req)
100 case SIMCALL_COMM_ISEND:
101 return MC_CALL_TYPE_SEND;
102 case SIMCALL_COMM_IRECV:
103 return MC_CALL_TYPE_RECV;
104 case SIMCALL_COMM_WAIT:
105 return MC_CALL_TYPE_WAIT;
106 case SIMCALL_COMM_WAITANY:
107 return MC_CALL_TYPE_WAITANY;
109 return MC_CALL_TYPE_NONE;
113 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);
114 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);
115 XBT_PRIVATE void MC_complete_comm_pattern(xbt_dynar_t list, smx_synchro_t comm_addr, unsigned int issuer, int backtracking);
117 XBT_PRIVATE void MC_restore_communications_pattern(simgrid::mc::State* state);
119 XBT_PRIVATE simgrid::mc::PatternCommunication* MC_comm_pattern_dup(simgrid::mc::PatternCommunication* comm);
120 XBT_PRIVATE xbt_dynar_t MC_comm_patterns_dup(xbt_dynar_t state);
122 XBT_PRIVATE void MC_state_copy_incomplete_communications_pattern(simgrid::mc::State* state);
123 XBT_PRIVATE void MC_state_copy_index_communications_pattern(simgrid::mc::State* state);