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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
/*
* Copyright (c) 2001-2002 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: iprobe.c,v 6.12 2003/02/20 19:57:13 jsquyres Exp $
*
* Function: - non-blocking check of incoming messages
* - message is not received
* Accepts: - source rank
* - message tag
* - communicator
* - flag (out)
* - status (out)
* Returns: - MPI_SUCCESS or error code
*/
#include <blktype.h>
#include <mpi.h>
#include <mpisys.h>
#include <mpitrace.h>
#include <lam-ssi-rpi.h>
#include <rpisys.h>
#include <terror.h>
/*@
MPI_Iprobe - Nonblocking test for a message
Input Parameters:
+ src - source rank, or 'MPI_ANY_SOURCE' (integer)
. tag - tag value or 'MPI_ANY_TAG' (integer)
- comm - communicator (handle)
Output Parameter:
+ flag - 1 if the message is ready to be received, 0 if it is not
(logical)
- stat - status object (Status), which may be the MPI constant
'MPI_STATUS_IGNORE'
Notes:
This function does not actually receive a message; it only indicates
that a message matching the signature specified is ready to be
received.
.N fortran
.N Errors
.N MPI_SUCCESS
.N MPI_ERR_ARG
.N MPI_ERR_COMM
.N MPI_ERR_TAG
.N MPI_ERR_RANK
.N ACK
@*/
int MPI_Iprobe(int src, int tag, MPI_Comm comm,
int *flag, MPI_Status *stat)
{
struct _req request_storage; /* request structure */
MPI_Request req; /* request */
int err; /* error code */
int fl_trace; /* do tracing? */
int r;
double startt = 0.0; /* start time */
lam_initerr_m();
lam_setfunc_m(BLKMPIIPROBE);
/*
* Check additional arguments.
*/
if (flag == 0) {
return(lam_errfunc(comm, BLKMPIIPROBE,
lam_mkerr(MPI_ERR_ARG, EINVAL)));
}
if ((tag < 0 && tag != MPI_ANY_TAG) || tag > lam_mpi_max_tag) {
return(lam_errfunc(comm, BLKMPIIPROBE,
lam_mkerr(MPI_ERR_TAG, EINVAL)));
}
/*
* Handle the trivial case.
*/
if (src == MPI_PROC_NULL) {
if (stat != MPI_STATUS_IGNORE) {
stat->MPI_ERROR = MPI_SUCCESS;
stat->MPI_SOURCE = MPI_PROC_NULL;
stat->MPI_TAG = MPI_ANY_TAG;
stat->st_length = 0;
}
*flag = 1;
lam_resetfunc_m(BLKMPIIPROBE);
return(MPI_SUCCESS);
}
if ((fl_trace = LAM_TRACE_TOP())) startt = MPI_Wtime();
/*
* Advance the system to give the probe a better chance of success.
*/
_mpi_req_blkclr();
err = _mpi_req_advance();
if (err != MPI_SUCCESS) {
return(lam_errfunc(comm, BLKMPIIPROBE, err));
}
LAM_ZERO_ME(request_storage);
req = &request_storage;
err = _mpi_req_build((char *) 0, 0, MPI_BYTE, src, tag, comm,
LAM_RQIPROBE, &req);
if (err != MPI_SUCCESS) {
return(lam_errfunc(comm, BLKMPIIPROBE, err));
}
err = _mpi_req_start(req);
if (err != MPI_SUCCESS) {
return(lam_errfunc(comm, BLKMPIIPROBE, err));
}
r = RPI_IPROBE(req);
if (r < 0) {
return(lam_errfunc(comm, BLKMPIIPROBE,
lam_mkerr(MPI_ERR_INTERN, errno)));
}
err = _mpi_req_end(req);
if (err != MPI_SUCCESS) {
return(lam_errfunc(comm, BLKMPIIPROBE, err));
}
/*
* Copy the status info if synchronized.
*/
if (r == 1) {
*flag = 1;
if (stat != MPI_STATUS_IGNORE) {
*stat = req->rq_status;
}
} else {
*flag = 0;
}
err = _mpi_req_destroy(&req);
if (err != MPI_SUCCESS) {
return(lam_errfunc(comm, BLKMPIIPROBE, err));
}
/*
* Generate a run time trace.
*/
if (fl_trace) {
lam_tr_msg(TRTNOIO, startt, LAM_S2US(MPI_Wtime() - startt),
0, src, tag, comm, 0, 0, 0, 0, 0, LAM_RQIPROBE);
}
lam_resetfunc_m(BLKMPIIPROBE);
return(MPI_SUCCESS);
}
|