root/ompi/mpiext/pcollreq/c/scatterv_init.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPIX_Scatterv_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$
  19  *
  20  * Additional copyrights may follow
  21  *
  22  * $HEADER$
  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/memchecker.h"
  33 #include "ompi/mpiext/pcollreq/c/mpiext_pcollreq_c.h"
  34 #include "ompi/runtime/ompi_spc.h"
  35 
  36 #if OMPI_BUILD_MPI_PROFILING
  37 #if OPAL_HAVE_WEAK_SYMBOLS
  38 #pragma weak MPIX_Scatterv_init = PMPIX_Scatterv_init
  39 #endif
  40 #define MPIX_Scatterv_init PMPIX_Scatterv_init
  41 #endif
  42 
  43 static const char FUNC_NAME[] = "MPIX_Scatterv_init";
  44 
  45 
  46 int MPIX_Scatterv_init(const void *sendbuf, const int sendcounts[], const int displs[],
  47                        MPI_Datatype sendtype, void *recvbuf, int recvcount,
  48                        MPI_Datatype recvtype, int root, MPI_Comm comm, MPI_Info info, MPI_Request *request)
  49 {
  50     int i, size, err;
  51 
  52     SPC_RECORD(OMPI_SPC_SCATTERV_INIT, 1);
  53 
  54     MEMCHECKER(
  55         ptrdiff_t ext;
  56 
  57         size = ompi_comm_remote_size(comm);
  58         ompi_datatype_type_extent(recvtype, &ext);
  59 
  60         memchecker_comm(comm);
  61         if(OMPI_COMM_IS_INTRA(comm)) {
  62               if(ompi_comm_rank(comm) == root) {
  63                 memchecker_datatype(sendtype);
  64                 /* check whether root's send buffer is defined. */
  65                 for (i = 0; i < size; i++) {
  66                     memchecker_call(&opal_memchecker_base_isdefined,
  67                                     (char *)(sendbuf)+displs[i]*ext,
  68                                     sendcounts[i], sendtype);
  69                 }
  70                 if(MPI_IN_PLACE != recvbuf) {
  71                     memchecker_datatype(recvtype);
  72                     /* check whether receive buffer is addressable. */
  73                     memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, recvcount, recvtype);
  74                 }
  75               } else {
  76                   memchecker_datatype(recvtype);
  77                   /* check whether receive buffer is addressable. */
  78                   memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, recvcount, recvtype);
  79               }
  80         } else {
  81             if(MPI_ROOT == root) {
  82                   memchecker_datatype(sendtype);
  83                   /* check whether root's send buffer is defined. */
  84                   for (i = 0; i < size; i++) {
  85                       memchecker_call(&opal_memchecker_base_isdefined,
  86                                       (char *)(sendbuf)+displs[i]*ext,
  87                                       sendcounts[i], sendtype);
  88                   }
  89             } else if (MPI_PROC_NULL != root) {
  90                 /* check whether receive buffer is addressable. */
  91                 memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, recvcount, recvtype);
  92             }
  93         }
  94     );
  95 
  96     if (MPI_PARAM_CHECK) {
  97         err = MPI_SUCCESS;
  98         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  99         if (ompi_comm_invalid(comm)) {
 100             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
 101                                           FUNC_NAME);
 102         } else if ((ompi_comm_rank(comm) != root && MPI_IN_PLACE == recvbuf) ||
 103                    (ompi_comm_rank(comm) == root && MPI_IN_PLACE == sendbuf)) {
 104             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 105         }
 106 
 107         /* Errors for intracommunicators */
 108 
 109         if (OMPI_COMM_IS_INTRA(comm)) {
 110 
 111             /* Errors for all ranks */
 112 
 113             if ((root >= ompi_comm_size(comm)) || (root < 0)) {
 114                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME);
 115             }
 116 
 117             if (MPI_IN_PLACE != recvbuf) {
 118                 if (recvcount < 0) {
 119                     return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT,
 120                                                   FUNC_NAME);
 121                 }
 122 
 123                 if (MPI_DATATYPE_NULL == recvtype || NULL == recvtype) {
 124                     return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE,
 125                                                   FUNC_NAME);
 126                 }
 127             }
 128 
 129             /* Errors for the root.  Some of these could have been
 130                combined into compound if statements above, but since
 131                this whole section can be compiled out (or turned off at
 132                run time) for efficiency, it's more clear to separate
 133                them out into individual tests. */
 134 
 135             if (ompi_comm_rank(comm) == root) {
 136                 if (NULL == displs) {
 137                     return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 138                 }
 139 
 140                 if (NULL == sendcounts) {
 141                     return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
 142                 }
 143 
 144                 size = ompi_comm_size(comm);
 145                 for (i = 0; i < size; ++i) {
 146                     OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]);
 147                     OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 148                 }
 149             }
 150         }
 151 
 152         /* Errors for intercommunicators */
 153 
 154         else {
 155             if (! ((root >= 0 && root < ompi_comm_remote_size(comm)) ||
 156                    MPI_ROOT == root || MPI_PROC_NULL == root)) {
 157                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME);
 158             }
 159 
 160           /* Errors for the receivers */
 161 
 162             if (MPI_ROOT != root && MPI_PROC_NULL != root) {
 163                 if (recvcount < 0) {
 164                     return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
 165                 }
 166 
 167                 if (MPI_DATATYPE_NULL == recvtype || NULL == recvtype) {
 168                     return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME);
 169                 }
 170             }
 171 
 172             /* Errors for the root.  Ditto on the comment above -- these
 173                error checks could have been combined above, but let's
 174                make the code easier to read. */
 175 
 176             else if (MPI_ROOT == root) {
 177                 if (NULL == displs) {
 178                     return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 179                 }
 180 
 181                 if (NULL == sendcounts) {
 182                     return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
 183                 }
 184 
 185                 size = ompi_comm_remote_size(comm);
 186                 for (i = 0; i < size; ++i) {
 187                     OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]);
 188                     OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 189                 }
 190             }
 191         }
 192     }
 193 
 194     OPAL_CR_ENTER_LIBRARY();
 195 
 196     /* Invoke the coll component to perform the back-end operation */
 197     err = comm->c_coll->coll_scatterv_init(sendbuf, sendcounts, displs,
 198                                            sendtype, recvbuf, recvcount, recvtype, root, comm,
 199                                            info, request, comm->c_coll->coll_scatterv_init_module);
 200     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 201 }

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