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 * 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 --- 11 unchanged lines hidden (view full) --- 33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 * 40 * Authors: Nathan Binkert |
41 * Sascha Bischoff |
42 */ 43 44// This file will contain default statistics for the simulator that 45// don't really belong to a specific simulator object 46 47#include <fstream> 48#include <iostream> 49#include <list> --- 19 unchanged lines hidden (view full) --- 69Stats::Value finalTick; 70Stats::Value simFreq; 71 72namespace Stats { 73 74Time statTime(true); 75Tick startTick; 76 |
77Event *dumpEvent; 78 |
79struct SimTicksReset : public Callback 80{ 81 void process() 82 { 83 statTime.setTimer(); 84 startTick = curTick(); 85 } 86}; --- 121 unchanged lines hidden (view full) --- 208} 209 210void 211initSimStats() 212{ 213 static Global global; 214} 215 |
216/** 217 * Event to dump and/or reset the statistics. 218 */ |
219class StatEvent : public Event 220{ 221 private: 222 bool dump; 223 bool reset; 224 Tick repeat; 225 226 public: --- 16 unchanged lines hidden (view full) --- 243 Stats::schedStatEvent(dump, reset, curTick() + repeat, repeat); 244 } 245 } 246}; 247 248void 249schedStatEvent(bool dump, bool reset, Tick when, Tick repeat) 250{ |
251 dumpEvent = new StatEvent(dump, reset, repeat); 252 mainEventQueue.schedule(dumpEvent, when); |
253} 254 |
255void 256periodicStatDump(uint64_t period) 257{ 258 /* 259 * If the period is set to 0, then we do not want to dump periodically, 260 * thus we deschedule the event. Else, if the period is not 0, but the event 261 * has already been scheduled, we need to get rid of the old event before we 262 * create a new one, as the old event will no longer be moved forward in the 263 * event that we resume from a checkpoint. 264 */ 265 if (dumpEvent != NULL && (period == 0 || dumpEvent->scheduled())) { 266 // Event should AutoDelete, so we do not need to free it. 267 mainEventQueue.deschedule(dumpEvent); 268 } 269 270 /* 271 * If the period is not 0, we schedule the event. If this is called with a 272 * period that is less than the current tick, then we shift the first dump 273 * by curTick. This ensures that we do not schedule the event is the past. 274 */ 275 if (period != 0) { 276 // Schedule the event 277 if (period >= curTick()) { 278 schedStatEvent(true, true, (Tick)period, (Tick)period); 279 } else { 280 schedStatEvent(true, true, (Tick)period + curTick(), (Tick)period); 281 } 282 } 283} 284 285void 286updateEvents() 287{ 288 /* 289 * If the dumpEvent has been scheduled, but is scheduled in the past, then 290 * we need to shift the event to be at a valid point in time. Therefore, we 291 * shift the event by curTick. 292 */ 293 if (dumpEvent != NULL && 294 (dumpEvent->scheduled() && dumpEvent->when() < curTick())) { 295 // shift by curTick() and reschedule 296 Tick _when = dumpEvent->when(); 297 mainEventQueue.reschedule(dumpEvent, _when + curTick()); 298 } 299} 300 |
301} // namespace Stats |