Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add start and copy_data methods to CommImpl
[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 "src/simix/ActorImpl.hpp"
11 #include "surf/surf.hpp"
12
13 enum e_smx_comm_type_t { SIMIX_COMM_SEND, SIMIX_COMM_RECEIVE, SIMIX_COMM_READY, SIMIX_COMM_DONE };
14
15 namespace simgrid {
16 namespace kernel {
17 namespace activity {
18
19 class XBT_PUBLIC CommImpl : public ActivityImpl {
20   ~CommImpl() override;
21
22 public:
23   explicit CommImpl(e_smx_comm_type_t type);
24   void start();
25   void copy_data();
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 SIMGRID_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*, simgrid::kernel::activity::CommImpl*) =
45       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   resource::Action* surf_action_ = nullptr; /* The Surf communication action encapsulated */
52   resource::Action* src_timeout_ = nullptr; /* Surf's actions to instrument the timeouts */
53   resource::Action* dst_timeout_ = nullptr; /* Surf's actions to instrument the timeouts */
54   actor::ActorImplPtr src_actor_ = nullptr;
55   actor::ActorImplPtr dst_actor_ = 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 the communication */
67   void* dst_data_ = nullptr;
68 };
69 }
70 }
71 } // namespace simgrid::kernel::activity
72
73 #endif