SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
BI_EmergencyBuff.c
Go to the documentation of this file.
1#include "Bdef.h"
2
3/***************************************************************************
4 * If there is insufficient space to allocate a needed buffer, this *
5 * routine is called. It moniters active buffers for the time defined by *
6 * the user-changeable macro value BUFWAIT. If in that time no active *
7 * buffer becomes inactive, a hang is assumed, and the grid is killed. *
8 ***************************************************************************/
9void BI_EmergencyBuff(Int length)
10{
12
13 char *cptr;
14 Int i, j;
15 double Mwalltime(void);
16 double t1;
17 extern Int BI_Np;
19
20 j = sizeof(BLACBUFF);
21 if (j % sizeof(MPI_Request))
22 j += sizeof(MPI_Request) - j % sizeof(MPI_Request);
23 i = j + BI_Np*sizeof(MPI_Request);
24 if (i % BUFFALIGN) i += BUFFALIGN - i % BUFFALIGN;
25 t1 = Mwalltime();
26 while ( (BI_ActiveQ) && (Mwalltime() - t1 < BUFWAIT) && !(BI_ReadyB) )
27 {
28 BI_UpdateBuffs(NULL);
29 if (BI_ReadyB)
30 {
31 if (BI_ReadyB->Len < length)
32 {
33 free(BI_ReadyB);
34 cptr = malloc(length + i);
35 BI_ReadyB = (BLACBUFF *) cptr;
36 if (BI_ReadyB)
37 {
38 BI_ReadyB->nAops = 0;
39 BI_ReadyB->Aops = (MPI_Request *) &cptr[j];
40 BI_ReadyB->Buff = &cptr[i];
41 BI_ReadyB->Len = length;
42 }
43 }
44 }
45 }
46 if (BI_ReadyB == NULL)
47 {
48 BI_BlacsErr(-1, __LINE__, __FILE__, "BLACS out of buffer space");
49 }
50}
void BI_EmergencyBuff(Int length)
BLACBUFF * BI_ReadyB
Int BI_Np
BLACBUFF * BI_ActiveQ
void BI_UpdateBuffs(BLACBUFF *Newbp)
#define Int
Definition Bconfig.h:22
void BI_BlacsErr(Int ConTxt, Int line, char *file, char *form,...)
Definition BI_BlacsErr.c:3
#define BUFWAIT
Definition Bdef.h:82
struct bLaCbUfF BLACBUFF
Definition Bdef.h:53
#define Mwalltime
Definition Bdef.h:263
#define BUFFALIGN
Definition Bdef.h:75
Int Len
Definition Bdef.h:57
MPI_Request * Aops
Definition Bdef.h:59
Int nAops
Definition Bdef.h:58
char * Buff
Definition Bdef.h:56