A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Merge branch 'models_type_rework_part2_try2' into 'master'
[simgrid.git]
/
src
/
s4u
/
s4u_Comm.cpp
diff --git
a/src/s4u/s4u_Comm.cpp
b/src/s4u/s4u_Comm.cpp
index f9c3c37deabf26435f14ada57aa5fa9d8fa592f7..23eaf0d2dcdf7f163b66a6d57c69edcf715efb76 100644
(file)
--- a/
src/s4u/s4u_Comm.cpp
+++ b/
src/s4u/s4u_Comm.cpp
@@
-23,9
+23,9
@@
Comm::~Comm()
{
if (state_ == State::STARTED && not detached_ &&
(pimpl_ == nullptr || pimpl_->state_ == kernel::activity::State::RUNNING)) {
- XBT_INFO("Comm %p freed before its completion. D
etached: %d, State: %d", this, detached_, (int)state_
);
+ XBT_INFO("Comm %p freed before its completion. D
id you forget to detach it? (state: %s)", this, get_state_str()
);
if (pimpl_ != nullptr)
- XBT_INFO("pimpl_->state: %
d", static_cast<int>(pimpl_->state_
));
+ XBT_INFO("pimpl_->state: %
s", pimpl_->get_state_str(
));
else
XBT_INFO("pimpl_ is null");
xbt_backtrace_display_current();
@@
-38,8
+38,10
@@
int Comm::wait_any_for(const std::vector<CommPtr>* comms, double timeout)
std::transform(begin(*comms), end(*comms), begin(rcomms),
[](const CommPtr& comm) { return static_cast<kernel::activity::CommImpl*>(comm->pimpl_.get()); });
int changed_pos = simcall_comm_waitany(rcomms.data(), rcomms.size(), timeout);
- if (changed_pos != -1)
+ if (changed_pos != -1) {
+ on_completion(*(comms->at(changed_pos)));
comms->at(changed_pos)->release_dependencies();
+ }
return changed_pos;
}
@@
-114,6
+116,11
@@
CommPtr Comm::set_dst_data(void** buff, size_t size)
dst_buff_size_ = size;
return this;
}
+CommPtr Comm::set_payload_size(double bytes)
+{
+ Activity::set_remaining(bytes);
+ return this;
+}
CommPtr Comm::sendto_init(Host* from, Host* to)
{
@@
-123,13
+130,19
@@
CommPtr Comm::sendto_init(Host* from, Host* to)
return res;
}
+
CommPtr Comm::sendto_async(Host* from, Host* to, double simulated_size_in_bytes)
{
- auto res = Comm::sendto_init(from, to);
- res->
set_remaining(simulated_size_in_bytes)->
start();
+ auto res = Comm::sendto_init(from, to)
->set_payload_size(simulated_size_in_bytes)
;
+ res->
vetoable_
start();
return res;
}
+void Comm::sendto(Host* from, Host* to, double simulated_size_in_bytes)
+{
+ sendto_async(from, to, simulated_size_in_bytes)->wait();
+}
+
Comm* Comm::start()
{
xbt_assert(get_state() == State::INITED || get_state() == State::STARTING,
@@
-139,7
+152,7
@@
Comm* Comm::start()
xbt_assert(src_buff_ == nullptr && dst_buff_ == nullptr,
"Direct host-to-host communications cannot carry any data.");
pimpl_ = kernel::actor::simcall([this] {
-
auto res = new kernel::activity::CommImpl(this->from_, this->to_, this->get_remaining(
));
+
kernel::activity::CommImplPtr res(new kernel::activity::CommImpl(this->from_, this->to_, this->get_remaining()
));
res->start();
return res;
});
@@
-186,7
+199,7
@@
Comm* Comm::wait_for(double timeout)
case State::INITED:
case State::STARTING: // It's not started yet. Do it in one simcall if it's a regular communication
if (from_ != nullptr || to_ != nullptr) {
- return start()->wait_for(timeout); // In the case of host2host comm, do it in two simcalls
+ return
vetoable_
start()->wait_for(timeout); // In the case of host2host comm, do it in two simcalls
} else if (src_buff_ != nullptr) {
on_start(*this, true /*is_sender*/);
simcall_comm_send(sender_, mailbox_->get_impl(), remains_, rate_, src_buff_, src_buff_size_, match_fun_,
@@
-230,9
+243,9
@@
int Comm::test_any(const std::vector<CommPtr>* comms)
Comm* Comm::detach()
{
- xbt_assert(state_ == State::INITED, "You cannot use %s() once your communication
started
(not implemented)",
- __FUNCTION__);
- xbt_assert(
src_buff_ != nullptr && src_buff_size_ !
= 0, "You can only detach sends, not recvs");
+ xbt_assert(state_ == State::INITED, "You cannot use %s() once your communication
is %s
(not implemented)",
+ __FUNCTION__
, get_state_str()
);
+ xbt_assert(
dst_buff_ == nullptr && dst_buff_size_ =
= 0, "You can only detach sends, not recvs");
detached_ = true;
vetoable_start();
return this;