Add in Context IDs to the simulator. From now on, cpuId is almost never used,
authorLisa Hsu <hsul@eecs.umich.edu>
Mon, 3 Nov 2008 02:57:07 +0000 (21:57 -0500)
committerLisa Hsu <hsul@eecs.umich.edu>
Mon, 3 Nov 2008 02:57:07 +0000 (21:57 -0500)
the primary identifier for a hardware context should be contextId().  The
concept of threads within a CPU remains, in the form of threadId() because
sometimes you need to know which context within a cpu to manipulate.

37 files changed:
src/arch/alpha/locked_mem.hh
src/arch/mips/locked_mem.hh
src/arch/sparc/ua2005.cc
src/arch/x86/tlb.cc
src/cpu/base.cc
src/cpu/base_dyn_inst.hh
src/cpu/checker/cpu_impl.hh
src/cpu/o3/cpu.cc
src/cpu/o3/fetch_impl.hh
src/cpu/o3/lsq.hh
src/cpu/o3/lsq_impl.hh
src/cpu/o3/thread_context.hh
src/cpu/o3/thread_context_impl.hh
src/cpu/ozone/cpu_impl.hh
src/cpu/ozone/front_end_impl.hh
src/cpu/simple/atomic.cc
src/cpu/simple/timing.cc
src/cpu/simple_thread.cc
src/cpu/thread_context.cc
src/cpu/thread_context.hh
src/cpu/thread_state.hh
src/dev/alpha/backdoor.cc
src/dev/alpha/tsunami_cchip.cc
src/dev/mips/malta_cchip.cc
src/dev/sinic.cc
src/dev/sparc/iob.cc
src/mem/cache/blk.hh
src/mem/cache/prefetch/base.cc
src/mem/cache/prefetch/ghb.cc
src/mem/cache/prefetch/ghb.hh
src/mem/cache/prefetch/stride.cc
src/mem/cache/prefetch/stride.hh
src/mem/physical.cc
src/mem/physical.hh
src/mem/request.hh
src/sim/system.cc
src/sim/system.hh

index 6f4f5a7487a89cccd69cbecdce7f08f4e874ff5e..e8928ba083e91c35c281e9bc5ea860f0254afef6 100644 (file)
@@ -85,9 +85,9 @@ handleLockedWrite(XC *xc, Request *req)
             stCondFailures++;
             xc->setStCondFailures(stCondFailures);
             if (stCondFailures % 100000 == 0) {
-                warn("cpu %d: %d consecutive "
+                warn("context %d: %d consecutive "
                      "store conditional failures\n",
-                     xc->cpuId(), stCondFailures);
+                     xc->contextId(), stCondFailures);
             }
 
             // store conditional failed already, so don't issue it to mem
