-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSCIC.cpp
More file actions
767 lines (666 loc) · 21.4 KB
/
SCIC.cpp
File metadata and controls
767 lines (666 loc) · 21.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
/****************************************************************************
* SCIC: A System C Interface Converter for DRAMSim
*
* Copyright (C) 2011 Myoungsoo Jung
* Pennsylvania State University
* David Donofrio
* John Shalf
* Lawrence Berkeley National Lab.
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*****************************************************************************/
#include "systemc.h"
#include "PrintMacros.h"
#include "MemorySystem.h"
#include "SCIC.h"
#include "assert.h"
#if (USE_SCIC_MEMSYS_QUERY == 1)
extern unsigned NUM_DEVICES;
extern unsigned NUM_RANKS;
extern uint BL;
#endif
#ifndef _SIM_
int SHOW_SIM_OUTPUT = 1;
ofstream visDataOut; //mostly used in MemoryController
#endif
////////////////////////////////////////////////////////////////////////////////
//
// Method: runSystem
// FullName: SCIC::runSystem
// Access: public
// Returns: void
//
// Descriptions - SCIC's SystemC thread.
//
//////////////////////////////////////////////////////////////////////////////
void SCIC::runSystem()
{
bool bIssued = false;
resetDataOut();
wait(SC_ZERO_TIME);
while(true)
{
if(_pLegacyMemorySystem == NULL)
{
//
// Since there is no module for emulating system c interface, this thread yields a control to other process until
// legacy memory system assigned.
//
//wait(SC_ZERO_TIME);
wait();
continue;
}
//
// clear signal
//
if(_prtCA->read() == true)
{
_prtCA->write(false);
resetDataOut();
}
//
// CPU issued an I/O requests to BIU
//
if(_prtDE->read() == true)
{
TransactionType type = _prtWE->read() ? DATA_WRITE : DATA_READ;
uint64_t * pBuffer = NULL;
#ifndef NO_STORAGE
if(type == DATA_WRITE)
{
pBuffer = getDataFromPort();
if(pBuffer != NULL)
{
SCIC_PRINT("DIN[0] : 0x" << hex << pBuffer[0] << " ADDR: 0x" << hex <<_prtDA->read());
}
else
{
//
// A CPU model use no storage trace or input without no_stroage option.
// Based what original DRAMSim use, SCIC handles this one to avoid
// a memory leak on scoreboard.
//
_bUserDataHandlingFault = true;
}
}
else
{
//
// Typically, if there is a request which is pending,
// no CPU commit the same request until memory system releases the request.
// Just in case, however, if an internal buffer was allocated already for same address,
// SCIC allocates no storage for this transaction.
//
ScoreBoard::iterator entry = _scoreBoard.find(_prtDA->read());
if(entry != _scoreBoard.end() && entry->second.WasWrite() != true)
{
pBuffer = entry->second.AllocatedMem();
entry->second.IncRefCnt();
}
else
{
pBuffer = new uint64_t[4];
ScoreBoardElement memElement(pBuffer, (type == DATA_WRITE) ? true : false);
_scoreBoard.insert(make_pair(_prtDA->read(), memElement));
}
}
#endif
Transaction trans(type, _prtDA->read(), (void *)pBuffer, _prtReqTransID->read());
//DEBUG("SC Memory System received address :" << std::hex << trans.address << std::dec);
alignTransactionAddress(trans);
bIssued = _pLegacyMemorySystem->addTransaction(trans);
if(bIssued == false)
{
//
// Transaction queue is full
//
_prtRB->write(true);
}
}
#if (USE_CALIBRATION_1CYCLE != 1)
//
// No matter what, the this system interface provides clock signal to memory system.
//
_pLegacyMemorySystem->update();
_nCurrentClk++;
#else
if(_bInitialTime == false)
{
//
// No matter what, the this system interface provides clock signal to memory system.
//
_pLegacyMemorySystem->update();
_nCurrentClk++;
}
else
{
_bInitialTime = false;
}
#endif
wait();
}
}
void power_callback(double a, double b, double c, double d)
{
// printf("power callback: %0.3f, %0.3f, %0.3f, %0.3f\n",a,b,c,d);
}
////////////////////////////////////////////////////////////////////////////////
//
// Method: AttachLegacyMemorySystem
// FullName: SCIC::AttachLegacyMemorySystem
// Access: public
// Returns: void
// Parameter: MemorySystem * pMemorySystem
//
// Descriptions - attach legacy memory system (DRAMSim instance0
// The SCIC should provide SystemC interface for this instance, so a CPU model,
// or user have to attach the memory system first before running sc_main
//
//////////////////////////////////////////////////////////////////////////////
void SCIC::AttachLegacyMemorySystem(MemorySystem *pMemorySystem)
{
if(_pLegacyMemorySystem != NULL)
{
ERROR("SystemC Interface has already legacy memory system");
exit(0);
}
else if(pMemorySystem == NULL)
{
ERROR("Memory System that you want to attach is not available");
exit(0);
}
else
{
_pLegacyMemorySystem = pMemorySystem;
//
// register callbacks
//
Callback_t *pReadCallback = new Callback_4Param<SCIC, void, uint, uint64_t, uint64_t, uint64_t>(this, &SCIC::readComplete);
Callback_t *pWriteCallback = new Callback_4Param<SCIC, void, uint, uint64_t, uint64_t, uint64_t>(this, &SCIC::writeComplete);
#if (USE_SCIC_MEMSYS_QUERY == 1)
CB_HIST *pHistgramCallback = new Callback_3Param<SCIC, void, uint, uint, uint>(this, &SCIC::measureIndividualLatency);
_pLegacyMemorySystem->RegisterCallbacks(pReadCallback, pWriteCallback, pHistgramCallback, power_callback);
#else
_pLegacyMemorySystem->RegisterCallbacks(pReadCallback, pWriteCallback, power_callback);
#endif
if(_pLegacyMemorySystem->memoryController == NULL)
{
ERROR("Memory System that you want to attach is not available");
exit(0);
}
#if (USE_SCIC_MEMSYS_QUERY == 1)
//
// build references
//
_vctpEnergy[SCIC_ENERGY_BACKGROUND] = _pLegacyMemorySystem->memoryController->BackgroundEnergy();
_vctpEnergy[SCIC_ENERGY_BURST] = _pLegacyMemorySystem->memoryController->BurstEnergy();
_vctpEnergy[SCIC_ENERGY_PRECHARGE] = _pLegacyMemorySystem->memoryController->ActpreEnergy();
_vctpEnergy[SCIC_ENERGY_REFRESH] = _pLegacyMemorySystem->memoryController->RefreshEnergy();
#endif
}
}
////////////////////////////////////////////////////////////////////////////////
//
// Method: getDataFromPort
// FullName: SCIC::getDataFromPort
// Access: public
// Returns: uint64_t *
//
// Descriptions - read data from DIN using a storage. User does not consider
// memory management because it is managed by the scoreboard manager.
//
//////////////////////////////////////////////////////////////////////////////
uint64_t * SCIC::getDataFromPort()
{
uint64_t *pBuffer = NULL;
if(_prtDIN[0]->read() != NULL_SIG64)
{
pBuffer = new uint64_t[4];
for (int nBuffIdx = 0; nBuffIdx < 4; ++nBuffIdx)
{
pBuffer[nBuffIdx] = _prtDIN[nBuffIdx]->read();
}
}
return pBuffer;
}
////////////////////////////////////////////////////////////////////////////////
//
// Method: freeMemoryElement
// FullName: SCIC::freeMemoryElement
// Access: public
// Returns: void
// Parameter: uint64_t key
// Parameter: bool bWrite
//
// Descriptions - this method will release an entry of scoreboard, which are
// matched with an associated key which comprises a key and type of transaction
//
//////////////////////////////////////////////////////////////////////////////
void SCIC::freeMemoryElement(uint64_t key, bool bWrite)
{
#ifndef NO_STORAGE
ScoreBoard::iterator iter = _scoreBoard.end();
//
// For the case that user uses k6 or mase without NO_STORAGE option
//
if (bWrite == true && _bUserDataHandlingFault == true )
{
return;
}
bool bReleased = false;
if(_scoreBoard.count(key) == 1 )
{
iter= _scoreBoard.find(key);
iter->second.DecRefCnt();
if(iter->second.RefCnts() == 0)
{
iter->second.Free();
bReleased = true;
}
}
else
{
pair<ScoreBoard::iterator, ScoreBoard::iterator> ret_pair = _scoreBoard.equal_range(key);
for(iter = ret_pair.first; iter != ret_pair.second; ++iter)
{
if(iter->second.WasWrite() == bWrite)
{
iter->second.DecRefCnt();
if(iter->second.RefCnts() == 0)
{
iter->second.Free();
bReleased = true;
}
break;
}
}
}
if(iter != _scoreBoard.end() && bReleased == true)
{
_scoreBoard.erase(iter);
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
// Method: setDataOutPort
// FullName: SCIC::setDataOutPort
// Access: public
// Returns: void
// Parameter: uint64_t key
//
// Descriptions - write data to DOUTs based on the provided key
// The key is a memory address used in a request transaction.
//
//////////////////////////////////////////////////////////////////////////////
void SCIC::setDataOutPort(uint64_t key)
{
#ifndef NO_STORAGE
if (key == NULL_SIG64)
{
for(int nBuffIdx = 0; nBuffIdx < 4; nBuffIdx++)
{
_prtDOUT[nBuffIdx]->write(NULL_SIG64);
}
}
else
{
uint64_t *pBuffer = NULL;
//
// look up scoreboard.
//
if(_scoreBoard.count(key) == 1)
{
pBuffer = _scoreBoard.find(key)->second.AllocatedMem();
}
else
{
pair<ScoreBoard::iterator, ScoreBoard::iterator> ret_pair = _scoreBoard.equal_range(key);
for(ScoreBoard::iterator iter = ret_pair.first; iter != ret_pair.second; ++iter)
{
if(iter->second.WasWrite() == false)
{
pBuffer = iter->second.AllocatedMem();
break;
}
}
}
if(pBuffer == NULL)
{
ERROR("get lost of allocated internal stroage");
assert(pBuffer != NULL);
}
SCIC_PRINT("DOUT[0] : 0x" << hex << pBuffer[0] << " ADDR: 0x" << hex << key);
for(int nBuffIdx = 0; nBuffIdx < 4; nBuffIdx++)
{
_prtDOUT[nBuffIdx]->write(pBuffer[nBuffIdx]);
}
}
#else
for(int nBuffIdx = 0; nBuffIdx < 4; nBuffIdx++)
{
_prtDOUT[nBuffIdx]->write(NULL_SIG64);
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
// Method: initializeInterface
// FullName: SCIC::initializeInterface
// Access: public
// Returns: void
//
// Descriptions - Initialize Internal States
//
//////////////////////////////////////////////////////////////////////////////
void SCIC::initializeInterface()
{
_pLegacyMemorySystem = NULL;
_bUserDataHandlingFault = false;
_bInitialTime = true;
#if (USE_SCIC_MEMSYS_QUERY == 1)
_nCycleTracker = NULL_SIG64;
_vctRtLatencyReport = vector<uint64_t>(NUM_RANKS*NUM_BANKS,0);
#endif
}
void SCIC::Reset()
{
if(_pLegacyMemorySystem == NULL)
{
throw "SCIC::Reset:: Invalid Pointer for MemorySystem instance";
}
#if (USE_SCIC_MEMSYS_QUERY == 1)
if(!((NUM_RANKS > 0) && (NUM_BANKS >0)) ) { throw "SCIC::Reset:: Invalid RANK / BANK Configuration - must be > 0";};
_nCycleTracker = NULL_SIG64;
_vctRtLatencyReport = vector<uint64_t>(NUM_RANKS*NUM_BANKS,0);
#endif
//initializeInterface();
resetDataOut();
}
////////////////////////////////////////////////////////////////////////////////
//
// Method: readComplete
// FullName: SCIC::readComplete
// Access: public
// Returns: void
// Parameter: uint nSystemId
// Parameter: uint64_t nTargatAddr
// Parameter: uint64_t nClockCycle
// Parameter: uint64_t nTransID
//
// Descriptions - read completion (This method releases scoreboard entry associated with the callback request.
//
//////////////////////////////////////////////////////////////////////////////
void SCIC::readComplete(uint nSystemId, uint64_t nTargatAddr, uint64_t nClockCycle, uint64_t nTransID)
{
_prtRB->write(false);
_prtAO->write(nTargatAddr);
_prtWO->write(false);
_prtCA->write(true);
_prtRespTransID->write(nTransID);
m_ptrCompAckEvent->notify(SC_ZERO_TIME);
setDataOutPort(nTargatAddr);
#if (USE_CALIBRATION_1CYCLE == 1)
wait(SC_ZERO_TIME);
#endif
#if (USE_SCIC_MEMSYS_QUERY == 1)
_nCycleTracker = nClockCycle;
#endif
freeMemoryElement(nTargatAddr, false);
}
////////////////////////////////////////////////////////////////////////////////
//
// Method: writeComplete
// FullName: SCIC::writeComplete
// Access: public
// Returns: void
// Parameter: uint nSystemId
// Parameter: uint64_t nTargatAddr
// Parameter: uint64_t nClockCycle
// Parameter: uint64_t nTransID
//
// Descriptions - callback for write completion.
//
//////////////////////////////////////////////////////////////////////////////
void SCIC::writeComplete(uint nSystemId, uint64_t nTargatAddr, uint64_t nClockCycle, uint64_t nTransID)
{
_prtRB->write(false);
_prtAO->write(nTargatAddr);
_prtWO->write(true);
_prtCA->write(true);
m_ptrCompAckEvent->notify(SC_ZERO_TIME);
_prtRespTransID->write(nTransID);
setDataOutPort(NULL_SIG64);
#if (USE_SCIC_MEMSYS_QUERY == 1)
_nCycleTracker = nClockCycle;
#endif
#if (USE_CALIBRATION_1CYCLE == 1)
wait(SC_ZERO_TIME);
#endif
freeMemoryElement(nTargatAddr, true);
}
void SCIC::alignTransactionAddress(Transaction &trans)
{
// zero out the low order bits which correspond to the size of a transaction
unsigned throwAwayBits = dramsim_log2((BL*JEDEC_DATA_BUS_BITS/8));
trans.address >>= throwAwayBits;
trans.address <<= throwAwayBits;
}
//////////////////////////////////////////////////////////////////////////
// Function-style inquiry methods for memory status
// These method enable to get latency and bandwidth for each memory request at real-time
//
// For compatibility to future version of DRAMSim,
// I recommend you to disable USE_SCIC_MEMSYS_QUERY preprocessor.
// If you need to use these methods to get statistics from memory,
// you is asked to port code fragments surrounded by the USE_SCIC_MEMSYS_QUERY macro
// to new version of DRAMSim.
//////////////////////////////////////////////////////////////////////////
#if (USE_SCIC_MEMSYS_QUERY == 1)
////////////////////////////////////////////////////////////////////////////////
//
// Method: measureIndividualLatency
// FullName: SCIC::measureIndividualLatency
// Access: public
// Returns: void
// Parameter: uint nLatency
// Parameter: uint nRank
// Parameter: uint nBank
//
// Descriptions -
// This method measures latency for each memory instruction.
// This is not going to elapse whole memory latencies for running.
// Instead, this method elapses latency for each rank and bank from the last point
// that you queried latency information using GetLatencyandMarkTimepoint().
//
//////////////////////////////////////////////////////////////////////////////
void SCIC::measureIndividualLatency(uint nLatency, uint nRank, uint nBank)
{
_vctRtLatencyReport[SEQUENTIAL(nRank, nBank)] += nLatency;
}
////////////////////////////////////////////////////////////////////////////////
//
// Method: GetLatencyandMarkTimepoint
// FullName: SCIC::GetLatencyandMarkTimepoint
// Access: public
// Returns: uint64_t
// Parameter: vector<uint64_t> & perfInfo
//
// Descriptions -
//
//////////////////////////////////////////////////////////////////////////////
uint64_t SCIC::GetLatencyandMarkTimepoint(vector<uint64_t> &perfInfo)
{
uint64_t nLatency = 0;
for (size_t i=0;i<NUM_RANKS;i++)
{
perfInfo[i] = 0;
for (size_t j=0; j<NUM_BANKS; j++)
{
perfInfo[i] += _vctRtLatencyReport[i + j];
nLatency += perfInfo[i];
//
// mark a time point
//
_vctRtLatencyReport[i + j] = 0;
}
}
return nLatency;
}
////////////////////////////////////////////////////////////////////////////////
//
// Method: GetNumsElapsedIo
// FullName: SCIC::GetNumsElapsedIo
// Access: public
// Returns: uint64_t
// Parameter: vector<uint64_t> & perfInfo
// Parameter: SCIC_STAT_QUERY queryType
//
// Descriptions -
// The information regarding the nums of transaction requests is available for each bank and rank.
// For identifying available performance class that you can measure using this, please check
// SCIC_STAT_QUERY enum values.
// If a user want to go over specific data for each bank, the user should iterate the vector information based on the number of rank * bank.
// Otherwise, the user can query the information, which be elapsed by all banks' data.
// The simple way addressing a rank is # of ranks * NUMS_RANKS + # of bank.
// (The size of the vector should be NUMS_RANKS * NUMS_BANKS)
//
//////////////////////////////////////////////////////////////////////////////
uint64_t SCIC::GetNumsElapsedIo(vector<uint64_t> &perfInfo, SCIC_STAT_QUERY queryType)
{
vector<uint64_t> &vctIoPerBank = (queryType == SCIC_STAT_READ) ? _pLegacyMemorySystem->memoryController->TotalReadsPerBank(): _pLegacyMemorySystem->memoryController->TotalWritesPerBank();
uint64_t nNumsIos = 0;
for (size_t i=0;i<NUM_RANKS;i++)
{
perfInfo[i] = 0;
for (size_t j=0; j<NUM_BANKS; j++)
{
perfInfo[i] += vctIoPerBank[SEQUENTIAL(i,j)];
nNumsIos += perfInfo[i];
}
}
return nNumsIos;
}
////////////////////////////////////////////////////////////////////////////////
//
// Method: GetElapsedPerfromanceInfo
// FullName: SCIC::GetElapsedPerfromanceInfo
// Access: public
// Returns: double
// Parameter: vector<double> & perfInfo
// Parameter: SCIC_PERF_QUERY queryType
//
// Descriptions -
// Perfromance information is available for each bank and rank.
// For identifying available performance class that you can measure using this, please check
// SCIC_PERF_QUERY enum values.
// If a user want to go over specific data for each bank, the user should iterate the vector information based on the number of rank * bank.
// Otherwise, the user can query the information, which be elapsed by all banks' data.
// The simple way addressing a rank is # of ranks * NUMS_RANKS + # of bank.
// (The size of the vector should be NUMS_RANKS * NUMS_BANKS)
//
//////////////////////////////////////////////////////////////////////////////
double SCIC::GetElapsedPerfromanceInfo(vector<double> &perfInfo, SCIC_PERF_QUERY queryType)
{
double secondsThisEpoch = (double)_pLegacyMemorySystem->currentClockCycle * tCK * 1E-9;
uint bytesPerTransaction = (64*BL)/8;
double nTotalPerfInfo = 0;
vector<uint64_t> &vctTotalEpochLatency = _pLegacyMemorySystem->memoryController->TotalEpochLatency();
vector<uint64_t> &vctTotalReadPerBank = _pLegacyMemorySystem->memoryController->TotalReadsPerBank();
vector<uint64_t> &vctTotalWritePerBank = _pLegacyMemorySystem->memoryController->TotalWritesPerBank();
if(queryType == SCIC_PERF_LATENCY)
{
for (size_t i=0;i<NUM_RANKS;i++)
{
for (size_t j=0; j<NUM_BANKS; j++)
{
perfInfo[SEQUENTIAL(i,j)] = ((double)vctTotalEpochLatency[SEQUENTIAL(i,j)] / (double)(vctTotalReadPerBank[SEQUENTIAL(i,j)])) * tCK;
nTotalPerfInfo += perfInfo[SEQUENTIAL(i,j)];
}
}
}
else if (queryType == SCIC_PERF_BANDWIDTH)
{
for (size_t i=0;i<NUM_RANKS;i++)
{
for (size_t j=0; j<NUM_BANKS; j++)
{
perfInfo[SEQUENTIAL(i,j)] = (((double)(vctTotalReadPerBank[SEQUENTIAL(i,j)]+vctTotalWritePerBank[SEQUENTIAL(i,j)]) * (double)bytesPerTransaction)/(1024.0*1024.0*1024.0)) / secondsThisEpoch;
nTotalPerfInfo += perfInfo[SEQUENTIAL(i,j)];
}
}
}
return nTotalPerfInfo;
}
////////////////////////////////////////////////////////////////////////////////
//
// Method: GetElapsedEnergyInfo
// FullName: SCIC::GetElapsedEnergyInfo
// Access: public
// Returns: double
// Parameter: vector<double> & energyInfos
// Parameter: SCIC_ENERGY_QUERY queryType
//
// Descriptions -
// Energy information will be delivered trhough energyInfos vector;
// users can specify enerygy type that they want using SCIC_ENERGY_QUERY enum value.
// (for example, SCIC_ENERGY_BACKGROUND means bacgrkound energy, SCIC_ENERGY_BURST means burst energy and so on.)
// The energy information (Watts) is accumulated for each rank; therefore
// users should be aware the number of rank.
// If a user want to go over specific data for each rank, the user should iterate the vector information based on the number of rank.
// Otherwise, the user can query the information, which be elapsed by all ranks' data.
// (The size of the vector should be NUMS_RANKS)
//
//////////////////////////////////////////////////////////////////////////////
double SCIC::GetElapsedEnergyInfo(vector<double> &energyInfos, SCIC_ENERGY_QUERY queryType)
{
double nTotalEnergyInfo = 0;
uint64_t cyclesElapsed = (_pLegacyMemorySystem->currentClockCycle % EPOCH_LENGTH == 0) ? EPOCH_LENGTH : _pLegacyMemorySystem->currentClockCycle % EPOCH_LENGTH;
if(queryType == SCIC_ENERGY_AVERAGE)
{
for (size_t i=0;i<NUM_RANKS;i++)
{
//
// The average latency will be different compared to original DRAMSim because
// the DRAMSim miscalculate average poewr (there are two redundant burst poewr used)
//
energyInfos[i] = 0;
for (int nTypeIdx = 0; nTypeIdx < SCIC_NUMS_ENERGY_TYPE; ++nTypeIdx)
{
energyInfos[i] += (double)((*(_vctpEnergy[nTypeIdx]))[i]);
}
energyInfos[i] = (energyInfos[i] / (double)(cyclesElapsed)) * Vdd / 1000.0;
nTotalEnergyInfo += energyInfos[i];
}
}
else {
for (size_t i=0;i<NUM_RANKS;i++)
{
energyInfos[i] = ((double)((*(_vctpEnergy[queryType]))[i]) / (double)(cyclesElapsed)) * Vdd / 1000.0;
nTotalEnergyInfo += energyInfos[i];
}
}
return nTotalEnergyInfo;
}
#endif
uint64_t SCIC::GetTotalNumsTransactions()
{
return _pLegacyMemorySystem->memoryController->TotalTransactions();
}
uint SCIC::GetBytePerTransaction()
{
return (64*BL)/8;
}