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
|
#include "Bdef.h"
int BI_BuffIsFree(BLACBUFF *bp, int Wait)
/*
* Check to see if buff is finished with async. operations. If Wait != 0,
* wait for all async. operations to complete.
*/
{
int i, info;
extern BI_MPI_Status *BI_Stats;
extern int BI_Np;
if (!Wait)
{
BI_MPI_Testall(bp->nAops, bp->Aops, &i, BI_Stats, info);
if (!i)
{
/*
* If we are doing our own Packing, need to check true length of receive
*/
#ifndef MpiBuffGood
/*
* If we have an outstanding receive, make sure that when it
* completes we correctly set bp->N, if required
*/
if (bp->N < 0)
{
if (bp->Aops[-bp->N-1] == BI_MPI_REQUEST_NULL)
{
BI_MPI_Get_count(&BI_Stats[(-bp->N-1)*BI_MPI_STATUS_SIZE],
BI_MPI_PACKED, &i, info);
if (i != BI_MPI_UNDEFINED) bp->N = i;
else BI_BlacsWarn(-1, __LINE__, __FILE__,
"MPI_Get_count returned MPI_UNDEFINED.\n");
}
}
#endif
return(0);
}
}
else
{
BI_MPI_Waitall(bp->nAops, bp->Aops, BI_Stats, info);
}
bp->nAops = 0;
/*
* If we are doing our own packing, need to check true length of receive
*/
#ifndef MpiBuffGood
/*
* If we had an outstanding receive, make sure that we correctly set bp->N,
* if required
*/
if (bp->N < 0)
{
BI_MPI_Get_count(&BI_Stats[(-bp->N-1)*BI_MPI_STATUS_SIZE],
BI_MPI_PACKED, &i, info);
if (i != BI_MPI_UNDEFINED) bp->N = i;
else BI_BlacsWarn(-1, __LINE__, __FILE__,
"MPI_Get_count returned MPI_UNDEFINED.\n");
}
#endif
return(1);
}
|