root/ompi/mpi/c/neighbor_alltoallw.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Neighbor_alltoallw

   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_alltoallw = PMPI_Neighbor_alltoallw
  42 #endif
  43 #define MPI_Neighbor_alltoallw PMPI_Neighbor_alltoallw
  44 #endif
  45 
  46 static const char FUNC_NAME[] = "MPI_Neighbor_alltoallw";
  47 
  48 
  49 int MPI_Neighbor_alltoallw(const void *sendbuf, const int sendcounts[], const MPI_Aint sdispls[],
  50                            const MPI_Datatype sendtypes[], void *recvbuf,
  51                            const int recvcounts[], const MPI_Aint rdispls[],
  52                            const MPI_Datatype recvtypes[], MPI_Comm comm)
  53 {
  54     int i, err;
  55     int indegree, outdegree;
  56 
  57     SPC_RECORD(OMPI_SPC_NEIGHBOR_ALLTOALLW, 1);
  58 
  59     MEMCHECKER(
  60         ptrdiff_t recv_ext;
  61         ptrdiff_t send_ext;
  62 
  63         memchecker_comm(comm);
  64 
  65         err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
  66         if (MPI_SUCCESS == err) {
  67             if (MPI_IN_PLACE != sendbuf) {
  68                 for ( i = 0; i < outdegree; i++ ) {
  69                     memchecker_datatype(sendtypes[i]);
  70 
  71                     ompi_datatype_type_extent(sendtypes[i], &send_ext);
  72 
  73                     memchecker_call(&opal_memchecker_base_isdefined,
  74                                     (char *)(sendbuf)+sdispls[i]*send_ext,
  75                                     sendcounts[i], sendtypes[i]);
  76                 }
  77             }
  78             for ( i = 0; i < indegree; i++ ) {
  79                 memchecker_datatype(recvtypes[i]);
  80                 ompi_datatype_type_extent(recvtypes[i], &recv_ext);
  81                 memchecker_call(&opal_memchecker_base_isaddressable,
  82                                 (char *)(recvbuf)+sdispls[i]*recv_ext,
  83                                 recvcounts[i], recvtypes[i]);
  84             }
  85         }
  86     );
  87 
  88     if (MPI_PARAM_CHECK) {
  89 
  90         /* Unrooted operation -- same checks for all ranks */
  91 
  92         err = MPI_SUCCESS;
  93         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  94         if (ompi_comm_invalid(comm) || OMPI_COMM_IS_INTER(comm)) {
  95             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  96                                           FUNC_NAME);
  97         } else if (! OMPI_COMM_IS_TOPO(comm)) {
  98             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TOPOLOGY,
  99                                           FUNC_NAME);
 100         } else if ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes) ||
 101             (NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes) ||
 102              MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
 103             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 104         }
 105 
 106         err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
 107         OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 108         for (i = 0; i < outdegree; ++i) {
 109             OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtypes[i], sendcounts[i]);
 110             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 111         }
 112         for (i = 0; i < indegree; ++i) {
 113             OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtypes[i], recvcounts[i]);
 114             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 115         }
 116 
 117         if( OMPI_COMM_IS_CART(comm) ) {
 118             const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
 119             if( 0 > cart->ndims ) {
 120                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 121             }
 122         }
 123         else if( OMPI_COMM_IS_GRAPH(comm) ) {
 124             int degree;
 125             mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
 126             if( 0 > degree ) {
 127                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 128             }
 129         }
 130         else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
 131             const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
 132             indegree  = dist_graph->indegree;
 133             outdegree = dist_graph->outdegree;
 134             if( indegree <  0 || outdegree <  0 ) {
 135                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 136             }
 137         }
 138     }
 139 
 140     OPAL_CR_ENTER_LIBRARY();
 141 
 142     /* Invoke the coll component to perform the back-end operation */
 143     err = comm->c_coll->coll_neighbor_alltoallw(sendbuf, sendcounts, sdispls, sendtypes,
 144                                                recvbuf, recvcounts, rdispls, recvtypes,
 145                                                comm, comm->c_coll->coll_neighbor_alltoallw_module);
 146     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 147 }
 148 

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