Skip to content

Commit

Permalink
Merge branch 'master' into danbone/execute-flush
Browse files Browse the repository at this point in the history
Signed-off-by: danbone <[email protected]>
  • Loading branch information
danbone authored Jan 8, 2024
2 parents 24042ba + 648a316 commit 9f22089
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 46 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ section for areas of needed contributions. If there is no Assignee,
the work isn't being done!

When developing on Olympia, please adhere to the documented [Coding
Style
Guidelines](https://github.com/riscv-software-src/riscv-perf-model/blob/knutel/coding_style_guidelines/CodingStyle.md).
Style Guidelines](./CodingStyle.md).

## Example Usage

Expand Down
7 changes: 0 additions & 7 deletions core/Inst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,6 @@ namespace olympia
}
bool isMarkedOldest() const { return is_oldest_; }

// Instruction trace/JSON generation -- mark instruction as
// last in trace/JSON file.
void setLast() { is_last_ = true; }
bool getLast() const { return is_last_; }


// Rewind iterator used for going back in program simulation after flushes
template<typename T>
void setRewindIterator(T iter) { rewind_iter_ = iter; }
Expand Down Expand Up @@ -253,7 +247,6 @@ namespace olympia
sparta::memory::addr_t inst_pc_ = 0; // Instruction's PC
sparta::memory::addr_t target_vaddr_ = 0; // Instruction's Target PC (for branches, loads/stores)
bool is_oldest_ = false;
bool is_last_ = false; // Is last intruction of trace
uint64_t unique_id_ = 0; // Supplied by Fetch
uint64_t program_id_ = 0; // Supplied by a trace Reader or execution backend
bool is_speculative_ = false; // Is this instruction soon to be flushed?
Expand Down
6 changes: 0 additions & 6 deletions core/InstGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ namespace olympia
inst->setUniqueID(++unique_id_);
inst->setProgramID(program_id_++);
++curr_inst_index_;
if(isDone()) {
inst->setLast();
}
return inst;

}
Expand Down Expand Up @@ -212,9 +209,6 @@ namespace olympia
inst->setTargetVAddr(next_it_->branchTarget());
}
++next_it_;
if(isDone()) {
inst->setLast();
}
return inst;
}
catch(std::exception & excpt) {
Expand Down
11 changes: 5 additions & 6 deletions core/LSU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ namespace olympia
ldst_pipeline_.registerHandlerAtStage(cache_lookup_stage_,
CREATE_SPARTA_HANDLER(LSU, handleCacheLookupReq_));

node->getParent()->registerForNotification<bool, LSU, &LSU::onRobDrained_>(
this, "rob_notif_channel", false /* ROB maybe not be constructed yet */);
node->getParent()->registerForNotification<bool, LSU, &LSU::onROBTerminate_>(
this, "rob_stopped_notif_channel", false /* ROB maybe not be constructed yet */);

ldst_pipeline_.registerHandlerAtStage(cache_read_stage_,
CREATE_SPARTA_HANDLER(LSU, handleCacheRead_));
Expand All @@ -111,8 +111,6 @@ namespace olympia
ILOG("LSU construct: #" << node->getGroupIdx());
}

void LSU::onRobDrained_(const bool & val) { retire_done_ = val; }

LSU::~LSU()
{
DLOG(getContainer()->getLocation() << ": " << load_store_info_allocator_.getNumAllocated()
Expand All @@ -121,11 +119,13 @@ namespace olympia
<< " MemoryAccessInfo objects allocated/created");
}

void LSU::onROBTerminate_(const bool & val) { rob_stopped_simulation_ = val; }

