Merge
[satune.git] / src / Tuner / searchtuner.h
1 #ifndef SEARCHTUNER_H
2 #define SEARCHTUNER_H
3 #include "classlist.h"
4 #include "tunable.h"
5 #include "structs.h"
6
7 class TunableSetting {
8 public:
9         TunableSetting(VarType type, TunableParam param);
10         TunableSetting(VarType type1, VarType type2, TunableParam param);
11         TunableSetting(TunableParam param);
12         TunableSetting(TunableSetting *ts);
13         void setDecision(int _low, int _high, int _default, int _selection);
14         void print();
15         CMEMALLOC;
16 private:
17         bool hasVar;
18         VarType type1;
19         VarType type2;
20         TunableParam param;
21         int lowValue;
22         int highValue;
23         int defaultValue;
24         int selectedValue;
25         friend unsigned int tunableSettingHash(TunableSetting *setting);
26         friend bool tunableSettingEquals(TunableSetting *setting1, TunableSetting *setting2);
27         friend class SearchTuner;
28 };
29
30 unsigned int tunableSettingHash(TunableSetting *setting);
31 bool tunableSettingEquals(TunableSetting *setting1, TunableSetting *setting2);
32
33 typedef Hashset<TunableSetting *, uintptr_t, 4, tunableSettingHash, tunableSettingEquals> HashsetTunableSetting;
34 typedef SetIterator<TunableSetting *, uintptr_t, 4, tunableSettingHash, tunableSettingEquals> SetIteratorTunableSetting;
35
36 class SearchTuner : public Tuner {
37 public:
38         SearchTuner();
39         ~SearchTuner();
40         int getTunable(TunableParam param, TunableDesc *descriptor);
41         int getVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor);
42         int getVarTunable(VarType vartype1, VarType vartype2, TunableParam param, TunableDesc *descriptor);
43         SearchTuner *copyUsed();
44         void randomMutate();
45         uint getSize() { return usedSettings.getSize();}
46         void print();
47         void printUsed();
48
49         CMEMALLOC;
50 private:
51         /** Used Settings keeps track of settings that were actually used by
52            the example. Mutating settings may cause the Constraint Compiler
53            not to query other settings.*/
54         HashsetTunableSetting usedSettings;
55         /** Settings contains all settings. */
56         HashsetTunableSetting settings;
57 };
58 #endif