On Mon, 2017-01-30 at 16:31 -0500, 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.

----code sample snipped, see original posting if interested----
> 
> Any suggestions would be most welcome.
> Thanks,
> George Reeke
> 
I just wanted to share with everyone a reply that I received offline
to my original posting.  Bottom line:  I needed to copy the result
of an MPI create type into handle lists where it was used, not just
put the name there.  In my case I was creating a structured type,
members of which were previously defined structure types.
(I have removed the name of the person who replied privately since
I do not know if posting it would be a problem.)
George Reeke

> Hi George,
> 
> George Reeke wrote on Tue, 31 Jan 2017 at 10:31:34
> 
> <snip...>
> 
> > MPI_Datatype GHtyp[2] = { MPHdr, MPBlk };
> 
> Note that GHtyp is initialized with uninitialized data in MPHdr and
MPBlk (i.e. garbage)
> 
> <snip...>
> > MPI_Type_contiguous(2, MPI_UNSIGNED, &MPHdr);
> 
> This sets MPHdr, but does not update GHtyp[0].  Replace '&MPHdr' with
'&GHtyp[0]'.
> 
> > MPI_Type_commit(&MPHdr);
> > MPI_Type_contiguous(lblk, MPI_UNSIGNED_CHAR, &MPBlk);
> 
> This sets MPBlk, but does not update GHtyp[1].  Replace '&MPBlk' with
'&GHtyp[1]'.
> 
> <snip...>
> > MPI_Type_create_struct(2, GHect, GHoff, GHtyp, &MPPkt);
> 
> GHtyp still contains garbage here, leading to your segfault.
> 


_______________________________________________
users mailing list
users@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/users

Reply via email to