crown  1.0.0
src/crown_binary_idle.cpp
Go to the documentation of this file.
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/crown.h>
00031 #include <crown/CrownScheduler.hpp>
00032 
00033 #include <pelib/XMLSchedule.hpp>
00034 #include <pelib/AmplInput.hpp>
00035 #include <pelib/AmplOutput.hpp>
00036 #include <pelib/Vector.hpp>
00037 #include <pelib/Matrix.hpp>
00038 #include <pelib/Set.hpp>
00039 #include <pelib/GraphML.hpp>
00040 #include <pelib/Schedule.hpp>
00041 
00042 using namespace std;
00043 using namespace pelib;
00044 using namespace pelib::crown;
00045 
00046 // Quality assessment parameters
00047 const long long int nsec_in_sec = 1000000000;
00048 
00049 int
00050 main(int argc, char** argv)
00051 {
00052         struct timespec seed, total_time;
00053         clock_gettime(CLOCK_MONOTONIC, &total_time);
00054         srand(seed.tv_nsec);
00055         time_t t = time(NULL);
00056         srand(t);
00057 
00058         cout << setprecision(6) << setiosflags(ios::fixed) << setiosflags(ios::showpoint);
00059         cerr << setprecision(6) << setiosflags(ios::fixed) << setiosflags(ios::showpoint);
00060 
00061         ifstream taskgraph(argv[1], std::ios::in);
00062         ifstream platform(argv[2], std::ios::in);
00063         ifstream parameters(argv[3], std::ios::in);
00064 
00065         Algebra alg_arch = AmplInput(AmplInput::floatHandlers()).parse(platform);
00066         Platform *arch = new Platform(alg_arch);
00067         Algebra param = AmplInput(AmplInput::floatHandlers()).parse(parameters);
00068         Taskgraph *tg = GraphML().parse(taskgraph);
00069         taskgraph.close();
00070         platform.close();
00071         parameters.close();
00072 
00073         //cerr << tg->getMakespanCalculator() << " = " << tg->getRoundTime(arch) << endl;
00074         Algebra schedule = tg->buildAlgebra(arch);
00075         //AmplInput().dump(cerr, schedule);
00076         schedule = schedule.merge(arch->buildAlgebra());
00077         schedule = schedule.merge(param);
00078         
00079 #if !SHOWPOWER
00080         schedule = crown_binary_idle(schedule, 3);
00081 #else
00082         schedule = crown_binary_idle(schedule, 0);
00083 #endif
00084         schedule = CrownScheduler::crownToSchedule(schedule);
00085         XMLSchedule().dump(cout, Schedule("crown_binary", schedule), tg, *arch);
00086 
00087         AmplOutput(AmplOutput::floatHandlers()).dump(cerr, Scalar<float>("complexity", crown_binary_complexity(schedule) * (allocation_fastest_complexity(schedule) + mapping_ltlg_complexity(schedule) + frequency_height_complexity(schedule))));
00088 
00089         delete arch;
00090         delete tg;
00091 
00092         float m = schedule.find<Scalar<float> >("m")->getValue();
00093         if(m < 0)
00094         {
00095                 cerr << "feasible = 0" << endl;
00096         }
00097         else
00098         {
00099                 cerr << "feasible = 1" << endl;
00100         }
00101         
00102 #if !SHOWPOWER
00103         float qual = mapping_quality(schedule);
00104         Scalar<float> q("quality", qual);
00105 
00106         AmplOutput(AmplOutput::floatHandlers()).dump(cerr, &q);
00107         AmplOutput(AmplOutput::floatHandlers()).dump(cerr, schedule.find<Scalar<float> >("_total_solve_elapsed_time"));
00108 #endif
00109 
00110         return EXIT_SUCCESS;
00111 }
00112