From 0a7636e5853293053d1a4b0826811652ce442f15 Mon Sep 17 00:00:00 2001 From: lasnier Date: Mon, 19 Nov 2012 20:40:01 +0100 Subject: [PATCH 1/2] Change class name for clarity --- smp/src/CMakeLists.txt | 8 ++--- smp/src/topology/complete.cpp | 41 +++++++++++++++++++++++++ smp/src/topology/complete.h | 50 +++++++++++++++++++++++++++++++ smp/src/topology/ring.cpp | 43 +++++++++++++++++++++++++++ smp/src/topology/ring.h | 51 +++++++++++++++++++++++++++++++ smp/src/topology/star.cpp | 46 ++++++++++++++++++++++++++++ smp/src/topology/star.h | 51 +++++++++++++++++++++++++++++++ smp/src/topology/topology.cpp | 47 +++++++++++++++++++++++++++++ smp/src/topology/topology.h | 56 +++++++++++++++++++++++++++++++++++ 9 files changed, 389 insertions(+), 4 deletions(-) create mode 100644 smp/src/topology/complete.cpp create mode 100644 smp/src/topology/complete.h create mode 100644 smp/src/topology/ring.cpp create mode 100644 smp/src/topology/ring.h create mode 100644 smp/src/topology/star.cpp create mode 100644 smp/src/topology/star.h create mode 100644 smp/src/topology/topology.cpp create mode 100644 smp/src/topology/topology.h diff --git a/smp/src/CMakeLists.txt b/smp/src/CMakeLists.txt index 500869899..ab7a306e4 100644 --- a/smp/src/CMakeLists.txt +++ b/smp/src/CMakeLists.txt @@ -21,11 +21,11 @@ set (SMP_FILE scheduler.h island.h topology/abstractTopology.h - topology/booleanTopology.h + topology/topology.h topology/topologyBuilder.h - topology/completeTopologyBuilder.cpp - topology/starTopologyBuilder.cpp - topology/ringTopologyBuilder.cpp + topology/complete.cpp + topology/star.cpp + topology/ring.cpp ) add_library(smp STATIC ${SMP_FILE}) diff --git a/smp/src/topology/complete.cpp b/smp/src/topology/complete.cpp new file mode 100644 index 000000000..0f769b22b --- /dev/null +++ b/smp/src/topology/complete.cpp @@ -0,0 +1,41 @@ +/* + +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::Complete::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_H_ +#define COMPLETE_H_ + +#include +#include + +namespace paradiseo +{ +namespace smp +{ + +class Complete: public TopologyBuilder +{ +public : + void operator()(unsigned nbIsland, std::vector>& matrix) const; +}; + +} + +} + +#endif diff --git a/smp/src/topology/ring.cpp b/smp/src/topology/ring.cpp new file mode 100644 index 000000000..30fc4d4d2 --- /dev/null +++ b/smp/src/topology/ring.cpp @@ -0,0 +1,43 @@ +/* + +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::Ring::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_H_ +#define RING_H_ + +#include +#include + +namespace paradiseo +{ +namespace smp +{ + +class Ring : public TopologyBuilder +{ +public : + void operator()(unsigned nbIsland, std::vector>& matrix) const; +}; + +} + +} + +#endif diff --git a/smp/src/topology/star.cpp b/smp/src/topology/star.cpp new file mode 100644 index 000000000..33bcf0b9d --- /dev/null +++ b/smp/src/topology/star.cpp @@ -0,0 +1,46 @@ +/* + +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::Star::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/star.h b/smp/src/topology/star.h new file mode 100644 index 000000000..2fccdb8b4 --- /dev/null +++ b/smp/src/topology/star.h @@ -0,0 +1,51 @@ +/* + +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_H_ +#define STAR_H_ + +#include +#include + +namespace paradiseo +{ +namespace smp +{ + +class Star : public TopologyBuilder +{ +public : + void operator()(unsigned nbIsland, std::vector>& matrix) const; +}; + +} + +} + +#endif diff --git a/smp/src/topology/topology.cpp b/smp/src/topology/topology.cpp new file mode 100644 index 000000000..02995d11b --- /dev/null +++ b/smp/src/topology/topology.cpp @@ -0,0 +1,47 @@ +/* + +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::Topology::Topology(unsigned nbIsland) +{ + TopologyType builder; + builder(nbIsland, _matrix); +} +template +std::vector paradiseo::smp::Topology::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/topology.h b/smp/src/topology/topology.h new file mode 100644 index 000000000..8b3b290aa --- /dev/null +++ b/smp/src/topology/topology.h @@ -0,0 +1,56 @@ +/* + +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 Topology : public AbstractTopology +{ + +public : + Topology(unsigned nbIsland); + + std::vector getIdNeighbours(unsigned idIsland) const; + +private : + TopologyType _builder; + std::vector> _matrix; +}; + +#include + +} + +} From 631d693bef58b63c880529291c596787363f02de Mon Sep 17 00:00:00 2001 From: lasnier Date: Tue, 20 Nov 2012 16:53:28 +0100 Subject: [PATCH 2/2] Add a builder attribute to the topology and construct method --- smp/src/topology/abstractTopology.h | 2 +- smp/src/topology/complete.cpp | 2 +- smp/src/topology/ring.cpp | 1 - smp/src/topology/star.cpp | 1 - smp/src/topology/topology.cpp | 20 ++++----- smp/src/topology/topology.h | 6 +-- smp/test/CMakeLists.txt | 2 +- smp/test/t-smpTopo.cpp | 70 +++++++++++++++++++++++++++++ 8 files changed, 86 insertions(+), 18 deletions(-) create mode 100644 smp/test/t-smpTopo.cpp diff --git a/smp/src/topology/abstractTopology.h b/smp/src/topology/abstractTopology.h index 61717bcd7..153573e9b 100644 --- a/smp/src/topology/abstractTopology.h +++ b/smp/src/topology/abstractTopology.h @@ -38,7 +38,7 @@ namespace smp class AbstractTopology { public : - virtual std::vector getIdNeighbours(unsigned idIsland) const =0; + virtual std::vector getIdNeighbors(unsigned idIsland) const =0; }; } diff --git a/smp/src/topology/complete.cpp b/smp/src/topology/complete.cpp index 0f769b22b..f52c2ab5d 100644 --- a/smp/src/topology/complete.cpp +++ b/smp/src/topology/complete.cpp @@ -38,4 +38,4 @@ void paradiseo::smp::Complete::operator()(unsigned nbIsland, std::vector -#include #include void paradiseo::smp::Ring::operator()(unsigned nbIsland, std::vector>& matrix) const diff --git a/smp/src/topology/star.cpp b/smp/src/topology/star.cpp index 33bcf0b9d..e6d9cc389 100644 --- a/smp/src/topology/star.cpp +++ b/smp/src/topology/star.cpp @@ -28,7 +28,6 @@ Contact: paradiseo-help@lists.gforge.inria.fr */ #include -#include #include void paradiseo::smp::Star::operator()(unsigned nbIsland, std::vector>& matrix) const diff --git a/smp/src/topology/topology.cpp b/smp/src/topology/topology.cpp index 02995d11b..f40298566 100644 --- a/smp/src/topology/topology.cpp +++ b/smp/src/topology/topology.cpp @@ -30,18 +30,18 @@ Contact: paradiseo-help@lists.gforge.inria.fr #include -template -paradiseo::smp::Topology::Topology(unsigned nbIsland) -{ - TopologyType builder; - builder(nbIsland, _matrix); -} template -std::vector paradiseo::smp::Topology::getIdNeighbours(unsigned idIsland) const +std::vector paradiseo::smp::Topology::getIdNeighbors(unsigned idIsland) const { - std::vector neighbours; + std::vector neighbors; for(unsigned j=0; j<_matrix.size();j++) - if(_matrix[idIsland][j]) neighbours.push_back(j); + if(_matrix[idIsland][j]) neighbors.push_back(j); - return neighbours; + return neighbors; +} + +template +void paradiseo::smp::Topology::construct(unsigned nbIsland) +{ + _builder(nbIsland, _matrix); } diff --git a/smp/src/topology/topology.h b/smp/src/topology/topology.h index 8b3b290aa..15df0321f 100644 --- a/smp/src/topology/topology.h +++ b/smp/src/topology/topology.h @@ -40,9 +40,9 @@ class Topology : public AbstractTopology { public : - Topology(unsigned nbIsland); - - std::vector getIdNeighbours(unsigned idIsland) const; + Topology() = default; + std::vector getIdNeighbors(unsigned idIsland) const; + void construct(unsigned nbIsland); private : TopologyType _builder; diff --git a/smp/test/CMakeLists.txt b/smp/test/CMakeLists.txt index 9e904f991..59fb57a6c 100644 --- a/smp/test/CMakeLists.txt +++ b/smp/test/CMakeLists.txt @@ -17,7 +17,7 @@ set (TEST_LIST t-smpMW_eoEasyPSO t-smpMW_eoSyncEasyPSO t-smpIsland - t-smpTopo) + t-smpTopo) ###################################################################################### ### 3) Create each test diff --git a/smp/test/t-smpTopo.cpp b/smp/test/t-smpTopo.cpp new file mode 100644 index 000000000..0d6101358 --- /dev/null +++ b/smp/test/t-smpTopo.cpp @@ -0,0 +1,70 @@ +#include +#include +#include +#include +#include +#include + +using namespace paradiseo::smp; + +int main() +{ + //Test of Complete Topology + Topology topo_comp; + topo_comp.construct(5); + + std::cout << std::endl << "---------------" << std::endl << "Test of Complete Topology" << std::endl; + + std::vector neighbors=topo_comp.getIdNeighbors(1); + std::cout << "neighbors of Island 1 : "< topo_star; + topo_star.construct(4); + + std::cout << std::endl << "---------------" << std::endl << "Test of Star Topology" << std::endl; + + neighbors=topo_star.getIdNeighbors(0); + std::cout < topo_ring; + topo_ring.construct(8); + + std::cout << std::endl << "---------------" << std::endl << "Test of Ring Topology" << std::endl; + + neighbors=topo_ring.getIdNeighbors(4); + std::cout <