int main(int argc, char **argv){ long vaddr; double arrive_time; load_config(); print_config(NULL); Ssd ssd; printf("INITIALIZING SSD Bimodal\n"); srandom(1); int preIO = SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE * BLOCK_SIZE; if (FTL_IMPLEMENTATION == 0) // PAGE preIO -= 16*BLOCK_SIZE; if (FTL_IMPLEMENTATION == 1) // BAST preIO -= (BAST_LOG_PAGE_LIMIT*BLOCK_SIZE)*2; if (FTL_IMPLEMENTATION == 2) // FAST preIO -= (FAST_LOG_PAGE_LIMIT*BLOCK_SIZE)*1.1; if (FTL_IMPLEMENTATION > 2) // DFTL BIFTL preIO -= 512; int deviceSize = 3145216; if (preIO > deviceSize) preIO = deviceSize; printf("Writes %i pages for startup out of %i total pages.\n", preIO, SSD_SIZE * PACKAGE_SIZE * DIE_SIZE * PLANE_SIZE * BLOCK_SIZE); double start_time = 0; double timeMultiplier = 10000; double read_time = 0; double write_time = 0; double trim_time = 0; unsigned long num_reads = 0; unsigned long num_writes = 0; unsigned long num_trims = 0; std::vector<double> avgsTrim; std::vector<double> avgsWrite1; std::vector<double> avgsRead1; std::vector<double> avgsRead2; std::vector<double> avgsRead3; std::vector<double> avgsTrim2; std::vector<double> avgsWrite2; std::vector<double> avgsRead4; std::vector<double> avgsWrite3; avgsTrim.reserve(1024*64); avgsWrite1.reserve(1024*64); avgsRead1.reserve(1024*64); avgsRead2.reserve(1024*64); avgsRead3.reserve(1024*64); avgsTrim2.reserve(1024*64); avgsWrite2.reserve(1024*64); avgsRead4.reserve(1024*64); avgsWrite3.reserve(1024*64); // Reset statistics ssd.reset_statistics(); // 1. Write random to the size of the device srand(1); double afterFormatStartTime = 0; //for (int i=0; i<preIO/3*2;i++) for (int i=0; i<preIO*1.1;i++) //for (int i=0; i<700000;i++) { long int r = random()%preIO; double d = ssd.event_arrive(WRITE, r, 1, afterFormatStartTime); afterFormatStartTime += d; if (i % 10000 == 0) printf("Wrote %i %f\n", i,d ); } start_time = afterFormatStartTime; // Reset statistics ssd.reset_statistics(); // 2. Trim an area. ( We let in be 512MB (offset 131072 pages or 2048 blocks) into the address space, and then 256MB (1024 blocks or 65536 pages) ) int startTrim = 2048*64; //131072 int endTrim = 3072*64; //196608 /* Test 1 */ for (int i=startTrim; i<endTrim;i++) { trim_time = ssd.event_arrive(TRIM, i, 1, ((start_time+arrive_time)*timeMultiplier)); avgsTrim.push_back(trim_time); num_trims++; arrive_time += trim_time; if (i % 1000 == 0) printf("Trim: %i %f\n", i, trim_time); } for (int i=startTrim; i<endTrim;i++) { trim_time = ssd.event_arrive(READ, i, 1, ((start_time+arrive_time)*timeMultiplier)); avgsRead1.push_back(trim_time); num_trims++; arrive_time += trim_time; if (i % 1000 == 0) printf("Read: %i %f\n", i, trim_time); } for (int i=startTrim; i<endTrim;i++) { trim_time = ssd.event_arrive(READ, i, 1, ((start_time+arrive_time)*timeMultiplier)); avgsRead2.push_back(trim_time); num_trims++; arrive_time += trim_time; if (i % 1000 == 0) printf("Read: %i %f\n", i, trim_time); } for (int i=startTrim; i<endTrim;i++) { trim_time = ssd.event_arrive(WRITE, i, 1, ((start_time+arrive_time)*timeMultiplier)); avgsWrite1.push_back(trim_time); num_trims++; arrive_time += trim_time; if (i % 1000 == 0) printf("Write: %i %f\n", i, trim_time); } for (int i=startTrim; i<endTrim;i++) { trim_time = ssd.event_arrive(READ, i, 1, ((start_time+arrive_time)*timeMultiplier)); avgsRead3.push_back(trim_time); num_trims++; arrive_time += trim_time; if (i % 1000 == 0) printf("Read: %i %f\n", i, trim_time); } /* Test 1 */ for (int i=startTrim; i<endTrim;i++) { trim_time = ssd.event_arrive(TRIM, i, 1, ((start_time+arrive_time)*timeMultiplier)); avgsTrim2.push_back(trim_time); num_trims++; arrive_time += trim_time; if (trim_time > 400) printf("Trim: %i %f\n", i, trim_time); } for (int i=startTrim; i<endTrim;i++) { trim_time = ssd.event_arrive(WRITE, i, 1, ((start_time+arrive_time)*timeMultiplier)); avgsWrite2.push_back(trim_time); num_trims++; arrive_time += trim_time; if (i % 1000 == 0) printf("Write: %i %f\n", i, trim_time); } for (int i=startTrim; i<endTrim;i++) { trim_time = ssd.event_arrive(READ, i, 1, ((start_time+arrive_time)*timeMultiplier)); avgsRead4.push_back(trim_time); num_trims++; arrive_time += trim_time; if (i % 1000 == 0) printf("Read: %i %f\n", i, trim_time); } // // 1. Write random to the size of the device // for (int i=0; i<700000;i++) // { // long int r = (random()%preIO-200000)+200000; // double d = ssd.event_arrive(WRITE, r, 1, afterFormatStartTime); // afterFormatStartTime += d; // // if (i % 10000 == 0) // printf("Wrote %i %f\n", i,d ); // } // // for (int i=startTrim; i<endTrim;i++) // { // // trim_time = ssd.event_arrive(WRITE, i, 1, ((start_time+arrive_time)*timeMultiplier)); // avgsWrite3.push_back(trim_time); // num_trims++; // // arrive_time += trim_time; // // if (i % 1000 == 0) // printf("Write: %i %f\n", i, trim_time); // // } ssd.print_ftl_statistics(); FILE *logFile = NULL; if ((logFile = fopen("output.log", "w")) == NULL) { printf("Output file cannot be written to.\n"); exit(-1); } fprintf(logFile, "Trim;Read1;Read2;Write1;Read3;Trim2;Write2;Read4;Write3\n"); for (size_t i=0;i<avgsTrim.size();i++) { fprintf(logFile, "%f;%f;%f;%f;%f;%f;%f;%f\n", avgsTrim[i],avgsRead1[i], avgsRead2[i], avgsWrite1[i], avgsRead3[i], avgsTrim2[i], avgsWrite2[i], avgsRead4[i]); } fclose(logFile); ssd.print_ftl_statistics(); ssd.print_statistics(); printf("Finished.\n"); return 0; }
int main(int argc, char** argv) { load_config(); print_config(NULL); printf("\n"); Ssd *ssd = new Ssd(); // create memory mapping of file that we are going to check with int fd; if (argc == 1) fd = open_temp_file(); else fd = open(argv[1], O_RDONLY); struct stat st; fstat(fd, &st); void *test_data = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (test_data == MAP_FAILED) fprintf(stderr, "File not mapped."); printf("Size of testfile: %iKB\n", (int)st.st_size/1024); /* * Experiment setup * 1. Do linear write and read. * 2. Write linear again and read. * 2. Do semi-random linear * 3. Do random * 4. Do backward linear */ double result = 0; printf("Test 1. Write sequential test data.\n"); result += do_seq(ssd, WRITE, test_data, st.st_size); printf("Test 1. Write sequential test data.\n"); result += do_seq(ssd, WRITE, test_data, st.st_size); printf("Test 1. Write sequential test data.\n"); result += do_seq(ssd, WRITE, test_data, st.st_size); // // printf("Test 1. Trim data.\n"); // result += do_seq(ssd, TRIM, test_data, st.st_size); printf("Test 1. Write sequential test data.\n"); result += do_seq(ssd, WRITE, test_data, st.st_size); printf("Test 2. Read sequential test data.\n"); result += do_seq(ssd, READ, test_data, st.st_size); // printf("Test 6. Write backward sequential test data.\n"); // result += do_seq_backward(ssd, WRITE, test_data, st.st_size); // // printf("Test 9. Read backward sequential test data.\n"); // result += do_seq_backward(ssd, READ, test_data, st.st_size); // printf("Test 3. Write second write.\n"); // result += do_seq(ssd, WRITE, test_data, st.st_size); // // printf("Test 4. Write third write.\n"); // result += do_seq_backward(ssd, WRITE, test_data, st.st_size); // // printf("Test 5. Read sequential test data.\n"); // result += do_seq_backward(ssd, READ, test_data, st.st_size); // // printf("Test 6. Write backward sequential test data.\n"); // result += do_seq_backward(ssd, WRITE, test_data, st.st_size); // // printf("Test 7. Read backward sequential test data.\n"); // result += do_seq_backward(ssd, READ, test_data, st.st_size); // // printf("Test 8. Write backward sequential test data again.\n"); // result += do_seq_backward(ssd, WRITE, test_data, st.st_size); // // printf("Test 9. Read backward sequential test data.\n"); // result += do_seq_backward(ssd, READ, test_data, st.st_size); printf("Write time: %.10lfs\n", result); ssd->print_statistics(); delete ssd; return 0; }