1 /* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef SIMGRID_KERNEL_ACTIVITY_COMM_HPP
7 #define SIMGRID_KERNEL_ACTIVITY_COMM_HPP
9 #include "src/kernel/activity/ActivityImpl.hpp"
10 #include "src/simix/ActorImpl.hpp"
11 #include "surf/surf.hpp"
18 class XBT_PUBLIC CommImpl : public ActivityImpl {
23 enum class Type { SEND = 0, RECEIVE, READY, DONE };
25 explicit CommImpl(Type type);
28 void suspend() override;
29 void resume() override;
31 void finish() override;
35 CommImpl::Type type; /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
36 smx_mailbox_t mbox = nullptr; /* Rendez-vous where the comm is queued */
39 smx_mailbox_t mbox_cpy = nullptr; /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR
40 (comm.mbox set to nullptr when the communication is removed from the mailbox
41 (used as garbage collector)) */
43 bool detached = false; /* If detached or not */
45 void (*clean_fun)(void*) = nullptr; /* Function to clean the detached src_buf if something goes wrong */
46 int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*) =
47 nullptr; /* Filter function used by the other side. It is used when
48 looking if a given communication matches my needs. For that, myself must match the
49 expectations of the other side, too. See */
50 void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t) = nullptr;
52 /* Surf action data */
53 resource::Action* surf_action_ = nullptr; /* The Surf communication action encapsulated */
54 resource::Action* src_timeout_ = nullptr; /* Surf's actions to instrument the timeouts */
55 resource::Action* dst_timeout_ = nullptr; /* Surf's actions to instrument the timeouts */
56 actor::ActorImplPtr src_actor_ = nullptr;
57 actor::ActorImplPtr dst_actor_ = nullptr;
59 double task_size_ = 0.0;
61 /* Data to be transfered */
62 void* src_buff_ = nullptr;
63 void* dst_buff_ = nullptr;
64 size_t src_buff_size_ = 0;
65 size_t* dst_buff_size_ = nullptr;
66 bool copied = false; /* whether the data were already copied */
68 void* src_data_ = nullptr; /* User data associated to the communication */
69 void* dst_data_ = nullptr;
73 } // namespace simgrid::kernel::activity