Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'mc' into mc++
[simgrid.git] / src / smpi / colls / allgather-pair.c
index a113ea9..46cde2d 100644 (file)
@@ -1,4 +1,10 @@
-#include "colls.h"
+/* Copyright (c) 2013-2014. 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"
 
 /*****************************************************************************
 
@@ -67,24 +73,28 @@ smpi_coll_tuned_allgather_pair(void *send_buff, int send_count,
 
   MPI_Aint extent;
   int i, src, dst, rank, num_procs;
-  int tag = 1;
+  int tag = COLL_TAG_ALLGATHER;
   MPI_Status status;
 
   char *send_ptr = (char *) send_buff;
   char *recv_ptr = (char *) recv_buff;
 
-  MPI_Comm_rank(comm, &rank);
-  MPI_Comm_size(comm, &num_procs);
-  MPI_Type_extent(send_type, &extent);
+  rank = smpi_comm_rank(comm);
+  num_procs = smpi_comm_size(comm);
+
+  if((num_procs&(num_procs-1)))
+    THROWF(arg_error,0, "allgather pair algorithm can't be used with non power of two number of processes ! ");
+
+  extent = smpi_datatype_get_extent(send_type);
 
   // local send/recv
-  MPI_Sendrecv(send_ptr, send_count, send_type, rank, tag,
+  smpi_mpi_sendrecv(send_ptr, send_count, send_type, rank, tag,
                recv_ptr + rank * recv_count * extent,
                recv_count, recv_type, rank, tag, comm, &status);
 
   for (i = 1; i < num_procs; i++) {
     src = dst = rank ^ i;
-    MPI_Sendrecv(send_ptr, send_count, send_type, dst, tag,
+    smpi_mpi_sendrecv(send_ptr, send_count, send_type, dst, tag,
                  recv_ptr + src * recv_count * extent, recv_count, recv_type,
                  src, tag, comm, &status);
   }