Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost.MPI] question about serializingcustomobject
From: Cristobal Navarro (axischire_at_[hidden])
Date: 2010-08-26 18:59:07


>
>
> Hmmm- what surrounds this?
>

-> there is more code part of an algorithm, but nothing important for the
example embedded.

>
> try
>
> {
> const class Lattice lat ...
> ...
> ar << lat
> }
>
> that might work better.
>
> Robert Ramey
>
thanks Robert, let me tell you about lat just in case i missed to point
something
lat was created this way
Lattice *lat = new Lattice("filename");
i thought that pointers passed to archive wasnt possible, thats why i did
"ao << *(this->lat);", and it actually worked when i removed edges. however
i also tried what yo suggested, and it also works without "edges", but
otherwise i get the same error.
this is updated code if i use class pointers

                printf("serializing to binlat.x...\n");
                //!file mode
                /*
                std::ofstream ofs("binlat.x", ios::binary);
                boost::archive::binary_oarchive oa(ofs);
                */
                oa << lat; //lat was created earlier at some point of the
program "Lattice *lat = new Lattice("filename")"
                ofs.close();
                lat->print(); //check what lattice im serializing
                //!Deserialization - read file binlat.x and reconstruct
                printf("reconstructing serialized binlat.x...\n");
                Lattice *nl;
                std::ifstream ifs("binlat.x", ios::binary);
                boost::archive::binary_iarchive ia(ifs);
                //!deserialize object
                ia >> nl;
                ifs.close();
                nl->print();

i had to change the receiving lattice to a class pointer too. in the end, it
also throws the same error when "edges" map is included on the
serialization.
i will keep trying different ideas to find the problem, in the meanwhile any
help is welcome.
by considering that when i remove "edges" from the serialization of Lattice
object it works, i suspect the problem comes from "edges" map or maybe from
the "Edge" class at a particular atribute.

>
>
> >
> >
> > i get bad errors when deserializing, complaining about a bool and
> > char.
> > serializing to binlat.x...
> > Lattice::print().....START
> > Nodes=2 Edges= 1
> > Node[0] sp=1 ext=1
> > Linked to edge 2 (Node 3 or 0 )
> > Node[3] sp=1 ext=2
> > Linked to edge 2 (Node 3 or 0 )
> > Lattice::print().....END
> > [enter]
> > reconstructing swerialized binlat.x...
> > [enter]
> > plattice:
> > /usr/local/include/boost/archive/basic_binary_iprimitive.hpp:98: void
> > boost::archive::basic_binary_iprimitive<Archive, Elem,
> > Tr>::load(bool&) [with Archive = boost::archive::binary_iarchive,
> > Elem = char, Tr = std::char_traits<char>]: Assertion `0 == i || 1 ==
> > i' failed.
> > [lenovo00:29384] *** Process received signal ***
> > [lenovo00:29384] Signal: Aborted (6)
> > [lenovo00:29384] Signal code: (-6)
> > [lenovo00:29384] [ 0] [0xfea410]
> > [lenovo00:29384] [ 1] /lib/tls/i686/cmov/libc.so.6(abort+0x182)
> > [0xd41a82]
> > [lenovo00:29384] [ 2]
> > /lib/tls/i686/cmov/libc.so.6(__assert_fail+0xf8) [0xd37718]
> > [lenovo00:29384] [ 3]
> > ..
> > ..
> > *** End of error message ***
> >
> >
> > i started debugging, and realized that the problem is completely gone
> > when i remove "edges" from the serialization members of "Lattice"
> > object.
> > its weird, because "edge" is a map of <int, Edge> and much simplier
> > than "nodes" which does work. obviously i cannot continue without
> > edges, so i need to fix it somehow, but i dont understand the error
> > related to edges, maybe is something im not seeing.
> >
> >
> > dont get distracted by the messy code, i had to edit it a little to
> > focus on the case.
> > regards
> > Cristobal
> >
> >
> >
> >
> >
> >
> > On Thu, Aug 26, 2010 at 4:35 PM, Robert Ramey <ramey_at_[hidden]> wrote:
> >
> >> Change the "would" into "is": it is possible to mix Boost.MPI with
> >> Boost.Serialization. Any objext that can be serialized can be sent by
> >> Boost.MPI. This was actually the basic idea behind Boost.MPI, to use
> >> Boost.Serialization to pack and unpack MPI buffers, or to create
> >> custom MPI datatypes.
> >
> > On thing that I never understood is why you need MPI data types at
> > all.
> > If one is serializing (packing) to a binary array, and sending that,
> > what
> > hae MPI data types have to do with it.
> >
> > If one were using heterogenious machines, I could understand the
> > usage of MPI types. But as I understand it, the MPI serialization
> > presumes
> > that the machines are binary compatible. So I'm just not seeing this.
> >
> > Robert Ramey
> >
> >
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users_at_[hidden]
> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users_at_[hidden]
> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net