-#include "src/surf/cpu_interface.hpp"
-#include "src/surf/network_interface.hpp"
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_network, simix, "SIMIX network-related synchronization");
-
-XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t src, smx_mailbox_t mbox, double task_size,
- double rate, unsigned char* src_buff, size_t src_buff_size,
- bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
- void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
- void* data, double timeout)
-{
- simgrid::kernel::activity::ActivityImplPtr comm = simcall_HANDLER_comm_isend(
- simcall, src, mbox, task_size, rate, src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, false);
- simcall->mc_value_ = 0;
- comm->wait_for(simcall->issuer_, timeout);
-}
-
-XBT_PRIVATE simgrid::kernel::activity::ActivityImplPtr simcall_HANDLER_comm_isend(
- smx_simcall_t /*simcall*/, smx_actor_t src_proc, smx_mailbox_t mbox, double task_size, double rate,
- unsigned char* src_buff, size_t src_buff_size,
- bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
- void (*clean_fun)(void*), // used to free the synchro in case of problem after a detached send
- void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), // used to copy data if not default one
- void* data, bool detached)
-{
- XBT_DEBUG("send from mailbox %p", mbox);
-
- /* Prepare a synchro describing us, so that it gets passed to the user-provided filter of other side */
- simgrid::kernel::activity::CommImplPtr this_comm(
- new simgrid::kernel::activity::CommImpl(simgrid::kernel::activity::CommImpl::Type::SEND));
-
- /* Look for communication synchro matching our needs. We also provide a description of
- * ourself so that the other side also gets a chance of choosing if it wants to match with us.
- *
- * If it is not found then push our communication into the rendez-vous point */
- simgrid::kernel::activity::CommImplPtr other_comm =
- mbox->find_matching_comm(simgrid::kernel::activity::CommImpl::Type::RECEIVE, match_fun, data, this_comm,
- /*done*/ false, /*remove_matching*/ true);
-
- if (not other_comm) {
- other_comm = std::move(this_comm);
-
- if (mbox->is_permanent()) {
- // this mailbox is for small messages, which have to be sent right now
- other_comm->state_ = simgrid::kernel::activity::State::READY;
- other_comm->dst_actor_ = mbox->get_permanent_receiver().get();
- mbox->push_done(other_comm);
- XBT_DEBUG("pushing a message into the permanent receive list %p, comm %p", mbox, other_comm.get());
-
- } else {
- mbox->push(other_comm);
- }
- } else {
- XBT_DEBUG("Receive already pushed");
-
- other_comm->state_ = simgrid::kernel::activity::State::READY;
- }
-
- if (detached) {
- other_comm->detach();
- other_comm->clean_fun = clean_fun;
- } else {
- other_comm->clean_fun = nullptr;
- src_proc->activities_.emplace_back(other_comm);
- }
-
- /* Setup the communication synchro */
- other_comm->src_actor_ = src_proc;
- other_comm->src_data_ = data;
- (*other_comm).set_src_buff(src_buff, src_buff_size).set_size(task_size).set_rate(rate);
-
- other_comm->match_fun = match_fun;
- other_comm->copy_data_fun = copy_data_fun;
-
- if (MC_is_active() || MC_record_replay_is_active())
- other_comm->state_ = simgrid::kernel::activity::State::RUNNING;
- else
- other_comm->start();
-
- return (detached ? nullptr : other_comm);
-}
-
-XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox,
- unsigned char* dst_buff, size_t* dst_buff_size,
- bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
- void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
- void* data, double timeout, double rate)
-{
- simgrid::kernel::activity::ActivityImplPtr comm = simcall_HANDLER_comm_irecv(
- simcall, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate);
- simcall->mc_value_ = 0;
- comm->wait_for(simcall->issuer_, timeout);
-}
-
-XBT_PRIVATE simgrid::kernel::activity::ActivityImplPtr
-simcall_HANDLER_comm_irecv(smx_simcall_t /*simcall*/, smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff,
- size_t* dst_buff_size, bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
- void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data,
- double rate)
-{
- simgrid::kernel::activity::CommImplPtr this_synchro(
- new simgrid::kernel::activity::CommImpl(simgrid::kernel::activity::CommImpl::Type::RECEIVE));
- XBT_DEBUG("recv from mbox %p. this_synchro=%p", mbox, this_synchro.get());