Merge topology conflicts
This commit is contained in:
commit
56a72c2ff1
11 changed files with 105 additions and 46 deletions
|
|
@ -50,15 +50,21 @@ public :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a vector containing the index of nearby nodes according to the topology
|
* Return a vector containing the index of nearby nodes according to the topology
|
||||||
* @param idIsland index of the node of which you want the neighbors.
|
* @param idNode index of the node of which you want the neighbors.
|
||||||
*/
|
*/
|
||||||
virtual std::vector<unsigned> getIdNeighbors(unsigned idIsland) const = 0;
|
virtual std::vector<unsigned> getIdNeighbors(unsigned idIsland) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct or re-construct a topology with the given number of nodes.
|
* Construct or re-construct a topology with the given number of nodes.
|
||||||
* @param nbIsland number of nodes for the topology
|
* @param nbNode number of nodes for the topology
|
||||||
*/
|
*/
|
||||||
virtual void construct(unsigned nbIsland) = 0;
|
virtual void construct(unsigned nbNode) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Changes the topology : removes any connection from/to the given node.
|
||||||
|
*@param idNode index of the node to be isolated
|
||||||
|
*/
|
||||||
|
virtual void isolateNode(unsigned idNode) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,12 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <topology/complete.h>
|
#include <topology/complete.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
void paradiseo::smp::Complete::operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const
|
void paradiseo::smp::Complete::operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const
|
||||||
{
|
{
|
||||||
matrix.clear();
|
matrix.clear();
|
||||||
std::vector<bool> line;
|
std::vector<bool> line;
|
||||||
line.assign(nbIsland,true);
|
line.assign(nbNode,true);
|
||||||
matrix.assign(nbIsland, line);
|
matrix.assign(nbNode, line);
|
||||||
for(int i=0;i<nbIsland;i++)
|
for(int i=0;i<nbNode;i++)
|
||||||
matrix[i][i]=false;
|
matrix[i][i]=false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public :
|
||||||
/**
|
/**
|
||||||
*Fills the given matrix for a complete topology with the specified number of nodes.
|
*Fills the given matrix for a complete topology with the specified number of nodes.
|
||||||
*/
|
*/
|
||||||
void operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const;
|
void operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,13 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <topology/ring.h>
|
#include <topology/ring.h>
|
||||||
|
|
||||||
void paradiseo::smp::Ring::operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const
|
void paradiseo::smp::Ring::operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const
|
||||||
{
|
{
|
||||||
matrix.clear();
|
matrix.clear();
|
||||||
std::vector<bool> line;
|
std::vector<bool> line;
|
||||||
line.assign(nbIsland, false);
|
line.assign(nbNode, false);
|
||||||
matrix.assign(nbIsland, line);
|
matrix.assign(nbNode, line);
|
||||||
|
|
||||||
for(int i=0; i<nbIsland;i++)
|
for(int i=0; i<nbNode;i++)
|
||||||
matrix[i][(i+1)%nbIsland]=true;
|
matrix[i][(i+1)%nbNode]=true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public :
|
||||||
/**
|
/**
|
||||||
*Fills the given matrix for a ring topology with the specified number of nodes.
|
*Fills the given matrix for a ring topology with the specified number of nodes.
|
||||||
*/
|
*/
|
||||||
void operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const;
|
void operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,16 +30,16 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <topology/star.h>
|
#include <topology/star.h>
|
||||||
|
|
||||||
void paradiseo::smp::Star::operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const
|
void paradiseo::smp::Star::operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const
|
||||||
{
|
{
|
||||||
matrix.clear();
|
matrix.clear();
|
||||||
std::vector<bool> line (nbIsland,false);
|
std::vector<bool> line (nbNode,false);
|
||||||
|
|
||||||
line[0]=true;
|
line[0]=true;
|
||||||
matrix.assign(nbIsland-1,line);
|
matrix.assign(nbNode-1,line);
|
||||||
|
|
||||||
line.clear();
|
line.clear();
|
||||||
line.assign(nbIsland, false);
|
line.assign(nbNode, false);
|
||||||
std::vector<std::vector<bool>>::iterator it = matrix.begin();
|
std::vector<std::vector<bool>>::iterator it = matrix.begin();
|
||||||
matrix.insert(it, line);
|
matrix.insert(it, line);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public :
|
||||||
/**
|
/**
|
||||||
*Fills the given matrix for a star topology with the specified number of nodes.
|
*Fills the given matrix for a star topology with the specified number of nodes.
|
||||||
*/
|
*/
|
||||||
void operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const;
|
void operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,20 +28,32 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
template <class TopologyType>
|
template <class TopologyType>
|
||||||
std::vector<unsigned> paradiseo::smp::Topology<TopologyType>::getIdNeighbors(unsigned idIsland) const
|
std::vector<unsigned> paradiseo::smp::Topology<TopologyType>::getIdNeighbors(unsigned idNode) const
|
||||||
{
|
{
|
||||||
std::vector<unsigned> neighbors;
|
std::vector<unsigned> neighbors;
|
||||||
for(unsigned j=0; j<_matrix.size();j++)
|
for(unsigned j=0; j<_matrix.size();j++)
|
||||||
if(_matrix[idIsland][j]) neighbors.push_back(j);
|
if(_matrix[idNode][j]) neighbors.push_back(j);
|
||||||
|
|
||||||
return neighbors;
|
return neighbors;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class TopologyType>
|
template <class TopologyType>
|
||||||
void paradiseo::smp::Topology<TopologyType>::construct(unsigned nbIsland)
|
void paradiseo::smp::Topology<TopologyType>::construct(unsigned nbNode)
|
||||||
{
|
{
|
||||||
_builder(nbIsland, _matrix);
|
_builder(nbNode, _matrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TopologyType>
|
||||||
|
void paradiseo::smp::Topology<TopologyType>::isolateNode(unsigned idNode)
|
||||||
|
{
|
||||||
|
for(int i=0;i<_matrix.size();i++)
|
||||||
|
{
|
||||||
|
//Line of idNode to false : no connection FROM this node
|
||||||
|
_matrix[idNode][i] = false;
|
||||||
|
|
||||||
|
//Column of idNode to false : no connection TO this node
|
||||||
|
_matrix[i][idNode] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,13 +60,19 @@ public :
|
||||||
* Inherited from AbstractTopology
|
* Inherited from AbstractTopology
|
||||||
* @see smp::topology::AbstractTopology::getIdNeighbors
|
* @see smp::topology::AbstractTopology::getIdNeighbors
|
||||||
*/
|
*/
|
||||||
std::vector<unsigned> getIdNeighbors(unsigned idIsland) const;
|
std::vector<unsigned> getIdNeighbors(unsigned idNode) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inherited from AbstractTopology : construct or re-construct a topology with the given number of nodes
|
* Inherited from AbstractTopology : construct or re-construct a topology with the given number of nodes
|
||||||
* @param nbIsland number of nodes for the topology
|
* @param nbNode number of nodes for the topology
|
||||||
*/
|
*/
|
||||||
void construct(unsigned nbIsland);
|
void construct(unsigned nbNode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Inherited from AbstractTopology : changes the topology : removes any connection from/to the given node.
|
||||||
|
*@param idNode index of the node to be isolated
|
||||||
|
*/
|
||||||
|
void isolateNode(unsigned idNode);
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
<abstractIsland.h>
|
<abstractNode.h>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Alexandre Quemy, Thibault Lasnier - INSA Rouen
|
Alexandre Quemy, Thibault Lasnier - INSA Rouen
|
||||||
|
|
@ -48,7 +48,7 @@ public :
|
||||||
*Build th topology with the given number of nodes in the matrix.
|
*Build th topology with the given number of nodes in the matrix.
|
||||||
*@see smp::topology::Ring, smp::topology::Star, smp::topology::Complete
|
*@see smp::topology::Ring, smp::topology::Star, smp::topology::Complete
|
||||||
**/
|
**/
|
||||||
virtual void operator()(unsigned _nbIsland, std::vector<std::vector<bool>>& _matrix) const = 0;
|
virtual void operator()(unsigned _nbNode, std::vector<std::vector<bool>>& _matrix) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,70 +16,105 @@ int main()
|
||||||
Topology<Complete> topo_comp;
|
Topology<Complete> topo_comp;
|
||||||
topo_comp.construct(n);
|
topo_comp.construct(n);
|
||||||
|
|
||||||
std::cout << std::endl << "---------------" << std::endl << "Test of Complete Topology (" << n <<" islands) :"<<std::endl;
|
std::cout << std::endl << "---------------" << std::endl << "Test of Complete Topology (" << n <<" nodes) :"<<std::endl;
|
||||||
|
|
||||||
std::vector<unsigned> neighbors=topo_comp.getIdNeighbors(1);
|
std::vector<unsigned> neighbors=topo_comp.getIdNeighbors(1);
|
||||||
std::cout << "neighbors of Island 1 : "<<std::endl;
|
std::cout << "neighbors of Node 1 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
|
|
||||||
neighbors=topo_comp.getIdNeighbors(2);
|
neighbors=topo_comp.getIdNeighbors(2);
|
||||||
std::cout <<std::endl << "Neighbors of Island 2 : "<<std::endl;
|
std::cout <<std::endl << "Neighbors of Node 2 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
//Re-construct Topology with different number of islands
|
//Isolate an node
|
||||||
|
topo_comp.isolateNode(2);
|
||||||
|
neighbors=topo_comp.getIdNeighbors(2);
|
||||||
|
std::cout <<std::endl << "Neighbors of Node 2 after isolation : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
|
std::cout << " " << neighbors[i];
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
neighbors=topo_comp.getIdNeighbors(3);
|
||||||
|
std::cout <<"Neighbors of Node 3 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
|
std::cout << " " << neighbors[i];
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
//Re-construct Topology with different number of nodes
|
||||||
n=3;
|
n=3;
|
||||||
topo_comp.construct(n);
|
topo_comp.construct(n);
|
||||||
neighbors=topo_comp.getIdNeighbors(2);
|
neighbors=topo_comp.getIdNeighbors(2);
|
||||||
std::cout <<"Changing number of islands to "<< n <<" : "<<std::endl;
|
std::cout <<"Changing number of nodes to "<< n <<",";
|
||||||
std::cout <<std::endl << "Neighbors of Island 2 : "<<std::endl;
|
std::cout <<"Neighbors of Node 2 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//Test of Star Topology
|
//Test of Star Topology
|
||||||
n=4;
|
n=4;
|
||||||
Topology<Star> topo_star;
|
Topology<Star> topo_star;
|
||||||
topo_star.construct(n);
|
topo_star.construct(n);
|
||||||
|
|
||||||
std::cout << std::endl << "---------------" << std::endl << "Test of Star Topology (" << n <<" islands) :" << std::endl;
|
std::cout << std::endl << "---------------" << std::endl << "Test of Star Topology (" << n <<" nodes) :" << std::endl;
|
||||||
|
|
||||||
neighbors=topo_star.getIdNeighbors(0);
|
neighbors=topo_star.getIdNeighbors(0);
|
||||||
std::cout <<std::endl << "Neighbors of Island 0 : "<<std::endl;
|
std::cout <<std::endl << "Neighbors of Node 0 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
neighbors=topo_star.getIdNeighbors(1);
|
neighbors=topo_star.getIdNeighbors(1);
|
||||||
std::cout <<std::endl << "Neighbors of Island 1 : "<<std::endl;
|
std::cout <<std::endl << "Neighbors of Node 1 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//Test of Ring Topology
|
//Test of Ring Topology
|
||||||
n=8;
|
n=8;
|
||||||
Topology<Ring> topo_ring;
|
Topology<Ring> topo_ring;
|
||||||
topo_ring.construct(n);
|
topo_ring.construct(n);
|
||||||
|
|
||||||
std::cout << std::endl << "---------------" << std::endl << "Test of Ring Topology (" << n <<" islands) :" << std::endl;
|
std::cout << std::endl << "---------------" << std::endl << "Test of Ring Topology (" << n <<" nodes) :" << std::endl;
|
||||||
|
|
||||||
neighbors=topo_ring.getIdNeighbors(4);
|
neighbors=topo_ring.getIdNeighbors(4);
|
||||||
std::cout <<std::endl << "Neighbors of Island 4 : "<<std::endl;
|
std::cout <<std::endl << "Neighbors of Node 4 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
neighbors=topo_ring.getIdNeighbors(7);
|
neighbors=topo_ring.getIdNeighbors(7);
|
||||||
std::cout <<std::endl << "Neighbors of Island 7 : "<<std::endl;
|
std::cout <<std::endl << "Neighbors of Node 7 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
neighbors=topo_ring.getIdNeighbors(0);
|
neighbors=topo_ring.getIdNeighbors(0);
|
||||||
std::cout <<std::endl << "Neighbors of Island 0 : "<<std::endl;
|
std::cout <<std::endl << "Neighbors of Node 0 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue