Skip to content

Commit

Permalink
cpu-o3: make store wb stage configurable
Browse files Browse the repository at this point in the history
store writeback at S4 by default
when using --ideal-kmhv3, store writeback at S2

Change-Id: I6a318ff6c182daca0ab041840d76575a16e45d82
  • Loading branch information
happy-lx committed Dec 20, 2024
1 parent 93517e8 commit 2f898df
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions configs/example/xiangshan.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ def setKmhV3IdealParams(args, system):
cpu.BankConflictCheck = False # real bank conflict 0.2 score
cpu.EnableLdMissReplay = False
cpu.EnablePipeNukeCheck = False
cpu.StoreWbStage = 2 # store writeback at s2

cpu.scheduler = IdealScheduler()
# use centralized load/store issue queue, for hmmer
Expand Down
2 changes: 2 additions & 0 deletions src/cpu/o3/BaseO3CPU.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ def support_take_over(cls):
SbufferEvictThreshold = Param.Unsigned(7, "store buffer eviction threshold")
storeBufferInactiveThreshold = Param.Unsigned(800, "store buffer writeback timeout threshold")

StoreWbStage = Param.Unsigned(4, "Which PipeLine Stage store instruction writeback, 4 means S4")

LSQDepCheckShift = Param.Unsigned(0,
"Number of places to shift addr before check")
LSQCheckLoads = Param.Bool(True,
Expand Down
2 changes: 2 additions & 0 deletions src/cpu/o3/lsq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ LSQ::LSQ(CPU *cpu_ptr, IEW *iew_ptr, const BaseO3CPUParams &params)
enableBankConflictCheck(params.BankConflictCheck),
_enableLdMissReplay(params.EnableLdMissReplay),
_enablePipeNukeCheck(params.EnablePipeNukeCheck),
_storeWbStage(params.StoreWbStage),
waitingForStaleTranslation(false),
staleTranslationWaitTxnId(0),
lsqPolicy(params.smtLSQPolicy),
Expand All @@ -104,6 +105,7 @@ LSQ::LSQ(CPU *cpu_ptr, IEW *iew_ptr, const BaseO3CPUParams &params)
if (!_enableLdMissReplay && _enablePipeNukeCheck) {
panic("LSQ can not support pipeline nuke replay when EnableLdMissReplay is False");
}
assert(_storeWbStage >= 2 && _storeWbStage <= 4);

//**********************************************
//************ Handle SMT Parameters ***********
Expand Down
3 changes: 3 additions & 0 deletions src/cpu/o3/lsq.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@ class LSQ

bool enableLdMissReplay() const { return _enableLdMissReplay; }
bool enablePipeNukeCheck() const { return _enablePipeNukeCheck; }
int storeWbStage() const { return _storeWbStage; }

protected:
/** D-cache is blocked */
Expand All @@ -1039,6 +1040,8 @@ class LSQ
bool _enableLdMissReplay;
bool _enablePipeNukeCheck;

int _storeWbStage;

/** If the LSQ is currently waiting for stale translations */
bool waitingForStaleTranslation;
/** The ID if the transaction that made translations stale */
Expand Down
26 changes: 14 additions & 12 deletions src/cpu/o3/lsq_unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1432,18 +1432,6 @@ LSQUnit::storePipeS4(const DynInstPtr &inst, std::bitset<LdStFlagNum> &flag)
DPRINTF(LSQUnit, "StorePipeS4: Executing store PC %s [sn:%lli] flags: %s\n",
inst->pcState(), inst->seqNum, getLdStFlagStr(flag));

// If the store had a fault then it may not have a mem req
if (fault != NoFault || !inst->readPredicate() || !inst->isStoreConditional()) {
// If the instruction faulted, then we need to send it
// along to commit without the instruction completing.
// Send this instruction to commit, also make sure iew
// stage realizes there is activity.
if (!flag[LdStFlags::Replayed]) {
inst->setExecuted();
iewStage->instToCommit(inst);
iewStage->activityThisCycle();
}
}
return fault;
}

Expand Down Expand Up @@ -1489,6 +1477,20 @@ LSQUnit::executeStorePipeSx()
default:
panic("unsupported storepipe length");
}
if (i == (lsq->storeWbStage() - 1)) {
// If the store had a fault then it may not have a mem req
if (fault != NoFault || !inst->readPredicate() || !inst->isStoreConditional()) {
// If the instruction faulted, then we need to send it
// along to commit without the instruction completing.
// Send this instruction to commit, also make sure iew
// stage realizes there is activity.
if (!flag[LdStFlags::Replayed]) {
inst->setExecuted();
iewStage->instToCommit(inst);
iewStage->activityThisCycle();
}
}
}
} else {
DPRINTF(LSQUnit, "Execute: Instruction was squashed. PC: %s, [tid:%i]"
" [sn:%llu]\n", inst->pcState(), inst->threadNumber,
Expand Down

0 comments on commit 2f898df

Please sign in to comment.