Skip to content

Commit

Permalink
Updated DI unit port allocation logic and relevant unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnWilkinson committed Nov 7, 2024
1 parent 52aa992 commit 0889f12
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
41 changes: 18 additions & 23 deletions src/lib/pipeline/DispatchIssueUnit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,39 +75,34 @@ void DispatchIssueUnit::tick() {
continue;
}

// 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
// Loop through all ports and remove any who's RS is at capacity or dispatch
// rate has been met
auto portIt = supportedPorts.begin();
while (portIt != supportedPorts.end()) {
uint16_t RS_Index = portMapping_[*portIt].first;
ReservationStation* rs = &reservationStations_[RS_Index];
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));
portIt = supportedPorts.erase(portIt);
} else {
foundRS = true;
portIt++;
}
}
// If no port with capacity or available dispatch rate found. Stall and
// return.
if (false == foundRS) {
// If no ports left, stall and return
if (supportedPorts.size() == 0) {
input_.stall(true);
rsStalls_++;
return;
}

// Find an available RS
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];

// Assume the uop will be ready
bool ready = true;

Expand Down
4 changes: 2 additions & 2 deletions test/unit/pipeline/DispatchIssueUnitTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace simeng {
namespace pipeline {

using ::testing::_;
using ::testing::Return;
using ::testing::ReturnRef;

Expand Down Expand Up @@ -269,8 +270,7 @@ TEST_F(PipelineDispatchIssueUnitTest, singleInstr_rsFull) {
// All expected calls to instruction during tick()
EXPECT_CALL(*uop, getSupportedPorts()).WillOnce(ReturnRef(suppPorts));
// All expected calls to portAllocator during tick()
EXPECT_CALL(portAlloc, allocate(suppPorts)).WillOnce(Return(EAGA));
EXPECT_CALL(portAlloc, deallocate(EAGA));
EXPECT_CALL(portAlloc, allocate(_)).Times(0);
input.getHeadSlots()[0] = uopPtr;
diUnit.tick();
// Ensure Reservation station sizes have stayed the same
Expand Down

0 comments on commit 0889f12

Please sign in to comment.