Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ideal model and value predictor support #297

Open
wants to merge 11 commits into
base: xs-dev
Choose a base branch
from

Conversation

zybzzz
Copy link
Contributor

@zybzzz zybzzz commented Feb 20, 2025

related: #215 #188 OpenXiangShan/NEMU#806

Added support for the ideal model and value prediction in this PR.

  1. Support for the Ideal Model: The ideal model can now be applied to int add-type instructions and scalar load operations for upper-bound performance analysis of value prediction.
  2. Support for Value Prediction: A basic implementation of value prediction has been provided. Since the previous value prediction implementation could not be toggled on or off, the related interfaces have been revised accordingly.

Through my testing on the server, both of these additions do not affect the execution of xs-gem5 when disabled.


The upstream merge of nemu will be a slow process, as the upstream nemu differs significantly from the version currently used for difftest, requiring time for integration. If this submission is accepted, I will first provide a precompiled version in the ready-to-run repository.

Referenced the implementation of the exit callback.

Change-Id: I040b7dcbcf9bf5e9c7fcae4fa062b55df7de3753
* add support for int add-type instructions.

* Added flag support for certain nonspec and system instructions to align
gem5 behavior with the ideal model.

Change-Id: Ifef310b5b662eb0e1517e59964fdc0cc13caa3f5
Change-Id: Ie7d744bcf13751a797c00397357d8b1b326f1e93
Change-Id: I67e94d719a39ef202621c6d5755a5335ecda4096
Change-Id: If315236b42cbd515eac3a1fcedebc08d66756fe6
Change-Id: Ibd23e2c7c129396a393a9ff51ae05c1e11fa00d6
* Added interfaces for the value predictor and ideal model in O3,
  ensuring that the original O3 execution remains unaffected when they are disabled.

* The code for the value predictor will be further refined in future
  updates.

Change-Id: I0a92c99ab0f5d8906911c942a75e241a0e070a87
Change-Id: Icdf2c27d2d2a9b8f908f8b587c9de6c0b87f5960
buildPredMetaData(ValuePredType::EStride));
vpPredMetaData->pc = instruction->getPC();
vpPredMetaData->seq_no = instruction->seqNum;
instruction->vpResult = valuePredictor->valuePredict(vpPredMetaData);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it do predict at rename?
Allocate new physical register and remap to the predicted value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it do predict at rename? Allocate new physical register and remap to the predicted value.

In fact, the predicted values are indeed used in the Rename stage. What is being simulated here is a scenario where value prediction occurs when the instruction is fetched in the Fetch stage, and the predicted value is utilized in the Rename stage—essentially frontend prediction with backend consumption.

From a microarchitectural implementation perspective, accessing the value predictor in the Fetch stage instead of the Rename stage allows the predictor to obtain incoming instructions earlier. This leverages the latency between the frontend and backend to hide the overhead of value prediction.

@@ -1270,6 +1276,52 @@ Rename::renameDestRegs(const DynInstPtr &inst, ThreadID tid)
rename_result.second);

++stats.renamedOperands;

if ((cpu->idealModelEnabled() && cpu->idealModelConfig->isValuePredSupported()) ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block seems can be optimized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block seems can be optimized.

Currently, there are two scenarios where value prediction is performed:

  1. When the ideal model is enabled
  2. When the value predictor is used independently

The if condition here is used to distinguish between these two cases. The implementation of the ideal model is incompatible with the actual value predictor, which is why this "if" is necessary.

Furthermore, the strict checks on which instructions and registers are eligible for value prediction are currently unavoidable. This is because the current implementation only supports value prediction for arithmetic instructions and standard loads, necessitating these strict checks on instructions and registers.

Change-Id: I8ac183aa0d4b981fd3d2f8dba52630e57d30474f
Change-Id: I845474e03f749e5d1f71ae5f69cb60453924b881
@zybzzz
Copy link
Contributor Author

zybzzz commented Feb 27, 2025

Due to the lack of consideration for the details in the instruction fetch stage, the ideal model still has some bugs that are currently being fixed.

Change-Id: Id10c087f1c5741e1da4258c11ae274281960eb41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants