Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
First works on the datatypes. Still missing a lot.
[simgrid.git] / src / smpi / colls / reduce_scatter-mpich.cpp
index b01fbd0..4906203 100644 (file)
@@ -32,13 +32,13 @@ int smpi_coll_tuned_reduce_scatter_mpich_pair(void *sendbuf, void *recvbuf, int
     int mpi_errno = MPI_SUCCESS;
     int total_count, dst, src;
     int is_commutative;
-    comm_size = smpi_comm_size(comm);
-    rank = smpi_comm_rank(comm);
+    comm_size = comm->size();
+    rank = comm->rank();
 
     extent =smpi_datatype_get_extent(datatype);
     smpi_datatype_extent(datatype, &true_lb, &true_extent);
     
-    if (smpi_op_is_commute(op)) {
+    if (op->is_commutative()) {
         is_commutative = 1;
     }
 
@@ -74,14 +74,14 @@ int smpi_coll_tuned_reduce_scatter_mpich_pair(void *sendbuf, void *recvbuf, int
             /* send the data that dst needs. recv data that this process
                needs from src into tmp_recvbuf */
             if (sendbuf != MPI_IN_PLACE) 
-                smpi_mpi_sendrecv(((char *)sendbuf+disps[dst]*extent), 
+                Request::sendrecv(((char *)sendbuf+disps[dst]*extent), 
                                              recvcounts[dst], datatype, dst,
                                              COLL_TAG_SCATTER, tmp_recvbuf,
                                              recvcounts[rank], datatype, src,
                                              COLL_TAG_SCATTER, comm,
                                              MPI_STATUS_IGNORE);
             else
-                smpi_mpi_sendrecv(((char *)recvbuf+disps[dst]*extent), 
+                Request::sendrecv(((char *)recvbuf+disps[dst]*extent), 
                                              recvcounts[dst], datatype, dst,
                                              COLL_TAG_SCATTER, tmp_recvbuf,
                                              recvcounts[rank], datatype, src,
@@ -90,14 +90,14 @@ int smpi_coll_tuned_reduce_scatter_mpich_pair(void *sendbuf, void *recvbuf, int
             
             if (is_commutative || (src < rank)) {
                 if (sendbuf != MPI_IN_PLACE) {
-                    smpi_op_apply( op,
+                    if(op!=MPI_OP_NULL) op->apply(
                                                  tmp_recvbuf, recvbuf, &recvcounts[rank],
-                               &datatype); 
+                               datatype); 
                 }
                 else {
-                   smpi_op_apply(op, 
+                   if(op!=MPI_OP_NULL) op->apply( 
                        tmp_recvbuf, ((char *)recvbuf+disps[rank]*extent), 
-                       &recvcounts[rank], &datatype);
+                       &recvcounts[rank], datatype);
                     /* we can't store the result at the beginning of
                        recvbuf right here because there is useful data
                        there that other process/processes need. at the
@@ -107,8 +107,8 @@ int smpi_coll_tuned_reduce_scatter_mpich_pair(void *sendbuf, void *recvbuf, int
             }
             else {
                 if (sendbuf != MPI_IN_PLACE) {
-                   smpi_op_apply(op, 
-                      recvbuf, tmp_recvbuf, &recvcounts[rank], &datatype);
+                   if(op!=MPI_OP_NULL) op->apply( 
+                      recvbuf, tmp_recvbuf, &recvcounts[rank], datatype);
                     /* copy result back into recvbuf */
                     mpi_errno = smpi_datatype_copy(tmp_recvbuf, recvcounts[rank],
                                                datatype, recvbuf,
@@ -116,9 +116,9 @@ int smpi_coll_tuned_reduce_scatter_mpich_pair(void *sendbuf, void *recvbuf, int
                     if (mpi_errno) return(mpi_errno);
                 }
                 else {
-                   smpi_op_apply(op, 
+                   if(op!=MPI_OP_NULL) op->apply( 
                         ((char *)recvbuf+disps[rank]*extent),
-                       tmp_recvbuf, &recvcounts[rank], &datatype);
+                       tmp_recvbuf, &recvcounts[rank], datatype);
                     /* copy result back into recvbuf */
                     mpi_errno = smpi_datatype_copy(tmp_recvbuf, recvcounts[rank],
                                                datatype, 
@@ -152,8 +152,8 @@ int smpi_coll_tuned_reduce_scatter_mpich_noncomm(void *sendbuf, void *recvbuf, i
                               MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
 {
     int mpi_errno = MPI_SUCCESS;
-    int comm_size = smpi_comm_size(comm) ;
-    int rank = smpi_comm_rank(comm);
+    int comm_size = comm->size() ;
+    int rank = comm->rank();
     int pof2;
     int log2_comm_size;
     int i, k;
@@ -223,7 +223,7 @@ int smpi_coll_tuned_reduce_scatter_mpich_noncomm(void *sendbuf, void *recvbuf, i
             send_offset += size;
         }
 
-        smpi_mpi_sendrecv(outgoing_data + send_offset*true_extent,
+        Request::sendrecv(outgoing_data + send_offset*true_extent,
                                      size, datatype, peer, COLL_TAG_SCATTER,
                                      incoming_data + recv_offset*true_extent,
                                      size, datatype, peer, COLL_TAG_SCATTER,
@@ -232,18 +232,18 @@ int smpi_coll_tuned_reduce_scatter_mpich_noncomm(void *sendbuf, void *recvbuf, i
            is now our peer's responsibility */
         if (rank > peer) {
             /* higher ranked value so need to call op(received_data, my_data) */
-            smpi_op_apply(op, 
+            if(op!=MPI_OP_NULL) op->apply( 
                    incoming_data + recv_offset*true_extent,
                      outgoing_data + recv_offset*true_extent,
-                     &size, &datatype );
+                     &size, datatype );
             /* buf0_was_inout = buf0_was_inout; */
         }
         else {
             /* lower ranked value so need to call op(my_data, received_data) */
-           smpi_op_apply( op,
+           if(op!=MPI_OP_NULL) op->apply(
                     outgoing_data + recv_offset*true_extent,
                      incoming_data + recv_offset*true_extent,
-                     &size, &datatype);
+                     &size, datatype);
             buf0_was_inout = !buf0_was_inout;
         }
 
@@ -279,13 +279,13 @@ int smpi_coll_tuned_reduce_scatter_mpich_rdb(void *sendbuf, void *recvbuf, int r
     int received;
     MPI_Datatype sendtype, recvtype;
     int nprocs_completed, tmp_mask, tree_root, is_commutative=0;
-    comm_size = smpi_comm_size(comm);
-    rank = smpi_comm_rank(comm);
+    comm_size = comm->size();
+    rank = comm->rank();
 
     extent =smpi_datatype_get_extent(datatype);
     smpi_datatype_extent(datatype, &true_lb, &true_extent);
     
-    if (smpi_op_is_commute(op)) {
+    if ((op==MPI_OP_NULL) || op->is_commutative()) {
         is_commutative = 1;
     }
 
@@ -380,7 +380,7 @@ int smpi_coll_tuned_reduce_scatter_mpich_rdb(void *sendbuf, void *recvbuf, int r
                        received in tmp_recvbuf and then accumulated into
                        tmp_results. accumulation is done later below.   */ 
 
-                    smpi_mpi_sendrecv(tmp_results, 1, sendtype, dst,
+                    Request::sendrecv(tmp_results, 1, sendtype, dst,
                                                  COLL_TAG_SCATTER,
                                                  tmp_recvbuf, 1, recvtype, dst,
                                                  COLL_TAG_SCATTER, comm,
@@ -424,7 +424,7 @@ int smpi_coll_tuned_reduce_scatter_mpich_rdb(void *sendbuf, void *recvbuf, int r
                             (rank < tree_root + nprocs_completed)
                             && (dst >= tree_root + nprocs_completed)) {
                             /* send the current result */
-                            smpi_mpi_send(tmp_recvbuf, 1, recvtype,
+                            Request::send(tmp_recvbuf, 1, recvtype,
                                                      dst, COLL_TAG_SCATTER,
                                                      comm);
                         }
@@ -433,7 +433,7 @@ int smpi_coll_tuned_reduce_scatter_mpich_rdb(void *sendbuf, void *recvbuf, int r
                         else if ((dst < rank) && 
                                  (dst < tree_root + nprocs_completed) &&
                                  (rank >= tree_root + nprocs_completed)) {
-                            smpi_mpi_recv(tmp_recvbuf, 1, recvtype, dst,
+                            Request::recv(tmp_recvbuf, 1, recvtype, dst,
                                                      COLL_TAG_SCATTER,
                                                      comm, MPI_STATUS_IGNORE); 
                             received = 1;
@@ -454,24 +454,24 @@ int smpi_coll_tuned_reduce_scatter_mpich_rdb(void *sendbuf, void *recvbuf, int r
                 if (received) {
                     if (is_commutative || (dst_tree_root < my_tree_root)) {
                         {
-                                smpi_op_apply(op, 
+                                if(op!=MPI_OP_NULL) op->apply( 
                                tmp_recvbuf, tmp_results, &blklens[0],
-                              &datatype); 
-                               smpi_op_apply(op, 
+                              datatype); 
+                               if(op!=MPI_OP_NULL) op->apply( 
                                ((char *)tmp_recvbuf + dis[1]*extent),
                               ((char *)tmp_results + dis[1]*extent),
-                              &blklens[1], &datatype); 
+                              &blklens[1], datatype); 
                         }
                     }
                     else {
                         {
-                                smpi_op_apply(op,
+                                if(op!=MPI_OP_NULL) op->apply(
                                    tmp_results, tmp_recvbuf, &blklens[0],
-                                   &datatype); 
-                                smpi_op_apply(op,
+                                   datatype); 
+                                if(op!=MPI_OP_NULL) op->apply(
                                    ((char *)tmp_results + dis[1]*extent),
                                    ((char *)tmp_recvbuf + dis[1]*extent),
-                                   &blklens[1], &datatype); 
+                                   &blklens[1], datatype); 
                         }
                         /* copy result back into tmp_results */
                         mpi_errno = smpi_datatype_copy(tmp_recvbuf, 1, recvtype,