index 5877b14394c41ff55695be0c2681cdd0c56a6b15..9f41ba0750bdc4c7729f023a17df8591f506ac8e 100644 (file)
@@ -83,9 +83,9 @@ handleLockedWrite(XC *xc, Request *req)
             stCondFailures++;
             xc->setStCondFailures(stCondFailures);
             if (stCondFailures % 10 == 0) {
-                warn("%i: cpu %d: %d consecutive "
+                warn("%i: context %d: %d consecutive "
                      "store conditional failures\n",
-                     curTick, xc->cpuId(), stCondFailures);
+                     curTick, xc->contextId(), stCondFailures);
             }
 
             if (stCondFailures == 5000) {
index 6961a24e943e8131de9a6bda021b80a34e36a2fa..502033d9766a7d4363efd2cfec89c4979113317b 100644 (file)
@@ -257,11 +257,11 @@ MiscRegFile::readFSReg(int miscReg, ThreadContext * tc)
         temp = readRegNoEffect(miscReg) & (STS::active | STS::speculative);
         // Check that the CPU array is fully populated
         // (by calling getNumCPus())
-        assert(sys->getNumCPUs() > tc->cpuId());
+        assert(sys->getNumContexts() > tc->contextId());
 
-        temp |= tc->cpuId()  << STS::shft_id;
+        temp |= tc->contextId()  << STS::shft_id;
 
-        for (x = tc->cpuId() & ~3; x < sys->threadContexts.size(); x++) {
+        for (x = tc->contextId() & ~3; x < sys->threadContexts.size(); x++) {
             switch (sys->threadContexts[x]->status()) {
               case ThreadContext::Active:
                 temp |= STS::st_run << (STS::shft_fsm0 -
index 17374fa0ced4781b324a97147413b8f2dae8d513..4980c5fe50792764b1bdb30109955e3392bbe5ba 100644 (file)
@@ -654,7 +654,7 @@ TLB::translate(RequestPtr &req, ThreadContext *tc, bool write, bool execute)
         */
         // Force the access to be uncacheable.
         req->setFlags(req->getFlags() | UNCACHEABLE);
-        req->setPaddr(x86LocalAPICAddress(tc->cpuId(), paddr - baseAddr));
+        req->setPaddr(x86LocalAPICAddress(tc->contextId(), paddr - baseAddr));
     }
 #endif
     return NoFault;
index 4845cbfaf7041c66a5c4910ffd3c8bf1a5aa1405..6409255f637fbec1da59a1e71ba4f1a3f3195d9b 100644 (file)
@@ -285,9 +285,9 @@ BaseCPU::registerThreadContexts()
     for (int i = 0; i < threadContexts.size(); ++i) {
         ThreadContext *tc = threadContexts[i];
 
-        system->registerThreadContext(tc);
+        tc->setContextId(system->registerThreadContext(tc));
 #if !FULL_SYSTEM
-        tc->getProcessPtr()->assignThreadContext(tc->cpuId());
+        tc->getProcessPtr()->assignThreadContext(tc->contextId());
 #endif
     }
 }
@@ -328,8 +328,8 @@ BaseCPU::takeOverFrom(BaseCPU *oldCPU, Port *ic, Port *dc)
 
         CpuEvent::replaceThreadContext(oldTC, newTC);
 
-        assert(newTC->cpuId() == oldTC->cpuId());
-        system->replaceThreadContext(newTC, newTC->cpuId());
+        assert(newTC->contextId() == oldTC->contextId());
+        system->replaceThreadContext(newTC, newTC->contextId());
 
         if (DTRACE(Context))
             ThreadContext::compare(oldTC, newTC);
index e0de3a372397770a905d5e8e0591b8152d0149be..3520fafaa2c14e882647e1dacc95716d61b9de70 100644 (file)
@@ -414,6 +414,9 @@ class BaseDynInst : public FastAlloc, public RefCounted
     /** Read this CPU's ID. */
     int cpuId() { return cpu->cpuId(); }
 
+    /** Read this context's system-wide ID **/
+    int contextId() { return thread->contextId(); }
+
     /** Returns the fault type. */
     Fault getFault() { return fault; }
 
@@ -868,7 +871,7 @@ BaseDynInst<Impl>::translateDataReadAddr(Addr vaddr, Addr &paddr,
     reqMade = true;
     Request *req = new Request();
     req->setVirt(asid, vaddr, size, flags, PC);
-    req->setThreadContext(thread->cpuId(), threadNumber);
+    req->setThreadContext(thread->contextId(), threadNumber);
 
     fault = cpu->translateDataReadReq(req, thread);
 
@@ -887,7 +890,7 @@ BaseDynInst<Impl>::read(Addr addr, T &data, unsigned flags)
     reqMade = true;
     Request *req = new Request();
     req->setVirt(asid, addr, sizeof(T), flags, this->PC);
-    req->setThreadContext(thread->cpuId(), threadNumber);
+    req->setThreadContext(thread->contextId(), threadNumber);
 
     fault = cpu->translateDataReadReq(req, thread);
 
@@ -942,7 +945,7 @@ BaseDynInst<Impl>::translateDataWriteAddr(Addr vaddr, Addr &paddr,
     reqMade = true;
     Request *req = new Request();
     req->setVirt(asid, vaddr, size, flags, PC);
-    req->setThreadContext(thread->cpuId(), threadNumber);
+    req->setThreadContext(thread->contextId(), threadNumber);
 
     fault = cpu->translateDataWriteReq(req, thread);
 
@@ -966,7 +969,7 @@ BaseDynInst<Impl>::write(T data, Addr addr, unsigned flags, uint64_t *res)
     reqMade = true;
     Request *req = new Request();
     req->setVirt(asid, addr, sizeof(T), flags, this->PC);
-    req->setThreadContext(thread->cpuId(), threadNumber);
+    req->setThreadContext(thread->contextId(), threadNumber);
 
     fault = cpu->translateDataWriteReq(req, thread);
 
index 9f6fa2b6d2eedaced56fec981d811974be4cbf3f..0428e88065b566315ac1e3096271536e1bf1da60 100644 (file)
@@ -152,7 +152,8 @@ Checker<DynInstPtr>::verify(DynInstPtr &completed_inst)
         memReq = new Request(inst->threadNumber, fetch_PC,
                              sizeof(uint32_t),
                              IFETCH_FLAGS(thread->readPC()),
-                             fetch_PC, thread->cpuId(), inst->threadNumber);
+                             fetch_PC, thread->contextId(),
+                             inst->threadNumber);
 
         bool succeeded = translateInstReq(memReq);
 
index b7cf4f1c08a52542721e34d6f3ef54312004b0e6..26c15526247bca4aa5ba42947e1880bc992ec65d 100644 (file)
@@ -589,9 +589,7 @@ template <class Impl>
 void
 FullO3CPU<Impl>::init()
 {
-    if (!deferRegistration) {
-        registerThreadContexts();
-    }
+    BaseCPU::init();
 
     // Set inSyscall so that the CPU doesn't squash when initially
     // setting up registers.
@@ -610,7 +608,7 @@ FullO3CPU<Impl>::init()
         }
 
 #if FULL_SYSTEM
-        TheISA::initCPU(src_tc, src_tc->cpuId());
+        TheISA::initCPU(src_tc, src_tc->contextId());
 #endif
     }
 
index 35031663ee71591cce9f481d7c1c599817451006..cff6db29966aa631ef73b208094a0f2ab0b09598 100644 (file)
@@ -362,7 +362,7 @@ template<class Impl>
 void
 DefaultFetch<Impl>::processCacheCompletion(PacketPtr pkt)
 {
-    unsigned tid = pkt->req->getThreadNum();
+    unsigned tid = pkt->req->threadId();
 
     DPRINTF(Fetch, "[tid:%u] Waking up from cache miss.\n",tid);
 
@@ -593,7 +593,8 @@ DefaultFetch<Impl>::fetchCacheLine(Addr fetch_PC, Fault &ret_fault, unsigned tid
     // Set the appropriate read size and flags as well.
     // Build request here.
     RequestPtr mem_req = new Request(tid, block_PC, cacheBlkSize, 0,
-                                     fetch_PC, cpu->cpuId(), tid);
+                                     fetch_PC, cpu->thread[tid]->contextId(),
+                                     tid);
 
     memReq[tid] = mem_req;
 
index f8a825726487000b33ec9568f43b671768078648..cf27552d424c218e066c0eac5921d957c424bf7e 100644 (file)
@@ -371,7 +371,7 @@ template <class T>
 Fault
 LSQ<Impl>::read(RequestPtr req, T &data, int load_idx)
 {
-    unsigned tid = req->getThreadNum();
+    unsigned tid = req->threadId();
 
     return thread[tid].read(req, data, load_idx);
 }
@@ -381,7 +381,7 @@ template <class T>
 Fault
 LSQ<Impl>::write(RequestPtr req, T &data, int store_idx)
 {
-    unsigned tid = req->getThreadNum();
+    unsigned tid = req->threadId();
 
     return thread[tid].write(req, data, store_idx);
 }
index 5aea020a95f1d6536ff723bd4eef577cd63df684..8f9f6308129c843dc23e46bce595e0dc0e17c383 100644 (file)
@@ -85,7 +85,7 @@ LSQ<Impl>::DcachePort::recvTiming(PacketPtr pkt)
     if (pkt->isError())
         DPRINTF(LSQ, "Got error packet back for address: %#X\n", pkt->getAddr());
     if (pkt->isResponse()) {
-        lsq->thread[pkt->req->getThreadNum()].completeDataAccess(pkt);
+        lsq->thread[pkt->req->threadId()].completeDataAccess(pkt);
     }
     else {
         // must be a snoop
index d571d25db5d6a7f9452f91eff2e2936611664ec7..c237b9587829b185681b44abfc995856618bc68a 100755 (executable)
@@ -78,6 +78,10 @@ class O3ThreadContext : public ThreadContext
     /** Reads this CPU's ID. */
     virtual int cpuId() { return cpu->cpuId(); }
 
+    virtual int contextId() { return thread->contextId(); }
+
+    virtual void setContextId(int id) { thread->setContextId(id); }
+
 #if FULL_SYSTEM
     /** Returns a pointer to the system. */
     virtual System *getSystemPtr() { return cpu->system; }
index 853ee2c63b65f7569ee77bc6bfaa960b574843bd..50f6e58b344846b363bc7d23c1ed5dc529e24f7b 100755 (executable)
@@ -63,6 +63,7 @@ O3ThreadContext<Impl>::takeOverFrom(ThreadContext *old_context)
     // copy over functional state
     setStatus(old_context->status());
     copyArchRegs(old_context);
+    setContextId(old_context->contextId());
 
 #if !FULL_SYSTEM
     thread->funcExeInst = old_context->readFuncExeInst();
index 52376afd8e550a99db136b96dbd653dae2b53101..eef1a7b2f2ab5e42eadbdfee831a79b337409973 100644 (file)
@@ -417,7 +417,7 @@ OzoneCPU<Impl>::init()
         ThreadContext *tc = threadContexts[i];
 
         // initialize CPU, including PC
-        TheISA::initCPU(tc, tc->cpuId());
+        TheISA::initCPU(tc, tc->contextId());
     }
 #endif
     frontEnd->renameTable.copyFrom(thread.renameTable);
@@ -734,14 +734,6 @@ OzoneCPU<Impl>::OzoneTC::getCpuPtr()
     return cpu;
 }
 
-template <class Impl>
-void
-OzoneCPU<Impl>::OzoneTC::setCpuId(int id)
-{
-    cpu->cpuId = id;
-    thread->setCpuId(id);
-}
-
 template <class Impl>
 void
 OzoneCPU<Impl>::OzoneTC::setStatus(Status new_status)
@@ -804,6 +796,7 @@ OzoneCPU<Impl>::OzoneTC::takeOverFrom(ThreadContext *old_context)
     setStatus(old_context->status());
     copyArchRegs(old_context);
     setCpuId(old_context->cpuId());
+    setContextId(old_context->contextId());
 
     thread->setInst(old_context->getInst());
 #if !FULL_SYSTEM
index df3609e276fdde97cfacd564d184f4f85eadd147..b1e13111517115bd1134fc55b56afd45e5ad88f5 100644 (file)
@@ -477,7 +477,7 @@ FrontEnd<Impl>::fetchCacheLine()
     // Setup the memReq to do a read of the first isntruction's address.
     // Set the appropriate read size and flags as well.
     memReq = new Request(0, fetch_PC, cacheBlkSize, 0,
-                         PC, cpu->cpuId(), 0);
+                         PC, cpu->thread->contextId());
 
     // Translate the instruction request.
     fault = cpu->translateInstReq(memReq, thread);
index 5e8ab9443aefb6749bd3c62857c8b3f6a31ad16b..feb8a7fc5aa3d29571ab7c7b7869bec383e8b577 100644 (file)
@@ -84,7 +84,7 @@ AtomicSimpleCPU::init()
         ThreadContext *tc = threadContexts[i];
 
         // initialize CPU, including PC
-        TheISA::initCPU(tc, _cpuId);
+        TheISA::initCPU(tc, tc->contextId());
     }
 #endif
     if (hasPhysMemPort) {
@@ -93,6 +93,7 @@ AtomicSimpleCPU::init()
         physmemPort.getPeerAddressRanges(pmAddrList, snoop);
         physMemAddr = *pmAddrList.begin();
     }
+    // Atomic doesn't do MT right now, so contextId == threadId
     ifetch_req.setThreadContext(_cpuId, 0); // Add thread ID if we add MT
     data_read_req.setThreadContext(_cpuId, 0); // Add thread ID here too
     data_write_req.setThreadContext(_cpuId, 0); // Add thread ID here too
index 247899ca8bfc3b9d771d2dd225ed309904ceb04c..ca1f0283e3e47e6c40c8af88f6b00039e94b2b47 100644 (file)
@@ -202,7 +202,6 @@ TimingSimpleCPU::takeOverFrom(BaseCPU *oldCPU)
         _status = Idle;
     }
     assert(threadContexts.size() == 1);
