fu_pool.hh (5034:6186ef720dd4) fu_pool.hh (7813:7338bc628489)
1/*
2 * Copyright (c) 2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Kevin Lim
29 */
30
31#ifndef __CPU_O3_FU_POOL_HH__
32#define __CPU_O3_FU_POOL_HH__
33
34#include <bitset>
35#include <list>
36#include <string>
37#include <vector>
38
1/*
2 * Copyright (c) 2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Kevin Lim
29 */
30
31#ifndef __CPU_O3_FU_POOL_HH__
32#define __CPU_O3_FU_POOL_HH__
33
34#include <bitset>
35#include <list>
36#include <string>
37#include <vector>
38
39#include "base/sched_list.hh"
39#include "cpu/sched_list.hh"
40#include "cpu/op_class.hh"
41#include "params/FUPool.hh"
42#include "sim/sim_object.hh"
43
44class FUDesc;
45class FuncUnit;
46
47/**
48 * Pool of FU's, specific to the new CPU model. The old FU pool had lists of
49 * free units and busy units, and whenever a FU was needed it would iterate
50 * through the free units to find a FU that provided the capability. This pool
51 * has lists of units specific to each of the capabilities, and whenever a FU
52 * is needed, it iterates through that list to find a free unit. The previous
53 * FU pool would have to be ticked each cycle to update which units became
54 * free. This FU pool lets the IEW stage handle freeing units, which frees
55 * them as their scheduled execution events complete. This limits units in this
56 * model to either have identical issue and op latencies, or 1 cycle issue
57 * latencies.
58 */
59class FUPool : public SimObject
60{
61 private:
62 /** Maximum op execution latencies, per op class. */
63 unsigned maxOpLatencies[Num_OpClasses];
64 /** Maximum issue latencies, per op class. */
65 unsigned maxIssueLatencies[Num_OpClasses];
66
67 /** Bitvector listing capabilities of this FU pool. */
68 std::bitset<Num_OpClasses> capabilityList;
69
70 /** Bitvector listing which FUs are busy. */
71 std::vector<bool> unitBusy;
72
73 /** List of units to be freed at the end of this cycle. */
74 std::vector<int> unitsToBeFreed;
75
76 /**
77 * Class that implements a circular queue to hold FU indices. The hope is
78 * that FUs that have been just used will be moved to the end of the queue
79 * by iterating through it, thus leaving free units at the head of the
80 * queue.
81 */
82 class FUIdxQueue {
83 public:
84 /** Constructs a circular queue of FU indices. */
85 FUIdxQueue()
86 : idx(0), size(0)
87 { }
88
89 /** Adds a FU to the queue. */
90 inline void addFU(int fu_idx);
91
92 /** Returns the index of the FU at the head of the queue, and changes
93 * the index to the next element.
94 */
95 inline int getFU();
96
97 private:
98 /** Circular queue index. */
99 int idx;
100
101 /** Size of the queue. */
102 int size;
103
104 /** Queue of FU indices. */
105 std::vector<int> funcUnitsIdx;
106 };
107
108 /** Per op class queues of FUs that provide that capability. */
109 FUIdxQueue fuPerCapList[Num_OpClasses];
110
111 /** Number of FUs. */
112 int numFU;
113
114 /** Functional units. */
115 std::vector<FuncUnit *> funcUnits;
116
117 typedef std::vector<FuncUnit *>::iterator fuListIterator;
118
119 public:
120 typedef FUPoolParams Params;
121 /** Constructs a FU pool. */
122 FUPool(const Params *p);
123 ~FUPool();
124
125 /** Annotates units that provide memory operations. Included only because
126 * old FU pool provided this function.
127 */
128 void annotateMemoryUnits(unsigned hit_latency);
129
130 /**
131 * Gets a FU providing the requested capability. Will mark the unit as busy,
132 * but leaves the freeing of the unit up to the IEW stage.
133 * @param capability The capability requested.
134 * @return Returns -2 if the FU pool does not have the capability, -1 if
135 * there is no free FU, and the FU's index otherwise.
136 */
137 int getUnit(OpClass capability);
138
139 /** Frees a FU at the end of this cycle. */
140 void freeUnitNextCycle(int fu_idx);
141
142 /** Frees all FUs on the list. */
143 void processFreeUnits();
144
145 /** Returns the total number of FUs. */
146 int size() { return numFU; }
147
148 /** Debugging function used to dump FU information. */
149 void dump();
150
151 /** Returns the operation execution latency of the given capability. */
152 unsigned getOpLatency(OpClass capability) {
153 return maxOpLatencies[capability];
154 }
155
156 /** Returns the issue latency of the given capability. */
157 unsigned getIssueLatency(OpClass capability) {
158 return maxIssueLatencies[capability];
159 }
160
161 /** Switches out functional unit pool. */
162 void switchOut();
163
164 /** Takes over from another CPU's thread. */
165 void takeOverFrom();
166};
167
168#endif // __CPU_O3_FU_POOL_HH__
40#include "cpu/op_class.hh"
41#include "params/FUPool.hh"
42#include "sim/sim_object.hh"
43
44class FUDesc;
45class FuncUnit;
46
47/**
48 * Pool of FU's, specific to the new CPU model. The old FU pool had lists of
49 * free units and busy units, and whenever a FU was needed it would iterate
50 * through the free units to find a FU that provided the capability. This pool
51 * has lists of units specific to each of the capabilities, and whenever a FU
52 * is needed, it iterates through that list to find a free unit. The previous
53 * FU pool would have to be ticked each cycle to update which units became
54 * free. This FU pool lets the IEW stage handle freeing units, which frees
55 * them as their scheduled execution events complete. This limits units in this
56 * model to either have identical issue and op latencies, or 1 cycle issue
57 * latencies.
58 */
59class FUPool : public SimObject
60{
61 private:
62 /** Maximum op execution latencies, per op class. */
63 unsigned maxOpLatencies[Num_OpClasses];
64 /** Maximum issue latencies, per op class. */
65 unsigned maxIssueLatencies[Num_OpClasses];
66
67 /** Bitvector listing capabilities of this FU pool. */
68 std::bitset<Num_OpClasses> capabilityList;
69
70 /** Bitvector listing which FUs are busy. */
71 std::vector<bool> unitBusy;
72
73 /** List of units to be freed at the end of this cycle. */
74 std::vector<int> unitsToBeFreed;
75
76 /**
77 * Class that implements a circular queue to hold FU indices. The hope is
78 * that FUs that have been just used will be moved to the end of the queue
79 * by iterating through it, thus leaving free units at the head of the
80 * queue.
81 */
82 class FUIdxQueue {
83 public:
84 /** Constructs a circular queue of FU indices. */
85 FUIdxQueue()
86 : idx(0), size(0)
87 { }
88
89 /** Adds a FU to the queue. */
90 inline void addFU(int fu_idx);
91
92 /** Returns the index of the FU at the head of the queue, and changes
93 * the index to the next element.
94 */
95 inline int getFU();
96
97 private:
98 /** Circular queue index. */
99 int idx;
100
101 /** Size of the queue. */
102 int size;
103
104 /** Queue of FU indices. */
105 std::vector<int> funcUnitsIdx;
106 };
107
108 /** Per op class queues of FUs that provide that capability. */
109 FUIdxQueue fuPerCapList[Num_OpClasses];
110
111 /** Number of FUs. */
112 int numFU;
113
114 /** Functional units. */
115 std::vector<FuncUnit *> funcUnits;
116
117 typedef std::vector<FuncUnit *>::iterator fuListIterator;
118
119 public:
120 typedef FUPoolParams Params;
121 /** Constructs a FU pool. */
122 FUPool(const Params *p);
123 ~FUPool();
124
125 /** Annotates units that provide memory operations. Included only because
126 * old FU pool provided this function.
127 */
128 void annotateMemoryUnits(unsigned hit_latency);
129
130 /**
131 * Gets a FU providing the requested capability. Will mark the unit as busy,
132 * but leaves the freeing of the unit up to the IEW stage.
133 * @param capability The capability requested.
134 * @return Returns -2 if the FU pool does not have the capability, -1 if
135 * there is no free FU, and the FU's index otherwise.
136 */
137 int getUnit(OpClass capability);
138
139 /** Frees a FU at the end of this cycle. */
140 void freeUnitNextCycle(int fu_idx);
141
142 /** Frees all FUs on the list. */
143 void processFreeUnits();
144
145 /** Returns the total number of FUs. */
146 int size() { return numFU; }
147
148 /** Debugging function used to dump FU information. */
149 void dump();
150
151 /** Returns the operation execution latency of the given capability. */
152 unsigned getOpLatency(OpClass capability) {
153 return maxOpLatencies[capability];
154 }
155
156 /** Returns the issue latency of the given capability. */
157 unsigned getIssueLatency(OpClass capability) {
158 return maxIssueLatencies[capability];
159 }
160
161 /** Switches out functional unit pool. */
162 void switchOut();
163
164 /** Takes over from another CPU's thread. */
165 void takeOverFrom();
166};
167
168#endif // __CPU_O3_FU_POOL_HH__