Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Use vector<RegionSnapshot> instead of vector<unique_ptr<RegionSnapshot>> in...
[simgrid.git] / src / mc / mc_smx.h
1 /* Copyright (c) 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 MC_SMX_H
8 #define MC_SMX_H
9
10 #include <stddef.h>
11
12 #include <xbt/log.h>
13 #include <simgrid/simix.h>
14
15 #include "smpi/private.h"
16
17 #include "mc_process.h"
18 #include "mc_protocol.h"
19
20 /** @file
21  *  @brief (Cross-process, MCer/MCed) Access to SMX structures
22  *
23  *  We copy some C data structure from the MCed process in the MCer process.
24  *  This is implemented by:
25  *
26  *   - `model_checker->process.smx_process_infos`
27  *      (copy of `simix_global->process_list`);
28  *
29  *   - `model_checker->process.smx_old_process_infos`
30  *      (copy of `simix_global->process_to_destroy`);
31  *
32  *   - `model_checker->hostnames`.
33  *
34  * The process lists are currently refreshed each time MCed code is executed.
35  * We don't try to give a persistent MCer address for a given MCed process.
36  * For this reason, a MCer mc_process_t is currently not reusable after
37  * MCed code.
38  */
39
40 SG_BEGIN_DECL()
41
42 struct s_mc_smx_process_info {
43   /** MCed address of the process */
44   void* address;
45   /** (Flat) Copy of the process data structure */
46   struct s_smx_process copy;
47   /** Hostname (owned by `mc_modelchecker->hostnames`) */
48   const char* hostname;
49   char* name;
50 };
51
52 XBT_INTERNAL xbt_dynar_t MC_smx_process_info_list_new(void);
53
54 XBT_INTERNAL void MC_process_smx_refresh(mc_process_t process);
55
56 /** Get the issuer of  a simcall (`req->issuer`)
57  *
58  *  In split-process mode, it does the black magic necessary to get an address
59  *  of a (shallow) copy of the data structure the issuer SIMIX process in the local
60  *  address space.
61  *
62  *  @param process the MCed process
63  *  @param req     the simcall (copied in the local process)
64  */
65 XBT_INTERNAL smx_process_t MC_smx_simcall_get_issuer(smx_simcall_t req);
66
67 XBT_INTERNAL const char* MC_smx_process_get_name(smx_process_t p);
68 XBT_INTERNAL const char* MC_smx_process_get_host_name(smx_process_t p);
69
70 #define MC_EACH_SIMIX_PROCESS(process, code) \
71   if (mc_mode == MC_MODE_CLIENT) { \
72     xbt_swag_foreach(process, simix_global->process_list) { \
73       code; \
74     } \
75   } else { \
76     MC_process_smx_refresh(&mc_model_checker->process()); \
77     unsigned int _smx_process_index; \
78     mc_smx_process_info_t _smx_process_info; \
79     xbt_dynar_foreach_ptr(mc_model_checker->process().smx_process_infos, _smx_process_index, _smx_process_info) { \
80       smx_process_t process = &_smx_process_info->copy; \
81       code; \
82     } \
83   }
84
85 /** Execute a given simcall */
86 XBT_INTERNAL void MC_simcall_handle(smx_simcall_t req, int value);
87
88 XBT_INTERNAL int MC_smpi_process_count(void);
89
90
91 /* ***** Resolve (local/MCer structure from remote/MCed addresses) ***** */
92
93 /** Get a local copy of the process from the process remote address */
94 XBT_INTERNAL smx_process_t MC_smx_resolve_process(smx_process_t process_remote_address);
95
96 /** Get the process info structure from the process remote address */
97 XBT_INTERNAL mc_smx_process_info_t MC_smx_resolve_process_info(smx_process_t process_remote_address);
98
99 XBT_INTERNAL unsigned long MC_smx_get_maxpid(void);
100
101 SG_END_DECL()
102
103 #endif