ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
BI_BuffIsFree.c
Go to the documentation of this file.
1 #include "Bdef.h"
2 
3 int BI_BuffIsFree(BLACBUFF *bp, int Wait)
4 /*
5  * Check to see if buff is finished with async. operations. If Wait != 0,
6  * wait for all async. operations to complete.
7  */
8 {
9  int i, info;
10  extern MPI_Status *BI_Stats;
11  extern int BI_Np;
12 
13 
14  if (!Wait)
15  {
16  info=MPI_Testall(bp->nAops, bp->Aops, &i, BI_Stats);
17  if (!i)
18  {
19 /*
20  * If we are doing our own Packing, need to check true length of receive
21  */
22 #ifndef MpiBuffGood
23 /*
24  * If we have an outstanding receive, make sure that when it
25  * completes we correctly set bp->N, if required
26  */
27  if (bp->N < 0)
28  {
29  if (bp->Aops[-bp->N-1] == MPI_REQUEST_NULL)
30  {
31  info=MPI_Get_count(&BI_Stats[(-bp->N-1)*sizeof(MPI_Status)],MPI_PACKED, &i);
32  if (i != MPI_UNDEFINED) bp->N = i;
33  else BI_BlacsWarn(-1, __LINE__, __FILE__,
34  "MPI_Get_count returned MPI_UNDEFINED.\n");
35  }
36  }
37 #endif
38  return(0);
39  }
40  }
41  else
42  {
43  info=MPI_Waitall(bp->nAops, bp->Aops, BI_Stats);
44  }
45 
46  bp->nAops = 0;
47 /*
48  * If we are doing our own packing, need to check true length of receive
49  */
50 #ifndef MpiBuffGood
51 /*
52  * If we had an outstanding receive, make sure that we correctly set bp->N,
53  * if required
54  */
55  if (bp->N < 0)
56  {
57  info=MPI_Get_count(&BI_Stats[(-bp->N-1)*sizeof(MPI_Status)],MPI_PACKED, &i);
58  if (i != MPI_UNDEFINED) bp->N = i;
59  else BI_BlacsWarn(-1, __LINE__, __FILE__,
60  "MPI_Get_count returned MPI_UNDEFINED.\n");
61  }
62 #endif
63  return(1);
64 }
BI_Stats
MPI_Status * BI_Stats
Definition: BI_GlobalVars.c:14
bLaCbUfF
Definition: Bdef.h:54
bLaCbUfF::N
int N
Definition: Bdef.h:61
bLaCbUfF::Aops
MPI_Request * Aops
Definition: Bdef.h:59
BI_Np
int BI_Np
Definition: BI_GlobalVars.c:7
bLaCbUfF::nAops
int nAops
Definition: Bdef.h:58
Bdef.h
BI_BlacsWarn
void BI_BlacsWarn(int ConTxt, int line, char *file, char *form,...)
Definition: BI_BlacsWarn.c:3
BI_BuffIsFree
int BI_BuffIsFree(BLACBUFF *bp, int Wait)
Definition: BI_BuffIsFree.c:3