1
1
openmpi/src/mpi/c/reduce_scatter.c
Jeff Squyres a5a712b31f Lots of changes in this commit, mostly having to do with the first
real commit of the collectives.  MPI_SCAN and MPI_EXSCAN are still not
implemented, but lots of other things are in the critical path and
holding up other people, so it's ok to commit without them:

- better checks for sizes in configure, and add defaults for fortran
  sizes if we don't have a fortran compiler
- fix some logic that was accidentally broken for size checks for the
  file type offset_t
- add some C equivalent types for fortran's complex and double complex
  (for use in internal reduction/op functions)
- additionals and slight reorganization of ompi_mpi_init()
  ompi_mpi_finalize()
- fully implement all top-level MPI collective calls, including all
  param checking for both intra- and inter-communicators (woof)
- change the communicator_t type for stuff that we need in coll, and
  update all references throughout the code base to match
- all kinds of updates to the coll framework base
- next cut of the basic coll module -- has all intracommunicator
  collectives implemented except scan and exscan (see note above).
  All intercommunicator functions return ERR_NOT_IMPLEMENTED.
- MPI_Op is a fixed implementation -- not component-ized yet.  So
  there are generic C loops for all implementations.

This commit was SVN r1491.
2004-06-29 00:02:25 +00:00

75 строки
2.1 KiB
C

/*
* $HEADERS$
*/
#include "ompi_config.h"
#include <stdio.h>
#include "mpi.h"
#include "mpi/c/bindings.h"
#include "mca/coll/coll.h"
#include "errhandler/errhandler.h"
#include "communicator/communicator.h"
#include "op/op.h"
#if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
#pragma weak MPI_Reduce_scatter = PMPI_Reduce_scatter
#endif
#if OMPI_PROFILING_DEFINES
#include "mpi/c/profile/defines.h"
#endif
static char FUNC_NAME[] = "MPI_Reduce_scatter";
int MPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
int i, err, size;
if (MPI_PARAM_CHECK) {
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
FUNC_NAME);
}
/* Unrooted operation; same checks for all ranks on both
intracommunicators and intercommunicators */
if (MPI_DATATYPE_NULL == datatype) {
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME);
}
if (MPI_OP_NULL == op) {
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, FUNC_NAME);
}
if (ompi_op_is_intrinsic(op) && datatype->id < DT_MAX_PREDEFINED &&
-1 == ompi_op_ddt_map[datatype->id]) {
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, FUNC_NAME);
}
if (NULL == recvcounts) {
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
}
if (OMPI_COMM_IS_INTRA(comm)) {
size = ompi_comm_size(comm);
} else {
size = ompi_comm_remote_size(comm);
}
for (i = 0; i < size; ++i) {
if (recvcounts[i] < 0) {
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
}
}
}
/* Invoke the coll component to perform the back-end operation */
err = comm->c_coll.coll_reduce_scatter(sendbuf, recvbuf, recvcounts,
datatype, op, comm);
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
}