Logo AND Algorithmique Numérique Distribuée

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