Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change malloc/free to new/delete.
[simgrid.git] / src / smpi / colls / allgather / allgather-smp-simple.cpp
index 030733b..dcaaecd 100644 (file)
@@ -1,16 +1,16 @@
-/* Copyright (c) 2013-2017. The SimGrid Team.
+/* Copyright (c) 2013-2019. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "../colls_private.h"
+#include "../colls_private.hpp"
 
 namespace simgrid{
 namespace smpi{
 
 
-int Coll_allgather_smp_simple::allgather(void *send_buf, int scount,
+int Coll_allgather_smp_simple::allgather(const void *send_buf, int scount,
                                          MPI_Datatype stype, void *recv_buf,
                                          int rcount, MPI_Datatype rtype,
                                          MPI_Comm comm)
@@ -67,18 +67,16 @@ int Coll_allgather_smp_simple::allgather(void *send_buf, int scount,
 
   }
 
-  // INTER-SMP-ALLGATHER 
+  // INTER-SMP-ALLGATHER
   // Every root of each SMP node post INTER-Sendrecv, then do INTRA-Bcast for each receiving message
 
 
 
   if (intra_rank == 0) {
-    MPI_Request *reqs, *req_ptr;
     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++) {
 
@@ -86,7 +84,7 @@ int Coll_allgather_smp_simple::allgather(void *send_buf, int scount,
       src = ((inter_rank - i + inter_comm_size) % inter_comm_size) * num_core;
       //send_offset = (rank * sextent * scount);
       recv_offset = (src * sextent * scount);
-      //      Request::sendrecv((recv_buf+send_offset), (scount * num_core), stype, dst, tag, 
+      //      Request::sendrecv((recv_buf+send_offset), (scount * num_core), stype, dst, tag,
       //             (recv_buf+recv_offset), (rcount * num_core), rtype, src, tag, comm, &status);
       //MPIC_Isend((recv_buf+send_offset), (scount * num_core), stype, dst, tag, comm, req_ptr++);
       *(req_ptr++) = Request::irecv(((char *) recv_buf + recv_offset), (rcount * num_core), rtype,
@@ -98,16 +96,15 @@ int Coll_allgather_smp_simple::allgather(void *send_buf, int scount,
       //src = ((inter_rank-i+inter_comm_size)%inter_comm_size) * num_core;
       send_offset = (rank * sextent * scount);
       //recv_offset = (src * sextent * scount);
-      //      Request::sendrecv((recv_buf+send_offset), (scount * num_core), stype, dst, tag, 
+      //      Request::sendrecv((recv_buf+send_offset), (scount * num_core), stype, dst, tag,
       //             (recv_buf+recv_offset), (rcount * num_core), rtype, src, tag, comm, &status);
       *(req_ptr++) = Request::isend(((char *) recv_buf + send_offset), (scount * num_core), stype,
                 dst, tag, comm);
       //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)