2004-01-20 09:30:33 +03:00
|
|
|
/*
|
|
|
|
* $HEADERS$
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-01-20 09:30:33 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "mpi.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "mpi/c/bindings.h"
|
2004-05-08 03:44:49 +04:00
|
|
|
#include "mca/coll/coll.h"
|
|
|
|
#include "communicator/communicator.h"
|
2004-01-20 09:30:33 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
|
2004-01-20 09:30:33 +03:00
|
|
|
#pragma weak MPI_Bcast = PMPI_Bcast
|
|
|
|
#endif
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#if OMPI_PROFILING_DEFINES
|
2004-04-20 22:50:43 +04:00
|
|
|
#include "mpi/c/profile/defines.h"
|
|
|
|
#endif
|
|
|
|
|
2004-05-08 03:44:49 +04:00
|
|
|
static char FUNC_NAME[] = "MPI_Bcast";
|
|
|
|
|
|
|
|
|
2004-01-20 09:30:33 +03:00
|
|
|
int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype,
|
2004-05-08 03:44:49 +04:00
|
|
|
int root, MPI_Comm comm)
|
|
|
|
{
|
|
|
|
int size, err;
|
|
|
|
mca_coll_base_bcast_fn_t func;
|
|
|
|
|
|
|
|
if (MPI_PARAM_CHECK) {
|
|
|
|
if (MPI_COMM_NULL == comm) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
|
2004-05-08 03:44:49 +04:00
|
|
|
FUNC_NAME);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL == buffer) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
|
2004-05-08 03:44:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (MPI_DATATYPE_NULL == datatype) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME);
|
2004-05-08 03:44:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (count < 0) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
|
2004-05-08 03:44:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_COMM_IS_INTRA(comm)) {
|
2004-05-08 03:44:49 +04:00
|
|
|
MPI_Comm_size(comm, &size);
|
|
|
|
if ((root >= size) || (root < 0)) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME);
|
2004-05-08 03:44:49 +04:00
|
|
|
}
|
|
|
|
if (count == 0 && comm->c_coll.coll_bcast_optimization) {
|
|
|
|
return(MPI_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If there's only one node, we're done */
|
|
|
|
|
|
|
|
else if (size <= 1) {
|
|
|
|
return(MPI_SUCCESS);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
MPI_Comm_remote_size(comm, &size);
|
|
|
|
if (!(((root < size) && (root >= 0))
|
|
|
|
|| (root == MPI_ROOT) || (root == MPI_PROC_NULL))) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME);
|
2004-05-08 03:44:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* VPS: Need to change this to another pointer, because we wont have
|
|
|
|
two pointers - intra and inter - cached in the new design */
|
|
|
|
func = comm->c_coll.coll_bcast_intra;
|
|
|
|
|
|
|
|
if (NULL == func)
|
|
|
|
return MPI_ERR_OTHER;
|
|
|
|
|
|
|
|
err = func(buffer, count, datatype, root, comm);
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
OMPI_ERRHANDLER_RETURN(err, comm, MPI_ERR_UNKNOWN, FUNC_NAME);
|
2004-01-20 09:30:33 +03:00
|
|
|
}
|