Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[cppcheck] Reduce scope for variables.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 2 Apr 2019 12:46:52 +0000 (14:46 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 3 Apr 2019 21:32:03 +0000 (23:32 +0200)
src/smpi/colls/smpi_nbc_impl.cpp
src/smpi/mpi/smpi_request.cpp

index 8a9e54e..14781da 100644 (file)
@@ -14,14 +14,12 @@ namespace smpi{
 
 int Colls::ibarrier(MPI_Comm comm, MPI_Request* request)
 {
 
 int Colls::ibarrier(MPI_Comm comm, MPI_Request* request)
 {
-  int i;
   int size = comm->size();
   int rank = comm->rank();
   int size = comm->size();
   int rank = comm->rank();
-  MPI_Request* requests;
   (*request) = new Request( nullptr, 0, MPI_BYTE,
                          rank,rank, COLL_TAG_BARRIER, comm, MPI_REQ_PERSISTENT);
   if (rank > 0) {
   (*request) = new Request( nullptr, 0, MPI_BYTE,
                          rank,rank, COLL_TAG_BARRIER, comm, MPI_REQ_PERSISTENT);
   if (rank > 0) {
-    requests = new MPI_Request[2];
+    MPI_Request* requests = new MPI_Request[2];
     requests[0] = Request::isend (nullptr, 0, MPI_BYTE, 0,
                              COLL_TAG_BARRIER,
                              comm);
     requests[0] = Request::isend (nullptr, 0, MPI_BYTE, 0,
                              COLL_TAG_BARRIER,
                              comm);
@@ -31,15 +29,10 @@ int Colls::ibarrier(MPI_Comm comm, MPI_Request* request)
     (*request)->set_nbc_requests(requests, 2);
   }
   else {
     (*request)->set_nbc_requests(requests, 2);
   }
   else {
-    requests = new MPI_Request[(size-1)*2];
-    for (i = 1; i < 2*size-1; i+=2) {
-        requests[i-1] = Request::irecv(nullptr, 0, MPI_BYTE, MPI_ANY_SOURCE,
-                                 COLL_TAG_BARRIER, comm
-                                 );
-        requests[i] = Request::isend(nullptr, 0, MPI_BYTE, (i+1)/2,
-                                 COLL_TAG_BARRIER,
-                                 comm
-                                 );
+    MPI_Request* requests = new MPI_Request[(size - 1) * 2];
+    for (int i = 1; i < 2 * size - 1; i += 2) {
+      requests[i - 1] = Request::irecv(nullptr, 0, MPI_BYTE, MPI_ANY_SOURCE, COLL_TAG_BARRIER, comm);
+      requests[i]     = Request::isend(nullptr, 0, MPI_BYTE, (i + 1) / 2, COLL_TAG_BARRIER, comm);
     }
     (*request)->set_nbc_requests(requests, 2*(size-1));
   }
     }
     (*request)->set_nbc_requests(requests, 2*(size-1));
   }
@@ -48,23 +41,21 @@ int Colls::ibarrier(MPI_Comm comm, MPI_Request* request)
 
 int Colls::ibcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm, MPI_Request* request)
 {
 
 int Colls::ibcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm, MPI_Request* request)
 {
-  int i;
   int size = comm->size();
   int rank = comm->rank();
   int size = comm->size();
   int rank = comm->rank();
-  MPI_Request* requests;
   (*request) = new Request( nullptr, 0, MPI_BYTE,
                          rank,rank, COLL_TAG_BCAST, comm, MPI_REQ_PERSISTENT);
   if (rank != root) {
   (*request) = new Request( nullptr, 0, MPI_BYTE,
                          rank,rank, COLL_TAG_BCAST, comm, MPI_REQ_PERSISTENT);
   if (rank != root) {
-    requests = new MPI_Request[1];
+    MPI_Request* requests = new MPI_Request[1];
     requests[0] = Request::irecv (buf, count, datatype, root,
                              COLL_TAG_BCAST,
                              comm);
     (*request)->set_nbc_requests(requests, 1);
   }
   else {
     requests[0] = Request::irecv (buf, count, datatype, root,
                              COLL_TAG_BCAST,
                              comm);
     (*request)->set_nbc_requests(requests, 1);
   }
   else {
-    requests = new MPI_Request[size-1];
+    MPI_Request* requests = new MPI_Request[size - 1];
     int n = 0;
     int n = 0;
-    for (i = 0; i < size; i++) {
+    for (int i = 0; i < size; i++) {
       if(i!=root){
         requests[n] = Request::isend(buf, count, datatype, i,
                                  COLL_TAG_BCAST,
       if(i!=root){
         requests[n] = Request::isend(buf, count, datatype, i,
                                  COLL_TAG_BCAST,
@@ -85,7 +76,6 @@ int Colls::iallgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   const int system_tag = COLL_TAG_ALLGATHER;
   MPI_Aint lb = 0;
   MPI_Aint recvext = 0;
   const int system_tag = COLL_TAG_ALLGATHER;
   MPI_Aint lb = 0;
   MPI_Aint recvext = 0;
-  MPI_Request *requests;
 
   int rank = comm->rank();
   int size = comm->size();
 
   int rank = comm->rank();
   int size = comm->size();
@@ -97,7 +87,7 @@ int Colls::iallgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   Datatype::copy(sendbuf, sendcount, sendtype, static_cast<char *>(recvbuf) + rank * recvcount * recvext, recvcount,
                      recvtype);
   // Send/Recv buffers to/from others;
   Datatype::copy(sendbuf, sendcount, sendtype, static_cast<char *>(recvbuf) + rank * recvcount * recvext, recvcount,
                      recvtype);
   // Send/Recv buffers to/from others;
-  requests = new MPI_Request[2 * (size - 1)];
+  MPI_Request* requests = new MPI_Request[2 * (size - 1)];
   int index = 0;
   for (int other = 0; other < size; other++) {
     if(other != rank) {
   int index = 0;
   for (int other = 0; other < size; other++) {
     if(other != rank) {
@@ -119,14 +109,13 @@ int Colls::iscatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   const int system_tag = COLL_TAG_SCATTER;
   MPI_Aint lb = 0;
   MPI_Aint sendext = 0;
   const int system_tag = COLL_TAG_SCATTER;
   MPI_Aint lb = 0;
   MPI_Aint sendext = 0;
-  MPI_Request *requests;
 
   int rank = comm->rank();
   int size = comm->size();
   (*request) = new Request( nullptr, 0, MPI_BYTE,
                          rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
   if(rank != root) {
 
   int rank = comm->rank();
   int size = comm->size();
   (*request) = new Request( nullptr, 0, MPI_BYTE,
                          rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
   if(rank != root) {
-    requests = new MPI_Request[1];
+    MPI_Request* requests = new MPI_Request[1];
     // Recv buffer from root
     requests[0] = Request::irecv(recvbuf, recvcount, recvtype, root, system_tag, comm);
     (*request)->set_nbc_requests(requests, 1);
     // Recv buffer from root
     requests[0] = Request::irecv(recvbuf, recvcount, recvtype, root, system_tag, comm);
     (*request)->set_nbc_requests(requests, 1);
@@ -138,7 +127,7 @@ int Colls::iscatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
                            sendcount, sendtype, recvbuf, recvcount, recvtype);
     }
     // Send buffers to receivers
                            sendcount, sendtype, recvbuf, recvcount, recvtype);
     }
     // Send buffers to receivers
-    requests = new MPI_Request[size - 1];
+    MPI_Request* requests = new MPI_Request[size - 1];
     int index = 0;
     for(int dst = 0; dst < size; dst++) {
       if(dst != root) {
     int index = 0;
     for(int dst = 0; dst < size; dst++) {
       if(dst != root) {
@@ -190,10 +179,7 @@ int Colls::iallgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, void
 
 int Colls::ialltoall( void *sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm, MPI_Request* request){
 int system_tag = COLL_TAG_ALLTOALL;
 
 int Colls::ialltoall( void *sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm, MPI_Request* request){
 int system_tag = COLL_TAG_ALLTOALL;
-  int i;
-  int count;
   MPI_Aint lb = 0, sendext = 0, recvext = 0;
   MPI_Aint lb = 0, sendext = 0, recvext = 0;
-  MPI_Request *requests;
 
   /* Initialize. */
   int rank = comm->rank();
 
   /* Initialize. */
   int rank = comm->rank();
@@ -207,10 +193,10 @@ int system_tag = COLL_TAG_ALLTOALL;
                                static_cast<char *>(recvbuf) + rank * recvcount * recvext, recvcount, recvtype);
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
                                static_cast<char *>(recvbuf) + rank * recvcount * recvext, recvcount, recvtype);
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
-    requests = new MPI_Request[2 * (size - 1)];
+    MPI_Request* requests = new MPI_Request[2 * (size - 1)];
     /* Post all receives first -- a simple optimization */
     /* Post all receives first -- a simple optimization */
-    count = 0;
-    for (i = (rank + 1) % size; i != rank; i = (i + 1) % size) {
+    int count = 0;
+    for (int i = (rank + 1) % size; i != rank; i = (i + 1) % size) {
       requests[count] = Request::irecv_init(static_cast<char *>(recvbuf) + i * recvcount * recvext, recvcount,
                                         recvtype, i, system_tag, comm);
       count++;
       requests[count] = Request::irecv_init(static_cast<char *>(recvbuf) + i * recvcount * recvext, recvcount,
                                         recvtype, i, system_tag, comm);
       count++;
@@ -220,7 +206,7 @@ int system_tag = COLL_TAG_ALLTOALL;
      *     when messages actually arrive in the order in which they were posted.
      * TODO: check the previous assertion
      */
      *     when messages actually arrive in the order in which they were posted.
      * TODO: check the previous assertion
      */
-    for (i = (rank + size - 1) % size; i != rank; i = (i + size - 1) % size) {
+    for (int i = (rank + size - 1) % size; i != rank; i = (i + size - 1) % size) {
       requests[count] = Request::isend_init(static_cast<char *>(sendbuf) + i * sendcount * sendext, sendcount,
                                         sendtype, i, system_tag, comm);
       count++;
       requests[count] = Request::isend_init(static_cast<char *>(sendbuf) + i * sendcount * sendext, sendcount,
                                         sendtype, i, system_tag, comm);
       count++;
@@ -238,7 +224,6 @@ int Colls::ialltoallv(void *sendbuf, int *sendcounts, int *senddisps, MPI_Dataty
   MPI_Aint lb = 0;
   MPI_Aint sendext = 0;
   MPI_Aint recvext = 0;
   MPI_Aint lb = 0;
   MPI_Aint sendext = 0;
   MPI_Aint recvext = 0;
-  MPI_Request *requests;
 
   /* Initialize. */
   int rank = comm->rank();
 
   /* Initialize. */
   int rank = comm->rank();
@@ -252,7 +237,7 @@ int Colls::ialltoallv(void *sendbuf, int *sendcounts, int *senddisps, MPI_Dataty
                                static_cast<char *>(recvbuf) + recvdisps[rank] * recvext, recvcounts[rank], recvtype);
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
                                static_cast<char *>(recvbuf) + recvdisps[rank] * recvext, recvcounts[rank], recvtype);
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
-    requests = new MPI_Request[2 * (size - 1)];
+    MPI_Request* requests = new MPI_Request[2 * (size - 1)];
     int count = 0;
     /* Create all receives that will be posted first */
     for (int i = 0; i < size; ++i) {
     int count = 0;
     /* Create all receives that will be posted first */
     for (int i = 0; i < size; ++i) {
@@ -284,7 +269,6 @@ int Colls::ialltoallv(void *sendbuf, int *sendcounts, int *senddisps, MPI_Dataty
 int Colls::ialltoallw(void *sendbuf, int *sendcounts, int *senddisps, MPI_Datatype* sendtypes,
                               void *recvbuf, int *recvcounts, int *recvdisps, MPI_Datatype* recvtypes, MPI_Comm comm, MPI_Request *request){
   const int system_tag = COLL_TAG_ALLTOALLV;
 int Colls::ialltoallw(void *sendbuf, int *sendcounts, int *senddisps, MPI_Datatype* sendtypes,
                               void *recvbuf, int *recvcounts, int *recvdisps, MPI_Datatype* recvtypes, MPI_Comm comm, MPI_Request *request){
   const int system_tag = COLL_TAG_ALLTOALLV;
-  MPI_Request *requests;
 
   /* Initialize. */
   int rank = comm->rank();
 
   /* Initialize. */
   int rank = comm->rank();
@@ -296,7 +280,7 @@ int Colls::ialltoallw(void *sendbuf, int *sendcounts, int *senddisps, MPI_Dataty
                                static_cast<char *>(recvbuf) + recvdisps[rank], recvcounts[rank], recvtypes[rank]): MPI_SUCCESS;
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
                                static_cast<char *>(recvbuf) + recvdisps[rank], recvcounts[rank], recvtypes[rank]): MPI_SUCCESS;
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
-    requests = new MPI_Request[2 * (size - 1)];
+    MPI_Request* requests = new MPI_Request[2 * (size - 1)];
     int count = 0;
     /* Create all receives that will be posted first */
     for (int i = 0; i < size; ++i) {
     int count = 0;
     /* Create all receives that will be posted first */
     for (int i = 0; i < size; ++i) {
@@ -331,7 +315,6 @@ int Colls::igather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   const int system_tag = COLL_TAG_GATHER;
   MPI_Aint lb = 0;
   MPI_Aint recvext = 0;
   const int system_tag = COLL_TAG_GATHER;
   MPI_Aint lb = 0;
   MPI_Aint recvext = 0;
-  MPI_Request *requests;
 
   int rank = comm->rank();
   int size = comm->size();
 
   int rank = comm->rank();
   int size = comm->size();
@@ -339,7 +322,7 @@ int Colls::igather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
                          rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
   if(rank != root) {
     // Send buffer to root
                          rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
   if(rank != root) {
     // Send buffer to root
-    requests = new MPI_Request[1];
+    MPI_Request* requests = new MPI_Request[1];
     requests[0]=Request::isend(sendbuf, sendcount, sendtype, root, system_tag, comm);
     (*request)->set_nbc_requests(requests, 1);
   } else {
     requests[0]=Request::isend(sendbuf, sendcount, sendtype, root, system_tag, comm);
     (*request)->set_nbc_requests(requests, 1);
   } else {
@@ -348,7 +331,7 @@ int Colls::igather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
     Datatype::copy(sendbuf, sendcount, sendtype, static_cast<char*>(recvbuf) + root * recvcount * recvext,
                        recvcount, recvtype);
     // Receive buffers from senders
     Datatype::copy(sendbuf, sendcount, sendtype, static_cast<char*>(recvbuf) + root * recvcount * recvext,
                        recvcount, recvtype);
     // Receive buffers from senders
-    requests = new MPI_Request[size - 1];
+    MPI_Request* requests = new MPI_Request[size - 1];
     int index = 0;
     for (int src = 0; src < size; src++) {
       if(src != root) {
     int index = 0;
     for (int src = 0; src < size; src++) {
       if(src != root) {
@@ -370,7 +353,6 @@ int Colls::igatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *r
   int system_tag = COLL_TAG_GATHERV;
   MPI_Aint lb = 0;
   MPI_Aint recvext = 0;
   int system_tag = COLL_TAG_GATHERV;
   MPI_Aint lb = 0;
   MPI_Aint recvext = 0;
-  MPI_Request *requests;
   
   int rank = comm->rank();
   int size = comm->size();
   
   int rank = comm->rank();
   int size = comm->size();
@@ -378,7 +360,7 @@ int Colls::igatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *r
                          rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
   if (rank != root) {
     // Send buffer to root
                          rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
   if (rank != root) {
     // Send buffer to root
-    requests = new MPI_Request[1];
+    MPI_Request* requests = new MPI_Request[1];
     requests[0]=Request::isend(sendbuf, sendcount, sendtype, root, system_tag, comm);
     (*request)->set_nbc_requests(requests, 1);
   } else {
     requests[0]=Request::isend(sendbuf, sendcount, sendtype, root, system_tag, comm);
     (*request)->set_nbc_requests(requests, 1);
   } else {
@@ -387,7 +369,7 @@ int Colls::igatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *r
     Datatype::copy(sendbuf, sendcount, sendtype, static_cast<char*>(recvbuf) + displs[root] * recvext,
                        recvcounts[root], recvtype);
     // Receive buffers from senders
     Datatype::copy(sendbuf, sendcount, sendtype, static_cast<char*>(recvbuf) + displs[root] * recvext,
                        recvcounts[root], recvtype);
     // Receive buffers from senders
-    requests = new MPI_Request[size - 1];
+    MPI_Request* requests = new MPI_Request[size - 1];
     int index = 0;
     for (int src = 0; src < size; src++) {
       if(src != root) {
     int index = 0;
     for (int src = 0; src < size; src++) {
       if(src != root) {
@@ -408,7 +390,6 @@ int Colls::iscatterv(void *sendbuf, int *sendcounts, int *displs, MPI_Datatype s
   int system_tag = COLL_TAG_SCATTERV;
   MPI_Aint lb = 0;
   MPI_Aint sendext = 0;
   int system_tag = COLL_TAG_SCATTERV;
   MPI_Aint lb = 0;
   MPI_Aint sendext = 0;
-  MPI_Request* requests;
 
   int rank = comm->rank();
   int size = comm->size();
 
   int rank = comm->rank();
   int size = comm->size();
@@ -416,7 +397,7 @@ int Colls::iscatterv(void *sendbuf, int *sendcounts, int *displs, MPI_Datatype s
                          rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
   if(rank != root) {
     // Recv buffer from root
                          rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
   if(rank != root) {
     // Recv buffer from root
-    requests = new MPI_Request[1];
+    MPI_Request* requests = new MPI_Request[1];
     requests[0]=Request::irecv(recvbuf, recvcount, recvtype, root, system_tag, comm);
     (*request)->set_nbc_requests(requests, 1);
   } else {
     requests[0]=Request::irecv(recvbuf, recvcount, recvtype, root, system_tag, comm);
     (*request)->set_nbc_requests(requests, 1);
   } else {
@@ -449,7 +430,6 @@ int Colls::ireduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatyp
   const int system_tag = COLL_TAG_REDUCE;
   MPI_Aint lb = 0;
   MPI_Aint dataext = 0;
   const int system_tag = COLL_TAG_REDUCE;
   MPI_Aint lb = 0;
   MPI_Aint dataext = 0;
-  MPI_Request* requests;
 
   char* sendtmpbuf = static_cast<char *>(sendbuf);
 
 
   char* sendtmpbuf = static_cast<char *>(sendbuf);
 
@@ -474,7 +454,7 @@ int Colls::ireduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatyp
 
   if(rank != root) {
     // Send buffer to root
 
   if(rank != root) {
     // Send buffer to root
-    requests = new MPI_Request[1];
+    MPI_Request* requests = new MPI_Request[1];
     requests[0]=Request::isend(sendtmpbuf, count, datatype, root, system_tag, comm);
     (*request)->set_nbc_requests(requests, 1);
   } else {
     requests[0]=Request::isend(sendtmpbuf, count, datatype, root, system_tag, comm);
     (*request)->set_nbc_requests(requests, 1);
   } else {
@@ -509,7 +489,6 @@ int Colls::iallreduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype data
   const int system_tag = COLL_TAG_ALLREDUCE;
   MPI_Aint lb = 0;
   MPI_Aint dataext = 0;
   const int system_tag = COLL_TAG_ALLREDUCE;
   MPI_Aint lb = 0;
   MPI_Aint dataext = 0;
-  MPI_Request *requests;
 
   int rank = comm->rank();
   int size = comm->size();
 
   int rank = comm->rank();
   int size = comm->size();
@@ -520,7 +499,7 @@ int Colls::iallreduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype data
   // Local copy from self
   Datatype::copy(sendbuf, count, datatype, recvbuf, count, datatype);
   // Send/Recv buffers to/from others;
   // Local copy from self
   Datatype::copy(sendbuf, count, datatype, recvbuf, count, datatype);
   // Send/Recv buffers to/from others;
-  requests = new MPI_Request[2 * (size - 1)];
+  MPI_Request* requests = new MPI_Request[2 * (size - 1)];
   int index = 0;
   for (int other = 0; other < size; other++) {
     if(other != rank) {
   int index = 0;
   for (int other = 0; other < size; other++) {
     if(other != rank) {
@@ -604,7 +583,6 @@ int Colls::ireduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts, MPI_Da
   const int system_tag = COLL_TAG_REDUCE_SCATTER;
   MPI_Aint lb = 0;
   MPI_Aint dataext = 0;
   const int system_tag = COLL_TAG_REDUCE_SCATTER;
   MPI_Aint lb = 0;
   MPI_Aint dataext = 0;
-  MPI_Request *requests;
 
   int rank = comm->rank();
   int size = comm->size();
 
   int rank = comm->rank();
   int size = comm->size();
@@ -614,7 +592,7 @@ int Colls::ireduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts, MPI_Da
   datatype->extent(&lb, &dataext);
 
   // Send/Recv buffers to/from others;
   datatype->extent(&lb, &dataext);
 
   // Send/Recv buffers to/from others;
-  requests = new MPI_Request[2 * (size - 1)];
+  MPI_Request* requests = new MPI_Request[2 * (size - 1)];
   int index = 0;
   int recvdisp=0;
   for (int other = 0; other < size; other++) {
   int index = 0;
   int recvdisp=0;
   for (int other = 0; other < size; other++) {
index 6287d7c..88c539e 100644 (file)
@@ -541,7 +541,6 @@ int Request::test(MPI_Request * request, MPI_Status * status, int* flag) {
   if(smpi_test_sleep > 0)
     simcall_process_sleep(nsleeps*smpi_test_sleep);
 
   if(smpi_test_sleep > 0)
     simcall_process_sleep(nsleeps*smpi_test_sleep);
 
-  MPI_Status* mystatus;
   Status::empty(status);
   *flag = 1;
   if (((*request)->flags_ & MPI_REQ_PREPARED) == 0) {
   Status::empty(status);
   *flag = 1;
   if (((*request)->flags_ & MPI_REQ_PREPARED) == 0) {
@@ -560,6 +559,7 @@ int Request::test(MPI_Request * request, MPI_Status * status, int* flag) {
     if (*flag) {
       finish_wait(request,status);
       if (*request != MPI_REQUEST_NULL && ((*request)->flags_ & MPI_REQ_GENERALIZED)){
     if (*flag) {
       finish_wait(request,status);
       if (*request != MPI_REQUEST_NULL && ((*request)->flags_ & MPI_REQ_GENERALIZED)){
+        MPI_Status* mystatus;
         if(status==MPI_STATUS_IGNORE){
           mystatus=new MPI_Status();
           Status::empty(mystatus);
         if(status==MPI_STATUS_IGNORE){
           mystatus=new MPI_Status();
           Status::empty(mystatus);
@@ -622,7 +622,6 @@ int Request::testany(int count, MPI_Request requests[], int *index, int* flag, M
   int i;
   *flag = 0;
   int ret = MPI_SUCCESS;
   int i;
   *flag = 0;
   int ret = MPI_SUCCESS;
-  MPI_Status* mystatus;
   *index = MPI_UNDEFINED;
 
   std::vector<int> map; /** Maps all matching comms back to their location in requests **/
   *index = MPI_UNDEFINED;
 
   std::vector<int> map; /** Maps all matching comms back to their location in requests **/
@@ -652,6 +651,7 @@ int Request::testany(int count, MPI_Request requests[], int *index, int* flag, M
       } else {
         finish_wait(&requests[*index],status);
       if (requests[*index] != MPI_REQUEST_NULL && (requests[*index]->flags_ & MPI_REQ_GENERALIZED)){
       } else {
         finish_wait(&requests[*index],status);
       if (requests[*index] != MPI_REQUEST_NULL && (requests[*index]->flags_ & MPI_REQ_GENERALIZED)){
+        MPI_Status* mystatus;
         if(status==MPI_STATUS_IGNORE){
           mystatus=new MPI_Status();
           Status::empty(mystatus);
         if(status==MPI_STATUS_IGNORE){
           mystatus=new MPI_Status();
           Status::empty(mystatus);