gem5
v20.1.0.0
|
#include "sim/simulate.hh"
#include <mutex>
#include <thread>
#include "base/logging.hh"
#include "base/pollevent.hh"
#include "base/types.hh"
#include "sim/async.hh"
#include "sim/eventq.hh"
#include "sim/sim_events.hh"
#include "sim/sim_exit.hh"
#include "sim/stat_control.hh"
Go to the source code of this file.
Functions | |
Event * | doSimLoop (EventQueue *) |
forward declaration More... | |
static void | thread_loop (EventQueue *queue) |
The main function for all subordinate threads (i.e., all threads other than the main thread). More... | |
GlobalSimLoopExitEvent * | simulate (Tick num_cycles) |
Simulate for num_cycles additional cycles. More... | |
static bool | testAndClearAsyncEvent () |
Test and clear the global async_event flag, such that each time the flag is cleared, only one thread returns true (and thus is assigned to handle the corresponding async event(s)). More... | |
Variables | |
std::mutex | asyncEventMutex |
Mutex for handling async events. More... | |
Barrier * | threadBarrier |
Global barrier for synchronizing threads entering/exiting the simulation loop. More... | |
GlobalSimLoopExitEvent * | simulate_limit_event = nullptr |
Event * doSimLoop | ( | EventQueue * | eventq | ) |
forward declaration
The main per-thread simulation loop.
This loop is executed by all simulation threads (the main thread and the subordinate threads) in parallel.
Definition at line 177 of file simulate.cc.
References async_event, async_exception, async_exit, async_io, async_statdump, async_statreset, curEventQueue(), curTick(), EventQueue::empty(), exitSimLoop(), EventQueue::handleAsyncInsertions(), X86ISA::lock, EventQueue::nextTick(), pollQueue, Stats::schedStatEvent(), PollQueue::service(), EventQueue::serviceOne(), and testAndClearAsyncEvent().
Referenced by simulate(), and thread_loop().
GlobalSimLoopExitEvent* simulate | ( | Tick | num_cycles | ) |
Simulate for num_cycles additional cycles.
If num_cycles is -1 (the default), do not limit simulation; some other event must terminate the loop. Exported to Python.
Delete the simulation quantum event.
Definition at line 80 of file simulate.cc.
References curTick(), BaseGlobalEvent::deschedule(), doSimLoop(), fatal, Event::globalEvent(), ArmISA::i, inform, inParallelMode, mainEventQueue, MaxTick, numMainEventQueues, EventBase::Progress_Event_Pri, BaseGlobalEvent::reschedule(), simQuantum, simulate_limit_event, thread_loop(), threadBarrier, and Barrier::wait().
Referenced by RubySystem::memWriteback(), pybind_init_event(), and RubySystem::startup().
|
static |
Test and clear the global async_event flag, such that each time the flag is cleared, only one thread returns true (and thus is assigned to handle the corresponding async event(s)).
Definition at line 157 of file simulate.cc.
References async_event, and asyncEventMutex.
Referenced by doSimLoop().
|
static |
The main function for all subordinate threads (i.e., all threads other than the main thread).
These threads start by waiting on threadBarrier. Once all threads have arrived at threadBarrier, they enter the simulation loop concurrently. When they exit the loop, they return to waiting on threadBarrier. This process is repeated until the simulation terminates.
Definition at line 64 of file simulate.cc.
References doSimLoop(), threadBarrier, and Barrier::wait().
Referenced by simulate().
std::mutex asyncEventMutex |
Mutex for handling async events.
Definition at line 46 of file simulate.cc.
Referenced by testAndClearAsyncEvent().
GlobalSimLoopExitEvent* simulate_limit_event = nullptr |
Definition at line 72 of file simulate.cc.
Referenced by simulate().
Barrier* threadBarrier |
Global barrier for synchronizing threads entering/exiting the simulation loop.
Definition at line 50 of file simulate.cc.
Referenced by simulate(), and thread_loop().