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

Branch Predictor Fixes & Improvements #148

Merged
merged 5 commits into from
Aug 26, 2024
Merged

Conversation

jiristefan
Copy link
Collaborator

Addresses some points from #143

  • fence.i instrukction will now cause predictor to flush BTB rows and BHT states
  • Even instructions which are Not Taken are added into BTB and updated into BHT
  • Unconditional jumps now have a flag in BTB and do not trigger BHT
  • Added 3rd predictor widget with additional information not directly related to BHT and BTB
  • Added new statistic counting total encountered branch instructions and pipeline flushes
  • Restructured predictor and GUI code

@jiristefan jiristefan requested review from jdupak and ppisa August 25, 2024 20:55
@jiristefan jiristefan marked this pull request as ready for review August 26, 2024 08:31
@ppisa
Copy link
Member

ppisa commented Aug 26, 2024

I have tested updated version with my simple test cases and all looks correct. I would wait for @jdupak for code style review and I hope we merge changes soon.

Copy link
Collaborator

@jdupak jdupak left a comment

Choose a reason for hiding this comment

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

Lookgs mostly good to me. There are some duplications and redundancies but no blockers. Good job, Jirka!

I am fine merging this now and fixing the issues in a subsequest PR. I leave it up to you.

// depending on the setting

const machine::PredictorType predictor_type { config->get_bp_type() };
const bool is_predictor_dynamic { predictor_type == machine::PredictorType::SMITH_1_BIT
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: This logic would be better placed in the predictor module.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed


number_of_bhr_bits = branch_predictor->get_number_of_bhr_bits();
number_of_bht_bits = branch_predictor->get_number_of_bht_bits();
initial_state = branch_predictor->get_initial_state();
const machine::PredictorType predictor_type { branch_predictor->get_predictor_type() };
const bool is_predictor_dynamic { predictor_type == machine::PredictorType::SMITH_1_BIT
Copy link
Collaborator

Choose a reason for hiding this comment

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

This logic is used at two places -> it should be a function to make make sure it is consistent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

zero_padding.fill('0', number_of_bhr_bits - binary_value.count());
value_bhr->setText("0b" + zero_padding + binary_value);
for (uint16_t column_index = 0; column_index < bht->columnCount(); column_index++) {
QTableWidgetItem *item;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Don't split initialization. This looks confusing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

item = get_btb_cell_item(row_index, DOCK_BTB_COL_TYPE);
item->setData(Qt::DisplayRole, machine::branch_type_to_string(btb_entry.branch_type).toString());
} else {
item = get_btb_cell_item(row_index, DOCK_BTB_COL_INSTR_ADDR);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would really prefer not to reuse to variable. It actually confused me for a while. Actually, you dont need a variable at all. You could just call setData on the result of the get_... method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

}

void DockPredictorInfo::set_update_widget_color(QString color_stylesheet) {
value_event_update_instruction->setStyleSheet(color_stylesheet);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here

number_of_bhr_bits = branch_predictor->get_number_of_bhr_bits();
initial_state = branch_predictor->get_initial_state();
const machine::PredictorType predictor_type { branch_predictor->get_predictor_type() };
is_predictor_dynamic = predictor_type == machine::PredictorType::SMITH_1_BIT
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another duplication

src/machine/predictor.h Show resolved Hide resolved
@ppisa
Copy link
Member

ppisa commented Aug 26, 2024

OK, I agree with incremental progress merging. The core changes are minimal and value of predictor is much bigger/usable for teaching in proposed version. I would like to add predictor disable action to all processor presets is some followup commit.

@ppisa ppisa added this pull request to the merge queue Aug 26, 2024
@ppisa ppisa removed this pull request from the merge queue due to a manual request Aug 26, 2024
@ppisa ppisa merged commit ea2957d into master Aug 26, 2024
11 checks passed
@ppisa
Copy link
Member

ppisa commented Aug 26, 2024

I have made merge in parallel to your commit
415f5d1 Fixed code duplication and table cell handling clarity
I have applied that commit above the master now.

@jiristefan
Copy link
Collaborator Author

Thank you, the last commit should hopefully address all the things mentioned in the review. I pushed it without noticing the merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants