Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change malloc/free to new/delete.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 18 Mar 2019 15:10:01 +0000 (16:10 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 30 Apr 2019 12:40:21 +0000 (14:40 +0200)
38 files changed:
src/smpi/colls/allgather/allgather-2dmesh.cpp
src/smpi/colls/allgather/allgather-3dmesh.cpp
src/smpi/colls/allgather/allgather-NTSLR-NB.cpp
src/smpi/colls/allgather/allgather-SMP-NTS.cpp
src/smpi/colls/allgather/allgather-mvapich-smp.cpp
src/smpi/colls/allgather/allgather-smp-simple.cpp
src/smpi/colls/allgather/allgather-spreading-simple.cpp
src/smpi/colls/allreduce/allreduce-mvapich-rs.cpp
src/smpi/colls/allreduce/allreduce-rab-rdb.cpp
src/smpi/colls/alltoall/alltoall-2dmesh.cpp
src/smpi/colls/alltoall/alltoall-3dmesh.cpp
src/smpi/colls/alltoall/alltoall-basic-linear.cpp
src/smpi/colls/alltoall/alltoall-bruck.cpp
src/smpi/colls/alltoall/alltoall-mvapich-scatter-dest.cpp
src/smpi/colls/alltoallv/alltoallv-bruck.cpp
src/smpi/colls/alltoallv/alltoallv-ompi-basic-linear.cpp
src/smpi/colls/bcast/bcast-NTSB.cpp
src/smpi/colls/bcast/bcast-NTSL-Isend.cpp
src/smpi/colls/bcast/bcast-NTSL.cpp
src/smpi/colls/bcast/bcast-SMP-binary.cpp
src/smpi/colls/bcast/bcast-SMP-linear.cpp
src/smpi/colls/bcast/bcast-arrival-pattern-aware-wait.cpp
src/smpi/colls/bcast/bcast-arrival-pattern-aware.cpp
src/smpi/colls/bcast/bcast-flattree-pipeline.cpp
src/smpi/colls/bcast/bcast-flattree.cpp
src/smpi/colls/bcast/bcast-mvapich-smp.cpp
src/smpi/colls/bcast/bcast-scatter-LR-allgather.cpp
src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp
src/smpi/colls/gather/gather-mvapich.cpp
src/smpi/colls/reduce/reduce-NTSL.cpp
src/smpi/colls/reduce/reduce-arrival-pattern-aware.cpp
src/smpi/colls/reduce/reduce-mvapich-knomial.cpp
src/smpi/colls/reduce/reduce-scatter-gather.cpp
src/smpi/colls/reduce_scatter/reduce_scatter-mpich.cpp
src/smpi/colls/reduce_scatter/reduce_scatter-ompi.cpp
src/smpi/colls/scatter/scatter-mvapich-two-level.cpp
src/smpi/colls/smpi_coll.cpp
src/smpi/colls/smpi_default_selector.cpp

index 02bd09b..0cfecd0 100644 (file)
@@ -115,7 +115,6 @@ Coll_allgather_2dmesh::allgather(const void *send_buff, int send_count, MPI_Data
                                  send_type, void *recv_buff, int recv_count,
                                  MPI_Datatype recv_type, MPI_Comm comm)
 {
                                  send_type, void *recv_buff, int recv_count,
                                  MPI_Datatype recv_type, MPI_Comm comm)
 {
-  MPI_Request *req, *req_ptr;
   MPI_Aint extent;
 
   int i, src, dst, rank, num_procs;
   MPI_Aint extent;
 
   int i, src, dst, rank, num_procs;
@@ -140,9 +139,8 @@ Coll_allgather_2dmesh::allgather(const void *send_buff, int send_count, MPI_Data
   if (Y > X)
     num_reqs = Y;
 
   if (Y > X)
     num_reqs = Y;
 
-  req = (MPI_Request *) xbt_malloc(num_reqs * sizeof(MPI_Request));
-
-  req_ptr = req;
+  MPI_Request* req     = new MPI_Request[num_reqs];
+  MPI_Request* req_ptr = req;
 
   // do local allgather/local copy
   recv_offset = rank * block_size;
 
   // do local allgather/local copy
   recv_offset = rank * block_size;
@@ -193,7 +191,7 @@ Coll_allgather_2dmesh::allgather(const void *send_buff, int send_count, MPI_Data
 
   Request::waitall(X - 1, req, MPI_STATUSES_IGNORE);
 
 
   Request::waitall(X - 1, req, MPI_STATUSES_IGNORE);
 
-  free(req);
+  delete[] req;
 
   return MPI_SUCCESS;
 }
 
   return MPI_SUCCESS;
 }
index 38ef2b0..8d99c07 100644 (file)
@@ -101,7 +101,6 @@ int Coll_allgather_3dmesh::allgather(const void *send_buff, int send_count,
                                      int recv_count, MPI_Datatype recv_type,
                                      MPI_Comm comm)
 {
                                      int recv_count, MPI_Datatype recv_type,
                                      MPI_Comm comm)
 {
-  MPI_Request *req, *req_ptr;
   MPI_Aint extent;
 
   int i, src, dst, rank, num_procs, block_size, my_z_base;
   MPI_Aint extent;
 
   int i, src, dst, rank, num_procs, block_size, my_z_base;
@@ -133,9 +132,8 @@ int Coll_allgather_3dmesh::allgather(const void *send_buff, int send_count,
 
   block_size = extent * send_count;
 
 
   block_size = extent * send_count;
 
-  req = (MPI_Request *) xbt_malloc(num_reqs * sizeof(MPI_Request));
-
-  req_ptr = req;
+  MPI_Request* req     = new MPI_Request[num_reqs];
+  MPI_Request* req_ptr = req;
 
   // do local allgather/local copy
   recv_offset = rank * block_size;
 
   // do local allgather/local copy
   recv_offset = rank * block_size;
@@ -206,7 +204,7 @@ int Coll_allgather_3dmesh::allgather(const void *send_buff, int send_count,
   }
   Request::waitall(Z - 1, req, MPI_STATUSES_IGNORE);
 
   }
   Request::waitall(Z - 1, req, MPI_STATUSES_IGNORE);
 
-  free(req);
+  delete[] req;
 
   return MPI_SUCCESS;
 }
 
   return MPI_SUCCESS;
 }
index 608e026..f05db0c 100644 (file)
@@ -26,10 +26,8 @@ Coll_allgather_NTSLR_NB::allgather(const void *sbuf, int scount, MPI_Datatype st
   size = comm->size();
   rextent = rtype->get_extent();
   sextent = stype->get_extent();
   size = comm->size();
   rextent = rtype->get_extent();
   sextent = stype->get_extent();
-  MPI_Request *rrequest_array;
-  MPI_Request *srequest_array;
-  rrequest_array = (MPI_Request *) xbt_malloc(size * sizeof(MPI_Request));
-  srequest_array = (MPI_Request *) xbt_malloc(size * sizeof(MPI_Request));
+  MPI_Request* rrequest_array = new MPI_Request[size];
+  MPI_Request* srequest_array = new MPI_Request[size];
 
   // irregular case use default MPI fucntions
   if (scount * sextent != rcount * rextent) {
 
   // irregular case use default MPI fucntions
   if (scount * sextent != rcount * rextent) {
@@ -66,8 +64,8 @@ Coll_allgather_NTSLR_NB::allgather(const void *sbuf, int scount, MPI_Datatype st
     Request::wait(&srequest_array[i], &status2);
   }
 
     Request::wait(&srequest_array[i], &status2);
   }
 
-  free(rrequest_array);
-  free(srequest_array);
+  delete[] rrequest_array;
+  delete[] srequest_array;
 
   return MPI_SUCCESS;
 }
 
   return MPI_SUCCESS;
 }
index 9e5986b..0e4e3db 100644 (file)
@@ -84,8 +84,8 @@ int Coll_allgather_SMP_NTS::allgather(const void *sbuf, int scount,
 
   // root of each SMP
   if (intra_rank == 0) {
 
   // root of each SMP
   if (intra_rank == 0) {
-    MPI_Request *rrequest_array = xbt_new(MPI_Request, inter_comm_size - 1);
-    MPI_Request *srequest_array = xbt_new(MPI_Request, inter_comm_size - 1);
+    MPI_Request* rrequest_array = new MPI_Request[inter_comm_size - 1];
+    MPI_Request* srequest_array = new MPI_Request[inter_comm_size - 1];
 
     src = ((inter_rank - 1 + inter_comm_size) % inter_comm_size) * num_core;
     dst = ((inter_rank + 1) % inter_comm_size) * num_core;
 
     src = ((inter_rank - 1 + inter_comm_size) % inter_comm_size) * num_core;
     dst = ((inter_rank + 1) % inter_comm_size) * num_core;
@@ -133,8 +133,8 @@ int Coll_allgather_SMP_NTS::allgather(const void *sbuf, int scount,
     }
 
     Request::waitall(inter_comm_size - 1, srequest_array, MPI_STATUSES_IGNORE);
     }
 
     Request::waitall(inter_comm_size - 1, srequest_array, MPI_STATUSES_IGNORE);
-    xbt_free(rrequest_array);
-    xbt_free(srequest_array);
+    delete[] rrequest_array;
+    delete[] srequest_array;
   }
   // last rank of each SMP
   else if (intra_rank == (num_core_in_current_smp - 1)) {
   }
   // last rank of each SMP
   else if (intra_rank == (num_core_in_current_smp - 1)) {
index 1a624eb..993efea 100644 (file)
@@ -105,18 +105,13 @@ int Coll_allgather_mvapich2_smp::allgather(const void *sendbuf,int sendcnt, MPI_
         /*When data in each socket is different*/
         if (comm->is_uniform() != 1) {
 
         /*When data in each socket is different*/
         if (comm->is_uniform() != 1) {
 
-            int *displs = NULL;
-            int *recvcnts = NULL;
             int *node_sizes = NULL;
             int i = 0;
 
             node_sizes = comm->get_non_uniform_map();
 
             int *node_sizes = NULL;
             int i = 0;
 
             node_sizes = comm->get_non_uniform_map();
 
-            displs =  static_cast<int *>(xbt_malloc(sizeof (int) * leader_comm_size));
-            recvcnts =  static_cast<int *>(xbt_malloc(sizeof (int) * leader_comm_size));
-            if (not displs || not recvcnts) {
-              return MPI_ERR_OTHER;
-            }
+            int* displs   = new int[leader_comm_size];
+            int* recvcnts = new int[leader_comm_size];
             recvcnts[0] = node_sizes[0] * recvcnt;
             displs[0] = 0;
 
             recvcnts[0] = node_sizes[0] * recvcnt;
             displs[0] = 0;
 
@@ -134,8 +129,8 @@ int Coll_allgather_mvapich2_smp::allgather(const void *sendbuf,int sendcnt, MPI_
                                        recvbuf, recvcnts,
                                        displs, recvtype,
                                        leader_comm);
                                        recvbuf, recvcnts,
                                        displs, recvtype,
                                        leader_comm);
-            xbt_free(displs);
-            xbt_free(recvcnts);
+            delete[] displs;
+            delete[] recvcnts;
         } else {
         void* sendtmpbuf=((char*)recvbuf)+recvtype->get_extent()*(recvcnt*local_size)*leader_comm->rank();
 
         } else {
         void* sendtmpbuf=((char*)recvbuf)+recvtype->get_extent()*(recvcnt*local_size)*leader_comm->rank();
 
index 06bf8d8..dcaaecd 100644 (file)
@@ -73,12 +73,10 @@ int Coll_allgather_smp_simple::allgather(const void *send_buf, int scount,
 
 
   if (intra_rank == 0) {
 
 
   if (intra_rank == 0) {
-    MPI_Request *reqs, *req_ptr;
     int num_req = (inter_comm_size - 1) * 2;
     int num_req = (inter_comm_size - 1) * 2;
-    reqs = (MPI_Request *) xbt_malloc(num_req * sizeof(MPI_Request));
-    req_ptr = reqs;
-    MPI_Status *stat;
-    stat = (MPI_Status *) xbt_malloc(num_req * sizeof(MPI_Status));
+    MPI_Request* reqs    = new MPI_Request[num_req];
+    MPI_Request* req_ptr = reqs;
+    MPI_Status* stat     = new MPI_Status[num_req];
 
     for (i = 1; i < inter_comm_size; i++) {
 
 
     for (i = 1; i < inter_comm_size; i++) {
 
@@ -105,9 +103,8 @@ int Coll_allgather_smp_simple::allgather(const void *send_buf, int scount,
       //MPIC_Irecv((recv_buf+recv_offset), (rcount * num_core), rtype, src, tag, comm, req_ptr++);
     }
     Request::waitall(num_req, reqs, stat);
       //MPIC_Irecv((recv_buf+recv_offset), (rcount * num_core), rtype, src, tag, comm, req_ptr++);
     }
     Request::waitall(num_req, reqs, stat);
-    free(reqs);
-    free(stat);
-
+    delete[] reqs;
+    delete[] stat;
   }
   //INTRA-BCAST (use flat tree)
 
   }
   //INTRA-BCAST (use flat tree)
 
index af20e8f..a1f55ca 100644 (file)
@@ -78,7 +78,6 @@ Coll_allgather_spreading_simple::allgather(const void *send_buff, int send_count
                                            MPI_Datatype recv_type,
                                            MPI_Comm comm)
 {
                                            MPI_Datatype recv_type,
                                            MPI_Comm comm)
 {
-  MPI_Request *reqs, *req_ptr;
   MPI_Aint extent;
   int i, src, dst, rank, num_procs, num_reqs;
   int tag = COLL_TAG_ALLGATHER;
   MPI_Aint extent;
   int i, src, dst, rank, num_procs, num_reqs;
   int tag = COLL_TAG_ALLGATHER;
@@ -90,14 +89,8 @@ Coll_allgather_spreading_simple::allgather(const void *send_buff, int send_count
   extent = send_type->get_extent();
 
   num_reqs = (2 * num_procs) - 2;
   extent = send_type->get_extent();
 
   num_reqs = (2 * num_procs) - 2;
-  reqs = (MPI_Request *) xbt_malloc(num_reqs * sizeof(MPI_Request));
-  if (not reqs) {
-    printf("allgather-spreading-simple.c:40: cannot allocate memory\n");
-    MPI_Finalize();
-    exit(0);
-  }
-
-  req_ptr = reqs;
+  MPI_Request* reqs    = new MPI_Request[num_reqs];
+  MPI_Request* req_ptr = reqs;
   Request::sendrecv(send_buff, send_count, send_type, rank, tag,
                (char *) recv_buff + rank * recv_count * extent, recv_count,
                recv_type, rank, tag, comm, &status);
   Request::sendrecv(send_buff, send_count, send_type, rank, tag,
                (char *) recv_buff + rank * recv_count * extent, recv_count,
                recv_type, rank, tag, comm, &status);
@@ -118,7 +111,7 @@ Coll_allgather_spreading_simple::allgather(const void *send_buff, int send_count
   }
 
   Request::waitall(num_reqs, reqs, MPI_STATUSES_IGNORE);
   }
 
   Request::waitall(num_reqs, reqs, MPI_STATUSES_IGNORE);
-  free(reqs);
+  delete[] reqs;
 
   return MPI_SUCCESS;
 }
 
   return MPI_SUCCESS;
 }
index d5102b1..1a74de8 100644 (file)
@@ -35,8 +35,7 @@ int Coll_allreduce_mvapich2_rs::allreduce(const void *sendbuf,
     int mpi_errno = MPI_SUCCESS;
     int newrank = 0;
     int mask, pof2, i, send_idx, recv_idx, last_idx, send_cnt;
     int mpi_errno = MPI_SUCCESS;
     int newrank = 0;
     int mask, pof2, i, send_idx, recv_idx, last_idx, send_cnt;
-    int dst, is_commutative, rem, newdst,
-        recv_cnt, *cnts, *disps;
+    int dst, is_commutative, rem, newdst, recv_cnt;
     MPI_Aint true_lb, true_extent, extent;
     void *tmp_buf, *tmp_buf_free;
 
     MPI_Aint true_lb, true_extent, extent;
     void *tmp_buf, *tmp_buf_free;
 
@@ -152,8 +151,8 @@ int Coll_allreduce_mvapich2_rs::allreduce(const void *sendbuf,
             /* for the reduce-scatter, calculate the count that
                each process receives and the displacement within
                the buffer */
             /* for the reduce-scatter, calculate the count that
                each process receives and the displacement within
                the buffer */
-            cnts = (int *)xbt_malloc(pof2 * sizeof (int));
-            disps = (int *)xbt_malloc(pof2 * sizeof (int));
+            int* cnts  = new int[pof2];
+            int* disps = new int[pof2];
 
             for (i = 0; i < (pof2 - 1); i++) {
                 cnts[i] = count / pof2;
 
             for (i = 0; i < (pof2 - 1); i++) {
                 cnts[i] = count / pof2;
@@ -267,8 +266,8 @@ int Coll_allreduce_mvapich2_rs::allreduce(const void *sendbuf,
 
                 mask >>= 1;
             }
 
                 mask >>= 1;
             }
-            xbt_free(disps);
-            xbt_free(cnts);
+            delete[] disps;
+            delete[] cnts;
         }
     }
 
         }
     }
 
index 4c9f338..90a44d2 100644 (file)
@@ -13,8 +13,7 @@ int Coll_allreduce_rab_rdb::allreduce(const void *sbuff, void *rbuff, int count,
 {
   int tag = COLL_TAG_ALLREDUCE;
   unsigned int mask, pof2, i, recv_idx, last_idx, send_idx, send_cnt;
 {
   int tag = COLL_TAG_ALLREDUCE;
   unsigned int mask, pof2, i, recv_idx, last_idx, send_idx, send_cnt;
-  int dst, newrank, rem, newdst,
-      recv_cnt, *cnts, *disps;
+  int dst, newrank, rem, newdst, recv_cnt;
   MPI_Aint extent;
   MPI_Status status;
   void *tmp_buf = NULL;
   MPI_Aint extent;
   MPI_Status status;
   void *tmp_buf = NULL;
@@ -81,8 +80,8 @@ int Coll_allreduce_rab_rdb::allreduce(const void *sbuff, void *rbuff, int count,
     // reduce-scatter, calculate the count that each process receives
     // and the displacement within the buffer
 
     // reduce-scatter, calculate the count that each process receives
     // and the displacement within the buffer
 
-    cnts = (int *) xbt_malloc(pof2 * sizeof(int));
-    disps = (int *) xbt_malloc(pof2 * sizeof(int));
+    int* cnts  = new int[pof2];
+    int* disps = new int[pof2];
 
     for (i = 0; i < (pof2 - 1); i++)
       cnts[i] = count / pof2;
 
     for (i = 0; i < (pof2 - 1); i++)
       cnts[i] = count / pof2;
@@ -177,9 +176,8 @@ int Coll_allreduce_rab_rdb::allreduce(const void *sbuff, void *rbuff, int count,
       mask >>= 1;
     }
 
       mask >>= 1;
     }
 
-    free(cnts);
-    free(disps);
-
+    delete[] cnts;
+    delete[] disps;
   }
   // In the non-power-of-two case, all odd-numbered processes of
   // rank < 2 * rem send the result to (rank-1), the ranks who didn't
   }
   // In the non-power-of-two case, all odd-numbered processes of
   // rank < 2 * rem send the result to (rank-1), the ranks who didn't
index e27e5de..41c2cef 100644 (file)
@@ -60,8 +60,7 @@ int Coll_alltoall_2dmesh::alltoall(const void *send_buff, int send_count,
                                     void *recv_buff, int recv_count,
                                     MPI_Datatype recv_type, MPI_Comm comm)
 {
                                     void *recv_buff, int recv_count,
                                     MPI_Datatype recv_type, MPI_Comm comm)
 {
-  MPI_Status *statuses, s;
-  MPI_Request *reqs, *req_ptr;;
+  MPI_Status s;
   MPI_Aint extent;
 
   char *tmp_buff1, *tmp_buff2;
   MPI_Aint extent;
 
   char *tmp_buff1, *tmp_buff2;
@@ -89,10 +88,9 @@ int Coll_alltoall_2dmesh::alltoall(const void *send_buff, int send_count,
   if (Y > X)
     num_reqs = Y;
 
   if (Y > X)
     num_reqs = Y;
 
-  statuses = (MPI_Status *) xbt_malloc(num_reqs * sizeof(MPI_Status));
-  reqs = (MPI_Request *) xbt_malloc(num_reqs * sizeof(MPI_Request));
-
-  req_ptr = reqs;
+  MPI_Status* statuses = new MPI_Status[num_reqs];
+  MPI_Request* reqs    = new MPI_Request[num_reqs];
+  MPI_Request* req_ptr = reqs;
 
   count = send_count * num_procs;
 
 
   count = send_count * num_procs;
 
@@ -168,8 +166,8 @@ int Coll_alltoall_2dmesh::alltoall(const void *send_buff, int send_count,
     Request::send(tmp_buff2, send_count * Y, send_type, dst, tag, comm);
   }
   Request::waitall(X - 1, reqs, statuses);
     Request::send(tmp_buff2, send_count * Y, send_type, dst, tag, comm);
   }
   Request::waitall(X - 1, reqs, statuses);
-  free(reqs);
-  free(statuses);
+  delete[] reqs;
+  delete[] statuses;
   smpi_free_tmp_buffer(tmp_buff1);
   smpi_free_tmp_buffer(tmp_buff2);
   return MPI_SUCCESS;
   smpi_free_tmp_buffer(tmp_buff1);
   smpi_free_tmp_buffer(tmp_buff2);
   return MPI_SUCCESS;
index 3870c52..58f8afe 100644 (file)
@@ -52,9 +52,8 @@ int Coll_alltoall_3dmesh::alltoall(const void *send_buff, int send_count,
                                     void *recv_buff, int recv_count,
                                     MPI_Datatype recv_type, MPI_Comm comm)
 {
                                     void *recv_buff, int recv_count,
                                     MPI_Datatype recv_type, MPI_Comm comm)
 {
-  MPI_Request *reqs, *req_ptr;
   MPI_Aint extent;
   MPI_Aint extent;
-  MPI_Status status, *statuses;
+  MPI_Status status;
   int i, j, src, dst, rank, num_procs, num_reqs, X, Y, Z, block_size, count;
   int my_z, two_dsize, my_row_base, my_col_base, my_z_base, src_row_base;
   int src_z_base, send_offset, recv_offset, tag = COLL_TAG_ALLTOALL;
   int i, j, src, dst, rank, num_procs, num_reqs, X, Y, Z, block_size, count;
   int my_z, two_dsize, my_row_base, my_col_base, my_z_base, src_row_base;
   int src_z_base, send_offset, recv_offset, tag = COLL_TAG_ALLTOALL;
@@ -86,10 +85,9 @@ int Coll_alltoall_3dmesh::alltoall(const void *send_buff, int send_count,
   tmp_buff1 = (char *) smpi_get_tmp_sendbuffer(block_size * num_procs * two_dsize);
   tmp_buff2 = (char *) smpi_get_tmp_recvbuffer(block_size * two_dsize);
 
   tmp_buff1 = (char *) smpi_get_tmp_sendbuffer(block_size * num_procs * two_dsize);
   tmp_buff2 = (char *) smpi_get_tmp_recvbuffer(block_size * two_dsize);
 
-  statuses = (MPI_Status *) xbt_malloc(num_reqs * sizeof(MPI_Status));
-  reqs = (MPI_Request *) xbt_malloc(num_reqs * sizeof(MPI_Request));
-
-  req_ptr = reqs;
+  MPI_Status* statuses = new MPI_Status[num_reqs];
+  MPI_Request* reqs    = new MPI_Request[num_reqs];
+  MPI_Request* req_ptr = reqs;
 
   recv_offset = (rank % two_dsize) * block_size * num_procs;
 
 
   recv_offset = (rank % two_dsize) * block_size * num_procs;
 
@@ -179,8 +177,8 @@ int Coll_alltoall_3dmesh::alltoall(const void *send_buff, int send_count,
 
   Request::waitall(Z - 1, reqs, statuses);
 
 
   Request::waitall(Z - 1, reqs, statuses);
 
-  free(reqs);
-  free(statuses);
+  delete[] reqs;
+  delete[] statuses;
   smpi_free_tmp_buffer(tmp_buff1);
   smpi_free_tmp_buffer(tmp_buff2);
   return MPI_SUCCESS;
   smpi_free_tmp_buffer(tmp_buff1);
   smpi_free_tmp_buffer(tmp_buff2);
   return MPI_SUCCESS;
index 06c5382..c8aeff2 100644 (file)
@@ -20,7 +20,6 @@ int Coll_alltoall_basic_linear::alltoall(const void *sendbuf, int sendcount, MPI
   int i;
   int count;
   MPI_Aint lb = 0, sendext = 0, recvext = 0;
   int i;
   int count;
   MPI_Aint lb = 0, sendext = 0, recvext = 0;
-  MPI_Request *requests;
 
   /* Initialize. */
   int rank = comm->rank();
 
   /* Initialize. */
   int rank = comm->rank();
@@ -33,7 +32,7 @@ int Coll_alltoall_basic_linear::alltoall(const void *sendbuf, int sendcount, MPI
                                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 = xbt_new(MPI_Request, 2 * (size - 1));
+    MPI_Request* requests = new MPI_Request[2 * (size - 1)];
     /* Post all receives first -- a simple optimization */
     count = 0;
     for (i = (rank + 1) % size; i != rank; i = (i + 1) % size) {
     /* Post all receives first -- a simple optimization */
     count = 0;
     for (i = (rank + 1) % size; i != rank; i = (i + 1) % size) {
@@ -59,7 +58,7 @@ int Coll_alltoall_basic_linear::alltoall(const void *sendbuf, int sendcount, MPI
       if(requests[i]!=MPI_REQUEST_NULL)
         Request::unref(&requests[i]);
     }
       if(requests[i]!=MPI_REQUEST_NULL)
         Request::unref(&requests[i]);
     }
-    xbt_free(requests);
+    delete[] requests;
   }
   return err;
 }
   }
   return err;
 }
index c2ea5ed..9c2f5bc 100644 (file)
@@ -41,7 +41,6 @@ Coll_alltoall_bruck::alltoall(const void *send_buff, int send_count,
   MPI_Aint extent;
   MPI_Datatype new_type;
 
   MPI_Aint extent;
   MPI_Datatype new_type;
 
-  int *blocks_length, *disps;
   int i, src, dst, rank, num_procs, count, block, position;
   int pack_size, tag = COLL_TAG_ALLTOALL, pof2 = 1;
 
   int i, src, dst, rank, num_procs, count, block, position;
   int pack_size, tag = COLL_TAG_ALLTOALL, pof2 = 1;
 
@@ -56,8 +55,8 @@ Coll_alltoall_bruck::alltoall(const void *send_buff, int send_count,
   extent = recv_type->get_extent();
 
   tmp_buff = (char *) smpi_get_tmp_sendbuffer(num_procs * recv_count * extent);
   extent = recv_type->get_extent();
 
   tmp_buff = (char *) smpi_get_tmp_sendbuffer(num_procs * recv_count * extent);
-  disps = (int *) xbt_malloc(sizeof(int) * num_procs);
-  blocks_length = (int *) xbt_malloc(sizeof(int) * num_procs);
+  int* disps         = new int[num_procs];
+  int* blocks_length = new int[num_procs];
 
   Request::sendrecv(send_ptr + rank * send_count * extent,
                (num_procs - rank) * send_count, send_type, rank, tag,
 
   Request::sendrecv(send_ptr + rank * send_count * extent,
                (num_procs - rank) * send_count, send_type, rank, tag,
@@ -98,8 +97,8 @@ Coll_alltoall_bruck::alltoall(const void *send_buff, int send_count,
     pof2 *= 2;
   }
 
     pof2 *= 2;
   }
 
-  free(disps);
-  free(blocks_length);
+  delete[] disps;
+  delete[] blocks_length;
 
   Request::sendrecv(recv_ptr + (rank + 1) * recv_count * extent,
                (num_procs - rank - 1) * recv_count, send_type,
 
   Request::sendrecv(recv_ptr + (rank + 1) * recv_count * extent,
                (num_procs - rank - 1) * recv_count, send_type,
index 5d77d38..e4dc8a0 100644 (file)
@@ -57,8 +57,6 @@ int Coll_alltoall_mvapich2_scatter_dest::alltoall(
     MPI_Aint     sendtype_extent = 0, recvtype_extent = 0;
     int mpi_errno=MPI_SUCCESS;
     int dst, rank;
     MPI_Aint     sendtype_extent = 0, recvtype_extent = 0;
     int mpi_errno=MPI_SUCCESS;
     int dst, rank;
-    MPI_Request *reqarray;
-    MPI_Status *starray;
 
     if (recvcount == 0) return MPI_SUCCESS;
 
 
     if (recvcount == 0) return MPI_SUCCESS;
 
@@ -93,9 +91,9 @@ int Coll_alltoall_mvapich2_scatter_dest::alltoall(
 
     /* FIXME: This should use the memory macros (there are storage
      leaks here if there is an error, for example) */
 
     /* FIXME: This should use the memory macros (there are storage
      leaks here if there is an error, for example) */
-    reqarray= (MPI_Request*)xbt_malloc(2*bblock*sizeof(MPI_Request));
+    MPI_Request* reqarray = new MPI_Request[2 * bblock];
 
 
-    starray=(MPI_Status *)xbt_malloc(2*bblock*sizeof(MPI_Status));
+    MPI_Status* starray = new MPI_Status[2 * bblock];
 
     for (ii=0; ii<comm_size; ii+=bblock) {
         ss = comm_size-ii < bblock ? comm_size-ii : bblock;
 
     for (ii=0; ii<comm_size; ii+=bblock) {
         ss = comm_size-ii < bblock ? comm_size-ii : bblock;
@@ -131,8 +129,8 @@ int Coll_alltoall_mvapich2_scatter_dest::alltoall(
         }
     }
     /* --END ERROR HANDLING-- */
         }
     }
     /* --END ERROR HANDLING-- */
-    xbt_free(starray);
-    xbt_free(reqarray);
+    delete[] starray;
+    delete[] reqarray;
     return (mpi_errno);
 
 }
     return (mpi_errno);
 
 }
index 6bb0147..8b3794f 100644 (file)
@@ -25,7 +25,6 @@ int Coll_alltoallv_bruck::alltoallv(const void *sendbuf, const int *sendcounts,
   MPI_Aint lb;
   MPI_Aint sendext = 0;
   MPI_Aint recvext = 0;
   MPI_Aint lb;
   MPI_Aint sendext = 0;
   MPI_Aint recvext = 0;
-  MPI_Request *requests;
 
   // FIXME: check implementation
   rank = comm->rank();
 
   // FIXME: check implementation
   rank = comm->rank();
@@ -43,52 +42,47 @@ int Coll_alltoallv_bruck::alltoallv(const void *sendbuf, const int *sendcounts,
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
 
   if (err == MPI_SUCCESS && size > 1) {
     /* Initiate all send/recv to/from others. */
 
-      int bblock = 4;//MPIR_PARAM_ALLTOALL_THROTTLE
-      //if (bblock == 0) bblock = comm_size;
+    int bblock = 4; // MPIR_PARAM_ALLTOALL_THROTTLE
+    // if (bblock == 0) bblock = comm_size;
 
 
+    // MPI_Request* requests = new MPI_Request[2 * (bblock - 1)];
+    int ii, ss, dst;
+    /* post only bblock isends/irecvs at a time as suggested by Tony Ladd */
+    for (ii = 0; ii < size; ii += bblock) {
+      MPI_Request* requests = new MPI_Request[2 * bblock];
 
 
-     // requests = xbt_new(MPI_Request, 2 * (bblock - 1));
-      int ii, ss, dst;
-      /* post only bblock isends/irecvs at a time as suggested by Tony Ladd */
-      for (ii=0; ii<size; ii+=bblock) {
-          requests = xbt_new(MPI_Request, 2 * (bblock ));
+      ss    = size - ii < bblock ? size - ii : bblock;
+      count = 0;
 
 
-          ss = size-ii < bblock ? size-ii : bblock;
-          count = 0;
-
-          /* do the communication -- post ss sends and receives: */
-          for ( i=0; i<ss; i++ ) {
-            dst = (rank+i+ii) % size;
-              if (dst == rank) {
-                XBT_DEBUG("<%d> skip request creation [src = %d, recvcount = %d]",
-                       rank, i, recvcounts[dst]);
-                continue;
-              }
-
-              requests[count]=Request::irecv((char *)recvbuf + recvdisps[dst] * recvext, recvcounts[dst],
-                                  recvtype, dst, system_tag, comm );
-              count++;
-            }
-            /* Now create all sends  */
-          for ( i=0; i<ss; i++ ) {
-              dst = (rank-i-ii+size) % size;
-              if (dst == rank) {
-                XBT_DEBUG("<%d> skip request creation [dst = %d, sendcount = %d]",
-                       rank, i, sendcounts[dst]);
-                continue;
-              }
-              requests[count]=Request::isend((char *)sendbuf + senddisps[dst] * sendext, sendcounts[dst],
-                                  sendtype, dst, system_tag, comm);
-              count++;
-            }
-            /* Wait for them all. */
-            //Colls::startall(count, requests);
-            XBT_DEBUG("<%d> wait for %d requests", rank, count);
-            Request::waitall(count, requests, MPI_STATUSES_IGNORE);
-            xbt_free(requests);
-
-          }
+      /* do the communication -- post ss sends and receives: */
+      for (i = 0; i < ss; i++) {
+        dst = (rank + i + ii) % size;
+        if (dst == rank) {
+          XBT_DEBUG("<%d> skip request creation [src = %d, recvcount = %d]", rank, i, recvcounts[dst]);
+          continue;
+        }
 
 
+        requests[count] =
+            Request::irecv((char*)recvbuf + recvdisps[dst] * recvext, recvcounts[dst], recvtype, dst, system_tag, comm);
+        count++;
+      }
+      /* Now create all sends  */
+      for (i = 0; i < ss; i++) {
+        dst = (rank - i - ii + size) % size;
+        if (dst == rank) {
+          XBT_DEBUG("<%d> skip request creation [dst = %d, sendcount = %d]", rank, i, sendcounts[dst]);
+          continue;
+        }
+        requests[count] =
+            Request::isend((char*)sendbuf + senddisps[dst] * sendext, sendcounts[dst], sendtype, dst, system_tag, comm);
+        count++;
+      }
+      /* Wait for them all. */
+      // Colls::startall(count, requests);
+      XBT_DEBUG("<%d> wait for %d requests", rank, count);
+      Request::waitall(count, requests, MPI_STATUSES_IGNORE);
+      delete[] requests;
+    }
   }
   return MPI_SUCCESS;
 }
   }
   return MPI_SUCCESS;
 }
index 5b646c6..de140a3 100644 (file)
@@ -30,7 +30,7 @@ Coll_alltoallv_ompi_basic_linear::alltoallv(const void *sbuf, const int *scounts
     MPI_Request *preq;
     size = comm->size();
     rank = comm->rank();
     MPI_Request *preq;
     size = comm->size();
     rank = comm->rank();
-    MPI_Request *ireqs= static_cast<MPI_Request*>(xbt_malloc(sizeof(MPI_Request) * size * 2));
+    MPI_Request* ireqs = new MPI_Request[size * 2];
     XBT_DEBUG(
                  "coll:tuned:alltoallv_intra_basic_linear rank %d", rank);
 
     XBT_DEBUG(
                  "coll:tuned:alltoallv_intra_basic_linear rank %d", rank);
 
@@ -101,7 +101,7 @@ Coll_alltoallv_ompi_basic_linear::alltoallv(const void *sbuf, const int *scounts
       if(ireqs[i]!=MPI_REQUEST_NULL)
         Request::unref(&ireqs[i]);
     }
       if(ireqs[i]!=MPI_REQUEST_NULL)
         Request::unref(&ireqs[i]);
     }
-    free(ireqs);
+    delete[] ireqs;
 
     return MPI_SUCCESS;
 }
 
     return MPI_SUCCESS;
 }
index 545705b..9a112c3 100644 (file)
@@ -17,11 +17,6 @@ int Coll_bcast_NTSB::bcast(void *buf, int count, MPI_Datatype datatype,
   int rank, size;
   int i;
 
   int rank, size;
   int i;
 
-  MPI_Request *send_request_array;
-  MPI_Request *recv_request_array;
-  MPI_Status *send_status_array;
-  MPI_Status *recv_status_array;
-
   MPI_Aint extent;
   extent = datatype->get_extent();
 
   MPI_Aint extent;
   extent = datatype->get_extent();
 
@@ -97,16 +92,10 @@ int Coll_bcast_NTSB::bcast(void *buf, int count, MPI_Datatype datatype,
   // pipelining
   else {
 
   // pipelining
   else {
 
-    send_request_array =
-        (MPI_Request *) xbt_malloc(2 * (size + pipe_length) * sizeof(MPI_Request));
-    recv_request_array =
-        (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-    send_status_array =
-        (MPI_Status *) xbt_malloc(2 * (size + pipe_length) * sizeof(MPI_Status));
-    recv_status_array =
-        (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
-
-
+    MPI_Request* send_request_array = new MPI_Request[2 * (size + pipe_length)];
+    MPI_Request* recv_request_array = new MPI_Request[size + pipe_length];
+    MPI_Status* send_status_array   = new MPI_Status[2 * (size + pipe_length)];
+    MPI_Status* recv_status_array   = new MPI_Status[size + pipe_length];
 
     /* case: root */
     if (rank == 0) {
 
     /* case: root */
     if (rank == 0) {
@@ -169,10 +158,10 @@ int Coll_bcast_NTSB::bcast(void *buf, int count, MPI_Datatype datatype,
       Request::waitall((2 * pipe_length), send_request_array, send_status_array);
     }
 
       Request::waitall((2 * pipe_length), send_request_array, send_status_array);
     }
 
-    free(send_request_array);
-    free(recv_request_array);
-    free(send_status_array);
-    free(recv_status_array);
+    delete[] send_request_array;
+    delete[] recv_request_array;
+    delete[] send_status_array;
+    delete[] recv_status_array;
   }                             /* end pipeline */
 
   /* when count is not divisible by block size, use default BCAST for the remainder */
   }                             /* end pipeline */
 
   /* when count is not divisible by block size, use default BCAST for the remainder */
index f480649..57857c0 100644 (file)
@@ -19,10 +19,6 @@ int Coll_bcast_NTSL_Isend::bcast(void *buf, int count, MPI_Datatype datatype,
   int tag = COLL_TAG_BCAST;
   MPI_Status status;
   MPI_Request request;
   int tag = COLL_TAG_BCAST;
   MPI_Status status;
   MPI_Request request;
-  MPI_Request *send_request_array;
-  MPI_Request *recv_request_array;
-  MPI_Status *send_status_array;
-  MPI_Status *recv_status_array;
   int rank, size;
   int i;
   MPI_Aint extent;
   int rank, size;
   int i;
   MPI_Aint extent;
@@ -76,14 +72,10 @@ int Coll_bcast_NTSL_Isend::bcast(void *buf, int count, MPI_Datatype datatype,
 
   /* pipeline bcast */
   else {
 
   /* pipeline bcast */
   else {
-    send_request_array =
-        (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-    recv_request_array =
-        (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-    send_status_array =
-        (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
-    recv_status_array =
-        (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
+    MPI_Request* send_request_array = new MPI_Request[size + pipe_length];
+    MPI_Request* recv_request_array = new MPI_Request[size + pipe_length];
+    MPI_Status* send_status_array   = new MPI_Status[size + pipe_length];
+    MPI_Status* recv_status_array   = new MPI_Status[size + pipe_length];
 
     /* root send data */
     if (rank == 0) {
 
     /* root send data */
     if (rank == 0) {
@@ -117,10 +109,10 @@ int Coll_bcast_NTSL_Isend::bcast(void *buf, int count, MPI_Datatype datatype,
       Request::waitall((pipe_length), send_request_array, send_status_array);
     }
 
       Request::waitall((pipe_length), send_request_array, send_status_array);
     }
 
-    free(send_request_array);
-    free(recv_request_array);
-    free(send_status_array);
-    free(recv_status_array);
+    delete[] send_request_array;
+    delete[] recv_request_array;
+    delete[] send_status_array;
+    delete[] recv_status_array;
   }                             /* end pipeline */
 
   /* when count is not divisible by block size, use default BCAST for the remainder */
   }                             /* end pipeline */
 
   /* when count is not divisible by block size, use default BCAST for the remainder */
index 56a5886..97e55c8 100644 (file)
@@ -19,10 +19,6 @@ int Coll_bcast_NTSL::bcast(void *buf, int count, MPI_Datatype datatype,
   int tag = COLL_TAG_BCAST;
   MPI_Status status;
   MPI_Request request;
   int tag = COLL_TAG_BCAST;
   MPI_Status status;
   MPI_Request request;
-  MPI_Request *send_request_array;
-  MPI_Request *recv_request_array;
-  MPI_Status *send_status_array;
-  MPI_Status *recv_status_array;
   int rank, size;
   int i;
   MPI_Aint extent;
   int rank, size;
   int i;
   MPI_Aint extent;
@@ -76,14 +72,10 @@ int Coll_bcast_NTSL::bcast(void *buf, int count, MPI_Datatype datatype,
 
   /* pipeline bcast */
   else {
 
   /* pipeline bcast */
   else {
-    send_request_array =
-        (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-    recv_request_array =
-        (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-    send_status_array =
-        (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
-    recv_status_array =
-        (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
+    MPI_Request* send_request_array = new MPI_Request[size + pipe_length];
+    MPI_Request* recv_request_array = new MPI_Request[size + pipe_length];
+    MPI_Status* send_status_array   = new MPI_Status[size + pipe_length];
+    MPI_Status* recv_status_array   = new MPI_Status[size + pipe_length];
 
     /* root send data */
     if (rank == 0) {
 
     /* root send data */
     if (rank == 0) {
@@ -117,10 +109,10 @@ int Coll_bcast_NTSL::bcast(void *buf, int count, MPI_Datatype datatype,
       Request::waitall((pipe_length), send_request_array, send_status_array);
     }
 
       Request::waitall((pipe_length), send_request_array, send_status_array);
     }
 
-    free(send_request_array);
-    free(recv_request_array);
-    free(send_status_array);
-    free(recv_status_array);
+    delete[] send_request_array;
+    delete[] recv_request_array;
+    delete[] send_status_array;
+    delete[] recv_status_array;
   }                             /* end pipeline */
 
   /* when count is not divisible by block size, use default BCAST for the remainder */
   }                             /* end pipeline */
 
   /* when count is not divisible by block size, use default BCAST for the remainder */
index 3b7d4eb..3ce7918 100644 (file)
@@ -16,8 +16,6 @@ int Coll_bcast_SMP_binary::bcast(void *buf, int count,
   int tag = COLL_TAG_BCAST;
   MPI_Status status;
   MPI_Request request;
   int tag = COLL_TAG_BCAST;
   MPI_Status status;
   MPI_Request request;
-  MPI_Request *request_array;
-  MPI_Status *status_array;
   int rank, size;
   int i;
   MPI_Aint extent;
   int rank, size;
   int i;
   MPI_Aint extent;
@@ -123,10 +121,8 @@ int Coll_bcast_SMP_binary::bcast(void *buf, int count,
 
   // pipeline bcast
   else {
 
   // pipeline bcast
   else {
-    request_array =
-        (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-    status_array =
-        (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
+    MPI_Request* request_array = new MPI_Request[size + pipe_length];
+    MPI_Status* status_array   = new MPI_Status[size + pipe_length];
 
     // case ROOT-of-each-SMP
     if (rank % host_num_core == 0) {
 
     // case ROOT-of-each-SMP
     if (rank % host_num_core == 0) {
@@ -215,8 +211,8 @@ int Coll_bcast_SMP_binary::bcast(void *buf, int count,
       }
     }
 
       }
     }
 
-    free(request_array);
-    free(status_array);
+    delete[] request_array;
+    delete[] status_array;
   }
 
   // when count is not divisible by block size, use default BCAST for the remainder
   }
 
   // when count is not divisible by block size, use default BCAST for the remainder
index 4f1a90e..a8c6bec 100644 (file)
@@ -16,8 +16,6 @@ int Coll_bcast_SMP_linear::bcast(void *buf, int count,
   int tag = COLL_TAG_BCAST;
   MPI_Status status;
   MPI_Request request;
   int tag = COLL_TAG_BCAST;
   MPI_Status status;
   MPI_Request request;
-  MPI_Request *request_array;
-  MPI_Status *status_array;
   int rank, size;
   int i;
   MPI_Aint extent;
   int rank, size;
   int i;
   MPI_Aint extent;
@@ -99,10 +97,8 @@ int Coll_bcast_SMP_linear::bcast(void *buf, int count,
   }
   // pipeline bcast
   else {
   }
   // pipeline bcast
   else {
-    request_array =
-        (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-    status_array =
-        (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
+    MPI_Request* request_array = new MPI_Request[size + pipe_length];
+    MPI_Status* status_array   = new MPI_Status[size + pipe_length];
 
     // case ROOT of each SMP
     if (rank % num_core == 0) {
 
     // case ROOT of each SMP
     if (rank % num_core == 0) {
@@ -164,8 +160,8 @@ int Coll_bcast_SMP_linear::bcast(void *buf, int count,
         }
       }
     }
         }
       }
     }
-    free(request_array);
-    free(status_array);
+    delete[] request_array;
+    delete[] status_array;
   }
 
   // when count is not divisible by block size, use default BCAST for the remainder
   }
 
   // when count is not divisible by block size, use default BCAST for the remainder
index e764c4b..46e6125 100644 (file)
@@ -24,11 +24,6 @@ int Coll_bcast_arrival_pattern_aware_wait::bcast(void *buf, int count,
 {
   MPI_Status status;
   MPI_Request request;
 {
   MPI_Status status;
   MPI_Request request;
-  MPI_Request *send_request_array;
-  MPI_Request *recv_request_array;
-  MPI_Status *send_status_array;
-  MPI_Status *recv_status_array;
-
 
   MPI_Status temp_status_array[BCAST_ARRIVAL_PATTERN_AWARE_MAX_NODE];
 
 
   MPI_Status temp_status_array[BCAST_ARRIVAL_PATTERN_AWARE_MAX_NODE];
 
@@ -98,14 +93,10 @@ int Coll_bcast_arrival_pattern_aware_wait::bcast(void *buf, int count,
 
   /* start pipeline bcast */
 
 
   /* start pipeline bcast */
 
-  send_request_array =
-      (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-  recv_request_array =
-      (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-  send_status_array =
-      (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
-  recv_status_array =
-      (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
+  MPI_Request* send_request_array = new MPI_Request[size + pipe_length];
+  MPI_Request* recv_request_array = new MPI_Request[size + pipe_length];
+  MPI_Status* send_status_array   = new MPI_Status[size + pipe_length];
+  MPI_Status* recv_status_array   = new MPI_Status[size + pipe_length];
 
   /* root */
   if (rank == 0) {
 
   /* root */
   if (rank == 0) {
@@ -239,10 +230,10 @@ int Coll_bcast_arrival_pattern_aware_wait::bcast(void *buf, int count,
     }
   }
 
     }
   }
 
-  free(send_request_array);
-  free(recv_request_array);
-  free(send_status_array);
-  free(recv_status_array);
+  delete[] send_request_array;
+  delete[] recv_request_array;
+  delete[] send_status_array;
+  delete[] recv_status_array;
   /* end pipeline */
 
   /* when count is not divisible by block size, use default BCAST for the remainder */
   /* end pipeline */
 
   /* when count is not divisible by block size, use default BCAST for the remainder */
index 7783792..1552b72 100644 (file)
@@ -21,10 +21,6 @@ int Coll_bcast_arrival_pattern_aware::bcast(void *buf, int count,
   int tag = -COLL_TAG_BCAST;
   MPI_Status status;
   MPI_Request request;
   int tag = -COLL_TAG_BCAST;
   MPI_Status status;
   MPI_Request request;
-  MPI_Request *send_request_array;
-  MPI_Request *recv_request_array;
-  MPI_Status *send_status_array;
-  MPI_Status *recv_status_array;
 
   MPI_Status temp_status_array[MAX_NODE];
 
 
   MPI_Status temp_status_array[MAX_NODE];
 
@@ -163,14 +159,10 @@ int Coll_bcast_arrival_pattern_aware::bcast(void *buf, int count,
   }
   /* pipeline bcast */
   else {
   }
   /* pipeline bcast */
   else {
-    send_request_array =
-        (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-    recv_request_array =
-        (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-    send_status_array =
-        (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
-    recv_status_array =
-        (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
+    MPI_Request* send_request_array = new MPI_Request[size + pipe_length];
+    MPI_Request* recv_request_array = new MPI_Request[size + pipe_length];
+    MPI_Status* send_status_array   = new MPI_Status[size + pipe_length];
+    MPI_Status* recv_status_array   = new MPI_Status[size + pipe_length];
 
     if (rank == 0) {
       //double start2 = MPI_Wtime();
 
     if (rank == 0) {
       //double start2 = MPI_Wtime();
@@ -350,10 +342,10 @@ int Coll_bcast_arrival_pattern_aware::bcast(void *buf, int count,
 
     }
 
 
     }
 
-    free(send_request_array);
-    free(recv_request_array);
-    free(send_status_array);
-    free(recv_status_array);
+    delete[] send_request_array;
+    delete[] recv_request_array;
+    delete[] send_status_array;
+    delete[] recv_status_array;
   }                             /* end pipeline */
 
   /* when count is not divisible by block size, use default BCAST for the remainder */
   }                             /* end pipeline */
 
   /* when count is not divisible by block size, use default BCAST for the remainder */
index 81406c8..07e4384 100644 (file)
@@ -31,11 +31,8 @@ Coll_bcast_flattree_pipeline::bcast(void *buff, int count,
   rank = comm->rank();
   num_procs = comm->size();
 
   rank = comm->rank();
   num_procs = comm->size();
 
-  MPI_Request *request_array;
-  MPI_Status *status_array;
-
-  request_array = (MPI_Request *) xbt_malloc(pipe_length * sizeof(MPI_Request));
-  status_array = (MPI_Status *) xbt_malloc(pipe_length * sizeof(MPI_Status));
+  MPI_Request* request_array = new MPI_Request[pipe_length];
+  MPI_Status* status_array   = new MPI_Status[pipe_length];
 
   if (rank != root) {
     for (i = 0; i < pipe_length; i++) {
 
   if (rank != root) {
     for (i = 0; i < pipe_length; i++) {
@@ -58,8 +55,8 @@ Coll_bcast_flattree_pipeline::bcast(void *buff, int count,
 
   }
 
 
   }
 
-  free(request_array);
-  free(status_array);
+  delete[] request_array;
+  delete[] status_array;
   return MPI_SUCCESS;
 }
 
   return MPI_SUCCESS;
 }
 
index 7178f2a..175c875 100644 (file)
@@ -11,9 +11,6 @@ int
 Coll_bcast_flattree::bcast(void *buff, int count, MPI_Datatype data_type,
                                int root, MPI_Comm comm)
 {
 Coll_bcast_flattree::bcast(void *buff, int count, MPI_Datatype data_type,
                                int root, MPI_Comm comm)
 {
-  MPI_Request *req_ptr;
-  MPI_Request *reqs;
-
   int i, rank, num_procs;
   int tag = COLL_TAG_BCAST;
 
   int i, rank, num_procs;
   int tag = COLL_TAG_BCAST;
 
@@ -25,8 +22,8 @@ Coll_bcast_flattree::bcast(void *buff, int count, MPI_Datatype data_type,
   }
 
   else {
   }
 
   else {
-    reqs = (MPI_Request *) xbt_malloc((num_procs - 1) * sizeof(MPI_Request));
-    req_ptr = reqs;
+    MPI_Request* reqs    = new MPI_Request[num_procs - 1];
+    MPI_Request* req_ptr = reqs;
 
     // Root sends data to all others
     for (i = 0; i < num_procs; i++) {
 
     // Root sends data to all others
     for (i = 0; i < num_procs; i++) {
@@ -38,7 +35,7 @@ Coll_bcast_flattree::bcast(void *buff, int count, MPI_Datatype data_type,
     // wait on all requests
     Request::waitall(num_procs - 1, reqs, MPI_STATUSES_IGNORE);
 
     // wait on all requests
     Request::waitall(num_procs - 1, reqs, MPI_STATUSES_IGNORE);
 
-    free(reqs);
+    delete[] reqs;
   }
   return MPI_SUCCESS;
 }
   }
   return MPI_SUCCESS;
 }
index b65ef8e..d7f6a3b 100644 (file)
@@ -177,8 +177,6 @@ int Coll_bcast_mvapich2_knomial_intra_node::bcast(void *buffer,
 {
     int local_size = 0, rank;
     int mpi_errno = MPI_SUCCESS;
 {
     int local_size = 0, rank;
     int mpi_errno = MPI_SUCCESS;
-    MPI_Request *reqarray = NULL;
-    MPI_Status *starray = NULL;
     int src, dst, mask, relative_rank;
     int k;
     if (MV2_Bcast_function==NULL){
     int src, dst, mask, relative_rank;
     int k;
     if (MV2_Bcast_function==NULL){
@@ -196,10 +194,9 @@ int Coll_bcast_mvapich2_knomial_intra_node::bcast(void *buffer,
     local_size = comm->size();
     rank = comm->rank();
 
     local_size = comm->size();
     rank = comm->rank();
 
+    MPI_Request* reqarray = new MPI_Request[2 * mv2_intra_node_knomial_factor];
 
 
-    reqarray=(MPI_Request *)xbt_malloc(2 * mv2_intra_node_knomial_factor * sizeof (MPI_Request));
-
-    starray=(MPI_Status *)xbt_malloc(2 * mv2_intra_node_knomial_factor * sizeof (MPI_Status));
+    MPI_Status* starray = new MPI_Status[2 * mv2_intra_node_knomial_factor];
 
     /* intra-node k-nomial bcast  */
     if (local_size > 1) {
 
     /* intra-node k-nomial bcast  */
     if (local_size > 1) {
@@ -240,8 +237,8 @@ int Coll_bcast_mvapich2_knomial_intra_node::bcast(void *buffer,
             mask /= mv2_intra_node_knomial_factor;
         }
     }
             mask /= mv2_intra_node_knomial_factor;
         }
     }
-    xbt_free(reqarray);
-    xbt_free(starray);
+    delete[] reqarray;
+    delete[] starray;
     return mpi_errno;
 }
 
     return mpi_errno;
 }
 
index 88c6b7d..1a3cb9b 100644 (file)
@@ -78,7 +78,7 @@ Coll_bcast_scatter_LR_allgather::bcast(void *buff, int count,
   MPI_Status status;
   int i, src, dst, rank, num_procs;
   int mask, relative_rank, curr_size, recv_size, send_size, nbytes;
   MPI_Status status;
   int i, src, dst, rank, num_procs;
   int mask, relative_rank, curr_size, recv_size, send_size, nbytes;
-  int scatter_size, left, right, next_src, *recv_counts, *disps;
+  int scatter_size, left, right, next_src;
   int tag = COLL_TAG_BCAST;
 
   rank = comm->rank();
   int tag = COLL_TAG_BCAST;
 
   rank = comm->rank();
@@ -139,8 +139,8 @@ Coll_bcast_scatter_LR_allgather::bcast(void *buff, int count,
   }
 
   // done scatter now do allgather
   }
 
   // done scatter now do allgather
-  recv_counts = (int *) xbt_malloc(sizeof(int) * num_procs);
-  disps = (int *) xbt_malloc(sizeof(int) * num_procs);
+  int* recv_counts = new int[num_procs];
+  int* disps       = new int[num_procs];
 
   for (i = 0; i < num_procs; i++) {
     recv_counts[i] = nbytes - i * scatter_size;
 
   for (i = 0; i < num_procs; i++) {
     recv_counts[i] = nbytes - i * scatter_size;
@@ -172,9 +172,8 @@ Coll_bcast_scatter_LR_allgather::bcast(void *buff, int count,
     next_src = (num_procs + next_src - 1) % num_procs;
   }
 
     next_src = (num_procs + next_src - 1) % num_procs;
   }
 
-
-  free(recv_counts);
-  free(disps);
+  delete[] recv_counts;
+  delete[] disps;
 
   return MPI_SUCCESS;
 }
 
   return MPI_SUCCESS;
 }
index 2bd91df..d8cb946 100644 (file)
@@ -162,15 +162,15 @@ Coll_bcast_scatter_rdb_allgather::bcast (
     }
     else
     {
     }
     else
     {
-        tmp_buf=(void*)xbt_malloc(nbytes);
-
-        /* TODO: Pipeline the packing and communication */
-        position = 0;
-        if (rank == root) {
-            mpi_errno = datatype->pack(buffer, count, tmp_buf, nbytes,
-                                       &position, comm);
-            if (mpi_errno) xbt_die("crash while packing %d", mpi_errno);
-        }
+      tmp_buf = new unsigned char[nbytes];
+
+      /* TODO: Pipeline the packing and communication */
+      position = 0;
+      if (rank == root) {
+        mpi_errno = datatype->pack(buffer, count, tmp_buf, nbytes, &position, comm);
+        if (mpi_errno)
+          xbt_die("crash while packing %d", mpi_errno);
+      }
     }
 
 
     }
 
 
@@ -334,8 +334,8 @@ Coll_bcast_scatter_rdb_allgather::bcast (
     }
 
 fn_exit:
     }
 
 fn_exit:
-/*    xbt_free(tmp_buf);*/
-    return mpi_errno;
+  /* delete[] static_cast<unsigned char*>(tmp_buf); */
+  return mpi_errno;
 }
 
 }
 }
 
 }
index 7d0a4e3..48946ed 100644 (file)
@@ -303,12 +303,8 @@ int Coll_gather_mvapich2_two_level::gather(const void *sendbuf,
         node_sizes = comm->get_non_uniform_map();
 
         if (leader_comm_rank == leader_root) {
         node_sizes = comm->get_non_uniform_map();
 
         if (leader_comm_rank == leader_root) {
-          displs   = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
-          recvcnts = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
-          if (not displs || not recvcnts) {
-            mpi_errno = MPI_ERR_OTHER;
-            return mpi_errno;
-          }
+          displs   = new int[leader_comm_size];
+          recvcnts = new int[leader_comm_size];
         }
 
         if (root == leader_of_root) {
         }
 
         if (root == leader_of_root) {
@@ -342,8 +338,8 @@ int Coll_gather_mvapich2_two_level::gather(const void *sendbuf,
                          leader_root, leader_comm);
         }
         if (leader_comm_rank == leader_root) {
                          leader_root, leader_comm);
         }
         if (leader_comm_rank == leader_root) {
-          xbt_free(displs);
-          xbt_free(recvcnts);
+          delete[] displs;
+          delete[] recvcnts;
         }
       }
     } else {
         }
       }
     } else {
index e07d5ac..e8f6dec 100644 (file)
@@ -20,10 +20,6 @@ int Coll_reduce_NTSL::reduce(const void *buf, void *rbuf, int count,
 {
   int tag = COLL_TAG_REDUCE;
   MPI_Status status;
 {
   int tag = COLL_TAG_REDUCE;
   MPI_Status status;
-  MPI_Request *send_request_array;
-  MPI_Request *recv_request_array;
-  MPI_Status *send_status_array;
-  MPI_Status *recv_status_array;
   int rank, size;
   int i;
   MPI_Aint extent;
   int rank, size;
   int i;
   MPI_Aint extent;
@@ -88,14 +84,10 @@ int Coll_reduce_NTSL::reduce(const void *buf, void *rbuf, int count,
 
   /* pipeline */
   else {
 
   /* pipeline */
   else {
-    send_request_array =
-        (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-    recv_request_array =
-        (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-    send_status_array =
-        (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
-    recv_status_array =
-        (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
+    MPI_Request* send_request_array = new MPI_Request[size + pipe_length];
+    MPI_Request* recv_request_array = new MPI_Request[size + pipe_length];
+    MPI_Status* send_status_array   = new MPI_Status[size + pipe_length];
+    MPI_Status* recv_status_array   = new MPI_Status[size + pipe_length];
 
     /* root recv data */
     if (rank == root) {
 
     /* root recv data */
     if (rank == root) {
@@ -135,10 +127,10 @@ int Coll_reduce_NTSL::reduce(const void *buf, void *rbuf, int count,
       Request::waitall((pipe_length), send_request_array, send_status_array);
     }
 
       Request::waitall((pipe_length), send_request_array, send_status_array);
     }
 
-    free(send_request_array);
-    free(recv_request_array);
-    free(send_status_array);
-    free(recv_status_array);
+    delete[] send_request_array;
+    delete[] recv_request_array;
+    delete[] send_status_array;
+    delete[] recv_status_array;
   }                             /* end pipeline */
 
   /* when count is not divisible by block size, use default BCAST for the remainder */
   }                             /* end pipeline */
 
   /* when count is not divisible by block size, use default BCAST for the remainder */
index 63454dc..8f0b202 100644 (file)
@@ -29,10 +29,6 @@ int Coll_reduce_arrival_pattern_aware::reduce(const void *buf, void *rbuf,
   int tag = -COLL_TAG_REDUCE;
   MPI_Status status;
   MPI_Request request;
   int tag = -COLL_TAG_REDUCE;
   MPI_Status status;
   MPI_Request request;
-  MPI_Request *send_request_array;
-  MPI_Request *recv_request_array;
-  MPI_Status *send_status_array;
-  MPI_Status *recv_status_array;
 
   MPI_Status temp_status_array[MAX_NODE];
 
 
   MPI_Status temp_status_array[MAX_NODE];
 
@@ -190,14 +186,10 @@ int Coll_reduce_arrival_pattern_aware::reduce(const void *buf, void *rbuf,
   else {
     //    printf("node %d start\n",rank);
 
   else {
     //    printf("node %d start\n",rank);
 
-    send_request_array =
-        (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-    recv_request_array =
-        (MPI_Request *) xbt_malloc((size + pipe_length) * sizeof(MPI_Request));
-    send_status_array =
-        (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
-    recv_status_array =
-        (MPI_Status *) xbt_malloc((size + pipe_length) * sizeof(MPI_Status));
+    MPI_Request* send_request_array = new MPI_Request[size + pipe_length];
+    MPI_Request* recv_request_array = new MPI_Request[size + pipe_length];
+    MPI_Status* send_status_array   = new MPI_Status[size + pipe_length];
+    MPI_Status* recv_status_array   = new MPI_Status[size + pipe_length];
 
     if (rank == 0) {
       sent_count = 0;
 
     if (rank == 0) {
       sent_count = 0;
@@ -319,13 +311,10 @@ int Coll_reduce_arrival_pattern_aware::reduce(const void *buf, void *rbuf,
       }
     }                           /* non-root */
 
       }
     }                           /* non-root */
 
-
-
-
-    free(send_request_array);
-    free(recv_request_array);
-    free(send_status_array);
-    free(recv_status_array);
+    delete[] send_request_array;
+    delete[] recv_request_array;
+    delete[] send_status_array;
+    delete[] recv_status_array;
 
     //printf("node %d done\n",rank);
   }                             /* end pipeline */
 
     //printf("node %d done\n",rank);
   }                             /* end pipeline */
index 25b6757..02328fb 100644 (file)
@@ -136,9 +136,6 @@ int Coll_reduce_mvapich2_knomial::reduce (
     MPI_Status status;
     int recv_iter=0, dst=-1, expected_send_count, expected_recv_count;
     int *src_array=NULL;
     MPI_Status status;
     int recv_iter=0, dst=-1, expected_send_count, expected_recv_count;
     int *src_array=NULL;
-    void **tmp_buf=NULL;
-    MPI_Request *requests=NULL;
-
 
     if (count == 0) return MPI_SUCCESS;
 
 
     if (count == 0) return MPI_SUCCESS;
 
@@ -176,11 +173,11 @@ int Coll_reduce_mvapich2_knomial::reduce (
            &dst, &expected_send_count, &expected_recv_count, &src_array);
 
     if(expected_recv_count > 0 ) {
            &dst, &expected_send_count, &expected_recv_count, &src_array);
 
     if(expected_recv_count > 0 ) {
-        tmp_buf  = static_cast<void**>(xbt_malloc(sizeof(void *)*expected_recv_count));
-        requests = static_cast<MPI_Request*>(xbt_malloc(sizeof(MPI_Request)*expected_recv_count));
-        for(k=0; k < expected_recv_count; k++ ) {
-            tmp_buf[k] = smpi_get_tmp_sendbuffer(count * std::max(extent, true_extent));
-            tmp_buf[k] = (void *)((char*)tmp_buf[k] - true_lb);
+      void** tmp_buf        = new void*[expected_recv_count];
+      MPI_Request* requests = new MPI_Request[expected_recv_count];
+      for (k = 0; k < expected_recv_count; k++) {
+        tmp_buf[k] = smpi_get_tmp_sendbuffer(count * std::max(extent, true_extent));
+        tmp_buf[k] = (void*)((char*)tmp_buf[k] - true_lb);
         }
 
         while(recv_iter  < expected_recv_count) {
         }
 
         while(recv_iter  < expected_recv_count) {
@@ -206,8 +203,8 @@ int Coll_reduce_mvapich2_knomial::reduce (
         for(k=0; k < expected_recv_count; k++ ) {
             smpi_free_tmp_buffer(tmp_buf[k]);
         }
         for(k=0; k < expected_recv_count; k++ ) {
             smpi_free_tmp_buffer(tmp_buf[k]);
         }
-        xbt_free(tmp_buf);
-        xbt_free(requests);
+        delete[] tmp_buf;
+        delete[] requests;
     }
 
     if(src_array != NULL) {
     }
 
     if(src_array != NULL) {
index 5bfa4ed..07eb4bd 100644 (file)
@@ -75,8 +75,8 @@ int Coll_reduce_scatter_gather::reduce(const void *sendbuf, void *recvbuf,
     } else                      /* rank >= 2*rem */
       newrank = rank - rem;
 
     } else                      /* rank >= 2*rem */
       newrank = rank - rem;
 
-    cnts = (int *) xbt_malloc(pof2 * sizeof(int));
-    disps = (int *) xbt_malloc(pof2 * sizeof(int));
+    cnts  = new int[pof2];
+    disps = new int[pof2];
 
     if (newrank != -1) {
       for (i = 0; i < (pof2 - 1); i++)
 
     if (newrank != -1) {
       for (i = 0; i < (pof2 - 1); i++)
@@ -252,8 +252,8 @@ int Coll_reduce_scatter_gather::reduce(const void *sendbuf, void *recvbuf,
     } else                      /* rank >= 2*rem */
       newrank = rank - rem;
 
     } else                      /* rank >= 2*rem */
       newrank = rank - rem;
 
-    cnts = (int *) xbt_malloc(pof2 * sizeof(int));
-    disps = (int *) xbt_malloc(pof2 * sizeof(int));
+    cnts  = new int[pof2];
+    disps = new int[pof2];
 
     if (newrank != -1) {
       for (i = 0; i < (pof2 - 1); i++)
 
     if (newrank != -1) {
       for (i = 0; i < (pof2 - 1); i++)
@@ -404,10 +404,8 @@ int Coll_reduce_scatter_gather::reduce(const void *sendbuf, void *recvbuf,
   if (tmp_buf)
     smpi_free_tmp_buffer(tmp_buf);
   if(temporary_buffer==1) smpi_free_tmp_buffer(recvbuf);
   if (tmp_buf)
     smpi_free_tmp_buffer(tmp_buf);
   if(temporary_buffer==1) smpi_free_tmp_buffer(recvbuf);
-  if (cnts)
-    free(cnts);
-  if (disps)
-    free(disps);
+  delete[] cnts;
+  delete[] disps;
 
   return 0;
 }
 
   return 0;
 }
index 1b590b7..74bc225 100644 (file)
@@ -29,7 +29,6 @@ int Coll_reduce_scatter_mpich_pair::reduce_scatter(const void *sendbuf, void *re
 {
     int   rank, comm_size, i;
     MPI_Aint extent, true_extent, true_lb;
 {
     int   rank, comm_size, i;
     MPI_Aint extent, true_extent, true_lb;
-    int  *disps;
     void *tmp_recvbuf;
     int mpi_errno = MPI_SUCCESS;
     int total_count, dst, src;
     void *tmp_recvbuf;
     int mpi_errno = MPI_SUCCESS;
     int total_count, dst, src;
@@ -44,7 +43,7 @@ int Coll_reduce_scatter_mpich_pair::reduce_scatter(const void *sendbuf, void *re
         is_commutative = 1;
     }
 
         is_commutative = 1;
     }
 
-    disps = (int*)xbt_malloc( comm_size * sizeof(int));
+    int* disps = new int[comm_size];
 
     total_count = 0;
     for (i=0; i<comm_size; i++) {
 
     total_count = 0;
     for (i=0; i<comm_size; i++) {
@@ -53,8 +52,8 @@ int Coll_reduce_scatter_mpich_pair::reduce_scatter(const void *sendbuf, void *re
     }
 
     if (total_count == 0) {
     }
 
     if (total_count == 0) {
-        xbt_free(disps);
-        return MPI_ERR_COUNT;
+      delete[] disps;
+      return MPI_ERR_COUNT;
     }
 
         if (sendbuf != MPI_IN_PLACE) {
     }
 
         if (sendbuf != MPI_IN_PLACE) {
@@ -138,7 +137,7 @@ int Coll_reduce_scatter_mpich_pair::reduce_scatter(const void *sendbuf, void *re
             if (mpi_errno) return(mpi_errno);
         }
 
             if (mpi_errno) return(mpi_errno);
         }
 
-        xbt_free(disps);
+        delete[] disps;
         smpi_free_tmp_buffer(tmp_recvbuf);
 
         return MPI_SUCCESS;
         smpi_free_tmp_buffer(tmp_recvbuf);
 
         return MPI_SUCCESS;
@@ -267,7 +266,6 @@ int Coll_reduce_scatter_mpich_rdb::reduce_scatter(const void *sendbuf, void *rec
 {
     int   rank, comm_size, i;
     MPI_Aint extent, true_extent, true_lb;
 {
     int   rank, comm_size, i;
     MPI_Aint extent, true_extent, true_lb;
-    int  *disps;
     void *tmp_recvbuf, *tmp_results;
     int mpi_errno = MPI_SUCCESS;
     int dis[2], blklens[2], total_count, dst;
     void *tmp_recvbuf, *tmp_results;
     int mpi_errno = MPI_SUCCESS;
     int dis[2], blklens[2], total_count, dst;
@@ -285,7 +283,7 @@ int Coll_reduce_scatter_mpich_rdb::reduce_scatter(const void *sendbuf, void *rec
         is_commutative = 1;
     }
 
         is_commutative = 1;
     }
 
-    disps = (int*)xbt_malloc( comm_size * sizeof(int));
+    int* disps = new int[comm_size];
 
     total_count = 0;
     for (i=0; i<comm_size; i++) {
 
     total_count = 0;
     for (i=0; i<comm_size; i++) {
@@ -485,7 +483,7 @@ int Coll_reduce_scatter_mpich_rdb::reduce_scatter(const void *sendbuf, void *rec
                                        recvcounts[rank], datatype);
             if (mpi_errno) return(mpi_errno);
 
                                        recvcounts[rank], datatype);
             if (mpi_errno) return(mpi_errno);
 
-    xbt_free(disps);
+    delete[] disps;
     smpi_free_tmp_buffer(tmp_recvbuf);
     smpi_free_tmp_buffer(tmp_results);
     return MPI_SUCCESS;
     smpi_free_tmp_buffer(tmp_recvbuf);
     smpi_free_tmp_buffer(tmp_results);
     return MPI_SUCCESS;
index bcd2dce..4b3a479 100644 (file)
@@ -53,7 +53,7 @@ Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter(const void *sbuf
                                                             )
 {
     int i, rank, size, count, err = MPI_SUCCESS;
                                                             )
 {
     int i, rank, size, count, err = MPI_SUCCESS;
-    int tmp_size=1, remain = 0, tmp_rank, *disps = NULL;
+    int tmp_size = 1, remain = 0, tmp_rank;
     ptrdiff_t true_lb, true_extent, lb, extent, buf_size;
     char *recv_buf = NULL, *recv_buf_free = NULL;
     char *result_buf = NULL, *result_buf_free = NULL;
     ptrdiff_t true_lb, true_extent, lb, extent, buf_size;
     char *recv_buf = NULL, *recv_buf_free = NULL;
     char *result_buf = NULL, *result_buf_free = NULL;
@@ -67,8 +67,7 @@ Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter(const void *sbuf
       THROWF(arg_error,0, " reduce_scatter ompi_basic_recursivehalving can only be used for commutative operations! ");
 
     /* Find displacements and the like */
       THROWF(arg_error,0, " reduce_scatter ompi_basic_recursivehalving can only be used for commutative operations! ");
 
     /* Find displacements and the like */
-    disps = (int*) xbt_malloc(sizeof(int) * size);
-    if (NULL == disps) return MPI_ERR_OTHER;
+    int* disps = new int[size];
 
     disps[0] = 0;
     for (i = 0; i < (size - 1); ++i) {
 
     disps[0] = 0;
     for (i = 0; i < (size - 1); ++i) {
@@ -78,8 +77,8 @@ Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter(const void *sbuf
 
     /* short cut the trivial case */
     if (0 == count) {
 
     /* short cut the trivial case */
     if (0 == count) {
-        xbt_free(disps);
-        return MPI_SUCCESS;
+      delete[] disps;
+      return MPI_SUCCESS;
     }
 
     /* get datatype information */
     }
 
     /* get datatype information */
@@ -147,23 +146,13 @@ Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter(const void *sbuf
     /* For ranks not kicked out by the above code, perform the
        recursive halving */
     if (tmp_rank >= 0) {
     /* For ranks not kicked out by the above code, perform the
        recursive halving */
     if (tmp_rank >= 0) {
-        int *tmp_disps = NULL, *tmp_rcounts = NULL;
         int mask, send_index, recv_index, last_index;
 
         /* recalculate disps and rcounts to account for the
            special "remainder" processes that are no longer doing
            anything */
         int mask, send_index, recv_index, last_index;
 
         /* recalculate disps and rcounts to account for the
            special "remainder" processes that are no longer doing
            anything */
-        tmp_rcounts = (int*) xbt_malloc(tmp_size * sizeof(int));
-        if (NULL == tmp_rcounts) {
-            err = MPI_ERR_OTHER;
-            goto cleanup;
-        }
-        tmp_disps = (int*) xbt_malloc(tmp_size * sizeof(int));
-        if (NULL == tmp_disps) {
-            xbt_free(tmp_rcounts);
-            err = MPI_ERR_OTHER;
-            goto cleanup;
-        }
+        int* tmp_rcounts = new int[tmp_size];
+        int* tmp_disps   = new int[tmp_size];
 
         for (i = 0 ; i < tmp_size ; ++i) {
             if (i < remain) {
 
         for (i = 0 ; i < tmp_size ; ++i) {
             if (i < remain) {
@@ -221,9 +210,9 @@ Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter(const void *sbuf
                                          COLL_TAG_REDUCE_SCATTER,
                                          comm);
                 if (MPI_SUCCESS != err) {
                                          COLL_TAG_REDUCE_SCATTER,
                                          comm);
                 if (MPI_SUCCESS != err) {
-                    xbt_free(tmp_rcounts);
-                    xbt_free(tmp_disps);
-                    goto cleanup;
+                  delete[] tmp_rcounts;
+                  delete[] tmp_disps;
+                  goto cleanup;
                 }
             }
             if (recv_count > 0 && send_count != 0) {
                 }
             }
             if (recv_count > 0 && send_count != 0) {
@@ -232,9 +221,9 @@ Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter(const void *sbuf
                                         COLL_TAG_REDUCE_SCATTER,
                                         comm);
                 if (MPI_SUCCESS != err) {
                                         COLL_TAG_REDUCE_SCATTER,
                                         comm);
                 if (MPI_SUCCESS != err) {
-                    xbt_free(tmp_rcounts);
-                    xbt_free(tmp_disps);
-                    goto cleanup;
+                  delete[] tmp_rcounts;
+                  delete[] tmp_disps;
+                  goto cleanup;
                 }
             }
             if (send_count > 0 && recv_count != 0) {
                 }
             }
             if (send_count > 0 && recv_count != 0) {
@@ -262,14 +251,14 @@ Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter(const void *sbuf
                                        rcounts[rank], dtype,
                                        rbuf, rcounts[rank], dtype);
             if (MPI_SUCCESS != err) {
                                        rcounts[rank], dtype,
                                        rbuf, rcounts[rank], dtype);
             if (MPI_SUCCESS != err) {
-                xbt_free(tmp_rcounts);
-                xbt_free(tmp_disps);
-                goto cleanup;
+              delete[] tmp_rcounts;
+              delete[] tmp_disps;
+              goto cleanup;
             }
         }
 
             }
         }
 
-        xbt_free(tmp_rcounts);
-        xbt_free(tmp_disps);
+        delete[] tmp_rcounts;
+        delete[] tmp_disps;
     }
 
     /* Now fix up the non-power of two case, by having the odd
     }
 
     /* Now fix up the non-power of two case, by having the odd
@@ -292,7 +281,7 @@ Coll_reduce_scatter_ompi_basic_recursivehalving::reduce_scatter(const void *sbuf
     }
 
  cleanup:
     }
 
  cleanup:
-    if (NULL != disps) xbt_free(disps);
+    delete[] disps;
     if (NULL != recv_buf_free) smpi_free_tmp_buffer(recv_buf_free);
     if (NULL != result_buf_free) smpi_free_tmp_buffer(result_buf_free);
 
     if (NULL != recv_buf_free) smpi_free_tmp_buffer(recv_buf_free);
     if (NULL != result_buf_free) smpi_free_tmp_buffer(result_buf_free);
 
@@ -369,7 +358,7 @@ Coll_reduce_scatter_ompi_ring::reduce_scatter(const void *sbuf, void *rbuf, cons
                                           )
 {
     int ret, line, rank, size, i, k, recv_from, send_to, total_count, max_block_count;
                                           )
 {
     int ret, line, rank, size, i, k, recv_from, send_to, total_count, max_block_count;
-    int inbi, *displs = NULL;
+    int inbi;
     char *tmpsend = NULL, *tmprecv = NULL, *accumbuf = NULL, *accumbuf_free = NULL;
     char *inbuf_free[2] = {NULL, NULL}, *inbuf[2] = {NULL, NULL};
     ptrdiff_t true_lb, true_extent, lb, extent, max_real_segsize;
     char *tmpsend = NULL, *tmprecv = NULL, *accumbuf = NULL, *accumbuf_free = NULL;
     char *inbuf_free[2] = {NULL, NULL}, *inbuf[2] = {NULL, NULL};
     ptrdiff_t true_lb, true_extent, lb, extent, max_real_segsize;
@@ -384,8 +373,8 @@ Coll_reduce_scatter_ompi_ring::reduce_scatter(const void *sbuf, void *rbuf, cons
     /* Determine the maximum number of elements per node,
        corresponding block size, and displacements array.
     */
     /* Determine the maximum number of elements per node,
        corresponding block size, and displacements array.
     */
-    displs = (int*) xbt_malloc(size * sizeof(int));
-    if (NULL == displs) { ret = -1; line = __LINE__; goto error_hndl; }
+    int* displs = new int[size];
+
     displs[0] = 0;
     total_count = rcounts[0];
     max_block_count = rcounts[0];
     displs[0] = 0;
     total_count = rcounts[0];
     max_block_count = rcounts[0];
@@ -401,7 +390,7 @@ Coll_reduce_scatter_ompi_ring::reduce_scatter(const void *sbuf, void *rbuf, cons
             ret = Datatype::copy((char*)sbuf, total_count, dtype, (char*)rbuf, total_count, dtype);
             if (ret < 0) { line = __LINE__; goto error_hndl; }
         }
             ret = Datatype::copy((char*)sbuf, total_count, dtype, (char*)rbuf, total_count, dtype);
             if (ret < 0) { line = __LINE__; goto error_hndl; }
         }
-        xbt_free(displs);
+        delete[] displs;
         return MPI_SUCCESS;
     }
 
         return MPI_SUCCESS;
     }
 
@@ -505,7 +494,7 @@ Coll_reduce_scatter_ompi_ring::reduce_scatter(const void *sbuf, void *rbuf, cons
     ret = Datatype::copy(tmprecv, rcounts[rank], dtype, (char*)rbuf, rcounts[rank], dtype);
     if (ret < 0) { line = __LINE__; goto error_hndl; }
 
     ret = Datatype::copy(tmprecv, rcounts[rank], dtype, (char*)rbuf, rcounts[rank], dtype);
     if (ret < 0) { line = __LINE__; goto error_hndl; }
 
-    if (NULL != displs) xbt_free(displs);
+    delete[] displs;
     if (NULL != accumbuf_free) smpi_free_tmp_buffer(accumbuf_free);
     if (NULL != inbuf_free[0]) smpi_free_tmp_buffer(inbuf_free[0]);
     if (NULL != inbuf_free[1]) smpi_free_tmp_buffer(inbuf_free[1]);
     if (NULL != accumbuf_free) smpi_free_tmp_buffer(accumbuf_free);
     if (NULL != inbuf_free[0]) smpi_free_tmp_buffer(inbuf_free[0]);
     if (NULL != inbuf_free[1]) smpi_free_tmp_buffer(inbuf_free[1]);
@@ -515,7 +504,7 @@ Coll_reduce_scatter_ompi_ring::reduce_scatter(const void *sbuf, void *rbuf, cons
  error_hndl:
     XBT_DEBUG( "%s:%4d\tRank %d Error occurred %d\n",
                  __FILE__, line, rank, ret);
  error_hndl:
     XBT_DEBUG( "%s:%4d\tRank %d Error occurred %d\n",
                  __FILE__, line, rank, ret);
-    if (NULL != displs) xbt_free(displs);
+    delete[] displs;
     if (NULL != accumbuf_free) smpi_free_tmp_buffer(accumbuf_free);
     if (NULL != inbuf_free[0]) smpi_free_tmp_buffer(inbuf_free[0]);
     if (NULL != inbuf_free[1]) smpi_free_tmp_buffer(inbuf_free[1]);
     if (NULL != accumbuf_free) smpi_free_tmp_buffer(accumbuf_free);
     if (NULL != inbuf_free[0]) smpi_free_tmp_buffer(inbuf_free[0]);
     if (NULL != inbuf_free[1]) smpi_free_tmp_buffer(inbuf_free[1]);
index c485a88..613a306 100644 (file)
@@ -150,8 +150,8 @@ int Coll_scatter_mvapich2_two_level_direct::scatter(const void *sendbuf,
 
             if (root != leader_of_root) {
               if (leader_comm_rank == leader_root) {
 
             if (root != leader_of_root) {
               if (leader_comm_rank == leader_root) {
-                displs      = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
-                sendcnts    = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+                displs      = new int[leader_comm_size];
+                sendcnts    = new int[leader_comm_size];
                 sendcnts[0] = node_sizes[0] * nbytes;
                 displs[0]   = 0;
 
                 sendcnts[0] = node_sizes[0] * nbytes;
                 displs[0]   = 0;
 
@@ -164,8 +164,8 @@ int Coll_scatter_mvapich2_two_level_direct::scatter(const void *sendbuf,
                               leader_root, leader_comm);
             } else {
               if (leader_comm_rank == leader_root) {
                               leader_root, leader_comm);
             } else {
               if (leader_comm_rank == leader_root) {
-                displs      = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
-                sendcnts    = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+                displs      = new int[leader_comm_size];
+                sendcnts    = new int[leader_comm_size];
                 sendcnts[0] = node_sizes[0] * sendcnt;
                 displs[0]   = 0;
 
                 sendcnts[0] = node_sizes[0] * sendcnt;
                 displs[0]   = 0;
 
@@ -178,8 +178,8 @@ int Coll_scatter_mvapich2_two_level_direct::scatter(const void *sendbuf,
                               leader_comm);
             }
             if (leader_comm_rank == leader_root) {
                               leader_comm);
             }
             if (leader_comm_rank == leader_root) {
-              xbt_free(displs);
-              xbt_free(sendcnts);
+              delete[] displs;
+              delete[] sendcnts;
             }
             } else {
                 if (leader_of_root != root) {
             }
             } else {
                 if (leader_of_root != root) {
@@ -326,8 +326,8 @@ int Coll_scatter_mvapich2_two_level_binomial::scatter(const void *sendbuf,
 
             if (root != leader_of_root) {
               if (leader_comm_rank == leader_root) {
 
             if (root != leader_of_root) {
               if (leader_comm_rank == leader_root) {
-                displs      = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
-                sendcnts    = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+                displs      = new int[leader_comm_size];
+                sendcnts    = new int[leader_comm_size];
                 sendcnts[0] = node_sizes[0] * nbytes;
                 displs[0]   = 0;
 
                 sendcnts[0] = node_sizes[0] * nbytes;
                 displs[0]   = 0;
 
@@ -340,8 +340,8 @@ int Coll_scatter_mvapich2_two_level_binomial::scatter(const void *sendbuf,
                               leader_root, leader_comm);
             } else {
               if (leader_comm_rank == leader_root) {
                               leader_root, leader_comm);
             } else {
               if (leader_comm_rank == leader_root) {
-                displs      = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
-                sendcnts    = static_cast<int*>(xbt_malloc(sizeof(int) * leader_comm_size));
+                displs      = new int[leader_comm_size];
+                sendcnts    = new int[leader_comm_size];
                 sendcnts[0] = node_sizes[0] * sendcnt;
                 displs[0]   = 0;
 
                 sendcnts[0] = node_sizes[0] * sendcnt;
                 displs[0]   = 0;
 
@@ -354,8 +354,8 @@ int Coll_scatter_mvapich2_two_level_binomial::scatter(const void *sendbuf,
                               leader_comm);
             }
             if (leader_comm_rank == leader_root) {
                               leader_comm);
             }
             if (leader_comm_rank == leader_root) {
-              xbt_free(displs);
-              xbt_free(sendcnts);
+              delete[] displs;
+              delete[] sendcnts;
             }
             } else {
                 if (leader_of_root != root) {
             }
             } else {
                 if (leader_of_root != root) {
index ffb2dd4..4cd2155 100644 (file)
@@ -150,8 +150,8 @@ int Colls::scan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype data
   Datatype::copy(sendbuf, count, datatype, recvbuf, count, datatype);
 
   // Send/Recv buffers to/from others
   Datatype::copy(sendbuf, count, datatype, recvbuf, count, datatype);
 
   // Send/Recv buffers to/from others
-  MPI_Request *requests = xbt_new(MPI_Request, size - 1);
-  void **tmpbufs = xbt_new(void *, rank);
+  MPI_Request* requests = new MPI_Request[size - 1];
+  void** tmpbufs        = new void*[rank];
   int index = 0;
   for (int other = 0; other < rank; other++) {
     tmpbufs[index] = smpi_get_tmp_sendbuffer(count * dataext);
   int index = 0;
   for (int other = 0; other < rank; other++) {
     tmpbufs[index] = smpi_get_tmp_sendbuffer(count * dataext);
@@ -191,8 +191,8 @@ int Colls::scan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype data
   for(index = 0; index < size-1; index++) {
     Request::unref(&requests[index]);
   }
   for(index = 0; index < size-1; index++) {
     Request::unref(&requests[index]);
   }
-  xbt_free(tmpbufs);
-  xbt_free(requests);
+  delete[] tmpbufs;
+  delete[] requests;
   return MPI_SUCCESS;
 }
 
   return MPI_SUCCESS;
 }
 
@@ -208,8 +208,8 @@ int Colls::exscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype da
   datatype->extent(&lb, &dataext);
 
   // Send/Recv buffers to/from others
   datatype->extent(&lb, &dataext);
 
   // Send/Recv buffers to/from others
-  MPI_Request *requests = xbt_new(MPI_Request, size - 1);
-  void **tmpbufs = xbt_new(void *, rank);
+  MPI_Request* requests = new MPI_Request[size - 1];
+  void** tmpbufs        = new void*[rank];
   int index = 0;
   for (int other = 0; other < rank; other++) {
     tmpbufs[index] = smpi_get_tmp_sendbuffer(count * dataext);
   int index = 0;
   for (int other = 0; other < rank; other++) {
     tmpbufs[index] = smpi_get_tmp_sendbuffer(count * dataext);
@@ -258,8 +258,8 @@ int Colls::exscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype da
   for(index = 0; index < size-1; index++) {
     Request::unref(&requests[index]);
   }
   for(index = 0; index < size-1; index++) {
     Request::unref(&requests[index]);
   }
-  xbt_free(tmpbufs);
-  xbt_free(requests);
+  delete[] tmpbufs;
+  delete[] requests;
   return MPI_SUCCESS;
 }
 
   return MPI_SUCCESS;
 }
 
index 8c5db82..5b1febb 100644 (file)
@@ -38,7 +38,7 @@ int Coll_reduce_scatter_default::reduce_scatter(const void *sendbuf, void *recvb
   /* arbitrarily choose root as rank 0 */
   int size = comm->size();
   int count = 0;
   /* arbitrarily choose root as rank 0 */
   int size = comm->size();
   int count = 0;
-  int *displs = xbt_new(int, size);
+  int* displs = new int[size];
   for (int i = 0; i < size; i++) {
     displs[i] = count;
     count += recvcounts[i];
   for (int i = 0; i < size; i++) {
     displs[i] = count;
     count += recvcounts[i];
@@ -48,7 +48,7 @@ int Coll_reduce_scatter_default::reduce_scatter(const void *sendbuf, void *recvb
   int ret = Coll_reduce_default::reduce(sendbuf, tmpbuf, count, datatype, op, 0, comm);
   if(ret==MPI_SUCCESS)
     ret = Colls::scatterv(tmpbuf, recvcounts, displs, datatype, recvbuf, recvcounts[rank], datatype, 0, comm);
   int ret = Coll_reduce_default::reduce(sendbuf, tmpbuf, count, datatype, op, 0, comm);
   if(ret==MPI_SUCCESS)
     ret = Colls::scatterv(tmpbuf, recvcounts, displs, datatype, recvbuf, recvcounts[rank], datatype, 0, comm);
-  xbt_free(displs);
+  delete[] displs;
   smpi_free_tmp_buffer(tmpbuf);
   return ret;
 }
   smpi_free_tmp_buffer(tmpbuf);
   return ret;
 }