Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6870509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:41:32+00:00 2026-05-27T03:41:32+00:00

It seems that sending stl complex data via the skeleton/content mechanism does not work.

  • 0

It seems that sending stl complex data via the skeleton/content
mechanism does not work.

Here is a simple code that shows the problem:

#include <boost/mpi.hpp>
#include <boost/serialization/complex.hpp>
#include <boost/serialization/vector.hpp>
#include <iostream>
namespace mpi = boost::mpi;
using namespace std;

int main(int argc, char* argv[])
{
     mpi::environment env(argc, argv);
     mpi::communicator world;
     int NN=world.size();
     int myid=world.rank();

     if (myid == 0)
     {
         int N = 10;
         vector <complex<double> > l(N);
         for (int p=1; p!=NN; p++)
             {
             int taskid=1;
             world.send(p, 0, taskid);
             world.send(p, 1, mpi::skeleton(l));
         }
         mpi::content c = mpi::get_content(l);
             for (int n = 0; n!=l.size() ; n++)
         {
             l[n]=complex<double>(1.0,1.0);
         }
         for (int p=1; p!=NN; p++)
         {
                 world.send(p, 1, c);
         }
     }
     else if (myid == 2)
     {
         vector <complex<double> > l;
         mpi::content c;
         world.recv(0, 1, mpi::skeleton(l));
         c = mpi::get_content(l);
         world.recv(0, 1, c);
         for (int n=0; n!=l.size(); n++)
         {
                 cout << l[n] << " ";
         }
         cout << endl;
     }
} 

The entries of the vector l on the output are not (1.0,1.0) but they seem to be
uninitialized. This only occurs if one uses complex data types AND
the skeleton/content mechanism.

Does anyone know, if this is a build
in problem, or if I am doing something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:41:33+00:00Added an answer on May 27, 2026 at 3:41 am

    I ran into a similar problem with one of my classes recently, and after some stepping through the serialization procedure in the debugger, I think I figured out what’s going on. The problem is using temporaries in the serialization operators. In boost/serialization/complex.hpp, the serialization functions look like this:

    template<class Archive, class T>
    inline void save(
        Archive & ar,
        std::complex< T > const & t,
        const unsigned int /* file_version */
    ){
        const T re = t.real();
        const T im = t.imag();
        ar << boost::serialization::make_nvp("real", re);
        ar << boost::serialization::make_nvp("imag", im);
    }
    
    template<class Archive, class T>
    inline void load(
        Archive & ar,
        std::complex< T >& t,
        const unsigned int /* file_version */ 
    ){
        T re;
        T im;
        ar >> boost::serialization::make_nvp("real", re);
        ar >> boost::serialization::make_nvp("imag", im);
        t = std::complex< T >(re,im);
    }
    

    Notice that the serialization is done through temporaries. The get_content functionality works by building an MPI datatype, which really is a map of the locations of content in memory. When receiving the message, MPI copies the data directly into those locations, without calling any serialization operators. The problem is that when “save” uses temporaries, get_content() won’t get the locations of the actual data but the temporaries, so the data received is not put into the right place.

    For the skeleton/content functionality to work, my impression is that the save function (which is what get_content() calls) must directly, and only, serialize the data members of the object. In this case it can’t, because it doesn’t have access to the internal representation of complex. One would have to write the serialization operators as members of the class, I think.

    (These limitations appear to not be mentioned at all in the Boost::MPI documentation.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seems that requirements on safety do not seem to like systems that use AI
From reading a few questions and answers here, it seems that a telnet stream
It appears that the HEAD requests I'm sending via jQuery's $.ajax({...}); method, are returning
We are facing a strange issue while sending email. It seems that the new
We're working on an app that streams a large amount of data out via
When I sent a mail using System.Net.Mail, it seems that the messages do not
I have a background thread that is sending data about the application's current status
Seems that even after unchecking the option in the PyDev/Debug preferenecs pane to launch
It seems that a List object cannot be stored in a List variable in
It seems that it is impossible to capture the keyboard event normally used for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.