root/ompi/mpiext/pcollreq/c/allreduce_init.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPIX_Allreduce_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) 2013      Los Alamos National Security, LLC.  All rights
  14  *                         reserved.
  15  * Copyright (c) 2015-2018 Research Organization for Information Science
  16  *                         and Technology (RIST). All rights reserved.
  17  * Copyright (c) 2016      IBM Corporation.  All rights reserved.
  18  * Copyright (c) 2018      FUJITSU LIMITED.  All rights reserved.
  19  * $COPYRIGHT$
  20  *
  21  * Additional copyrights may follow
  22  *
  23  * $HEADER$
  24  */
  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_Allreduce_init = PMPIX_Allreduce_init
  42 #endif
  43 #define MPIX_Allreduce_init PMPIX_Allreduce_init
  44 #endif
  45 
  46 static const char FUNC_NAME[] = "MPIX_Allreduce_init";
  47 
  48 
  49 int MPIX_Allreduce_init(const void *sendbuf, void *recvbuf, int count,
  50                         MPI_Datatype datatype, MPI_Op op, MPI_Comm comm,
  51                         MPI_Info info, MPI_Request *request)
  52 {
  53     int err;
  54 
  55     SPC_RECORD(OMPI_SPC_ALLREDUCE_INIT, 1);
  56 
  57     MEMCHECKER(
  58         memchecker_datatype(datatype);
  59         memchecker_comm(comm);
  60 
  61         /* check whether receive buffer is defined. */
  62         memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, count, datatype);
  63 
  64         /* check whether the actual send buffer is defined. */
  65         if (MPI_IN_PLACE == sendbuf) {
  66             memchecker_call(&opal_memchecker_base_isdefined, recvbuf, count, datatype);
  67         } else {
  68             memchecker_call(&opal_memchecker_base_isdefined, sendbuf, count, datatype);
  69         }
  70     );
  71 
  72     if (MPI_PARAM_CHECK) {
  73         char *msg;
  74 
  75         /* Unrooted operation -- same checks for all ranks on both
  76            intracommunicators and intercommunicators */
  77 
  78         err = MPI_SUCCESS;
  79         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  80         if (ompi_comm_invalid(comm)) {
  81             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  82                                           FUNC_NAME);
  83         } else if (MPI_OP_NULL == op) {
  84             err = MPI_ERR_OP;
  85         } else if (!ompi_op_is_valid(op, datatype, &msg, FUNC_NAME)) {
  86             int ret = OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, msg);
  87             free(msg);
  88             return ret;
  89         } else if ((MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
  90                    MPI_IN_PLACE == recvbuf ) {
  91             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_BUFFER,
  92                                           FUNC_NAME);
  93         } else if( (sendbuf == recvbuf) &&
  94                    (MPI_BOTTOM != sendbuf) &&
  95                    (count > 1) ) {
  96             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_BUFFER,
  97                                           FUNC_NAME);
  98         } else {
  99             OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count);
 100         }
 101         OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 102     }
 103 
 104 
 105     /* MPI standard says that reductions have to have a count of at least 1,
 106      * but some benchmarks (e.g., IMB) calls this function with a count of 0.
 107      * So handle that case.
 108      */
 109     if (0 == count) {
 110         err = ompi_request_persistent_noop_create(request);
 111         OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 112     }
 113 
 114     OPAL_CR_ENTER_LIBRARY();
 115 
 116     /* Invoke the coll component to perform the back-end operation */
 117 
 118     OBJ_RETAIN(op);
 119     err = comm->c_coll->coll_allreduce_init(sendbuf, recvbuf, count, datatype,
 120                                             op, comm, info, request, comm->c_coll->coll_allreduce_init_module);
 121     OBJ_RELEASE(op);
 122     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 123 }

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