Skip to content

Commit

Permalink
Made more balanced RS allocation in DI unit by not stalling on first …
Browse files Browse the repository at this point in the history
…port allocation failure but instead cycling through all possible RSs.
  • Loading branch information
FinnWilkinson committed Sep 19, 2024
1 parent 4134c3e commit 7f91ef9
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions src/lib/pipeline/DispatchIssueUnit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,42 @@ void DispatchIssueUnit::tick() {
continue;
}

const std::vector<uint16_t>& supportedPorts = uop->getSupportedPorts();
std::vector<uint16_t> supportedPorts = uop->getSupportedPorts();
if (uop->exceptionEncountered()) {
// Exception; mark as ready to commit, and remove from pipeline
uop->setCommitReady();
input_.getHeadSlots()[slot] = nullptr;
continue;
}
// Allocate issue port to uop
uint16_t port = portAllocator_.allocate(supportedPorts);
uint16_t RS_Index = portMapping_[port].first;
uint16_t RS_Port = portMapping_[port].second;
assert(RS_Index < reservationStations_.size() &&
"Allocated port inaccessible");
ReservationStation& rs = reservationStations_[RS_Index];

// When appropriate, stall uop or input buffer if stall buffer full
if (rs.currentSize == rs.capacity ||
dispatches_[RS_Index] == rs.dispatchRate) {
// Deallocate port given
portAllocator_.deallocate(port);
// Try find an available RS
uint16_t port = 0;
uint16_t RS_Index = 0;
uint16_t RS_Port = 0;
ReservationStation* rs;
bool foundRS = false;
while (false == foundRS && supportedPorts.size() > 0) {
// Allocate issue port to uop
port = portAllocator_.allocate(supportedPorts);
RS_Index = portMapping_[port].first;
RS_Port = portMapping_[port].second;
assert(RS_Index < reservationStations_.size() &&
"Allocated port inaccessible");
rs = &reservationStations_[RS_Index];
// When appropriate, stall uop or input buffer if stall buffer full
if (rs->currentSize == rs->capacity ||
dispatches_[RS_Index] == rs->dispatchRate) {
// Deallocate port given
portAllocator_.deallocate(port);
supportedPorts.erase(
std::find(supportedPorts.begin(), supportedPorts.end(), port));
} else {
foundRS = true;
}
}
// If no port with capacity or available dispatch rate found. Stall and
// return.
if (false == foundRS) {
input_.stall(true);
rsStalls_++;
return;
Expand Down Expand Up @@ -123,10 +139,10 @@ void DispatchIssueUnit::tick() {

// Increment dispatches made and RS occupied entries size
dispatches_[RS_Index]++;
rs.currentSize++;
rs->currentSize++;

if (ready) {
rs.ports[RS_Port].ready.push_back(std::move(uop));
rs->ports[RS_Port].ready.push_back(std::move(uop));
}

input_.getHeadSlots()[slot] = nullptr;
Expand Down

0 comments on commit 7f91ef9

Please sign in to comment.