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/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 new file mode 100644 index 000000000..f52c2ab5d --- /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..269a77ed3 --- /dev/null +++ b/smp/src/topology/ring.cpp @@ -0,0 +1,42 @@ +/* + +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::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..e6d9cc389 --- /dev/null +++ b/smp/src/topology/star.cpp @@ -0,0 +1,45 @@ +/* + +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::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..f40298566 --- /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 +std::vector paradiseo::smp::Topology::getIdNeighbors(unsigned idIsland) const +{ + std::vector neighbors; + for(unsigned j=0; j<_matrix.size();j++) + if(_matrix[idIsland][j]) neighbors.push_back(j); + + 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 new file mode 100644 index 000000000..15df0321f --- /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() = default; + std::vector getIdNeighbors(unsigned idIsland) const; + void construct(unsigned nbIsland); + +private : + TopologyType _builder; + std::vector> _matrix; +}; + +#include + +} + +} diff --git a/smp/test/CMakeLists.txt b/smp/test/CMakeLists.txt index aca8f9979..4d6e4e43d 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 ) ###################################################################################### 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 <