-    _cpuId = tc->cpuId();
     previousTick = curTick;
 }
 
index 6034ca1202f9fa09b1247b86cbce1ad2e3f57e0e..5c6b729b6c8303d7cc95e621cfe0539de5748a88 100644 (file)
@@ -182,6 +182,8 @@ SimpleThread::copyState(ThreadContext *oldContext)
     funcExeInst = oldContext->readFuncExeInst();
 #endif
     inst = oldContext->getInst();
+
+    _contextId = oldContext->contextId();
 }
 
 void
index 58912c564b20aa8bed1423dd7f224e143c9874e1..ab105a4350e992af27f381e5bfa1513e42dccf8a 100644 (file)
@@ -78,4 +78,11 @@ ThreadContext::compare(ThreadContext *one, ThreadContext *two)
     int id2 = two->cpuId();
     if (id1 != id2)
         panic("CPU ids don't match, one: %d, two: %d", id1, id2);
+
+    id1 = one->contextId();
+    id2 = two->contextId();
+    if (id1 != id2)
+        panic("Context ids don't match, one: %d, two: %d", id1, id2);
+
+
 }
index d06194012967ca01895be62d681324acface4b5e..a94be702417be8964e72a9c2e8b5de3e61d4a057 100644 (file)
@@ -117,6 +117,12 @@ class ThreadContext
 
     virtual int cpuId() = 0;
 
