Optimize communications with std::move to avoid data duplications
This commit is contained in:
parent
3fd610a08b
commit
d72afd64fb
2 changed files with 6 additions and 7 deletions
|
|
@ -112,7 +112,7 @@ void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::send(eoSelect<EOT>& _select)
|
||||||
// Convert pop to base pop
|
// Convert pop to base pop
|
||||||
eoPop<bEOT> baseMigPop;
|
eoPop<bEOT> baseMigPop;
|
||||||
for(auto& indi : migPop)
|
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;
|
//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())
|
if(!it->joinable())
|
||||||
sentMessages.erase(it);
|
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())
|
while (!listImigrants.empty())
|
||||||
{
|
{
|
||||||
//std::cout << "On reçoit dans l'île : " << listImigrants.size() << std::endl;
|
//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
|
// Convert objects from base to our objects type
|
||||||
eoPop<EOT> offspring;
|
eoPop<EOT> offspring;
|
||||||
for(auto& indi : base_offspring)
|
for(auto& indi : base_offspring)
|
||||||
offspring.push_back(convertFromBase(indi));
|
offspring.push_back(std::move(convertFromBase(indi)));
|
||||||
|
|
||||||
// Evaluate objects to integrate
|
// Evaluate objects to integrate
|
||||||
for(auto& indi : offspring)
|
for(auto& indi : offspring)
|
||||||
|
|
|
||||||
|
|
@ -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 we change when the algorithm is running, we need to recontruct the topo
|
||||||
if(running)
|
if(running)
|
||||||
{
|
{
|
||||||
std::cout << "Changing topology" << std::endl;
|
|
||||||
topo.construct(islands.size());
|
topo.construct(islands.size());
|
||||||
// If we change the topology during the algorithm, we need to isolate stopped islands
|
// If we change the topology during the algorithm, we need to isolate stopped islands
|
||||||
for(auto it : islands)
|
for(auto it : islands)
|
||||||
|
|
@ -152,9 +151,9 @@ void paradiseo::smp::IslandModel<EOT>::send(void)
|
||||||
std::vector<unsigned> neighbors = topo.getIdNeighbors(idFrom);
|
std::vector<unsigned> neighbors = topo.getIdNeighbors(idFrom);
|
||||||
|
|
||||||
// Send elements to neighbors
|
// Send elements to neighbors
|
||||||
eoPop<EOT> migPop = listEmigrants.front().first;
|
eoPop<EOT> migPop = std::move(listEmigrants.front().first);
|
||||||
for (unsigned idTo : neighbors)
|
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();
|
listEmigrants.pop();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue