inorder: get rid of references to mainEventQueue.
authorSteve Reinhardt <steve.reinhardt@amd.com>
Sat, 8 Jan 2011 05:50:29 +0000 (21:50 -0800)
committerSteve Reinhardt <steve.reinhardt@amd.com>
Sat, 8 Jan 2011 05:50:29 +0000 (21:50 -0800)
Events need to be scheduled on the queue assigned
to the SimObject, not on the global queue (which
should be going away).
Also cleaned up a number of redundant expressions
that made the code unnecessarily verbose.

src/cpu/inorder/cpu.cc
src/cpu/inorder/cpu.hh
src/cpu/inorder/resource.cc
src/cpu/inorder/resource.hh
src/cpu/inorder/resource_pool.cc

index 5f723d0b3bd737b8aa1193b38239713df20deef5..bb324ce642ac35d9c2454b88e40174a08edb6736 100644 (file)
@@ -157,12 +157,12 @@ InOrderCPU::CPUEvent::description()
 void
 InOrderCPU::CPUEvent::scheduleEvent(int delay)
 {
+    Tick when = cpu->nextCycle(curTick + cpu->ticks(delay));
+
     if (squashed())
-        mainEventQueue.reschedule(this, cpu->nextCycle(curTick +
-                                                       cpu->ticks(delay)));
+        cpu->reschedule(this, when);
     else if (!scheduled())
-        mainEventQueue.schedule(this, cpu->nextCycle(curTick +
-                                                     cpu->ticks(delay)));
+        cpu->schedule(this, when);
 }
 
 void
@@ -540,7 +540,7 @@ InOrderCPU::tick()
         } else {
             //Tick next_tick = curTick + cycles(1);
             //tickEvent.schedule(next_tick);
-            mainEventQueue.schedule(&tickEvent, nextCycle(curTick + 1));
+            schedule(&tickEvent, nextCycle(curTick + 1));
             DPRINTF(InOrderCPU, "Scheduled CPU for next tick @ %i.\n", 
                     nextCycle(curTick + 1));
         }
@@ -701,7 +701,7 @@ InOrderCPU::scheduleCpuEvent(CPUEventType c_event, Fault fault,
     if (delay >= 0) {
         DPRINTF(InOrderCPU, "Scheduling CPU Event (%s) for cycle %i, [tid:%i].\n",
                 eventNames[c_event], curTick + delay, tid);
-        mainEventQueue.schedule(cpu_event, sked_tick);
+        schedule(cpu_event, sked_tick);
     } else {
         cpu_event->process();
         cpuEventRemoveList.push(cpu_event);
@@ -1403,7 +1403,7 @@ InOrderCPU::wakeCPU()
 
     numCycles += extra_cycles;
 
-    mainEventQueue.schedule(&tickEvent, nextCycle(curTick));
+    schedule(&tickEvent, nextCycle(curTick));
 }
 
 #if FULL_SYSTEM
index 3b2041cfa5fe1eb44f9fa4010dafca64886b7b83..42bae0d31a7d9abadab76eafbd08e115447c46f9 100644 (file)
@@ -156,12 +156,12 @@ class InOrderCPU : public BaseCPU
     /** Schedule tick event, regardless of its current state. */
     void scheduleTickEvent(int delay)
     {
+        Tick when = nextCycle(curTick + ticks(delay));
+
         if (tickEvent.squashed())
-          mainEventQueue.reschedule(&tickEvent, 
-                                    nextCycle(curTick + ticks(delay)));
+            reschedule(&tickEvent, when);
         else if (!tickEvent.scheduled())
-          mainEventQueue.schedule(&tickEvent, 
-                                  nextCycle(curTick + ticks(delay)));
+            schedule(&tickEvent, when);
     }
 
     /** Unschedule tick event, regardless of its current state. */
index 8cc8f9fe11423bd40eabd80efb36622de264125b..4eab89687484217bc2df3d6c00605632fb18a4c4 100644 (file)
@@ -498,3 +498,15 @@ ResourceEvent::description()
 
     return desc.c_str();
 }
+
+void
+ResourceEvent::scheduleEvent(int delay)
+{
+    InOrderCPU *cpu = resource->cpu;
+    Tick when = curTick + resource->ticks(delay);
+
+    if (squashed())
+        cpu->reschedule(this, when);
+    else if (!scheduled())
+        cpu->schedule(this, when);
+}
index 2e0143f9ff3d67acbddf0b1261e684e2ef40957d..5684dc166faa6b854b22e6dac5dffbde1c2277a4 100644 (file)
@@ -277,13 +277,7 @@ class ResourceEvent : public Event
     void setSlot(int slot) { slotIdx = slot; }
 
     /** Schedule resource event, regardless of its current state. */
