1/* 2 * Copyright (c) 2000-2005 The Regents of The University of Michigan 3 * Copyright (c) 2013 Advanced Micro Devices, Inc. 4 * Copyright (c) 2013 Mark D. Hill and David A. Wood 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 --- 53 unchanged lines hidden (view full) --- 62extern Tick simQuantum; 63 64//! Current number of allocated main event queues. 65extern uint32_t numMainEventQueues; 66 67//! Array for main event queues. 68extern std::vector<EventQueue *> mainEventQueue; 69 |
70//! The current event queue for the running thread. Access to this queue 71//! does not require any locking from the thread. 72 73extern __thread EventQueue *_curEventQueue; 74 |
75//! Current mode of execution: parallel / serial 76extern bool inParallelMode; 77 78//! Function for returning eventq queue for the provided 79//! index. The function allocates a new queue in case one 80//! does not exist for the index, provided that the index 81//! is with in bounds. 82EventQueue *getEventQueue(uint32_t index); --- 265 unchanged lines hidden (view full) --- 348 /// Get the event priority 349 Priority priority() const { return _priority; } 350 351 //! If this is part of a GlobalEvent, return the pointer to the 352 //! Global Event. By default, there is no GlobalEvent, so return 353 //! NULL. (Overridden in GlobalEvent::BarrierEvent.) 354 virtual BaseGlobalEvent *globalEvent() { return NULL; } 355 |
356 void serialize(CheckpointOut &cp) const override; 357 void unserialize(CheckpointIn &cp) override; |
358}; 359 |
360inline bool 361operator<(const Event &l, const Event &r) 362{ 363 return l.when() < r.when() || 364 (l.when() == r.when() && l.priority() < r.priority()); 365} 366 367inline bool --- 22 unchanged lines hidden (view full) --- 390 return l.when() == r.when() && l.priority() == r.priority(); 391} 392 393inline bool 394operator!=(const Event &l, const Event &r) 395{ 396 return l.when() != r.when() || l.priority() != r.priority(); 397} |
398 399/** 400 * Queue of events sorted in time order 401 * 402 * Events are scheduled (inserted into the event queue) using the 403 * schedule() method. This method either inserts a <i>synchronous</i> 404 * or <i>asynchronous</i> event. 405 * --- 71 unchanged lines hidden (view full) --- 477 //! Function for adding events to the async queue. The added events 478 //! are added to main event queue later. Threads, other than the 479 //! owning thread, should call this function instead of insert(). 480 void asyncInsert(Event *event); 481 482 EventQueue(const EventQueue &); 483 484 public: |
485 /** 486 * Temporarily migrate execution to a different event queue. 487 * 488 * An instance of this class temporarily migrates execution to a 489 * different event queue by releasing the current queue, locking 490 * the new queue, and updating curEventQueue(). This can, for 491 * example, be useful when performing IO across thread event 492 * queues when timing is not crucial (e.g., during fast --- 43 unchanged lines hidden (view full) --- 536 ~ScopedRelease() 537 { 538 eq.lock(); 539 } 540 541 private: 542 EventQueue &eq; 543 }; |
544 545 EventQueue(const std::string &n); 546 547 virtual const std::string name() const { return objName; } 548 void name(const std::string &st) { objName = st; } 549 550 //! Schedule the given event on this queue. Safe to call from any 551 //! thread. --- 99 unchanged lines hidden (view full) --- 651 */ 652 void checkpointReschedule(Event *event); 653 654 virtual ~EventQueue() { } 655}; 656 657void dumpMainQueue(); 658 |
659class EventManager 660{ 661 protected: 662 /** A pointer to this object's event queue */ 663 EventQueue *eventq; 664 665 public: 666 EventManager(EventManager &em) : eventq(em.eventq) {} --- 96 unchanged lines hidden (view full) --- 763 const std::string 764 name() const 765 { 766 return object->name() + ".wrapped_event"; 767 } 768 769 const char *description() const { return "EventWrapped"; } 770}; |
771 772#endif // __SIM_EVENTQ_HH__ |