eventq.cc (9356:b279bad40aa3) | eventq.cc (9983:2cce74fe359e) |
---|---|
1/* 2 * Copyright (c) 2000-2005 The Regents of The University of Michigan 3 * Copyright (c) 2008 The Hewlett-Packard Development Company | 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. |
|
4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer; 10 * redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the --- 29 unchanged lines hidden (view full) --- 41#include "base/trace.hh" 42#include "cpu/smt.hh" 43#include "debug/Config.hh" 44#include "sim/core.hh" 45#include "sim/eventq_impl.hh" 46 47using namespace std; 48 | 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 9 * met: redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer; 11 * redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the --- 29 unchanged lines hidden (view full) --- 42#include "base/trace.hh" 43#include "cpu/smt.hh" 44#include "debug/Config.hh" 45#include "sim/core.hh" 46#include "sim/eventq_impl.hh" 47 48using namespace std; 49 |
50Tick simQuantum = 0; 51 |
|
49// | 52// |
50// Main Event Queue | 53// Main Event Queues |
51// | 54// |
52// Events on this queue are processed at the *beginning* of each | 55// Events on these queues are processed at the *beginning* of each |
53// cycle, before the pipeline simulation is performed. 54// | 56// cycle, before the pipeline simulation is performed. 57// |
55EventQueue mainEventQueue("Main Event Queue"); | 58uint32_t numMainEventQueues = 0; 59vector<EventQueue *> mainEventQueue; 60__thread EventQueue *_curEventQueue = NULL; 61bool inParallelMode = false; |
56 | 62 |
63EventQueue * 64getEventQueue(uint32_t index) 65{ 66 while (numMainEventQueues <= index) { 67 numMainEventQueues++; 68 mainEventQueue.push_back( 69 new EventQueue(csprintf("MainEventQueue-%d", index))); 70 } 71 72 return mainEventQueue[index]; 73} 74 |
|
57#ifndef NDEBUG 58Counter Event::instanceCounter = 0; 59#endif 60 61Event::~Event() 62{ 63 assert(!scheduled()); 64 flags = 0; --- 86 unchanged lines hidden (view full) --- 151} 152 153void 154EventQueue::remove(Event *event) 155{ 156 if (head == NULL) 157 panic("event not found!"); 158 | 75#ifndef NDEBUG 76Counter Event::instanceCounter = 0; 77#endif 78 79Event::~Event() 80{ 81 assert(!scheduled()); 82 flags = 0; --- 86 unchanged lines hidden (view full) --- 169} 170 171void 172EventQueue::remove(Event *event) 173{ 174 if (head == NULL) 175 panic("event not found!"); 176 |
177 assert(event->queue == this); 178 |
|
159 // deal with an event on the head's 'in bin' list (event has the same 160 // time as the head) 161 if (*head == *event) { 162 head = Event::removeItem(event, head); 163 return; 164 } 165 166 // Find the 'in bin' list that this event belongs on --- 60 unchanged lines hidden (view full) --- 227 SERIALIZE_SCALAR(_priority); 228 short _flags = flags; 229 SERIALIZE_SCALAR(_flags); 230} 231 232void 233Event::unserialize(Checkpoint *cp, const string §ion) 234{ | 179 // deal with an event on the head's 'in bin' list (event has the same 180 // time as the head) 181 if (*head == *event) { 182 head = Event::removeItem(event, head); 183 return; 184 } 185 186 // Find the 'in bin' list that this event belongs on --- 60 unchanged lines hidden (view full) --- 247 SERIALIZE_SCALAR(_priority); 248 short _flags = flags; 249 SERIALIZE_SCALAR(_flags); 250} 251 252void 253Event::unserialize(Checkpoint *cp, const string §ion) 254{ |
255} 256 257void 258Event::unserialize(Checkpoint *cp, const string §ion, EventQueue *eventq) 259{ |
|
235 if (scheduled()) | 260 if (scheduled()) |
236 mainEventQueue.deschedule(this); | 261 eventq->deschedule(this); |
237 238 UNSERIALIZE_SCALAR(_when); 239 UNSERIALIZE_SCALAR(_priority); 240 241 short _flags; 242 UNSERIALIZE_SCALAR(_flags); 243 244 // Old checkpoints had no concept of the Initialized flag --- 9 unchanged lines hidden (view full) --- 254 // need to see if original event was in a scheduled, unsquashed 255 // state, but don't want to restore those flags in the current 256 // object itself (since they aren't immediately true) 257 bool wasScheduled = flags.isSet(Scheduled) && !flags.isSet(Squashed); 258 flags.clear(Squashed | Scheduled); 259 260 if (wasScheduled) { 261 DPRINTF(Config, "rescheduling at %d\n", _when); | 262 263 UNSERIALIZE_SCALAR(_when); 264 UNSERIALIZE_SCALAR(_priority); 265 266 short _flags; 267 UNSERIALIZE_SCALAR(_flags); 268 269 // Old checkpoints had no concept of the Initialized flag --- 9 unchanged lines hidden (view full) --- 279 // need to see if original event was in a scheduled, unsquashed 280 // state, but don't want to restore those flags in the current 281 // object itself (since they aren't immediately true) 282 bool wasScheduled = flags.isSet(Scheduled) && !flags.isSet(Squashed); 283 flags.clear(Squashed | Scheduled); 284 285 if (wasScheduled) { 286 DPRINTF(Config, "rescheduling at %d\n", _when); |
262 mainEventQueue.schedule(this, _when); | 287 eventq->schedule(this, _when); |
263 } 264} 265 266void 267EventQueue::serialize(ostream &os) 268{ 269 std::list<Event *> eventPtrs; 270 --- 112 unchanged lines hidden (view full) --- 383 Event* t = head; 384 head = s; 385 return t; 386} 387 388void 389dumpMainQueue() 390{ | 288 } 289} 290 291void 292EventQueue::serialize(ostream &os) 293{ 294 std::list<Event *> eventPtrs; 295 --- 112 unchanged lines hidden (view full) --- 408 Event* t = head; 409 head = s; 410 return t; 411} 412 413void 414dumpMainQueue() 415{ |
391 mainEventQueue.dump(); | 416 for (uint32_t i = 0; i < numMainEventQueues; ++i) { 417 mainEventQueue[i]->dump(); 418 } |
392} 393 394 395const char * 396Event::description() const 397{ 398 return "generic"; 399} --- 27 unchanged lines hidden (view full) --- 427#endif 428 cprintf("Scheduled for %d, priority %d\n", when(), _priority); 429 } else { 430 cprintf("Not Scheduled\n"); 431 } 432} 433 434EventQueue::EventQueue(const string &n) | 419} 420 421 422const char * 423Event::description() const 424{ 425 return "generic"; 426} --- 27 unchanged lines hidden (view full) --- 454#endif 455 cprintf("Scheduled for %d, priority %d\n", when(), _priority); 456 } else { 457 cprintf("Not Scheduled\n"); 458 } 459} 460 461EventQueue::EventQueue(const string &n) |
435 : objName(n), head(NULL), _curTick(0) 436{} | 462 : objName(n), head(NULL), _curTick(0), 463 async_queue_mutex(new std::mutex()) 464{ 465} 466 467void 468EventQueue::asyncInsert(Event *event) 469{ 470 async_queue_mutex->lock(); 471 async_queue.push_back(event); 472 async_queue_mutex->unlock(); 473} 474 475void 476EventQueue::handleAsyncInsertions() 477{ 478 assert(this == curEventQueue()); 479 async_queue_mutex->lock(); 480 481 while (!async_queue.empty()) { 482 insert(async_queue.front()); 483 async_queue.pop_front(); 484 } 485 486 async_queue_mutex->unlock(); 487} |