Skip to content

Commit 13d8224

Browse files
Fixing a lot of commit warnings and errors
1 parent d74d4e3 commit 13d8224

19 files changed

+1027
-6542
lines changed

.cproject

+936-6,479
Large diffs are not rendered by default.

.project

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</dictionary>
3232
<dictionary>
3333
<key>org.eclipse.cdt.make.core.buildLocation</key>
34-
<value>${workspace_loc:/FTL/Page}</value>
34+
<value>${workspace_loc:/FTL/Trace}</value>
3535
</dictionary>
3636
<dictionary>
3737
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>

FTLs/bast_ftl.cpp

+5-9
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,19 @@ FtlImpl_Bast::FtlImpl_Bast(Controller &controller):
7575
{
7676

7777
// Detect required number of bits for logical address size
78-
addressSize = log(SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE)/log(2);
78+
addressSize = log(NUMBER_OF_ADDRESSABLE_BLOCKS)/log(2);
7979
addressShift = log(BLOCK_SIZE)/log(2);
8080

8181
// Find required number of bits for block size
8282
printf("Total required bits for representation: %i (Address: %i Block: %i) \n", addressSize + addressShift, addressSize, addressShift);
8383

8484
// Initialise block mapping table.
85-
uint numBlocks = SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE;
86-
data_list = new long[numBlocks];
85+
data_list = new long[NUMBER_OF_ADDRESSABLE_BLOCKS];
8786

88-
for (uint i=0;i<numBlocks;i++)
87+
for (uint i=0;i<NUMBER_OF_ADDRESSABLE_BLOCKS;i++)
8988
data_list[i] = -1;
9089

91-
printf("Total mapping table size: %luKB\n", numBlocks * sizeof(uint) / 1024);
90+
printf("Total mapping table size: %luKB\n", NUMBER_OF_ADDRESSABLE_BLOCKS * sizeof(uint) / 1024);
9291
printf("Using BAST FTL.\n");
9392
}
9493

@@ -287,7 +286,7 @@ bool FtlImpl_Bast::is_sequential(LogPageBlock* logBlock, long lba, Event &event)
287286

