gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
simulate.cc File Reference
#include "sim/simulate.hh"
#include <mutex>
#include <thread>
#include "base/misc.hh"
#include "base/pollevent.hh"
#include "base/types.hh"
#include "sim/async.hh"
#include "sim/eventq_impl.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

EventdoSimLoop (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...
 
GlobalSimLoopExitEventsimulate (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...
 
BarrierthreadBarrier
 Global barrier for synchronizing threads entering/exiting the simulation loop. More...
 
GlobalSimLoopExitEventsimulate_limit_event = nullptr
 

Function Documentation

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 180 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.

Returns
The SimLoopExitEvent that caused the loop to exit.

Delete the simulation quantum event.

Definition at line 83 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, thread_loop(), and Barrier::wait().

Referenced by RubySystem::memWriteback(), pybind_init_event(), and RubySystem::startup().

static bool testAndClearAsyncEvent ( )
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 160 of file simulate.cc.

References async_event, and asyncEventMutex.

Referenced by doSimLoop().

static void thread_loop ( EventQueue queue)
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 67 of file simulate.cc.

References doSimLoop(), and Barrier::wait().

Referenced by simulate().

Variable Documentation

std::mutex asyncEventMutex

Mutex for handling async events.

Definition at line 49 of file simulate.cc.

Referenced by testAndClearAsyncEvent().

GlobalSimLoopExitEvent* simulate_limit_event = nullptr

Definition at line 75 of file simulate.cc.

Barrier* threadBarrier

Global barrier for synchronizing threads entering/exiting the simulation loop.

Definition at line 53 of file simulate.cc.


Generated on Fri Jun 9 2017 13:03:59 for gem5 by doxygen 1.8.6