void sig_int(int signo) { void print_cpu_time(void); print_cpu_time(); exit(0); }
int main(int argc, char *argv[]) { // Program name ParameterRef parameters; try { // ---------- General options ------------ // // Synthesis cpu time long total_time; START_TIME(total_time); // General options register // ---------- Initialization ------------ // // ---------- Parameter parsing ------------ // long cpu_time; START_TIME(cpu_time); parameters = ParameterRef(new EucalyptusParameter(argv[0], argc, argv)); switch(parameters->Exec()) { case PARAMETER_NOTPARSED: { exit_code = PARAMETER_NOTPARSED; throw "Bad Parameters format"; } case EXIT_SUCCESS: { if(not (parameters->getOption<bool>(OPT_no_clean))) { boost::filesystem::remove_all(parameters->getOption<std::string>(OPT_output_temporary_directory)); } return EXIT_SUCCESS; } case PARAMETER_PARSED: { exit_code = EXIT_FAILURE; break; } default: { THROW_ERROR("Bad Parameters parsing"); } } int output_level = parameters->getOption<int>(OPT_output_level); STOP_TIME(cpu_time); if(output_level >= OUTPUT_LEVEL_MINIMUM) parameters->PrintFullHeader(std::cerr); /// eucalyptus does not perform a clock constrained synthesis if(!parameters->isOption(OPT_clock_period)) parameters->setOption(OPT_clock_period, 0.0); // Technology library manager technology_managerRef TM = technology_managerRef(new technology_manager(parameters)); ///creating the datastructure representing the target device const auto target_device = static_cast<TargetDevice_Type>(parameters->getOption<unsigned int>(OPT_target_device_type)); target_deviceRef device = target_device::create_device(target_device, parameters, TM); device->set_parameter("clock_period", parameters->getOption<double>(OPT_clock_period)); target_managerRef target = target_managerRef(new target_manager(parameters, TM, device)); const DesignFlowManagerRef design_flow_manager(new DesignFlowManager(parameters)); const DesignFlowGraphConstRef design_flow_graph = design_flow_manager->CGetDesignFlowGraph(); const DesignFlowStepFactoryConstRef technology_flow_step_factory(new TechnologyFlowStepFactory(TM, device, design_flow_manager, parameters)); design_flow_manager->RegisterFactory(technology_flow_step_factory); const std::string technology_flow_signature = TechnologyFlowStep::ComputeSignature(TechnologyFlowStep_Type::LOAD_TECHNOLOGY); const vertex technology_flow_step = design_flow_manager->GetDesignFlowStep(technology_flow_signature); const DesignFlowStepRef technology_design_flow_step = technology_flow_step ? design_flow_graph->CGetDesignFlowStepInfo(technology_flow_step)->design_flow_step : GetPointer<const TechnologyFlowStepFactory>(technology_flow_step_factory)->CreateTechnologyFlowStep(TechnologyFlowStep_Type::LOAD_TECHNOLOGY); design_flow_manager->AddStep(technology_design_flow_step); #if HAVE_XILINX || HAVE_ALTERA || HAVE_LATTICE || HAVE_DESIGN_COMPILER if(parameters->isOption(OPT_component_name)) { const DesignFlowStepRef design_flow_step(new RTLCharacterization(target, parameters->getOption<std::string>(OPT_component_name), design_flow_manager, parameters)); design_flow_manager->AddStep(design_flow_step); } #endif design_flow_manager->Exec(); #if HAVE_EXPERIMENTAL if (parameters->isOption(OPT_import_ip_core)) { START_TIME(cpu_time); std::string core_hdl = parameters->getOption<std::string>(OPT_import_ip_core); core_generationRef core_gen = core_generationRef(new core_generation(parameters)); core_gen->convert_to_XML(core_hdl, device->get_type()); STOP_TIME(cpu_time); PRINT_OUT_MEX(DEBUG_LEVEL_MINIMUM, output_level, " ==== Core generation performed in " + print_cpu_time(cpu_time) + " seconds; ====\n"); } if (parameters->isOption(OPT_export_ip_core)) { START_TIME(cpu_time); std::string core_name = parameters->getOption<std::string>(OPT_export_ip_core); core_generationRef core_gen = core_generationRef(new core_generation(parameters)); core_gen->export_core(TM, core_name); STOP_TIME(cpu_time); PRINT_OUT_MEX(DEBUG_LEVEL_MINIMUM, output_level, " ==== Core exported in " + print_cpu_time(cpu_time) + " seconds; ====\n"); } #endif STOP_TIME(total_time); PRINT_MSG(" ==== Total Execution Time: " + print_cpu_time(total_time) + " seconds; ====\n"); if(not (parameters->getOption<bool>(OPT_no_clean))) { boost::filesystem::remove_all(parameters->getOption<std::string>(OPT_output_temporary_directory)); } return EXIT_SUCCESS; // Eucalyptus tool has completed execution without errors } // exception catching catch (const char * str) { std::cerr << str << std::endl; } catch (const std::string& str) { std::cerr << str << std::endl; } catch (std::exception &e) { std::cerr << e.what() << std::endl; } catch (...) { std::cerr << "Unknown error type" << std::endl; } switch(exit_code) { case PARAMETER_NOTPARSED: { parameters->PrintUsage(std::cout); break; } case EXIT_FAILURE: { parameters->PrintBugReport(std::cout); break; } default: { } } if(parameters and not (parameters->getOption<bool>(OPT_no_clean))) { boost::filesystem::remove_all(parameters->getOption<std::string>(OPT_output_temporary_directory)); } return exit_code; }
DesignFlowStep_Status weighted_clique_register::InternalExec() { const FunctionBehaviorConstRef FB = HLSMgr->CGetFunctionBehavior(funId); long step_time; START_TIME(step_time); const CliqueCovering_Algorithm clique_covering_algorithm = GetPointer<const WeightedCliqueRegisterBindingSpecialization>(hls_flow_step_specialization)->clique_covering_algorithm; refcount< clique_covering<CG_vertex_descriptor> > register_clique = clique_covering<CG_vertex_descriptor>::create_solver(clique_covering_algorithm); create_compatibility_graph(); std::vector<CG_vertex_descriptor>::const_iterator v_it_end = verts.end(); unsigned int vertex_index = 0; unsigned int num_registers = 0; for(std::vector<CG_vertex_descriptor>::const_iterator v_it = verts.begin(); v_it != v_it_end; ++v_it, ++vertex_index) register_clique->add_vertex(*v_it, STR(vertex_index)); if(vertex_index>0) { boost::graph_traits<compatibility_graph>::edge_iterator cg_ei,cg_ei_end; for(boost::tie(cg_ei,cg_ei_end) = boost::edges(CG); cg_ei != cg_ei_end; ++cg_ei) { CG_vertex_descriptor src = boost::source(*cg_ei, CG); CG_vertex_descriptor tgt = boost::target(*cg_ei, CG); register_clique->add_edge(src, tgt, CG[*cg_ei].weight); } if(parameters->getOption<bool>(OPT_print_dot)) { const auto functionName = FB->CGetBehavioralHelper()->get_function_name(); const auto output_directory = parameters->getOption<std::string>(OPT_dot_directory) + "/" + functionName + "/"; if (!boost::filesystem::exists(output_directory)) boost::filesystem::create_directories(output_directory); const auto file_name = output_directory + "HLS_RegisterBinding.dot"; register_clique->writeDot(file_name); } /// performing clique covering no_check_clique<CG_vertex_descriptor> cq; register_clique->exec(no_filter_clique<CG_vertex_descriptor>(), cq); /// vertex to clique map std::map<CG_vertex_descriptor, unsigned int> v2c; /// retrieve the solution num_registers = static_cast<unsigned int>(register_clique->num_vertices()); for (unsigned int i = 0; i < num_registers; ++i) { std::set<CG_vertex_descriptor> clique = register_clique->get_clique(i); std::set<CG_vertex_descriptor>::const_iterator v_end = clique.end(); for (std::set<CG_vertex_descriptor>::const_iterator v = clique.begin(); v != v_end; ++v) { v2c[*v] = i; } } /// finalize HLS->Rreg = reg_bindingRef(new reg_binding(HLS, HLSMgr)); const std::list<vertex> & support = HLS->Rliv->get_support(); const std::list<vertex>::const_iterator vEnd = support.end(); for(std::list<vertex>::const_iterator vIt = support.begin(); vIt != vEnd; vIt++) { const std::set<unsigned int>& live = HLS->Rliv->get_live_in(*vIt); std::set<unsigned int>::iterator k_end = live.end(); for(std::set<unsigned int>::iterator k = live.begin(); k != k_end; k++) { unsigned int storage_value_index = HLS->storage_value_information->get_storage_value_index(*vIt, *k); HLS->Rreg->bind(storage_value_index, v2c[verts[storage_value_index]]); } } } else { HLS->Rreg = reg_bindingRef(new reg_binding(HLS, HLSMgr)); num_registers = 0; } HLS->Rreg->set_used_regs(num_registers); STOP_TIME(step_time); if(output_level <= OUTPUT_LEVEL_PEDANTIC) INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, ""); INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "-->Register binding information for function " + FB->CGetBehavioralHelper()->get_function_name() + ":"); INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, std::string("---Register allocation algorithm obtains ") + (num_registers == register_lower_bound ? "an optimal" : "a sub-optimal") + " result: " + STR(num_registers) + " registers"+(num_registers == register_lower_bound?"":("(LB:"+STR(register_lower_bound)+")"))); if (output_level >= OUTPUT_LEVEL_VERY_PEDANTIC) HLS->Rreg->print(); if(output_level >= OUTPUT_LEVEL_MINIMUM and output_level <= OUTPUT_LEVEL_PEDANTIC) INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "Time to perform register binding: " + print_cpu_time(step_time) + " seconds"); INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "<--"); if(output_level <= OUTPUT_LEVEL_PEDANTIC) INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, ""); return DesignFlowStep_Status::SUCCESS; }
int main(int argc, char **argv) { int opts = global_options(&argc, &argv); int data_len; #ifdef HAVE_LIBPAPI int papi_counters = PAPI_num_counters(); if (papi_counters < papi_array_len) { fprintf(stderr, "%s: Warning: there are only %d hardware counters available!\n", progname, papi_counters); papi_array_len = papi_counters; } if (papi_test(papi_events, papi_array_len)) exit(1); for (int nv = 0; nv <= papi_array_len; ++nv) loop_calibration[nv] = 100000000; data_len = papi_array_len + 1; #else data_len = 2; #endif if (opts < 0 || argc < 2 || argc > 5) { print_help_and_exit(); } struct elim_params params; params.m = atoi(argv[1]); if (argc >= 3) params.n = atoi(argv[2]); else params.n = params.m; if (argc >= 4) params.algorithm = argv[3]; else params.algorithm = "ple"; if (argc >= 5) params.r = atoi(argv[4]); else params.r = MIN(params.m, params.n); srandom(17); unsigned long long data[16]; for (int i = 0; i < 4; ++i) run_nothing((void*)¶ms, data, &data_len); run_bench(run, (void*)¶ms, data, data_len); double cc_per_op = ((double)data[1])/ ( (double)params.m * (double)params.n * powl((double)params.r,0.807) ); printf("m: %5d, n: %5d, last r: %5d, cpu cycles: %12llu, cc/(mnr^0.807): %.5lf, ", params.m, params.n, params.r, data[1], cc_per_op); print_wall_time(data[0] / 1000000.0); printf(", "); print_cpu_time(data[1] / (double)cpucycles_persecond()); printf("\n"); #ifdef HAVE_LIBPAPI for (int n = 1; n < data_len; ++n) { double tmp = ((double)data[n]) / powl((double)params.n,2.807); printf("%20s (%20llu) per bit (divided by n^2.807): %15.5f\n", papi_event_name(papi_events[n - 1]), data[n], tmp); } #endif }
void DesignCompilerWrapper::parse_synthesis_reports() { if (report_files.find(SYNTHESIS_LOG) == report_files.end() || !boost::filesystem::exists(report_files[SYNTHESIS_LOG])) { synthesis_time = 0; return; } std::string synthesis_report = report_files[SYNTHESIS_LOG]; std::ifstream output_file(synthesis_report.c_str()); if (output_file.is_open()) { PRINT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "File \"" + synthesis_report + "\" opened"); while (!output_file.eof()) { std::string line; getline(output_file, line); PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, line); if (line.size() and line.find("microseconds per iteration") != std::string::npos and line.find("echo") == std::string::npos) { std::string token("microseconds per iteration"); std::string elapsed_time_string = line.substr(0, line.find(token)); boost::trim(elapsed_time_string); synthesis_time = boost::lexical_cast<double>(elapsed_time_string) / 1000.0; } if (line.size() and line.find("RESULT SYNTHESIS:") != std::string::npos and line.find("echo") == std::string::npos) { std::string token("RESULT SYNTHESIS:"); std::string result_string = line.substr(line.find(token) + token.size() + 1, line.size()); boost::trim(result_string); synthesis_result = boost::lexical_cast<bool>(result_string); } } } if (synthesis_time > 0) { PRINT_OUT_MEX(OUTPUT_LEVEL_VERBOSE, output_level, "** Synthesis Report **"); PRINT_OUT_MEX(OUTPUT_LEVEL_VERBOSE, output_level, "* Elapsed synthesis time : " << print_cpu_time(static_cast<long int>(synthesis_time)) << " seconds"); PRINT_OUT_MEX(OUTPUT_LEVEL_VERBOSE, output_level, "*****************"); } }
void read_technology_library(technology_managerRef TM, const ParameterConstRef Param, const target_deviceRef device) { #if HAVE_EXPERIMENTAL || HAVE_FROM_LIBERTY || HAVE_LIBRARY_COMPILER int output_level = Param->getOption<int>(OPT_output_level); #endif #ifndef NDEBUG int debug_level = Param->get_class_debug_level("parse_technology"); #endif #if HAVE_FROM_LIBERTY //parsing of liberty format if (Param->isOption(OPT_input_liberty_library_file)) { long lib2xmlTime; std::string LibFile = Param->getOption<std::string>(OPT_input_liberty_library_file); std::string XmlList; std::vector<std::string> SplittedLibs; boost::algorithm::split(SplittedLibs, LibFile, boost::algorithm::is_any_of(";")); for (unsigned int i = 0; i < SplittedLibs.size(); i++) { if (SplittedLibs.size() == 0) continue; boost::trim(SplittedLibs[i]); std::vector<std::string> SplittedLib; boost::algorithm::split(SplittedLib, SplittedLibs[i], boost::algorithm::is_any_of(":")); std::string LibraryFile, LibraryName; if (SplittedLib.size() < 1 or SplittedLib.size() > 2) THROW_ERROR("Malformed input liberty description: \"" + SplittedLibs[i] + "\""); if (SplittedLib.size() == 1) { LibraryFile = SplittedLib[0]; } else { LibraryName = SplittedLib[0]; LibraryFile = SplittedLib[1]; } if (!boost::filesystem::exists(LibraryFile)) THROW_ERROR("Liberty file \"" + LibraryFile + "\" does not exists!"); START_TIME(lib2xmlTime); std::string TargetXML = Param->getOption<std::string>(OPT_output_temporary_directory) + "/library_" + boost::lexical_cast<std::string>(i) + ".xml"; lib2xml(LibraryFile, TargetXML, Param); if (XmlList.size()) XmlList += ";"; XmlList += TargetXML; STOP_TIME(lib2xmlTime); PRINT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "(koala) Read and converted the liberty file \"" + LibraryFile + "\" in " + boost::lexical_cast<std::string>(print_cpu_time(lib2xmlTime)) + " seconds;\n"); } ///FIXME: setting parameters const_cast<Parameter *>(Param.get())->setOption("input_xml_library_file", XmlList); } #endif #if HAVE_BOOLEAN_PARSER_BUILT if (Param->isOption("input_genlib_library_file")) { long genlibTime; START_TIME(genlibTime); PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "(koala) Reading the genlib technology library"); std::string LibraryName = Param->getOption<std::string>("genlib_library_file"); technology_managerRef local_TM = technology_managerRef(new technology_manager(Param)); read_genlib_technology_File(LibraryName, local_TM, Param); STOP_TIME(genlibTime); PRINT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "(koala) Read the technology library file \"" + LibraryName + "\" in " + boost::lexical_cast<std::string>(print_cpu_time(genlibTime)) + " seconds;\n"); write_technology_File(technology_manager::XML, "genlib", local_TM, device->get_type()); ///FIXME: setting parameters const_cast<Parameter *>(Param.get())->setOption("input_xml_library_file", "genlib.xml"); const_cast<Parameter *>(Param.get())->removeOption("input_genlib_library_file"); } #endif if (Param->isOption("input_xml_library_file")) { PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "(koala) Reading the XML technology library"); std::string LibraryName; std::string XmlLibraryList = Param->getOption<std::string>("input_xml_library_file"); std::vector<std::string> SplittedLibs; boost::algorithm::split(SplittedLibs, XmlLibraryList, boost::algorithm::is_any_of(";")); for (unsigned int i = 0; i < SplittedLibs.size(); i++) { if (SplittedLibs.size() == 0) continue; LibraryName = SplittedLibs[i]; long xmlTime; START_TIME(xmlTime); read_technology_File(SplittedLibs[i], TM, Param, device); STOP_TIME(xmlTime); PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "(koala) Read the XML technology library file \"" + LibraryName + "\" in " + boost::lexical_cast<std::string>(print_cpu_time(xmlTime)) + " seconds;\n"); } #if HAVE_BOOLEAN_PARSER_BUILT if (Param->getOption<bool>(OPT_dump_genlib)) { std::string genlib_name(LibraryName.substr(0, LibraryName.find_last_of('.')) + ".genlib"); PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "(koala) Dumping the technology library in genlib format"); #if HAVE_CIRCUIT_BUILT dump_genlib(genlib_name, TM); #endif } #endif } #if HAVE_EXPERIMENTAL if (Param->isOption("input_lef_library_file")) { std::string FileList = Param->getOption<std::string>("input_lef_library_file"); std::vector<std::string> SplittedLibs; boost::algorithm::split(SplittedLibs, FileList, boost::algorithm::is_any_of(";")); for (unsigned int i = 0; i < SplittedLibs.size(); i++) { if (SplittedLibs.size() == 0) continue; boost::trim(SplittedLibs[i]); std::vector<std::string> SplittedName; boost::algorithm::split(SplittedName, SplittedLibs[i], boost::algorithm::is_any_of(":")); if (SplittedName.size() != 2) THROW_ERROR("Malformed LEF description: \"" + SplittedLibs[i] + "\""); std::string LibraryName = SplittedName[0]; std::string LefFileName = SplittedName[1]; if (!boost::filesystem::exists(LefFileName)) THROW_ERROR("Lef file \"" + LefFileName + "\" does not exists!"); if (!TM->is_library_manager(LibraryName)) THROW_ERROR("Library \"" + LibraryName + "\" is not contained into the datastructure"); const library_managerRef& LM = TM->get_library_manager(LibraryName); LM->set_info(library_manager::LEF, LefFileName); PRINT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "(koala) Stored LEF file \"" + LefFileName + "\" for library \"" + LibraryName + "\";\n"); } } #endif #if HAVE_LIBRARY_COMPILER if (Param->isOption("input_db_library_file")) { std::string FileList = Param->getOption<std::string>("input_db_library_file"); std::vector<std::string> SplittedLibs; boost::algorithm::split(SplittedLibs, FileList, boost::algorithm::is_any_of(";")); for (unsigned int i = 0; i < SplittedLibs.size(); i++) { if (SplittedLibs.size() == 0) continue; boost::trim(SplittedLibs[i]); std::vector<std::string> SplittedName; boost::algorithm::split(SplittedName, SplittedLibs[i], boost::algorithm::is_any_of(":")); if (SplittedName.size() != 2) THROW_ERROR("Malformed db description: \"" + SplittedLibs[i] + "\""); std::string LibraryName = SplittedName[0]; std::string dbFileName = SplittedName[1]; if (!TM->is_library_manager(LibraryName)) THROW_ERROR("Library \"" + LibraryName + "\" is not contained into the datastructure"); const library_managerRef LM = TM->get_library_manager(LibraryName); LM->set_info(library_manager::DB, dbFileName); PRINT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "(koala) Stored DB file \"" + dbFileName + "\" for library \"" + LibraryName + "\";\n"); } } #endif }
DesignFlowStep_Status values_scheme::InternalExec() { long step_time; START_TIME(step_time); THROW_ASSERT(HLS->Rliv, "Liveness analysis not yet computed"); unsigned int i = 0; const std::list<vertex> & support = HLS->Rliv->get_support(); const std::list<vertex>::const_iterator vEnd = support.end(); for(std::list<vertex>::const_iterator vIt = support.begin(); vIt != vEnd; vIt++) { //std::cerr << "current state for sv " << HLS->Rliv->get_name(*vIt) << std::endl; const std::set<unsigned int>& live = HLS->Rliv->get_live_in(*vIt); const std::set<unsigned int>::const_iterator k_end = live.end(); for(std::set<unsigned int>::const_iterator k = live.begin(); k != k_end; k++) { if(HLS->storage_value_information->storage_index_map.find(*k) == HLS->storage_value_information->storage_index_map.end()) { HLS->storage_value_information->storage_index_map[*k] = i; HLS->storage_value_information->variable_index_vect.push_back(*k); i++; } } } HLS->storage_value_information->number_of_storage_values = i; if(output_level <= OUTPUT_LEVEL_PEDANTIC) INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, ""); INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "-->Storage Value Information of function " + HLSMgr->CGetFunctionBehavior(funId)->CGetBehavioralHelper()->get_function_name() + ":"); INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "---Number of storage values inserted: "+boost::lexical_cast<std::string>(i)); STOP_TIME(step_time); if(output_level >= OUTPUT_LEVEL_MINIMUM and output_level <= OUTPUT_LEVEL_PEDANTIC) INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "Time to compute storage value information: " + print_cpu_time(step_time) + " seconds"); INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "<--"); if(output_level <= OUTPUT_LEVEL_PEDANTIC) INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, ""); return DesignFlowStep_Status::SUCCESS; }
int main () { print_cpu_time(); return(0); }