crown
1.0.0
|
00001 /* 00002 Copyright 2015 Nicolas Melot 00003 00004 This file is part of Crown. 00005 00006 Crown is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 Crown is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with Crown. If not, see <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00021 00022 #include <fstream> 00023 #include <set> 00024 00025 #include <cstdlib> 00026 00027 #include <crown/allocation.h> 00028 #include <crown/mapping.h> 00029 #include <crown/scaling.h> 00030 #include <crown/annealing.h> 00031 #include <crown/crown.h> 00032 #include <crown/CrownScheduler.hpp> 00033 00034 #include <pelib/XMLSchedule.hpp> 00035 #include <pelib/AmplInput.hpp> 00036 #include <pelib/AmplOutput.hpp> 00037 #include <pelib/Vector.hpp> 00038 #include <pelib/Matrix.hpp> 00039 #include <pelib/Set.hpp> 00040 #include <pelib/GraphML.hpp> 00041 #include <pelib/Schedule.hpp> 00042 00043 using namespace pelib; 00044 using namespace pelib::crown; 00045 using namespace std; 00046 00047 int 00048 main(int argc, char** argv) 00049 { 00050 time_t t = time(NULL); 00051 srand(t); 00052 cout << setprecision(6) << setiosflags(ios::fixed) << setiosflags(ios::showpoint); 00053 cerr << setprecision(6) << setiosflags(ios::fixed) << setiosflags(ios::showpoint); 00054 00055 ifstream taskgraph(argv[1], std::ios::in); 00056 ifstream platform(argv[2], std::ios::in); 00057 ifstream parameters(argv[3], std::ios::in); 00058 00059 Algebra alg_arch = AmplInput(AmplInput::floatHandlers()).parse(platform); 00060 Platform *arch = new Platform(alg_arch); 00061 Algebra param = AmplInput(AmplInput::floatHandlers()).parse(parameters); 00062 Taskgraph *tg = GraphML().parse(taskgraph); 00063 taskgraph.close(); 00064 platform.close(); 00065 parameters.close(); 00066 00067 Algebra schedule = tg->buildAlgebra(arch); 00068 schedule = schedule.merge(arch->buildAlgebra()); 00069 schedule = schedule.merge(param); 00070 00071 schedule = crown_binary_annealing_allocation_off(schedule, 8, 0.6, 0.9, 2, 2, 0.5); 00072 schedule = CrownScheduler::crownToSchedule(schedule); 00073 00074 XMLSchedule().dump(cout, Schedule("crown_binary_annaling_allocation_", schedule), tg, *arch); 00075 /* 00076 cerr << allocation_fastest_complexity(schedule) << endl; 00077 cerr << mapping_ltlg_complexity(schedule) << endl; 00078 cerr << frequency_height_complexity(schedule) << endl; 00079 cerr << allocation_fastest_complexity(schedule) + mapping_ltlg_complexity(schedule) + frequency_height_complexity(schedule) << endl; 00080 cerr << crown_binary_complexity(schedule) << endl; 00081 cerr << annealing_complexity(8, 0.6, 0.9, 2, 2, 0.5) << endl; 00082 cerr << crown_binary_complexity(schedule) + annealing_complexity(8, 0.6, 0.9, 2, 2, 0.5) << endl; 00083 */ 00084 AmplOutput(AmplOutput::floatHandlers()).dump(cerr, Scalar<float>("complexity", (crown_binary_complexity(schedule) + annealing_complexity(8, 0.6, 0.9, 2, 2, 0.5)) * (allocation_fastest_complexity(schedule) + mapping_ltlg_complexity(schedule) + frequency_height_complexity(schedule)))); 00085 00086 float qual = mapping_quality(schedule); 00087 Scalar<float> q("quality", qual); 00088 00089 float m = schedule.find<Scalar<float> >("m")->getValue(); 00090 if(m < 0) 00091 { 00092 cerr << "feasible = 0" << endl; 00093 } 00094 else 00095 { 00096 cerr << "feasible = 1" << endl; 00097 } 00098 00099 AmplOutput(AmplOutput::floatHandlers()).dump(cerr, &q); 00100 AmplOutput(AmplOutput::floatHandlers()).dump(cerr, schedule.find<Scalar<float> >("_total_solve_elapsed_time")); 00101 00102 return EXIT_SUCCESS; 00103 } 00104