Dear Gilles et al, You are correct. I solved the problem based on an email I got privately based on the same idea. I have just posted that private reply so the solution will be more widely known among us amateurs. Thanks, George Reeke
On Tue, 2017-01-31 at 09:07 +0900, Gilles Gouaillardet wrote: > George, > > > at first glance, it seems GHtyp is initialized too early with > > uninitialized types MPHdr and MPBlk. > > > can you try to initialize GHtyp *after* both types are commited ? > > > if it still does not work, could you please post a self contained and > simple reproducer ? > > > Cheers, > > > Gilles > > > On 1/31/2017 6:31 AM, George Reeke wrote: > > 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 > > > > > > > > > > > > _______________________________________________ > > users mailing list > > users@lists.open-mpi.org > > https://urldefense.proofpoint.com/v2/url?u=https-3A__rfd.newmexicoconsortium.org_mailman_listinfo_users&d=DwICAg&c=JeTkUgVztGMmhKYjxsy2rfoWYibK1YmxXez1G3oNStg&r=-0HYJje2XxONzoGLV3ECU5R_Z00xayE_1fNBml0KNOw&m=6jcjTW1w8vADLHM-UQbR1V8MmPVUF0b3eL0lVXih2FU&s=EW16AGT-1oxU0wl0DgK9ojoH4lfD4_UmrMCFGg8q7MM&e= > > > > > > _______________________________________________ > users mailing list > users@lists.open-mpi.org > https://urldefense.proofpoint.com/v2/url?u=https-3A__rfd.newmexicoconsortium.org_mailman_listinfo_users&d=DwICAg&c=JeTkUgVztGMmhKYjxsy2rfoWYibK1YmxXez1G3oNStg&r=-0HYJje2XxONzoGLV3ECU5R_Z00xayE_1fNBml0KNOw&m=6jcjTW1w8vADLHM-UQbR1V8MmPVUF0b3eL0lVXih2FU&s=EW16AGT-1oxU0wl0DgK9ojoH4lfD4_UmrMCFGg8q7MM&e= > _______________________________________________ users mailing list users@lists.open-mpi.org https://rfd.newmexicoconsortium.org/mailman/listinfo/users