Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds optional branch logging and basic-block metadata collection to the branch predictor plugin to support cross-simulator (qflex vs gem5) instruction/branch stream comparisons and checkpoint export.
Changes:
- Add per-core branch PC logging to
branch_trace_core_<id>.logwhen enabled via plugin options. - Track basic-block boundaries at instruction granularity and record
bbl_bytesinto BTB entries (and optionally into a new export-only BBL-BTB structure). - Extend checkpoint frontend export to include
bbl_bytesin serialized BTB entries.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/components/bp/mod.rs |
Adds branch trace logging, basic-block tracking state, and instruction-exec callbacks to compute bbl_bytes. |
src/components/bp/fetch.rs |
Adds bbl_bytes plumbing through training and introduces export-only restore state (RestoreExportState). |
src/components/bp/fetch/btb.rs |
Extends BTB entries to store bbl_bytes and threads it through BTB training. |
src/components/bp/fetch/bbl_btb.rs |
New data structure to record basic blocks (BBL-BTB) for export/restore workflows. |
src/checkpoint/frontend.rs |
Includes bbl_bytes in the exported Flexus BTB JSON entries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[derive(Serialize, Deserialize)] | ||
| pub struct PerCoreFetchUnit { | ||
| btb: btb::BTB<{ parameter::BTB_SET }, { parameter::BTB_ASSO }>, | ||
| #[serde(default, alias = "btb")] |
Comment on lines
+247
to
265
| unsafe fn on_translation(tb: *mut crate::qemu_api::qemu_plugin_tb) { | ||
| let instruction_count = unsafe { qemu_api::qemu_plugin_tb_n_insns(tb) }; | ||
| if instruction_count == 0 { | ||
| return; | ||
| } | ||
|
|
||
| for i in 0..instruction_count { | ||
| let insn = unsafe { qemu_api::qemu_plugin_tb_get_insn(tb, i) }; | ||
| let insn_addr = unsafe { qemu_api::qemu_plugin_insn_vaddr(insn) }; | ||
| unsafe { | ||
| qemu_api::qemu_plugin_register_vcpu_insn_exec_cb( | ||
| insn, | ||
| Some(vcpu_insn_exec), | ||
| qemu_api::qemu_plugin_cb_flags_QEMU_PLUGIN_CB_NO_REGS, | ||
| insn_addr as *mut ffi::c_void, | ||
| ); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For comparing the sequences of instructions collected from qflex and gem5, I added modifications to this repo. Please review and approve the PR if you agree. These modifications enable logging the executed branches in a dedicated file.