288287
// Is block switch possible? i.e. log block switch
289288
bool isSequential = true;
290-
for (uint i=0;i<BLOCK_SIZE;i++) if (logBlock->pages[i] != i)
289+
for (uint i=0;i<BLOCK_SIZE;i++) if (logBlock->pages[i] != (int)i)
291290
{
292291
isSequential = false;
293292
break;
@@ -329,8 +328,6 @@ bool FtlImpl_Bast::random_merge(LogPageBlock *logBlock, long lba, Event &event)
329328
Address eventAddress = Address(event.get_logical_address(), PAGE);
330329
Address newDataBlock = Block_manager::instance()->get_free_block(DATA, event);
331330

332-
Block *b1 = controller.get_block_pointer(logBlock->address);
333-
334331
int t=0;
335332
for (uint i=0;i<BLOCK_SIZE;i++)
336333
{
@@ -378,7 +375,6 @@ bool FtlImpl_Bast::random_merge(LogPageBlock *logBlock, long lba, Event &event)
378375
if (data_list[lba] != -1)
379376
{
380377
Address a = Address(data_list[lba], PAGE);
381-
Block *b2 = controller.get_block_pointer(a);
382378
Block_manager::instance()->erase_and_invalidate(event, a, DATA);
383379
}
384380

FTLs/bdftl_ftl.cpp

+5-11
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ FtlImpl_BDftl::BPage::BPage()
4949
FtlImpl_BDftl::FtlImpl_BDftl(Controller &controller):
5050
FtlImpl_DftlParent(controller)
5151
{
52-
uint ssdBlockSize = SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE;
53-
block_map = new BPage[ssdBlockSize];
54-
trim_map = new bool[ssdBlockSize*BLOCK_SIZE];
52+
block_map = new BPage[NUMBER_OF_ADDRESSABLE_BLOCKS];
53+
trim_map = new bool[NUMBER_OF_ADDRESSABLE_BLOCKS*BLOCK_SIZE];
5554

5655
inuseBlock = NULL;
5756

@@ -77,7 +76,7 @@ enum status FtlImpl_BDftl::read(Event &event)
7776
{
7877
uint dppn = block_map[dlbn].pbn + (dlpn % BLOCK_SIZE);
7978

80-
if (block_map[dlbn].pbn != -1)
79+
if (block_map[dlbn].pbn != (uint) -1)
8180
event.set_address(Address(dppn, PAGE));
8281
else
8382
{
@@ -349,7 +348,6 @@ void FtlImpl_BDftl::cleanup_block(Event &event, Block *block)
349348
* 2. Invalidate old pages
350349
* 3. mark their corresponding translation pages for update
351350
*/
352-
uint cnt=0;
353351
for (uint i=0;i<BLOCK_SIZE;i++)
354352
{
355353
assert(block->get_state(i) != EMPTY);
@@ -368,9 +366,7 @@ void FtlImpl_BDftl::cleanup_block(Event &event, Block *block)
368366
// Get new address to write to and invalidate previous
369367
Event writeEvent = Event(WRITE, event.get_logical_address(), 1, event.get_start_time()+readEvent.get_time_taken());
370368
Address dataBlockAddress = Address(get_free_data_page(event, false), PAGE);
371-
Block *entryBlock = controller.get_block_pointer(dataBlockAddress);
372369
writeEvent.set_address(dataBlockAddress);
373-
374370
writeEvent.set_replace_address(Address(block->get_physical_address()+i, PAGE));
375371

376372
// Setup the write event to read from the right place.
@@ -438,13 +434,11 @@ bool FtlImpl_BDftl::block_next_new()
438434

439435
void FtlImpl_BDftl::print_ftl_statistics()
440436
{
441-
int size = SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE;
442-
443437
printf("FTL Stats:\n");
444-
printf(" Blocks total: %i\n", size);
438+
printf(" Blocks total: %i\n", NUMBER_OF_ADDRESSABLE_BLOCKS);
445439

446440
int numOptimal = 0;
447-
for (int i=0;i<size;i++)
441+
for (uint i=0;i<NUMBER_OF_ADDRESSABLE_BLOCKS;i++)
448442
{
449443
BPage bp = block_map[i];
450444
if (bp.optimal)

FTLs/dftl_ftl.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ using namespace ssd;
4343
FtlImpl_Dftl::FtlImpl_Dftl(Controller &controller):
4444
FtlImpl_DftlParent(controller)
4545
{
46-
uint ssdSize = SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE * BLOCK_SIZE;
46+
uint ssdSize = NUMBER_OF_ADDRESSABLE_BLOCKS * BLOCK_SIZE;
4747

4848
printf("Total size to map: %uKB\n", ssdSize * PAGE_SIZE / 1024);
4949
printf("Using DFTL.\n");
@@ -153,7 +153,7 @@ void FtlImpl_Dftl::cleanup_block(Event &event, Block *block)
153153
// Get new address to write to and invalidate previous
154154
Event writeEvent = Event(WRITE, event.get_logical_address(), 1, event.get_start_time()+readEvent.get_time_taken());
155155
Address dataBlockAddress = Address(get_free_data_page(event, false), PAGE);
156-
Block *entryBlock = controller.get_block_pointer(dataBlockAddress);
156+
157157
writeEvent.set_address(dataBlockAddress);
158158

159159
writeEvent.set_replace_address(Address(block->get_physical_address()+i, PAGE));

FTLs/dftl_parent.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ FtlImpl_DftlParent::FtlImpl_DftlParent(Controller &controller):
6767
currentTranslationPage = -1;
6868

6969
// Detect required number of bits for logical address size
70-
addressSize = log(SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE * BLOCK_SIZE)/log(2);
70+
addressSize = log(NUMBER_OF_ADDRESSABLE_BLOCKS * BLOCK_SIZE)/log(2);
7171

7272
// Find required number of bits for block size
7373
addressPerPage = (PAGE_SIZE/ceil(addressSize / 8.0)); // 8 bits per byte
@@ -78,7 +78,7 @@ FtlImpl_DftlParent::FtlImpl_DftlParent(Controller &controller):
7878
printf("Number of elements in Cached Mapping Table (CMT): %i\n", totalCMTentries);
7979

8080
// Initialise block mapping table.
81-
uint ssdSize = SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE * BLOCK_SIZE;
81+
uint ssdSize = NUMBER_OF_ADDRESSABLE_BLOCKS * BLOCK_SIZE;
8282

8383
trans_map.reserve(ssdSize);
8484
for (uint i=0;i<ssdSize;i++)

FTLs/fast_ftl.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,16 @@ using namespace ssd;
3434
FtlImpl_Fast::FtlImpl_Fast(Controller &controller):
3535
FtlParent(controller)
3636
{
37-
addressSize = log(SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE)/log(2);
37+
addressSize = log(NUMBER_OF_ADDRESSABLE_BLOCKS)/log(2);
3838
addressShift = log(BLOCK_SIZE)/log(2);
3939

4040
printf("Total required bits for representation: %i (Address: %i Block: %i) \n", addressSize + addressShift, addressSize, addressShift);
4141

4242
// Initialise block mapping table.
43-
uint numBlocks = SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE;
44-
data_list = new long[numBlocks];
45-
std::fill_n(data_list, numBlocks, -1);
43+
data_list = new long[NUMBER_OF_ADDRESSABLE_BLOCKS];
44+
std::fill_n(data_list, NUMBER_OF_ADDRESSABLE_BLOCKS, -1);
4645

47-
pin_list = new bool[numBlocks*BLOCK_SIZE];
46+
pin_list = new bool[NUMBER_OF_ADDRESSABLE_BLOCKS*BLOCK_SIZE];
4847

4948
// SW
5049
sequential_offset = 0;
@@ -54,7 +53,7 @@ FtlImpl_Fast::FtlImpl_Fast(Controller &controller):
5453

5554
log_pages = NULL;
5655

57-
printf("Total mapping table size: %luKB\n", numBlocks * sizeof(uint) / 1024);
56+
printf("Total mapping table size: %luKB\n", NUMBER_OF_ADDRESSABLE_BLOCKS * sizeof(uint) / 1024);
5857
printf("Using FAST FTL.\n");
5958
}
6059

@@ -102,7 +101,7 @@ enum status FtlImpl_Fast::read(Event &event)
102101
{
103102
//event.incr_time_taken(RAM_READ_DELAY);
104103

105-
if (currentBlock->aPages[i] == event.get_logical_address())
104+
if (currentBlock->aPages[i] == (long)event.get_logical_address())
106105
{
107106
Address readAddress = Address(currentBlock->address.get_linear_address() + i, PAGE);
108107
event.set_address(readAddress);
@@ -201,7 +200,7 @@ enum status FtlImpl_Fast::trim(Event &event)
201200
{
202201
for (int i=0;i<currentBlock->numPages;i++)
203202
{
204-
if (currentBlock->aPages[i] == event.get_logical_address())
203+
if (currentBlock->aPages[i] == (long)event.get_logical_address())
205204
{
206205
Address address = Address(currentBlock->address.get_linear_address() + i, PAGE);
207206
Block *block = controller.get_block_pointer(address);

FTLs/page_ftl.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ using namespace ssd;
3030
FtlImpl_Page::FtlImpl_Page(Controller &controller):
3131
FtlParent(controller)
3232
{
33-
trim_map = new bool[SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE * BLOCK_SIZE];
33+
trim_map = new bool[NUMBER_OF_ADDRESSABLE_BLOCKS * BLOCK_SIZE];
3434

3535
numPagesActive = 0;
3636

@@ -50,7 +50,7 @@ enum status FtlImpl_Page::read(Event &event)
5050

5151
controller.stats.numFTLRead++;
5252

53-
return controller.issue(event);;
53+
return controller.issue(event);
5454
}
5555

5656
enum status FtlImpl_Page::write(Event &event)
@@ -60,7 +60,7 @@ enum status FtlImpl_Page::write(Event &event)
6060

6161
controller.stats.numFTLWrite++;
6262

63-
if (numPagesActive == SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE * BLOCK_SIZE)
63+
if (numPagesActive == NUMBER_OF_ADDRESSABLE_BLOCKS * BLOCK_SIZE)
6464
{
6565
numPagesActive -= BLOCK_SIZE;
6666

run_ufliptrace.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ int main(int argc, char **argv){
104104

105105
long writeEvent = 0;
106106
long readEvent = 0;
107-
for (int i=0; i<files.size();i++)
107+
for (unsigned int i=0; i<files.size();i++)
108108
{
109109
char *filename = NULL;
110110
asprintf(&filename, "%s%s", argv[1], files[i].c_str());
@@ -192,9 +192,7 @@ int main(int argc, char **argv){
192192
unsigned long num_reads = 0;
193193
unsigned long num_writes = 0;
194194

195-
long cnt=0;
196-
197-
for (int i=0; i<files.size();i++)
195+
for (unsigned int i=0; i<files.size();i++)
198196
{
199197
char *filename = NULL;
200198
asprintf(&filename, "%s%s", argv[1], files[i].c_str());

ssd.conf

+8-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ MAP_DIRECTORY_SIZE 100
8383

8484
# FTL Implementation to use 0 = Page, 1 = BAST,
8585
# 2 = FAST, 3 = DFTL, 4 = Bimodal
86-
FTL_IMPLEMENTATION 2
86+
FTL_IMPLEMENTATION 4
8787

8888
# LOG Page limit for BAST
8989
BAST_LOG_PAGE_LIMIT 1024
@@ -96,3 +96,10 @@ CACHE_DFTL_LIMIT 512
9696

9797
# 0 -> Normal behavior, 1 -> Striping, 2 -> Logical address space parallelism
9898
PARALLELISM_MODE 0
99+
100+
# Written in round robin: Virtual block size (as a multiple of the physical block size)
101+
VIRTUAL_BLOCK_SIZE = 1
102+
103+
# Striping: Virtual page size (as a multiple of the physical page size)
104+
VIRTUAL_PAGE_SIZE = 1
105+

ssd.h

+14-4
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,15 @@ extern const uint CACHE_DFTL_LIMIT;
146146
/*
147147
* Parallelism mode
148148
*/
149-
extern const uint PARALLELISM_MODE = 0;
149+
extern const uint PARALLELISM_MODE;
150150

151+
/* Virtual block size (as a multiple of the physical block size) */
152+
extern const uint VIRTUAL_BLOCK_SIZE;
153+
154+
/* Virtual page size (as a multiple of the physical page size) */
155+
extern const uint VIRTUAL_PAGE_SIZE;
156+
157+
const uint NUMBER_OF_ADDRESSABLE_BLOCKS = SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE / VIRTUAL_PAGE_SIZE;
151158
/*
152159
* Memory area to support pages with data.
153160
*/
@@ -386,7 +393,7 @@ class Event
386393
double time_taken;
387394
double bus_wait_time;
388395
enum event_type type;
389-
bool noop;
396+
390397
ulong logical_address;
391398
Address address;
392399
Address merge_address;
@@ -395,6 +402,7 @@ class Event
395402
uint size;
396403
void *payload;
397404
Event *next;
405+
bool noop;
398406
};
399407

400408
/* Single bus channel
@@ -484,6 +492,8 @@ class Page
484492
class Block
485493
{
486494
public:
495+
long physical_address;
496+
uint pages_invalid;
487497
Block(const Plane &parent, uint size = BLOCK_SIZE, ulong erases_remaining = BLOCK_ERASES, double erase_delay = BLOCK_ERASE_DELAY, long physical_address = 0);
488498
~Block(void);
489499
enum status read(Event &event);
@@ -506,8 +516,7 @@ class Block
506516
Block *get_pointer(void);
507517
block_type get_block_type(void) const;
508518
void set_block_type(block_type value);
509-
long physical_address;
510-
uint pages_invalid;
519+
511520
private:
512521
uint size;
513522
Page * const data;
@@ -992,6 +1001,7 @@ class Controller
9921001
const FtlParent &get_ftl(void) const;
9931002
private:
9941003
enum status issue(Event &event_list);
1004+
void translate_address(Address &address);
9951005
ssd::ulong get_erases_remaining(const Address &address) const;
9961006
void get_least_worn(Address &address) const;
9971007
double get_last_erase_time(const Address &address) const;

ssd_block.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,29 @@
3131
using namespace ssd;
3232

3333
Block::Block(const Plane &parent, uint block_size, ulong erases_remaining, double erase_delay, long physical_address):
34+
pages_invalid(0),
35+
physical_address(physical_address),
3436
size(block_size),
3537

3638
/* use a const pointer (Page * const data) to use as an array
3739
* but like a reference, we cannot reseat the pointer */
3840
data((Page *) malloc(block_size * sizeof(Page))),
3941
parent(parent),
4042
pages_valid(0),
41-
pages_invalid(0),
43+
4244
state(FREE),
43-
modification_time(-1),
45+
4446
/* set erases remaining to BLOCK_ERASES to match Block constructor args
4547
* in Plane class
4648
* this is the cheap implementation but can change to pass through classes */
47-
/* erases_remaining(BLOCK_ERASES), */
4849
erases_remaining(erases_remaining),
4950

5051
/* assume hardware created at time 0 and had an implied free erasure */
5152
last_erase_time(0.0),
5253
erase_delay(erase_delay),
53-
physical_address(physical_address)
54+
55+
modification_time(-1)
56+
5457
{
5558
uint i;
5659

0 commit comments

Comments
 (0)