cpu.hh (2817:273f7fb94f83) | cpu.hh (2829:f354c00bba05) |
---|---|
1/* 2 * Copyright (c) 2004-2005 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; --- 88 unchanged lines hidden (view full) --- 97 typedef typename Impl::Params Params; 98 typedef typename Impl::DynInstPtr DynInstPtr; 99 100 typedef O3ThreadState<Impl> Thread; 101 102 typedef typename std::list<DynInstPtr>::iterator ListIt; 103 104 friend class O3ThreadContext<Impl>; | 1/* 2 * Copyright (c) 2004-2005 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; --- 88 unchanged lines hidden (view full) --- 97 typedef typename Impl::Params Params; 98 typedef typename Impl::DynInstPtr DynInstPtr; 99 100 typedef O3ThreadState<Impl> Thread; 101 102 typedef typename std::list<DynInstPtr>::iterator ListIt; 103 104 friend class O3ThreadContext<Impl>; |
105 |
|
105 public: 106 enum Status { 107 Running, 108 Idle, 109 Halted, 110 Blocked, 111 SwitchedOut 112 }; 113 114 /** Overall CPU status. */ 115 Status _status; 116 | 106 public: 107 enum Status { 108 Running, 109 Idle, 110 Halted, 111 Blocked, 112 SwitchedOut 113 }; 114 115 /** Overall CPU status. */ 116 Status _status; 117 |
118 /** Per-thread status in CPU, used for SMT. */ 119 Status _threadStatus[Impl::MaxThreads]; 120 |
|
117 private: 118 class TickEvent : public Event 119 { 120 private: 121 /** Pointer to the CPU. */ 122 FullO3CPU<Impl> *cpu; 123 124 public: --- 20 unchanged lines hidden (view full) --- 145 146 /** Unschedule tick event, regardless of its current state. */ 147 void unscheduleTickEvent() 148 { 149 if (tickEvent.scheduled()) 150 tickEvent.squash(); 151 } 152 | 121 private: 122 class TickEvent : public Event 123 { 124 private: 125 /** Pointer to the CPU. */ 126 FullO3CPU<Impl> *cpu; 127 128 public: --- 20 unchanged lines hidden (view full) --- 149 150 /** Unschedule tick event, regardless of its current state. */ 151 void unscheduleTickEvent() 152 { 153 if (tickEvent.scheduled()) 154 tickEvent.squash(); 155 } 156 |
157 class ActivateThreadEvent : public Event 158 { 159 private: 160 /** Number of Thread to Activate */ 161 int tid; 162 163 /** Pointer to the CPU. */ 164 FullO3CPU<Impl> *cpu; 165 166 public: 167 /** Constructs the event. */ 168 ActivateThreadEvent(); 169 170 /** Initialize Event */ 171 void init(int thread_num, FullO3CPU<Impl> *thread_cpu); 172 173 /** Processes the event, calling activateThread() on the CPU. */ 174 void process(); 175 176 /** Returns the description of the event. */ 177 const char *description(); 178 }; 179 180 /** Schedule thread to activate , regardless of its current state. */ 181 void scheduleActivateThreadEvent(int tid, int delay) 182 { 183 // Schedule thread to activate, regardless of its current state. 184 if (activateThreadEvent[tid].squashed()) 185 activateThreadEvent[tid].reschedule(curTick + cycles(delay)); 186 else if (!activateThreadEvent[tid].scheduled()) 187 activateThreadEvent[tid].schedule(curTick + cycles(delay)); 188 } 189 190 /** Unschedule actiavte thread event, regardless of its current state. */ 191 void unscheduleActivateThreadEvent(int tid) 192 { 193 if (activateThreadEvent[tid].scheduled()) 194 activateThreadEvent[tid].squash(); 195 } 196 197 /** The tick event used for scheduling CPU ticks. */ 198 ActivateThreadEvent activateThreadEvent[Impl::MaxThreads]; 199 |
|
153 public: 154 /** Constructs a CPU with the given parameters. */ 155 FullO3CPU(Params *params); 156 /** Destructor. */ 157 ~FullO3CPU(); 158 159 /** Registers statistics. */ 160 void fullCPURegStats(); 161 162 /** Ticks CPU, calling tick() on each stage, and checking the overall 163 * activity to see if the CPU should deschedule itself. 164 */ 165 void tick(); 166 167 /** Initialize the CPU */ 168 void init(); 169 | 200 public: 201 /** Constructs a CPU with the given parameters. */ 202 FullO3CPU(Params *params); 203 /** Destructor. */ 204 ~FullO3CPU(); 205 206 /** Registers statistics. */ 207 void fullCPURegStats(); 208 209 /** Ticks CPU, calling tick() on each stage, and checking the overall 210 * activity to see if the CPU should deschedule itself. 211 */ 212 void tick(); 213 214 /** Initialize the CPU */ 215 void init(); 216 |
217 /** Add Thread to Active Threads List */ 218 void activateThread(unsigned int tid); 219 |
|
170 /** Setup CPU to insert a thread's context */ 171 void insertThread(unsigned tid); 172 173 /** Remove all of a thread's context from CPU */ 174 void removeThread(unsigned tid); 175 176 /** Count the Total Instructions Committed in the CPU. */ 177 virtual Counter totalInstructions() const --- 339 unchanged lines hidden (view full) --- 517 bool contextSwitch; 518 519 /** Threads Scheduled to Enter CPU */ 520 std::list<int> cpuWaitList; 521 522 /** The cycle that the CPU was last running, used for statistics. */ 523 Tick lastRunningCycle; 524 | 220 /** Setup CPU to insert a thread's context */ 221 void insertThread(unsigned tid); 222 223 /** Remove all of a thread's context from CPU */ 224 void removeThread(unsigned tid); 225 226 /** Count the Total Instructions Committed in the CPU. */ 227 virtual Counter totalInstructions() const --- 339 unchanged lines hidden (view full) --- 567 bool contextSwitch; 568 569 /** Threads Scheduled to Enter CPU */ 570 std::list<int> cpuWaitList; 571 572 /** The cycle that the CPU was last running, used for statistics. */ 573 Tick lastRunningCycle; 574 |
575 /** The cycle that the CPU was last activated by a new thread*/ 576 Tick lastActivatedCycle; 577 |
|
525 /** Number of Threads CPU can process */ 526 unsigned numThreads; 527 528 /** Mapping for system thread id to cpu id */ 529 std::map<unsigned,unsigned> threadMap; 530 531 /** Available thread ids in the cpu*/ 532 std::vector<unsigned> tids; --- 20 unchanged lines hidden --- | 578 /** Number of Threads CPU can process */ 579 unsigned numThreads; 580 581 /** Mapping for system thread id to cpu id */ 582 std::map<unsigned,unsigned> threadMap; 583 584 /** Available thread ids in the cpu*/ 585 std::vector<unsigned> tids; --- 20 unchanged lines hidden --- |