root/ompi/mpiext/pcollreq/c/alltoallv_init.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPIX_Alltoallv_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-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-2018 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/mpiext/pcollreq/c/mpiext_pcollreq_c.h"
  35 #include "ompi/runtime/ompi_spc.h"
  36 
  37 #if OMPI_BUILD_MPI_PROFILING
  38 #if OPAL_HAVE_WEAK_SYMBOLS
  39 #pragma weak MPIX_Alltoallv_init = PMPIX_Alltoallv_init
  40 #endif
  41 #define MPIX_Alltoallv_init PMPIX_Alltoallv_init
  42 #endif
  43 
  44 static const char FUNC_NAME[] = "MPIX_Alltoallv_init";
  45 
  46 
  47 int MPIX_Alltoallv_init(const void *sendbuf, const int sendcounts[], const int sdispls[],
  48                    MPI_Datatype sendtype, void *recvbuf, const int recvcounts[],
  49                    const int rdispls[], MPI_Datatype recvtype, MPI_Comm comm,
  50                    MPI_Info info, MPI_Request *request)
  51 {
  52     int i, size, err;
  53 
  54     SPC_RECORD(OMPI_SPC_ALLTOALLV_INIT, 1);
  55 
  56     MEMCHECKER(
  57         ptrdiff_t recv_ext;
  58         ptrdiff_t send_ext;
  59 
  60         memchecker_comm(comm);
  61 
  62         if (MPI_IN_PLACE != sendbuf) {
  63             memchecker_datatype(sendtype);
  64             ompi_datatype_type_extent(sendtype, &send_ext);
  65         }
  66 
  67         memchecker_datatype(recvtype);
  68         ompi_datatype_type_extent(recvtype, &recv_ext);
  69 
  70         size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
  71         for ( i = 0; i < size; i++ ) {
  72             if (MPI_IN_PLACE != sendbuf) {
  73                 /* check if send chunks are defined. */
  74                 memchecker_call(&opal_memchecker_base_isdefined,
  75                                 (char *)(sendbuf)+sdispls[i]*send_ext,
  76                                 sendcounts[i], sendtype);
  77             }
  78             /* check if receive chunks are addressable. */
  79             memchecker_call(&opal_memchecker_base_isaddressable,
  80                             (char *)(recvbuf)+rdispls[i]*recv_ext,
  81                             recvcounts[i], recvtype);
  82         }
  83     );
  84 
  85     if (MPI_PARAM_CHECK) {
  86 
  87         /* Unrooted operation -- same checks for all ranks */
  88 
  89         err = MPI_SUCCESS;
  90         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  91         if (ompi_comm_invalid(comm)) {
  92             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  93                                           FUNC_NAME);
  94         }
  95 
  96         if (MPI_IN_PLACE == sendbuf) {
  97             sendcounts = recvcounts;
  98             sdispls = rdispls;
  99             sendtype = recvtype;
 100         }
 101 
 102         if ((NULL == sendcounts) || (NULL == sdispls) ||
 103             (NULL == recvcounts) || (NULL == rdispls) ||
 104             (MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
 105             MPI_IN_PLACE == recvbuf) {
 106             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 107         }
 108 
 109         size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
 110         for (i = 0; i < size; ++i) {
 111             OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]);
 112             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 113             OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtype, recvcounts[i]);
 114             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 115         }
 116 
 117         if (MPI_IN_PLACE != sendbuf && !OMPI_COMM_IS_INTER(comm)) {
 118             int me = ompi_comm_rank(comm);
 119             size_t sendtype_size, recvtype_size;
 120             ompi_datatype_type_size(sendtype, &sendtype_size);
 121             ompi_datatype_type_size(recvtype, &recvtype_size);
 122             if ((sendtype_size*sendcounts[me]) != (recvtype_size*recvcounts[me])) {
 123                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TRUNCATE, FUNC_NAME);
 124             }
 125         }
 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_alltoallv_init(sendbuf, sendcounts, sdispls,
 132                                             sendtype, recvbuf, recvcounts, rdispls,
 133                                             recvtype, comm, info, request, comm->c_coll->coll_alltoallv_init_module);
 134     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 135 }
 136 

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