George Reeke
2017-01-30 21:31:34 UTC
Dear colleagues,
I am trying MPI_Type_create_struct for the first time.
I want to combine a small structure (two ints) with a vector of
variable length to send in a single message. Here is a simplified
extract of the relevant C code. The MPI_Type_create_struct call
gives a segfault. The nearest I can see to what is wrong is that
the argument I called GHtyp has as its first element a small
integer (0x53) which the function ompi_datatype_create_struct
is trying to use as a pointer. But I thought I created it with
an MPI_Type_contiguous call:
/* The next three variables are passed in from other
* calculations and have reasonable values per gdb. */
char *pv = /* Pointer to my data array */
int lblk = /* Length of one element of my data array */
int nblks = /* Number of these blocks in the data vector */
MPI_Datatype MPHdr,MPBlk,MPPkt;
struct GHdr_t {
int odat, nblk; /* Code to set these values not shown */
} sGHdr;
int GHect[2] = { 1, 0 }; /* Second count inserted below */
MPI_Datatype GHtyp[2] = { MPHdr, MPBlk };
MPI_Aint GHoff[2];
/* Executable code */
MPI_Type_contiguous(2, MPI_UNSIGNED, &MPHdr);
MPI_Type_commit(&MPHdr);
MPI_Type_contiguous(lblk, MPI_UNSIGNED_CHAR, &MPBlk);
MPI_Type_commit(&MPBlk);
GHect[1] = nblks;
MPI_Get_address(pv, GHoff+1);
MPI_Get_address(&sGHdr, GHoff);
MPI_Type_create_struct(2, GHect, GHoff, GHtyp, &MPPkt);
----segfault on this call-never gets to the following commit----
Any suggestions would be most welcome.
Thanks,
George Reeke
I am trying MPI_Type_create_struct for the first time.
I want to combine a small structure (two ints) with a vector of
variable length to send in a single message. Here is a simplified
extract of the relevant C code. The MPI_Type_create_struct call
gives a segfault. The nearest I can see to what is wrong is that
the argument I called GHtyp has as its first element a small
integer (0x53) which the function ompi_datatype_create_struct
is trying to use as a pointer. But I thought I created it with
an MPI_Type_contiguous call:
/* The next three variables are passed in from other
* calculations and have reasonable values per gdb. */
char *pv = /* Pointer to my data array */
int lblk = /* Length of one element of my data array */
int nblks = /* Number of these blocks in the data vector */
MPI_Datatype MPHdr,MPBlk,MPPkt;
struct GHdr_t {
int odat, nblk; /* Code to set these values not shown */
} sGHdr;
int GHect[2] = { 1, 0 }; /* Second count inserted below */
MPI_Datatype GHtyp[2] = { MPHdr, MPBlk };
MPI_Aint GHoff[2];
/* Executable code */
MPI_Type_contiguous(2, MPI_UNSIGNED, &MPHdr);
MPI_Type_commit(&MPHdr);
MPI_Type_contiguous(lblk, MPI_UNSIGNED_CHAR, &MPBlk);
MPI_Type_commit(&MPBlk);
GHect[1] = nblks;
MPI_Get_address(pv, GHoff+1);
MPI_Get_address(&sGHdr, GHoff);
MPI_Type_create_struct(2, GHect, GHoff, GHtyp, &MPPkt);
----segfault on this call-never gets to the following commit----
Any suggestions would be most welcome.
Thanks,
George Reeke