diff --git a/smp/src/topology/abstractTopology.h b/smp/src/topology/abstractTopology.h index 153573e9b..38020d3c8 100644 --- a/smp/src/topology/abstractTopology.h +++ b/smp/src/topology/abstractTopology.h @@ -35,10 +35,28 @@ namespace paradiseo namespace smp { +/** AbstractTopology: The Abstract Topology defines what is necessary to any topology. +In order to know a topology, we just need to know how to construct it and what are the neighbors of each node, regardless of the type of topology (boolean or stochastic). + +@see smp::topology::Topology, smp::topology::TopologyBuilder + +*/ + class AbstractTopology { -public : +public : + + /** + * 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. + */ virtual std::vector getIdNeighbors(unsigned idIsland) const =0; + + /** + * Construct or re-construct a topology with the given number of nodes. + * @param nbIsland number of nodes for the topology + */ + virtual void construct(unsigned nbIsland) =0; }; } diff --git a/smp/src/topology/booleanTopology.cpp b/smp/src/topology/booleanTopology.cpp deleted file mode 100644 index 45b933f15..000000000 --- a/smp/src/topology/booleanTopology.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012 - -Alexandre Quemy, Thibault Lasnier - INSA Rouen - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr -*/ - - -#include - -template -paradiseo::smp::BooleanTopology::BooleanTopology(unsigned nbIsland) -{ - TopologyType builder; - builder(nbIsland, _matrix); -} -template -std::vector paradiseo::smp::BooleanTopology::getIdNeighbours(unsigned idIsland) const -{ - std::vector neighbours; - for(unsigned j=0; j<_matrix.size();j++) - if(_matrix[idIsland][j]) neighbours.push_back(j); - - return neighbours; -} diff --git a/smp/src/topology/booleanTopology.h b/smp/src/topology/booleanTopology.h deleted file mode 100644 index 9536a04c6..000000000 --- a/smp/src/topology/booleanTopology.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012 - -Alexandre Quemy, Thibault Lasnier - INSA Rouen - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr -*/ - -#include -#include - -namespace paradiseo -{ -namespace smp -{ - -template -class BooleanTopology : public AbstractTopology -{ - -public : - BooleanTopology(unsigned nbIsland); - - std::vector getIdNeighbours(unsigned idIsland) const; - -private : - std::vector> _matrix; -}; - -#include - -} - -} diff --git a/smp/src/topology/complete.h b/smp/src/topology/complete.h index 612284afb..44a773963 100644 --- a/smp/src/topology/complete.h +++ b/smp/src/topology/complete.h @@ -37,9 +37,15 @@ namespace paradiseo namespace smp { +/** +*Complete: Inherit from TopologyBuilder. Reprents a builder for a complete topology : each node has every other node for neighor. +*/ class Complete: public TopologyBuilder { public : + /** + *Fills the given matrix for a complete topology with the specified number of nodes. + */ void operator()(unsigned nbIsland, std::vector>& matrix) const; }; diff --git a/smp/src/topology/completeTopologyBuilder.cpp b/smp/src/topology/completeTopologyBuilder.cpp deleted file mode 100644 index 18556a184..000000000 --- a/smp/src/topology/completeTopologyBuilder.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012 - -Alexandre Quemy, Thibault Lasnier - INSA Rouen - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr -*/ - -#include -#include - -void paradiseo::smp::CompleteTopologyBuilder::operator()(unsigned nbIsland, std::vector>& matrix) const -{ - matrix.clear(); - std::vector line; - line.assign(nbIsland,true); - matrix.assign(nbIsland, line); - for(int i=0;i -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012 - -Alexandre Quemy, Thibault Lasnier - INSA Rouen - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr -*/ -#ifndef COMPLETE_TOPO_BUILDER_H_ -#define COMPLETE_TOPO_BUILDER_H_ - -#include -#include - -namespace paradiseo -{ -namespace smp -{ - -class CompleteTopologyBuilder: public TopologyBuilder -{ -public : - void operator()(unsigned nbIsland, std::vector>& matrix) const; -}; - -} - -} - -#endif diff --git a/smp/src/topology/ring.h b/smp/src/topology/ring.h index 9bb0c43f7..9cf34a7f3 100644 --- a/smp/src/topology/ring.h +++ b/smp/src/topology/ring.h @@ -38,10 +38,16 @@ namespace paradiseo namespace smp { +/** +*Ring: Inherit from TopologyBuilder. Reprents a builder for a complete topology : each node has the next node for neighor. The last node is connected to the first. +*/ class Ring : public TopologyBuilder { public : - void operator()(unsigned nbIsland, std::vector>& matrix) const; + /** + *Fills the given matrix for a ring topology with the specified number of nodes. + */ + void operator()(unsigned nbIsland, std::vector>& matrix) const; }; } diff --git a/smp/src/topology/ringTopologyBuilder.cpp b/smp/src/topology/ringTopologyBuilder.cpp deleted file mode 100644 index ad21d51f2..000000000 --- a/smp/src/topology/ringTopologyBuilder.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012 - -Alexandre Quemy, Thibault Lasnier - INSA Rouen - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr -*/ - -#include -#include -#include - -void paradiseo::smp::RingTopologyBuilder::operator()(unsigned nbIsland, std::vector>& matrix) const -{ - matrix.clear(); - std::vector line; - line.assign(nbIsland, false); - matrix.assign(nbIsland, line); - - for(int i=0; i -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012 - -Alexandre Quemy, Thibault Lasnier - INSA Rouen - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr -*/ - -#ifndef RING_TOPO_BUILDER_H_ -#define RING_TOPO_BUILDER_H_ - -#include -#include - -namespace paradiseo -{ -namespace smp -{ - -class RingTopologyBuilder : public TopologyBuilder -{ -public : - void operator()(unsigned nbIsland, std::vector>& matrix) const; -}; - -} - -} - -#endif diff --git a/smp/src/topology/star.h b/smp/src/topology/star.h index 2fccdb8b4..d79bf091d 100644 --- a/smp/src/topology/star.h +++ b/smp/src/topology/star.h @@ -38,9 +38,15 @@ namespace paradiseo namespace smp { +/** +*Star: Inherit from TopologyBuilder. Reprents a builder for a star topology : each node excepted the first has every other node for neighor. The first node doesn't have any neighbor. +*/ class Star : public TopologyBuilder { public : + /** + *Fills the given matrix for a star topology with the specified number of nodes. + */ void operator()(unsigned nbIsland, std::vector>& matrix) const; }; diff --git a/smp/src/topology/starTopologyBuilder.cpp b/smp/src/topology/starTopologyBuilder.cpp deleted file mode 100644 index a2c723289..000000000 --- a/smp/src/topology/starTopologyBuilder.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012 - -Alexandre Quemy, Thibault Lasnier - INSA Rouen - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr -*/ - -#include -#include -#include - -void paradiseo::smp::StarTopologyBuilder::operator()(unsigned nbIsland, std::vector>& matrix) const -{ - matrix.clear(); - std::vector line (nbIsland,false); - - line[0]=true; - matrix.assign(nbIsland-1,line); - - line.clear(); - line.assign(nbIsland, false); - std::vector>::iterator it = matrix.begin(); - matrix.insert(it, line); -} diff --git a/smp/src/topology/starTopologyBuilder.h b/smp/src/topology/starTopologyBuilder.h deleted file mode 100644 index c00e4d373..000000000 --- a/smp/src/topology/starTopologyBuilder.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012 - -Alexandre Quemy, Thibault Lasnier - INSA Rouen - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr -*/ - -#ifndef STAR_TOPO_BUILDER_H_ -#define STAR_TOPO_BUILDER_H_ - -#include -#include - -namespace paradiseo -{ -namespace smp -{ - -class StarTopologyBuilder : public TopologyBuilder -{ -public : - void operator()(unsigned nbIsland, std::vector>& matrix) const; -}; - -} - -} - -#endif diff --git a/smp/src/topology/topology.h b/smp/src/topology/topology.h index 15df0321f..d159a9309 100644 --- a/smp/src/topology/topology.h +++ b/smp/src/topology/topology.h @@ -35,16 +35,38 @@ namespace paradiseo namespace smp { +/** +Topology : Inherit from AbstractTopology and must be templated with the type of Topology (e.g : Ring, Star...) +It represents the boolean topology, and cannot be used for Stochastic topology. + +@see smp::topology::AbstractTopology +*/ + template class Topology : public AbstractTopology { public : + + /** + * Default constructor + */ Topology() = default; + + /** + * Inherited from AbstractTopology + * @see smp::topology::AbstractTopology::getIdNeighbors + */ std::vector getIdNeighbors(unsigned idIsland) const; + + /** + * Inherited from AbstractTopology : construct or re-construct a topology with the given number of nodes + * @param nbIsland number of nodes for the topology + */ void construct(unsigned nbIsland); private : + TopologyType _builder; std::vector> _matrix; }; diff --git a/smp/src/topology/topologyBuilder.h b/smp/src/topology/topologyBuilder.h index 427d969bd..cf91b2b01 100644 --- a/smp/src/topology/topologyBuilder.h +++ b/smp/src/topology/topologyBuilder.h @@ -37,9 +37,17 @@ namespace paradiseo namespace smp { +/** TopologyBuilder: abstract class to build any boolean topology with a particular structure. +*/ + class TopologyBuilder { public : + + /** + *Build th topology with the given number of nodes in the matrix. + *@see smp::topology::Ring, smp::topology::Star, smp::topology::Complete + **/ virtual void operator()(unsigned _nbIsland, std::vector>& _matrix) const = 0; }; diff --git a/smp/test/t-smpTopo.cpp b/smp/test/t-smpTopo.cpp index 0d6101358..68a52cc2a 100644 --- a/smp/test/t-smpTopo.cpp +++ b/smp/test/t-smpTopo.cpp @@ -9,11 +9,14 @@ using namespace paradiseo::smp; int main() { - //Test of Complete Topology - Topology topo_comp; - topo_comp.construct(5); + int n; - std::cout << std::endl << "---------------" << std::endl << "Test of Complete Topology" << std::endl; + //Test of Complete Topology + n=5; + Topology topo_comp; + topo_comp.construct(n); + + std::cout << std::endl << "---------------" << std::endl << "Test of Complete Topology (" << n <<" islands) :"< neighbors=topo_comp.getIdNeighbors(1); std::cout << "neighbors of Island 1 : "< topo_star; - topo_star.construct(4); + topo_star.construct(n); - std::cout << std::endl << "---------------" << std::endl << "Test of Star Topology" << std::endl; + std::cout << std::endl << "---------------" << std::endl << "Test of Star Topology (" << n <<" islands) :" << std::endl; neighbors=topo_star.getIdNeighbors(0); std::cout < topo_ring; - topo_ring.construct(8); + topo_ring.construct(n); - std::cout << std::endl << "---------------" << std::endl << "Test of Ring Topology" << std::endl; + std::cout << std::endl << "---------------" << std::endl << "Test of Ring Topology (" << n <<" islands) :" << std::endl; neighbors=topo_ring.getIdNeighbors(4); std::cout <