Perfect forwarding for identity conversion functions. Add heterogeneous test (to clean and improve)
This commit is contained in:
parent
f67ee442c7
commit
5a4596862b
6 changed files with 233 additions and 15 deletions
|
|
@ -51,7 +51,7 @@ The abstract island is used to manipulate island pointers wihout the knowledge o
|
|||
@see smp::Island
|
||||
*/
|
||||
|
||||
template<class EOT>
|
||||
template<class bEOT>
|
||||
class AIsland
|
||||
{
|
||||
public:
|
||||
|
|
@ -61,9 +61,7 @@ public:
|
|||
/**
|
||||
* Check if there is population to receive
|
||||
*/
|
||||
virtual void setModel(IslandModel<EOT>* _model) = 0;
|
||||
|
||||
|
||||
virtual void setModel(IslandModel<bEOT>* _model) = 0;
|
||||
|
||||
/**
|
||||
* Check if there is population to receive or to emigrate
|
||||
|
|
@ -73,7 +71,7 @@ public:
|
|||
/**
|
||||
* Update the island by adding population to send in the imigrants list.
|
||||
*/
|
||||
virtual void update(eoPop<EOT> _data) = 0;
|
||||
virtual void update(eoPop<bEOT> _data) = 0;
|
||||
|
||||
/**
|
||||
* Check if the algorithm is stopped.
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
|
||||
template<template <class> class EOAlgo, class EOT, class bEOT>
|
||||
template<class... Args>
|
||||
paradiseo::smp::Island<EOAlgo,EOT,bEOT>::Island(std::function<EOT(bEOT&)> _convertFromBase, std::function<bEOT(EOT&)> _convertToBase, eoPop<EOT>& _pop, IntPolicy<EOT>& _intPolicy, MigPolicy<EOT>& _migPolicy, Args&... args) :
|
||||
paradiseo::smp::Island<EOAlgo,EOT,bEOT>::Island(std::function<EOT&&(bEOT&)> _convertFromBase, std::function<bEOT&&(EOT&)> _convertToBase, eoPop<EOT>& _pop, IntPolicy<EOT>& _intPolicy, MigPolicy<EOT>& _migPolicy, Args&... args) :
|
||||
// The PPExpander looks for the continuator in the parameters pack.
|
||||
// The private inheritance of ContWrapper wraps the continuator and add islandNotifier.
|
||||
ContWrapper<EOT, bEOT>(Loop<Args...>().template findValue<eoContinue<EOT>>(args...), this),
|
||||
|
|
@ -54,8 +54,8 @@ template<class... Args>
|
|||
paradiseo::smp::Island<EOAlgo,EOT,bEOT>::Island(eoPop<EOT>& _pop, IntPolicy<EOT>& _intPolicy, MigPolicy<EOT>& _migPolicy, Args&... args) :
|
||||
Island(
|
||||
// Default conversion functions for homogeneous islands
|
||||
[](bEOT& i) -> EOT { return (EOT)i; },
|
||||
[](EOT& i) -> bEOT { return (bEOT)i; },
|
||||
[](bEOT& i) -> EOT&& { return std::forward<EOT>(i); },
|
||||
[](EOT& i) -> bEOT&& { return std::forward<bEOT>(i); },
|
||||
_pop, _intPolicy, _migPolicy, args...)
|
||||
{ }
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::send(eoSelect<EOT>& _select)
|
|||
for(auto& indi : migPop)
|
||||
baseMigPop.push_back(convertToBase(indi));
|
||||
|
||||
std::cout << "On envoie de l'île : " << migPop << std::endl;
|
||||
//std::cout << "On envoie de l'île : " << migPop << std::endl;
|
||||
|
||||
// Delete delivered messages
|
||||
for(auto it = sentMessages.begin(); it != sentMessages.end(); it++)
|
||||
|
|
@ -131,7 +131,7 @@ void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::receive(void)
|
|||
std::lock_guard<std::mutex> lock(this->m);
|
||||
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();
|
||||
|
||||
// Convert objects from base to our objects type
|
||||
|
|
@ -152,7 +152,7 @@ void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::receive(void)
|
|||
template<template <class> class EOAlgo, class EOT, class bEOT>
|
||||
void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::update(eoPop<bEOT> _data)
|
||||
{
|
||||
std::cout << "On update dans l'île" << std::endl;
|
||||
//std::cout << "On update dans l'île" << std::endl;
|
||||
std::lock_guard<std::mutex> lock(this->m);
|
||||
listImigrants.push(_data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public:
|
|||
* @param args Parameters to construct the algorithm.
|
||||
*/
|
||||
template<class... Args>
|
||||
Island(std::function<EOT(bEOT&)> _convertFromBase, std::function<bEOT(EOT&)> _convertToBase, eoPop<EOT>& pop, IntPolicy<EOT>& _intPolicy, MigPolicy<EOT>& _migPolicy, Args&... args);
|
||||
Island(std::function<EOT&&(bEOT&)> _convertFromBase, std::function<bEOT&&(EOT&)> _convertToBase, eoPop<EOT>& pop, IntPolicy<EOT>& _intPolicy, MigPolicy<EOT>& _migPolicy, Args&... args);
|
||||
/**
|
||||
* Constructor
|
||||
* @param _popSize Size of the algorithm population.
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ template<class EOT>
|
|||
void paradiseo::smp::IslandModel<EOT>::update(eoPop<EOT> _data, AIsland<EOT>* _island)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
std::cout << "Mediateur reçoit ! " << _data << std::endl;
|
||||
//std::cout << "Mediateur reçoit ! " << _data << std::endl;
|
||||
listEmigrants.push(std::pair<eoPop<EOT>,AIsland<EOT>*>(_data, _island));
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ void paradiseo::smp::IslandModel<EOT>::send(void)
|
|||
std::lock_guard<std::mutex> lock(m);
|
||||
while (!listEmigrants.empty())
|
||||
{
|
||||
std::cout << "Mediator envoie ! " << listEmigrants.size() << std::endl;
|
||||
//std::cout << "Mediator envoie ! " << listEmigrants.size() << std::endl;
|
||||
// Get the neighbors
|
||||
unsigned idFrom = table.getLeft()[listEmigrants.front().second];
|
||||
std::vector<unsigned> neighbors = topo.getIdNeighbors(idFrom);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue