From daf47a5a47be5466fc1ef30f3b4c0c68c0ccb221 Mon Sep 17 00:00:00 2001 From: Anthony Hung Date: Thu, 7 Mar 2024 23:23:33 -0800 Subject: [PATCH 1/8] All instructions including SYS can possibly go through register rename. A problem occurs when a SYS instr gets a renamed dest register. SYS instrutions do not go in any execution pipe. In current code renamed registers can only be made ready in an excution pipe. So SYS instructions with dest register rename can never become ready. So any subsequent instruction waiting on the destination register just hangs. The solution I made was to give the ROB a scoreboard view and make the dest register ready when the ROB does the flush upon retiring SYS instructions. In an unrelated fix in the same block of code I also added a line to set the expected_flush_ variable to true or else the flush fails. --- core/ROB.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++------- core/ROB.hpp | 7 +++++++ 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/core/ROB.cpp b/core/ROB.cpp index a757dbcc..db317ab5 100644 --- a/core/ROB.cpp +++ b/core/ROB.cpp @@ -72,6 +72,7 @@ namespace olympia void ROB::sendInitialCredits_() { + setup_scoreboard_view() ; out_reorder_buffer_credits_.send(reorder_buffer_.capacity()); ev_ensure_forward_progress_.schedule(retire_timeout_interval_); } @@ -188,13 +189,7 @@ namespace olympia // This is rare for the example if(SPARTA_EXPECT_FALSE(ex_inst.getPipe() == InstArchInfo::TargetPipe::SYS)) { - ILOG("Instigating flush... " << ex_inst); - - FlushManager::FlushingCriteria criteria(FlushManager::FlushCause::POST_SYNC, ex_inst_ptr); - out_retire_flush_.send(criteria); - - ++num_flushes_; - break; + retireSysInst(ex_inst_ptr); } } else { @@ -248,4 +243,44 @@ namespace olympia } } + // sys instr doesn't have a pipe so we handle special stuff here + void ROB::retireSysInst(InstPtr &ex_inst) + { + auto reg_file = ex_inst->getRenameData().getDestination().rf; + if (reg_file == core_types::RegFile::RF_INVALID) + { // this is the case if dst = x0 + DLOG("retiring SYS instr "); + } else // this is needed or else destination register is + { // forever reserved and not ready + const auto & dest_bits = ex_inst->getDestRegisterBitMask(reg_file); + scoreboard_views_[reg_file]->setReady(dest_bits); + DLOG("retiring SYS inst dest reg bits: " << sparta::printBitSet(dest_bits)); + } + + FlushManager::FlushingCriteria criteria(FlushManager::FlushCause::POST_SYNC, ex_inst); + out_retire_flush_.send(criteria); + expect_flush_ = true; + ++num_flushes_; + ILOG("Instigating flush due to SYS instruction... " << *ex_inst); + + + } + + // for SYS instr which doesn't have an exe pipe + void ROB::setup_scoreboard_view() + { + const char QNAME[] = "iq0"; + auto cpu_node = getContainer()->findAncestorByName("core.*"); + if (cpu_node == nullptr) + { + cpu_node = getContainer()->getRoot(); + } + const auto& rf = core_types::RF_INTEGER; + + // alu0, alu1 name is based on exe names, point to issue_queue name instead + DLOG("setup sb view: " << QNAME ); + scoreboard_views_[rf].reset( + new sparta::ScoreboardView(QNAME, core_types::regfile_names[rf], + cpu_node)); // name needs to come from issue_queue + } } diff --git a/core/ROB.hpp b/core/ROB.hpp index a024410f..e9609d0e 100644 --- a/core/ROB.hpp +++ b/core/ROB.hpp @@ -134,5 +134,12 @@ namespace olympia void dumpDebugContent_(std::ostream& output) const override final; void onStartingTeardown_() override final; + void retireSysInst(InstPtr & ); + + void setup_scoreboard_view() ; + // Scoreboards + using ScoreboardViews = + std::array, core_types::N_REGFILES>; + ScoreboardViews scoreboard_views_; }; } From 8f1bb9e5d51b9a50242706c8a548a3022f8e7100 Mon Sep 17 00:00:00 2001 From: Anthony Hung Date: Mon, 25 Mar 2024 20:37:28 -0700 Subject: [PATCH 2/8] this somehow doesn't work --- core/ROB.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/ROB.cpp b/core/ROB.cpp index db317ab5..f5c7c3fb 100644 --- a/core/ROB.cpp +++ b/core/ROB.cpp @@ -6,6 +6,7 @@ #include "sparta/utils/LogUtils.hpp" #include "sparta/events/StartupEvent.hpp" +#include "CoreUtils.hpp" namespace olympia { @@ -269,18 +270,24 @@ namespace olympia // for SYS instr which doesn't have an exe pipe void ROB::setup_scoreboard_view() { - const char QNAME[] = "iq0"; + std::string iq_name = "iq0"; // default name + auto cpu_node = getContainer()->findAncestorByName("core.*"); if (cpu_node == nullptr) { cpu_node = getContainer()->getRoot(); } const auto& rf = core_types::RF_INTEGER; - + const auto exe_pipe_rename = + olympia::coreutils::getPipeTopology(cpu_node, "exe_pipe_rename"); + if (exe_pipe_rename.size() > 0) + iq_name = exe_pipe_rename[0][1]; // just grab the first issue queue + // alu0, alu1 name is based on exe names, point to issue_queue name instead - DLOG("setup sb view: " << QNAME ); + DLOG("setup sb view: " << iq_name ); scoreboard_views_[rf].reset( - new sparta::ScoreboardView(QNAME, core_types::regfile_names[rf], + new sparta::ScoreboardView(iq_name, core_types::regfile_names[rf], cpu_node)); // name needs to come from issue_queue } } + From d7ab6c8a22033c5194db327493b14c0be035ce87 Mon Sep 17 00:00:00 2001 From: Anthony Hung Date: Mon, 25 Mar 2024 20:48:53 -0700 Subject: [PATCH 3/8] this fails too --- core/ROB.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/ROB.cpp b/core/ROB.cpp index f5c7c3fb..d3698ed0 100644 --- a/core/ROB.cpp +++ b/core/ROB.cpp @@ -271,17 +271,21 @@ namespace olympia void ROB::setup_scoreboard_view() { std::string iq_name = "iq0"; // default name - + + if (getContainer() != nullptr) + { + const auto exe_pipe_rename = + olympia::coreutils::getPipeTopology(getContainer()->getRoot(), "exe_pipe_rename"); + if (exe_pipe_rename.size() > 0) + iq_name = exe_pipe_rename[0][1]; // just grab the first issue queue + } + auto cpu_node = getContainer()->findAncestorByName("core.*"); if (cpu_node == nullptr) { cpu_node = getContainer()->getRoot(); } const auto& rf = core_types::RF_INTEGER; - const auto exe_pipe_rename = - olympia::coreutils::getPipeTopology(cpu_node, "exe_pipe_rename"); - if (exe_pipe_rename.size() > 0) - iq_name = exe_pipe_rename[0][1]; // just grab the first issue queue // alu0, alu1 name is based on exe names, point to issue_queue name instead DLOG("setup sb view: " << iq_name ); From 89269513d8b899d58f6644db9626a2698d5c11a6 Mon Sep 17 00:00:00 2001 From: Anthony Hung Date: Tue, 26 Mar 2024 14:26:40 -0700 Subject: [PATCH 4/8] this one works... --- core/ROB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ROB.cpp b/core/ROB.cpp index d3698ed0..26fc4e7d 100644 --- a/core/ROB.cpp +++ b/core/ROB.cpp @@ -275,7 +275,7 @@ namespace olympia if (getContainer() != nullptr) { const auto exe_pipe_rename = - olympia::coreutils::getPipeTopology(getContainer()->getRoot(), "exe_pipe_rename"); + olympia::coreutils::getPipeTopology(getContainer()->getParent(), "exe_pipe_rename"); if (exe_pipe_rename.size() > 0) iq_name = exe_pipe_rename[0][1]; // just grab the first issue queue } From b84f3ca2fcaac5451d5a5583c7f9505ef61a99b9 Mon Sep 17 00:00:00 2001 From: Anthony Hung Date: Tue, 26 Mar 2024 14:40:23 -0700 Subject: [PATCH 5/8] conform to camel naming --- core/ROB.cpp | 2 +- core/ROB.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/ROB.cpp b/core/ROB.cpp index 26fc4e7d..797acecd 100644 --- a/core/ROB.cpp +++ b/core/ROB.cpp @@ -268,7 +268,7 @@ namespace olympia } // for SYS instr which doesn't have an exe pipe - void ROB::setup_scoreboard_view() + void ROB::setupScoreboardView_() { std::string iq_name = "iq0"; // default name diff --git a/core/ROB.hpp b/core/ROB.hpp index e9609d0e..5bc1ac1b 100644 --- a/core/ROB.hpp +++ b/core/ROB.hpp @@ -136,7 +136,7 @@ namespace olympia void retireSysInst(InstPtr & ); - void setup_scoreboard_view() ; + void setupScoreboardView() ; // Scoreboards using ScoreboardViews = std::array, core_types::N_REGFILES>; From 4744dc819976546c3dcf08419c250db8a9d144f4 Mon Sep 17 00:00:00 2001 From: Anthony Hung Date: Tue, 26 Mar 2024 14:42:18 -0700 Subject: [PATCH 6/8] conform to camel naming --- core/ROB.cpp | 2 +- core/ROB.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/ROB.cpp b/core/ROB.cpp index 797acecd..40a1b22f 100644 --- a/core/ROB.cpp +++ b/core/ROB.cpp @@ -245,7 +245,7 @@ namespace olympia } // sys instr doesn't have a pipe so we handle special stuff here - void ROB::retireSysInst(InstPtr &ex_inst) + void ROB::retireSysInst_(InstPtr &ex_inst) { auto reg_file = ex_inst->getRenameData().getDestination().rf; if (reg_file == core_types::RegFile::RF_INVALID) diff --git a/core/ROB.hpp b/core/ROB.hpp index 5bc1ac1b..d77757ba 100644 --- a/core/ROB.hpp +++ b/core/ROB.hpp @@ -134,7 +134,7 @@ namespace olympia void dumpDebugContent_(std::ostream& output) const override final; void onStartingTeardown_() override final; - void retireSysInst(InstPtr & ); + void retireSysInst_(InstPtr & ); void setupScoreboardView() ; // Scoreboards From 342e74b1d513a3707c392826bf1e1477a82b330d Mon Sep 17 00:00:00 2001 From: Anthony Hung Date: Tue, 26 Mar 2024 14:46:42 -0700 Subject: [PATCH 7/8] conform to camel naming --- core/ROB.cpp | 4 ++-- core/ROB.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/ROB.cpp b/core/ROB.cpp index 40a1b22f..664b0c59 100644 --- a/core/ROB.cpp +++ b/core/ROB.cpp @@ -73,7 +73,7 @@ namespace olympia void ROB::sendInitialCredits_() { - setup_scoreboard_view() ; + setupScoreboardView_() ; out_reorder_buffer_credits_.send(reorder_buffer_.capacity()); ev_ensure_forward_progress_.schedule(retire_timeout_interval_); } @@ -190,7 +190,7 @@ namespace olympia // This is rare for the example if(SPARTA_EXPECT_FALSE(ex_inst.getPipe() == InstArchInfo::TargetPipe::SYS)) { - retireSysInst(ex_inst_ptr); + retireSysInst_(ex_inst_ptr); } } else { diff --git a/core/ROB.hpp b/core/ROB.hpp index d77757ba..b5941c9e 100644 --- a/core/ROB.hpp +++ b/core/ROB.hpp @@ -136,7 +136,7 @@ namespace olympia void retireSysInst_(InstPtr & ); - void setupScoreboardView() ; + void setupScoreboardView_() ; // Scoreboards using ScoreboardViews = std::array, core_types::N_REGFILES>; From f5f4dc518c7d6596ba97b07a29cebfad52479615 Mon Sep 17 00:00:00 2001 From: Anthony Hung Date: Thu, 4 Apr 2024 14:50:55 -0700 Subject: [PATCH 8/8] adjust spacing --- core/ROB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ROB.cpp b/core/ROB.cpp index 664b0c59..09637814 100644 --- a/core/ROB.cpp +++ b/core/ROB.cpp @@ -190,7 +190,7 @@ namespace olympia // This is rare for the example if(SPARTA_EXPECT_FALSE(ex_inst.getPipe() == InstArchInfo::TargetPipe::SYS)) { - retireSysInst_(ex_inst_ptr); + retireSysInst_(ex_inst_ptr); } } else {