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