This source file includes following definitions.
- MPI_Allreduce
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  24 #include "ompi_config.h"
  25 #include <stdio.h>
  26 
  27 #include "ompi/mpi/c/bindings.h"
  28 #include "ompi/runtime/params.h"
  29 #include "ompi/communicator/communicator.h"
  30 #include "ompi/errhandler/errhandler.h"
  31 #include "ompi/datatype/ompi_datatype.h"
  32 #include "ompi/op/op.h"
  33 #include "ompi/memchecker.h"
  34 #include "ompi/runtime/ompi_spc.h"
  35 
  36 #if OMPI_BUILD_MPI_PROFILING
  37 #if OPAL_HAVE_WEAK_SYMBOLS
  38 #pragma weak MPI_Allreduce = PMPI_Allreduce
  39 #endif
  40 #define MPI_Allreduce PMPI_Allreduce
  41 #endif
  42 
  43 static const char FUNC_NAME[] = "MPI_Allreduce";
  44 
  45 
  46 int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count,
  47                   MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
  48 {
  49     int err;
  50 
  51     SPC_RECORD(OMPI_SPC_ALLREDUCE, 1);
  52 
  53     MEMCHECKER(
  54         memchecker_datatype(datatype);
  55         memchecker_comm(comm);
  56 
  57         
  58         memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, count, datatype);
  59 
  60         
  61         if (MPI_IN_PLACE == sendbuf) {
  62             memchecker_call(&opal_memchecker_base_isdefined, recvbuf, count, datatype);
  63         } else {
  64             memchecker_call(&opal_memchecker_base_isdefined, sendbuf, count, datatype);
  65         }
  66     );
  67 
  68     if (MPI_PARAM_CHECK) {
  69         char *msg;
  70 
  71         
  72 
  73 
  74         err = MPI_SUCCESS;
  75         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  76         if (ompi_comm_invalid(comm)) {
  77             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  78                                           FUNC_NAME);
  79         } else if (MPI_OP_NULL == op) {
  80             err = MPI_ERR_OP;
  81         } else if (!ompi_op_is_valid(op, datatype, &msg, FUNC_NAME)) {
  82             int ret = OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, msg);
  83             free(msg);
  84             return ret;
  85         } else if ((MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
  86                    MPI_IN_PLACE == recvbuf ) {
  87             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_BUFFER,
  88                                           FUNC_NAME);
  89         } else if( (sendbuf == recvbuf) &&
  90                    (MPI_BOTTOM != sendbuf) &&
  91                    (count > 1) ) {
  92             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_BUFFER,
  93                                           FUNC_NAME);
  94         } else {
  95             OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count);
  96         }
  97         OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
  98     }
  99 
 100     
 101 
 102 
 103 
 104     if (0 == count) {
 105         return MPI_SUCCESS;
 106     }
 107 
 108     OPAL_CR_ENTER_LIBRARY();
 109 
 110     
 111 
 112     OBJ_RETAIN(op);
 113     err = comm->c_coll->coll_allreduce(sendbuf, recvbuf, count,
 114                                       datatype, op, comm,
 115                                       comm->c_coll->coll_allreduce_module);
 116     OBJ_RELEASE(op);
 117     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 118 }
 119