void LSU::onStartingTeardown_()
{
// If ROB has not stopped the simulation &
// the ldst has entries to process we should fail
if ((false == retire_done_) && (false == ldst_inst_queue_.empty()))
if ((false == rob_stopped_simulation_) && (false == ldst_inst_queue_.empty()))
{
dumpDebugContent_(std::cerr);
sparta_assert(false, "Issue queue has pending instructions");
Expand Down Expand Up @@ -983,7 +983,6 @@ namespace olympia

void LSU::removeInstFromReplayQueue_(const InstPtr & inst_to_remove)
{
// return;
ILOG("Removing Inst from replay queue " << inst_to_remove);
for (const auto & ldst_inst : ldst_inst_queue_)
{
Expand Down
26 changes: 16 additions & 10 deletions core/LSU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,11 @@ namespace olympia
// Type Name/Alias Declaration
////////////////////////////////////////////////////////////////////////////////

bool retire_done_ = false;
using LoadStoreInstInfoPtr = sparta::SpartaSharedPointer<LoadStoreInstInfo>;
using LoadStoreInstIterator = sparta::Buffer<LoadStoreInstInfoPtr>::const_iterator;

using FlushCriteria = FlushManager::FlushingCriteria;

void onRobDrained_(const bool & val);

private:
using ScoreboardViews =
std::array<std::unique_ptr<sparta::ScoreboardView>, core_types::N_REGFILES>;
Expand Down Expand Up @@ -173,6 +170,9 @@ namespace olympia
// LSU Microarchitecture parameters
const bool allow_speculative_load_exec_;

// ROB stopped simulation early, transactions could still be inflight.
bool rob_stopped_simulation_ = false;

////////////////////////////////////////////////////////////////////////////////
// Event Handlers
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -230,7 +230,6 @@ namespace olympia
// Handle instruction flush in LSU
void handleFlush_(const FlushCriteria &);

void dumpDebugContent_(std::ostream & output) const override final;
// Instructions in the replay ready to issue
void replayReady_(const LoadStoreInstInfoPtr &);

Expand All @@ -240,6 +239,17 @@ namespace olympia
// Instructions in the replay ready to issue
void appendReady_(const LoadStoreInstInfoPtr &);

// Called when ROB terminates the simulation
void onROBTerminate_(const bool & val);

// When simulation is ending (error or not), this function
// will be called
void onStartingTeardown_() override;

// Typically called when the simulator is shutting down due to an exception
// writes out text to aid debug
void dumpDebugContent_(std::ostream & output) const override final;

////////////////////////////////////////////////////////////////////////////////
// Regular Function/Subroutine Call
////////////////////////////////////////////////////////////////////////////////
Expand All @@ -248,6 +258,8 @@ namespace olympia

void allocateInstToIssueQueue_(const InstPtr & inst_ptr);

bool olderStoresExists_(const InstPtr & inst_ptr);

bool allOlderStoresIssued_(const InstPtr & inst_ptr);

void readyDependentLoads_(const LoadStoreInstInfoPtr &);
Expand Down Expand Up @@ -325,12 +337,6 @@ namespace olympia
sparta::Counter biu_reqs_{getStatisticSet(), "biu_reqs", "Number of BIU reqs",
sparta::Counter::COUNT_NORMAL};

// When simulation is ending (error or not), this function
// will be called
void onStartingTeardown_() override;

bool olderStoresExists_(const InstPtr & inst_ptr);

friend class LSUTester;
};

Expand Down
20 changes: 6 additions & 14 deletions core/ROB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ namespace olympia
ev_ensure_forward_progress_.setContinuing(false);

// Notify other components when ROB stops the simulation
rob_drained_notif_source_.reset(new sparta::NotificationSource<bool>(
rob_stopped_notif_source_.reset(new sparta::NotificationSource<bool>(
this->getContainer(),
"rob_notif_channel",
"Notification channel for rob",
"rob_notif_channel"
"rob_stopped_notif_channel",
"ROB terminated simulation channel",
"rob_stopped_notif_channel"
));

// Send initial credits to anyone that cares. Probably Dispatch.
sparta::StartupEvent(node, CREATE_SPARTA_HANDLER(ROB, sendInitialCredits_));
}
Expand Down Expand Up @@ -163,7 +164,7 @@ namespace olympia
// Will be true if the user provides a -i option
if (SPARTA_EXPECT_FALSE((num_retired_ == num_insts_to_retire_))) {
rob_stopped_simulation_ = true;
rob_drained_notif_source_->postNotification(true);
rob_stopped_notif_source_->postNotification(true);
getScheduler()->stopRunning();
break;
}
Expand All @@ -180,15 +181,6 @@ namespace olympia
++num_flushes_;
break;
}

// Check to see if this is the last instruction of the
// trace
if(ex_inst.getLast()) {
rob_stopped_simulation_ = true;
rob_drained_notif_source_->postNotification(true);
// No need to stop the scheduler -- let simulation
// drain normally. Also, don't need to check forward progress
}
}
else {
break;
Expand Down
2 changes: 1 addition & 1 deletion core/ROB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace olympia
sparta::Event<> ev_ensure_forward_progress_{&unit_event_set_, "forward_progress_check",
CREATE_SPARTA_HANDLER(ROB, checkForwardProgress_)};

std::unique_ptr<sparta::NotificationSource<bool>> rob_drained_notif_source_;
std::unique_ptr<sparta::NotificationSource<bool>> rob_stopped_notif_source_;

void sendInitialCredits_();
void retireEvent_();
Expand Down

0 comments on commit 9f22089

Please sign in to comment.