ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
BI_Pack.c
Go to the documentation of this file.
1 #include "Bdef.h"
2 BLACBUFF *BI_Pack(BLACSCONTEXT *ctxt,BVOID *A,BLACBUFF *bp,MPI_Datatype Dtype)
3 {
4  BLACBUFF *BI_GetBuff(int);
5  int i, info, one=1;
6  MPI_Aint eltsiz;
7 #ifdef ZeroByteTypeBug
8  char *cptr;
9  extern BLACBUFF BI_AuxBuff;
10  extern int BI_Np;
11 #endif
12 
13 /*
14  * Some versions of mpich and its derivitives cannot handle 0 byte typedefs,
15  * so we have set MPI_BYTE as a flag for a 0 byte message
16  */
17 #ifdef ZeroByteTypeBug
18  if (Dtype == MPI_BYTE)
19  {
20  info = sizeof(BLACBUFF);
21  if (info % sizeof(MPI_Request))
22  info += sizeof(MPI_Request) - info % sizeof(MPI_Request);
23  i = info + BI_Np*sizeof(MPI_Request);
24  if (i % BUFFALIGN) i += BUFFALIGN - i % BUFFALIGN;
25  cptr = malloc(i);
26  if (cptr)
27  {
28  bp = (BLACBUFF *) cptr;
29  bp->Len = bp->N = bp->nAops = 0;
30  bp->Aops = (MPI_Request *) &cptr[info];
31  bp->Buff = (char *) &bp->Len;
32  bp->dtype = MPI_BYTE;
33  return(bp);
34  }
35  else BI_BlacsErr(BI_ContxtNum(ctxt), __LINE__, __FILE__,
36  "Not enough memory to allocate 0 byte buffer\n");
37  }
38 #endif
39  if (bp == NULL)
40  {
41  info=MPI_Pack_size(one, Dtype, ctxt->scp->comm, &i);
42  bp = BI_GetBuff(i);
43  }
44 
45  i = 0;
46  info=MPI_Pack(A, one, Dtype, bp->Buff, bp->Len, &i, ctxt->scp->comm);
47  bp->dtype = MPI_PACKED;
48  bp->N = i;
49 
50  return(bp);
51 }
BI_Pack
BLACBUFF * BI_Pack(BLACSCONTEXT *ctxt, BVOID *A, BLACBUFF *bp, MPI_Datatype Dtype)
Definition: BI_Pack.c:2
BUFFALIGN
#define BUFFALIGN
Definition: Bdef.h:75
BI_GetBuff
BLACBUFF * BI_GetBuff(int length)
Definition: BI_GetBuff.c:36
bLaCbUfF::Buff
char * Buff
Definition: Bdef.h:56
BVOID
#define BVOID
Definition: Bdef.h:136
bLaCbUfF::Len
int Len
Definition: Bdef.h:57
bLaCbUfF
Definition: Bdef.h:54
bLaCbUfF::N
int N
Definition: Bdef.h:61
bLaCbUfF::Aops
MPI_Request * Aops
Definition: Bdef.h:59
bLaCsCoNtExT
Definition: Bdef.h:23
BI_Np
int BI_Np
Definition: BI_GlobalVars.c:7
bLaCbUfF::nAops
int nAops
Definition: Bdef.h:58
bLaCsCoNtExT::scp
BLACSSCOPE * scp
Definition: Bdef.h:26
Bdef.h
bLaCsScOpE::comm
MPI_Comm comm
Definition: Bdef.h:15
BI_AuxBuff
BLACBUFF BI_AuxBuff
Definition: BI_GlobalVars.c:10
bLaCbUfF::dtype
MPI_Datatype dtype
Definition: Bdef.h:60
BLACBUFF
struct bLaCbUfF BLACBUFF
Definition: Bdef.h:53
BI_BlacsErr
void BI_BlacsErr(int ConTxt, int line, char *file, char *form,...)
Definition: BI_BlacsErr.c:3
BI_ContxtNum
int BI_ContxtNum(BLACSCONTEXT *ctxt)
Definition: BI_ContxtNum.c:3