pelib  2.0.0
include/pelib/Platform.hpp
Go to the documentation of this file.
00001 /*
00002  Copyright 2015 Nicolas Melot
00003 
00004  This file is part of Pelib.
00005 
00006  Pelib is free software: you can redistribute it and/or modify
00007  it under the terms of the GNU General Public License as published by
00008  the Free Software Foundation, either version 3 of the License, or
00009  (at your option) any later version.
00010 
00011  Pelib is distributed in the hope that it will be useful,
00012  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  GNU General Public License for more details.
00015 
00016  You should have received a copy of the GNU General Public License
00017  along with Pelib. If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 
00021 #include <set>
00022 
00023 #include <pelib/Core.hpp>
00024 #include <pelib/Algebra.hpp>
00025 
00026 #ifndef PELIB_PLATFORM
00027 #define PELIB_PLATFORM
00028 
00029 #define debug(var) std::cout << "[" << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "] " << #var << " = \"" << (var) << "\"" << std::endl;
00030 
00031 namespace pelib
00032 {
00034         class Platform: public Record
00035         {
00036                 public:
00037                         typedef std::set<const Core*, Core::LessCorePtrByCoreId> island;
00038                         struct LessIslandByFirstCoreId 
00039                         {
00040                                 bool operator() (const island &x, const island &y) const
00041                                 {
00042                                         for(island::const_iterator xx = x.begin(), yy = y.begin(); xx != x.end() && yy != y.end(); xx++, yy++)
00043                                         {
00044                                                 if(*xx == *yy)
00045                                                 {
00046                                                         continue;
00047                                                 }
00048                                                 else
00049                                                 {
00050                                                         return **xx < **yy;
00051                                                 }
00052                                         }
00053 
00054                                         return x.size() < y.size();
00055                                 }
00056                         };
00057                         typedef std::set<island, LessIslandByFirstCoreId> islands;
00058 
00062                         Platform();
00063 
00068                         Platform(size_t p, const Core* ref);
00069 
00073                         Platform(const island &cores);
00074 
00083                         Platform(const island& cores, const islands &shared, const islands &main, const islands &priv, const islands &voltage, const islands &freq);
00084 
00086                         Platform(const Platform *arch);
00087 
00089                         Platform(const Platform &arch);
00090 
00094                         Platform(const Algebra &arch);
00095 
00097                         virtual Platform* clone() const;
00098 
00100                         virtual const std::set<const Core*, Core::LessCorePtrByCoreId>& getCores() const;
00101 
00103                         virtual bool isHomogeneous() const;
00104 
00106                         virtual const islands& getSharedMemoryIslands() const;
00107 
00109                         virtual const islands getSharedMemoryIslands(size_t core_id) const;
00110 
00114                         virtual const islands getSharedMemoryIslands(const std::set<int>& islands) const;
00118                         virtual const std::set<int> getSharedMemoryIslands(const islands& isls) const;
00120                         virtual const islands& getMainMemoryIslands() const;
00122                         virtual const islands getMainMemoryIslands(size_t core_id) const;
00124                         virtual const islands& getPrivateMemoryIslands() const;
00126                         virtual const islands getPrivateMemoryIslands(size_t core_id) const;
00128                         virtual const islands& getVoltageIslands() const;
00130                         virtual const island& getVoltageIsland(size_t core_id) const;
00132                         virtual const islands& getFrequencyIslands() const;
00134                         virtual const island& getFrequencyIsland(size_t core_id) const;
00135 
00137                         virtual const Core* getCore(size_t id) const;
00138 
00140                         virtual size_t getCoreId(const Core*) const;
00141 
00143                         virtual Algebra buildAlgebra() const;
00144 
00146                         virtual ~Platform();
00147                         virtual Platform&
00148                         operator=(const Platform& copy);
00149                 protected:
00151                         island cores;
00153                         islands shared, main, priv, voltage, freq;
00154                 private:                
00155                         void copy(const Platform *pt);
00156         };
00157 }
00158 
00159 #undef debug
00160 
00161 #endif