2

I have a distributed boost::numeric::ublas::vector distributed_boost_vector and i would like to gather in the root processor the whole distributed boost vector. I am trying to use the function:

template<typename T> 
void gather(const communicator & comm, const T & in_value, T * out_values, 
          int root);

writing

boost::mpi::gather<boost::numeric::ublas::vector<double> >
  (boost_comm, distributed_boost_vector, all_boost_vector, 0);

where all_boost_vector is a boost::numeric::ublas::vector

I receive "no matching function for call" error in compilation, why?

1 Answers1

1

The most relevant overloads are:

void gather( const boost::mpi::communicator &comm, const T &in_value, T *out_values, int root )
void gather( const boost::mpi::communicator &comm, const T &in_value, int root )
void gather( const boost::mpi::communicator &comm, const T &in_value, std::vector<T> &out_values, int root )

So either pass by pointer:

boost::mpi::gather(boost_comm, distributed_boost_vector, &all_boost_vector, 0);

Or pass std::vector for out_values:

std::vector<ublasv> out_values;
boost::mpi::gather(boost_comm, distributed_boost_vector, out_values, 0);

Live On Coliru

#include <boost/numeric/ublas/vector.hpp>
#include <boost/mpi/collectives/gather.hpp>
#include <iostream>

int main() {
    boost::mpi::communicator boost_comm;
    typedef boost::numeric::ublas::vector<double> ublasv;

    ublasv distributed_boost_vector, all_boost_vector;
    boost::mpi::gather(boost_comm, distributed_boost_vector, &all_boost_vector, 0);

    std::vector<ublasv> out_values;
    boost::mpi::gather(boost_comm, distributed_boost_vector, out_values, 0);
}
sehe
  • 374,641
  • 47
  • 450
  • 633
  • The compiler now gives: main.o: In function `__tcf_10': main.cpp:(.text+0xfd9): undefined reference to `boost::serialization::extended_type_info::key_unregister() const' main.cpp:(.text+0xfe3): undefined reference to `boost::serialization::typeid_system::extended_type_info_typeid_0::type_unregister()' main.cpp:(.text+0xffb): undefined reference to `boost::serialization::typeid_system::extended_type_info_typeid_0::~extended_type_info_typeid_0()' main.o: In function `__tcf_5':....and so on. It seems that it does not recognize the ublasv as a serializable vector – Antonella Longo Dec 30 '14 at 07:13
  • @AntonellaLongo that's a linker error. It did link with me. Did you link to the necessary libraries? Add `-pthread -lboost_system -lboost_serialization` and possibly more (mpi, boost_thread etc) – sehe Dec 30 '14 at 12:14
  • I have the boost installed not in /usr/lib, but is /home/boost (i do not have root access), so how can i add those libraries? I also use an automake system to configure and make my library, where should i add the names of the other libraries that you suggest? – Antonella Longo Dec 30 '14 at 12:44
  • @AntonellaLongo I'm not an expert in autotools. You should ask your project lead - or the one who set that up. Regarding linking to a custom version see **[here](http://stackoverflow.com/a/22313790/85371)** or **[here](http://stackoverflow.com/a/22905480/85371)** e.g. You can always ask another question about your build tool setup, perhaps. – sehe Dec 30 '14 at 13:07