root/ompi/mpiext/pcollreq/c/allgatherv_init.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPIX_Allgatherv_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) 2010      University of Houston.  All rights reserved.
  14  * Copyright (c) 2012 Cisco Systems, Inc.  All rights reserved.
  15  * Copyright (c) 2012-2013 Los Alamos National Security, LLC.  All rights
  16  *                         reserved.
  17  * Copyright (c) 2015-2018 Research Organization for Information Science
  18  *                         and Technology (RIST). 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/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_Allgatherv_init = PMPIX_Allgatherv_init
  41 #endif
  42 #define MPIX_Allgatherv_init PMPIX_Allgatherv_init
  43 #endif
  44 
  45 static const char FUNC_NAME[] = "MPIX_Allgatherv_init";
  46 
  47 
  48 int MPIX_Allgatherv_init(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  49                          void *recvbuf, const int recvcounts[], const int displs[],
  50                          MPI_Datatype recvtype, MPI_Comm comm,
  51                          MPI_Info info, MPI_Request *request)
  52 {
  53     int i, size, err;
  54 
  55     SPC_RECORD(OMPI_SPC_ALLGATHERV_INIT, 1);
  56 
  57     MEMCHECKER(
  58         int rank;
  59         ptrdiff_t ext;
  60 
  61         rank = ompi_comm_rank(comm);
  62         size = ompi_comm_size(comm);
  63         ompi_datatype_type_extent(recvtype, &ext);
  64 
  65         memchecker_datatype(recvtype);
  66         memchecker_comm (comm);
  67         /* check whether the receive buffer is addressable. */
  68         for (i = 0; i < size; i++) {
  69             memchecker_call(&opal_memchecker_base_isaddressable,
  70                             (char *)(recvbuf)+displs[i]*ext,
  71                             recvcounts[i], recvtype);
  72         }
  73 
  74         /* check whether the actual send buffer is defined. */
  75         if (MPI_IN_PLACE == sendbuf) {
  76             memchecker_call(&opal_memchecker_base_isdefined,
  77                             (char *)(recvbuf)+displs[rank]*ext,
  78                             recvcounts[rank], recvtype);
  79         } else {
  80             memchecker_datatype(sendtype);
  81             memchecker_call(&opal_memchecker_base_isdefined, sendbuf, sendcount, sendtype);
  82         }
  83     );
  84 
  85     if (MPI_PARAM_CHECK) {
  86 
  87         /* Unrooted operation -- same checks for all ranks on both
  88            intracommunicators and intercommunicators */
  89 
  90         err = MPI_SUCCESS;
  91         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  92         if (ompi_comm_invalid(comm)) {
  93             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  94                                           FUNC_NAME);
  95         } else if ((MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
  96                    MPI_IN_PLACE == recvbuf) {
  97             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
  98         } else if (MPI_DATATYPE_NULL == recvtype) {
  99             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME);
 100         }
 101 
 102         if (MPI_IN_PLACE != sendbuf) {
 103             OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
 104         }
 105         OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 106 
 107       /* We always define the remote group to be the same as the local
 108          group in the case of an intracommunicator, so it's safe to
 109          get the size of the remote group here for both intra- and
 110          intercommunicators */
 111 
 112         size = ompi_comm_remote_size(comm);
 113         for (i = 0; i < size; ++i) {
 114           if (recvcounts[i] < 0) {
 115             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
 116           }
 117         }
 118 
 119         if (NULL == displs) {
 120           return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_BUFFER, FUNC_NAME);
 121         }
 122     }
 123 
 124     OPAL_CR_ENTER_LIBRARY();
 125 
 126     /* Invoke the coll component to perform the back-end operation */
 127     err = comm->c_coll->coll_allgatherv_init(sendbuf, sendcount, sendtype,
 128                                              recvbuf, recvcounts, displs,
 129                                              recvtype, comm, info, request,
 130                                              comm->c_coll->coll_allgatherv_init_module);
 131     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 132 }
 133 

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