Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
unify collective tags
[simgrid.git] / src / smpi / colls / reduce-scatter-gather.c
index 4dbcbf1..24ad911 100644 (file)
@@ -10,12 +10,12 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf,
                                           MPI_Op op, int root, MPI_Comm comm)
 {
   MPI_Status status;
-  int comm_size, rank, type_size, pof2, rem, newrank;
+  int comm_size, rank, pof2, rem, newrank;
   int mask, *cnts, *disps, i, j, send_idx = 0;
   int recv_idx, last_idx = 0, newdst;
   int dst, send_cnt, recv_cnt, newroot, newdst_tree_root;
   int newroot_tree_root, new_count;
-  int tag = 4321;
+  int tag = COLL_TAG_REDUCE;
   void *send_ptr, *recv_ptr, *tmp_buf;
 
   cnts = NULL;
@@ -29,7 +29,6 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf,
   comm_size = smpi_comm_size(comm);
 
   extent = smpi_datatype_get_extent(datatype);
-  type_size = smpi_datatype_size(datatype);
 
   /* find nearest power-of-two less than or equal to comm_size */
   pof2 = 1;
@@ -42,7 +41,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf,
     send_ptr = (void *) xbt_malloc(new_count * extent);
     recv_ptr = (void *) xbt_malloc(new_count * extent);
     tmp_buf = (void *) xbt_malloc(new_count * extent);
-    memcpy(send_ptr, sendbuf, extent * new_count);
+    memcpy(send_ptr, sendbuf, extent * count);
 
     //if ((rank != root))
     smpi_mpi_sendrecv(send_ptr, new_count, datatype, rank, tag,
@@ -56,7 +55,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf,
         newrank = -1;
       } else {
         smpi_mpi_recv(tmp_buf, count, datatype, rank + 1, tag, comm, &status);
-        star_reduction(op, tmp_buf, recv_ptr, &new_count, &datatype);
+        smpi_op_apply(op, tmp_buf, recv_ptr, &new_count, &datatype);
         newrank = rank / 2;
       }
     } else                      /* rank >= 2*rem */
@@ -109,7 +108,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf,
         /* tmp_buf contains data received in this step.
            recvbuf contains data accumulated so far */
 
-        star_reduction(op, (char *) tmp_buf + disps[recv_idx] * extent,
+        smpi_op_apply(op, (char *) tmp_buf + disps[recv_idx] * extent,
                        (char *) recv_ptr + disps[recv_idx] * extent,
                        &recv_cnt, &datatype);
 
@@ -233,7 +232,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf,
 
       else {
         smpi_mpi_recv(tmp_buf, count, datatype, rank + 1, tag, comm, &status);
-        star_reduction(op, tmp_buf, recvbuf, &count, &datatype);
+        smpi_op_apply(op, tmp_buf, recvbuf, &count, &datatype);
         newrank = rank / 2;
       }
     } else                      /* rank >= 2*rem */
@@ -286,7 +285,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf,
         /* tmp_buf contains data received in this step.
            recvbuf contains data accumulated so far */
 
-        star_reduction(op, (char *) tmp_buf + disps[recv_idx] * extent,
+        smpi_op_apply(op, (char *) tmp_buf + disps[recv_idx] * extent,
                        (char *) recvbuf + disps[recv_idx] * extent,
                        &recv_cnt, &datatype);