int MPIR_Bcast_impl(void *buffer, int count, MPI_Datatype datatype, int root, MPIR_Comm * comm_ptr, MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; if (comm_ptr->comm_kind == MPIR_COMM_KIND__INTRACOMM) { /* intracommunicator */ switch (MPIR_CVAR_BCAST_INTRA_ALGORITHM) { case MPIR_CVAR_BCAST_INTRA_ALGORITHM_binomial: mpi_errno = MPIR_Bcast_intra_binomial(buffer, count, datatype, root, comm_ptr, errflag); break; case MPIR_CVAR_BCAST_INTRA_ALGORITHM_scatter_recursive_doubling_allgather: mpi_errno = MPIR_Bcast_intra_scatter_recursive_doubling_allgather(buffer, count, datatype, root, comm_ptr, errflag); break; case MPIR_CVAR_BCAST_INTRA_ALGORITHM_scatter_ring_allgather: mpi_errno = MPIR_Bcast_intra_scatter_ring_allgather(buffer, count, datatype, root, comm_ptr, errflag); break; case MPIR_CVAR_BCAST_INTRA_ALGORITHM_nb: mpi_errno = MPIR_Bcast_allcomm_nb(buffer, count, datatype, root, comm_ptr, errflag); break; case MPIR_CVAR_BCAST_INTRA_ALGORITHM_auto: MPL_FALLTHROUGH; default: mpi_errno = MPIR_Bcast_intra_auto(buffer, count, datatype, root, comm_ptr, errflag); break; } } else { /* intercommunicator */ switch (MPIR_CVAR_BCAST_INTER_ALGORITHM) { case MPIR_CVAR_BCAST_INTER_ALGORITHM_remote_send_local_bcast: mpi_errno = MPIR_Bcast_inter_remote_send_local_bcast(buffer, count, datatype, root, comm_ptr, errflag); break; case MPIR_CVAR_BCAST_INTER_ALGORITHM_nb: mpi_errno = MPIR_Bcast_allcomm_nb(buffer, count, datatype, root, comm_ptr, errflag); break; case MPIR_CVAR_BCAST_INTER_ALGORITHM_auto: MPL_FALLTHROUGH; default: mpi_errno = MPIR_Bcast_inter_auto(buffer, count, datatype, root, comm_ptr, errflag); break; } } if (mpi_errno) MPIR_ERR_POP(mpi_errno); fn_exit: return mpi_errno; fn_fail: goto fn_exit; }
int MPIR_Bcast_impl(void *buffer, int count, MPI_Datatype datatype, int root, MPIR_Comm * comm_ptr, MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; if (comm_ptr->comm_kind == MPIR_COMM_KIND__INTRACOMM) { /* intracommunicator */ switch (MPIR_Bcast_intra_algo_choice) { case MPIR_BCAST_INTRA_ALGO_BINOMIAL: mpi_errno = MPIR_Bcast_intra_binomial(buffer, count, datatype, root, comm_ptr, errflag); break; case MPIR_BCAST_INTRA_ALGO_SCATTER_RECURSIVE_DOUBLING_ALLGATHER: mpi_errno = MPIR_Bcast_intra_scatter_recursive_doubling_allgather(buffer, count, datatype, root, comm_ptr, errflag); break; case MPIR_BCAST_INTRA_ALGO_SCATTER_RING_ALLGATHER: mpi_errno = MPIR_Bcast_intra_scatter_ring_allgather(buffer, count, datatype, root, comm_ptr, errflag); break; case MPIR_BCAST_INTRA_ALGO_NB: mpi_errno = MPIR_Bcast_allcomm_nb(buffer, count, datatype, root, comm_ptr, errflag); break; case MPIR_BCAST_INTRA_ALGO_AUTO: MPL_FALLTHROUGH; default: mpi_errno = MPIR_Bcast_intra_auto(buffer, count, datatype, root, comm_ptr, errflag); break; } } else { /* intercommunicator */ switch (MPIR_Bcast_inter_algo_choice) { case MPIR_BCAST_INTER_ALGO_REMOTE_SEND_LOCAL_BCAST: mpi_errno = MPIR_Bcast_inter_remote_send_local_bcast(buffer, count, datatype, root, comm_ptr, errflag); break; case MPIR_BCAST_INTER_ALGO_NB: mpi_errno = MPIR_Bcast_allcomm_nb(buffer, count, datatype, root, comm_ptr, errflag); break; case MPIR_BCAST_INTER_ALGO_AUTO: MPL_FALLTHROUGH; default: mpi_errno = MPIR_Bcast_inter_auto(buffer, count, datatype, root, comm_ptr, errflag); break; } } if (mpi_errno) MPIR_ERR_POP(mpi_errno); fn_exit: return mpi_errno; fn_fail: goto fn_exit; }
int MPIR_Bcast_inter_remote_send_local_bcast ( void *buffer, int count, MPI_Datatype datatype, int root, MPIR_Comm *comm_ptr, MPIR_Errflag_t *errflag) { int rank, mpi_errno; int mpi_errno_ret = MPI_SUCCESS; MPI_Status status; MPIR_Comm *newcomm_ptr = NULL; MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPIR_BCAST_INTER); MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPIR_BCAST_INTER); if (root == MPI_PROC_NULL) { /* local processes other than root do nothing */ mpi_errno = MPI_SUCCESS; } else if (root == MPI_ROOT) { /* root sends to rank 0 on remote group and returns */ mpi_errno = MPIC_Send(buffer, count, datatype, 0, MPIR_BCAST_TAG, comm_ptr, errflag); if (mpi_errno) { /* for communication errors, just record the error but continue */ *errflag = MPIR_ERR_GET_CLASS(mpi_errno); MPIR_ERR_SET(mpi_errno, *errflag, "**fail"); MPIR_ERR_ADD(mpi_errno_ret, mpi_errno); } } else { /* remote group. rank 0 on remote group receives from root */ rank = comm_ptr->rank; if (rank == 0) { mpi_errno = MPIC_Recv(buffer, count, datatype, root, MPIR_BCAST_TAG, comm_ptr, &status, errflag); if (mpi_errno) { /* for communication errors, just record the error but continue */ *errflag = MPIR_ERR_GET_CLASS(mpi_errno); MPIR_ERR_SET(mpi_errno, *errflag, "**fail"); MPIR_ERR_ADD(mpi_errno_ret, mpi_errno); } } /* Get the local intracommunicator */ if (!comm_ptr->local_comm) MPII_Setup_intercomm_localcomm( comm_ptr ); newcomm_ptr = comm_ptr->local_comm; /* now do the usual broadcast on this intracommunicator with rank 0 as root. */ mpi_errno = MPIR_Bcast_intra_auto(buffer, count, datatype, 0, newcomm_ptr, errflag); if (mpi_errno) { /* for communication errors, just record the error but continue */ *errflag = MPIR_ERR_GET_CLASS(mpi_errno); MPIR_ERR_SET(mpi_errno, *errflag, "**fail"); MPIR_ERR_ADD(mpi_errno_ret, mpi_errno); } } MPIR_FUNC_TERSE_EXIT(MPID_STATE_MPIR_BCAST_INTER); /* --BEGIN ERROR HANDLING-- */ if (mpi_errno_ret) mpi_errno = mpi_errno_ret; else if (*errflag != MPIR_ERR_NONE) MPIR_ERR_SET(mpi_errno, MPI_ERR_OTHER, "**coll_fail"); /* --END ERROR HANDLING-- */ return mpi_errno; }