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

Public GIT Repository
On some systems, sqrt(int) is not defined properly. On others its just implemented...
[simgrid.git] / src / smpi / colls / alltoall / alltoall-bruck.cpp
index 9c0e30cd2ae6117303e246401b6e1935a01df69c..cd524443e1062c82d8c35a04f4cdb5ad2f30e03e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014. 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
  * Auther: MPICH / modified by Ahmad Faraj
 
  ****************************************************************************/
+
+#include "../colls_private.hpp"
+
+namespace simgrid{
+namespace smpi{
+
+
 int
-smpi_coll_tuned_alltoall_bruck(void *send_buff, int send_count,
+Coll_alltoall_bruck::alltoall(const void *send_buff, int send_count,
                                MPI_Datatype send_type, void *recv_buff,
                                int recv_count, MPI_Datatype recv_type,
                                MPI_Comm comm)
@@ -34,12 +41,9 @@ smpi_coll_tuned_alltoall_bruck(void *send_buff, int send_count,
   MPI_Aint extent;
   MPI_Datatype new_type;
 
-  int *blocks_length, *disps;
-  int i, src, dst, rank, num_procs, count, remainder, block, position;
+  int i, src, dst, rank, num_procs, count, block, position;
   int pack_size, tag = COLL_TAG_ALLTOALL, pof2 = 1;
 
-
-  char *tmp_buff;
   char *send_ptr = (char *) send_buff;
   char *recv_ptr = (char *) recv_buff;
 
@@ -48,9 +52,9 @@ smpi_coll_tuned_alltoall_bruck(void *send_buff, int send_count,
 
   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);
+  unsigned char* tmp_buff = smpi_get_tmp_sendbuffer(num_procs * recv_count * extent);
+  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,
@@ -79,7 +83,7 @@ smpi_coll_tuned_alltoall_bruck(void *send_buff, int send_count,
       }
 
     MPI_Type_indexed(count, blocks_length, disps, recv_type, &new_type);
-    smpi_datatype_commit(&new_type);
+    new_type->commit();
 
     position = 0;
     MPI_Pack(recv_buff, 1, new_type, tmp_buff, pack_size, &position, comm);
@@ -91,8 +95,8 @@ smpi_coll_tuned_alltoall_bruck(void *send_buff, int send_count,
     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,
@@ -113,3 +117,6 @@ smpi_coll_tuned_alltoall_bruck(void *send_buff, int send_count,
   smpi_free_tmp_buffer(tmp_buff);
   return MPI_SUCCESS;
 }
+
+}
+}