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-2005 The University of Tennessee and The University
6
* of Tennessee Research Foundation. All rights
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.
14
* Additional copyrights may follow
19
#include "ompi_config.h"
20
#include "coll_basic.h"
23
#include "ompi/constants.h"
24
#include "ompi/datatype/datatype.h"
25
#include "ompi/mca/coll/coll.h"
26
#include "ompi/mca/coll/base/coll_tags.h"
27
#include "coll_basic.h"
32
* Function: - basic gatherv operation
33
* Accepts: - same arguments as MPI_Gatherb()
34
* Returns: - MPI_SUCCESS or error code
37
mca_coll_basic_gatherv_intra(void *sbuf, int scount,
38
struct ompi_datatype_t *sdtype,
39
void *rbuf, int *rcounts, int *disps,
40
struct ompi_datatype_t *rdtype, int root,
41
struct ompi_communicator_t *comm)
51
size = ompi_comm_size(comm);
52
rank = ompi_comm_rank(comm);
54
/* Everyone but root sends data and returns. Don't send anything
55
for sendcounts of 0 (even though MPI_Gatherv has a guard for 0
56
counts, this routine is used elsewhere, like the implementation
57
of allgatherv, so it's possible to get here with a scount of
62
return MCA_PML_CALL(send(sbuf, scount, sdtype, root,
63
MCA_COLL_BASE_TAG_GATHERV,
64
MCA_PML_BASE_SEND_STANDARD, comm));
69
/* I am the root, loop receiving data. */
71
err = ompi_ddt_get_extent(rdtype, &lb, &extent);
72
if (OMPI_SUCCESS != err) {
76
for (i = 0; i < size; ++i) {
77
ptmp = ((char *) rbuf) + (extent * disps[i]);
80
/* simple optimization */
81
if (MPI_IN_PLACE != sbuf && (0 < scount) && (0 < rcounts[i])) {
82
err = ompi_ddt_sndrcv(sbuf, scount, sdtype,
83
ptmp, rcounts[i], rdtype);
86
/* Only receive if there is something to receive */
88
err = MCA_PML_CALL(recv(ptmp, rcounts[i], rdtype, i,
89
MCA_COLL_BASE_TAG_GATHERV,
90
comm, MPI_STATUS_IGNORE));
94
if (MPI_SUCCESS != err) {
108
* Function: - basic gatherv operation
109
* Accepts: - same arguments as MPI_Gatherv()
110
* Returns: - MPI_SUCCESS or error code
113
mca_coll_basic_gatherv_inter(void *sbuf, int scount,
114
struct ompi_datatype_t *sdtype,
115
void *rbuf, int *rcounts, int *disps,
116
struct ompi_datatype_t *rdtype, int root,
117
struct ompi_communicator_t *comm)
126
ompi_request_t **reqs = comm->c_coll_basic_data->mccb_reqs;
128
size = ompi_comm_remote_size(comm);
129
rank = ompi_comm_rank(comm);
131
/* If not root, receive data. Note that we will only get here if
132
* scount > 0 or rank == root. */
134
if (MPI_PROC_NULL == root) {
137
} else if (MPI_ROOT != root) {
138
/* Everyone but root sends data and returns. */
139
err = MCA_PML_CALL(send(sbuf, scount, sdtype, root,
140
MCA_COLL_BASE_TAG_GATHERV,
141
MCA_PML_BASE_SEND_STANDARD, comm));
143
/* I am the root, loop receiving data. */
144
err = ompi_ddt_get_extent(rdtype, &lb, &extent);
145
if (OMPI_SUCCESS != err) {
149
for (i = 0; i < size; ++i) {
150
ptmp = ((char *) rbuf) + (extent * disps[i]);
151
err = MCA_PML_CALL(irecv(ptmp, rcounts[i], rdtype, i,
152
MCA_COLL_BASE_TAG_GATHERV,
154
if (OMPI_SUCCESS != err) {
159
err = ompi_request_wait_all(size, reqs, MPI_STATUSES_IGNORE);