Logo AND Algorithmique Numérique Distribuée

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