root/ompi/mpi/c/ialltoallw.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Ialltoallw

   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_Ialltoallw = PMPI_Ialltoallw
  39 #endif
  40 #define MPI_Ialltoallw PMPI_Ialltoallw
  41 #endif
  42 
  43 static const char FUNC_NAME[] = "MPI_Ialltoallw";
  44 
  45 
  46 int MPI_Ialltoallw(const void *sendbuf, const int sendcounts[], const int sdispls[],
  47                    const MPI_Datatype sendtypes[], void *recvbuf, const int recvcounts[],
  48                    const int rdispls[], const MPI_Datatype recvtypes[], MPI_Comm comm,
  49                    MPI_Request *request)
  50 {
  51     int i, size, err;
  52 
  53     SPC_RECORD(OMPI_SPC_IALLTOALLW, 1);
  54 
  55     MEMCHECKER(
  56         ptrdiff_t recv_ext;
  57         ptrdiff_t send_ext;
  58 
  59 
  60         memchecker_comm(comm);
  61 
  62         size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
  63         for ( i = 0; i < size; i++ ) {
  64             if (MPI_IN_PLACE != sendbuf) {
  65                 memchecker_datatype(sendtypes[i]);
  66                 ompi_datatype_type_extent(sendtypes[i], &send_ext);
  67                 memchecker_call(&opal_memchecker_base_isdefined,
  68                                 (char *)(sendbuf)+sdispls[i]*send_ext,
  69                                 sendcounts[i], sendtypes[i]);
  70             }
  71 
  72             memchecker_datatype(recvtypes[i]);
  73             ompi_datatype_type_extent(recvtypes[i], &recv_ext);
  74             memchecker_call(&opal_memchecker_base_isaddressable,
  75                             (char *)(recvbuf)+rdispls[i]*recv_ext,
  76                             recvcounts[i], recvtypes[i]);
  77         }
  78     );
  79 
  80     if (MPI_PARAM_CHECK) {
  81 
  82         /* Unrooted operation -- same checks for all ranks */
  83 
  84         err = MPI_SUCCESS;
  85         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  86         if (ompi_comm_invalid(comm)) {
  87             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  88                                           FUNC_NAME);
  89         }
  90 
  91         if (MPI_IN_PLACE == sendbuf) {
  92             sendcounts = recvcounts;
  93             sdispls    = rdispls;
  94             sendtypes  = recvtypes;
  95         }
  96 
  97         if ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes) ||
  98             (NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes) ||
  99             (MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
 100             MPI_IN_PLACE == recvbuf) {
 101             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
 102         }
 103 
 104         size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
 105         for (i = 0; i < size; ++i) {
 106             OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtypes[i], sendcounts[i]);
 107             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 108             OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtypes[i], recvcounts[i]);
 109             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 110         }
 111 
 112         if (MPI_IN_PLACE != sendbuf && !OMPI_COMM_IS_INTER(comm)) {
 113             int me = ompi_comm_rank(comm);
 114             size_t sendtype_size, recvtype_size;
 115             ompi_datatype_type_size(sendtypes[me], &sendtype_size);
 116             ompi_datatype_type_size(recvtypes[me], &recvtype_size);
 117             if ((sendtype_size*sendcounts[me]) != (recvtype_size*recvcounts[me])) {
 118                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TRUNCATE, FUNC_NAME);
 119             }
 120         }
 121     }
 122 
 123     OPAL_CR_ENTER_LIBRARY();
 124 
 125     /* Invoke the coll component to perform the back-end operation */
 126     err = comm->c_coll->coll_ialltoallw(sendbuf, sendcounts, sdispls,
 127                                        sendtypes, recvbuf, recvcounts,
 128                                        rdispls, recvtypes, comm, request,
 129                                        comm->c_coll->coll_ialltoallw_module);
 130     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 131 }
 132 

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