Skip to content
This repository was archived by the owner on Dec 21, 2023. It is now read-only.

Commit d620fcd

Browse files
author
hyojongk
committed
added semi-independent row & column command lines
1 parent 91f08c9 commit d620fcd

File tree

4 files changed

+89
-47
lines changed

4 files changed

+89
-47
lines changed

AddressMapping.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ unsigned sliceLowerBits(uint64_t& addr, unsigned bits)
4545
void addressMapping(uint64_t addr, unsigned &chn, unsigned &rnk, unsigned &bnk, unsigned &row,
4646
unsigned &col)
4747
{
48-
//uint64_t addr_old = addr;
48+
#ifdef DEBUG_BUILD
49+
uint64_t addr_old = addr;
50+
#endif
4951

5052
unsigned tx_size = TRANSACTION_SIZE;
5153
unsigned tx_bits = log2(tx_size);

MemoryController.cpp

Lines changed: 79 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@ MemoryController::MemoryController(unsigned sid, unsigned cid, MemorySystem *par
4949
{
5050
parentMemorySystem = parent;
5151

52-
// outgoingCmdPacket represents a shared command bus between ranks, or pseudo channels.
53-
outgoingCmdPacket = NULL;
54-
cmdCyclesLeft = 0;
52+
// outgoingRowCmdPacket and outgoingColCmdPacket represent shared row and column command bus
53+
// between ranks, or pseudo channels.
54+
outgoingRowCmdPacket = NULL;
55+
outgoingColCmdPacket = NULL;
56+
rowCmdCyclesLeft = 0;
57+
colCmdCyclesLeft = 0;
5558

5659
// outgoingDataPackets represent per-pseudo-channel I/Os for write
5760
outgoingDataPackets.reserve(NUM_RANKS);
@@ -156,12 +159,21 @@ void MemoryController::update()
156159
{
157160
updateBankStates();
158161

159-
// check for outgoing command packets and handle countdowns
160-
if (outgoingCmdPacket != NULL) {
161-
cmdCyclesLeft--;
162-
if (cmdCyclesLeft == 0) { // packet is ready to be received by rank
163-
(*ranks)[outgoingCmdPacket->rank]->receiveFromBus(outgoingCmdPacket);
164-
outgoingCmdPacket = NULL;
162+
// check for outgoing row command packets and handle countdowns
163+
if (outgoingRowCmdPacket != NULL) {
164+
rowCmdCyclesLeft--;
165+
if (rowCmdCyclesLeft == 0) { // packet is ready to be received by rank
166+
(*ranks)[outgoingRowCmdPacket->rank]->receiveFromBus(outgoingRowCmdPacket);
167+
outgoingRowCmdPacket = NULL;
168+
}
169+
}
170+
171+
// check for outgoing column command packets and handle countdowns
172+
if (outgoingColCmdPacket != NULL) {
173+
colCmdCyclesLeft--;
174+
if (colCmdCyclesLeft == 0) { // packet is ready to be received by rank
175+
(*ranks)[outgoingColCmdPacket->rank]->receiveFromBus(outgoingColCmdPacket);
176+
outgoingColCmdPacket = NULL;
165177
}
166178
}
167179

@@ -184,7 +196,7 @@ void MemoryController::update()
184196

185197
LatencyBreakdown &lbd = *it;
186198
DEBUG("[" << stackID << "][" << channelID << "] addr:" << hex <<
187-
" 0x" << outgoingDataPacket[i]->physicalAddress << dec <<
199+
" 0x" << outgoingDataPackets[i]->physicalAddress << dec <<
188200
" timeAddedToTransactionQueue: " << lbd.timeAddedToTransactionQueue <<
189201
" timeAddedToCommandQueue: " << lbd.timeAddedToCommandQueue <<
190202
" timeScheduled: " << lbd.timeScheduled <<
@@ -310,6 +322,14 @@ void MemoryController::update()
310322
bankStates[rank][bank].nextRead = bankStates[rank][bank].nextActivate;
311323
bankStates[rank][bank].nextWrite = bankStates[rank][bank].nextActivate;
312324
}
325+
326+
if (outgoingColCmdPacket != NULL) {
327+
ERROR("[" << stackID << "][" << channelID << "] cycle:" << currentClockCycle << " Error - command bus collision");
328+
exit(-1);
329+
}
330+
331+
outgoingColCmdPacket = poppedBusPacket;
332+
colCmdCyclesLeft = tCMD;
313333
break;
314334

315335
case WRITE_P:
@@ -366,6 +386,14 @@ void MemoryController::update()
366386
bankStates[rank][bank].nextRead = bankStates[rank][bank].nextActivate;
367387
bankStates[rank][bank].nextWrite = bankStates[rank][bank].nextActivate;
368388
}
389+
390+
if (outgoingColCmdPacket != NULL) {
391+
ERROR("[" << stackID << "][" << channelID << "] cycle:" << currentClockCycle << " Error - command bus collision");
392+
exit(-1);
393+
}
394+
395+
outgoingColCmdPacket = poppedBusPacket;
396+
colCmdCyclesLeft = tCMD;
369397
break;
370398

371399
case ACTIVATE:
@@ -401,6 +429,14 @@ void MemoryController::update()
401429
bankStates[rank][i].nextActivate);
402430
}
403431
}
432+
433+
if (outgoingRowCmdPacket != NULL) {
434+
ERROR("[" << stackID << "][" << channelID << "] cycle:" << currentClockCycle << " Error - command bus collision");
435+
exit(-1);
436+
}
437+
438+
outgoingRowCmdPacket = poppedBusPacket;
439+
rowCmdCyclesLeft = tCMD;
404440
break;
405441

406442
case PRECHARGE:
@@ -409,6 +445,14 @@ void MemoryController::update()
409445
bankStates[rank][bank].stateChangeCountdown = tRP;
410446
bankStates[rank][bank].nextActivate = max(currentClockCycle + tRP,
411447
bankStates[rank][bank].nextActivate);
448+
449+
if (outgoingRowCmdPacket != NULL) {
450+
ERROR("[" << stackID << "][" << channelID << "] cycle:" << currentClockCycle << " Error - command bus collision");
451+
exit(-1);
452+
}
453+
454+
outgoingRowCmdPacket = poppedBusPacket;
455+
rowCmdCyclesLeft = tCMD;
412456
break;
413457

414458
case REFRESH:
@@ -418,22 +462,21 @@ void MemoryController::update()
418462
bankStates[rank][i].lastCommand = REFRESH;
419463
bankStates[rank][i].stateChangeCountdown = tRFC;
420464
}
465+
466+
if (outgoingRowCmdPacket != NULL) {
467+
ERROR("[" << stackID << "][" << channelID << "] cycle:" << currentClockCycle << " Error - command bus collision");
468+
exit(-1);
469+
}
470+
471+
outgoingRowCmdPacket = poppedBusPacket;
472+
rowCmdCyclesLeft = tCMD;
421473
break;
422474

423475
default:
424476
ERROR("== Error - command we shouldn't have of type : " << poppedBusPacket->busPacketType);
425477
exit(0);
426478
}
427479

