X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/40616078da72e823931c1fb884949054699ec39d..72d32c4e88a57f4786f62fec48a1bfa454adbff9:/src/smpi/colls/allreduce/allreduce-mvapich-two-level.cpp diff --git a/src/smpi/colls/allreduce/allreduce-mvapich-two-level.cpp b/src/smpi/colls/allreduce/allreduce-mvapich-two-level.cpp index d2a2264c82..b643cdb1c7 100644 --- a/src/smpi/colls/allreduce/allreduce-mvapich-two-level.cpp +++ b/src/smpi/colls/allreduce/allreduce-mvapich-two-level.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2014. 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 @@ -35,47 +35,48 @@ * See COPYRIGHT in top-level directory. */ -#include "../colls_private.h" +#include "../colls_private.hpp" -#define MPIR_Allreduce_pt2pt_rd_MV2 smpi_coll_tuned_allreduce_rdb -#define MPIR_Allreduce_pt2pt_rs_MV2 smpi_coll_tuned_allreduce_mvapich2_rs +#define MPIR_Allreduce_pt2pt_rd_MV2 allreduce__rdb +#define MPIR_Allreduce_pt2pt_rs_MV2 allreduce__mvapich2_rs -extern int (*MV2_Allreduce_function)(void *sendbuf, +extern int (*MV2_Allreducection)(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm); -extern int (*MV2_Allreduce_intra_function)( void *sendbuf, +extern int (*MV2_Allreduce_intra_function)(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm); - -static int MPIR_Allreduce_reduce_p2p_MV2( void *sendbuf, + +namespace simgrid::smpi { +static int MPIR_Allreduce_reduce_p2p_MV2(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) { - mpi_coll_reduce_fun(sendbuf,recvbuf,count,datatype,op,0,comm); + colls::reduce(sendbuf, recvbuf, count, datatype, op, 0, comm); return MPI_SUCCESS; } -static int MPIR_Allreduce_reduce_shmem_MV2( void *sendbuf, +static int MPIR_Allreduce_reduce_shmem_MV2(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) { - mpi_coll_reduce_fun(sendbuf,recvbuf,count,datatype,op,0,comm); + colls::reduce(sendbuf, recvbuf, count, datatype, op, 0, comm); return MPI_SUCCESS; } - - + + /* general two level allreduce helper function */ -int smpi_coll_tuned_allreduce_mvapich2_two_level(void *sendbuf, +int allreduce__mvapich2_two_level(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, @@ -88,15 +89,15 @@ int smpi_coll_tuned_allreduce_mvapich2_two_level(void *sendbuf, int local_rank = -1, local_size = 0; //if not set (use of the algo directly, without mvapich2 selector) - if(MV2_Allreduce_intra_function==NULL) - MV2_Allreduce_intra_function = smpi_coll_tuned_allreduce_mpich; - if(MV2_Allreduce_function==NULL) - MV2_Allreduce_function = smpi_coll_tuned_allreduce_rdb; - + if (MV2_Allreduce_intra_function == nullptr) + MV2_Allreduce_intra_function = allreduce__mpich; + if (MV2_Allreducection == nullptr) + MV2_Allreducection = allreduce__rdb; + if(comm->get_leaders_comm()==MPI_COMM_NULL){ comm->init_smp(); } - + if (count == 0) { return MPI_SUCCESS; } @@ -119,7 +120,7 @@ int smpi_coll_tuned_allreduce_mvapich2_two_level(void *sendbuf, /* Doing the shared memory gather and reduction by the leader */ if (local_rank == 0) { - if ((MV2_Allreduce_intra_function == &MPIR_Allreduce_reduce_shmem_MV2) || + if ((MV2_Allreduce_intra_function == &MPIR_Allreduce_reduce_shmem_MV2) || (MV2_Allreduce_intra_function == &MPIR_Allreduce_reduce_p2p_MV2) ) { mpi_errno = MV2_Allreduce_intra_function(sendbuf, recvbuf, count, datatype, @@ -132,10 +133,10 @@ int smpi_coll_tuned_allreduce_mvapich2_two_level(void *sendbuf, } if (local_size != total_size) { - void* sendtmpbuf = (char *)smpi_get_tmp_sendbuffer(count*datatype->get_extent()); + unsigned char* sendtmpbuf = smpi_get_tmp_sendbuffer(count * datatype->get_extent()); Datatype::copy(recvbuf, count, datatype,sendtmpbuf, count, datatype); /* inter-node allreduce */ - if(MV2_Allreduce_function == &MPIR_Allreduce_pt2pt_rd_MV2){ + if(MV2_Allreducection == &MPIR_Allreduce_pt2pt_rd_MV2){ mpi_errno = MPIR_Allreduce_pt2pt_rd_MV2(sendtmpbuf, recvbuf, count, datatype, op, leader_comm); @@ -148,7 +149,7 @@ int smpi_coll_tuned_allreduce_mvapich2_two_level(void *sendbuf, } } else { /* insert the first reduce here */ - if ((MV2_Allreduce_intra_function == &MPIR_Allreduce_reduce_shmem_MV2) || + if ((MV2_Allreduce_intra_function == &MPIR_Allreduce_reduce_shmem_MV2) || (MV2_Allreduce_intra_function == &MPIR_Allreduce_reduce_p2p_MV2) ) { mpi_errno = MV2_Allreduce_intra_function(sendbuf, recvbuf, count, datatype, @@ -161,10 +162,11 @@ int smpi_coll_tuned_allreduce_mvapich2_two_level(void *sendbuf, } } - /* Broadcasting the mesage from leader to the rest */ + /* Broadcasting the message from leader to the rest */ /* Note: shared memory broadcast could improve the performance */ - mpi_errno = mpi_coll_bcast_fun(recvbuf, count, datatype, 0, shmem_comm); + mpi_errno = colls::bcast(recvbuf, count, datatype, 0, shmem_comm); return (mpi_errno); } +} // namespace simgrid::smpi