root/ompi/mpi/c/neighbor_allgather.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Neighbor_allgather

   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) 2010      University of Houston.  All rights reserved.
  15  * Copyright (c) 2013      Los Alamos National Security, LLC. All rights
  16  *                         reserved.
  17  * Copyright (c) 2015-2017 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_Neighbor_allgather = PMPI_Neighbor_allgather
  43 #endif
  44 #define MPI_Neighbor_allgather PMPI_Neighbor_allgather
  45 #endif
  46 
  47 static const char FUNC_NAME[] = "MPI_Neighbor_allgather";
  48 
  49 
  50 int MPI_Neighbor_allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  51                            void *recvbuf, int recvcount, MPI_Datatype recvtype,
  52                            MPI_Comm comm)
  53 {
  54     int err;
  55 
  56     SPC_RECORD(OMPI_SPC_NEIGHBOR_ALLGATHER, 1);
  57 
  58     MEMCHECKER(
  59         int rank;
  60         ptrdiff_t ext;
  61 
  62         rank = ompi_comm_rank(comm);
  63         ompi_datatype_type_extent(recvtype, &ext);
  64 
  65         memchecker_datatype(recvtype);
  66         memchecker_comm(comm);
  67         /* check whether the actual send buffer is defined. */
  68         if (MPI_IN_PLACE != sendbuf) {
  69             memchecker_datatype(sendtype);
  70             memchecker_call(&opal_memchecker_base_isdefined, sendbuf, sendcount, sendtype);
  71         }
  72         /* check whether the receive buffer is addressable. */
  73         memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, recvcount, recvtype);
  74     );
  75 
  76     if (MPI_PARAM_CHECK) {
  77 
  78         /* Unrooted operation -- same checks for all ranks on both
  79            intracommunicators and intercommunicators */
  80 
  81         err = MPI_SUCCESS;
  82         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  83         if (ompi_comm_invalid(comm) || OMPI_COMM_IS_INTER(comm)) {
  84           OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
  85         } else if (! OMPI_COMM_IS_TOPO(comm)) {
  86           OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TOPOLOGY, FUNC_NAME);
  87         } else if (MPI_DATATYPE_NULL == recvtype || NULL == recvtype) {
  88           err = MPI_ERR_TYPE;
  89         } else if (recvcount < 0) {
  90           err = MPI_ERR_COUNT;
  91         } else if (MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
  92           return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
  93         } else {
  94             OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
  95         }
  96         OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
  97 
  98         if( OMPI_COMM_IS_CART(comm) ) {
  99             const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
 100             if( 0 > cart->ndims ) {
 101                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 102             }
 103         }
 104         else if( OMPI_COMM_IS_GRAPH(comm) ) {
 105             int degree;
 106             mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
 107             if( 0 > degree ) {
 108                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 109             }
 110         }
 111         else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
 112             const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
 113             int indegree  = dist_graph->indegree;
 114             int outdegree = dist_graph->outdegree;
 115             if( indegree <  0 || outdegree <  0 ) {
 116                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 117             }
 118         }
 119     }
 120 
 121     /* Do we need to do anything?  Everyone had to give the same send
 122        signature, which means that everyone must have given a
 123        sendcount > 0. */
 124     if ((0 == sendcount) || (0 == recvcount)) {
 125         return MPI_SUCCESS;
 126     }
 127 
 128     OPAL_CR_ENTER_LIBRARY();
 129 
 130     /* Invoke the coll component to perform the back-end operation */
 131     err = comm->c_coll->coll_neighbor_allgather(sendbuf, sendcount, sendtype,
 132                                                recvbuf, recvcount, recvtype, comm,
 133                                                comm->c_coll->coll_neighbor_allgather_module);
 134     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 135 }
 136 

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