root/ompi/mpiext/pcollreq/c/scatter_init.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPIX_Scatter_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) 2006-2007 Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2008      University of Houston.  All rights reserved.
  15  * Copyright (c) 2008      Sun Microsystems, Inc.  All rights reserved.
  16  * Copyright (c) 2013      Los Alamos National Security, LLC.  All rights
  17  *                         reserved.
  18  * Copyright (c) 2015-2018 Research Organization for Information Science
  19  *                         and Technology (RIST). All rights reserved.
  20  * $COPYRIGHT$
  21  *
  22  * Additional copyrights may follow
  23  *
  24  * $HEADER$
  25  */
  26 #include "ompi_config.h"
  27 #include <stdio.h>
  28 
  29 #include "ompi/mpi/c/bindings.h"
  30 #include "ompi/runtime/params.h"
  31 #include "ompi/communicator/communicator.h"
  32 #include "ompi/errhandler/errhandler.h"
  33 #include "ompi/datatype/ompi_datatype.h"
  34 #include "ompi/memchecker.h"
  35 #include "ompi/mpiext/pcollreq/c/mpiext_pcollreq_c.h"
  36 #include "ompi/runtime/ompi_spc.h"
  37 
  38 #if OMPI_BUILD_MPI_PROFILING
  39 #if OPAL_HAVE_WEAK_SYMBOLS
  40 #pragma weak MPIX_Scatter_init = PMPIX_Scatter_init
  41 #endif
  42 #define MPIX_Scatter_init PMPIX_Scatter_init
  43 #endif
  44 
  45 static const char FUNC_NAME[] = "MPIX_Scatter_init";
  46 
  47 
  48 int MPIX_Scatter_init(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  49                       void *recvbuf, int recvcount, MPI_Datatype recvtype,
  50                       int root, MPI_Comm comm, MPI_Info info, MPI_Request *request)
  51 {
  52     int err;
  53 
  54     SPC_RECORD(OMPI_SPC_SCATTER_INIT, 1);
  55 
  56     MEMCHECKER(
  57         memchecker_comm(comm);
  58         if(OMPI_COMM_IS_INTRA(comm)) {
  59             if(ompi_comm_rank(comm) == root) {
  60                 memchecker_datatype(sendtype);
  61                 /* check whether root's send buffer is defined. */
  62                 memchecker_call(&opal_memchecker_base_isdefined, sendbuf, sendcount, sendtype);
  63                 if(MPI_IN_PLACE != recvbuf) {
  64                     memchecker_datatype(recvtype);
  65                     /* check whether receive buffer is addressable. */
  66                     memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, recvcount, recvtype);
  67                 }
  68             } else {
  69                 memchecker_datatype(recvtype);
  70                 /* check whether receive buffer is addressable. */
  71                 memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, recvcount, recvtype);
  72             }
  73         } else {
  74             if(MPI_ROOT == root) {
  75                 memchecker_datatype(sendtype);
  76                 /* check whether root's send buffer is defined. */
  77                 memchecker_call(&opal_memchecker_base_isdefined, sendbuf, sendcount, sendtype);
  78             } else if (MPI_PROC_NULL != root) {
  79                 memchecker_datatype(recvtype);
  80                 /* check whether receive buffer is addressable. */
  81                 memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, recvcount, recvtype);
  82             }
  83         }
  84     );
  85 
  86     if (MPI_PARAM_CHECK) {
  87         err = MPI_SUCCESS;
  88         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  89         if (ompi_comm_invalid(comm)) {
  90             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  91                                           FUNC_NAME);
  92         } else if ((ompi_comm_rank(comm) != root && MPI_IN_PLACE == recvbuf) ||
  93                    (ompi_comm_rank(comm) == root && MPI_IN_PLACE == sendbuf)) {
  94             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
  95         }
  96 
  97         /* Errors for intracommunicators */
  98 
  99         if (OMPI_COMM_IS_INTRA(comm)) {
 100 
 101           /* Errors for all ranks */
 102 
 103           if ((root >= ompi_comm_size(comm)) || (root < 0)) {
 104               err = MPI_ERR_ROOT;
 105           } else if (MPI_IN_PLACE != recvbuf) {
 106               if (recvcount < 0) {
 107                   err = MPI_ERR_COUNT;
 108               } else if (MPI_DATATYPE_NULL == recvtype || NULL == recvtype) {
 109                   err = MPI_ERR_TYPE;
 110               }
 111           }
 112 
 113           /* Errors for the root.  Some of these could have been
 114              combined into compound if statements above, but since
 115              this whole section can be compiled out (or turned off at
 116              run time) for efficiency, it's more clear to separate
 117              them out into individual tests. */
 118 
 119           else if (ompi_comm_rank(comm) == root) {
 120             OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
 121           }
 122           OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 123         }
 124 
 125         /* Errors for intercommunicators */
 126 
 127         else {
 128           if (! ((root >= 0 && root < ompi_comm_remote_size(comm)) ||
 129                  MPI_ROOT == root || MPI_PROC_NULL == root)) {
 130             err = MPI_ERR_ROOT;
 131           }
 132 
 133           /* Errors for the receivers */
 134 
 135           else if (MPI_ROOT != root && MPI_PROC_NULL != root) {
 136             if (recvcount < 0) {
 137               err = MPI_ERR_COUNT;
 138             } else if (MPI_DATATYPE_NULL == recvtype) {
 139               err = MPI_ERR_TYPE;
 140             }
 141           }
 142 
 143           /* Errors for the root.  Ditto on the comment above -- these
 144              error checks could have been combined above, but let's
 145              make the code easier to read. */
 146 
 147           else if (MPI_ROOT == root) {
 148             OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
 149           }
 150           OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
 151         }
 152     }
 153 
 154     OPAL_CR_ENTER_LIBRARY();
 155 
 156     /* Invoke the coll component to perform the back-end operation */
 157     err = comm->c_coll->coll_scatter_init(sendbuf, sendcount, sendtype, recvbuf,
 158                                           recvcount, recvtype, root, comm, info, request,
 159                                           comm->c_coll->coll_scatter_init_module);
 160     OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
 161 }

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