root/ompi/mpiext/pcollreq/c/reduce_init.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPIX_Reduce_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      Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 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_init = PMPIX_Reduce_init
  42 #endif
  43 #define MPIX_Reduce_init PMPIX_Reduce_init
  44 #endif
  45 
  46 static const char FUNC_NAME[] = "MPIX_Reduce_init";
  47 
  48 
  49 int MPIX_Reduce_init(const void *sendbuf, void *recvbuf, int count,
  50                      MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm,
  51                      MPI_Info info, MPI_Request *request)
  52 {
  53     int err;
  54 
  55     SPC_RECORD(OMPI_SPC_REDUCE_INIT, 1);
  56 
  57     MEMCHECKER(
  58         memchecker_datatype(datatype);
  59         memchecker_comm(comm);
  60 
  61         if(OMPI_COMM_IS_INTRA(comm)) {
  62             if(ompi_comm_rank(comm) == root) {
  63                 /* check whether root's send buffer is defined. */
  64                 if (MPI_IN_PLACE == sendbuf) {
  65                     memchecker_call(&opal_memchecker_base_isdefined, recvbuf, count, datatype);
  66                 } else {
  67                     memchecker_call(&opal_memchecker_base_isdefined, sendbuf, count, datatype);
  68                 }
  69 
  70                 /* check whether root's receive buffer is addressable. */
  71                 memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, count, datatype);
  72             } else {
  73                 /* check whether send buffer is defined on other processes. */
  74                 memchecker_call(&opal_memchecker_base_isdefined, sendbuf, count, datatype);
  75             }
  76         } else {
  77             if (MPI_ROOT == root) {
  78                 /* check whether root's receive buffer is addressable. */
  79                 memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, count, datatype);
  80             } else if (MPI_PROC_NULL != root) {
  81                 /* check whether send buffer is defined. */
  82                 memchecker_call(&opal_memchecker_base_isdefined, sendbuf, count, datatype);
  83             }
  84         }
  85     );
  86 
  87     if (MPI_PARAM_CHECK) {
  88         char *msg;
  89         err = MPI_SUCCESS;
  90         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  91         if (ompi_comm_invalid(comm)) {
  92             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  93                                           FUNC_NAME);
  94         }
  95 
  96         /* Checks for all ranks */
  97 
  98         else if (MPI_OP_NULL == op || NULL == op) {
  99             err = MPI_ERR_OP;
 100         } else if (!ompi_op_is_valid(op, datatype, &msg, FUNC_NAME)) {
 101             int ret = OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, msg);
 102             free(msg);
 103             return ret;
 104         } else if ((ompi_comm_rank(comm) != root && MPI_IN_PLACE == sendbuf) ||
 105                    (ompi_comm_rank(comm) == root && ((MPI_IN_PLACE == recvbuf) || (sendbuf == recvbuf)))) {
 106             err = MPI_ERR_ARG;
 107         } else {
 108             OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count);
 109         }
 110         OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 111 
 112         /* Intercommunicator errors */
 113 
 114         if (!OMPI_COMM_IS_INTRA(comm)) {
 115             if (! ((root >= 0 && root < ompi_comm_remote_size(comm)) ||
 116                    MPI_ROOT == root || MPI_PROC_NULL == root)) {
 117                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME);
 118             }
 119         }
 120 
 121         /* Intracommunicator errors */
 122 
 123         else {
 124             if (root < 0 || root >= ompi_comm_size(comm)) {
 125                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME);
 126             }
 127         }
 128     }
 129 
 130     /* MPI standard says that reductions have to have a count of at least 1,
 131      * but some benchmarks (e.g., IMB) calls this function with a count of 0.
 132      * So handle that case.
 133      */
 134     if (0 == count) {
 135         err = ompi_request_persistent_noop_create(request);
 136         OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 137     }
 138 
 139     OPAL_CR_ENTER_LIBRARY();
 140 
 141     /* Invoke the coll component to perform the back-end operation */
 142     OBJ_RETAIN(op);
 143     err = comm->c_coll->coll_reduce_init(sendbuf, recvbuf, count,
 144                                          datatype, op, root, comm, info, request,
 145                                          comm->c_coll->coll_reduce_init_module);
 146     OBJ_RELEASE(op);
 147     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 148 }

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