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

Fix end of simulation empty buffer checks in LSU #138

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions core/Inst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,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_; }

// Set the instructions unique ID. This ID in constantly
// incremented and does not repeat. The same instruction in a
// trace can have different unique IDs (due to flushing)
Expand Down Expand Up @@ -223,7 +218,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 @@ -106,9 +106,6 @@ namespace olympia
++curr_inst_index_;
inst->setUniqueID(++unique_id_);
inst->setProgramID(unique_id_);
if(isDone()) {
inst->setLast();
}
return inst;

}
Expand Down Expand Up @@ -177,9 +174,6 @@ namespace olympia
//inst->setVAddrVector(std::move(addrs));
}
++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 @@ -992,7 +992,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 @@ -175,6 +172,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 @@ -232,7 +232,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 @@ -242,6 +241,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 @@ -250,6 +260,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 @@ -321,12 +333,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 @@ -139,7 +140,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 @@ -157,15 +158,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 @@ -116,7 +116,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