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.
| 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 29#ifndef __CPU_O3_FU_POOL_HH__ 30#define __CPU_O3_FU_POOL_HH__ 31 32#include <bitset> 33#include <list> 34#include <string> 35#include <vector> 36 37#include "base/sched_list.hh" 38#include "cpu/op_class.hh" 39#include "sim/sim_object.hh" 40 41class FUDesc; 42class FuncUnit; 43 44/** 45 * Pool of FU's, specific to the new CPU model. The old FU pool had lists of 46 * free units and busy units, and whenever a FU was needed it would iterate 47 * through the free units to find a FU that provided the capability. This pool 48 * has lists of units specific to each of the capabilities, and whenever a FU 49 * is needed, it iterates through that list to find a free unit. The previous 50 * FU pool would have to be ticked each cycle to update which units became 51 * free. This FU pool lets the IEW stage handle freeing units, which frees 52 * them as their scheduled execution events complete. This limits units in this 53 * model to either have identical issue and op latencies, or 1 cycle issue 54 * latencies. 55 */ 56class FUPool : public SimObject 57{ 58 private: 59 /** Maximum op execution latencies, per op class. */ 60 unsigned maxOpLatencies[Num_OpClasses]; 61 /** Maximum issue latencies, per op class. */ 62 unsigned maxIssueLatencies[Num_OpClasses]; 63 64 /** Bitvector listing capabilities of this FU pool. */ 65 std::bitset<Num_OpClasses> capabilityList; 66 67 /** Bitvector listing which FUs are busy. */ 68 std::vector<bool> unitBusy; 69 70 /** List of units to be freed at the end of this cycle. */ 71 std::vector<int> unitsToBeFreed; 72 73 /** 74 * Class that implements a circular queue to hold FU indices. The hope is 75 * that FUs that have been just used will be moved to the end of the queue 76 * by iterating through it, thus leaving free units at the head of the 77 * queue. 78 */ 79 class FUIdxQueue { 80 public: 81 /** Constructs a circular queue of FU indices. */ 82 FUIdxQueue() 83 : idx(0), size(0) 84 { } 85 86 /** Adds a FU to the queue. */ 87 inline void addFU(int fu_idx); 88 89 /** Returns the index of the FU at the head of the queue, and changes 90 * the index to the next element. 91 */ 92 inline int getFU(); 93 94 private: 95 /** Circular queue index. */ 96 int idx; 97 98 /** Size of the queue. */ 99 int size; 100 101 /** Queue of FU indices. */ 102 std::vector<int> funcUnitsIdx; 103 }; 104 105 /** Per op class queues of FUs that provide that capability. */ 106 FUIdxQueue fuPerCapList[Num_OpClasses]; 107 108 /** Number of FUs. */ 109 int numFU; 110 111 /** Functional units. */ 112 std::vector<FuncUnit *> funcUnits; 113 114 typedef std::vector<FuncUnit *>::iterator fuListIterator; 115 116 public: 117 118 /** Constructs a FU pool. */ 119 FUPool(std::string name, std::vector<FUDesc *> l); 120 ~FUPool(); 121 122 /** Annotates units that provide memory operations. Included only because 123 * old FU pool provided this function. 124 */ 125 void annotateMemoryUnits(unsigned hit_latency); 126 127 /** 128 * Gets a FU providing the requested capability. Will mark the unit as busy, 129 * but leaves the freeing of the unit up to the IEW stage. 130 * @param capability The capability requested. 131 * @return Returns -2 if the FU pool does not have the capability, -1 if 132 * there is no free FU, and the FU's index otherwise. 133 */ 134 int getUnit(OpClass capability); 135 136 /** Frees a FU at the end of this cycle. */ 137 void freeUnitNextCycle(int fu_idx); 138 139 /** Frees all FUs on the list. */ 140 void processFreeUnits(); 141 142 /** Returns the total number of FUs. */ 143 int size() { return numFU; } 144 145 /** Debugging function used to dump FU information. */ 146 void dump(); 147 148 /** Returns the operation execution latency of the given capability. */ 149 unsigned getOpLatency(OpClass capability) { 150 return maxOpLatencies[capability]; 151 } 152 153 /** Returns the issue latency of the given capability. */ 154 unsigned getIssueLatency(OpClass capability) { 155 return maxIssueLatencies[capability]; 156 } 157 158 /** Switches out functional unit pool. */ 159 void switchOut(); 160 161 /** Takes over from another CPU's thread. */ 162 void takeOverFrom(); 163}; 164 165#endif // __CPU_O3_FU_POOL_HH__
| 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" 40#include "cpu/op_class.hh" 41#include "sim/sim_object.hh" 42 43class FUDesc; 44class FuncUnit; 45 46/** 47 * Pool of FU's, specific to the new CPU model. The old FU pool had lists of 48 * free units and busy units, and whenever a FU was needed it would iterate 49 * through the free units to find a FU that provided the capability. This pool 50 * has lists of units specific to each of the capabilities, and whenever a FU 51 * is needed, it iterates through that list to find a free unit. The previous 52 * FU pool would have to be ticked each cycle to update which units became 53 * free. This FU pool lets the IEW stage handle freeing units, which frees 54 * them as their scheduled execution events complete. This limits units in this 55 * model to either have identical issue and op latencies, or 1 cycle issue 56 * latencies. 57 */ 58class FUPool : public SimObject 59{ 60 private: 61 /** Maximum op execution latencies, per op class. */ 62 unsigned maxOpLatencies[Num_OpClasses]; 63 /** Maximum issue latencies, per op class. */ 64 unsigned maxIssueLatencies[Num_OpClasses]; 65 66 /** Bitvector listing capabilities of this FU pool. */ 67 std::bitset<Num_OpClasses> capabilityList; 68 69 /** Bitvector listing which FUs are busy. */ 70 std::vector<bool> unitBusy; 71 72 /** List of units to be freed at the end of this cycle. */ 73 std::vector<int> unitsToBeFreed; 74 75 /** 76 * Class that implements a circular queue to hold FU indices. The hope is 77 * that FUs that have been just used will be moved to the end of the queue 78 * by iterating through it, thus leaving free units at the head of the 79 * queue. 80 */ 81 class FUIdxQueue { 82 public: 83 /** Constructs a circular queue of FU indices. */ 84 FUIdxQueue() 85 : idx(0), size(0) 86 { } 87 88 /** Adds a FU to the queue. */ 89 inline void addFU(int fu_idx); 90 91 /** Returns the index of the FU at the head of the queue, and changes 92 * the index to the next element. 93 */ 94 inline int getFU(); 95 96 private: 97 /** Circular queue index. */ 98 int idx; 99 100 /** Size of the queue. */ 101 int size; 102 103 /** Queue of FU indices. */ 104 std::vector<int> funcUnitsIdx; 105 }; 106 107 /** Per op class queues of FUs that provide that capability. */ 108 FUIdxQueue fuPerCapList[Num_OpClasses]; 109 110 /** Number of FUs. */ 111 int numFU; 112 113 /** Functional units. */ 114 std::vector<FuncUnit *> funcUnits; 115 116 typedef std::vector<FuncUnit *>::iterator fuListIterator; 117 118 public: 119 120 /** Constructs a FU pool. */ 121 FUPool(std::string name, std::vector<FUDesc *> l); 122 ~FUPool(); 123 124 /** Annotates units that provide memory operations. Included only because 125 * old FU pool provided this function. 126 */ 127 void annotateMemoryUnits(unsigned hit_latency); 128 129 /** 130 * Gets a FU providing the requested capability. Will mark the unit as busy, 131 * but leaves the freeing of the unit up to the IEW stage. 132 * @param capability The capability requested. 133 * @return Returns -2 if the FU pool does not have the capability, -1 if 134 * there is no free FU, and the FU's index otherwise. 135 */ 136 int getUnit(OpClass capability); 137 138 /** Frees a FU at the end of this cycle. */ 139 void freeUnitNextCycle(int fu_idx); 140 141 /** Frees all FUs on the list. */ 142 void processFreeUnits(); 143 144 /** Returns the total number of FUs. */ 145 int size() { return numFU; } 146 147 /** Debugging function used to dump FU information. */ 148 void dump(); 149 150 /** Returns the operation execution latency of the given capability. */ 151 unsigned getOpLatency(OpClass capability) { 152 return maxOpLatencies[capability]; 153 } 154 155 /** Returns the issue latency of the given capability. */ 156 unsigned getIssueLatency(OpClass capability) { 157 return maxIssueLatencies[capability]; 158 } 159 160 /** Switches out functional unit pool. */ 161 void switchOut(); 162 163 /** Takes over from another CPU's thread. */ 164 void takeOverFrom(); 165}; 166 167#endif // __CPU_O3_FU_POOL_HH__
|