Hypercubic
This commit is contained in:
parent
ae4699176f
commit
bc769718d6
8 changed files with 238 additions and 75 deletions
|
|
@ -1,7 +1,4 @@
|
|||
#include <topology/topology.h>
|
||||
#include <topology/complete.h>
|
||||
#include <topology/star.h>
|
||||
#include <topology/ring.h>
|
||||
#include <smp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -10,82 +7,86 @@ using namespace paradiseo::smp;
|
|||
int main()
|
||||
{
|
||||
int n;
|
||||
std::vector<unsigned> value;
|
||||
|
||||
//Test of Complete Topology
|
||||
n=5;
|
||||
Topology<Complete> topo_comp;
|
||||
topo_comp.construct(n);
|
||||
|
||||
std::cout << std::endl << "---------------" << std::endl << "Test of Complete Topology (" << n <<" nodes) :"<<std::endl;
|
||||
|
||||
std::vector<unsigned> neighbors=topo_comp.getIdNeighbors(1);
|
||||
std::cout << "neighbors of Node 1 : "<<std::endl;
|
||||
if(neighbors.empty())
|
||||
std::cout <<"None";
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
|
||||
std::vector<unsigned> neighbors = topo_comp.getIdNeighbors(1);
|
||||
|
||||
value.clear();
|
||||
value.push_back(0);
|
||||
value.push_back(2);
|
||||
value.push_back(3);
|
||||
value.push_back(4);
|
||||
assert(neighbors == value);
|
||||
|
||||
neighbors=topo_comp.getIdNeighbors(2);
|
||||
std::cout <<std::endl << "Neighbors of Node 2 : "<<std::endl;
|
||||
if(neighbors.empty())
|
||||
std::cout <<"None";
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
std::cout << std::endl;
|
||||
|
||||
|
||||
value.clear();
|
||||
value.push_back(0);
|
||||
value.push_back(1);
|
||||
value.push_back(3);
|
||||
value.push_back(4);
|
||||
assert(neighbors == value);
|
||||
|
||||
//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;
|
||||
|
||||
assert(neighbors.empty());
|
||||
|
||||
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;
|
||||
|
||||
|
||||
value.clear();
|
||||
value.push_back(0);
|
||||
value.push_back(1);
|
||||
value.push_back(4);
|
||||
assert(neighbors == value);
|
||||
|
||||
//Re-construct Topology with different number of nodes
|
||||
n=3;
|
||||
topo_comp.construct(n);
|
||||
neighbors=topo_comp.getIdNeighbors(2);
|
||||
std::cout <<"Changing number of nodes to "<< n <<",";
|
||||
std::cout <<"Neighbors of Node 2 : "<<std::endl;
|
||||
if(neighbors.empty())
|
||||
std::cout <<"None";
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
std::cout << std::endl;
|
||||
|
||||
|
||||
value.clear();
|
||||
value.push_back(0);
|
||||
value.push_back(1);
|
||||
assert(neighbors == value);
|
||||
|
||||
n=8;
|
||||
topo_comp.construct(n);
|
||||
neighbors = topo_comp.getIdNeighbors(3);
|
||||
|
||||
value.clear();
|
||||
value.push_back(0);
|
||||
value.push_back(1);
|
||||
value.push_back(2);
|
||||
value.push_back(4);
|
||||
value.push_back(5);
|
||||
value.push_back(6);
|
||||
value.push_back(7);
|
||||
assert(neighbors == value);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//Test of Star Topology
|
||||
n=4;
|
||||
Topology<Star> topo_star;
|
||||
topo_star.construct(n);
|
||||
|
||||
std::cout << std::endl << "---------------" << std::endl << "Test of Star Topology (" << n <<" nodes) :" << std::endl;
|
||||
|
||||
neighbors=topo_star.getIdNeighbors(0);
|
||||
std::cout <<std::endl << "Neighbors of Node 0 : "<<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_star.getIdNeighbors(0);
|
||||
|
||||
value.clear();
|
||||
assert(neighbors == value);
|
||||
|
||||
neighbors=topo_star.getIdNeighbors(1);
|
||||
std::cout <<std::endl << "Neighbors of Node 1 : "<<std::endl;
|
||||
if(neighbors.empty())
|
||||
std::cout <<"None";
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
std::cout << std::endl;
|
||||
|
||||
value.clear();
|
||||
value.push_back(0);
|
||||
assert(neighbors == value);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//Test of Ring Topology
|
||||
|
|
@ -93,29 +94,54 @@ int main()
|
|||
Topology<Ring> topo_ring;
|
||||
topo_ring.construct(n);
|
||||
|
||||
std::cout << std::endl << "---------------" << std::endl << "Test of Ring Topology (" << n <<" nodes) :" << std::endl;
|
||||
|
||||
neighbors=topo_ring.getIdNeighbors(4);
|
||||
std::cout <<std::endl << "Neighbors of Node 4 : "<<std::endl;
|
||||
if(neighbors.empty())
|
||||
std::cout <<"None";
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
std::cout << std::endl;
|
||||
|
||||
value.clear();
|
||||
value.push_back(5);
|
||||
assert(neighbors == value);
|
||||
|
||||
neighbors=topo_ring.getIdNeighbors(7);
|
||||
std::cout <<std::endl << "Neighbors of Node 7 : "<<std::endl;
|
||||
if(neighbors.empty())
|
||||
std::cout <<"None";
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
std::cout << std::endl;
|
||||
|
||||
value.clear();
|
||||
value.push_back(0);
|
||||
assert(neighbors == value);
|
||||
|
||||
neighbors=topo_ring.getIdNeighbors(0);
|
||||
std::cout <<std::endl << "Neighbors of Node 0 : "<<std::endl;
|
||||
if(neighbors.empty())
|
||||
std::cout <<"None";
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
std::cout << std::endl;
|
||||
|
||||
value.clear();
|
||||
value.push_back(1);
|
||||
assert(neighbors == value);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//Test of Hypercubic Topology
|
||||
n=2;
|
||||
Topology<Hypercubic> topo_hyper;
|
||||
topo_hyper.construct(n);
|
||||
|
||||
neighbors=topo_hyper.getIdNeighbors(0);
|
||||
|
||||
value.clear();
|
||||
value.push_back(1);
|
||||
assert(neighbors == value);
|
||||
|
||||
n=4;
|
||||
topo_hyper.construct(n);
|
||||
|
||||
neighbors=topo_hyper.getIdNeighbors(1);
|
||||
|
||||
value.clear();
|
||||
value.push_back(0);
|
||||
value.push_back(3);
|
||||
assert(neighbors == value);
|
||||
|
||||
n=8;
|
||||
topo_hyper.construct(n);
|
||||
|
||||
neighbors=topo_hyper.getIdNeighbors(5);
|
||||
|
||||
value.clear();
|
||||
value.push_back(1);
|
||||
value.push_back(4);
|
||||
value.push_back(7);
|
||||
assert(neighbors == value);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue