]> AND Public Git Repository - simgrid.git/blobdiff - src/smpi/colls/reduce/reduce-flat-tree.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
reduce the use of simcall_process_sleep() -> this_actor::sleep_for()
[simgrid.git] / src / smpi / colls / reduce / reduce-flat-tree.cpp
index c4c2e7fd2175a5bc0f51925c41ed5446602471a8..e9ffc8ab8dad76fcb047f804434ed59b87f22cc1 100644 (file)
@@ -1,15 +1,15 @@
-/* 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"
 //#include <star-reduction.c>
 namespace simgrid{
 namespace smpi{
 int
-Coll_reduce_flat_tree::reduce(void *sbuf, void *rbuf, int count,
+Coll_reduce_flat_tree::reduce(const void *sbuf, void *rbuf, int count,
                                  MPI_Datatype dtype, MPI_Op op,
                                  int root, MPI_Comm comm)
 {
@@ -17,8 +17,8 @@ Coll_reduce_flat_tree::reduce(void *sbuf, void *rbuf, int count,
   int size;
   int rank;
   MPI_Aint extent;
-  char *origin = 0;
-  char *inbuf;
+  unsigned char* origin = nullptr;
+  const unsigned char* inbuf;
   MPI_Status status;
 
   rank = comm->rank();
@@ -36,8 +36,7 @@ Coll_reduce_flat_tree::reduce(void *sbuf, void *rbuf, int count,
      messages. */
 
   if (size > 1)
-    origin = (char *) smpi_get_tmp_recvbuffer(count * extent);
-
+    origin = smpi_get_tmp_recvbuffer(count * extent);
 
   /* Initialize the receive buffer. */
   if (rank == (size - 1))
@@ -50,7 +49,7 @@ Coll_reduce_flat_tree::reduce(void *sbuf, void *rbuf, int count,
 
   for (i = size - 2; i >= 0; --i) {
     if (rank == i)
-      inbuf = static_cast<char*>(sbuf);
+      inbuf = static_cast<const unsigned char*>(sbuf);
     else {
       Request::recv(origin, count, dtype, i, tag, comm, &status);
       inbuf = origin;
@@ -61,8 +60,7 @@ Coll_reduce_flat_tree::reduce(void *sbuf, void *rbuf, int count,
 
   }
 
-  if (origin)
-    smpi_free_tmp_buffer(origin);
+  smpi_free_tmp_buffer(origin);
 
   /* All done */
   return 0;