root/ompi/mpiext/pcollreq/c/neighbor_alltoallv_init.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPIX_Neighbor_alltoallv_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-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) 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-2018 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 #include "ompi/mpiext/pcollreq/c/mpiext_pcollreq_c.h"
  39 
  40 #if OMPI_BUILD_MPI_PROFILING
  41 #if OPAL_HAVE_WEAK_SYMBOLS
  42 #pragma weak MPIX_Neighbor_alltoallv_init = PMPIX_Neighbor_alltoallv_init
  43 #endif
  44 #define MPIX_Neighbor_alltoallv_init PMPIX_Neighbor_alltoallv_init
  45 #endif
  46 
  47 static const char FUNC_NAME[] = "MPIX_Neighbor_alltoallv_init";
  48 
  49 
  50 int MPIX_Neighbor_alltoallv_init(const void *sendbuf, const int sendcounts[], const int sdispls[],
  51                                  MPI_Datatype sendtype, void *recvbuf, const int recvcounts[],
  52                                  const int rdispls[], MPI_Datatype recvtype, MPI_Comm comm,
  53                                  MPI_Info info, MPI_Request *request)
  54 {
  55     int i, err;
  56     int indegree, outdegree;
  57 
  58     SPC_RECORD(OMPI_SPC_NEIGHBOR_ALLTOALLV_INIT, 1);
  59 
  60     MEMCHECKER(
  61         ptrdiff_t recv_ext;
  62         ptrdiff_t send_ext;
  63 
  64         memchecker_comm(comm);
  65 
  66         if (MPI_IN_PLACE != sendbuf) {
  67             memchecker_datatype(sendtype);
  68             ompi_datatype_type_extent(recvtype, &recv_ext);
  69         }
  70 
  71         memchecker_datatype(recvtype);
  72         ompi_datatype_type_extent(sendtype, &send_ext);
  73 
  74         err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
  75         if (MPI_SUCCESS == err) {
  76             if (MPI_IN_PLACE != sendbuf) {
  77                 for ( i = 0; i < outdegree; i++ ) {
  78                     /* check if send chunks are defined. */
  79                     memchecker_call(&opal_memchecker_base_isdefined,
  80                                     (char *)(sendbuf)+sdispls[i]*send_ext,
  81                                     sendcounts[i], sendtype);
  82                 }
  83             }
  84             for ( i = 0; i < indegree; i++ ) {
  85                 /* check if receive chunks are addressable. */
  86                 memchecker_call(&opal_memchecker_base_isaddressable,
  87                                 (char *)(recvbuf)+rdispls[i]*recv_ext,
  88                                 recvcounts[i], recvtype);
  89             }
  90         }
  91     );
  92 
  93     if (MPI_PARAM_CHECK) {
  94 
  95         /* Unrooted operation -- same checks for all ranks */
  96 
  97         err = MPI_SUCCESS;
  98         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  99         if (ompi_comm_invalid(comm) || OMPI_COMM_IS_INTER(comm)) {
 100             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
 101                                           FUNC_NAME);
 102         } else if (! OMPI_COMM_IS_TOPO(comm)) {
 103             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TOPOLOGY,
 104                                           FUNC_NAME);
 105         } else if ((NULL == sendcounts) || (NULL == sdispls) ||
 106             (NULL == recvcounts) || (NULL == rdispls) ||
 107             MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
 108             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 109         }
 110 
 111         err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
 112         OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 113         for (i = 0; i < outdegree; ++i) {
 114             OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]);
 115             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 116         }
 117         for (i = 0; i < indegree; ++i) {
 118             OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtype, recvcounts[i]);
 119             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 120         }
 121 
 122         if( OMPI_COMM_IS_CART(comm) ) {
 123             const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
 124             if( 0 > cart->ndims ) {
 125                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 126             }
 127         }
 128         else if( OMPI_COMM_IS_GRAPH(comm) ) {
 129             int degree;
 130             mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
 131             if( 0 > degree ) {
 132                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 133             }
 134         }
 135         else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
 136             const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
 137             indegree  = dist_graph->indegree;
 138             outdegree = dist_graph->outdegree;
 139             if( indegree <  0 || outdegree <  0 ) {
 140                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 141             }
 142         }
 143     }
 144 
 145     OPAL_CR_ENTER_LIBRARY();
 146 
 147     /* Invoke the coll component to perform the back-end operation */
 148     err = comm->c_coll->coll_neighbor_alltoallv_init(sendbuf, sendcounts, sdispls,
 149                                                      sendtype, recvbuf, recvcounts, rdispls,
 150                                                      recvtype, comm, info, request,
 151                                                      comm->c_coll->coll_neighbor_alltoallv_init_module);
 152     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 153 }
 154 

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