Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / smpi / colls / reduce / reduce-mvapich-two-level.cpp
index 4d47d23..c99ec42 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2022. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
 #define SHMEM_COLL_BLOCK_SIZE (local_size * mv2_g_shmem_coll_max_msg_size)
 #define mv2_use_knomial_reduce 1
 
-#define MPIR_Reduce_inter_knomial_wrapper_MV2 Coll_reduce_mvapich2_knomial::reduce
-#define MPIR_Reduce_intra_knomial_wrapper_MV2 Coll_reduce_mvapich2_knomial::reduce
-#define MPIR_Reduce_binomial_MV2 Coll_reduce_binomial::reduce
-#define MPIR_Reduce_redscat_gather_MV2 Coll_reduce_scatter_gather::reduce
-#define MPIR_Reduce_shmem_MV2 Coll_reduce_ompi_basic_linear::reduce
+#define MPIR_Reduce_inter_knomial_wrapper_MV2 reduce__mvapich2_knomial
+#define MPIR_Reduce_intra_knomial_wrapper_MV2 reduce__mvapich2_knomial
+#define MPIR_Reduce_binomial_MV2 reduce__binomial
+#define MPIR_Reduce_redscat_gather_MV2 reduce__scatter_gather
+#define MPIR_Reduce_shmem_MV2 reduce__ompi_basic_linear
 
 extern int (*MV2_Reduce_function)( const void *sendbuf,
     void *recvbuf,
@@ -73,15 +73,15 @@ static int (*reduce_fn)(const void *sendbuf,
                              int count,
                              MPI_Datatype datatype,
                              MPI_Op op, int root, MPI_Comm  comm);
-namespace simgrid{
-namespace smpi{
-int Coll_reduce_mvapich2_two_level::reduce( const void *sendbuf,
-                                     void *recvbuf,
-                                     int count,
-                                     MPI_Datatype datatype,
-                                     MPI_Op op,
-                                     int root,
-                                     MPI_Comm comm)
+namespace simgrid {
+namespace smpi {
+int reduce__mvapich2_two_level( const void *sendbuf,
+                                void *recvbuf,
+                                int count,
+                                MPI_Datatype datatype,
+                                MPI_Op op,
+                                int root,
+                                MPI_Comm comm)
 {
     int mpi_errno = MPI_SUCCESS;
     int my_rank, total_size, local_rank, local_size;
@@ -91,14 +91,14 @@ int Coll_reduce_mvapich2_two_level::reduce( const void *sendbuf,
     const unsigned char* in_buf = nullptr;
     unsigned char *out_buf = nullptr, *tmp_buf = nullptr;
     MPI_Aint true_lb, true_extent, extent;
-    int is_commutative = 0, stride = 0;
+    int stride          = 0;
     int intra_node_root=0;
 
     //if not set (use of the algo directly, without mvapich2 selector)
-    if(MV2_Reduce_function==NULL)
-      MV2_Reduce_function=Coll_reduce_mpich::reduce;
-    if(MV2_Reduce_intra_function==NULL)
-      MV2_Reduce_intra_function=Coll_reduce_mpich::reduce;
+    if (MV2_Reduce_function == nullptr)
+      MV2_Reduce_function = reduce__mpich;
+    if (MV2_Reduce_intra_function == nullptr)
+      MV2_Reduce_intra_function = reduce__mpich;
 
     if(comm->get_leaders_comm()==MPI_COMM_NULL){
       comm->init_smp();
@@ -115,7 +115,7 @@ int Coll_reduce_mvapich2_two_level::reduce( const void *sendbuf,
     leader_of_root = comm->group()->rank(leaders_map[root]);
     leader_root = leader_comm->group()->rank(leaders_map[root]);
 
-    is_commutative= (op==MPI_OP_NULL || op->is_commutative());
+    bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
 
     datatype->extent(&true_lb,
                                        &true_extent);
@@ -124,8 +124,7 @@ int Coll_reduce_mvapich2_two_level::reduce( const void *sendbuf,
 
     if (local_size == total_size) {
         /* First handle the case where there is only one node */
-        if (stride <= MV2_INTRA_SHMEM_REDUCE_MSG &&
-            is_commutative == 1) {
+        if (stride <= MV2_INTRA_SHMEM_REDUCE_MSG && is_commutative) {
             if (local_rank == 0 ) {
               tmp_buf = smpi_get_tmp_sendbuffer(count * std::max(extent, true_extent));
               tmp_buf = tmp_buf - true_lb;
@@ -215,7 +214,7 @@ int Coll_reduce_mvapich2_two_level::reduce( const void *sendbuf,
          *this step*/
         if (MV2_Reduce_intra_function == & MPIR_Reduce_shmem_MV2)
         {
-          if (is_commutative == 1 && (count * (std::max(extent, true_extent)) < SHMEM_COLL_BLOCK_SIZE)) {
+          if (is_commutative && (count * (std::max(extent, true_extent)) < SHMEM_COLL_BLOCK_SIZE)) {
             mpi_errno = MV2_Reduce_intra_function(in_buf, out_buf, count, datatype, op, intra_node_root, shmem_comm);
             } else {
                     mpi_errno = MPIR_Reduce_intra_knomial_wrapper_MV2(in_buf, out_buf, count,