gem5  v20.1.0.0
Functions | Variables
simulate.cc File Reference
#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

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

◆ doSimLoop()

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().

◆ simulate()

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 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().

◆ testAndClearAsyncEvent()

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 157 of file simulate.cc.

References async_event, and asyncEventMutex.

Referenced by doSimLoop().

◆ thread_loop()

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 64 of file simulate.cc.

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

Referenced by simulate().

Variable Documentation

◆ asyncEventMutex

std::mutex asyncEventMutex

Mutex for handling async events.

Definition at line 46 of file simulate.cc.

Referenced by testAndClearAsyncEvent().

◆ simulate_limit_event

GlobalSimLoopExitEvent* simulate_limit_event = nullptr

Definition at line 72 of file simulate.cc.

Referenced by simulate().

◆ threadBarrier

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().


Generated on Wed Sep 30 2020 14:02:19 for gem5 by doxygen 1.8.17