Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
turn SIMIX_comm_new() into a proper constructor
[simgrid.git] / src / simix / SynchroComm.hpp
1 /* Copyright (c) 2007-2016. 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 _SIMIX_SYNCHRO_COMM_HPP
7 #define _SIMIX_SYNCHRO_COMM_HPP
8
9 #include "surf/surf.h"
10 #include "src/simix/Synchro.h"
11
12 typedef enum {
13   SIMIX_COMM_SEND,
14   SIMIX_COMM_RECEIVE,
15   SIMIX_COMM_READY,
16   SIMIX_COMM_DONE
17 } e_smx_comm_type_t;
18
19 namespace simgrid {
20 namespace simix {
21
22   XBT_PUBLIC_CLASS Comm : public Synchro {
23   public:
24     Comm(e_smx_comm_type_t type);
25     void suspend();
26     void resume();
27     void cancel();
28
29     e_smx_comm_type_t type;         /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
30     smx_mailbox_t mbox = nullptr;   /* Rendez-vous where the comm is queued */
31
32 #if HAVE_MC
33     smx_mailbox_t mbox_cpy;         /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR
34                                        (comm.mbox set to NULL when the communication is removed from the mailbox
35                                        (used as garbage collector)) */
36 #endif
37     int refcount = 1;               /* Number of processes involved in the cond */
38     int detached = 0;               /* If detached or not */
39
40     void (*clean_fun)(void*);       /* Function to clean the detached src_buf if something goes wrong */
41     int (*match_fun)(void*,void*,smx_synchro_t);  /* Filter function used by the other side. It is used when
42                                        looking if a given communication matches my needs. For that, myself must match the
43                                        expectations of the other side, too. See  */
44     void (*copy_data_fun) (smx_synchro_t, void*, size_t);
45
46     /* Surf action data */
47     surf_action_t surf_comm = nullptr;        /* The Surf communication action encapsulated */
48     surf_action_t src_timeout = nullptr;      /* Surf's actions to instrument the timeouts */
49     surf_action_t dst_timeout = nullptr;      /* Surf's actions to instrument the timeouts */
50     smx_process_t src_proc = nullptr;
51     smx_process_t dst_proc = nullptr;
52     double rate;
53     double task_size;
54
55     /* Data to be transfered */
56     void *src_buff = nullptr;
57     void *dst_buff = nullptr;
58     size_t src_buff_size;
59     size_t *dst_buff_size;
60     unsigned copied = 0;          /* whether the data were already copied */
61
62     void* src_data;                 /* User data associated to communication */
63     void* dst_data;
64   };
65
66 }} // namespace simgrid::simix
67
68 #endif