root/ompi/mpi/c/neighbor_alltoall.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Neighbor_alltoall

   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) 2013      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_alltoall = PMPI_Neighbor_alltoall
  42 #endif
  43 #define MPI_Neighbor_alltoall PMPI_Neighbor_alltoall
  44 #endif
  45 
  46 static const char FUNC_NAME[] = "MPI_Neighbor_alltoall";
  47 
  48 
  49 int MPI_Neighbor_alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  50                           void *recvbuf, int recvcount, MPI_Datatype recvtype,
  51                           MPI_Comm comm)
  52 {
  53     size_t sendtype_size, recvtype_size;
  54     int err;
  55 
  56     SPC_RECORD(OMPI_SPC_NEIGHBOR_ALLTOALL, 1);
  57 
  58     MEMCHECKER(
  59         memchecker_comm(comm);
  60         if (MPI_IN_PLACE != sendbuf) {
  61             memchecker_datatype(sendtype);
  62             memchecker_call(&opal_memchecker_base_isdefined, (void *)sendbuf, sendcount, sendtype);
  63         }
  64         memchecker_datatype(recvtype);
  65         memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, recvcount, recvtype);
  66     );
  67 
  68     if (MPI_PARAM_CHECK) {
  69 
  70         /* Unrooted operation -- same checks for all ranks on both
  71            intracommunicators and intercommunicators */
  72 
  73         err = MPI_SUCCESS;
  74         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  75         if (ompi_comm_invalid(comm) || OMPI_COMM_IS_INTER(comm)) {
  76             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  77                                           FUNC_NAME);
  78         } else if (! OMPI_COMM_IS_TOPO(comm)) {
  79             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TOPOLOGY,
  80                                           FUNC_NAME);
  81         } else if (MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
  82             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
  83                                           FUNC_NAME);
  84         } else {
  85             OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
  86             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
  87             OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtype, recvcount);
  88             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
  89         }
  90 
  91         ompi_datatype_type_size(sendtype, &sendtype_size);
  92         ompi_datatype_type_size(recvtype, &recvtype_size);
  93         if ((sendtype_size*sendcount) != (recvtype_size*recvcount)) {
  94             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TRUNCATE, FUNC_NAME);
  95         }
  96 
  97         if( OMPI_COMM_IS_CART(comm) ) {
  98             const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
  99             if( 0 > cart->ndims ) {
 100                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 101             }
 102         }
 103         else if( OMPI_COMM_IS_GRAPH(comm) ) {
 104             int degree;
 105             mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
 106             if( 0 > degree ) {
 107                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 108             }
 109         }
 110         else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
 111             const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
 112             int indegree  = dist_graph->indegree;
 113             int outdegree = dist_graph->outdegree;
 114             if( indegree <  0 || outdegree <  0 ) {
 115                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 116             }
 117         }
 118     }
 119 
 120     /* Do we need to do anything? */
 121 
 122     ompi_datatype_type_size(sendtype, &sendtype_size);
 123     ompi_datatype_type_size(recvtype, &recvtype_size);
 124     if (((0 == sendcount) || (0 == sendtype_size)) &&
 125         ((0 == recvcount) || 0 == (recvtype_size))) {
 126         return MPI_SUCCESS;
 127     }
 128 
 129     OPAL_CR_ENTER_LIBRARY();
 130 
 131     /* Invoke the coll component to perform the back-end operation */
 132     err = comm->c_coll->coll_neighbor_alltoall(sendbuf, sendcount, sendtype, recvbuf,
 133                                               recvcount, recvtype, comm,
 134                                               comm->c_coll->coll_neighbor_alltoall_module);
 135     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 136 }
 137 

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