Giacomo Travaglini has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/15601
Change subject: cpu, arch, arch-arm: Wire unused VecElem code in the O3
model
......................................................................
cpu, arch, arch-arm: Wire unused VecElem code in the O3 model
VecElem code had been introduced in order to simulate change of renaming
for vector registers. Most of the work is happening on the rename_map
switchRenameMode. Change of renaming can happen after a squash in the
pipeline.
This patch is also changing the interface to the ISA part so that
a PCState is used instead of ISA in order to check if rename mode
has changed.
Change-Id: I8af795d771b958e0a0d459abfeceff5f16b4b5d4
Signed-off-by: Giacomo Travaglini <[email protected]>
---
M src/arch/arm/isa.hh
M src/arch/generic/traits.hh
M src/cpu/o3/cpu.cc
M src/cpu/o3/cpu.hh
M src/cpu/o3/rename_impl.hh
M src/cpu/o3/rename_map.cc
M src/cpu/o3/rename_map.hh
7 files changed, 115 insertions(+), 45 deletions(-)
diff --git a/src/arch/arm/isa.hh b/src/arch/arm/isa.hh
index 1ec0f46..af3fea9 100644
--- a/src/arch/arm/isa.hh
+++ b/src/arch/arm/isa.hh
@@ -698,15 +698,28 @@
}
template<>
-struct initRenameMode<ArmISA::ISA>
+struct renameMode<ArmISA::ISA>
{
- static Enums::VecRegRenameMode mode(const ArmISA::ISA* isa)
+ static Enums::VecRegRenameMode
+ init(const ArmISA::ISA* isa)
{
return isa->vecRegRenameMode();
}
- static bool equals(const ArmISA::ISA* isa1, const ArmISA::ISA* isa2)
+
+ static Enums::VecRegRenameMode
+ mode(const ArmISA::PCState& pc)
{
- return mode(isa1) == mode(isa2);
+ if (pc.aarch64()) {
+ return Enums::Full;
+ } else {
+ return Enums::Elem;
+ }
+ }
+
+ static bool
+ equalsInit(const ArmISA::ISA* isa1, const ArmISA::ISA* isa2)
+ {
+ return init(isa1) == init(isa2);
}
};
diff --git a/src/arch/generic/traits.hh b/src/arch/generic/traits.hh
index 3dc6b30..f129172 100644
--- a/src/arch/generic/traits.hh
+++ b/src/arch/generic/traits.hh
@@ -42,6 +42,7 @@
#ifndef __ARCH_COMMON_TRAITS_HH__
#define __ARCH_COMMON_TRAITS_HH__
+#include "arch/types.hh"
#include "enums/VecRegRenameMode.hh"
/** Helper structure to get the vector register mode for a given ISA.
@@ -50,14 +51,19 @@
* appropriate member of the ISA.
*/
template <typename ISA>
-struct initRenameMode
+struct renameMode
{
- static Enums::VecRegRenameMode mode(const ISA*) { return Enums::Full; }
+ static Enums::VecRegRenameMode init(const ISA*) { return Enums::Full; }
+
+ static Enums::VecRegRenameMode
+ mode(const TheISA::PCState&)
+ { return Enums::Full; }
+
/**
* Compare the initial rename mode of two instances of the ISA.
* Result is true by definition, as the default mode is Full.
* */
- static bool equals(const ISA*, const ISA*) { return true; }
+ static bool equalsInit(const ISA*, const ISA*) { return true; }
};
#endif /* __ARCH_COMMON_TRAITS_HH__ */
diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc
index e5b8103..0f42851 100644
--- a/src/cpu/o3/cpu.cc
+++ b/src/cpu/o3/cpu.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2012, 2014, 2016, 2017 ARM Limited
+ * Copyright (c) 2011-2012, 2014, 2016, 2017, 2019 ARM Limited
* Copyright (c) 2013 Advanced Micro Devices, Inc.
* All rights reserved
*
@@ -155,7 +155,7 @@
/* It is mandatory that all SMT threads use the same renaming mode as
* they are sharing registers and rename */
- vecMode(initRenameMode<TheISA::ISA>::mode(params->isa[0])),
+ vecMode(renameMode<TheISA::ISA>::init(params->isa[0])),
regFile(params->numPhysIntRegs,
params->numPhysFloatRegs,
params->numPhysVecRegs,
@@ -266,7 +266,7 @@
// Setup the rename map for whichever stages need it.
for (ThreadID tid = 0; tid < numThreads; tid++) {
isa[tid] = params->isa[tid];
- assert(initRenameMode<TheISA::ISA>::equals(isa[tid], isa[0]));
+ assert(renameMode<TheISA::ISA>::equalsInit(isa[tid], isa[0]));
// Only Alpha has an FP zero register, so for other ISAs we
// use an invalid FP register index to avoid special treatment
@@ -962,6 +962,26 @@
}
template <class Impl>
+void
+FullO3CPU<Impl>::switchRenameMode(ThreadID tid, UnifiedFreeList* freelist)
+{
+ auto pc = this->pcState(tid);
+
+ // rename_change is the pair
+ // <change in renaming happened, new vector renaming mode>
+ auto new_mode = renameMode<TheISA::ISA>::mode(pc);
+
+ // We update vecMode only if there has been a change
+ if (new_mode != vecMode) {
+ vecMode = new_mode;
+
+ renameMap[tid].switchMode(vecMode);
+ commitRenameMap[tid].switchMode(vecMode);
+ renameMap[tid].switchFreeList(freelist);
+ }
+}
+
+template <class Impl>
Fault
FullO3CPU<Impl>::getInterrupts()
{
diff --git a/src/cpu/o3/cpu.hh b/src/cpu/o3/cpu.hh
index 4c46776..a358385 100644
--- a/src/cpu/o3/cpu.hh
+++ b/src/cpu/o3/cpu.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2013, 2016 ARM Limited
+ * Copyright (c) 2011-2013, 2016, 2019 ARM Limited
* Copyright (c) 2013 Advanced Micro Devices, Inc.
* All rights reserved
*
@@ -370,6 +370,14 @@
bool simPalCheck(int palFunc, ThreadID tid);
+ /** Check if a change in renaming is needed for vector registers.
+ * The vecMode variable is updated and propagated to rename maps.
+ *
+ * @param tid ThreadID
+ * @param freelist list of free registers
+ */
+ void switchRenameMode(ThreadID tid, UnifiedFreeList* freelist);
+
/** Returns the Fault for any valid interrupt. */
Fault getInterrupts();
diff --git a/src/cpu/o3/rename_impl.hh b/src/cpu/o3/rename_impl.hh
index 7c2fcbe..5b655c5 100644
--- a/src/cpu/o3/rename_impl.hh
+++ b/src/cpu/o3/rename_impl.hh
@@ -660,6 +660,7 @@
inst->numVecDestRegs(),
inst->numVecElemDestRegs(),
inst->numCCDestRegs())) {
+
DPRINTF(Rename, "Blocking due to lack of free "
"physical registers to rename to.\n");
blockThisCycle = true;
@@ -927,10 +928,6 @@
// After a syscall squashes everything, the history buffer may be empty
// but the ROB may still be squashing instructions.
- if (historyBuffer[tid].empty()) {
- return;
- }
-
// Go through the most recent instructions, undoing the mappings
// they did and freeing up the registers.
while (!historyBuffer[tid].empty() &&
@@ -965,6 +962,9 @@
++renameUndoneMaps;
}
+
+ // Check if we need to change vector renaming mode after squashing
+ cpu->switchRenameMode(tid, freeList);
}
template<class Impl>
diff --git a/src/cpu/o3/rename_map.cc b/src/cpu/o3/rename_map.cc
index 1b831d9..86c4393 100644
--- a/src/cpu/o3/rename_map.cc
+++ b/src/cpu/o3/rename_map.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 ARM Limited
+ * Copyright (c) 2016,2019 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -125,45 +125,68 @@
}
void
-UnifiedRenameMap::switchMode(VecMode newVecMode, UnifiedFreeList* freeList)
+UnifiedRenameMap::switchFreeList(UnifiedFreeList* freeList)
{
- if (newVecMode == Enums::Elem && vecMode == Enums::Full) {
- /* Switch to vector element rename mode. */
+ if (vecMode == Enums::Elem) {
+
/* The free list should currently be tracking full registers. */
panic_if(freeList->hasFreeVecElems(),
"The free list is already tracking Vec elems");
panic_if(freeList->numFreeVecRegs() !=
regFile->numVecPhysRegs() - TheISA::NumVecRegs,
"The free list has lost vector registers");
- /* Split the mapping of each arch reg. */
- int reg = 0;
- for (auto &e: vecMap) {
- PhysRegFile::IdRange range = this->regFile->getRegElemIds(e);
- uint32_t i;
- for (i = 0; range.first != range.second; i++, range.first++) {
- vecElemMap.setEntry(RegId(VecElemClass, reg, i),
- &(*range.first));
- }
- panic_if(i != NVecElems,
- "Wrong name of elems: expecting %u, got %d\n",
- TheISA::NumVecElemPerVecReg, i);
- reg++;
- }
+
/* Split the free regs. */
while (freeList->hasFreeVecRegs()) {
auto vr = freeList->getVecReg();
auto range = this->regFile->getRegElemIds(vr);
freeList->addRegs(range.first, range.second);
}
- vecMode = Enums::Elem;
- } else if (newVecMode == Enums::Full && vecMode == Enums::Elem) {
- /* Switch to full vector register rename mode. */
+
+ } else if (vecMode == Enums::Full) {
+
/* The free list should currently be tracking register elems. */
panic_if(freeList->hasFreeVecRegs(),
"The free list is already tracking full Vec");
panic_if(freeList->numFreeVecElems() !=
regFile->numVecElemPhysRegs() - TheISA::NumFloatRegs,
"The free list has lost vector register elements");
+
+ auto range = regFile->getRegIds(VecRegClass);
+ freeList->addRegs(range.first + TheISA::NumVecRegs, range.second);
+
+ /* We remove the elems from the free list. */
+ while (freeList->hasFreeVecElems())
+ freeList->getVecElem();
+ }
+}
+
+void
+UnifiedRenameMap::switchMode(VecMode newVecMode)
+{
+ if (newVecMode == Enums::Elem && vecMode == Enums::Full) {
+
+ /* Switch to vector element rename mode. */
+ vecMode = Enums::Elem;
+
+ /* Split the mapping of each arch reg. */
+ int vec_idx = 0;
+ for (auto &vec: vecMap) {
+ PhysRegFile::IdRange range = this->regFile->getRegElemIds(vec);
+ auto idx = 0;
+ for (auto phys_elem = range.first;
+ phys_elem < range.second; idx++, phys_elem++) {
+
+ setEntry(RegId(VecElemClass, vec_idx, idx), &(*phys_elem));
+ }
+ vec_idx++;
+ }
+
+ } else if (newVecMode == Enums::Full && vecMode == Enums::Elem) {
+
+ /* Switch to full vector register rename mode. */
+ vecMode = Enums::Full;
+
/* To rebuild the arch regs we take the easy road:
* 1.- Stitch the elems together into vectors.
* 2.- Replace the contents of the register file with the vectors
@@ -184,12 +207,5 @@
regFile->setVecReg(regFile->getTrueId(&pregId), new_RF[i]);
}
- auto range = regFile->getRegIds(VecRegClass);
- freeList->addRegs(range.first + TheISA::NumVecRegs, range.second);
-
- /* We remove the elems from the free list. */
- while (freeList->hasFreeVecElems())
- freeList->getVecElem();
- vecMode = Enums::Full;
}
}
diff --git a/src/cpu/o3/rename_map.hh b/src/cpu/o3/rename_map.hh
index ab909f0..d306680 100644
--- a/src/cpu/o3/rename_map.hh
+++ b/src/cpu/o3/rename_map.hh
@@ -160,7 +160,6 @@
/** @} */
};
-
/**
* Unified register rename map for all classes of registers. Wraps a
* set of class-specific rename maps. Methods that do not specify a
@@ -377,8 +376,16 @@
/**
* Set vector mode to Full or Elem.
* Ignore 'silent' modifications.
+ *
+ * @param newVecMode new vector renaming mode
*/
- void switchMode(VecMode newVecMode, UnifiedFreeList* freeList);
+ void switchMode(VecMode newVecMode);
+
+ /**
+ * Switch freeList of registers from Full to Elem or vicevers
+ * depending on vecMode (vector renaming mode).
+ */
+ void switchFreeList(UnifiedFreeList* freeList);
};
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/15601
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I8af795d771b958e0a0d459abfeceff5f16b4b5d4
Gerrit-Change-Number: 15601
Gerrit-PatchSet: 1
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev