crown  1.0.0
src/allocation-fastest.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 
00024 #include <pelib/argument_parsing.hpp>
00025 #include <pelib/dl.h>
00026 
00027 #include <crown/allocation.h>
00028 #include <crown/CrownAllocationFastest.hpp>
00029 #include <crown/CrownConfigBinary.hpp>
00030 #include <crown/CrownConfigOrgan.hpp>
00031 #include <crown/CrownConfigTaskgraph.hpp>
00032 
00033 #ifdef debug
00034 #undef debug
00035 #endif
00036 
00037 #define debug(var) cout << "[" << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "] " << #var << " = \"" << (var) << "\"" << endl;
00038 
00039 using namespace std;
00040 using namespace pelib;
00041 using namespace crown;
00042 
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif
00046 
00047 struct args
00048 {
00049         float gemin;
00050         bool showError, showOutput;
00051         
00052 };
00053 typedef struct args args_t;
00054 
00055 static args_t
00056 parse(char **args)
00057 {
00058         args_t out;
00059         out.showError = false;
00060         out.showOutput = false;
00061         out.gemin = 0;
00062 
00063         for(; args[0] != NULL; args++)
00064         {
00065                 if(strcmp(args[0], "--show-stdout") == 0)
00066                 {
00067                         out.showOutput = true;
00068                         continue;
00069                 }
00070                 if(strcmp(args[0], "--show-stderr") == 0)
00071                 {
00072                         out.showError = true;
00073                         continue;
00074                 }
00075                 if(strcmp(args[0], "--min-efficiency") == 0)
00076                 {
00077                         stringstream str(args[0]);
00078                         str >> out.gemin;
00079                         continue;
00080                 }
00081         }
00082 
00083         return out;
00084 }
00085 
00086 const CrownAllocation*
00087 crown_allocation(size_t argc, char **argv)
00088 {
00089         args_t args = parse(argv);
00090 
00091         // Convert solver output to general schedule
00092         CrownAllocation *alloc = new CrownAllocationFastest(args.gemin, args.showOutput, args.showError);
00093         return alloc;
00094 }
00095 
00096 void
00097 crown_delete_algebra(pelib::Algebra *alloc)
00098 {
00099         delete alloc;
00100 }
00101 
00102 #ifdef __cplusplus
00103 }
00104 #endif