- void **tmpbufs = xbt_malloc((size - 1) * sizeof(void *));
- for (i = 0; i < size - 1; i++) {
- // we need 1 buffer per request to store intermediate receptions
- tmpbufs[i] = xbt_malloc(count * datatype->size);
- }
- memcpy(recvbuf, sendbuf, count * datatype->size * sizeof(char)); // initiliaze recv buf with my own snd buf
-
- // i can not use: 'request->forward = size-1;' (which would progagate size-1 receive reqs)
- // since we should op values as soon as one receiving request matches.
- for (i = 0; i < size - 1; i++) {
- // reminder: for smpi_create_request() the src is always the process sending.
- src = i < root ? i : i + 1;
- retval = smpi_create_request(tmpbufs[i], count, datatype,
- src, root, tag, comm, &(tabrequest[i]));
- if (NULL != tabrequest[i] && MPI_SUCCESS == retval) {
- if (MPI_SUCCESS == retval) {
- smpi_mpi_irecv(tabrequest[i]);
- }
- }
+int MPI_Testany(int count, MPI_Request requests[], int* index, int* flag, MPI_Status* status) {
+ int retval;
+
+ smpi_bench_end(-1, NULL); //FIXME
+ if(index == NULL || flag == NULL) {
+ retval = MPI_ERR_ARG;
+ } else {
+ *flag = smpi_mpi_testany(count, requests, index, status);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(-1, NULL);
+ return retval;
+}
+
+int MPI_Wait(MPI_Request* request, MPI_Status* status) {
+ int retval;
+ int rank = request && (*request)->comm != MPI_COMM_NULL
+ ? smpi_comm_rank((*request)->comm)
+ : -1;
+
+#ifdef HAVE_TRACING
+ MPI_Group group = smpi_comm_group((*request)->comm);
+ int src_traced = smpi_group_rank (group , (*request)->src);
+ int dst_traced = smpi_group_rank (group , (*request)->dst);
+ int is_wait_for_receive = (*request)->recv;
+ TRACE_smpi_ptp_in (rank, src_traced, dst_traced, __FUNCTION__);
+#endif
+ smpi_bench_end(rank, "Wait");
+ if(request == NULL) {
+ retval = MPI_ERR_ARG;
+ } else if(*request == MPI_REQUEST_NULL) {
+ retval = MPI_ERR_REQUEST;
+ } else {
+ smpi_mpi_wait(request, status);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(rank, "Wait");
+#ifdef HAVE_TRACING
+ TRACE_smpi_ptp_out (rank, src_traced, dst_traced, __FUNCTION__);
+ if (is_wait_for_receive){
+ TRACE_smpi_recv (rank, src_traced, dst_traced);
+ }
+#endif
+ return retval;
+}
+
+int MPI_Waitany(int count, MPI_Request requests[], int* index, MPI_Status* status) {
+ int retval;
+
+#ifdef HAVE_TRACING
+ //save requests information for tracing
+ int i;
+ xbt_dynar_t srcs = xbt_dynar_new (sizeof(int), xbt_free);
+ xbt_dynar_t dsts = xbt_dynar_new (sizeof(int), xbt_free);
+ xbt_dynar_t recvs = xbt_dynar_new (sizeof(int), xbt_free);
+ for (i = 0; i < count; i++){
+ MPI_Request req = requests[i]; //already received requests are no longer valid
+ if (req){
+ int *asrc = xbt_new(int, 1);
+ int *adst = xbt_new(int, 1);
+ int *arecv = xbt_new(int, 1);
+ *asrc = req->src;
+ *adst = req->dst;
+ *arecv = req->recv;
+ xbt_dynar_insert_at (srcs, i, asrc);
+ xbt_dynar_insert_at (dsts, i, adst);
+ xbt_dynar_insert_at (recvs, i, arecv);
+ }else{
+ int *t = xbt_new(int, 1);
+ xbt_dynar_insert_at (srcs, i, t);
+ xbt_dynar_insert_at (dsts, i, t);
+ xbt_dynar_insert_at (recvs, i, t);