From bad5891a4d5a2d97e1dea926cb640f516c1fae0c Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 26 Dec 2019 23:59:49 +0100 Subject: [PATCH] Use type bool for boolean variables in smpi/colls/. --- src/smpi/colls/allgather/allgather-2dmesh.cpp | 8 +- src/smpi/colls/allgather/allgather-3dmesh.cpp | 10 +- .../colls/allreduce/allreduce-mvapich-rs.cpp | 4 +- src/smpi/colls/alltoallv/alltoallv-ring.cpp | 4 +- src/smpi/colls/bcast/bcast-mvapich-smp.cpp | 16 +-- .../bcast/bcast-scatter-rdb-allgather.cpp | 11 +- src/smpi/colls/gather/gather-mvapich.cpp | 15 +-- src/smpi/colls/reduce/reduce-binomial.cpp | 2 +- .../colls/reduce/reduce-mvapich-knomial.cpp | 4 +- .../colls/reduce/reduce-mvapich-two-level.cpp | 9 +- src/smpi/colls/reduce/reduce-rab.cpp | 7 +- .../reduce_scatter/reduce_scatter-mpich.cpp | 11 +- src/smpi/colls/smpi_mpich_selector.cpp | 4 +- src/smpi/colls/smpi_mvapich2_selector.cpp | 81 ++++++------- .../colls/smpi_mvapich2_selector_stampede.hpp | 110 +++++++++--------- src/smpi/colls/smpi_openmpi_selector.cpp | 4 +- 16 files changed, 141 insertions(+), 159 deletions(-) diff --git a/src/smpi/colls/allgather/allgather-2dmesh.cpp b/src/smpi/colls/allgather/allgather-2dmesh.cpp index 0a774ada87..e1810a32bd 100644 --- a/src/smpi/colls/allgather/allgather-2dmesh.cpp +++ b/src/smpi/colls/allgather/allgather-2dmesh.cpp @@ -53,7 +53,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Function: is_2dmesh - * Return: int + * Return: bool * Inputs: num: the number of processors in a communicator @@ -66,7 +66,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ****************************************************************************/ #ifndef TWOD #define TWOD -static int is_2dmesh(int num, int *i, int *j) +static bool is_2dmesh(int num, int* i, int* j) { int x, max = num / 2; x = sqrt(double(num)); @@ -82,11 +82,11 @@ static int is_2dmesh(int num, int *i, int *j) *j = x; } - return 1; + return true; } x++; } - return 0; + return false; } #endif /***************************************************************************** diff --git a/src/smpi/colls/allgather/allgather-3dmesh.cpp b/src/smpi/colls/allgather/allgather-3dmesh.cpp index 02e5d12f76..c7f3b9027d 100644 --- a/src/smpi/colls/allgather/allgather-3dmesh.cpp +++ b/src/smpi/colls/allgather/allgather-3dmesh.cpp @@ -50,8 +50,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ /***************************************************************************** - * Function: is_2dmesh - * return: int + * Function: is_3dmesh + * return: bool * num: the number of processors in a communicator * i: x dimension * j: y dimension @@ -60,7 +60,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ****************************************************************************/ #ifndef THREED #define THREED -static int is_3dmesh(int num, int *i, int *j, int *k) +static bool is_3dmesh(int num, int* i, int* j, int* k) { int x, max = num / 3; x = cbrt(num); @@ -69,11 +69,11 @@ static int is_3dmesh(int num, int *i, int *j, int *k) if ((num % (x * x)) == 0) { *i = *j = x; *k = num / (x * x); - return 1; + return true; } x++; } - return 0; + return false; } #endif /***************************************************************************** diff --git a/src/smpi/colls/allreduce/allreduce-mvapich-rs.cpp b/src/smpi/colls/allreduce/allreduce-mvapich-rs.cpp index cbfdaa7d98..f1b6a4597c 100644 --- a/src/smpi/colls/allreduce/allreduce-mvapich-rs.cpp +++ b/src/smpi/colls/allreduce/allreduce-mvapich-rs.cpp @@ -35,7 +35,7 @@ int allreduce__mvapich2_rs(const void *sendbuf, int mpi_errno = MPI_SUCCESS; int newrank = 0; int mask, pof2, i, send_idx, recv_idx, last_idx, send_cnt; - int dst, is_commutative, rem, newdst, recv_cnt; + int dst, rem, newdst, recv_cnt; MPI_Aint true_lb, true_extent, extent; if (count == 0) { @@ -47,7 +47,7 @@ int allreduce__mvapich2_rs(const void *sendbuf, int comm_size = comm->size(); int rank = comm->rank(); - is_commutative = (op==MPI_OP_NULL || op->is_commutative()); + bool is_commutative = (op == MPI_OP_NULL || op->is_commutative()); /* need to allocate temporary buffer to store incoming data */ datatype->extent(&true_lb, &true_extent); diff --git a/src/smpi/colls/alltoallv/alltoallv-ring.cpp b/src/smpi/colls/alltoallv/alltoallv-ring.cpp index 53969d3776..eb082a2666 100644 --- a/src/smpi/colls/alltoallv/alltoallv-ring.cpp +++ b/src/smpi/colls/alltoallv/alltoallv-ring.cpp @@ -43,10 +43,10 @@ int alltoallv__ring(const void* send_buff, const int* send_counts, const int* se num_procs = comm->size(); send_chunk = send_type->get_extent(); recv_chunk = recv_type->get_extent(); - int pof2 = ((num_procs != 0) && ((num_procs & (~num_procs + 1)) == num_procs)); + bool pof2 = ((num_procs != 0) && ((num_procs & (~num_procs + 1)) == num_procs)); for (i = 0; i < num_procs; i++) { - if (pof2 == 1) { + if (pof2) { /* use exclusive-or algorithm */ src = dst = rank ^ i; } else { diff --git a/src/smpi/colls/bcast/bcast-mvapich-smp.cpp b/src/smpi/colls/bcast/bcast-mvapich-smp.cpp index 70239f6cce..4e5f047474 100644 --- a/src/smpi/colls/bcast/bcast-mvapich-smp.cpp +++ b/src/smpi/colls/bcast/bcast-mvapich-smp.cpp @@ -250,9 +250,9 @@ int bcast__mvapich2_intra_node(void *buffer, { int mpi_errno = MPI_SUCCESS; int comm_size; - int two_level_bcast = 1; + bool two_level_bcast = true; size_t nbytes = 0; - int is_homogeneous, is_contig; + bool is_homogeneous, is_contig; MPI_Aint type_size; unsigned char* tmp_buf = nullptr; MPI_Comm shmem_comm; @@ -275,16 +275,16 @@ int bcast__mvapich2_intra_node(void *buffer, // rank = comm->rank(); /* if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN)*/ - is_contig = 1; + is_contig = true; /* else { MPID_Datatype_get_ptr(datatype, dtp); is_contig = dtp->is_contig; } */ - is_homogeneous = 1; + is_homogeneous = true; #ifdef MPID_HAS_HETERO if (comm_ptr->is_hetero) - is_homogeneous = 0; + is_homogeneous = false; #endif /* MPI_Type_size() might not give the accurate size of the packed @@ -303,13 +303,13 @@ int bcast__mvapich2_intra_node(void *buffer, nbytes = (size_t) (count) * (type_size); if (comm_size <= mv2_bcast_two_level_system_size) { if (nbytes > mv2_bcast_short_msg && nbytes < mv2_bcast_large_msg) { - two_level_bcast = 1; + two_level_bcast = true; } else { - two_level_bcast = 0; + two_level_bcast = false; } } - if (two_level_bcast == 1 + if (two_level_bcast #if defined(_MCST_SUPPORT_) || comm_ptr->ch.is_mcast_ok #endif diff --git a/src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp b/src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp index 9cf489b424..52f0ba46b3 100644 --- a/src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp +++ b/src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp @@ -114,7 +114,8 @@ int bcast__scatter_rdb_allgather( int relative_rank, mask; int mpi_errno = MPI_SUCCESS; int scatter_size, curr_size, recv_size = 0; - int j, k, i, tmp_mask, is_contig, is_homogeneous; + int j, k, i, tmp_mask; + bool is_contig, is_homogeneous; MPI_Aint type_size = 0, nbytes = 0; int relative_dst, dst_tree_root, my_tree_root, send_offset; int recv_offset, tree_root, nprocs_completed, offset; @@ -130,13 +131,9 @@ int bcast__scatter_rdb_allgather( if (comm_size == 1) goto fn_exit; //if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN) - if(datatype->flags() & DT_FLAG_CONTIGUOUS) - is_contig = 1; - else { - is_contig = 0; - } + is_contig = ((datatype->flags() & DT_FLAG_CONTIGUOUS) != 0); - is_homogeneous = 1; + is_homogeneous = true; /* MPI_Type_size() might not give the accurate size of the packed * datatype for heterogeneous systems (because of padding, encoding, diff --git a/src/smpi/colls/gather/gather-mvapich.cpp b/src/smpi/colls/gather/gather-mvapich.cpp index 127ca1bcac..5eb527fe4a 100644 --- a/src/smpi/colls/gather/gather-mvapich.cpp +++ b/src/smpi/colls/gather/gather-mvapich.cpp @@ -52,9 +52,8 @@ typedef int (*MV2_Gather_function_ptr) (const void *sendbuf, extern MV2_Gather_function_ptr MV2_Gather_inter_leader_function; extern MV2_Gather_function_ptr MV2_Gather_intra_node_function; -#define TEMP_BUF_HAS_NO_DATA (0) -#define TEMP_BUF_HAS_DATA (1) - +#define TEMP_BUF_HAS_NO_DATA (false) +#define TEMP_BUF_HAS_DATA (true) namespace simgrid{ namespace smpi{ @@ -80,13 +79,9 @@ namespace smpi{ * intra node gather function * errflag - (out) to record errors */ -static int MPIR_pt_pt_intra_gather( const void *sendbuf, int sendcnt, MPI_Datatype sendtype, - void *recvbuf, int recvcnt, MPI_Datatype recvtype, - int root, int rank, - void *tmp_buf, int nbytes, - int is_data_avail, - MPI_Comm comm, - MV2_Gather_function_ptr intra_node_fn_ptr) +static int MPIR_pt_pt_intra_gather(const void* sendbuf, int sendcnt, MPI_Datatype sendtype, void* recvbuf, int recvcnt, + MPI_Datatype recvtype, int root, int rank, void* tmp_buf, int nbytes, + bool is_data_avail, MPI_Comm comm, MV2_Gather_function_ptr intra_node_fn_ptr) { int mpi_errno = MPI_SUCCESS; MPI_Aint recvtype_extent = 0; /* Datatype extent */ diff --git a/src/smpi/colls/reduce/reduce-binomial.cpp b/src/smpi/colls/reduce/reduce-binomial.cpp index a47f49add9..6100604079 100644 --- a/src/smpi/colls/reduce/reduce-binomial.cpp +++ b/src/smpi/colls/reduce/reduce-binomial.cpp @@ -29,7 +29,7 @@ int reduce__binomial(const void *sendbuf, void *recvbuf, int count, extent = datatype->get_extent(); unsigned char* tmp_buf = smpi_get_tmp_sendbuffer(count * extent); - int is_commutative = (op==MPI_OP_NULL || op->is_commutative()); + bool is_commutative = (op == MPI_OP_NULL || op->is_commutative()); mask = 1; int lroot; diff --git a/src/smpi/colls/reduce/reduce-mvapich-knomial.cpp b/src/smpi/colls/reduce/reduce-mvapich-knomial.cpp index 866ab8a966..0603e51194 100644 --- a/src/smpi/colls/reduce/reduce-mvapich-knomial.cpp +++ b/src/smpi/colls/reduce/reduce-mvapich-knomial.cpp @@ -128,7 +128,7 @@ int reduce__mvapich2_knomial( MPI_Comm comm) { int mpi_errno = MPI_SUCCESS; - int rank, is_commutative; + int rank; int src, k; MPI_Request send_request; int index=0; @@ -146,7 +146,7 @@ int reduce__mvapich2_knomial( datatype->extent(&true_lb, &true_extent); extent = datatype->get_extent(); - is_commutative = (op==MPI_OP_NULL || op->is_commutative()); + bool is_commutative = (op == MPI_OP_NULL || op->is_commutative()); if (rank != root) { recvbuf = (void*)smpi_get_tmp_recvbuffer(count * std::max(extent, true_extent)); diff --git a/src/smpi/colls/reduce/reduce-mvapich-two-level.cpp b/src/smpi/colls/reduce/reduce-mvapich-two-level.cpp index f3017a8df2..20a15ad574 100644 --- a/src/smpi/colls/reduce/reduce-mvapich-two-level.cpp +++ b/src/smpi/colls/reduce/reduce-mvapich-two-level.cpp @@ -91,7 +91,7 @@ int reduce__mvapich2_two_level( 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) @@ -115,7 +115,7 @@ int reduce__mvapich2_two_level( 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 reduce__mvapich2_two_level( 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 reduce__mvapich2_two_level( 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, diff --git a/src/smpi/colls/reduce/reduce-rab.cpp b/src/smpi/colls/reduce/reduce-rab.cpp index 86bb34ae45..06059579c0 100644 --- a/src/smpi/colls/reduce/reduce-rab.cpp +++ b/src/smpi/colls/reduce/reduce-rab.cpp @@ -517,7 +517,8 @@ static void MPI_I_do_op(void* b1, void* b2, void* rslt, int cnt, REDUCE_LIMITS namespace simgrid{ namespace smpi{ -static int MPI_I_anyReduce(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype mpi_datatype, MPI_Op mpi_op, int root, MPI_Comm comm, int is_all) +static int MPI_I_anyReduce(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype mpi_datatype, MPI_Op mpi_op, + int root, MPI_Comm comm, bool is_all) { char *scr1buf, *scr2buf, *scr3buf, *xxx, *sendbuf, *recvbuf; int myrank, size, x_base, x_size, computed, idx; @@ -951,12 +952,12 @@ static int MPI_I_anyReduce(const void* Sendbuf, void* Recvbuf, int count, MPI_Da int reduce__rab(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) { - return( MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op, root, comm, 0) ); + return MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op, root, comm, false); } int allreduce__rab(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) { - return( MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op, -1, comm, 1) ); + return MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op, -1, comm, true); } } } diff --git a/src/smpi/colls/reduce_scatter/reduce_scatter-mpich.cpp b/src/smpi/colls/reduce_scatter/reduce_scatter-mpich.cpp index 2f75f1f9b0..98eb126d91 100644 --- a/src/smpi/colls/reduce_scatter/reduce_scatter-mpich.cpp +++ b/src/smpi/colls/reduce_scatter/reduce_scatter-mpich.cpp @@ -32,16 +32,13 @@ int reduce_scatter__mpich_pair(const void *sendbuf, void *recvbuf, const int rec unsigned char* tmp_recvbuf; int mpi_errno = MPI_SUCCESS; int total_count, dst, src; - int is_commutative; comm_size = comm->size(); rank = comm->rank(); extent =datatype->get_extent(); datatype->extent(&true_lb, &true_extent); - if (op->is_commutative()) { - is_commutative = 1; - } + bool is_commutative = (op == MPI_OP_NULL || op->is_commutative()); int* disps = new int[comm_size]; @@ -274,16 +271,14 @@ int reduce_scatter__mpich_rdb(const void *sendbuf, void *recvbuf, const int recv int mask, dst_tree_root, my_tree_root, j, k; int received; MPI_Datatype sendtype, recvtype; - int nprocs_completed, tmp_mask, tree_root, is_commutative=0; + int nprocs_completed, tmp_mask, tree_root; comm_size = comm->size(); rank = comm->rank(); extent =datatype->get_extent(); datatype->extent(&true_lb, &true_extent); - if ((op==MPI_OP_NULL) || op->is_commutative()) { - is_commutative = 1; - } + bool is_commutative = (op == MPI_OP_NULL || op->is_commutative()); int* disps = new int[comm_size]; diff --git a/src/smpi/colls/smpi_mpich_selector.cpp b/src/smpi/colls/smpi_mpich_selector.cpp index 3c0f27abb9..b5a9c68ca9 100644 --- a/src/smpi/colls/smpi_mpich_selector.cpp +++ b/src/smpi/colls/smpi_mpich_selector.cpp @@ -457,10 +457,10 @@ int reduce_scatter__mpich(const void *sbuf, void *rbuf, if( (op==MPI_OP_NULL || op->is_commutative()) && total_message_size > 524288) { return reduce_scatter__mpich_pair(sbuf, rbuf, rcounts, dtype, op, comm); } else if ((op != MPI_OP_NULL && not op->is_commutative())) { - int is_block_regular = 1; + bool is_block_regular = true; for (i = 0; i < (comm_size - 1); ++i) { if (rcounts[i] != rcounts[i + 1]) { - is_block_regular = 0; + is_block_regular = false; break; } } diff --git a/src/smpi/colls/smpi_mvapich2_selector.cpp b/src/smpi/colls/smpi_mvapich2_selector.cpp index 2128f77c74..410c1cfd37 100644 --- a/src/smpi/colls/smpi_mvapich2_selector.cpp +++ b/src/smpi/colls/smpi_mvapich2_selector.cpp @@ -86,10 +86,9 @@ int allgather__mvapich2(const void *sendbuf, int sendcount, MPI_Datatype sendtyp int mpi_errno = MPI_SUCCESS; long nbytes = 0, comm_size, recvtype_size; int range = 0; - int partial_sub_ok = 0; + bool partial_sub_ok = false; int conf_index = 0; int range_threshold = 0; - int is_two_level = 0; MPI_Comm shmem_comm; //MPI_Comm *shmem_commptr=NULL; /* Get the size of the communicator */ @@ -116,14 +115,14 @@ int allgather__mvapich2(const void *sendbuf, int sendcount, MPI_Datatype sendtyp do { if (local_size == mv2_allgather_table_ppn_conf[i]) { conf_index = i; - partial_sub_ok = 1; + partial_sub_ok = true; break; } i++; } while(i < mv2_allgather_num_ppn_conf); } conf_check_end: - if (partial_sub_ok != 1) { + if (not partial_sub_ok) { conf_index = 0; } @@ -147,11 +146,11 @@ int allgather__mvapich2(const void *sendbuf, int sendcount, MPI_Datatype sendtyp mv2_allgather_thresholds_table[conf_index][range].inter_leader[range_threshold]. MV2_pt_Allgatherction; - is_two_level = mv2_allgather_thresholds_table[conf_index][range].two_level[range_threshold]; + bool is_two_level = mv2_allgather_thresholds_table[conf_index][range].two_level[range_threshold]; /* intracommunicator */ - if(is_two_level ==1){ - if(partial_sub_ok ==1){ + if (is_two_level) { + if (partial_sub_ok) { if (comm->is_blocked()){ mpi_errno = MPIR_2lvl_Allgather_MV2(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, @@ -340,18 +339,17 @@ int allreduce__mvapich2(const void *sendbuf, MPI_Aint sendtype_size = 0; long nbytes = 0; - int is_commutative = 0; MPI_Aint true_lb, true_extent; sendtype_size=datatype->size(); nbytes = count * sendtype_size; datatype->extent(&true_lb, &true_extent); - is_commutative = op->is_commutative(); + bool is_commutative = op->is_commutative(); { int range = 0, range_threshold = 0, range_threshold_intra = 0; - int is_two_level = 0; + bool is_two_level = false; /* Search for the corresponding system size inside the tuning table */ while ((range < (mv2_size_allreduce_tuning_table - 1)) && @@ -360,7 +358,7 @@ int allreduce__mvapich2(const void *sendbuf, } /* Search for corresponding inter-leader function */ /* skip mcast pointers if mcast is not available */ - if(mv2_allreduce_thresholds_table[range].mcast_enabled != 1){ + if (not mv2_allreduce_thresholds_table[range].mcast_enabled) { while ((range_threshold < (mv2_allreduce_thresholds_table[range].size_inter_table - 1)) && ((mv2_allreduce_thresholds_table[range]. inter_leader[range_threshold].MV2_pt_Allreducection @@ -378,8 +376,8 @@ int allreduce__mvapich2(const void *sendbuf, && (mv2_allreduce_thresholds_table[range].inter_leader[range_threshold].max != -1)) { range_threshold++; } - if(mv2_allreduce_thresholds_table[range].is_two_level_allreduce[range_threshold] == 1){ - is_two_level = 1; + if (mv2_allreduce_thresholds_table[range].is_two_level_allreduce[range_threshold]) { + is_two_level = true; } /* Search for corresponding intra-node function */ while ((range_threshold_intra < @@ -403,23 +401,23 @@ int allreduce__mvapich2(const void *sendbuf, { MV2_Allreducection = &MPIR_Allreduce_pt2pt_rd_MV2; } - if(is_two_level != 1) { + if (not is_two_level) { MV2_Allreducection = &MPIR_Allreduce_pt2pt_rd_MV2; } } - if(is_two_level == 1){ - // check if shm is ready, if not use other algorithm first - if (is_commutative) { + if (is_two_level) { + // check if shm is ready, if not use other algorithm first + if (is_commutative) { if(comm->get_leaders_comm()==MPI_COMM_NULL){ comm->init_smp(); } mpi_errno = MPIR_Allreduce_two_level_MV2(sendbuf, recvbuf, count, datatype, op, comm); - } else { + } else { mpi_errno = MPIR_Allreduce_pt2pt_rd_MV2(sendbuf, recvbuf, count, datatype, op, comm); - } + } } else { mpi_errno = MV2_Allreducection(sendbuf, recvbuf, count, datatype, op, comm); @@ -468,12 +466,11 @@ int bcast__mvapich2(void *buffer, { int mpi_errno = MPI_SUCCESS; int comm_size/*, rank*/; - int two_level_bcast = 1; + bool two_level_bcast = true; long nbytes = 0; int range = 0; int range_threshold = 0; int range_threshold_intra = 0; - // int is_homogeneous, is_contig; MPI_Aint type_size; //, position; // unsigned char *tmp_buf = NULL; @@ -490,15 +487,15 @@ int bcast__mvapich2(void *buffer, comm_size = comm->size(); //rank = comm->rank(); - //is_contig=1; + // bool is_contig = true; /* if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN)*/ -/* is_contig = 1;*/ +/* is_contig = true;*/ /* else {*/ /* MPID_Datatype_get_ptr(datatype, dtp);*/ /* is_contig = dtp->is_contig;*/ /* }*/ - // is_homogeneous = 1; + // bool is_homogeneous = true; /* MPI_Type_size() might not give the accurate size of the packed * datatype for heterogeneous systems (because of padding, encoding, @@ -585,7 +582,7 @@ int bcast__mvapich2(void *buffer, #else mv2_bcast_thresholds_table[range].is_two_level_bcast[range_threshold]; #endif - if (two_level_bcast == 1) { + if (two_level_bcast) { // if (not is_contig || not is_homogeneous) { // tmp_buf = smpi_get_tmp_sendbuffer(nbytes); @@ -669,11 +666,11 @@ int reduce__mvapich2(const void *sendbuf, int range = 0; int range_threshold = 0; int range_intra_threshold = 0; - int is_commutative, pof2; + int pof2; int comm_size = 0; long nbytes = 0; int sendtype_size; - int is_two_level = 0; + bool is_two_level = false; comm_size = comm->size(); sendtype_size=datatype->size(); @@ -682,7 +679,7 @@ int reduce__mvapich2(const void *sendbuf, if (count == 0) return MPI_SUCCESS; - is_commutative = (op==MPI_OP_NULL || op->is_commutative()); + bool is_commutative = (op == MPI_OP_NULL || op->is_commutative()); /* find nearest power-of-two less than or equal to comm_size */ for( pof2 = 1; pof2 <= comm_size; pof2 <<= 1 ); @@ -729,24 +726,23 @@ int reduce__mvapich2(const void *sendbuf, { mv2_reduce_inter_knomial_factor = mv2_reduce_thresholds_table[range].inter_k_degree; } - if(mv2_reduce_thresholds_table[range].is_two_level_reduce[range_threshold] == 1){ - is_two_level = 1; + if (mv2_reduce_thresholds_table[range].is_two_level_reduce[range_threshold]) { + is_two_level = true; } /* We call Reduce function */ - if(is_two_level == 1) - { - if (is_commutative == 1) { + if (is_two_level) { + if (is_commutative) { if(comm->get_leaders_comm()==MPI_COMM_NULL){ comm->init_smp(); } mpi_errno = MPIR_Reduce_two_level_helper_MV2(sendbuf, recvbuf, count, datatype, op, root, comm); - } else { + } else { mpi_errno = MPIR_Reduce_binomial_MV2(sendbuf, recvbuf, count, datatype, op, root, comm); - } + } } else if(MV2_Reduce_function == &MPIR_Reduce_inter_knomial_wrapper_MV2 ){ - if(is_commutative ==1) + if (is_commutative) { mpi_errno = MV2_Reduce_function(sendbuf, recvbuf, count, datatype, op, root, comm); @@ -781,13 +777,12 @@ int reduce_scatter__mvapich2(const void *sendbuf, void *recvbuf, const int *recv int mpi_errno = MPI_SUCCESS; int i = 0, comm_size = comm->size(), total_count = 0, type_size = 0, nbytes = 0; - int is_commutative = 0; int* disps = new int[comm_size]; if(mv2_red_scat_thresholds_table==NULL) init_mv2_reduce_scatter_tables_stampede(); - is_commutative=(op==MPI_OP_NULL || op->is_commutative()); + bool is_commutative = (op == MPI_OP_NULL || op->is_commutative()); for (i = 0; i < comm_size; i++) { disps[i] = total_count; total_count += recvcnts[i]; @@ -823,10 +818,10 @@ int reduce_scatter__mvapich2(const void *sendbuf, void *recvbuf, const int *recv recvcnts, datatype, op, comm); } else { - int is_block_regular = 1; + bool is_block_regular = true; for (i = 0; i < (comm_size - 1); ++i) { if (recvcnts[i] != recvcnts[i+1]) { - is_block_regular = 0; + is_block_regular = false; break; } } @@ -861,7 +856,7 @@ int scatter__mvapich2(const void *sendbuf, int mpi_errno = MPI_SUCCESS; // int mpi_errno_ret = MPI_SUCCESS; int rank, nbytes, comm_size; - int partial_sub_ok = 0; + bool partial_sub_ok = false; int conf_index = 0; MPI_Comm shmem_comm; // MPID_Comm *shmem_commptr=NULL; @@ -897,7 +892,7 @@ int scatter__mvapich2(const void *sendbuf, do { if (local_size == mv2_scatter_table_ppn_conf[i]) { conf_index = i; - partial_sub_ok = 1; + partial_sub_ok = true; break; } i++; @@ -905,7 +900,7 @@ int scatter__mvapich2(const void *sendbuf, } } - if (partial_sub_ok != 1) { + if (not partial_sub_ok) { conf_index = 0; } diff --git a/src/smpi/colls/smpi_mvapich2_selector_stampede.hpp b/src/smpi/colls/smpi_mvapich2_selector_stampede.hpp index e859efc44c..16bfdce0b1 100644 --- a/src/smpi/colls/smpi_mvapich2_selector_stampede.hpp +++ b/src/smpi/colls/smpi_mvapich2_selector_stampede.hpp @@ -339,7 +339,7 @@ struct mv2_allgather_tuning_element { struct mv2_allgather_tuning_table { int numproc; - int two_level[MV2_MAX_NB_THRESHOLDS]; + bool two_level[MV2_MAX_NB_THRESHOLDS]; int size_inter_table; mv2_allgather_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS]; }; @@ -379,7 +379,7 @@ static void init_mv2_allgather_tables_stampede() mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_1ppn[] = { { 2, - {0}, + {false}, 1, { {0, -1, &MPIR_Allgather_Ring_MV2}, @@ -387,7 +387,7 @@ static void init_mv2_allgather_tables_stampede() }, { 4, - {0, 0}, + {false, false}, 2, { {0, 262144, &MPIR_Allgather_RD_MV2}, {262144, -1, &MPIR_Allgather_Ring_MV2}, @@ -395,7 +395,7 @@ static void init_mv2_allgather_tables_stampede() }, { 8, - {0, 0}, + {false, false}, 2, { {0, 131072, &MPIR_Allgather_RD_MV2}, {131072, -1, &MPIR_Allgather_Ring_MV2}, @@ -403,7 +403,7 @@ static void init_mv2_allgather_tables_stampede() }, { 16, - {0, 0}, + {false, false}, 2, { {0, 131072, &MPIR_Allgather_RD_MV2}, {131072, -1, &MPIR_Allgather_Ring_MV2}, @@ -411,7 +411,7 @@ static void init_mv2_allgather_tables_stampede() }, { 32, - {0, 0}, + {false, false}, 2, { {0, 65536, &MPIR_Allgather_RD_MV2}, {65536, -1, &MPIR_Allgather_Ring_MV2}, @@ -419,7 +419,7 @@ static void init_mv2_allgather_tables_stampede() }, { 64, - {0, 0}, + {false, false}, 2, { {0, 32768, &MPIR_Allgather_RD_MV2}, {32768, -1, &MPIR_Allgather_Ring_MV2}, @@ -432,7 +432,7 @@ static void init_mv2_allgather_tables_stampede() mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_2ppn[] = { { 4, - {0, 0}, + {false, false}, 2, { {0, 524288, &MPIR_Allgather_RD_MV2}, {524288, -1, &MPIR_Allgather_Ring_MV2}, @@ -440,7 +440,7 @@ static void init_mv2_allgather_tables_stampede() }, { 8, - {0, 1, 0}, + {false, true, false}, 2, { {0, 32768, &MPIR_Allgather_RD_MV2}, @@ -450,7 +450,7 @@ static void init_mv2_allgather_tables_stampede() }, { 16, - {0, 1, 0}, + {false, true, false}, 2, { {0, 16384, &MPIR_Allgather_RD_MV2}, @@ -460,7 +460,7 @@ static void init_mv2_allgather_tables_stampede() }, { 32, - {1, 1, 0}, + {true, true, false}, 2, { {0, 65536, &MPIR_Allgather_RD_MV2}, @@ -470,7 +470,7 @@ static void init_mv2_allgather_tables_stampede() }, { 64, - {1, 1, 0}, + {true, true, false}, 2, { {0, 32768, &MPIR_Allgather_RD_MV2}, @@ -480,7 +480,7 @@ static void init_mv2_allgather_tables_stampede() }, { 128, - {1, 1, 0}, + {true, true, false}, 2, { {0, 65536, &MPIR_Allgather_RD_MV2}, @@ -495,7 +495,7 @@ static void init_mv2_allgather_tables_stampede() mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_16ppn[] = { { 16, - {0, 0}, + {false, false}, 2, { {0, 1024, &MPIR_Allgather_RD_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2}, @@ -503,7 +503,7 @@ static void init_mv2_allgather_tables_stampede() }, { 32, - {0, 0}, + {false, false}, 2, { {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2}, @@ -511,7 +511,7 @@ static void init_mv2_allgather_tables_stampede() }, { 64, - {0, 0}, + {false, false}, 2, { {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2}, @@ -519,7 +519,7 @@ static void init_mv2_allgather_tables_stampede() }, { 128, - {0, 0}, + {false, false}, 2, { {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2}, @@ -527,7 +527,7 @@ static void init_mv2_allgather_tables_stampede() }, { 256, - {0, 0}, + {false, false}, 2, { {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2}, @@ -535,7 +535,7 @@ static void init_mv2_allgather_tables_stampede() }, { 512, - {0, 0}, + {false, false}, 2, { {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2}, @@ -737,8 +737,8 @@ struct mv2_allreduce_tuning_element { struct mv2_allreduce_tuning_table { int numproc; - int mcast_enabled; - int is_two_level_allreduce[MV2_MAX_NB_THRESHOLDS]; + bool mcast_enabled; + bool is_two_level_allreduce[MV2_MAX_NB_THRESHOLDS]; int size_inter_table; mv2_allreduce_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS]; int size_intra_table; @@ -793,8 +793,8 @@ static void init_mv2_allreduce_tables_stampede() mv2_allreduce_tuning_table mv2_tmp_allreduce_thresholds_table[] = { { 16, - 0, - {1, 0}, + false, + {true, false}, 2, { {0, 1024, &MPIR_Allreduce_pt2pt_rd_MV2}, {1024, -1, &MPIR_Allreduce_pt2pt_rs_MV2}, @@ -806,8 +806,8 @@ static void init_mv2_allreduce_tables_stampede() }, { 32, - 0, - {1, 1, 0}, + false, + {true, true, false}, 3, { {0, 1024, &MPIR_Allreduce_pt2pt_rd_MV2}, @@ -821,8 +821,8 @@ static void init_mv2_allreduce_tables_stampede() }, { 64, - 0, - {1, 1, 0}, + false, + {true, true, false}, 3, { {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2}, @@ -836,8 +836,8 @@ static void init_mv2_allreduce_tables_stampede() }, { 128, - 0, - {1, 1, 0}, + false, + {true, true, false}, 3, { {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2}, @@ -851,8 +851,8 @@ static void init_mv2_allreduce_tables_stampede() }, { 256, - 0, - {1, 1, 0}, + false, + {true, true, false}, 3, { {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2}, @@ -866,8 +866,8 @@ static void init_mv2_allreduce_tables_stampede() }, { 512, - 0, - {1, 1, 0}, + false, + {true, true, false}, 3, { {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2}, @@ -881,8 +881,8 @@ static void init_mv2_allreduce_tables_stampede() }, { 1024, - 0, - {1, 1, 1, 0}, + false, + {true, true, true, false}, 4, { {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2}, @@ -897,8 +897,8 @@ static void init_mv2_allreduce_tables_stampede() }, { 2048, - 0, - {1, 1, 1, 0}, + false, + {true, true, true, false}, 4, { {0, 64, &MPIR_Allreduce_pt2pt_rd_MV2}, @@ -929,7 +929,7 @@ struct mv2_bcast_tuning_table { int bcast_segment_size; int intra_node_knomial_factor; int inter_node_knomial_factor; - int is_two_level_bcast[MV2_MAX_NB_THRESHOLDS]; + bool is_two_level_bcast[MV2_MAX_NB_THRESHOLDS]; int size_inter_table; mv2_bcast_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS]; int size_intra_table; @@ -980,7 +980,7 @@ static void init_mv2_bcast_tables_stampede() 8192, 4, 4, - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + {true, true, true, true, true, true, true, true, true, true, true}, 11, {{0, 8, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, {8, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, @@ -1009,7 +1009,7 @@ static void init_mv2_bcast_tables_stampede() 8192, 4, 4, - {1, 1, 1, 1, 1, 1, 1, 1}, + {true, true, true, true, true, true, true, true}, 8, {{0, 128, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, {128, 256, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, @@ -1032,7 +1032,7 @@ static void init_mv2_bcast_tables_stampede() 8192, 4, 4, - {1, 1, 1, 1, 1, 1, 1, 1, 1}, + {true, true, true, true, true, true, true, true, true}, 9, {{0, 2, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, {2, 4, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, @@ -1057,7 +1057,7 @@ static void init_mv2_bcast_tables_stampede() 8192, 4, 4, - {1, 1, 1, 0}, + {true, true, true, false}, 4, {{0, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, {8192, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, @@ -1072,7 +1072,7 @@ static void init_mv2_bcast_tables_stampede() 8192, 4, 4, - {1, 1, 1, 1, 1}, + {true, true, true, true, true}, 5, {{0, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, {16384, 131072, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}, @@ -1089,7 +1089,7 @@ static void init_mv2_bcast_tables_stampede() 8192, 4, 4, - {1, 1, 1, 1, 1}, + {true, true, true, true, true}, 5, {{0, 4096, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, {4096, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, @@ -1106,7 +1106,7 @@ static void init_mv2_bcast_tables_stampede() 8192, 4, 4, - {1, 1, 1, 1, 1}, + {true, true, true, true, true}, 5, {{0, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, {8192, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, @@ -1123,7 +1123,7 @@ static void init_mv2_bcast_tables_stampede() 8192, 4, 4, - {1, 1, 1, 1, 1, 1, 1}, + {true, true, true, true, true, true, true}, 7, {{0, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}, {16, 32, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4}, @@ -1157,7 +1157,7 @@ struct mv2_reduce_tuning_table { int numproc; int inter_k_degree; int intra_k_degree; - int is_two_level_reduce[MV2_MAX_NB_THRESHOLDS]; + bool is_two_level_reduce[MV2_MAX_NB_THRESHOLDS]; int size_inter_table; mv2_reduce_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS]; int size_intra_table; @@ -1195,7 +1195,7 @@ static void init_mv2_reduce_tables_stampede() 16, 4, 4, - {1, 0, 0}, + {true, false, false}, 3, { {0, 262144, &MPIR_Reduce_inter_knomial_wrapper_MV2}, @@ -1211,7 +1211,7 @@ static void init_mv2_reduce_tables_stampede() 32, 4, 4, - {1, 1, 1, 1, 0, 0, 0}, + {true, true, true, true, false, false, false}, 7, { {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2}, @@ -1236,7 +1236,7 @@ static void init_mv2_reduce_tables_stampede() 64, 4, 4, - {1, 1, 1, 1, 0}, + {true, true, true, true, false}, 5, { {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2}, @@ -1258,7 +1258,7 @@ static void init_mv2_reduce_tables_stampede() 128, 4, 4, - {1, 0, 1, 0, 1, 0}, + {true, false, true, false, true, false}, 6, { {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2}, @@ -1281,7 +1281,7 @@ static void init_mv2_reduce_tables_stampede() 256, 4, 4, - {1, 1, 1, 0, 1, 1, 0}, + {true, true, true, false, true, true, false}, 7, { {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2}, @@ -1306,7 +1306,7 @@ static void init_mv2_reduce_tables_stampede() 512, 4, 4, - {1, 0, 1, 1, 1, 0}, + {true, false, true, true, true, false}, 6, { {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2}, @@ -1329,7 +1329,7 @@ static void init_mv2_reduce_tables_stampede() 1024, 4, 4, - {1, 0, 1, 1, 1}, + {true, false, true, true, true}, 5, { {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2}, @@ -1351,7 +1351,7 @@ static void init_mv2_reduce_tables_stampede() 2048, 4, 4, - {1, 0, 1, 1, 1, 1}, + {true, false, true, true, true, true}, 6, { {0, 2048, &MPIR_Reduce_inter_knomial_wrapper_MV2}, diff --git a/src/smpi/colls/smpi_openmpi_selector.cpp b/src/smpi/colls/smpi_openmpi_selector.cpp index 46eca5e992..77bc0d82e9 100644 --- a/src/smpi/colls/smpi_openmpi_selector.cpp +++ b/src/smpi/colls/smpi_openmpi_selector.cpp @@ -100,12 +100,12 @@ int barrier__ompi(MPI_Comm comm) /* * the use the recursive doubling algorithm, otherwise*/ /* * bruck is the one we want.*/ { - int has_one = 0; + bool has_one = false; for( ; communicator_size > 0; communicator_size >>= 1 ) { if( communicator_size & 0x1 ) { if( has_one ) return barrier__ompi_bruck(comm); - has_one = 1; + has_one = true; } } } -- 2.20.1