OpenASIP  2.0
CostDBEntryStatsRF.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file CostDBEntryStatsRF.cc
26  *
27  * Implementation of CostDBEntryStatsRF class.
28  *
29  * @author Tommi Rantanen 2003 (tommi.rantanen-no.spam-tut.fi)
30  * @author Jari Mäntyneva 2005 (jari.mantyneva-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 #include <map>
35 
36 #include "CostDBEntryStatsRF.hh"
37 #include "Application.hh"
38 #include "Conversion.hh"
39 
40 using std::string;
41 using std::map;
42 
43 
44 /**
45  * Constructor.
46  *
47  * @param areaData area.
48  * @param delayData delay.
49  */
50 CostDBEntryStatsRF::CostDBEntryStatsRF(double areaData, double delayData):
51  CostDBEntryStats(areaData, delayData) {
52 }
53 
54 /**
55  * Constructor.
56  *
57  * Combines two statistics into one using coefficient as a weighting
58  * factor on interpolating the statistics. For example, if weighting
59  * factor is 0.4, the first area 100 and the second 200, area of new
60  * statistics will be 140. delay and energy will be handled similarly.
61  *
62  * @param stats1 First statistics.
63  * @param stats2 Second statistics.
64  * @param coefficient Weighting factor.
65  */
67  const CostDBEntryStatsRF& stats1,
68  const CostDBEntryStatsRF& stats2,
69  double coefficient):
70  CostDBEntryStats(stats1, stats2, coefficient) {
71 }
72 
73 
74 /**
75  * Destructor.
76  */
78 }
79 
80 
81 
82 /**
83  * Create correct type of statistics.
84  *
85  * @return Correct type of statistics.
86  */
89 
90  return new CostDBEntryStatsRF(area(), delay());
91 }
92 
93 /**
94  * Returns the energy of an entry in an active cycle.
95  *
96  * The function will fail since register files do not have unambiguous
97  * energy for the whole unit but separately for each access pairs.
98  *
99  * @return The energy of an entry in an active cycle.
100  * @exception WrongSubclass An illegal function was called for this
101  * instance.
102  * @exception KeyNotFound Never thown by this function.
103  */
104 double
106  throw WrongSubclass(__FILE__, __LINE__,
107  "CostDBEntryStatsRF::energyActive");
108  return 0.0; // stupid return statement to make compiler quiet
109 }
110 
111 /**
112  * Returns the read energy of an entry.
113  *
114  * @return The read energy of an entry.
115  * @exception WrongSubclass Never thrown by this function.
116  * @exception KeyNotFound Throws if read energy is not set.
117  */
118 double
120  return findEnergy(ENERGY_READ);
121 }
122 
123 /**
124  * Returns the write energy of an entry.
125  *
126  * @return The write energy of an entry.
127  * @exception WrongSubclass Never thrown by this function.
128  * @exception KeyNotFound Throws if write energy is not set.
129  */
130 double
132  return findEnergy(ENERGY_WRITE);
133 }
134 
135 /**
136  * Returns the reads and writes energy of an entry.
137  *
138  * @param reads The number of simultaneus reads done for the unit.
139  * @param writes The number of simultaneus writes done for the unit.
140  * @return The reads and writes energy of an entry.
141  * @exception WrongSubclass Never thrown by this function.
142  * @exception KeyNotFound Throws if the requested energy is not found.
143  */
144 double
145 CostDBEntryStatsRF::energyReadWrite(int reads, int writes) const {
146  return findEnergy(generateReadWriteString(reads, writes));
147 }
148 
149 /**
150  * Set the energy of an entry in an active cycle.
151  *
152  * The function will fail since function units do not have unambiguous
153  * energy for the whole unit but separately for each operation.
154  *
155  * @param energy The energy of an entry in an active cycle.
156  * @exception WrongSubclass An illegal function was called for this
157  * instance.
158  */
159 void
161  throw WrongSubclass(__FILE__, __LINE__,
162  "CostDBEntryStatsRF::setEnergyActive");
163 }
164 
165 /**
166  * Set the read energy of an entry.
167  *
168  * @param energy The read energy of an entry.
169  * @exception WrongSubclass An illegal function was called for this instance.
170  */
171 void
173  addEnergy(ENERGY_READ, energy);
174 }
175 
176 /**
177  * Set the write energy of an entry.
178  *
179  * @param energy The write energy of an entry.
180  * @exception WrongSubclass Never thrown by this function.
181  */
182 void
184  addEnergy(ENERGY_WRITE, energy);
185 }
186 
187 /**
188  * Set the reads and writes energy of an entry.
189  *
190  * @param energy The reads and writes energy of an entry.
191  * @param reads The number of reads of the unit.
192  * @param writes The number of writes of the unit.
193  * @exception WrongSubclass Never thrown by this function.
194  */
195 void
196 CostDBEntryStatsRF::setEnergyReadWrite(int reads, int writes, double energy) {
197  addEnergy(generateReadWriteString(reads, writes), energy);
198 }
199 
200 /**
201  * Returns a string corresponding to given (read,write) combination in
202  * internal format.
203  *
204  * @param reads Number of simultaneous reads.
205  * @param writes Number of simultaneous writes.
206  * @return String corresponding to given (read,write) combination in
207  * internal format.
208  */
209 std::string
211 
212  return ENERGY_READ_WRITE + "_" +
213  Conversion::toString(reads) + "_" +
214  Conversion::toString(writes);
215 }
CostDBEntryStats::ENERGY_WRITE
static const std::string ENERGY_WRITE
String for write energy.
Definition: CostDBEntryStats.hh:92
CostDBEntryStatsRF::setEnergyRead
virtual void setEnergyRead(double energy)
Definition: CostDBEntryStatsRF.cc:172
CostDBEntryStats::ENERGY_READ_WRITE
static const std::string ENERGY_READ_WRITE
String for reads and writes energy.
Definition: CostDBEntryStats.hh:94
CostDBEntryStats::delay
virtual double delay() const
CostDBEntryStatsRF
Definition: CostDBEntryStatsRF.hh:45
Conversion::toString
static std::string toString(const T &source)
CostDBEntryStatsRF::energyWrite
virtual double energyWrite() const
Definition: CostDBEntryStatsRF.cc:131
WrongSubclass
Definition: Exception.hh:336
Conversion.hh
CostDBEntryStatsRF::CostDBEntryStatsRF
CostDBEntryStatsRF(double areaData, double delayData)
Definition: CostDBEntryStatsRF.cc:50
CostDBEntryStats::ENERGY_READ
static const std::string ENERGY_READ
String for read energy.
Definition: CostDBEntryStats.hh:90
Application.hh
CostDBEntryStats::area
virtual double area() const
CostDBEntryStatsRF::~CostDBEntryStatsRF
virtual ~CostDBEntryStatsRF()
Definition: CostDBEntryStatsRF.cc:77
CostDBEntryStatsRF::setEnergyWrite
virtual void setEnergyWrite(double energy)
Definition: CostDBEntryStatsRF.cc:183
CostDBEntryStatsRF::setEnergyActive
virtual void setEnergyActive(double energy)
Definition: CostDBEntryStatsRF.cc:160
CostDBEntryStatsRF::setEnergyReadWrite
virtual void setEnergyReadWrite(int reads, int writes, double energy)
Definition: CostDBEntryStatsRF.cc:196
CostDBEntryStats::addEnergy
virtual void addEnergy(const std::string &name, double energy)
Definition: CostDBEntryStats.cc:413
CostDBEntryStatsRF::createStats
virtual CostDBEntryStats * createStats() const
Definition: CostDBEntryStatsRF.cc:88
CostDBEntryStatsRF.hh
CostDBEntryStatsRF::energyRead
virtual double energyRead() const
Definition: CostDBEntryStatsRF.cc:119
CostDBEntryStats::findEnergy
virtual double findEnergy(const std::string &key) const
Definition: CostDBEntryStats.cc:308
CostDBEntryStatsRF::generateReadWriteString
static std::string generateReadWriteString(int reads, int writes)
Definition: CostDBEntryStatsRF.cc:210
CostDBEntryStats
Definition: CostDBEntryStats.hh:46
CostDBEntryStatsRF::energyReadWrite
virtual double energyReadWrite(int reads, int writes) const
Definition: CostDBEntryStatsRF.cc:145
CostDBEntryStatsRF::energyActive
virtual double energyActive() const
Definition: CostDBEntryStatsRF.cc:105