eventq.hh (11800:54436a1784dc) | eventq.hh (11990:5fad911cc326) |
---|---|
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 | 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#ifndef SWIG | |
71//! The current event queue for the running thread. Access to this queue 72//! does not require any locking from the thread. 73 74extern __thread EventQueue *_curEventQueue; 75 | 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 |
76#endif 77 | |
78//! Current mode of execution: parallel / serial 79extern bool inParallelMode; 80 81//! Function for returning eventq queue for the provided 82//! index. The function allocates a new queue in case one 83//! does not exist for the index, provided that the index 84//! is with in bounds. 85EventQueue *getEventQueue(uint32_t index); --- 265 unchanged lines hidden (view full) --- 351 /// Get the event priority 352 Priority priority() const { return _priority; } 353 354 //! If this is part of a GlobalEvent, return the pointer to the 355 //! Global Event. By default, there is no GlobalEvent, so return 356 //! NULL. (Overridden in GlobalEvent::BarrierEvent.) 357 virtual BaseGlobalEvent *globalEvent() { return NULL; } 358 | 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 |
359#ifndef SWIG | |
360 void serialize(CheckpointOut &cp) const override; 361 void unserialize(CheckpointIn &cp) override; | 356 void serialize(CheckpointOut &cp) const override; 357 void unserialize(CheckpointIn &cp) override; |
362#endif | |
363}; 364 | 358}; 359 |
365#ifndef SWIG | |
366inline bool 367operator<(const Event &l, const Event &r) 368{ 369 return l.when() < r.when() || 370 (l.when() == r.when() && l.priority() < r.priority()); 371} 372 373inline bool --- 22 unchanged lines hidden (view full) --- 396 return l.when() == r.when() && l.priority() == r.priority(); 397} 398 399inline bool 400operator!=(const Event &l, const Event &r) 401{ 402 return l.when() != r.when() || l.priority() != r.priority(); 403} | 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} |
404#endif | |
405 406/** 407 * Queue of events sorted in time order 408 * 409 * Events are scheduled (inserted into the event queue) using the 410 * schedule() method. This method either inserts a <i>synchronous</i> 411 * or <i>asynchronous</i> event. 412 * --- 71 unchanged lines hidden (view full) --- 484 //! Function for adding events to the async queue. The added events 485 //! are added to main event queue later. Threads, other than the 486 //! owning thread, should call this function instead of insert(). 487 void asyncInsert(Event *event); 488 489 EventQueue(const EventQueue &); 490 491 public: | 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: |
492#ifndef SWIG | |
493 /** 494 * Temporarily migrate execution to a different event queue. 495 * 496 * An instance of this class temporarily migrates execution to a 497 * different event queue by releasing the current queue, locking 498 * the new queue, and updating curEventQueue(). This can, for 499 * example, be useful when performing IO across thread event 500 * queues when timing is not crucial (e.g., during fast --- 43 unchanged lines hidden (view full) --- 544 ~ScopedRelease() 545 { 546 eq.lock(); 547 } 548 549 private: 550 EventQueue &eq; 551 }; | 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 }; |
552#endif | |
553 554 EventQueue(const std::string &n); 555 556 virtual const std::string name() const { return objName; } 557 void name(const std::string &st) { objName = st; } 558 559 //! Schedule the given event on this queue. Safe to call from any 560 //! thread. --- 99 unchanged lines hidden (view full) --- 660 */ 661 void checkpointReschedule(Event *event); 662 663 virtual ~EventQueue() { } 664}; 665 666void dumpMainQueue(); 667 | 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 |
668#ifndef SWIG | |
669class EventManager 670{ 671 protected: 672 /** A pointer to this object's event queue */ 673 EventQueue *eventq; 674 675 public: 676 EventManager(EventManager &em) : eventq(em.eventq) {} --- 96 unchanged lines hidden (view full) --- 773 const std::string 774 name() const 775 { 776 return object->name() + ".wrapped_event"; 777 } 778 779 const char *description() const { return "EventWrapped"; } 780}; | 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}; |
781#endif | |
782 783#endif // __SIM_EVENTQ_HH__ | 771 772#endif // __SIM_EVENTQ_HH__ |