torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PlacementSiteTypeMapping.hpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Header for the Placement class.
18 
19 #ifndef TORC_PLACER_PLACEMENTSITETYPEMAPPING_HPP
20 #define TORC_PLACER_PLACEMENTSITETYPEMAPPING_HPP
21 
23 #include <string>
24 #include <vector>
25 #include <map>
26 #include <set>
27 
28 namespace torc {
29 namespace placer {
30 
31  /// \brief Placement mapping for legal instance types to site types.
32 
34  protected:
35  //types
38  typedef boost::uint32_t uint32;
39 
40  //typedef std::map<uint32, uint32> InstanceTypeToCandidateTypeMap;
41  typedef std::vector<uint32> InstanceTypeToCandidateTypeMap;
42 
44  typedef std::vector<const Site*> SitePtrVector;
45  typedef std::vector<SitePtrVector> SitePtrVectorVector;
46  typedef std::vector<SitePtrVectorVector> SitePtrVectorVectorVector;
47 
48  typedef std::set<Site*> SitePtrSet;
49  typedef std::vector<SitePtrSet> SitePtrSetVector;
50  typedef std::vector<SitePtrSetVector> SitePtrSetVectorVector;
51 
52  public:
55  std::vector<uint32> mLegalSiteTypes;
56  std::vector<uint32> mLegalInstanceTypes;
57  public:
58  MappingSiteType (std::string inName) : mName(inName) {}
59  const std::string& getName() { return mName; }
60  std::vector<uint32>& getSiteTypes() { return mLegalSiteTypes; }
61  std::vector<uint32>& getInstanceTypes() { return mLegalInstanceTypes; }
62  };
63 
64  typedef std::vector<MappingSiteType> TypeVector;
65 
66 
67  protected:
68  // members
69  DDB& mDB;
70  const Sites& mSites;
72 
74  std::map<std::string, uint32> mTypeLookup;
75 
76  public:
78  : mDB(inDB), mSites(inDB.getSites()), mSiteTypes(mSites.getSiteTypes()) {
79 
81  // this is the default mapping so it is simple matching of instance to site types.
82  // it is assumed that the type index on the instance side matches the database.
83  for (uint32 i = 0; i < mSites.getSiteTypeCount(); i++) {
85  }
86 
87  //populateGroups();
88  }
90  protected:
91  // Set up the structures to receive mapping data
93  mTypeVector.clear();
94  mTypeLookup.clear();
95  // set up a map of site type indices
96  for (uint32 i = 0; i < mSites.getSiteTypeCount(); i++) {
98  mTypeLookup.insert(std::pair<std::string, uint32>(mSiteTypes[i].getName(), i));
99  }
100  }
101 
102  void addMapData(std::string itype, std::string stype) {
103  uint32 ii = mTypeLookup[itype];
104  uint32 si = mTypeLookup[stype];
105 
106  mTypeVector[ii].getSiteTypes().push_back(si);
107  mTypeVector[si].getInstanceTypes().push_back(ii);
108 
109  }
110  public:
111  uint32 getNumTypes() { return mTypeLookup.size(); }
112 
113  std::vector<MappingSiteType>& getTypeVector() {
114  return mTypeVector;
115  }
116 
117  std::vector<uint32>& getLegalSitesForInstance(uint32 inInstanceTypeIndex) {
118  return mTypeVector[inInstanceTypeIndex].getSiteTypes();
119  }
120  std::vector<uint32>& getLegalInstancesForSite(uint32 inSiteTypeIndex) {
121  return mTypeVector[inSiteTypeIndex].getInstanceTypes();
122  }
123  MappingSiteType& getType(uint32 inIndex) { return mTypeVector[inIndex]; }
124 
126  return mTypeVector[mTypeLookup[inName]];
127  }
128  const std::string& getName(uint32 inIndex) { return mTypeVector[inIndex].getName(); }
129 
130  /// \brief Get the type index for a given type name, creates a new entry if not found.
131  uint32 getTypeIndex(const std::string& inType) { return mTypeLookup[inType]; }
132 
133  /*std::vector<uint32>& operator[] (const uint32 inIndex) {
134  return mTypeVector[inIndex].getDeviceSiteTypes();
135  }
136  uint32& operator[] (const std::string& inString) {
137  return mTypeLookup[inString];
138  }*/
139 
140 
141  }; // class PlacementSiteTypeMapping
142 } // namespace placer
143 } // namespace torc
144 
145 #endif // TORC_PLACER_PLACEMENTSITETYPEMAPPING_HPP
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
MappingSiteType & getType(std::string &inName)
const std::string & getName(uint32 inIndex)
std::vector< SitePtrSetVector > SitePtrSetVectorVector
std::vector< uint32 > & getLegalInstancesForSite(uint32 inSiteTypeIndex)
std::vector< SitePtrVector > SitePtrVectorVector
std::vector< MappingSiteType > & getTypeVector()
std::string string
std::map< std::string, uint32 > mTypeLookup
Encapsulation of a device logic site.
Definition: Site.hpp:30
Site type and population data for the family and the device.
Definition: Sites.hpp:45
void addMapData(std::string itype, std::string stype)
std::vector< SitePtrVectorVector > SitePtrVectorVectorVector
SiteTypeCount getSiteTypeCount(void) const
Returns the site type count for this family.
Definition: Sites.hpp:123
MappingSiteType & getType(uint32 inIndex)
Placement mapping for legal instance types to site types.
const architecture::Array< const architecture::PrimitiveDef > & mSiteTypes
Header for the DDB class.
uint32 getTypeIndex(const std::string &inType)
Get the type index for a given type name, creates a new entry if not found.
std::vector< uint32 > & getLegalSitesForInstance(uint32 inInstanceTypeIndex)