root/ompi/mpiext/pcollreq/c/neighbor_alltoallw_init.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPIX_Neighbor_alltoallw_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_alltoallw_init = PMPIX_Neighbor_alltoallw_init
  43 #endif
  44 #define MPIX_Neighbor_alltoallw_init PMPIX_Neighbor_alltoallw_init
  45 #endif
  46 
  47 static const char FUNC_NAME[] = "MPIX_Neighbor_alltoallw_init";
  48 
  49 
  50 int MPIX_Neighbor_alltoallw_init(const void *sendbuf, const int sendcounts[], const MPI_Aint sdispls[],
  51                                  const MPI_Datatype sendtypes[], void *recvbuf, const int recvcounts[],
  52                                  const MPI_Aint rdispls[], const MPI_Datatype recvtypes[], 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_ALLTOALLW_INIT, 1);
  59 
  60     MEMCHECKER(
  61         ptrdiff_t recv_ext;
  62         ptrdiff_t send_ext;
  63 
  64         memchecker_comm(comm);
  65 
  66         err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
  67         if (MPI_SUCCESS == err) {
  68             if (MPI_IN_PLACE != sendbuf) {
  69                 for ( i = 0; i < outdegree; i++ ) {
  70                     memchecker_datatype(sendtypes[i]);
  71 
  72                     ompi_datatype_type_extent(sendtypes[i], &send_ext);
  73 
  74                     memchecker_call(&opal_memchecker_base_isdefined,
  75                                     (char *)(sendbuf)+sdispls[i]*send_ext,
  76                                     sendcounts[i], sendtypes[i]);
  77                 }
  78             }
  79             for ( i = 0; i < indegree; i++ ) {
  80                 memchecker_datatype(recvtypes[i]);
  81 
  82                 ompi_datatype_type_extent(recvtypes[i], &recv_ext);
  83 
  84                 memchecker_call(&opal_memchecker_base_isaddressable,
  85                                 (char *)(recvbuf)+sdispls[i]*recv_ext,
  86                                 recvcounts[i], recvtypes[i]);
  87             }
  88         }
  89     );
  90 
  91     if (MPI_PARAM_CHECK) {
  92 
  93         /* Unrooted operation -- same checks for all ranks */
  94 
  95         err = MPI_SUCCESS;
  96         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  97         if (ompi_comm_invalid(comm) || OMPI_COMM_IS_INTER(comm)) {
  98             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  99                                           FUNC_NAME);
 100         } else if (! OMPI_COMM_IS_TOPO(comm)) {
 101             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TOPOLOGY,
 102                                           FUNC_NAME);
 103         }
 104 
 105         if ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes) ||
 106             (NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes) ||
 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, sendtypes[i], 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, recvtypes[i], 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_alltoallw_init(sendbuf, sendcounts, sdispls, sendtypes,
 149                                                      recvbuf, recvcounts, rdispls, recvtypes, comm,
 150                                                      info, request,
 151                                                      comm->c_coll->coll_neighbor_alltoallw_init_module);
 152     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 153 }
 154 

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