stat_control.cc (9850:87d6b41749e9) | stat_control.cc (9983:2cce74fe359e) |
---|---|
1/* 2 * Copyright (c) 2012 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated 11 * unmodified and in its entirety in all distributions of the software, 12 * modified or unmodified, in source code or in binary form. 13 * 14 * Copyright (c) 2004-2005 The Regents of The University of Michigan | 1/* 2 * Copyright (c) 2012 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated 11 * unmodified and in its entirety in all distributions of the software, 12 * modified or unmodified, in source code or in binary form. 13 * 14 * Copyright (c) 2004-2005 The Regents of The University of Michigan |
15 * Copyright (c) 2013 Advanced Micro Devices, Inc. 16 * Copyright (c) 2013 Mark D. Hill and David A. Wood |
|
15 * All rights reserved. 16 * 17 * Redistribution and use in source and binary forms, with or without 18 * modification, are permitted provided that the following conditions are 19 * met: redistributions of source code must retain the above copyright 20 * notice, this list of conditions and the following disclaimer; 21 * redistributions in binary form must reproduce the above copyright 22 * notice, this list of conditions and the following disclaimer in the --- 25 unchanged lines hidden (view full) --- 48#include <iostream> 49#include <list> 50 51#include "base/callback.hh" 52#include "base/hostinfo.hh" 53#include "base/statistics.hh" 54#include "base/time.hh" 55#include "cpu/base.hh" | 17 * All rights reserved. 18 * 19 * Redistribution and use in source and binary forms, with or without 20 * modification, are permitted provided that the following conditions are 21 * met: redistributions of source code must retain the above copyright 22 * notice, this list of conditions and the following disclaimer; 23 * redistributions in binary form must reproduce the above copyright 24 * notice, this list of conditions and the following disclaimer in the --- 25 unchanged lines hidden (view full) --- 50#include <iostream> 51#include <list> 52 53#include "base/callback.hh" 54#include "base/hostinfo.hh" 55#include "base/statistics.hh" 56#include "base/time.hh" 57#include "cpu/base.hh" |
56#include "sim/eventq_impl.hh" | 58#include "sim/global_event.hh" |
57#include "sim/stat_control.hh" 58 59using namespace std; 60 61Stats::Formula simSeconds; 62Stats::Value simTicks; 63Stats::Value finalTick; 64Stats::Value simFreq; 65 66namespace Stats { 67 68Time statTime(true); 69Tick startTick; 70 | 59#include "sim/stat_control.hh" 60 61using namespace std; 62 63Stats::Formula simSeconds; 64Stats::Value simTicks; 65Stats::Value finalTick; 66Stats::Value simFreq; 67 68namespace Stats { 69 70Time statTime(true); 71Tick startTick; 72 |
71Event *dumpEvent; | 73GlobalEvent *dumpEvent; |
72 73struct SimTicksReset : public Callback 74{ 75 void process() 76 { 77 statTime.setTimer(); 78 startTick = curTick(); 79 } --- 125 unchanged lines hidden (view full) --- 205initSimStats() 206{ 207 static Global global; 208} 209 210/** 211 * Event to dump and/or reset the statistics. 212 */ | 74 75struct SimTicksReset : public Callback 76{ 77 void process() 78 { 79 statTime.setTimer(); 80 startTick = curTick(); 81 } --- 125 unchanged lines hidden (view full) --- 207initSimStats() 208{ 209 static Global global; 210} 211 212/** 213 * Event to dump and/or reset the statistics. 214 */ |
213class StatEvent : public Event | 215class StatEvent : public GlobalEvent |
214{ 215 private: 216 bool dump; 217 bool reset; 218 Tick repeat; 219 220 public: | 216{ 217 private: 218 bool dump; 219 bool reset; 220 Tick repeat; 221 222 public: |
221 StatEvent(bool _dump, bool _reset, Tick _repeat) 222 : Event(Stat_Event_Pri, AutoDelete), | 223 StatEvent(Tick _when, bool _dump, bool _reset, Tick _repeat) 224 : GlobalEvent(_when, Stat_Event_Pri, 0), |
223 dump(_dump), reset(_reset), repeat(_repeat) 224 { 225 } 226 227 virtual void 228 process() 229 { 230 if (dump) 231 Stats::dump(); 232 233 if (reset) 234 Stats::reset(); 235 236 if (repeat) { 237 Stats::schedStatEvent(dump, reset, curTick() + repeat, repeat); 238 } 239 } | 225 dump(_dump), reset(_reset), repeat(_repeat) 226 { 227 } 228 229 virtual void 230 process() 231 { 232 if (dump) 233 Stats::dump(); 234 235 if (reset) 236 Stats::reset(); 237 238 if (repeat) { 239 Stats::schedStatEvent(dump, reset, curTick() + repeat, repeat); 240 } 241 } |
242 243 const char *description() const { return "GlobalStatEvent"; } |
|
240}; 241 242void 243schedStatEvent(bool dump, bool reset, Tick when, Tick repeat) 244{ | 244}; 245 246void 247schedStatEvent(bool dump, bool reset, Tick when, Tick repeat) 248{ |
245 dumpEvent = new StatEvent(dump, reset, repeat); 246 mainEventQueue.schedule(dumpEvent, when); | 249 // simQuantum is being added to the time when the stats would be 250 // dumped so as to ensure that this event happens only after the next 251 // sync amongst the event queues. Asingle event queue simulation 252 // should remain unaffected. 253 dumpEvent = new StatEvent(when + simQuantum, dump, reset, repeat); |
247} 248 249void 250periodicStatDump(Tick period) 251{ 252 /* 253 * If the period is set to 0, then we do not want to dump periodically, 254 * thus we deschedule the event. Else, if the period is not 0, but the event 255 * has already been scheduled, we need to get rid of the old event before we 256 * create a new one, as the old event will no longer be moved forward in the 257 * event that we resume from a checkpoint. 258 */ 259 if (dumpEvent != NULL && (period == 0 || dumpEvent->scheduled())) { 260 // Event should AutoDelete, so we do not need to free it. | 254} 255 256void 257periodicStatDump(Tick period) 258{ 259 /* 260 * If the period is set to 0, then we do not want to dump periodically, 261 * thus we deschedule the event. Else, if the period is not 0, but the event 262 * has already been scheduled, we need to get rid of the old event before we 263 * create a new one, as the old event will no longer be moved forward in the 264 * event that we resume from a checkpoint. 265 */ 266 if (dumpEvent != NULL && (period == 0 || dumpEvent->scheduled())) { 267 // Event should AutoDelete, so we do not need to free it. |
261 mainEventQueue.deschedule(dumpEvent); | 268 dumpEvent->deschedule(); |
262 } 263 264 /* 265 * If the period is not 0, we schedule the event. If this is called with a 266 * period that is less than the current tick, then we shift the first dump 267 * by curTick. This ensures that we do not schedule the event is the past. 268 */ 269 if (period != 0) { --- 13 unchanged lines hidden (view full) --- 283 * If the dumpEvent has been scheduled, but is scheduled in the past, then 284 * we need to shift the event to be at a valid point in time. Therefore, we 285 * shift the event by curTick. 286 */ 287 if (dumpEvent != NULL && 288 (dumpEvent->scheduled() && dumpEvent->when() < curTick())) { 289 // shift by curTick() and reschedule 290 Tick _when = dumpEvent->when(); | 269 } 270 271 /* 272 * If the period is not 0, we schedule the event. If this is called with a 273 * period that is less than the current tick, then we shift the first dump 274 * by curTick. This ensures that we do not schedule the event is the past. 275 */ 276 if (period != 0) { --- 13 unchanged lines hidden (view full) --- 290 * If the dumpEvent has been scheduled, but is scheduled in the past, then 291 * we need to shift the event to be at a valid point in time. Therefore, we 292 * shift the event by curTick. 293 */ 294 if (dumpEvent != NULL && 295 (dumpEvent->scheduled() && dumpEvent->when() < curTick())) { 296 // shift by curTick() and reschedule 297 Tick _when = dumpEvent->when(); |
291 mainEventQueue.reschedule(dumpEvent, _when + curTick()); | 298 dumpEvent->reschedule(_when + curTick()); |
292 } 293} 294 295} // namespace Stats | 299 } 300} 301 302} // namespace Stats |