Logo AND Algorithmique Numérique Distribuée

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