root/ompi/mpi/c/neighbor_alltoallv.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Neighbor_alltoallv

   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) 2007      Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2012-2017 Los Alamos National Security, LLC.  All rights
  15  *                         reserved.
  16  * Copyright (c) 2014-2015 Research Organization for Information Science
  17  *                         and Technology (RIST). All rights reserved.
  18  * Copyright (c) 2017      IBM Corporation.  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/mca/topo/topo.h"
  36 #include "ompi/mca/topo/base/base.h"
  37 #include "ompi/runtime/ompi_spc.h"
  38 
  39 #if OMPI_BUILD_MPI_PROFILING
  40 #if OPAL_HAVE_WEAK_SYMBOLS
  41 #pragma weak MPI_Neighbor_alltoallv = PMPI_Neighbor_alltoallv
  42 #endif
  43 #define MPI_Neighbor_alltoallv PMPI_Neighbor_alltoallv
  44 #endif
  45 
  46 static const char FUNC_NAME[] = "MPI_Neighbor_alltoallv";
  47 
  48 
  49 int MPI_Neighbor_alltoallv(const void *sendbuf, const int sendcounts[], const int sdispls[],
  50                            MPI_Datatype sendtype, void *recvbuf,
  51                            const int recvcounts[], const int rdispls[],
  52                            MPI_Datatype recvtype, MPI_Comm comm)
  53 {
  54     int i, err;
  55     int indegree, outdegree;
  56 
  57     SPC_RECORD(OMPI_SPC_NEIGHBOR_ALLTOALLV, 1);
  58 
  59     MEMCHECKER(
  60         ptrdiff_t recv_ext;
  61         ptrdiff_t send_ext;
  62 
  63         memchecker_comm(comm);
  64 
  65         if (MPI_IN_PLACE != sendbuf) {
  66             memchecker_datatype(sendtype);
  67             ompi_datatype_type_extent(recvtype, &recv_ext);
  68         }
  69 
  70         memchecker_datatype(recvtype);
  71         ompi_datatype_type_extent(sendtype, &send_ext);
  72 
  73         err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
  74         if (MPI_SUCCESS == err) {
  75             if (MPI_IN_PLACE != sendbuf) {
  76                 for ( i = 0; i < outdegree; i++ ) {
  77                     /* check if send chunks are defined. */
  78                     memchecker_call(&opal_memchecker_base_isdefined,
  79                                     (char *)(sendbuf)+sdispls[i]*send_ext,
  80                                     sendcounts[i], sendtype);
  81                 }
  82             }
  83             for ( i = 0; i < indegree; i++ ) {
  84                 /* check if receive chunks are addressable. */
  85                 memchecker_call(&opal_memchecker_base_isaddressable,
  86                                 (char *)(recvbuf)+rdispls[i]*recv_ext,
  87                                 recvcounts[i], recvtype);
  88             }
  89         }
  90     );
  91 
  92     if (MPI_PARAM_CHECK) {
  93 
  94         /* Unrooted operation -- same checks for all ranks */
  95 
  96         err = MPI_SUCCESS;
  97         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  98         if (ompi_comm_invalid(comm) || OMPI_COMM_IS_INTER(comm)) {
  99             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
 100                                           FUNC_NAME);
 101         } else if (! OMPI_COMM_IS_TOPO(comm)) {
 102             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
 103                                           FUNC_NAME);
 104         } else if ((NULL == sendcounts) || (NULL == sdispls) ||
 105             (NULL == recvcounts) || (NULL == rdispls) ||
 106             MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
 107             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 108         }
 109 
 110         err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
 111         OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 112         for (i = 0; i < outdegree; ++i) {
 113             OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]);
 114             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 115         }
 116         for (i = 0; i < indegree; ++i) {
 117             OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtype, recvcounts[i]);
 118             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 119         }
 120 
 121         if( OMPI_COMM_IS_CART(comm) ) {
 122             const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
 123             if( 0 > cart->ndims ) {
 124                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 125             }
 126         }
 127         else if( OMPI_COMM_IS_GRAPH(comm) ) {
 128             int degree;
 129             mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
 130             if( 0 > degree ) {
 131                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 132             }
 133         }
 134         else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
 135             const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
 136             indegree  = dist_graph->indegree;
 137             outdegree = dist_graph->outdegree;
 138             if( indegree <  0 || outdegree <  0 ) {
 139                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 140             }
 141         }
 142     }
 143 
 144     OPAL_CR_ENTER_LIBRARY();
 145 
 146     /* Invoke the coll component to perform the back-end operation */
 147     err = comm->c_coll->coll_neighbor_alltoallv(sendbuf, sendcounts, sdispls, sendtype,
 148                                                recvbuf, recvcounts, rdispls, recvtype,
 149                                                comm, comm->c_coll->coll_neighbor_alltoallv_module);
 150     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 151 }
 152 

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