From 0a75b60ea7578c155e3903e2d4cbe21077f48a60 Mon Sep 17 00:00:00 2001 From: Kathlene Magnus Date: Mon, 15 Jul 2024 10:01:08 -0700 Subject: [PATCH] Adding flushing support to the vector uop generator --- core/Decode.cpp | 7 +++++-- core/IssueQueue.cpp | 2 +- core/VectorUopGenerator.cpp | 15 ++++++++++----- core/VectorUopGenerator.hpp | 14 ++++++++++++-- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/core/Decode.cpp b/core/Decode.cpp index bed28cd7..2d523254 100644 --- a/core/Decode.cpp +++ b/core/Decode.cpp @@ -178,6 +178,9 @@ namespace olympia ILOG("Got a flush call for " << criteria); fetch_queue_credits_outp_.send(fetch_queue_.size()); fetch_queue_.clear(); + + // Reset the vector uop generator + vec_uop_gen_->handleFlush(criteria); } // Decode instructions @@ -268,9 +271,9 @@ namespace olympia // Original instruction will act as the first UOp inst->setUOpID(0); // set UOpID() - while(vec_uop_gen_->keepGoing()) + while(vec_uop_gen_->getNumUopsRemaining() > 0) { - const InstPtr uop = vec_uop_gen_->genUop(); + const InstPtr uop = vec_uop_gen_->generateUop(); if (insts->size() < num_to_decode_) { insts->emplace_back(uop); diff --git a/core/IssueQueue.cpp b/core/IssueQueue.cpp index 62fa2a38..91345b2a 100644 --- a/core/IssueQueue.cpp +++ b/core/IssueQueue.cpp @@ -99,7 +99,7 @@ namespace olympia { const auto srcs = ex_inst->getRenameData().getSourceList(); uint32_t ready = 0; - for(auto src : srcs) + for(const auto & src : srcs) { // vector-scalar operations have 1 vector src and 1 scalar src that // need to be checked, so can't assume the register files are the diff --git a/core/VectorUopGenerator.cpp b/core/VectorUopGenerator.cpp index 3c146340..d9237d76 100644 --- a/core/VectorUopGenerator.cpp +++ b/core/VectorUopGenerator.cpp @@ -40,7 +40,7 @@ namespace olympia } } - const InstPtr VectorUopGenerator::genUop() + const InstPtr VectorUopGenerator::generateUop() { ++num_uops_generated_; @@ -82,13 +82,18 @@ namespace olympia const uint32_t num_elems = current_VCSRs->vl / current_VCSRs->sew; uop->setTail(num_elems < current_VCSRs->vlmax); - // Reset - current_inst_ = nullptr; - num_uops_generated_ = 0; - num_uops_to_generate_ = 0; + reset_(); } ILOG("Generated uop: " << uop); return uop; } + + void VectorUopGenerator::handleFlush(const FlushManager::FlushingCriteria & flush_criteria) + { + if(current_inst_ && flush_criteria.includedInFlush(current_inst_)) + { + reset_(); + } + } } // namespace olympia diff --git a/core/VectorUopGenerator.hpp b/core/VectorUopGenerator.hpp index 42fea766..dbd5ce98 100644 --- a/core/VectorUopGenerator.hpp +++ b/core/VectorUopGenerator.hpp @@ -7,6 +7,7 @@ #include "sparta/simulation/ParameterSet.hpp" #include "Inst.hpp" +#include "FlushManager.hpp" #include "MavisUnit.hpp" namespace olympia @@ -41,9 +42,11 @@ namespace olympia void setInst(const InstPtr & inst); - const InstPtr genUop(); + const InstPtr generateUop(); - bool keepGoing() const { return num_uops_to_generate_ > 1; } + uint64_t getNumUopsRemaining() const { return num_uops_to_generate_; } + + void handleFlush(const FlushManager::FlushingCriteria &); private: MavisType * mavis_facade_; @@ -53,5 +56,12 @@ namespace olympia uint64_t num_uops_generated_ = 0; uint64_t num_uops_to_generate_ = 0; + + void reset_() + { + current_inst_ = nullptr; + num_uops_generated_ = 0; + num_uops_to_generate_ = 0; + } }; } // namespace olympia