428-
//check for collision on bus
429-
if (outgoingCmdPacket != NULL) {
430-
ERROR("[" << stackID << "][" << channelID << "] cycle:" << currentClockCycle << " Error - command bus collision");
431-
exit(-1);
432-
}
433-
434-
outgoingCmdPacket = poppedBusPacket;
435-
cmdCyclesLeft = tCMD;
436-
437480
#ifdef DEBUG_LATENCY
438481
deque<LatencyBreakdown> &dq = latencyBreakdowns[poppedBusPacket->physicalAddress];
439482
for (auto it = dq.begin(); it != dq.end(); ++it) {
@@ -457,7 +500,8 @@ void MemoryController::update()
457500
if (commandQueue.hasRoomFor(2, newRank)) {
458501
if (DEBUG_ADDR_MAP) {
459502
PRINTN("[" << stackID << "][" << channelID << "] ");
460-
PRINTN("cycle:" << currentClockCycle << " new transaction 0x" << hex << transaction->getAddress() << dec);
503+
PRINTN("cycle:" << currentClockCycle << " new transaction 0x" << hex <<
504+
transaction->getAddress() << dec);
461505
PRINTN((transaction->getTransactionType() == DATA_READ ? " read " : " write "));
462506
PRINT("ra:" << newRank << " ba:" << newBank << " ro:" << newRow << " co:" << newCol);
463507
}
@@ -518,14 +562,14 @@ void MemoryController::update()
518562
for (unsigned i = 0; i < pendingReadTransactions.size(); ++i) {
519563
if (pendingReadTransactions[i]->getAddress() == returnTransaction[0]->getAddress()) {
520564
#ifdef DEBUG_LATENCY
521-
deque<LatencyBreakdown> &dq = latencyBreakdowns[pendingReadTransactions[i]->address];
565+
deque<LatencyBreakdown> &dq = latencyBreakdowns[pendingReadTransactions[i]->getAddress()];
522566
for (auto it = dq.begin(); it != dq.end(); ++it) {
523567
if (it->isRead && it->timeReadDone != 0) {
524568
it->timeReturned = currentClockCycle;
525569

526570
LatencyBreakdown &lbd = *it;
527571
DEBUG("[" << stackID << "][" << channelID << "] addr:" << hex <<
528-
" 0x" << pendingReadTransactions[i]->address << dec <<
572+
" 0x" << pendingReadTransactions[i]->getAddress() << dec <<
529573
" timeAddedToTransactionQueue: " << lbd.timeAddedToTransactionQueue <<
530574
" timeAddedToCommandQueue: " << lbd.timeAddedToCommandQueue <<
531575
" timeScheduled: " << lbd.timeScheduled <<
@@ -541,7 +585,7 @@ void MemoryController::update()
541585
returnReadData(pendingReadTransactions[i]);
542586
delete pendingReadTransactions[i];
543587
pendingReadTransactions.erase(pendingReadTransactions.begin()+i);
544-
foundMatch=true;
588+
foundMatch = true;
545589
break;
546590
}
547591
}
@@ -550,6 +594,7 @@ void MemoryController::update()
550594
ERROR("Can't find a matching transaction for 0x" << hex << returnTransaction[0]->getAddress() << dec);
551595
abort();
552596
}
597+
553598
delete returnTransaction[0];
554599
returnTransaction.erase(returnTransaction.begin());
555600
}
@@ -574,11 +619,12 @@ bool MemoryController::addTransaction(Transaction *trans)
574619
transactionQueue.push_back(trans);
575620

576621
#ifdef DEBUG_LATENCY
577-
LatencyBreakdown lbd(currentClockCycle, (trans->transactionType == DATA_READ));
578-
auto it = latencyBreakdowns.find(trans->address);
622+
LatencyBreakdown lbd(currentClockCycle, (trans->getTransactionType() == DATA_READ));
623+
uint64_t addr = trans->getAddress();
624+
auto it = latencyBreakdowns.find(addr);
579625
if (it == latencyBreakdowns.end()) //not found
580-
latencyBreakdowns[trans->address] = deque<LatencyBreakdown>();
581-
latencyBreakdowns[trans->address].push_back(lbd);
626+
latencyBreakdowns[addr] = deque<LatencyBreakdown>();
627+
latencyBreakdowns[addr].push_back(lbd);
582628
#endif
583629
return true;
584630
} else {
@@ -615,23 +661,16 @@ void MemoryController::printStats(bool finalStats)
615661
uint64_t totalBytesTransferred = totalTransactions * bytesPerTransaction;
616662
double secondsThisEpoch = (double)cyclesElapsed * tCK * 1E-9;
617663

618-
// only per rank
619-
vector<double> backgroundPower = vector<double>(NUM_RANKS,0.0);
620-
vector<double> burstPower = vector<double>(NUM_RANKS,0.0);
621-
vector<double> refreshPower = vector<double>(NUM_RANKS,0.0);
622-
vector<double> actprePower = vector<double>(NUM_RANKS,0.0);
623-
vector<double> averagePower = vector<double>(NUM_RANKS,0.0);
624-
625664
// per bank variables
626-
vector<double> averageLatency = vector<double>(NUM_RANKS*NUM_BANKS,0.0);
665+
//vector<double> averageLatency = vector<double>(NUM_RANKS*NUM_BANKS,0.0);
627666
vector<double> bandwidth = vector<double>(NUM_RANKS*NUM_BANKS,0.0);
628667

629668
double totalBandwidth=0.0;
630669
for (unsigned i = 0; i < NUM_RANKS; ++i) {
631-
for (unsigned j = 0; j < NUM_BANKS; j++) {
632-
bandwidth[SEQUENTIAL(i,j)] = (((double)(totalReadsPerBank[SEQUENTIAL(i,j)]+totalWritesPerBank[SEQUENTIAL(i,j)]) * (double)bytesPerTransaction)/(1024.0*1024.0*1024.0)) / secondsThisEpoch;
633-
averageLatency[SEQUENTIAL(i,j)] = ((float)totalEpochLatency[SEQUENTIAL(i,j)] / (float)(totalReadsPerBank[SEQUENTIAL(i,j)])) * tCK;
634-
totalBandwidth+=bandwidth[SEQUENTIAL(i,j)];
670+
for (unsigned j = 0; j < NUM_BANKS; ++j) {
671+
bandwidth[SEQUENTIAL(i,j)] = (((double)(totalReadsPerBank[SEQUENTIAL(i,j)] + totalWritesPerBank[SEQUENTIAL(i,j)]) * (double)bytesPerTransaction)/(1024.0*1024.0*1024.0)) / secondsThisEpoch;
672+
//averageLatency[SEQUENTIAL(i,j)] = ((float)totalEpochLatency[SEQUENTIAL(i,j)] / (float)(totalReadsPerBank[SEQUENTIAL(i,j)])) * tCK;
673+
totalBandwidth += bandwidth[SEQUENTIAL(i,j)];
635674
totalReadsPerRank[i] += totalReadsPerBank[SEQUENTIAL(i,j)];
636675
totalWritesPerRank[i] += totalWritesPerBank[SEQUENTIAL(i,j)];
637676
}
@@ -642,8 +681,7 @@ void MemoryController::printStats(bool finalStats)
642681

643682
PRINT("Channel " << parentMemorySystem->channelID << " statistics");
644683
PRINTN(" Total Return Transactions: " << totalTransactions);
645-
PRINT( " (" << totalBytesTransferred << " bytes) aggregate average bandwidth " << totalBandwidth
646-
<< "GB/s");
684+
PRINT( " (" << totalBytesTransferred << " bytes) aggregate average bandwidth " << totalBandwidth << "GB/s");
647685

648686
//double totalAggregateBandwidth = 0.0;
649687
for (unsigned r = 0; r < NUM_RANKS; ++r) {

MemoryController.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ class MemoryController : public SimulatorObject
120120
vector<Rank*>* ranks;
121121

122122
// these packets are counting down waiting to be transmitted on the "bus"
123-
BusPacket* outgoingCmdPacket;
124-
unsigned cmdCyclesLeft;
123+
BusPacket* outgoingRowCmdPacket;
124+
BusPacket* outgoingColCmdPacket;
125+
unsigned rowCmdCyclesLeft;
126+
unsigned colCmdCyclesLeft;
125127
vector<BusPacket*> outgoingDataPackets;
126128
vector<unsigned> dataCyclesLeft;
127129

Transaction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ Transaction::Transaction(const Transaction &t) :
5454
ostream &operator<<(ostream &os, const Transaction &t)
5555
{
5656
if (t.transactionType == DATA_READ)
57-
os<<"T [Read] [0x" << hex << t.address << "]" << dec <<endl;
57+
os << "T [Read] [0x" << hex << t.address << "]" << dec << endl;
5858
else if (t.transactionType == DATA_WRITE)
59-
os<<"T [Write] [0x" << hex << t.address << "] [" << dec << t.data << "]" <<endl;
59+
os << "T [Write] [0x" << hex << t.address << "] [" << dec << t.data << "]" << endl;
6060
else if (t.transactionType == RETURN_DATA)
61-
os<<"T [Data] [0x" << hex << t.address << "] [" << dec << t.data << "]" <<endl;
61+
os << "T [Data] [0x" << hex << t.address << "] [" << dec << t.data << "]" << endl;
6262
return os;
6363
}
6464

0 commit comments

Comments
 (0)