eventq.cc (10905:a6ca6831e775) | eventq.cc (10906:3ab1d7ed6545) |
---|---|
1/* 2 * Copyright (c) 2000-2005 The Regents of The University of Michigan 3 * Copyright (c) 2008 The Hewlett-Packard Development Company 4 * Copyright (c) 2013 Advanced Micro Devices, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are --- 27 unchanged lines hidden (view full) --- 36#include <iostream> 37#include <string> 38#include <vector> 39 40#include "base/hashmap.hh" 41#include "base/misc.hh" 42#include "base/trace.hh" 43#include "cpu/smt.hh" | 1/* 2 * Copyright (c) 2000-2005 The Regents of The University of Michigan 3 * Copyright (c) 2008 The Hewlett-Packard Development Company 4 * Copyright (c) 2013 Advanced Micro Devices, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are --- 27 unchanged lines hidden (view full) --- 36#include <iostream> 37#include <string> 38#include <vector> 39 40#include "base/hashmap.hh" 41#include "base/misc.hh" 42#include "base/trace.hh" 43#include "cpu/smt.hh" |
44#include "debug/Config.hh" | 44#include "debug/Checkpoint.hh" |
45#include "sim/core.hh" 46#include "sim/eventq_impl.hh" 47 48using namespace std; 49 50Tick simQuantum = 0; 51 52// --- 195 unchanged lines hidden (view full) --- 248 SERIALIZE_SCALAR(_priority); 249 short _flags = flags; 250 SERIALIZE_SCALAR(_flags); 251} 252 253void 254Event::unserialize(CheckpointIn &cp) 255{ | 45#include "sim/core.hh" 46#include "sim/eventq_impl.hh" 47 48using namespace std; 49 50Tick simQuantum = 0; 51 52// --- 195 unchanged lines hidden (view full) --- 248 SERIALIZE_SCALAR(_priority); 249 short _flags = flags; 250 SERIALIZE_SCALAR(_flags); 251} 252 253void 254Event::unserialize(CheckpointIn &cp) 255{ |
256} | 256 assert(!scheduled()); |
257 | 257 |
258void 259Event::unserializeEvent(CheckpointIn &cp, EventQueue *eventq) 260{ 261 if (scheduled()) 262 eventq->deschedule(this); 263 | |
264 UNSERIALIZE_SCALAR(_when); 265 UNSERIALIZE_SCALAR(_priority); 266 | 258 UNSERIALIZE_SCALAR(_when); 259 UNSERIALIZE_SCALAR(_priority); 260 |
267 short _flags; | 261 FlagsType _flags; |
268 UNSERIALIZE_SCALAR(_flags); 269 270 // Old checkpoints had no concept of the Initialized flag 271 // so restoring from old checkpoints always fail. 272 // Events are initialized on construction but original code 273 // "flags = _flags" would just overwrite the initialization. 274 // So, read in the checkpoint flags, but then set the Initialized 275 // flag on top of it in order to avoid failures. 276 assert(initialized()); 277 flags = _flags; 278 flags.set(Initialized); 279 280 // need to see if original event was in a scheduled, unsquashed 281 // state, but don't want to restore those flags in the current 282 // object itself (since they aren't immediately true) | 262 UNSERIALIZE_SCALAR(_flags); 263 264 // Old checkpoints had no concept of the Initialized flag 265 // so restoring from old checkpoints always fail. 266 // Events are initialized on construction but original code 267 // "flags = _flags" would just overwrite the initialization. 268 // So, read in the checkpoint flags, but then set the Initialized 269 // flag on top of it in order to avoid failures. 270 assert(initialized()); 271 flags = _flags; 272 flags.set(Initialized); 273 274 // need to see if original event was in a scheduled, unsquashed 275 // state, but don't want to restore those flags in the current 276 // object itself (since they aren't immediately true) |
283 bool wasScheduled = flags.isSet(Scheduled) && !flags.isSet(Squashed); 284 flags.clear(Squashed | Scheduled); 285 286 if (wasScheduled) { 287 DPRINTF(Config, "rescheduling at %d\n", _when); 288 eventq->schedule(this, _when); | 277 if (flags.isSet(Scheduled) && !flags.isSet(Squashed)) { 278 flags.clear(Squashed | Scheduled); 279 } else { 280 DPRINTF(Checkpoint, "Event '%s' need to be scheduled @%d\n", 281 name(), _when); |
289 } 290} 291 292void 293EventQueue::serialize(CheckpointOut &cp) const 294{ 295 std::list<Event *> eventPtrs; 296 --- 27 unchanged lines hidden (view full) --- 324 UNSERIALIZE_SCALAR(numEvents); 325 326 std::string eventName; 327 for (int i = 0; i < numEvents; i++) { 328 // get the pointer value associated with the event 329 paramIn(cp, csprintf("event%d", i), eventName); 330 331 // create the event based on its pointer value | 282 } 283} 284 285void 286EventQueue::serialize(CheckpointOut &cp) const 287{ 288 std::list<Event *> eventPtrs; 289 --- 27 unchanged lines hidden (view full) --- 317 UNSERIALIZE_SCALAR(numEvents); 318 319 std::string eventName; 320 for (int i = 0; i < numEvents; i++) { 321 // get the pointer value associated with the event 322 paramIn(cp, csprintf("event%d", i), eventName); 323 324 // create the event based on its pointer value |
332 Serializable::create(cp, eventName); | 325 Serializable *obj(Serializable::create(cp, eventName)); 326 Event *event(dynamic_cast<Event *>(obj)); 327 fatal_if(!event, 328 "Event queue unserialized something that wasn't an event.\n"); 329 330 checkpointReschedule(event); |
333 } 334} 335 336void | 331 } 332} 333 334void |
335EventQueue::checkpointReschedule(Event *event) 336{ 337 // It's safe to call insert() directly here since this method 338 // should only be called when restoring from a checkpoint (which 339 // happens before thread creation). 340 if (event->flags.isSet(Event::Scheduled)) 341 insert(event); 342} 343void |
|
337EventQueue::dump() const 338{ 339 cprintf("============================================================\n"); 340 cprintf("EventQueue Dump (cycle %d)\n", curTick()); 341 cprintf("------------------------------------------------------------\n"); 342 343 if (empty()) 344 cprintf("<No Events>\n"); --- 140 unchanged lines hidden --- | 344EventQueue::dump() const 345{ 346 cprintf("============================================================\n"); 347 cprintf("EventQueue Dump (cycle %d)\n", curTick()); 348 cprintf("------------------------------------------------------------\n"); 349 350 if (empty()) 351 cprintf("<No Events>\n"); --- 140 unchanged lines hidden --- |