X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/40616078da72e823931c1fb884949054699ec39d..1bf033cc925aa31693ef5163ea056fde5b75ff1e:/src/smpi/colls/bcast/bcast-mvapich-smp.cpp diff --git a/src/smpi/colls/bcast/bcast-mvapich-smp.cpp b/src/smpi/colls/bcast/bcast-mvapich-smp.cpp index af641acf40..2313ed64a7 100644 --- a/src/smpi/colls/bcast/bcast-mvapich-smp.cpp +++ b/src/smpi/colls/bcast/bcast-mvapich-smp.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2014. The SimGrid Team. +/* Copyright (c) 2013-2018. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -34,15 +34,15 @@ * (C) 2001 by Argonne National Laboratory. * See COPYRIGHT in top-level directory. */ -#include "../colls_private.h" +#include "../colls_private.hpp" extern int (*MV2_Bcast_function) (void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm_ptr); extern int (*MV2_Bcast_intra_node_function) (void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm_ptr); - + extern int zcpy_knomial_factor; extern int mv2_pipelined_zcpy_knomial_factor; extern int bcast_segment_size; @@ -51,17 +51,17 @@ extern int mv2_intra_node_knomial_factor; extern int mv2_bcast_two_level_system_size; #define INTRA_NODE_ROOT 0 -#define MPIR_Pipelined_Bcast_Zcpy_MV2 smpi_coll_tuned_bcast_mpich -#define MPIR_Pipelined_Bcast_MV2 smpi_coll_tuned_bcast_mpich -#define MPIR_Bcast_binomial_MV2 smpi_coll_tuned_bcast_binomial_tree -#define MPIR_Bcast_scatter_ring_allgather_shm_MV2 smpi_coll_tuned_bcast_scatter_LR_allgather -#define MPIR_Bcast_scatter_doubling_allgather_MV2 smpi_coll_tuned_bcast_scatter_rdb_allgather -#define MPIR_Bcast_scatter_ring_allgather_MV2 smpi_coll_tuned_bcast_scatter_LR_allgather -#define MPIR_Shmem_Bcast_MV2 smpi_coll_tuned_bcast_mpich -#define MPIR_Bcast_tune_inter_node_helper_MV2 smpi_coll_tuned_bcast_mvapich2_inter_node -#define MPIR_Bcast_inter_node_helper_MV2 smpi_coll_tuned_bcast_mvapich2_inter_node -#define MPIR_Knomial_Bcast_intra_node_MV2 smpi_coll_tuned_bcast_mvapich2_knomial_intra_node -#define MPIR_Bcast_intra_MV2 smpi_coll_tuned_bcast_mvapich2_intra_node +#define MPIR_Pipelined_Bcast_Zcpy_MV2 Coll_bcast_mpich::bcast +#define MPIR_Pipelined_Bcast_MV2 Coll_bcast_mpich::bcast +#define MPIR_Bcast_binomial_MV2 Coll_bcast_binomial_tree::bcast +#define MPIR_Bcast_scatter_ring_allgather_shm_MV2 Coll_bcast_scatter_LR_allgather::bcast +#define MPIR_Bcast_scatter_doubling_allgather_MV2 Coll_bcast_scatter_rdb_allgather::bcast +#define MPIR_Bcast_scatter_ring_allgather_MV2 Coll_bcast_scatter_LR_allgather::bcast +#define MPIR_Shmem_Bcast_MV2 Coll_bcast_mpich::bcast +#define MPIR_Bcast_tune_inter_node_helper_MV2 Coll_bcast_mvapich2_inter_node::bcast +#define MPIR_Bcast_inter_node_helper_MV2 Coll_bcast_mvapich2_inter_node::bcast +#define MPIR_Knomial_Bcast_intra_node_MV2 Coll_bcast_mvapich2_knomial_intra_node::bcast +#define MPIR_Bcast_intra_MV2 Coll_bcast_mvapich2_intra_node::bcast extern int zcpy_knomial_factor; extern int mv2_pipelined_zcpy_knomial_factor; @@ -73,7 +73,9 @@ extern int mv2_intra_node_knomial_factor; #define mv2_bcast_large_msg 512*1024 #define mv2_knomial_intra_node_threshold 131072 #define mv2_scatter_rd_inter_leader_bcast 1 -int smpi_coll_tuned_bcast_mvapich2_inter_node(void *buffer, +namespace simgrid{ +namespace smpi{ +int Coll_bcast_mvapich2_inter_node::bcast(void *buffer, int count, MPI_Datatype datatype, int root, @@ -91,17 +93,17 @@ int smpi_coll_tuned_bcast_mvapich2_inter_node(void *buffer, if (MV2_Bcast_function==NULL){ - MV2_Bcast_function=smpi_coll_tuned_bcast_mpich; + MV2_Bcast_function=Coll_bcast_mpich::bcast; } - + if (MV2_Bcast_intra_node_function==NULL){ - MV2_Bcast_intra_node_function= smpi_coll_tuned_bcast_mpich; + MV2_Bcast_intra_node_function= Coll_bcast_mpich::bcast; } - + if(comm->get_leaders_comm()==MPI_COMM_NULL){ comm->init_smp(); } - + shmem_comm = comm->get_intra_comm(); local_rank = shmem_comm->rank(); local_size = shmem_comm->size(); @@ -115,8 +117,8 @@ int smpi_coll_tuned_bcast_mvapich2_inter_node(void *buffer, int* leaders_map = comm->get_leaders_map(); leader_of_root = comm->group()->rank(leaders_map[root]); leader_root = leader_comm->group()->rank(leaders_map[root]); - - + + if (local_size > 1) { if ((local_rank == 0) && (root != rank) && (leader_root == global_rank)) { Request::recv(buffer, count, datatype, root, @@ -168,7 +170,7 @@ int smpi_coll_tuned_bcast_mvapich2_inter_node(void *buffer, } -int smpi_coll_tuned_bcast_mvapich2_knomial_intra_node(void *buffer, +int Coll_bcast_mvapich2_knomial_intra_node::bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm) @@ -180,17 +182,17 @@ int smpi_coll_tuned_bcast_mvapich2_knomial_intra_node(void *buffer, int src, dst, mask, relative_rank; int k; if (MV2_Bcast_function==NULL){ - MV2_Bcast_function=smpi_coll_tuned_bcast_mpich; + MV2_Bcast_function=Coll_bcast_mpich::bcast; } - + if (MV2_Bcast_intra_node_function==NULL){ - MV2_Bcast_intra_node_function= smpi_coll_tuned_bcast_mpich; + MV2_Bcast_intra_node_function= Coll_bcast_mpich::bcast; } - + if(comm->get_leaders_comm()==MPI_COMM_NULL){ comm->init_smp(); } - + local_size = comm->size(); rank = comm->rank(); @@ -244,7 +246,7 @@ int smpi_coll_tuned_bcast_mvapich2_knomial_intra_node(void *buffer, } -int smpi_coll_tuned_bcast_mvapich2_intra_node(void *buffer, +int Coll_bcast_mvapich2_intra_node::bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm) @@ -252,7 +254,7 @@ int smpi_coll_tuned_bcast_mvapich2_intra_node(void *buffer, int mpi_errno = MPI_SUCCESS; int comm_size; int two_level_bcast = 1; - size_t nbytes = 0; + size_t nbytes = 0; int is_homogeneous, is_contig; MPI_Aint type_size; void *tmp_buf = NULL; @@ -261,17 +263,17 @@ int smpi_coll_tuned_bcast_mvapich2_intra_node(void *buffer, if (count == 0) return MPI_SUCCESS; if (MV2_Bcast_function==NULL){ - MV2_Bcast_function=smpi_coll_tuned_bcast_mpich; + MV2_Bcast_function=Coll_bcast_mpich::bcast; } - + if (MV2_Bcast_intra_node_function==NULL){ - MV2_Bcast_intra_node_function= smpi_coll_tuned_bcast_mpich; + MV2_Bcast_intra_node_function= Coll_bcast_mpich::bcast; } - + if(comm->get_leaders_comm()==MPI_COMM_NULL){ comm->init_smp(); } - + comm_size = comm->size(); // rank = comm->rank(); /* @@ -316,24 +318,22 @@ int smpi_coll_tuned_bcast_mvapich2_intra_node(void *buffer, #endif ) { - if (!is_contig || !is_homogeneous) { - tmp_buf=(void *)smpi_get_tmp_sendbuffer(nbytes); - - /* TODO: Pipeline the packing and communication */ - // position = 0; -/* if (rank == root) {*/ -/* mpi_errno =*/ -/* MPIR_Pack_impl(buffer, count, datatype, tmp_buf, nbytes, &position);*/ -/* if (mpi_errno)*/ -/* MPIU_ERR_POP(mpi_errno);*/ -/* }*/ + if (not is_contig || not is_homogeneous) { + tmp_buf = (void*)smpi_get_tmp_sendbuffer(nbytes); + + /* TODO: Pipeline the packing and communication */ + // position = 0; + /* if (rank == root) {*/ + /* mpi_errno =*/ + /* MPIR_Pack_impl(buffer, count, datatype, tmp_buf, nbytes, &position);*/ + /* if (mpi_errno)*/ + /* MPIU_ERR_POP(mpi_errno);*/ + /* }*/ } shmem_comm = comm->get_intra_comm(); - if (!is_contig || !is_homogeneous) { - mpi_errno = - MPIR_Bcast_inter_node_helper_MV2(tmp_buf, nbytes, MPI_BYTE, - root, comm); + if (not is_contig || not is_homogeneous) { + mpi_errno = MPIR_Bcast_inter_node_helper_MV2(tmp_buf, nbytes, MPI_BYTE, root, comm); } else { mpi_errno = MPIR_Bcast_inter_node_helper_MV2(buffer, count, datatype, root, @@ -342,20 +342,15 @@ int smpi_coll_tuned_bcast_mvapich2_intra_node(void *buffer, /* We are now done with the inter-node phase */ if (nbytes <= mv2_knomial_intra_node_threshold) { - if (!is_contig || !is_homogeneous) { - mpi_errno = MPIR_Shmem_Bcast_MV2(tmp_buf, nbytes, MPI_BYTE, - root, shmem_comm); + if (not is_contig || not is_homogeneous) { + mpi_errno = MPIR_Shmem_Bcast_MV2(tmp_buf, nbytes, MPI_BYTE, root, shmem_comm); } else { mpi_errno = MPIR_Shmem_Bcast_MV2(buffer, count, datatype, root, shmem_comm); } } else { - if (!is_contig || !is_homogeneous) { - mpi_errno = - MPIR_Knomial_Bcast_intra_node_MV2(tmp_buf, nbytes, - MPI_BYTE, - INTRA_NODE_ROOT, - shmem_comm); + if (not is_contig || not is_homogeneous) { + mpi_errno = MPIR_Knomial_Bcast_intra_node_MV2(tmp_buf, nbytes, MPI_BYTE, INTRA_NODE_ROOT, shmem_comm); } else { mpi_errno = MPIR_Knomial_Bcast_intra_node_MV2(buffer, count, @@ -388,3 +383,6 @@ int smpi_coll_tuned_bcast_mvapich2_intra_node(void *buffer, return mpi_errno; } + +} +}