This source file includes following definitions.
- MPI_Reduce_scatter
   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_Reduce_scatter = PMPI_Reduce_scatter
  39 #endif
  40 #define MPI_Reduce_scatter PMPI_Reduce_scatter
  41 #endif
  42 
  43 static const char FUNC_NAME[] = "MPI_Reduce_scatter";
  44 
  45 
  46 int MPI_Reduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts[],
  47                        MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
  48 {
  49     int i, err, size, count;
  50 
  51     SPC_RECORD(OMPI_SPC_REDUCE_SCATTER, 1);
  52 
  53     MEMCHECKER(
  54         int rank;
  55 
  56         size = ompi_comm_size(comm);
  57         rank = ompi_comm_rank(comm);
  58         for (count = i = 0; i < size; ++i) {
  59             if (0 == recvcounts[i]) {
  60                 count += recvcounts[i];
  61             }
  62         }
  63 
  64         memchecker_comm(comm);
  65         memchecker_datatype(datatype);
  66 
  67         
  68         memchecker_call(&opal_memchecker_base_isaddressable, recvbuf,
  69                         recvcounts[rank], datatype);
  70 
  71         
  72         if(MPI_IN_PLACE == sendbuf) {
  73             memchecker_call(&opal_memchecker_base_isdefined, recvbuf, count, datatype);
  74         } else {
  75             memchecker_call(&opal_memchecker_base_isdefined, sendbuf, count, datatype);
  76 
  77         }
  78     );
  79 
  80     if (MPI_PARAM_CHECK) {
  81         char *msg;
  82         err = MPI_SUCCESS;
  83         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  84         if (ompi_comm_invalid(comm)) {
  85             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  86                                           FUNC_NAME);
  87         }
  88 
  89         
  90 
  91 
  92         else if (MPI_OP_NULL == op || NULL == op) {
  93           err = MPI_ERR_OP;
  94         } else if (!ompi_op_is_valid(op, datatype, &msg, FUNC_NAME)) {
  95             int ret = OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, msg);
  96             free(msg);
  97             return ret;
  98         } else if (NULL == recvcounts) {
  99           err = MPI_ERR_COUNT;
 100         } else if (MPI_IN_PLACE == recvbuf) {
 101           err = MPI_ERR_ARG;
 102         }
 103         OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 104 
 105         
 106 
 107 
 108         size = ompi_comm_size(comm);
 109         for (i = 0; i < size; ++i) {
 110           OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, recvcounts[i]);
 111           OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 112         }
 113     }
 114 
 115     
 116 
 117 
 118 
 119     size = ompi_comm_size(comm);
 120     for (count = i = 0; i < size; ++i) {
 121         if (0 == recvcounts[i]) {
 122             ++count;
 123         }
 124     }
 125     if (size == count) {
 126         return MPI_SUCCESS;
 127     }
 128 
 129     OPAL_CR_ENTER_LIBRARY();
 130 
 131     
 132 
 133     OBJ_RETAIN(op);
 134     err = comm->c_coll->coll_reduce_scatter(sendbuf, recvbuf, recvcounts,
 135                                            datatype, op, comm,
 136                                            comm->c_coll->coll_reduce_scatter_module);
 137     OBJ_RELEASE(op);
 138     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 139 }