root/ompi/mpiext/pcollreq/c/neighbor_allgatherv_init.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPIX_Neighbor_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-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 #include "ompi/mpiext/pcollreq/c/mpiext_pcollreq_c.h"
  40 
  41 #if OMPI_BUILD_MPI_PROFILING
  42 #if OPAL_HAVE_WEAK_SYMBOLS
  43 #pragma weak MPIX_Neighbor_allgatherv_init = PMPIX_Neighbor_allgatherv_init
  44 #endif
  45 #define MPIX_Neighbor_allgatherv_init PMPIX_Neighbor_allgatherv_init
  46 #endif
  47 
  48 static const char FUNC_NAME[] = "MPIX_Neighbor_allgatherv_init";
  49 
  50 
  51 int MPIX_Neighbor_allgatherv_init(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  52                                   void *recvbuf, const int recvcounts[], const int displs[],
  53                                   MPI_Datatype recvtype, MPI_Comm comm,
  54                                   MPI_Info info, MPI_Request *request)
  55 {
  56     int i, size, err;
  57 
  58     SPC_RECORD(OMPI_SPC_NEIGHBOR_ALLGATHERV_INIT, 1);
  59 
  60     MEMCHECKER(
  61         int rank;
  62         ptrdiff_t ext;
  63 
  64         rank = ompi_comm_rank(comm);
  65         size = ompi_comm_size(comm);
  66         ompi_datatype_type_extent(recvtype, &ext);
  67 
  68         memchecker_datatype(recvtype);
  69         memchecker_comm (comm);
  70         /* check whether the receive buffer is addressable. */
  71         for (i = 0; i < size; i++) {
  72             memchecker_call(&opal_memchecker_base_isaddressable,
  73                             (char *)(recvbuf)+displs[i]*ext,
  74                             recvcounts[i], recvtype);
  75         }
  76 
  77         /* check whether the actual send buffer is defined. */
  78         if (MPI_IN_PLACE != sendbuf) {
  79             memchecker_datatype(sendtype);
  80             memchecker_call(&opal_memchecker_base_isdefined, sendbuf, sendcount, sendtype);
  81         }
  82     );
  83 
  84     if (MPI_PARAM_CHECK) {
  85 
  86         /* Unrooted operation -- same checks for all ranks on both
  87            intracommunicators and intercommunicators */
  88 
  89         err = MPI_SUCCESS;
  90         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  91         if (ompi_comm_invalid(comm) || OMPI_COMM_IS_INTER(comm)) {
  92             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  93                                           FUNC_NAME);
  94         } else if (! OMPI_COMM_IS_TOPO(comm)) {
  95             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TOPOLOGY,
  96                                           FUNC_NAME);
  97         } else if (MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
  98             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
  99         } else if (MPI_DATATYPE_NULL == recvtype) {
 100             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME);
 101         }
 102 
 103         OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
 104         OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 105 
 106       /* We always define the remote group to be the same as the local
 107          group in the case of an intracommunicator, so it's safe to
 108          get the size of the remote group here for both intra- and
 109          intercommunicators */
 110 
 111         size = ompi_comm_remote_size(comm);
 112         for (i = 0; i < size; ++i) {
 113           if (recvcounts[i] < 0) {
 114             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
 115           }
 116         }
 117 
 118         if (NULL == displs) {
 119           return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_BUFFER, 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             int indegree  = dist_graph->indegree;
 138             int 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_allgatherv_init(sendbuf, sendcount, sendtype,
 149                                                       recvbuf, (int *) recvcounts, (int *) displs,
 150                                                       recvtype, comm, info, request,
 151                                                       comm->c_coll->coll_neighbor_allgatherv_init_module);
 152     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 153 }
 154 

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