-MPI_Request smpi_mpi_irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm) {
- MPI_Request request;
- MPI_Request rdv[2];
- size_t size = smpi_datatype_size(datatype) * count;
-
- if (size > EAGER_LIMIT) {
- /* Warning: this (zero-length synchronous) call will come back here with size == 0 */
- DEBUG1("RDV recv from %d", src);
- rdv[0] = smpi_mpi_irecv(NULL, 0, MPI_BYTE, src, RDV_TAG, comm);
- rdv[1] = smpi_mpi_isend(NULL, 0, MPI_BYTE, src, RDV_TAG, comm);
- smpi_mpi_waitall(2, rdv, MPI_STATUS_IGNORE);
+/* MPI Low level calls */
+MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype,
+ int dst, int tag, MPI_Comm comm)
+{
+ MPI_Request request =
+ build_request(buf, count, datatype, smpi_comm_rank(comm), dst, tag,
+ comm, PERSISTENT | SEND);
+
+ return request;
+}
+
+MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype,
+ int src, int tag, MPI_Comm comm)
+{
+ MPI_Request request =
+ build_request(buf, count, datatype, src, smpi_comm_rank(comm), tag,
+ comm, PERSISTENT | RECV);
+
+ return request;
+}
+
+void smpi_mpi_start(MPI_Request request)
+{
+ smx_rdv_t mailbox;
+ int detached = 0;
+
+ xbt_assert(!request->action,
+ "Cannot (re)start a non-finished communication");
+ if(request->flags & RECV) {
+ print_request("New recv", request);
+ mailbox = smpi_process_mailbox();
+ // FIXME: SIMIX does not yet support non-contiguous datatypes
+ request->action = SIMIX_req_comm_irecv(mailbox, request->buf, &request->size, &match_recv, request);
+ } else {
+ print_request("New send", request);
+ mailbox = smpi_process_remote_mailbox(
+ smpi_group_index(smpi_comm_group(request->comm), request->dst));
+ // FIXME: SIMIX does not yet support non-contiguous datatypes
+
+ if (request->size < 64*1024 ) { // eager mode => detached send (FIXME: this limit should be configurable)
+ void *oldbuf = request->buf;
+ detached = 1;
+ request->buf = malloc(request->size);
+ memcpy(request->buf,oldbuf,request->size);
+ XBT_DEBUG("Send request %p is detached; buf %p copied into %p",request,oldbuf,request->buf);
+ } else {
+ XBT_DEBUG("Send request %p is not detached (buf: %p)",request,request->buf);
+ }
+ request->action =
+ SIMIX_req_comm_isend(mailbox, request->size, -1.0,
+ request->buf, request->size,
+ &match_send,
+ (void (*)(void *))&smpi_mpi_request_free, // how to free the userdata if a detached send fails
+ request,
+ // detach if msg size < eager/rdv switch limit
+ detached);
+
+#ifdef HAVE_TRACING
+ SIMIX_req_set_category (request->action, TRACE_internal_smpi_get_category());
+#endif