Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
First works on the datatypes. Still missing a lot.
[simgrid.git] / src / smpi / colls / allreduce-smp-rdb.cpp
index 9770d29..b303642 100644 (file)
@@ -35,12 +35,12 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count,
   int tag = COLL_TAG_ALLREDUCE;
   int mask, src, dst;
   MPI_Status status;
-  if(smpi_comm_get_leaders_comm(comm)==MPI_COMM_NULL){
-    smpi_comm_init_smp(comm);
+  if(comm->get_leaders_comm()==MPI_COMM_NULL){
+    comm->init_smp();
   }
   int num_core=1;
-  if (smpi_comm_is_uniform(comm)){
-    num_core = smpi_comm_size(smpi_comm_get_intra_comm(comm));
+  if (comm->is_uniform()){
+    num_core = comm->get_intra_comm()->size();
   }
   /*
      #ifdef MPICH2_REDUCTION
@@ -52,8 +52,8 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count,
      uop  = op_ptr->op;
      #endif
    */
-  comm_size = smpi_comm_size(comm);
-  rank = smpi_comm_rank(comm);
+  comm_size = comm->size();
+  rank = comm->rank();
   MPI_Aint extent;
   extent = smpi_datatype_get_extent(dtype);
   tmp_buf = (void *) smpi_get_tmp_sendbuffer(count * extent);
@@ -68,7 +68,7 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count,
   int inter_comm_size = (comm_size + num_core - 1) / num_core;
 
   /* copy input buffer to output buffer */
-  smpi_mpi_sendrecv(send_buf, count, dtype, rank, tag,
+  Request::sendrecv(send_buf, count, dtype, rank, tag,
                recv_buf, count, dtype, rank, tag, comm, &status);
 
   /* start binomial reduce intra communication inside each SMP node */
@@ -77,12 +77,12 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count,
     if ((mask & intra_rank) == 0) {
       src = (inter_rank * num_core) + (intra_rank | mask);
       if (src < comm_size) {
-        smpi_mpi_recv(tmp_buf, count, dtype, src, tag, comm, &status);
-        smpi_op_apply(op, tmp_buf, recv_buf, &count, &dtype);
+        Request::recv(tmp_buf, count, dtype, src, tag, comm, &status);
+        if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, dtype);
       }
     } else {
       dst = (inter_rank * num_core) + (intra_rank & (~mask));
-      smpi_mpi_send(recv_buf, count, dtype, dst, tag, comm);
+      Request::send(recv_buf, count, dtype, dst, tag, comm);
       break;
     }
     mask <<= 1;
@@ -110,12 +110,12 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count,
     if (inter_rank < 2 * rem) {
       if (inter_rank % 2 == 0) {
         dst = rank + num_core;
-        smpi_mpi_send(recv_buf, count, dtype, dst, tag, comm);
+        Request::send(recv_buf, count, dtype, dst, tag, comm);
         newrank = -1;
       } else {
         src = rank - num_core;
-        smpi_mpi_recv(tmp_buf, count, dtype, src, tag, comm, &status);
-        smpi_op_apply(op, tmp_buf, recv_buf, &count, &dtype);
+        Request::recv(tmp_buf, count, dtype, src, tag, comm, &status);
+        if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, dtype);
         newrank = inter_rank / 2;
       }
     } else {
@@ -139,9 +139,9 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count,
         dst *= num_core;
 
         /* exchange data in rdb manner */
-        smpi_mpi_sendrecv(recv_buf, count, dtype, dst, tag, tmp_buf, count, dtype,
+        Request::sendrecv(recv_buf, count, dtype, dst, tag, tmp_buf, count, dtype,
                      dst, tag, comm, &status);
-        smpi_op_apply(op, tmp_buf, recv_buf, &count, &dtype);
+        if(op!=MPI_OP_NULL) op->apply( tmp_buf, recv_buf, &count, dtype);
         mask <<= 1;
       }
     }
@@ -151,9 +151,9 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count,
      */
     if (inter_rank < 2 * rem) {
       if (inter_rank % 2) {
-        smpi_mpi_send(recv_buf, count, dtype, rank - num_core, tag, comm);
+        Request::send(recv_buf, count, dtype, rank - num_core, tag, comm);
       } else {
-        smpi_mpi_recv(recv_buf, count, dtype, rank + num_core, tag, comm, &status);
+        Request::recv(recv_buf, count, dtype, rank + num_core, tag, comm, &status);
       }
     }
   }
@@ -167,7 +167,7 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count,
   while (mask < num_core_in_current_smp) {
     if (intra_rank & mask) {
       src = (inter_rank * num_core) + (intra_rank - mask);
-      smpi_mpi_recv(recv_buf, count, dtype, src, tag, comm, &status);
+      Request::recv(recv_buf, count, dtype, src, tag, comm, &status);
       break;
     }
     mask <<= 1;
@@ -177,7 +177,7 @@ int smpi_coll_tuned_allreduce_smp_rdb(void *send_buf, void *recv_buf, int count,
   while (mask > 0) {
     dst = (inter_rank * num_core) + (intra_rank + mask);
     if (dst < comm_size) {
-      smpi_mpi_send(recv_buf, count, dtype, dst, tag, comm);
+      Request::send(recv_buf, count, dtype, dst, tag, comm);
     }
     mask >>= 1;
   }