2004-01-12 00:26:55 +03:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2006-08-24 20:38:08 +04:00
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-01-12 00:26:55 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-02-15 00:26:30 +03:00
|
|
|
#include "coll_basic.h"
|
2004-01-12 00:26:55 +03:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "mpi.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/constants.h"
|
2005-09-13 00:21:53 +04:00
|
|
|
#include "ompi/op/op.h"
|
|
|
|
#include "ompi/datatype/datatype.h"
|
|
|
|
#include "ompi/mca/pml/pml.h"
|
|
|
|
#include "ompi/mca/coll/coll.h"
|
|
|
|
#include "ompi/mca/coll/base/coll_tags.h"
|
2004-01-12 00:26:55 +03:00
|
|
|
#include "coll_basic.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2004-06-29 04:02:25 +04:00
|
|
|
* exscan_intra
|
2004-01-12 00:26:55 +03:00
|
|
|
*
|
|
|
|
* Function: - basic exscan operation
|
2005-01-30 03:24:05 +03:00
|
|
|
* Accepts: - same arguments as MPI_Exscan()
|
2004-01-12 00:26:55 +03:00
|
|
|
* Returns: - MPI_SUCCESS or error code
|
|
|
|
*/
|
2005-08-10 14:51:42 +04:00
|
|
|
int
|
|
|
|
mca_coll_basic_exscan_intra(void *sbuf, void *rbuf, int count,
|
2005-08-10 21:53:43 +04:00
|
|
|
struct ompi_datatype_t *dtype,
|
|
|
|
struct ompi_op_t *op,
|
2007-08-19 07:37:49 +04:00
|
|
|
struct ompi_communicator_t *comm,
|
2008-07-29 02:40:57 +04:00
|
|
|
mca_coll_base_module_t *module)
|
2004-01-12 00:26:55 +03:00
|
|
|
{
|
2006-10-18 00:20:58 +04:00
|
|
|
int size, rank, err;
|
|
|
|
ptrdiff_t true_lb, true_extent, lb, extent;
|
2005-08-10 14:51:42 +04:00
|
|
|
char *free_buffer = NULL;
|
|
|
|
char *reduce_buffer = NULL;
|
|
|
|
char *source;
|
|
|
|
MPI_Request req = MPI_REQUEST_NULL;
|
|
|
|
|
|
|
|
/* Initialize. */
|
|
|
|
|
|
|
|
rank = ompi_comm_rank(comm);
|
|
|
|
size = ompi_comm_size(comm);
|
|
|
|
|
|
|
|
/* If we're rank 0, then we send our sbuf to the next rank */
|
|
|
|
|
|
|
|
if (0 == rank) {
|
2005-08-10 21:53:43 +04:00
|
|
|
return MCA_PML_CALL(send(sbuf, count, dtype, rank + 1,
|
|
|
|
MCA_COLL_BASE_TAG_EXSCAN,
|
|
|
|
MCA_PML_BASE_SEND_STANDARD, comm));
|
2004-01-12 00:26:55 +03:00
|
|
|
}
|
2004-06-29 17:04:38 +04:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
/* If we're the last rank, then just receive the result from the
|
|
|
|
* prior rank */
|
|
|
|
|
|
|
|
else if ((size - 1) == rank) {
|
2005-08-10 21:53:43 +04:00
|
|
|
return MCA_PML_CALL(recv(rbuf, count, dtype, rank - 1,
|
|
|
|
MCA_COLL_BASE_TAG_EXSCAN, comm,
|
|
|
|
MPI_STATUS_IGNORE));
|
2005-08-10 14:51:42 +04:00
|
|
|
}
|
2004-06-29 17:04:38 +04:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
/* Otherwise, get the result from the prior rank, combine it with my
|
|
|
|
* data, and send it to the next rank */
|
2004-06-29 17:04:38 +04:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
/* Start the receive for the prior rank's answer */
|
|
|
|
|
|
|
|
err = MCA_PML_CALL(irecv(rbuf, count, dtype, rank - 1,
|
2005-08-10 21:53:43 +04:00
|
|
|
MCA_COLL_BASE_TAG_EXSCAN, comm, &req));
|
2004-06-29 17:04:38 +04:00
|
|
|
if (MPI_SUCCESS != err) {
|
2005-08-10 21:53:43 +04:00
|
|
|
goto error;
|
2004-01-12 00:26:55 +03:00
|
|
|
}
|
2004-06-29 17:04:38 +04:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
/* Get a temporary buffer to perform the reduction into. Rationale
|
|
|
|
* for malloc'ing this size is provided in coll_basic_reduce.c. */
|
2004-06-29 17:04:38 +04:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
ompi_ddt_get_extent(dtype, &lb, &extent);
|
|
|
|
ompi_ddt_get_true_extent(dtype, &true_lb, &true_extent);
|
2004-06-29 17:04:38 +04:00
|
|
|
|
2006-08-24 20:38:08 +04:00
|
|
|
free_buffer = (char*)malloc(true_extent + (count - 1) * extent);
|
2005-08-10 14:51:42 +04:00
|
|
|
if (NULL == free_buffer) {
|
2005-08-10 21:53:43 +04:00
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2004-01-12 00:26:55 +03:00
|
|
|
}
|
2005-08-10 14:51:42 +04:00
|
|
|
reduce_buffer = free_buffer - lb;
|
2004-06-29 17:04:38 +04:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
if (ompi_op_is_commute(op)) {
|
|
|
|
|
2005-08-10 21:53:43 +04:00
|
|
|
/* If we're commutative, we can copy my sbuf into the reduction
|
|
|
|
* buffer before the receive completes */
|
2005-08-10 14:51:42 +04:00
|
|
|
|
2005-09-14 00:06:54 +04:00
|
|
|
err = ompi_ddt_copy_content_same_ddt(dtype, count,
|
2006-08-24 20:38:08 +04:00
|
|
|
reduce_buffer, (char*)sbuf);
|
2005-08-10 21:53:43 +04:00
|
|
|
if (MPI_SUCCESS != err) {
|
|
|
|
goto error;
|
|
|
|
}
|
2005-08-10 14:51:42 +04:00
|
|
|
|
2005-08-10 21:53:43 +04:00
|
|
|
/* Now setup the reduction */
|
2005-08-10 14:51:42 +04:00
|
|
|
|
2006-08-24 20:38:08 +04:00
|
|
|
source = (char*)rbuf;
|
2005-08-10 14:51:42 +04:00
|
|
|
|
2005-08-10 21:53:43 +04:00
|
|
|
/* Finally, wait for the receive to complete (so that we can do
|
|
|
|
* the reduction). */
|
2005-08-10 14:51:42 +04:00
|
|
|
|
2005-08-10 21:53:43 +04:00
|
|
|
err = ompi_request_wait(&req, MPI_STATUS_IGNORE);
|
|
|
|
if (MPI_SUCCESS != err) {
|
|
|
|
goto error;
|
|
|
|
}
|
2005-08-10 14:51:42 +04:00
|
|
|
} else {
|
|
|
|
|
2005-08-10 21:53:43 +04:00
|
|
|
/* Setup the reduction */
|
2005-08-10 14:51:42 +04:00
|
|
|
|
2006-08-24 20:38:08 +04:00
|
|
|
source = (char*)sbuf;
|
2005-08-10 14:51:42 +04:00
|
|
|
|
2005-08-10 21:53:43 +04:00
|
|
|
/* If we're not commutative, we have to wait for the receive to
|
|
|
|
* complete and then copy it into the reduce buffer */
|
2005-08-10 14:51:42 +04:00
|
|
|
|
2005-08-10 21:53:43 +04:00
|
|
|
err = ompi_request_wait(&req, MPI_STATUS_IGNORE);
|
|
|
|
if (MPI_SUCCESS != err) {
|
|
|
|
goto error;
|
|
|
|
}
|
2005-08-10 14:51:42 +04:00
|
|
|
|
2005-09-14 00:06:54 +04:00
|
|
|
err = ompi_ddt_copy_content_same_ddt(dtype, count,
|
2006-08-24 20:38:08 +04:00
|
|
|
reduce_buffer, (char*)rbuf);
|
2005-08-10 21:53:43 +04:00
|
|
|
if (MPI_SUCCESS != err) {
|
|
|
|
goto error;
|
|
|
|
}
|
2004-01-12 00:26:55 +03:00
|
|
|
}
|
2004-06-29 17:04:38 +04:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
/* Now reduce the received answer with my source into the answer
|
|
|
|
* that we send off to the next rank */
|
2004-06-29 17:04:38 +04:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
ompi_op_reduce(op, source, reduce_buffer, count, dtype);
|
2004-06-29 17:04:38 +04:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
/* Send my result off to the next rank */
|
2004-06-29 17:04:38 +04:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
err = MCA_PML_CALL(send(reduce_buffer, count, dtype, rank + 1,
|
2005-08-10 21:53:43 +04:00
|
|
|
MCA_COLL_BASE_TAG_EXSCAN,
|
|
|
|
MCA_PML_BASE_SEND_STANDARD, comm));
|
2004-06-29 17:04:38 +04:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
/* Error */
|
2004-06-29 17:04:38 +04:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
error:
|
|
|
|
free(free_buffer);
|
|
|
|
if (MPI_REQUEST_NULL != req) {
|
2005-08-10 21:53:43 +04:00
|
|
|
ompi_request_cancel(req);
|
|
|
|
ompi_request_wait(&req, MPI_STATUS_IGNORE);
|
2005-08-10 14:51:42 +04:00
|
|
|
}
|
2004-01-12 00:26:55 +03:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
/* All done */
|
2004-01-12 00:26:55 +03:00
|
|
|
|
2005-08-10 14:51:42 +04:00
|
|
|
return err;
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* exscan_inter
|
|
|
|
*
|
|
|
|
* Function: - basic exscan operation
|
2005-01-30 03:24:05 +03:00
|
|
|
* Accepts: - same arguments as MPI_Exscan()
|
2004-06-29 04:02:25 +04:00
|
|
|
* Returns: - MPI_SUCCESS or error code
|
|
|
|
*/
|
2005-08-10 14:51:42 +04:00
|
|
|
int
|
|
|
|
mca_coll_basic_exscan_inter(void *sbuf, void *rbuf, int count,
|
2005-08-10 21:53:43 +04:00
|
|
|
struct ompi_datatype_t *dtype,
|
|
|
|
struct ompi_op_t *op,
|
2007-08-19 07:37:49 +04:00
|
|
|
struct ompi_communicator_t *comm,
|
2008-07-29 02:40:57 +04:00
|
|
|
mca_coll_base_module_t *module)
|
2004-06-29 04:02:25 +04:00
|
|
|
{
|
2005-08-10 14:51:42 +04:00
|
|
|
return OMPI_ERR_NOT_IMPLEMENTED;
|
2004-01-12 00:26:55 +03:00
|
|
|
}
|