-    void scheduleEvent(int delay)
-    {
-        if (squashed())
-          mainEventQueue.reschedule(this, curTick + resource->ticks(delay));
-        else if (!scheduled())
-          mainEventQueue.schedule(this, curTick + resource->ticks(delay));
-    }
+    void scheduleEvent(int delay);
 
     /** Unschedule resource event, regardless of its current state. */
     void unscheduleEvent()
index d7ae18d3d83769e6c43d43e9e3de335b9ab3a452..97ea889fde28357c426b4c8ee2431d794c9a29ca 100644 (file)
@@ -244,6 +244,8 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
 {
     assert(delay >= 0);
 
+    Tick when = cpu->nextCycle(curTick + cpu->ticks(delay));
+
     switch (e_type)
     {
       case InOrderCPU::ActivateThread:
@@ -258,9 +260,7 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
                                  inst->squashingStage,
                                  inst->bdelaySeqNum,
                                  inst->readTid());
-            mainEventQueue.schedule(res_pool_event, 
-                                    cpu->nextCycle(curTick +
-                                                   cpu->ticks(delay)));
+            cpu->schedule(res_pool_event, when);
         }
         break;
 
@@ -278,19 +278,17 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
                                  inst->bdelaySeqNum,
                                  tid);
 
-            mainEventQueue.schedule(res_pool_event, 
-                                    cpu->nextCycle(curTick +
-                                                   cpu->ticks(delay)));
-
+            cpu->schedule(res_pool_event, when);
         }
         break;
 
       case InOrderCPU::SuspendThread:
         {
+            // not sure why we add another nextCycle() call here...
+            Tick sked_tick = cpu->nextCycle(when);
 
             DPRINTF(Resource, "Scheduling Suspend Thread Resource Pool "
-                    "Event for tick %i.\n",
-                    cpu->nextCycle(cpu->nextCycle(curTick + cpu->ticks(delay))));
+                    "Event for tick %i.\n", sked_tick);
 
             ResPoolEvent *res_pool_event = new ResPoolEvent(this,
                                                             e_type,
@@ -299,10 +297,7 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
                                                             inst->bdelaySeqNum,
                                                             tid);
 
-            Tick sked_tick = curTick + cpu->ticks(delay);
-            mainEventQueue.schedule(res_pool_event,
-                                    cpu->nextCycle(cpu->nextCycle(sked_tick)));
-
+            cpu->schedule(res_pool_event, sked_tick);
         }
         break;
 
@@ -316,10 +311,7 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
                                  inst->squashingStage,
                                  inst->seqNum,
                                  inst->readTid());
-            mainEventQueue.schedule(res_pool_event, 
-                                    cpu->nextCycle(curTick +
-                                                   cpu->ticks(delay)));
-
+            cpu->schedule(res_pool_event, when);
         }
         break;
 
@@ -333,9 +325,7 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
                                  inst->squashingStage,
                                  inst->bdelaySeqNum,
                                  inst->readTid());
-            mainEventQueue.schedule(res_pool_event, 
-                                    cpu->nextCycle(curTick +
-                                                   cpu->ticks(delay)));
+            cpu->schedule(res_pool_event, when);
         }
         break;
 
@@ -350,23 +340,21 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
                                  inst->squashingStage,
                                  inst->seqNum - 1,
                                  inst->readTid());
-            mainEventQueue.schedule(res_pool_event, 
-                                    cpu->nextCycle(curTick + cpu->ticks(delay)));
+            cpu->schedule(res_pool_event, when);
         }
         break;
 
       case ResourcePool::UpdateAfterContextSwitch:
         {
-            DPRINTF(Resource, "Scheduling UpdatePC Resource Pool Event for tick %i.\n",
+            DPRINTF(Resource, "Scheduling UpdatePC Resource Pool Event "
+                    "for tick %i.\n",
                     curTick + delay);
             ResPoolEvent *res_pool_event = new ResPoolEvent(this,e_type,
                                                             inst,
                                                             inst->squashingStage,
                                                             inst->seqNum,
                                                             inst->readTid());
-            mainEventQueue.schedule(res_pool_event,
-                                    cpu->nextCycle(curTick + cpu->ticks(delay)));
-
+            cpu->schedule(res_pool_event, when);
         }
         break;
 
@@ -552,16 +540,13 @@ ResourcePool::ResPoolEvent::description()
 void
 ResourcePool::ResPoolEvent::scheduleEvent(int delay)
 {
+    InOrderCPU *cpu = resPool->cpu;
+    Tick when = cpu->nextCycle(curTick + cpu->ticks(delay));
+
     if (squashed()) {
-        mainEventQueue.reschedule(this,
-                                  resPool->cpu->nextCycle(curTick +
-                                                          resPool->
-                                                          cpu->ticks(delay)));
+        cpu->reschedule(this, when);
     } else if (!scheduled()) {
-        mainEventQueue.schedule(this,
-                                resPool->cpu->nextCycle(curTick +
-                                                        resPool->
-                                                        cpu->ticks(delay)));
+        cpu->schedule(this, when);
     }
 }