root/ompi/mpiext/pcollreq/c/neighbor_alltoall_init.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPIX_Neighbor_alltoall_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      Oak Ridge National Laboratory. All rights reserved.
  15  * Copyright (c) 2013      Los Alamos National Security, LLC. All rights
  16  *                         reserved.
  17  * Copyright (c) 2014-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_alltoall_init = PMPIX_Neighbor_alltoall_init
  44 #endif
  45 #define MPIX_Neighbor_alltoall_init PMPIX_Neighbor_alltoall_init
  46 #endif
  47 
  48 static const char FUNC_NAME[] = "MPIX_Neighbor_alltoall_init";
  49 
  50 
  51 int MPIX_Neighbor_alltoall_init(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  52                                 void *recvbuf, int recvcount, MPI_Datatype recvtype,
  53                                 MPI_Comm comm, MPI_Info info, MPI_Request *request)
  54 {
  55     size_t sendtype_size, recvtype_size;
  56     int err;
  57 
  58     SPC_RECORD(OMPI_SPC_NEIGHBOR_ALLTOALL_INIT, 1);
  59 
  60     MEMCHECKER(
  61         memchecker_comm(comm);
  62         if (MPI_IN_PLACE != sendbuf) {
  63             memchecker_datatype(sendtype);
  64             memchecker_call(&opal_memchecker_base_isdefined, (void *)sendbuf, sendcount, sendtype);
  65         }
  66         memchecker_datatype(recvtype);
  67         memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, recvcount, recvtype);
  68     );
  69 
  70     if (MPI_PARAM_CHECK) {
  71 
  72         /* Unrooted operation -- same checks for all ranks on both
  73            intracommunicators and intercommunicators */
  74 
  75         err = MPI_SUCCESS;
  76         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  77         if (ompi_comm_invalid(comm) || OMPI_COMM_IS_INTER(comm)) {
  78             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  79                                           FUNC_NAME);
  80         } else if (! OMPI_COMM_IS_TOPO(comm)) {
  81             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TOPOLOGY,
  82                                           FUNC_NAME);
  83         } else if (MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
  84             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
  85                                           FUNC_NAME);
  86         } else {
  87             OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
  88             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
  89             OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtype, recvcount);
  90             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
  91         }
  92 
  93         ompi_datatype_type_size(sendtype, &sendtype_size);
  94         ompi_datatype_type_size(recvtype, &recvtype_size);
  95         if ((sendtype_size*sendcount) != (recvtype_size*recvcount)) {
  96             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TRUNCATE, FUNC_NAME);
  97         }
  98 
  99         if( OMPI_COMM_IS_CART(comm) ) {
 100             const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
 101             if( 0 > cart->ndims ) {
 102                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 103             }
 104         }
 105         else if( OMPI_COMM_IS_GRAPH(comm) ) {
 106             int degree;
 107             mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
 108             if( 0 > degree ) {
 109                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 110             }
 111         }
 112         else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
 113             const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
 114             int indegree  = dist_graph->indegree;
 115             int outdegree = dist_graph->outdegree;
 116             if( indegree <  0 || outdegree <  0 ) {
 117                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 118             }
 119         }
 120     }
 121 
 122     OPAL_CR_ENTER_LIBRARY();
 123 
 124     /* Invoke the coll component to perform the back-end operation */
 125     err = comm->c_coll->coll_neighbor_alltoall_init(sendbuf, sendcount, sendtype,
 126                                                     recvbuf, recvcount, recvtype, comm,
 127                                                     info, request,
 128                                                     comm->c_coll->coll_neighbor_alltoall_init_module);
 129     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 130 }

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