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
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
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 *************************** */