std::multimap< Leaf::Leaf_identifier::label, Leaf::Leaf_identifier::feature_vector > load_data(const Fs::path& dir) { std::multimap< Leaf::Leaf_identifier::label, Leaf::Leaf_identifier::feature_vector > rs; std::map<std::string, Leaf::Leaf_identifier::label> name2id; assert(Fs::is_directory(dir)); int id = 1; for (auto iter = Fs::directory_iterator(dir); iter != Fs::directory_iterator(); ++iter) { auto& path = iter->path(); if (path.extension() == ".txt") { auto label = 0; label = id++; name2id[path.stem().string()] = label; auto v = read_vectors(path); for (auto& f: v) { rs.insert({label, f}); } } } std::ofstream ofs("name-map.map"); assert(ofs); boost::archive::text_oarchive out(ofs); out << name2id; return rs; }
int main (int argc, char* const argv[]) { int i,j; char c; nodummy = 0; program_name = argv[0]; double u1, u2, total = 0; struct timeval tv; /* Get the input arguments */ option_set(argc,argv); /* Handle the input files */ handle_files (circuit_name,vectors_name); gettimeofday(&tv,NULL); u1 = tv.tv_sec*1.0e6 + tv.tv_usec; /* Read the circuit file and make the structures */ if (read_circuit (circuit_fd) < 0) system_error ("read_circuit"); fclose (circuit_fd); if (nog<=0 || nopi<=0 || nopo<=0) { fprintf(stderr,"Error in circuit file: #PI=%d, #PO=%d, #GATES=%d\n",nopi,nopo,nog); abort(); } /* Add a gate for the output stage as you did for the input stage */ nodummy = add_PO(); /* Compute the levels of the circuit */ allocate_stacks(); maxlevel = compute_level(); place_PO(); printf("the max level = %d\n",maxlevel); /* Computes the level of each gate */ allocate_event_list(); levelize(); //xfree(event_list); gettimeofday(&tv,NULL); u2 = tv.tv_sec*1.0e6 + tv.tv_usec; total=(u2-u1); printf("Time for construction of data structures: %f usec\n", total); total= 0; printf("opening vectors file= %s\n",vectors_name); vectors_fd = fopen (vectors_name, "r"); if (vectors_fd == NULL) system_error ("fopen"); gettimeofday(&tv,NULL); u1 = tv.tv_sec*1.0e6 + tv.tv_usec; /* Read the vector file and put the input values to the INPUT GATES */ if (read_vectors (vectors_fd,vectors_name) != 0) system_error ("read_vectors"); //fclose (vectors_fd); //valgrind mistake //logic simulation here LUT = create_lut (LUT); logic_sim(); i=0; j=0; if(test_name[0]=='\0') { while((c=circuit_name[i++])!='\0') { if(c=='/') j=0; else if(c=='.') break; else test_name[j++]=c; } test_name[j]='\0'; strcat(test_name,".test"); } gettimeofday(&tv,NULL); u2 = tv.tv_sec*1.0e6 + tv.tv_usec; total=(u2-u1); printf("Time for logic simulation: %f usec\n", total); total= 0; //print_logic_sim(); //<---------------------------------------------------------------- //fault simulation here gettimeofday(&tv,NULL); u1 = tv.tv_sec*1.0e6 + tv.tv_usec; create_fault_list (); //print_fault_list(); fault_sim(); gettimeofday(&tv,NULL); u2 = tv.tv_sec*1.0e6 + tv.tv_usec; total=(u2-u1); printf("Time for fault simulation: %f usec\n", total); total= 0; /*if ( fault_name == NULL ) { printf("\nWe are done\n"); return 0; } printf("opening fault file= %s\n",fault_name); vectors_fd = fopen (vectors_name, "r"); if (vectors_fd == NULL) system_error ("fopen"); */ // synexeia simulation<----------------------------------- printf("\nWe are done\n"); return 0; }
int main(int argc, char* argv[]) { std::vector<std::string> files = read_dir("data"); std::string test_arg; if(argc < 2) { test_arg = ""; } else { test_arg = argv[1]; } for (auto const& file : files) { std::vector<std::string> inputs = read_vectors(file); if (executeEvaluationWithFile("bleichenbacher", file, test_arg)) { std::string result_folder = "results/bleichenbacher"; std::unique_ptr<BleichenbacherTest> test(new BleichenbacherTest(inputs, result_folder, 2048)); test->execute_evaluation(); } else if (executeEvaluationWithFile("manger", file, test_arg)) { std::string result_folder = "results/manger"; std::unique_ptr<MangerTest> test(new MangerTest(inputs, result_folder, 2048)); test->execute_evaluation(); } else if (executeEvaluationWithFile("lucky13sec3", file, test_arg)) { std::string result_folder_sha1 = "results/lucky13sha1sec3"; std::unique_ptr<Lucky13Test> test_sha1(new Lucky13Test(inputs, result_folder_sha1, "SHA-1", 20)); test_sha1->execute_evaluation(); std::string result_folder_sha256 = "results/lucky13sha256sec3"; std::unique_ptr<Lucky13Test> test_sha256(new Lucky13Test(inputs, result_folder_sha256, "SHA-256", 32)); test_sha256->execute_evaluation(); } else if (executeEvaluationWithFile("lucky13sec4sha1", file, test_arg)) { std::string result_folder_sha1 = "results/lucky13sha1sec4"; std::unique_ptr<Lucky13Test> test_sha1(new Lucky13Test(inputs, result_folder_sha1, "SHA-1", 20)); test_sha1->execute_evaluation(); } else if (executeEvaluationWithFile("lucky13sec4sha256", file, test_arg)) { std::string result_folder_sha256 = "results/lucky13sha256sec4"; std::unique_ptr<Lucky13Test> test_sha256(new Lucky13Test(inputs, result_folder_sha256, "SHA-256", 32)); test_sha256->execute_evaluation(); } else if (executeEvaluationWithFile("lucky13sha384", file, test_arg)) { std::string result_folder_sha384 = "results/lucky13sha384"; std::unique_ptr<Lucky13Test> test_sha384(new Lucky13Test(inputs, result_folder_sha384, "SHA-384", 48)); test_sha384->execute_evaluation(); } else { std::cout << "\nSkipping the following test: " << file; } } return 1; }