root/ompi/mpi/c/ialltoallv.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Ialltoallv

   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) 2012-2013 Los Alamos National Security, LLC.  All rights
  15  *                         reserved.
  16  * Copyright (c) 2014-2016 Research Organization for Information Science
  17  *                         and Technology (RIST). All rights reserved.
  18  * $COPYRIGHT$
  19  *
  20  * Additional copyrights may follow
  21  *
  22  * $HEADER$
  23  */
  24 
  25 #include "ompi_config.h"
  26 #include <stdio.h>
  27 
  28 #include "ompi/mpi/c/bindings.h"
  29 #include "ompi/runtime/params.h"
  30 #include "ompi/communicator/communicator.h"
  31 #include "ompi/errhandler/errhandler.h"
  32 #include "ompi/datatype/ompi_datatype.h"
  33 #include "ompi/memchecker.h"
  34 #include "ompi/runtime/ompi_spc.h"
  35 
  36 #if OMPI_BUILD_MPI_PROFILING
  37 #if OPAL_HAVE_WEAK_SYMBOLS
  38 #pragma weak MPI_Ialltoallv = PMPI_Ialltoallv
  39 #endif
  40 #define MPI_Ialltoallv PMPI_Ialltoallv
  41 #endif
  42 
  43 static const char FUNC_NAME[] = "MPI_Ialltoallv";
  44 
  45 
  46 int MPI_Ialltoallv(const void *sendbuf, const int sendcounts[], const int sdispls[],
  47                    MPI_Datatype sendtype, void *recvbuf, const int recvcounts[],
  48                    const int rdispls[], MPI_Datatype recvtype, MPI_Comm comm,
  49                    MPI_Request *request)
  50 {
  51     int i, size, err;
  52 
  53     SPC_RECORD(OMPI_SPC_IALLTOALLV, 1);
  54 
  55     MEMCHECKER(
  56         ptrdiff_t recv_ext;
  57         ptrdiff_t send_ext;
  58 
  59         memchecker_comm(comm);
  60 
  61         if (MPI_IN_PLACE != sendbuf) {
  62             memchecker_datatype(sendtype);
  63             ompi_datatype_type_extent(sendtype, &send_ext);
  64         }
  65 
  66         memchecker_datatype(recvtype);
  67         ompi_datatype_type_extent(recvtype, &recv_ext);
  68 
  69         size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
  70         for ( i = 0; i < size; i++ ) {
  71             if (MPI_IN_PLACE != sendbuf) {
  72                 /* check if send chunks are defined. */
  73                 memchecker_call(&opal_memchecker_base_isdefined,
  74                                 (char *)(sendbuf)+sdispls[i]*send_ext,
  75                                 sendcounts[i], sendtype);
  76             }
  77             /* check if receive chunks are addressable. */
  78             memchecker_call(&opal_memchecker_base_isaddressable,
  79                             (char *)(recvbuf)+rdispls[i]*recv_ext,
  80                             recvcounts[i], recvtype);
  81         }
  82     );
  83 
  84     if (MPI_PARAM_CHECK) {
  85 
  86         /* Unrooted operation -- same checks for all ranks */
  87 
  88         err = MPI_SUCCESS;
  89         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  90         if (ompi_comm_invalid(comm)) {
  91             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  92                                           FUNC_NAME);
  93         }
  94 
  95         if (MPI_IN_PLACE == sendbuf) {
  96             sendcounts = recvcounts;
  97             sdispls = rdispls;
  98             sendtype = recvtype;
  99         }
 100 
 101         if ((NULL == sendcounts) || (NULL == sdispls) ||
 102             (NULL == recvcounts) || (NULL == rdispls) ||
 103             (MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
 104             MPI_IN_PLACE == recvbuf) {
 105             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 106         }
 107 
 108         size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
 109         for (i = 0; i < size; ++i) {
 110             OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]);
 111             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 112             OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtype, recvcounts[i]);
 113             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 114         }
 115 
 116         if (MPI_IN_PLACE != sendbuf && !OMPI_COMM_IS_INTER(comm)) {
 117             int me = ompi_comm_rank(comm);
 118             size_t sendtype_size, recvtype_size;
 119             ompi_datatype_type_size(sendtype, &sendtype_size);
 120             ompi_datatype_type_size(recvtype, &recvtype_size);
 121             if ((sendtype_size*sendcounts[me]) != (recvtype_size*recvcounts[me])) {
 122                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TRUNCATE, FUNC_NAME);
 123             }
 124         }
 125     }
 126 
 127     OPAL_CR_ENTER_LIBRARY();
 128 
 129     /* Invoke the coll component to perform the back-end operation */
 130     err = comm->c_coll->coll_ialltoallv(sendbuf, sendcounts, sdispls,
 131                                        sendtype, recvbuf, recvcounts, rdispls,
 132                                        recvtype, comm, request, comm->c_coll->coll_ialltoallv_module);
 133     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 134 }
 135 

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