@@ -49,9 +49,12 @@ MemoryController::MemoryController(unsigned sid, unsigned cid, MemorySystem *par
49
49
{
50
50
parentMemorySystem = parent;
51
51
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 ;
55
58
56
59
// outgoingDataPackets represent per-pseudo-channel I/Os for write
57
60
outgoingDataPackets.reserve (NUM_RANKS);
@@ -156,12 +159,21 @@ void MemoryController::update()
156
159
{
157
160
updateBankStates ();
158
161
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 ;
165
177
}
166
178
}
167
179
@@ -184,7 +196,7 @@ void MemoryController::update()
184
196
185
197
LatencyBreakdown &lbd = *it;
186
198
DEBUG (" [" << stackID << " ][" << channelID << " ] addr:" << hex <<
187
- " 0x" << outgoingDataPacket [i]->physicalAddress << dec <<
199
+ " 0x" << outgoingDataPackets [i]->physicalAddress << dec <<
188
200
" timeAddedToTransactionQueue: " << lbd.timeAddedToTransactionQueue <<
189
201
" timeAddedToCommandQueue: " << lbd.timeAddedToCommandQueue <<
190
202
" timeScheduled: " << lbd.timeScheduled <<
@@ -310,6 +322,14 @@ void MemoryController::update()
310
322
bankStates[rank][bank].nextRead = bankStates[rank][bank].nextActivate ;
311
323
bankStates[rank][bank].nextWrite = bankStates[rank][bank].nextActivate ;
312
324
}
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;
313
333
break ;
314
334
315
335
case WRITE_P:
@@ -366,6 +386,14 @@ void MemoryController::update()
366
386
bankStates[rank][bank].nextRead = bankStates[rank][bank].nextActivate ;
367
387
bankStates[rank][bank].nextWrite = bankStates[rank][bank].nextActivate ;
368
388
}
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;
369
397
break ;
370
398
371
399
case ACTIVATE:
@@ -401,6 +429,14 @@ void MemoryController::update()
401
429
bankStates[rank][i].nextActivate );
402
430
}
403
431
}
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;
404
440
break ;
405
441
406
442
case PRECHARGE:
@@ -409,6 +445,14 @@ void MemoryController::update()
409
445
bankStates[rank][bank].stateChangeCountdown = tRP;
410
446
bankStates[rank][bank].nextActivate = max (currentClockCycle + tRP,
411
447
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;
412
456
break ;
413
457
414
458
case REFRESH:
@@ -418,22 +462,21 @@ void MemoryController::update()
418
462
bankStates[rank][i].lastCommand = REFRESH;
419
463
bankStates[rank][i].stateChangeCountdown = tRFC;
420
464
}
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;
421
473
break ;
422
474
423
475
default :
424
476
ERROR (" == Error - command we shouldn't have of type : " << poppedBusPacket->busPacketType );
425
477
exit (0 );
426
478
}
427
479
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
-
437
480
#ifdef DEBUG_LATENCY
438
481
deque<LatencyBreakdown> &dq = latencyBreakdowns[poppedBusPacket->physicalAddress ];
439
482
for (auto it = dq.begin (); it != dq.end (); ++it) {
@@ -457,7 +500,8 @@ void MemoryController::update()
457
500
if (commandQueue.hasRoomFor (2 , newRank)) {
458
501
if (DEBUG_ADDR_MAP) {
459
502
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);
461
505
PRINTN ((transaction->getTransactionType () == DATA_READ ? " read " : " write " ));
462
506
PRINT (" ra:" << newRank << " ba:" << newBank << " ro:" << newRow << " co:" << newCol);
463
507
}
@@ -518,14 +562,14 @@ void MemoryController::update()
518
562
for (unsigned i = 0 ; i < pendingReadTransactions.size (); ++i) {
519
563
if (pendingReadTransactions[i]->getAddress () == returnTransaction[0 ]->getAddress ()) {
520
564
#ifdef DEBUG_LATENCY
521
- deque<LatencyBreakdown> &dq = latencyBreakdowns[pendingReadTransactions[i]->address ];
565
+ deque<LatencyBreakdown> &dq = latencyBreakdowns[pendingReadTransactions[i]->getAddress () ];
522
566
for (auto it = dq.begin (); it != dq.end (); ++it) {
523
567
if (it->isRead && it->timeReadDone != 0 ) {
524
568
it->timeReturned = currentClockCycle;
525
569
526
570
LatencyBreakdown &lbd = *it;
527
571
DEBUG (" [" << stackID << " ][" << channelID << " ] addr:" << hex <<
528
- " 0x" << pendingReadTransactions[i]->address << dec <<
572
+ " 0x" << pendingReadTransactions[i]->getAddress () << dec <<
529
573
" timeAddedToTransactionQueue: " << lbd.timeAddedToTransactionQueue <<
530
574
" timeAddedToCommandQueue: " << lbd.timeAddedToCommandQueue <<
531
575
" timeScheduled: " << lbd.timeScheduled <<
@@ -541,7 +585,7 @@ void MemoryController::update()
541
585
returnReadData (pendingReadTransactions[i]);
542
586
delete pendingReadTransactions[i];
543
587
pendingReadTransactions.erase (pendingReadTransactions.begin ()+i);
544
- foundMatch= true ;
588
+ foundMatch = true ;
545
589
break ;
546
590
}
547
591
}
@@ -550,6 +594,7 @@ void MemoryController::update()
550
594
ERROR (" Can't find a matching transaction for 0x" << hex << returnTransaction[0 ]->getAddress () << dec);
551
595
abort ();
552
596
}
597
+
553
598
delete returnTransaction[0 ];
554
599
returnTransaction.erase (returnTransaction.begin ());
555
600
}
@@ -574,11 +619,12 @@ bool MemoryController::addTransaction(Transaction *trans)
574
619
transactionQueue.push_back (trans);
575
620
576
621
#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);
579
625
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);
582
628
#endif
583
629
return true ;
584
630
} else {
@@ -615,23 +661,16 @@ void MemoryController::printStats(bool finalStats)
615
661
uint64_t totalBytesTransferred = totalTransactions * bytesPerTransaction;
616
662
double secondsThisEpoch = (double )cyclesElapsed * tCK * 1E-9 ;
617
663
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
-
625
664
// 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);
627
666
vector<double > bandwidth = vector<double >(NUM_RANKS*NUM_BANKS,0.0 );
628
667
629
668
double totalBandwidth=0.0 ;
630
669
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)];
635
674
totalReadsPerRank[i] += totalReadsPerBank[SEQUENTIAL (i,j)];
636
675
totalWritesPerRank[i] += totalWritesPerBank[SEQUENTIAL (i,j)];
637
676
}
@@ -642,8 +681,7 @@ void MemoryController::printStats(bool finalStats)
642
681
643
682
PRINT (" Channel " << parentMemorySystem->channelID << " statistics" );
644
683
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" );
647
685
648
686
// double totalAggregateBandwidth = 0.0;
649
687
for (unsigned r = 0 ; r < NUM_RANKS; ++r) {
0 commit comments