root/ompi/mpiext/pcollreq/c/gather_init.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPIX_Gather_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-2007 Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2008      University of Houston.  All rights reserved.
  15  * Copyright (c) 2008      Sun Microsystems, Inc.  All rights reserved.
  16  * Copyright (c) 2013      Los Alamos National Security, LLC.  All rights
  17  *                         reserved.
  18  * Copyright (c) 2015-2018 Research Organization for Information Science
  19  *                         and Technology (RIST). 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/memchecker.h"
  35 #include "ompi/mpiext/pcollreq/c/mpiext_pcollreq_c.h"
  36 #include "ompi/runtime/ompi_spc.h"
  37 
  38 #if OMPI_BUILD_MPI_PROFILING
  39 #if OPAL_HAVE_WEAK_SYMBOLS
  40 #pragma weak MPIX_Gather_init = PMPIX_Gather_init
  41 #endif
  42 #define MPIX_Gather_init PMPIX_Gather_init
  43 #endif
  44 
  45 static const char FUNC_NAME[] = "MPIX_Gather_init";
  46 
  47 
  48 int MPIX_Gather_init(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  49                      void *recvbuf, int recvcount, MPI_Datatype recvtype,
  50                      int root, MPI_Comm comm, MPI_Info info, MPI_Request *request)
  51 {
  52     int err;
  53 
  54     SPC_RECORD(OMPI_SPC_GATHER_INIT, 1);
  55 
  56     MEMCHECKER(
  57         int rank;
  58         ptrdiff_t ext;
  59 
  60         rank = ompi_comm_rank(comm);
  61         ompi_datatype_type_extent(recvtype, &ext);
  62 
  63         memchecker_comm(comm);
  64         if(OMPI_COMM_IS_INTRA(comm)) {
  65             if(ompi_comm_rank(comm) == root) {
  66                 /* check whether root's send buffer is defined. */
  67                 if (MPI_IN_PLACE == sendbuf) {
  68                   memchecker_call(&opal_memchecker_base_isdefined,
  69                                   (char *)(recvbuf)+rank*ext,
  70                                   recvcount, recvtype);
  71                 } else {
  72                     memchecker_datatype(sendtype);
  73                     memchecker_call(&opal_memchecker_base_isdefined, sendbuf, sendcount, sendtype);
  74                 }
  75 
  76                 memchecker_datatype(recvtype);
  77                 /* check whether root's receive buffer is addressable. */
  78                 memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, recvcount, recvtype);
  79             } else {
  80                 memchecker_datatype(sendtype);
  81                 /* check whether send buffer is defined on other processes. */
  82                 memchecker_call(&opal_memchecker_base_isdefined, sendbuf, sendcount, sendtype);
  83             }
  84         } else {
  85             if (MPI_ROOT == root) {
  86                 memchecker_datatype(recvtype);
  87                 /* check whether root's receive buffer is addressable. */
  88                 memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, recvcount, recvtype);
  89             } else if (MPI_PROC_NULL != root) {
  90                 memchecker_datatype(sendtype);
  91                 /* check whether send buffer is defined. */
  92                 memchecker_call(&opal_memchecker_base_isdefined, sendbuf, sendcount, sendtype);
  93             }
  94         }
  95     );
  96 
  97     if (MPI_PARAM_CHECK) {
  98         err = MPI_SUCCESS;
  99         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
 100         if (ompi_comm_invalid(comm)) {
 101             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
 102                                           FUNC_NAME);
 103         } else if ((ompi_comm_rank(comm) != root && MPI_IN_PLACE == sendbuf) ||
 104                    (ompi_comm_rank(comm) == root && MPI_IN_PLACE == recvbuf)) {
 105             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 106         }
 107 
 108         /* Errors for intracommunicators */
 109 
 110         if (OMPI_COMM_IS_INTRA(comm)) {
 111 
 112             /* Errors for all ranks */
 113 
 114             if ((root >= ompi_comm_size(comm)) || (root < 0)) {
 115                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME);
 116             }
 117 
 118             if (MPI_IN_PLACE != sendbuf) {
 119                 OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
 120             }
 121             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 122 
 123             /* Errors for the root.  Some of these could have been
 124                combined into compound if statements above, but since
 125                this whole section can be compiled out (or turned off at
 126                run time) for efficiency, it's more clear to separate
 127                them out into individual tests. */
 128 
 129             if (ompi_comm_rank(comm) == root) {
 130                 if (MPI_DATATYPE_NULL == recvtype || NULL == recvtype) {
 131                     return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME);
 132                 }
 133 
 134                 if (recvcount < 0) {
 135                     return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
 136                 }
 137             }
 138         }
 139 
 140         /* Errors for intercommunicators */
 141 
 142         else {
 143             if (! ((root >= 0 && root < ompi_comm_remote_size(comm)) ||
 144                    MPI_ROOT == root || MPI_PROC_NULL == root)) {
 145                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME);
 146             }
 147 
 148             /* Errors for the senders */
 149 
 150             if (MPI_ROOT != root && MPI_PROC_NULL != root) {
 151                 OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
 152                 OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 153             }
 154 
 155             /* Errors for the root.  Ditto on the comment above -- these
 156                error checks could have been combined above, but let's
 157                make the code easier to read. */
 158 
 159             else if (MPI_ROOT == root) {
 160                 if (recvcount < 0) {
 161                     return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
 162                 }
 163 
 164                 if (MPI_DATATYPE_NULL == recvtype || NULL == recvtype) {
 165                     return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME);
 166                 }
 167             }
 168         }
 169     }
 170 
 171     OPAL_CR_ENTER_LIBRARY();
 172 
 173     /* Invoke the coll component to perform the back-end operation */
 174     err = comm->c_coll->coll_gather_init(sendbuf, sendcount, sendtype, recvbuf,
 175                                          recvcount, recvtype, root, comm, info, request,
 176                                          comm->c_coll->coll_gather_init_module);
 177     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 178 }

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