From f440f91c0d78d785b2a9cf87c718a54af453cf26 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Mon, 8 Jul 2013 14:31:36 +0200 Subject: [PATCH] testany should work and return a flag if we test 0 comms. --- src/smpi/smpi_base.c | 46 +++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index df76fc2b0e..73fe79ad64 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -636,33 +636,31 @@ int smpi_mpi_testany(int count, MPI_Request requests[], int *index, *index = MPI_UNDEFINED; flag = 0; - if(count > 0) { - comms = xbt_dynar_new(sizeof(smx_action_t), NULL); - map = xbt_new(int, count); - size = 0; - for(i = 0; i < count; i++) { - if((requests[i]!=MPI_REQUEST_NULL) && requests[i]->action) { - xbt_dynar_push(comms, &requests[i]->action); - map[size] = i; - size++; - } + comms = xbt_dynar_new(sizeof(smx_action_t), NULL); + map = xbt_new(int, count); + size = 0; + for(i = 0; i < count; i++) { + if((requests[i]!=MPI_REQUEST_NULL) && requests[i]->action) { + xbt_dynar_push(comms, &requests[i]->action); + map[size] = i; + size++; } - if(size > 0) { - i = simcall_comm_testany(comms); - // not MPI_UNDEFINED, as this is a simix return code - if(i != -1) { - *index = map[i]; - finish_wait(&requests[*index], status); - flag = 1; - } - }else{ - //all requests are null or inactive, return true - flag=1; - smpi_empty_status(status); + } + if(size > 0) { + i = simcall_comm_testany(comms); + // not MPI_UNDEFINED, as this is a simix return code + if(i != -1) { + *index = map[i]; + finish_wait(&requests[*index], status); + flag = 1; } - xbt_free(map); - xbt_dynar_free(&comms); + }else{ + //all requests are null or inactive, return true + flag=1; + smpi_empty_status(status); } + xbt_free(map); + xbt_dynar_free(&comms); return flag; } -- 2.20.1