i am currently evalutating a simple program that allows so scatter an array/vector of lines/strings over a number of processes. I have created a simple test program which i am not able to compile. I am hoping someone can help me finding a solution. Here is the program:
#include <boost/mpi.hpp>
#include <string>
#include <iostream>
#include <vector>
namespace mpi = boost::mpi;
int main(int argc, char* argv[])
{
mpi::environment env(argc, argv);
mpi::communicator world;
std::vector< std::vector < std::string > > all (3, std::vector < std::string >());
std::vector< std::string > mine;
if (world.rank() == 0) {
all[0].push_back("String1");
all[0].push_back("String2");
all[1].push_back("String3");
all[1].push_back("String4");
all[2].push_back("String5");
all[2].push_back("String6");
}
mpi::scatter(world, all, mine, 0);
for (int r = 0; r < world.size(); ++r) {
world.barrier();
if (r == world.rank()) {
std::cout << "Rank " << r << " got " << mine[0] << std::endl;
}
}
return 0;
}
i tried both of the following commands to compile it:
mpic++ scatter_mini.cpp -o scatter_mpi -lboost_mpi
mpic++ scatter_mini.cpp -o scatter_mpi -lboost_mpi -lboost_serialization
Both result in the same error which i give you here in a shortened version (in german sorry):
/usr/include/boost/serialization/access.hpp: In Instanziierung von »static void boost::serialization::access::serialize(Archive&, T&, unsigned int) [with Archive = boost::mpi::packed_iarchive; T = std::vector<std::__cxx11::basic_string<char> >]«:
/usr/include/boost/serialization/serialization.hpp:68:22: erfordert durch »void boost::serialization::serialize(Archive&, T&, unsigned int) [with Archive = boost::mpi::packed_iarchive; T = std::vector<std::__cxx11::basic_string<char> >]«
/usr/include/boost/serialization/serialization.hpp:118:14: erfordert durch »void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::mpi::packed_iarchive; T = std::vector<std::__cxx11::basic_string<char> >]«
/usr/include/boost/archive/detail/iserializer.hpp:187:40: erfordert durch »void boost::archive::detail::iserializer<Archive, T>::load_object_data(boost::archive::detail::basic_iarchive&, void*, unsigned int) const [with Archive = boost::mpi::packed_iarchive; T = std::vector<std::__cxx11::basic_string<char> >]«
/usr/include/boost/archive/detail/iserializer.hpp:121:1: erfordert durch »class boost::archive::detail::iserializer<boost::mpi::packed_iarchive, std::vector<std::__cxx11::basic_string<char> > >«
/usr/include/boost/archive/detail/iserializer.hpp:409:27: erfordert durch »static void boost::archive::detail::load_non_pointer_type<Archive>::load_standard::invoke(Archive&, const T&) [with T = std::vector<std::__cxx11::basic_string<char> >; Archive = boost::mpi::packed_iarchive]«
/usr/include/boost/archive/detail/iserializer.hpp:461:22: [ 5 Instanziierungskontexte werden übersprungen, »-ftemplate-backtrace-limit=0« zum Ausschalten verwenden ]
/usr/include/boost/archive/detail/interface_iarchive.hpp:68:36: erfordert durch »Archive& boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T = std::vector<std::__cxx11::basic_string<char> >; Archive = boost::mpi::packed_iarchive]«
/usr/include/boost/mpi/collectives/scatter.hpp:124:14: erfordert durch »void boost::mpi::detail::dispatch_scatter_sendbuf(const boost::mpi::communicator&, const buffer_type&, const std::vector<int>&, const T*, T*, int, int) [with T = std::vector<std::__cxx11::basic_string<char> >; boost::mpi::binary_buffer_oprimitive::buffer_type = std::vector<char, boost::mpi::allocator<char> >]«
/usr/include/boost/mpi/collectives/scatter.hpp:143:27: erfordert durch »void boost::mpi::detail::scatter_impl(const boost::mpi::communicator&, const T*, T*, int, int, mpl_::false_) [with T = std::vector<std::__cxx11::basic_string<char> >; mpl_::false_ = mpl_::bool_<false>]«
/usr/include/boost/mpi/collectives/scatter.hpp:159:23: erfordert durch »void boost::mpi::scatter(const boost::mpi::communicator&, const T*, T&, int) [with T = std::vector<std::__cxx11::basic_string<char> >]«
/usr/include/boost/mpi/collectives/scatter.hpp:168:27: erfordert durch »void boost::mpi::scatter(const boost::mpi::communicator&, const std::vector<T>&, T&, int) [with T = std::vector<std::__cxx11::basic_string<char> >]«
scatter_mini.cpp:28:35: von hier erfordert
/usr/include/boost/serialization/access.hpp:116:11: Fehler: »class std::vector<std::__cxx11::basic_string<char> >« hat kein Element namens »serialize«
I am pretty sure i have all the necessary packages installed, i also can compile other boost mpi programs, especially those from the boost mpi tutorials/examples.
Your code is missing necessary headers. Try adding: