root/ompi/mpiext/pcollreq/c/alltoallw_init.c

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

DEFINITIONS

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

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