root/ompi/mca/coll/basic/coll_basic_gather.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_coll_basic_gather_inter

   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2015 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2015      Research Organization for Information Science
  13  *                         and Technology (RIST). All rights reserved.
  14  * $COPYRIGHT$
  15  *
  16  * Additional copyrights may follow
  17  *
  18  * $HEADER$
  19  */
  20 
  21 #include "ompi_config.h"
  22 #include "coll_basic.h"
  23 
  24 #include "mpi.h"
  25 #include "ompi/constants.h"
  26 #include "coll_basic.h"
  27 #include "ompi/datatype/ompi_datatype.h"
  28 #include "ompi/mca/coll/coll.h"
  29 #include "ompi/mca/coll/base/coll_tags.h"
  30 #include "ompi/mca/pml/pml.h"
  31 
  32 
  33 /*
  34  *      gather_inter
  35  *
  36  *      Function:       - basic gather operation
  37  *      Accepts:        - same arguments as MPI_Gather()
  38  *      Returns:        - MPI_SUCCESS or error code
  39  */
  40 int
  41 mca_coll_basic_gather_inter(const void *sbuf, int scount,
  42                             struct ompi_datatype_t *sdtype,
  43                             void *rbuf, int rcount,
  44                             struct ompi_datatype_t *rdtype,
  45                             int root, struct ompi_communicator_t *comm,
  46                             mca_coll_base_module_t *module)
  47 {
  48     int i;
  49     int err;
  50     int size;
  51     char *ptmp;
  52     MPI_Aint incr;
  53     MPI_Aint extent;
  54     MPI_Aint lb;
  55 
  56     size = ompi_comm_remote_size(comm);
  57 
  58     if (MPI_PROC_NULL == root) {
  59         /* do nothing */
  60         err = OMPI_SUCCESS;
  61     } else if (MPI_ROOT != root) {
  62         /* Everyone but root sends data and returns. */
  63         err = MCA_PML_CALL(send(sbuf, scount, sdtype, root,
  64                                 MCA_COLL_BASE_TAG_GATHER,
  65                                 MCA_PML_BASE_SEND_STANDARD, comm));
  66     } else {
  67         /* I am the root, loop receiving the data. */
  68         err = ompi_datatype_get_extent(rdtype, &lb, &extent);
  69         if (OMPI_SUCCESS != err) {
  70             return OMPI_ERROR;
  71         }
  72 
  73         incr = extent * rcount;
  74         for (i = 0, ptmp = (char *) rbuf; i < size; ++i, ptmp += incr) {
  75             err = MCA_PML_CALL(recv(ptmp, rcount, rdtype, i,
  76                                     MCA_COLL_BASE_TAG_GATHER,
  77                                     comm, MPI_STATUS_IGNORE));
  78             if (MPI_SUCCESS != err) {
  79                 return err;
  80             }
  81         }
  82     }
  83 
  84     /* All done */
  85     return err;
  86 }

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