root/ompi/mpi/c/alltoall.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Alltoall

   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) 2013      Los Alamos National Security, LLC. All rights
  15  *                         reserved.
  16  * Copyright (c) 2014-2015 Research Organization for Information Science
  17  *                         and Technology (RIST). All rights reserved.
  18  * Copyright (c) 2015      Mellanox Technologies. All rights reserved.
  19  *
  20  * $COPYRIGHT$
  21  *
  22  * Additional copyrights may follow
  23  *
  24  * $HEADER$
  25  */
  26 
  27 #include "ompi_config.h"
  28 #include <stdio.h>
  29 
  30 #include "ompi/mpi/c/bindings.h"
  31 #include "ompi/runtime/params.h"
  32 #include "ompi/communicator/communicator.h"
  33 #include "ompi/errhandler/errhandler.h"
  34 #include "ompi/datatype/ompi_datatype.h"
  35 #include "ompi/memchecker.h"
  36 #include "ompi/runtime/ompi_spc.h"
  37 
  38 #if OMPI_BUILD_MPI_PROFILING
  39 #if OPAL_HAVE_WEAK_SYMBOLS
  40 #pragma weak MPI_Alltoall = PMPI_Alltoall
  41 #endif
  42 #define MPI_Alltoall PMPI_Alltoall
  43 #endif
  44 
  45 static const char FUNC_NAME[] = "MPI_Alltoall";
  46 
  47 
  48 int MPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  49                  void *recvbuf, int recvcount, MPI_Datatype recvtype,
  50                  MPI_Comm comm)
  51 {
  52     int err;
  53     size_t recvtype_size;
  54 
  55     SPC_RECORD(OMPI_SPC_ALLTOALL, 1);
  56 
  57     MEMCHECKER(
  58         memchecker_comm(comm);
  59         if (MPI_IN_PLACE != sendbuf) {
  60             memchecker_datatype(sendtype);
  61             memchecker_call(&opal_memchecker_base_isdefined, (void *)sendbuf, sendcount, sendtype);
  62         }
  63         memchecker_datatype(recvtype);
  64         memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, recvcount, recvtype);
  65     );
  66 
  67     if (MPI_PARAM_CHECK) {
  68 
  69         /* Unrooted operation -- same checks for all ranks on both
  70            intracommunicators and intercommunicators */
  71 
  72         err = MPI_SUCCESS;
  73         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  74         if (ompi_comm_invalid(comm)) {
  75             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  76                                           FUNC_NAME);
  77         } else if ((MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
  78                    MPI_IN_PLACE == recvbuf) {
  79             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
  80                                           FUNC_NAME);
  81         } else {
  82             if(MPI_IN_PLACE != sendbuf) {
  83                 OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
  84                 OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
  85             }
  86             OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtype, recvcount);
  87             OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
  88         }
  89 
  90         if (MPI_IN_PLACE != sendbuf && !OMPI_COMM_IS_INTER(comm)) {
  91             size_t sendtype_size, recvtype_size;
  92             ompi_datatype_type_size(sendtype, &sendtype_size);
  93             ompi_datatype_type_size(recvtype, &recvtype_size);
  94             if ((sendtype_size*sendcount) != (recvtype_size*recvcount)) {
  95                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TRUNCATE, FUNC_NAME);
  96             }
  97         }
  98     }
  99 
 100     if (! OMPI_COMM_IS_INTER(comm)) {
 101         ompi_datatype_type_size(recvtype, &recvtype_size);
 102         if( (0 == recvcount) || (0 == recvtype_size) ) {
 103             return MPI_SUCCESS;
 104         }
 105     }
 106 
 107     OPAL_CR_ENTER_LIBRARY();
 108 
 109     /* Invoke the coll component to perform the back-end operation */
 110     err = comm->c_coll->coll_alltoall(sendbuf, sendcount, sendtype,
 111                                      recvbuf, recvcount, recvtype,
 112                                      comm, comm->c_coll->coll_alltoall_module);
 113     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 114 }
 115 

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