Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
the extraction of the graph is a NetZone method
[simgrid.git] / src / smpi / colls / alltoall / alltoall-basic-linear.cpp
index 9b1b1a2aad56d872f3d6fba17b87fd66de7534d2..272ffb9e66a5a5842b27ae2640f85e272f8ceaae 100644 (file)
@@ -1,10 +1,10 @@
-/* Copyright (c) 2013-2017. The SimGrid Team.
+/* Copyright (c) 2013-2020. 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"
 
 /*Naive and simple basic alltoall implementation. */
 
@@ -13,14 +13,13 @@ namespace simgrid{
 namespace smpi{
 
 
-int Coll_alltoall_basic_linear::alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
-                                          void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
+int alltoall__basic_linear(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
+                           void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
 {
-  int system_tag = 888;
+  int system_tag = COLL_TAG_ALLTOALL;
   int i;
   int count;
   MPI_Aint lb = 0, sendext = 0, recvext = 0;
-  MPI_Request *requests;
 
   /* Initialize. */
   int rank = comm->rank();
@@ -29,11 +28,11 @@ int Coll_alltoall_basic_linear::alltoall(void *sendbuf, int sendcount, MPI_Datat
   sendtype->extent(&lb, &sendext);
   recvtype->extent(&lb, &recvext);
   /* simple optimization */
-  int err = Datatype::copy(static_cast<char *>(sendbuf) + rank * sendcount * sendext, sendcount, sendtype,
+  int err = Datatype::copy(static_cast<const char *>(sendbuf) + rank * sendcount * sendext, sendcount, sendtype,
                                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) {
@@ -47,7 +46,7 @@ int Coll_alltoall_basic_linear::alltoall(void *sendbuf, int sendcount, MPI_Datat
      * TODO: check the previous assertion
      */
     for (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,
+      requests[count] = Request::isend_init(static_cast<const char *>(sendbuf) + i * sendcount * sendext, sendcount,
                                         sendtype, i, system_tag, comm);
       count++;
     }
@@ -59,7 +58,7 @@ int Coll_alltoall_basic_linear::alltoall(void *sendbuf, int sendcount, MPI_Datat
       if(requests[i]!=MPI_REQUEST_NULL)
         Request::unref(&requests[i]);
     }
-    xbt_free(requests);
+    delete[] requests;
   }
   return err;
 }