Skip to content

Commit 5a5b31d

Browse files
Merge branch 'master' into parallelism
Conflicts: run_correctness.cpp Adding RAID support with striping and Round robin.
2 parents dd71688 + a304a97 commit 5a5b31d

13 files changed

+379
-944
lines changed

.cproject

+121-905
Large diffs are not rendered by default.

.project

+2-2
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/Trace}</value>
34+
<value>${workspace_loc:/FTL/RAID}</value>
3535
</dictionary>
3636
<dictionary>
3737
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
@@ -59,7 +59,7 @@
5959
</dictionary>
6060
<dictionary>
6161
<key>org.eclipse.cdt.make.core.stopOnError</key>
62-
<value>true</value>
62+
<value>false</value>
6363
</dictionary>
6464
<dictionary>
6565
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>

FTLs/dftl_ftl.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ FtlImpl_Dftl::FtlImpl_Dftl(Controller &controller):
4444
FtlImpl_DftlParent(controller)
4545
{
4646
uint ssdSize = NUMBER_OF_ADDRESSABLE_BLOCKS * BLOCK_SIZE;
47-
4847
printf("Total size to map: %uKB\n", ssdSize * PAGE_SIZE / 1024);
4948
printf("Using DFTL.\n");
5049
return;

FTLs/dftl_parent.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ FtlImpl_DftlParent::FtlImpl_DftlParent(Controller &controller):
6262
FtlParent(controller)
6363
{
6464
addressPerPage = 0;
65-
65+
cmt = 0;
6666
currentDataPage = -1;
6767
currentTranslationPage = -1;
6868

run_correctness.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ using namespace ssd;
1515

1616
#define GARBAGEPATH "/home/silverwolf/garbage"
1717

18+
double timings = 0.0;
19+
1820
double do_seq(Ssd *ssd, event_type type, void *test, unsigned int file_size)
1921
{
2022
unsigned int adr, i = 0;
2123
double result = 0;
2224
for (adr = 0; adr < file_size;adr += PAGE_SIZE)
2325
{
24-
double iotime = ssd->event_arrive(type, i, 1, (double) adr, (char*)test + adr);
26+
double iotime = ssd->event_arrive(type, i, 1, timings, (char*)test + adr);
2527
//printf("IO Execution time: %f\n", iotime);
2628
result += iotime;
29+
timings += iotime;
2730
if (type == READ)
2831
{
2932
if (ssd->get_result_buffer() == NULL)
@@ -43,11 +46,14 @@ double do_seq_backward(Ssd *ssd, event_type type, void *test, unsigned int file_
4346
double result = 0;
4447
for (adr = file_size; adr > 0;adr -= PAGE_SIZE)
4548
{
46-
result += ssd->event_arrive(type, j+i, 1, file_size-(double) adr, (char*)test + adr - PAGE_SIZE);
49+
double iotime = ssd->event_arrive(type, j+i, 1, timings, (char*)test + adr - PAGE_SIZE);
4750

4851
if (type == READ && memcmp(ssd->get_result_buffer(), (char*)test + adr - PAGE_SIZE, PAGE_SIZE) != 0)
4952
fprintf(stderr, "Err. Data does not compare. i: %i\n", j+i);
5053

54+
result += iotime;
55+
timings += iotime;
56+
5157
i--;
5258

5359
if (i == -1u)
@@ -56,7 +62,6 @@ double do_seq_backward(Ssd *ssd, event_type type, void *test, unsigned int file_
5662
j += BLOCK_SIZE;
5763
}
5864
}
59-
6065
return result;
6166
}
6267

@@ -116,10 +121,12 @@ int main()
116121

117122
printf("Test 1. Write sequential test data.\n");
118123
result += do_seq(ssd, WRITE, test_data, st.st_size);
124+
//
125+
// printf("Test 1. Trim data.\n");
126+
// result += do_seq(ssd, TRIM, test_data, st.st_size);
119127

120-
printf("Test 1. Trim data.\n");
121-
result += do_seq(ssd, TRIM, test_data, st.st_size);
122-
128+
printf("Test 1. Write sequential test data.\n");
129+
result += do_seq(ssd, WRITE, test_data, st.st_size);
123130

124131
printf("Test 2. Read sequential test data.\n");
125132
result += do_seq(ssd, READ, test_data, st.st_size);

run_raid.cpp

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* Copyright 2012 Matias Bjørling */
2+
3+
/* FlashSim is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* any later version. */
7+
8+
/* FlashSim is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details. */
12+
13+
/* You should have received a copy of the GNU General Public License
14+
* along with FlashSim. If not, see <http://www.gnu.org/licenses/>. */
15+
16+
/****************************************************************************/
17+
18+
#include "ssd.h"
19+
20+
#define SIZE 10
21+
22+
using namespace ssd;
23+
24+
int main()
25+
{
26+
load_config();
27+
print_config(NULL);
28+
29+
RaidSsd *ssd = new RaidSsd();
30+
31+
double result;
32+
double cur_time = 1;
33+
34+
for (int i = 0; i < SIZE; i++)
35+
{
36+
result = ssd -> event_arrive(WRITE, i*2, 1, 0);
37+
cur_time += result;
38+
}
39+
for (int i = 0; i < SIZE; i++)
40+
{
41+
result = ssd -> event_arrive(READ, i*2, 1, 0);
42+
cur_time += result;
43+
}
44+
45+
printf("Total execution time %f\n", cur_time);
46+
47+
delete ssd;
48+
return 0;
49+
}

ssd.conf

+12-9
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ BUS_TABLE_SIZE 512
3838

3939
# Ssd class:
4040
# number of Packages per Ssd (size)
41-
SSD_SIZE 4
41+
SSD_SIZE 1
4242

4343
# Package class:
4444
# number of Dies per Package (size)
45-
PACKAGE_SIZE 2
45+
PACKAGE_SIZE 1
4646

4747
# Die class:
4848
# number of Planes per Die (size)
49-
DIE_SIZE 2
49+
DIE_SIZE 1
5050

5151
# Plane class:
5252
# number of Blocks per Plane (size)
5353
# delay for reading from plane register
5454
# delay for writing to plane register
5555
# delay for merging is based on read, write, reg_read, reg_write
5656
# and does not need to be explicitly defined
57-
PLANE_SIZE 2048
57+
PLANE_SIZE 256
5858
PLANE_REG_READ_DELAY 0.01
5959
PLANE_REG_WRITE_DELAY 0.01
6060

@@ -74,7 +74,7 @@ BLOCK_ERASE_DELAY 2000
7474
# Size of pages (in bytes)
7575
PAGE_READ_DELAY 25
7676
PAGE_WRITE_DELAY 300
77-
PAGE_ENABLE_DATA 2048
77+
PAGE_ENABLE_DATA 1
7878

7979
# MAPPING
8080
# Specify reservation of
@@ -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 4
86+
FTL_IMPLEMENTATION 3
8787

8888
# LOG Page limit for BAST
8989
BAST_LOG_PAGE_LIMIT 1024
@@ -95,11 +95,14 @@ FAST_LOG_PAGE_LIMIT 1024
9595
CACHE_DFTL_LIMIT 512
9696

9797
# 0 -> Normal behavior, 1 -> Striping, 2 -> Logical address space parallelism
98-
PARALLELISM_MODE 0
98+
PARALLELISM_MODE 2
9999

100100
# Written in round robin: Virtual block size (as a multiple of the physical block size)
101-
VIRTUAL_BLOCK_SIZE = 1
101+
VIRTUAL_BLOCK_SIZE 1
102102

103103
# Striping: Virtual page size (as a multiple of the physical page size)
104-
VIRTUAL_PAGE_SIZE = 1
104+
VIRTUAL_PAGE_SIZE 1
105+
106+
# RAISSDs: Number of physical SSDs
107+
RAID_NUMBER_OF_PHYSICAL_SSDS 2
105108

ssd.h

+27-5
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ extern const uint VIRTUAL_BLOCK_SIZE;
154154
/* Virtual page size (as a multiple of the physical page size) */
155155
extern const uint VIRTUAL_PAGE_SIZE;
156156

157-
const uint NUMBER_OF_ADDRESSABLE_BLOCKS = SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE / VIRTUAL_PAGE_SIZE;
157+
extern const uint NUMBER_OF_ADDRESSABLE_BLOCKS;
158+
159+
/* RAISSDs: Number of physical SSDs */
160+
extern const uint RAID_NUMBER_OF_PHYSICAL_SSDS;
161+
158162
/*
159163
* Memory area to support pages with data.
160164
*/
@@ -726,10 +730,6 @@ class Block_manager
726730
std::vector<Block*> free_list;
727731
std::vector<Block*> invalid_list;
728732

729-
// Until all pages have been requested, we serve them from a linear
730-
// address space.
731-
ulong simpleCurrentFree;
732-
733733
// Counter for returning the next free page.
734734
ulong directoryCurrentPage;
735735
// Address on the current cached page in SRAM.
@@ -1066,6 +1066,28 @@ class Ssd
10661066
double last_erase_time;
10671067
};
10681068

1069+
class RaidSsd
1070+
{
1071+
public:
1072+
RaidSsd (uint ssd_size = SSD_SIZE);
1073+
~RaidSsd(void);
1074+
double event_arrive(enum event_type type, ulong logical_address, uint size, double start_time);
1075+
double event_arrive(enum event_type type, ulong logical_address, uint size, double start_time, void *buffer);
1076+
void *get_result_buffer();
1077+
friend class Controller;
1078+
void print_statistics();
1079+
void reset_statistics();
1080+
void write_statistics(FILE *stream);
1081+
void write_header(FILE *stream);
1082+
const Controller &get_controller(void) const;
1083+
1084+
void print_ftl_statistics();
1085+
private:
1086+
uint size;
1087+
1088+
Ssd *Ssds;
1089+
1090+
};
10691091
} /* end namespace ssd */
10701092

10711093
#endif

ssd_bm.cpp

+17-13
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Block_manager::Block_manager(FtlParent *ftl) : ftl(ftl)
3636
max_map_pages = MAP_DIRECTORY_SIZE * BLOCK_SIZE;
3737

3838
directoryCurrentPage = 0;
39-
simpleCurrentFree = 0;
4039
num_insert_events = 0;
4140

4241
data_active = 0;
@@ -76,13 +75,15 @@ Block_manager *Block_manager::instance()
7675
*/
7776
void Block_manager::get_page_block(Address &address, Event &event)
7877
{
79-
if (simpleCurrentFree < max_blocks*BLOCK_SIZE)
80-
{
81-
address.set_linear_address(simpleCurrentFree, BLOCK);
82-
current_writing_block = simpleCurrentFree;
83-
simpleCurrentFree += BLOCK_SIZE;
84-
}
85-
else
78+
// We need separate queues for each plane? communication channel? communication channel is at the per die level at the moment. i.e. each LUN is a die.
79+
//
80+
// if (simpleCurrentFree < max_blocks*BLOCK_SIZE)
81+
// {
82+
// address.set_linear_address(simpleCurrentFree, BLOCK);
83+
// current_writing_block = simpleCurrentFree;
84+
// simpleCurrentFree += BLOCK_SIZE;
85+
// }
86+
// else
8687
{
8788
if (free_list.size() <= 1 && !out_of_blocks)
8889
{
@@ -137,7 +138,7 @@ void Block_manager::print_statistics()
137138
printf("-----------------\n");
138139
printf("Log blocks: %lu\n", log_active);
139140
printf("Data blocks: %lu\n", data_active);
140-
printf("Free blocks: %lu\n", (max_blocks - (simpleCurrentFree/BLOCK_SIZE)) + free_list.size());
141+
// printf("Free blocks: %lu\n", (max_blocks - (simpleCurrentFree/BLOCK_SIZE)) + free_list.size());
141142
printf("Invalid blocks: %lu\n", invalid_list.size());
142143
printf("Free2 blocks: %lu\n", (unsigned long int)invalid_list.size() + (unsigned long int)log_active + (unsigned long int)data_active - (unsigned long int)free_list.size());
143144
printf("-----------------\n");
@@ -202,6 +203,8 @@ void Block_manager::insert_events(Event &event)
202203

203204
ActiveByCost::iterator it = active_cost.get<1>().end();
204205
--it;
206+
207+
205208
while (num_to_erase != 0 && (*it)->get_pages_invalid() > 0 && (*it)->get_pages_valid() == BLOCK_SIZE)
206209
{
207210
if (current_writing_block != (*it)->physical_address)
@@ -311,10 +314,11 @@ void Block_manager::erase_and_invalidate(Event &event, Address &address, block_t
311314

312315
int Block_manager::get_num_free_blocks()
313316
{
314-
if (simpleCurrentFree < max_blocks*BLOCK_SIZE)
315-
return (simpleCurrentFree / BLOCK_SIZE) + free_list.size();
316-
else
317-
return free_list.size();
317+
318+
// if (simpleCurrentFree < max_blocks*BLOCK_SIZE)
319+
// return (simpleCurrentFree / BLOCK_SIZE) + free_list.size();
320+
// else
321+
// return free_list.size();
318322
}
319323

320324
void Block_manager::update_block(Block * b)

ssd_config.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ uint VIRTUAL_BLOCK_SIZE = 1;
167167
/* Virtual page size (as a multiple of the physical page size) */
168168
uint VIRTUAL_PAGE_SIZE = 1;
169169

170+
uint NUMBER_OF_ADDRESSABLE_BLOCKS = 0;
171+
172+
/* RAISSDs: Number of physical SSDs */
173+
uint RAID_NUMBER_OF_PHYSICAL_SSDS = 0;
174+
170175
void load_entry(char *name, double value, uint line_number) {
171176
/* cheap implementation - go through all possibilities and match entry */
172177
if (!strcmp(name, "RAM_READ_DELAY"))
@@ -225,6 +230,8 @@ void load_entry(char *name, double value, uint line_number) {
225230
VIRTUAL_BLOCK_SIZE = value;
226231
else if (!strcmp(name, "VIRTUAL_PAGE_SIZE"))
227232
VIRTUAL_PAGE_SIZE = value;
233+
else if (!strcmp(name, "RAID_NUMBER_OF_PHYSICAL_SSDS"))
234+
RAID_NUMBER_OF_PHYSICAL_SSDS = value;
228235
else
229236
fprintf(stderr, "Config file parsing error on line %u\n", line_number);
230237
return;
@@ -263,6 +270,9 @@ void load_config(void) {
263270
line_number);
264271
}
265272
fclose(config_file);
273+
274+
NUMBER_OF_ADDRESSABLE_BLOCKS = (SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE) / VIRTUAL_PAGE_SIZE;
275+
266276
return;
267277
}
268278

@@ -291,6 +301,8 @@ void print_config(FILE *stream) {
291301
fprintf(stream, "MAP_DIRECTORY_SIZE: %i\n", MAP_DIRECTORY_SIZE);
292302
fprintf(stream, "FTL_IMPLEMENTATION: %i\n", FTL_IMPLEMENTATION);
293303
fprintf(stream, "PARALLELISM_MODE: %i\n", PARALLELISM_MODE);
304+
fprintf(stream, "RAID_NUMBER_OF_PHYSICAL_SSDS: %i\n", RAID_NUMBER_OF_PHYSICAL_SSDS);
305+
294306
return;
295307
}
296308

ssd_ftlparent.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Block_manager *Block_manager::inst = NULL;
3131
FtlParent::FtlParent(Controller &controller) : controller(controller)
3232
{
3333
Block_manager::instance_initialize(this);
34+
35+
printf("Number of addressable blocks: %u\n", NUMBER_OF_ADDRESSABLE_BLOCKS);
36+
3437
}
3538

3639

0 commit comments

Comments
 (0)