root/ompi/mpiext/pcollreq/c/reduce_scatter_init.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPIX_Reduce_scatter_init

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2018 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2006-2012 Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2012-2013 Los Alamos National Security, LLC.  All rights
  15  *                         reserved.
  16  * Copyright (c) 2015-2018 Research Organization for Information Science
  17  *                         and Technology (RIST). All rights reserved.
  18  * Copyright (c) 2016      IBM Corporation.  All rights reserved.
  19  * Copyright (c) 2018      FUJITSU LIMITED.  All rights reserved.
  20  * $COPYRIGHT$
  21  *
  22  * Additional copyrights may follow
  23  *
  24  * $HEADER$
  25  */
  26 #include "ompi_config.h"
  27 #include <stdio.h>
  28 
  29 #include "ompi/mpi/c/bindings.h"
  30 #include "ompi/runtime/params.h"
  31 #include "ompi/communicator/communicator.h"
  32 #include "ompi/errhandler/errhandler.h"
  33 #include "ompi/datatype/ompi_datatype.h"
  34 #include "ompi/op/op.h"
  35 #include "ompi/memchecker.h"
  36 #include "ompi/mpiext/pcollreq/c/mpiext_pcollreq_c.h"
  37 #include "ompi/runtime/ompi_spc.h"
  38 
  39 #if OMPI_BUILD_MPI_PROFILING
  40 #if OPAL_HAVE_WEAK_SYMBOLS
  41 #pragma weak MPIX_Reduce_scatter_init = PMPIX_Reduce_scatter_init
  42 #endif
  43 #define MPIX_Reduce_scatter_init PMPIX_Reduce_scatter_init
  44 #endif
  45 
  46 static const char FUNC_NAME[] = "MPIX_Reduce_scatter_init";
  47 
  48 
  49 int MPIX_Reduce_scatter_init(const void *sendbuf, void *recvbuf, const int recvcounts[],
  50                              MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, MPI_Info info, MPI_Request *request)
  51 {
  52     int i, err, size, count;
  53 
  54     SPC_RECORD(OMPI_SPC_REDUCE_SCATTER_INIT, 1);
  55 
  56     MEMCHECKER(
  57         int rank;
  58         int count;
  59 
  60         size = ompi_comm_size(comm);
  61         rank = ompi_comm_rank(comm);
  62         for (count = i = 0; i < size; ++i) {
  63             if (0 == recvcounts[i]) {
  64                 count += recvcounts[i];
  65             }
  66         }
  67 
  68         memchecker_comm(comm);
  69         memchecker_datatype(datatype);
  70 
  71         /* check receive buffer of current proccess, whether it's addressable. */
  72         memchecker_call(&opal_memchecker_base_isaddressable, recvbuf,
  73                         recvcounts[rank], datatype);
  74 
  75         /* check whether the actual send buffer is defined. */
  76         if(MPI_IN_PLACE == sendbuf) {
  77             memchecker_call(&opal_memchecker_base_isdefined, recvbuf, count, datatype);
  78         } else {
  79             memchecker_call(&opal_memchecker_base_isdefined, sendbuf, count, datatype);
  80 
  81         }
  82     );
  83 
  84     if (MPI_PARAM_CHECK) {
  85         char *msg;
  86         err = MPI_SUCCESS;
  87         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  88         if (ompi_comm_invalid(comm)) {
  89             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  90                                           FUNC_NAME);
  91         }
  92 
  93         /* Unrooted operation; same checks for all ranks on both
  94            intracommunicators and intercommunicators */
  95 
  96         else if (MPI_OP_NULL == op || NULL == op) {
  97           err = MPI_ERR_OP;
  98         } else if (!ompi_op_is_valid(op, datatype, &msg, FUNC_NAME)) {
  99             int ret = OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, msg);
 100             free(msg);
 101             return ret;
 102         } else if (NULL == recvcounts) {
 103           err = MPI_ERR_COUNT;
 104         } else if (MPI_IN_PLACE == recvbuf) {
 105           err = MPI_ERR_ARG;
 106         }
 107         OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 108 
 109         /* Based on the standard each group has to provide the same total
 110            number of elements, so the size of the recvcounts array depends
 111            on the number of participants in the local group.  */
 112         size = ompi_comm_size(comm);
 113         for (i = 0; i < size; ++i) {
 114           OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, recvcounts[i]);
 115           OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 116         }
 117     }
 118 
 119     /* MPI standard says that reductions have to have a count of at least 1,
 120      * but some benchmarks (e.g., IMB) calls this function with a count of 0.
 121      * So handle that case.
 122      */
 123     size = ompi_comm_size(comm);
 124     for (count = i = 0; i < size; ++i) {
 125         if (0 == recvcounts[i]) {
 126             ++count;
 127         }
 128     }
 129     if (size == count) {
 130         err = ompi_request_persistent_noop_create(request);
 131         OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 132     }
 133 
 134     OPAL_CR_ENTER_LIBRARY();
 135 
 136     /* Invoke the coll component to perform the back-end operation */
 137 
 138     OBJ_RETAIN(op);
 139     err = comm->c_coll->coll_reduce_scatter_init(sendbuf, recvbuf, recvcounts,
 140                                                  datatype, op, comm, info, request,
 141                                                  comm->c_coll->coll_reduce_scatter_init_module);
 142     OBJ_RELEASE(op);
 143     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 144 }

/* [<][>][^][v][top][bottom][index][help] */