mageec  0.1.0
MAchine Guided Energy Efficient Compilation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
mageec-ml.h
Go to the documentation of this file.
1 /* MAGEEC Machine Learning Interface
2  Copyright (C) 2013, 2014 Embecosm Limited and University of Bristol
3 
4  This file is part of MAGEEC.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 
20 #ifndef __MAGEEC_ML_H__
21 #define __MAGEEC_ML_H__
22 
23 #include <string>
24 #include <vector>
25 #include <stdint.h>
26 #include "mageec-decision.h"
27 #include "mageec-features.h"
28 #include "mageec-passes.h"
29 #include "mageec-result.h"
30 #include "mageec-db.h"
31 
32 namespace mageec
33 {
37 class mageec_ml
38 {
39  database *db;
40  std::vector<mageec_pass*> known_passes;
41 public:
42  virtual ~mageec_ml() {}
43 
49  virtual int init (std::string dbfilename);
50 
57  virtual int init (std::string compiler_version,
58  std::string compiler_target);
62  void new_file (void);
63 
67  void end_file (void);
68 
72  void finish (void);
73 
79  void provide_features (std::vector<mageec_feature*> features);
80 
86  std::vector<mageec_pass> get_passes();
87 
93  std::vector<mageec_pass*> all_passes();
94 
101  virtual decision make_decision (mageec_pass* pass,
102  std::vector<mageec_feature*> features);
103 
108  void process_results();
109 
119  void add_result (std::vector<mageec_feature*> features,
120  std::vector<mageec_pass*> passes,
121  int64_t metric,
122  bool good);
123 
128  void add_result (result res);
129 
138  void raw_result (std::vector<mageec_feature*> features,
139  std::vector<mageec_pass*> passes,
140  std::vector<int64_t> metrics,
141  bool good);
142 };
143 
150 class file_ml : public mageec_ml
151 {
152  std::vector<std::string> passlist;
153 public:
154  virtual int init (std::string dbfilename);
155  virtual int init (std::string compiler_version,
156  std::string compiler_target);
157  virtual decision make_decision (mageec_pass* pass,
158  std::vector<mageec_feature*> features);
159 };
160 
161 } // End namespace mageec
162 
163 #endif