+void smpi_mpi_probe(int source, int tag, MPI_Comm comm, MPI_Status* status){
+ int flag=0;
+ //FIXME find another wait to avoid busy waiting ?
+ // the issue here is that we have to wait on a nonexistent comm
+ while(flag==0){
+ smpi_mpi_iprobe(source, tag, comm, &flag, status);
+ XBT_DEBUG("Busy Waiting on probing : %d", flag);
+ if(!flag) {
+ simcall_process_sleep(0.0001);
+ }
+ }
+}
+
+void smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status){
+ MPI_Request request =build_request(NULL, 0, MPI_CHAR, source, smpi_comm_rank(comm), tag,
+ comm, NON_PERSISTENT | RECV);
+
+ // behave like a receive, but don't do it
+ smx_rdv_t mailbox;
+
+ print_request("New iprobe", request);
+ // We have to test both mailboxes as we don't know if we will receive one one or another
+ if (xbt_cfg_get_int(_surf_cfg_set, "smpi/async_small_thres")>0){
+ mailbox = smpi_process_mailbox_small();
+ XBT_DEBUG("trying to probe the perm recv mailbox");
+ request->action = simcall_comm_iprobe(mailbox, request->src, request->tag, &match_recv, (void*)request);
+ }
+ if (request->action==NULL){
+ mailbox = smpi_process_mailbox();
+ XBT_DEBUG("trying to probe the other mailbox");
+ request->action = simcall_comm_iprobe(mailbox, request->src, request->tag, &match_recv, (void*)request);
+ }
+
+ if(request->action){
+ MPI_Request req = (MPI_Request)SIMIX_comm_get_src_data(request->action);
+ *flag=true;
+ if(status != MPI_STATUS_IGNORE) {
+ status->MPI_SOURCE = req->src;
+ status->MPI_TAG = req->tag;
+ status->MPI_ERROR = MPI_SUCCESS;
+ status->count = req->size;
+ }
+ }
+ else *flag=false;
+ smpi_mpi_request_free(&request);
+
+ return;
+}
+