Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move the synchronization stuff to its own directory
[simgrid.git] / src / synchro / 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/synchro/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     ~Comm() override;
24   public:
25     explicit Comm(e_smx_comm_type_t type);
26     void suspend() override;
27     void resume() override;
28     void post() override;
29     void cancel();
30     double remains();
31     void cleanupSurf(); // FIXME: make me protected
32
33     e_smx_comm_type_t type;         /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
34     smx_mailbox_t mbox = nullptr;   /* Rendez-vous where the comm is queued */
35
36 #if HAVE_MC
37     smx_mailbox_t mbox_cpy = nullptr; /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR
38                                        (comm.mbox set to nullptr when the communication is removed from the mailbox
39                                        (used as garbage collector)) */
40 #endif
41     bool detached = false;          /* If detached or not */
42
43     void (*clean_fun)(void*) = nullptr; /* Function to clean the detached src_buf if something goes wrong */
44     int (*match_fun)(void*,void*,smx_synchro_t) = nullptr;  /* Filter function used by the other side. It is used when
45                                        looking if a given communication matches my needs. For that, myself must match the
46                                        expectations of the other side, too. See  */
47     void (*copy_data_fun) (smx_synchro_t, void*, size_t) =nullptr;
48
49     /* Surf action data */
50     surf_action_t surf_comm = nullptr;        /* The Surf communication action encapsulated */
51     surf_action_t src_timeout = nullptr;      /* Surf's actions to instrument the timeouts */
52     surf_action_t dst_timeout = nullptr;      /* Surf's actions to instrument the timeouts */
53     smx_process_t src_proc = nullptr;
54     smx_process_t dst_proc = nullptr;
55     double rate = 0.0;
56     double task_size = 0.0;
57
58     /* Data to be transfered */
59     void *src_buff = nullptr;
60     void *dst_buff = nullptr;
61     size_t src_buff_size = 0;
62     size_t *dst_buff_size = nullptr;
63     bool copied = false;         /* whether the data were already copied */
64
65     void* src_data = nullptr;    /* User data associated to communication */
66     void* dst_data = nullptr;
67   };
68
69 }} // namespace simgrid::simix
70
71 #endif