+    virtual int getThreadNum() = 0;
+
+    virtual int contextId() = 0;
+
+    virtual void setContextId(int id) = 0;
+
     virtual TheISA::ITB *getITBPtr() = 0;
 
     virtual TheISA::DTB *getDTBPtr() = 0;
@@ -177,8 +183,6 @@ class ThreadContext
     virtual void profileSample() = 0;
 #endif
 
-    virtual int getThreadNum() = 0;
-
     // Also somewhat obnoxious.  Really only used for the TLB fault.
     // However, may be quite useful in SPARC.
     virtual TheISA::MachInst getInst() = 0;
@@ -300,6 +304,12 @@ class ProxyThreadContext : public ThreadContext
 
     int cpuId() { return actualTC->cpuId(); }
 
+    int getThreadNum() { return actualTC->getThreadNum(); }
+
+    int contextId() { return actualTC->contextId(); }
+
+    void setContextId(int id) { actualTC->setContextId(id); }
+
     TheISA::ITB *getITBPtr() { return actualTC->getITBPtr(); }
 
     TheISA::DTB *getDTBPtr() { return actualTC->getDTBPtr(); }
@@ -360,9 +370,6 @@ class ProxyThreadContext : public ThreadContext
     void profileClear() { return actualTC->profileClear(); }
     void profileSample() { return actualTC->profileSample(); }
 #endif
