summaryrefslogtreecommitdiff
path: root/src/sim/eventq_impl.hh
diff options
context:
space:
mode:
authorSteve Reinhardt ext:(%2C%20Nilay%20Vaish%20%3Cnilay%40cs.wisc.edu%3E%2C%20Ali%20Saidi%20%3CAli.Saidi%40ARM.com%3E) <stever@gmail.com>2013-11-25 11:21:00 -0600
committerSteve Reinhardt ext:(%2C%20Nilay%20Vaish%20%3Cnilay%40cs.wisc.edu%3E%2C%20Ali%20Saidi%20%3CAli.Saidi%40ARM.com%3E) <stever@gmail.com>2013-11-25 11:21:00 -0600
commitde366a16f11b7e27a5b5e064a2a773052568428e (patch)
tree9bed0ebc9801c118e0f17702a979a659a59a67df /src/sim/eventq_impl.hh
parent8a53da22c2f07aed924a45ab296f7468d842d7f6 (diff)
downloadgem5-de366a16f11b7e27a5b5e064a2a773052568428e.tar.xz
sim: simulate with multiple threads and event queues
This patch adds support for simulating with multiple threads, each of which operates on an event queue. Each sim object specifies which eventq is would like to be on. A custom barrier implementation is being added using which eventqs synchronize. The patch was tested in two different configurations: 1. ruby_network_test.py: in this simulation L1 cache controllers receive requests from the cpu. The requests are replied to immediately without any communication taking place with any other level. 2. twosys-tsunami-simple-atomic: this configuration simulates a client-server system which are connected by an ethernet link. We still lack the ability to communicate using message buffers or ports. But other things like simulation start and end, synchronizing after every quantum are working. Committed by: Nilay Vaish
Diffstat (limited to 'src/sim/eventq_impl.hh')
-rw-r--r--src/sim/eventq_impl.hh28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/sim/eventq_impl.hh b/src/sim/eventq_impl.hh
index c53a4da77..360731d7b 100644
--- a/src/sim/eventq_impl.hh
+++ b/src/sim/eventq_impl.hh
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2012 The Regents of The University of Michigan
- * Copyright (c) 2012 Mark D. Hill and David A. Wood
+ * Copyright (c) 2012-2013 Mark D. Hill and David A. Wood
+ * Copyright (c) 2013 Advanced Micro Devices, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,19 +39,26 @@
#include "sim/eventq.hh"
inline void
-EventQueue::schedule(Event *event, Tick when)
+EventQueue::schedule(Event *event, Tick when, bool global)
{
assert(when >= getCurTick());
assert(!event->scheduled());
assert(event->initialized());
event->setWhen(when, this);
- insert(event);
+
+ // The check below is to make sure of two things
+ // a. a thread schedules local events on other queues through the asyncq
+ // b. a thread schedules global events on the asyncq, whether or not
+ // this event belongs to this eventq. This is required to maintain
+ // a total order amongst the global events. See global_event.{cc,hh}
+ // for more explanation.
+ if (inParallelMode && (this != curEventQueue() || global)) {
+ asyncInsert(event);
+ } else {
+ insert(event);
+ }
event->flags.set(Event::Scheduled);
- if (this == &mainEventQueue)
- event->flags.set(Event::IsMainQueue);
- else
- event->flags.clear(Event::IsMainQueue);
if (DTRACE(Event))
event->trace("scheduled");
@@ -61,6 +69,7 @@ EventQueue::deschedule(Event *event)
{
assert(event->scheduled());
assert(event->initialized());
+ assert(!inParallelMode || this == curEventQueue());
remove(event);
@@ -80,6 +89,7 @@ EventQueue::reschedule(Event *event, Tick when, bool always)
assert(when >= getCurTick());
assert(always || event->scheduled());
assert(event->initialized());
+ assert(!inParallelMode || this == curEventQueue());
if (event->scheduled())
remove(event);
@@ -88,10 +98,6 @@ EventQueue::reschedule(Event *event, Tick when, bool always)
insert(event);
event->flags.clear(Event::Squashed);
event->flags.set(Event::Scheduled);
- if (this == &mainEventQueue)
- event->flags.set(Event::IsMainQueue);
- else
- event->flags.clear(Event::IsMainQueue);
if (DTRACE(Event))
event->trace("rescheduled");