Optimize communications with std::move to avoid data duplications

This commit is contained in:
quemy 2012-12-09 22:21:17 +01:00
commit d72afd64fb
2 changed files with 6 additions and 7 deletions

View file

@ -112,7 +112,7 @@ void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::send(eoSelect<EOT>& _select)
// Convert pop to base pop
eoPop<bEOT> baseMigPop;
for(auto& indi : migPop)
baseMigPop.push_back(convertToBase(indi));
baseMigPop.push_back(std::move(convertToBase(indi)));
//std::cout << "On envoie de l'île : " << migPop << std::endl;
@ -121,7 +121,7 @@ void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::send(eoSelect<EOT>& _select)
if(!it->joinable())
sentMessages.erase(it);
sentMessages.push_back(std::thread(&IslandModel<bEOT>::update, model, baseMigPop, this));
sentMessages.push_back(std::thread(&IslandModel<bEOT>::update, model, std::move(baseMigPop), this));
}
}
@ -132,12 +132,12 @@ void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::receive(void)
while (!listImigrants.empty())
{
//std::cout << "On reçoit dans l'île : " << listImigrants.size() << std::endl;
eoPop<bEOT> base_offspring = listImigrants.front();
eoPop<bEOT> base_offspring = std::move(listImigrants.front());
// Convert objects from base to our objects type
eoPop<EOT> offspring;
for(auto& indi : base_offspring)
offspring.push_back(convertFromBase(indi));
offspring.push_back(std::move(convertFromBase(indi)));
// Evaluate objects to integrate
for(auto& indi : offspring)

View file

@ -131,7 +131,6 @@ void paradiseo::smp::IslandModel<EOT>::setTopology(AbstractTopology& _topo)
// If we change when the algorithm is running, we need to recontruct the topo
if(running)
{
std::cout << "Changing topology" << std::endl;
topo.construct(islands.size());
// If we change the topology during the algorithm, we need to isolate stopped islands
for(auto it : islands)
@ -152,9 +151,9 @@ void paradiseo::smp::IslandModel<EOT>::send(void)
std::vector<unsigned> neighbors = topo.getIdNeighbors(idFrom);
// Send elements to neighbors
eoPop<EOT> migPop = listEmigrants.front().first;
eoPop<EOT> migPop = std::move(listEmigrants.front().first);
for (unsigned idTo : neighbors)
sentMessages.push_back(std::thread(&AIsland<EOT>::update, table.getRight()[idTo], migPop));
sentMessages.push_back(std::thread(&AIsland<EOT>::update, table.getRight()[idTo], std::move(migPop)));
listEmigrants.pop();
}