1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
/*
* Copyright (c) 2001-2003 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 1998-2001 University of Notre Dame.
* All rights reserved.
* Copyright (c) 1994-1998 The Ohio State University.
* All rights reserved.
*
* This file is part of the LAM/MPI software package. For license
* information, see the LICENSE file in the top level directory of the
* LAM/MPI source distribution.
*
* $HEADER$
*
* $Id: scan.c,v 6.12 2004/03/02 03:43:29 jsquyres Exp $
*
* Function: - partial reduce from 0 to rank i, at each rank i
* Accepts: - send buffer
* - receive buffer
* - count of elements
* - type of elements
* - operation to perform
* - communicator
* Returns: - MPI_SUCCESS or error code
*/
#include <stdlib.h>
#include <lam_config.h>
#include <blktype.h>
#include <mpi.h>
#include <mpisys.h>
/*@
MPI_Scan - Computes the scan (partial reductions) of data on a collection of
processes
Input Parameters:
+ sbuf - starting address of send buffer (choice)
. count - number of elements in input buffer (integer)
. dtype - data type of elements of input buffer (handle)
. op - operation (handle)
- comm - communicator (handle)
Output Parameter:
. rbuf - starting address of receive buffer (choice)
.N IMPI
.N fortran
.N collops
.N Errors
.N MPI_SUCCESS
.N MPI_ERR_COMM
.N MPI_ERR_COLL_NOT_IMPLEMENTED
.N MPI_ERR_IMPI
.N MPI_ERR_COUNT
.N MPI_ERR_TYPE
.N MPI_ERR_OP
.N MPI_ERR_BUFFER
.N MPI_ERR_BUFFER_ALIAS
.N ACK
@*/
int MPI_Scan(void *sbuf, void *rbuf, int count,
MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)
{
int err;
lam_ssi_coll_scan_fn_t func;
lam_initerr_m();
lam_setfunc_m(BLKMPISCAN);
/*
* Check for invalid arguments.
*/
if (comm == MPI_COMM_NULL) {
return (lam_errfunc(comm, BLKMPISCAN,
lam_mkerr(MPI_ERR_COMM, EINVAL)));
}
func = comm->c_ssi_coll.lsca_scan;
if (dtype == MPI_DATATYPE_NULL) {
return(lam_errfunc(comm, BLKMPISCAN,
lam_mkerr(MPI_ERR_TYPE, EINVAL)));
}
if (count < 0) {
return(lam_errfunc(comm, BLKMPISCAN,
lam_mkerr(MPI_ERR_COUNT, EINVAL)));
}
if (op == MPI_OP_NULL) {
return(lam_errfunc(comm, BLKMPISCAN,
lam_mkerr(MPI_ERR_OP, EINVAL)));
}
if (func == NULL) {
return(lam_errfunc(comm, BLKMPISCAN,
lam_mkerr(MPI_ERR_OTHER, ENOT_IMPLEMENTED)));
}
LAM_TRACE(lam_tr_cffstart(BLKMPISCAN));
/* Check for zero count case. */
if (count == 0) {
LAM_TRACE(lam_tr_cffend(BLKMPISCAN, -1, comm, dtype, count));
lam_resetfunc_m(BLKMPISCAN);
return MPI_SUCCESS;
}
/* Call the coll SSI to actually perform the barrier */
if ((err = func(sbuf, rbuf, count, dtype, op, comm)) != MPI_SUCCESS)
return(lam_errfunc(comm, BLKMPISCAN,
lam_mkerr(MPI_ERR_COMM, err)));
/* All done */
LAM_TRACE(lam_tr_cffend(BLKMPISCAN, -1, comm, dtype, count));
lam_resetfunc(BLKMPISCAN);
return MPI_SUCCESS;
}
|