Commit 73697154 authored by Fred Suter's avatar Fred Suter
Browse files

Enable setting a specific data copy callback to any comm

This is becoming mandatory if one has the silly idea to mix SMPI
communications and S4U communications within the same simulation
launched with smpirun.

smpirun sets its own callback for ALL comms in smpi_main and thus
consider that averything is a SMPI communication. If you need to
trick SMPI to have S4U comms on the side, you thus have to
override this callback:

Sender side:
  mbox->put_init(payload, size)
      ->set_copy_data_callback(SIMIX_comm_copy_pointer_callback)
      ->detach(); // or start/vetoable_start/wait

Receiver side:
 mbox->get_init()
     ->set_dst_data(reinterpret_cast<void**>(data), sizeof(void*))
     ->set_copy_data_callback(SIMIX_comm_copy_pointer_callback)
     ->wait(); // or start/vetoable_start
parent 94cee054
Pipeline #435330 passed with stages
in 11 minutes and 29 seconds
......@@ -168,6 +168,8 @@ public:
Actor* get_sender() const;
bool is_assigned() const override { return (to_ != nullptr && from_ != nullptr) || (mailbox_ != nullptr); }
CommPtr set_copy_data_callback(void (*callback)(kernel::activity::CommImpl*, void*, size_t));
};
} // namespace s4u
} // namespace simgrid
......
......@@ -297,6 +297,16 @@ Actor* Comm::get_sender() const
return sender ? sender->get_ciface() : nullptr;
}
CommPtr Comm::set_copy_data_callback(void (*callback)(kernel::activity::CommImpl*, void*, size_t))
{
static void (*saved_callback)(kernel::activity::CommImpl*, void*, size_t);
saved_callback = callback;
copy_data_function_ = [](simgrid::kernel::activity::CommImpl* comm, void* buff, size_t size) {
saved_callback(comm, buff, size);
};
return this;
}
} // namespace s4u
} // namespace simgrid
/* **************************** Public C interface *************************** */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment