Autotune Framework
[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(TunableParam param);
11         TunableSetting(TunableSetting * ts);
12         void setDecision(int _low, int _high, int _default, int _selection);
13         MEMALLOC;
14  private:
15         bool hasVar;
16         VarType type;
17         TunableParam param;
18         int lowValue;
19         int highValue;
20         int defaultValue;
21         int selectedValue;
22         friend unsigned int tunableSettingHash(TunableSetting *setting);
23         friend bool tunableSettingEquals(TunableSetting *setting1, TunableSetting *setting2);
24         friend class SearchTuner;
25 };
26
27 unsigned int tunableSettingHash(TunableSetting *setting);
28 bool tunableSettingEquals(TunableSetting *setting1, TunableSetting *setting2);
29
30 typedef HashSet<TunableSetting *, uintptr_t, 4, tunableSettingHash, tunableSettingEquals> HashSetTunableSetting;
31 typedef HSIterator<TunableSetting *, uintptr_t, 4, tunableSettingHash, tunableSettingEquals> HSIteratorTunableSetting;
32
33 class SearchTuner : public Tuner {
34  public:
35         SearchTuner();
36         ~SearchTuner();
37         int getTunable(TunableParam param, TunableDesc *descriptor);
38         int getVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor);
39         SearchTuner * copyUsed();
40         void randomMutate();
41         uint getSize() { return usedSettings.getSize();}
42         
43         MEMALLOC;
44  private:
45         /** Used Settings keeps track of settings that were actually used by
46                  the example. Mutating settings may cause the Constraint Compiler
47                  not to query other settings.*/
48         HashSetTunableSetting usedSettings;
49         /** Settings contains all settings. */
50         HashSetTunableSetting settings;
51 };
52 #endif