root/ompi/mpi/c/ineighbor_allgatherv.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Ineighbor_allgatherv

   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-2017 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 (c) 2017      IBM Corporation.  All rights reserved.
  20  * $COPYRIGHT$
  21  *
  22  * Additional copyrights may follow
  23  *
  24  * $HEADER$
  25  */
  26 
  27 #include "ompi_config.h"
  28 #include <stdio.h>
  29 
  30 #include "ompi/mpi/c/bindings.h"
  31 #include "ompi/runtime/params.h"
  32 #include "ompi/communicator/communicator.h"
  33 #include "ompi/errhandler/errhandler.h"
  34 #include "ompi/datatype/ompi_datatype.h"
  35 #include "ompi/memchecker.h"
  36 #include "ompi/mca/topo/topo.h"
  37 #include "ompi/mca/topo/base/base.h"
  38 #include "ompi/runtime/ompi_spc.h"
  39 
  40 #if OMPI_BUILD_MPI_PROFILING
  41 #if OPAL_HAVE_WEAK_SYMBOLS
  42 #pragma weak MPI_Ineighbor_allgatherv = PMPI_Ineighbor_allgatherv
  43 #endif
  44 #define MPI_Ineighbor_allgatherv PMPI_Ineighbor_allgatherv
  45 #endif
  46 
  47 static const char FUNC_NAME[] = "MPI_Ineighbor_allgatherv";
  48 
  49 
  50 int MPI_Ineighbor_allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  51                              void *recvbuf, const int recvcounts[], const int displs[],
  52                              MPI_Datatype recvtype, MPI_Comm comm, MPI_Request *request)
  53 {
  54     int i, size, err;
  55 
  56     SPC_RECORD(OMPI_SPC_INEIGHBOR_ALLGATHERV, 1);
  57 
  58     MEMCHECKER(
  59         int rank;
  60         ptrdiff_t ext;
  61 
  62         rank = ompi_comm_rank(comm);
  63         size = ompi_comm_size(comm);
  64         ompi_datatype_type_extent(recvtype, &ext);
  65 
  66         memchecker_datatype(recvtype);
  67         memchecker_comm (comm);
  68         /* check whether the receive buffer is addressable. */
  69         for (i = 0; i < size; i++) {
  70             memchecker_call(&opal_memchecker_base_isaddressable,
  71                             (char *)(recvbuf)+displs[i]*ext,
  72                             recvcounts[i], recvtype);
  73         }
  74 
  75         /* check whether the actual send buffer is defined. */
  76         if (MPI_IN_PLACE != sendbuf) {
  77             memchecker_datatype(sendtype);
  78             memchecker_call(&opal_memchecker_base_isdefined, sendbuf, sendcount, sendtype);
  79         }
  80     );
  81 
  82     if (MPI_PARAM_CHECK) {
  83 
  84         /* Unrooted operation -- same checks for all ranks on both
  85            intracommunicators and intercommunicators */
  86 
  87         err = MPI_SUCCESS;
  88         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  89         if (ompi_comm_invalid(comm) || OMPI_COMM_IS_INTER(comm)) {
  90             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  91                                           FUNC_NAME);
  92         } else if (! OMPI_COMM_IS_TOPO(comm)) {
  93             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TOPOLOGY,
  94                                           FUNC_NAME);
  95         } else if (MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
  96             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
  97         } else if (MPI_DATATYPE_NULL == recvtype) {
  98             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME);
  99         }
 100 
 101         OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
 102         OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 103 
 104       /* We always define the remote group to be the same as the local
 105          group in the case of an intracommunicator, so it's safe to
 106          get the size of the remote group here for both intra- and
 107          intercommunicators */
 108 
 109         size = ompi_comm_remote_size(comm);
 110         for (i = 0; i < size; ++i) {
 111           if (recvcounts[i] < 0) {
 112             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
 113           }
 114         }
 115 
 116         if (NULL == displs) {
 117           return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_BUFFER, FUNC_NAME);
 118         }
 119 
 120         if( OMPI_COMM_IS_CART(comm) ) {
 121             const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
 122             if( 0 > cart->ndims ) {
 123                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 124             }
 125         }
 126         else if( OMPI_COMM_IS_GRAPH(comm) ) {
 127             int degree;
 128             mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
 129             if( 0 > degree ) {
 130                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 131             }
 132         }
 133         else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
 134             const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
 135             int indegree  = dist_graph->indegree;
 136             int outdegree = dist_graph->outdegree;
 137             if( indegree <  0 || outdegree <  0 ) {
 138                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 139             }
 140         }
 141     }
 142 
 143     OPAL_CR_ENTER_LIBRARY();
 144 
 145     /* Invoke the coll component to perform the back-end operation */
 146     err = comm->c_coll->coll_ineighbor_allgatherv(sendbuf, sendcount, sendtype,
 147                                                  recvbuf, (int *) recvcounts, (int *) displs,
 148                                                  recvtype, comm, request,
 149                                                  comm->c_coll->coll_ineighbor_allgatherv_module);
 150     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 151 }
 152 

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