-
-    int getThreadNum() { return actualTC->getThreadNum(); }
-
     // @todo: Do I need this?
     MachInst getInst() { return actualTC->getInst(); }
 
index f3f154de3bcf96013e9cd74033681c690efbc41c..fdb2ab0ab7b1b50bb630b538939c78039ee6d07b 100644 (file)
@@ -80,6 +80,10 @@ struct ThreadState {
 
     int cpuId() { return baseCpu->cpuId(); }
 
+    int contextId() { return _contextId; }
+
+    void setContextId(int id) { _contextId = id; }
+
     void setTid(int id) { tid = id; }
 
     int readTid() { return tid; }
@@ -169,6 +173,9 @@ struct ThreadState {
     // Pointer to the base CPU.
     BaseCPU *baseCpu;
 
+    // system wide HW context id
+    int _contextId;
+
     // Index of hardware thread context on the CPU that this represents.
     int tid;
 
index 3ba6cbd241390ddd54e8532b1d1d5331069215f3..66f682e66cea9952897babf71da486f61d4fb41d 100644 (file)
@@ -84,7 +84,7 @@ void
 AlphaBackdoor::startup()
 {
     system->setAlphaAccess(pioAddr);
-    alphaAccess->numCPUs = system->getNumCPUs();
+    alphaAccess->numCPUs = system->numContexts();
     alphaAccess->kernStart = system->getKernelStart();
     alphaAccess->kernEnd = system->getKernelEnd();
     alphaAccess->entryPoint = system->getKernelEntry();
index 4477b5adcac1e147c0ce722a70dba9ab6e50d55e..52a2aea14c83675fff309b37aa841319fb93f36f 100644 (file)
@@ -110,7 +110,13 @@ TsunamiCChip::read(PacketPtr pkt)
                    break;
               case TSDEV_CC_MISC:
                   pkt->set(((ipint << 8) & 0xF) | ((itint << 4) & 0xF) |
-                                     (pkt->req->getCpuNum() & 0x3));
+                                     (pkt->req->contextId() & 0x3));
+                  // currently, FS cannot handle MT so contextId and
+                  // cpuId are effectively the same, don't know if it will
+                  // matter if FS becomes MT enabled.  I suspect no because
+                  // we are currently able to boot up to 64 procs anyway
+                  // which would render the CPUID of this register useless
+                  // anyway
                   break;
               case TSDEV_CC_AAR0:
               case TSDEV_CC_AAR1:
index 5a4ea45856ad7bf29971cc480d96876d293d0ed2..26597766523fb3061c1607ff803e7a893e5079a9 100755 (executable)
@@ -103,7 +103,7 @@ MaltaCChip::read(PacketPtr pkt)
                    break;
               case TSDEV_CC_MISC:
                   pkt->set((ipint << 8) & 0xF | (itint << 4) & 0xF |
-                                     (pkt->req->getCpuNum() & 0x3));
+                                     (pkt->req->contextId() & 0x3));
                   break;
               case TSDEV_CC_AAR0:
               case TSDEV_CC_AAR1:
index 49806d37cdcccfbfdf18f19848443c1d49e29b91..bf7398e6247a22b3ea23acdbf880f5954127d6bb 100644 (file)
@@ -379,7 +379,7 @@ Device::read(PacketPtr pkt)
     assert(config.command & PCI_CMD_MSE);
     assert(pkt->getAddr() >= BARAddrs[0] && pkt->getSize() < BARSize[0]);
 
-    int cpu = pkt->req->getCpuNum();
+    int cpu = pkt->req->contextId();
     Addr daddr = pkt->getAddr() - BARAddrs[0];
     Addr index = daddr >> Regs::VirtualShift;
     Addr raddr = daddr & Regs::VirtualMask;
@@ -466,7 +466,7 @@ Device::write(PacketPtr pkt)
     assert(config.command & PCI_CMD_MSE);
     assert(pkt->getAddr() >= BARAddrs[0] && pkt->getSize() < BARSize[0]);
 
-    int cpu = pkt->req->getCpuNum();
+    int cpu = pkt->req->contextId();
     Addr daddr = pkt->getAddr() - BARAddrs[0];
     Addr index = daddr >> Regs::VirtualShift;
     Addr raddr = daddr & Regs::VirtualMask;
index 6608fc64add79c9561dfb93fae093086586e4231..f99ee5804a301466fb00df0a4ff5fddf999c3d94 100644 (file)
@@ -120,7 +120,7 @@ void
 Iob::readJBus(PacketPtr pkt)
 {
         Addr accessAddr = pkt->getAddr() - iobJBusAddr;
-        int cpuid = pkt->req->getCpuNum();
+        int cpuid = pkt->req->contextId();
         int index;
         uint64_t data;
 
@@ -235,7 +235,7 @@ void
 Iob::writeJBus(PacketPtr pkt)
 {
         Addr accessAddr = pkt->getAddr() - iobJBusAddr;
-        int cpuid = pkt->req->getCpuNum();
+        int cpuid = pkt->req->contextId();
         int index;
         uint64_t data;
 
index 9bfbd646dde58ea11afe24fb2e515895e3454e62..bdf323d87993edde28c8f647ef77c09a9e92e6ee 100644 (file)
@@ -108,18 +108,16 @@ class CacheBlk
      */
     class Lock {
       public:
-        int cpuNum;     // locking CPU
-        int threadNum;  // locking thread ID within CPU
+        int contextId;     // locking context
 
         // check for matching execution context
         bool matchesContext(Request *req)
         {
-            return (cpuNum == req->getCpuNum() &&
-                    threadNum == req->getThreadNum());
+            return (contextId == req->contextId());
         }
 
         Lock(Request *req)
-            : cpuNum(req->getCpuNum()), threadNum(req->getThreadNum())
+            : contextId(req->contextId())
         {
         }
     };
index fcc02ff285e444905a56d3474c9aa8aa82798899..a7e6cfdfcf9f95cb54715636d1b5cc49ef939449 100644 (file)
@@ -203,8 +203,8 @@ BasePrefetcher::handleMiss(PacketPtr &pkt, Tick time)
             PacketPtr prefetch;
             prefetch = new Packet(prefetchReq, MemCmd::HardPFReq, -1);
             prefetch->allocate();
-            prefetch->req->setThreadContext(pkt->req->getCpuNum(),
-                                            pkt->req->getThreadNum());
+            prefetch->req->setThreadContext(pkt->req->contextId(),
+                                            pkt->req->threadId());
 
             prefetch->time = time + (*delay); //@todo ADD LATENCY HERE
             //... initialize
index f5b88e1a687105bf98900e3761de72a91f337ef3..c8b87e99d5168b15ce077313547c3f4914b347d0 100644 (file)
@@ -42,16 +42,16 @@ GHBPrefetcher::calculatePrefetch(PacketPtr &pkt, std::list<Addr> &addresses,
                                  std::list<Tick> &delays)
 {
     Addr blkAddr = pkt->getAddr() & ~(Addr)(this->blkSize-1);
-    int cpuID = pkt->req->getCpuNum();
-    if (!useCPUId) cpuID = 0;
+    int contextId = pkt->req->contextId();
+    if (!useContextId) contextId = 0;
 
 
-    int new_stride = blkAddr - last_miss_addr[cpuID];
-    int old_stride = last_miss_addr[cpuID] -
-        second_last_miss_addr[cpuID];
+    int new_stride = blkAddr - last_miss_addr[contextId];
+    int old_stride = last_miss_addr[contextId] -
+        second_last_miss_addr[contextId];
 
-    second_last_miss_addr[cpuID] = last_miss_addr[cpuID];
-    last_miss_addr[cpuID] = blkAddr;
+    second_last_miss_addr[contextId] = last_miss_addr[contextId];
+    last_miss_addr[contextId] = blkAddr;
 
     if (new_stride == old_stride) {
         for (int d=1; d <= degree; d++) {
index 4fb69201691adb1a32e06dd9302b7660412d43f7..156a74afaef06907355ebba8a23fc5ac98c05f42 100644 (file)
@@ -47,13 +47,13 @@ class GHBPrefetcher : public BasePrefetcher
 
     Tick latency;
     int degree;
-    bool useCPUId;
+    bool useContextId;
 
   public:
 
     GHBPrefetcher(const BaseCacheParams *p)
         : BasePrefetcher(p), latency(p->prefetch_latency),
-          degree(p->prefetch_degree), useCPUId(p->prefetch_use_cpu_id)
+          degree(p->prefetch_degree), useContextId(p->prefetch_use_cpu_id)
     {
     }
 
index e93058d6eb2b411a477bab9f71e8b636695fd230..ad5846daa2ce5682c2af87cbefccfcd8b0daa964 100644 (file)
@@ -41,18 +41,18 @@ StridePrefetcher::calculatePrefetch(PacketPtr &pkt, std::list<Addr> &addresses,
                                     std::list<Tick> &delays)
 {
 //      Addr blkAddr = pkt->paddr & ~(Addr)(this->blkSize-1);
-    int cpuID = pkt->req->getCpuNum();
-    if (!useCPUId) cpuID = 0;
+    int contextId = pkt->req->contextId();
+    if (!useContextId) contextId = 0;
 
     /* Scan Table for IAddr Match */
 /*      std::list<strideEntry*>::iterator iter;
-  for (iter=table[cpuID].begin();
-  iter !=table[cpuID].end();
+  for (iter=table[contextId].begin();
+  iter !=table[contextId].end();
   iter++) {
   if ((*iter)->IAddr == pkt->pc) break;
   }
 
-  if (iter != table[cpuID].end()) {
+  if (iter != table[contextId].end()) {
   //Hit in table
 
   int newStride = blkAddr - (*iter)->MAddr;
index ca173277cf2123c945bfbcb918ee7d5f70680b45..4738fd9bc09de1d78153f7c6fde085bd29e8e33d 100644 (file)
@@ -63,14 +63,14 @@ class StridePrefetcher : public BasePrefetcher
     std::list<strideEntry*> table[64/*MAX_CPUS*/];
     Tick latency;
     int degree;
-    bool useCPUId;
+    bool useContextId;
 
 
   public:
 
     StridePrefetcher(const BaseCacheParams *p)
         : BasePrefetcher(p), latency(p->prefetch_latency),
-          degree(p->prefetch_degree), useCPUId(p->prefetch_use_cpu_id)
+          degree(p->prefetch_degree), useContextId(p->prefetch_use_cpu_id)
     {
     }
 
index 20e19669ce748ea0ec90dafdc55bbac96e4c6d40..16ff3de6ddb49520dabe4e734950b662b891bc0c 100644 (file)
@@ -139,16 +139,16 @@ PhysicalMemory::trackLoadLocked(PacketPtr pkt)
 
     for (i = lockedAddrList.begin(); i != lockedAddrList.end(); ++i) {
         if (i->matchesContext(req)) {
-            DPRINTF(LLSC, "Modifying lock record: cpu %d thread %d addr %#x\n",
-                    req->getCpuNum(), req->getThreadNum(), paddr);
+            DPRINTF(LLSC, "Modifying lock record: context %d addr %#x\n",
+                    req->contextId(), paddr);
             i->addr = paddr;
             return;
         }
     }
 
     // no record for this xc: need to allocate a new one
-    DPRINTF(LLSC, "Adding lock record: cpu %d thread %d addr %#x\n",
-            req->getCpuNum(), req->getThreadNum(), paddr);
+    DPRINTF(LLSC, "Adding lock record: context %d addr %#x\n",
+            req->contextId(), paddr);
     lockedAddrList.push_front(LockedAddr(req));
 }
 
@@ -183,14 +183,14 @@ PhysicalMemory::checkLockedAddrList(PacketPtr pkt)
                 // it's a store conditional, and as far as the memory
                 // system can tell, the requesting context's lock is
                 // still valid.
-                DPRINTF(LLSC, "StCond success: cpu %d thread %d addr %#x\n",
-                        req->getCpuNum(), req->getThreadNum(), paddr);
+                DPRINTF(LLSC, "StCond success: context %d addr %#x\n",
+                        req->contextId(), paddr);
                 success = true;
             }
 
             // Get rid of our record of this lock and advance to next
-            DPRINTF(LLSC, "Erasing lock record: cpu %d thread %d addr %#x\n",
-                    i->cpuNum, i->threadNum, paddr);
+            DPRINTF(LLSC, "Erasing lock record: context %d addr %#x\n",
+                    i->contextId, paddr);
             i = lockedAddrList.erase(i);
         }
         else {
index 2a0086ba9a5439b13d44366a4da63883210dc43e..d18138ecdfa5e64469436c170533a0080dd673b1 100644 (file)
@@ -90,20 +90,17 @@ class PhysicalMemory : public MemObject
         static Addr mask(Addr paddr) { return (paddr & ~Addr_Mask); }
 
         Addr addr;      // locked address
-        int cpuNum;     // locking CPU
-        int threadNum;  // locking thread ID within CPU
+        int contextId;     // locking hw context
 
         // check for matching execution context
         bool matchesContext(Request *req)
         {
-            return (cpuNum == req->getCpuNum() &&
-                    threadNum == req->getThreadNum());
+            return (contextId == req->contextId());
         }
 
         LockedAddr(Request *req)
             : addr(mask(req->getPaddr())),
-              cpuNum(req->getCpuNum()),
-              threadNum(req->getThreadNum())
+              contextId(req->contextId())
         {
         }
     };
index 613655ea44642eb374bd0db55438e515ab9a4ce6..da0d9c7e09969428efc3990d29519d9e5ed98bb4 100644 (file)
@@ -115,10 +115,10 @@ class Request : public FastAlloc
      * store conditional or the compare value for a CAS. */
     uint64_t extraData;
 
-    /** The cpu number (for statistics, typically). */
-    int cpuNum;
-    /** The requesting thread id (for statistics, typically). */
-    int  threadNum;
+    /** The context ID (for statistics, typically). */
+    int _contextId;
+    /** The thread ID (id within this CPU) */
+    int _threadId;
 
     /** program counter of initiating access; for tracing/debugging */
     Addr pc;
@@ -129,8 +129,8 @@ class Request : public FastAlloc
     bool validAsidVaddr;
     /** Whether or not the sc result is valid. */
     bool validExData;
-    /** Whether or not the cpu number & thread ID are valid. */
-    bool validCpuAndThreadNums;
+    /** Whether or not the context ID is valid. */
+    bool validContextAndThreadIds;
     /** Whether or not the pc is valid. */
     bool validPC;
 
@@ -138,7 +138,7 @@ class Request : public FastAlloc
     /** Minimal constructor.  No fields are initialized. */
     Request()
         : validPaddr(false), validAsidVaddr(false),
-          validExData(false), validCpuAndThreadNums(false), validPC(false)
+          validExData(false), validContextAndThreadIds(false), validPC(false)
     {}
 
     /**
@@ -146,13 +146,13 @@ class Request : public FastAlloc
      * just physical address, size, flags, and timestamp (to curTick).
      * These fields are adequate to perform a request.  */
     Request(Addr _paddr, int _size, int _flags)
-        : validCpuAndThreadNums(false)
+        : validContextAndThreadIds(false)
     { setPhys(_paddr, _size, _flags); }
 
     Request(int _asid, Addr _vaddr, int _size, int _flags, Addr _pc,
-            int _cpuNum, int _threadNum)
+            int _context_id, int _thread_id)
     {
-        setThreadContext(_cpuNum, _threadNum);
+        setThreadContext(_context_id, _thread_id);
         setVirt(_asid, _vaddr, _size, _flags, _pc);
     }
 
@@ -160,11 +160,11 @@ class Request : public FastAlloc
 
     /**
      * Set up CPU and thread numbers. */
-    void setThreadContext(int _cpuNum, int _threadNum)
+    void setThreadContext(int _context_id, int _thread_id)
     {
-        cpuNum = _cpuNum;
-        threadNum = _threadNum;
-        validCpuAndThreadNums = true;
+        _contextId = _context_id;
+        _threadId = _thread_id;
+        validContextAndThreadIds = true;
     }
 
     /**
@@ -261,10 +261,10 @@ class Request : public FastAlloc
     void setExtraData(uint64_t _extraData)
     { extraData = _extraData; validExData = true; }
 
-    /** Accessor function for cpu number.*/
-    int getCpuNum() { assert(validCpuAndThreadNums); return cpuNum; }
-    /** Accessor function for thread number.*/
-    int getThreadNum()  { assert(validCpuAndThreadNums); return threadNum; }
+    /** Accessor function for context ID.*/
+    int contextId() { assert(validContextAndThreadIds); return _contextId; }
+    /** Accessor function for thread ID. */
+    int threadId() { assert(validContextAndThreadIds); return _threadId; }
 
     /** Accessor function for pc.*/
     Addr getPC() { assert(validPC); return pc; }
index 8f25b4bb80b1ef76034a2b08a0d7a553adbbb25d..9704c83f02acbed13903f2e4718f902f421394b9 100644 (file)
@@ -58,7 +58,7 @@ vector<System *> System::systemList;
 int System::numSystemsRunning = 0;
 
 System::System(Params *p)
-    : SimObject(p), physmem(p->physmem), numcpus(0),
+    : SimObject(p), physmem(p->physmem), _numContexts(0),
 #if FULL_SYSTEM
       init_param(p->init_param),
       functionalPort(p->name + "-fport"),
@@ -181,7 +181,7 @@ System::registerThreadContext(ThreadContext *tc)
         panic("Cannot have two CPUs with the same id (%d)\n", id);
 
     threadContexts[id] = tc;
-    numcpus++;
+    _numContexts++;
 
     int port = getRemoteGDBPort();
     if (rgdb_enable && port) {
index 26cac714b0387cfb167b4540ba2907c5e4adf2d3..e993a7a503baf6046dc5fc5a8c4ea7d50b1fee5d 100644 (file)
@@ -87,19 +87,19 @@ class System : public SimObject
     PCEventQueue pcEventQueue;
 
     std::vector<ThreadContext *> threadContexts;
-    int numcpus;
+    int _numContexts;
 
     ThreadContext * getThreadContext(int tid)
     {
         return threadContexts[tid];
     }
 
-    int getNumCPUs()
+    int numContexts()
     {
-        if (numcpus != threadContexts.size())
+        if (_numContexts != threadContexts.size())
             panic("cpu array not fully populated!");
 
-        return numcpus;
+        return _numContexts;
     }
 
 #if FULL_SYSTEM