#include "orderelement.h"
#include "structs.h"
#include "decomposeorderresolver.h"
+#include "tunabledependent.h"
#define HASHNEXT(hash, newval) {hash += newval; hash += hash << 10; hash ^= hash >> 6;}
#define HASHFINAL(hash) {hash += hash << 3; hash ^= hash >> 11; hash += hash << 15;}
return true;
}
+unsigned int tunable_dependent_hash_function(TunableDependent *This){
+ return (uint)This->dependent;
+}
+
+bool tunable_dependent_equals(TunableDependent *key1, TunableDependent *key2){
+ return key1->dependent == key2->dependent;
+}
+
unsigned int order_node_hash_function(OrderNodeKey *This) {
return (uint) This->id;
}
bool table_entry_equals(TableEntry *key1, TableEntry *key2);
unsigned int order_node_hash_function(OrderNodeKey *This);
bool order_node_equals(OrderNodeKey *key1, OrderNodeKey *key2);
+unsigned int tunable_dependent_hash_function(TunableDependent *This);
+bool tunable_dependent_equals(TunableDependent *key1, TunableDependent *key2);
unsigned int order_edge_hash_function(OrderEdge *This);
bool order_edge_equals(OrderEdge *key1, OrderEdge *key2);
unsigned int order_element_hash_function(OrderElement *This);
typedef Hashset<TableEntry *, uintptr_t, PTRSHIFT, table_entry_hash_function, table_entry_equals> HashsetTableEntry;
typedef Hashset<OrderNodeKey *, uintptr_t, PTRSHIFT, order_node_hash_function, order_node_equals> HashsetOrderNode;
+typedef Hashset<TunableDependent *, uintptr_t, PTRSHIFT, tunable_dependent_hash_function, tunable_dependent_equals> HashsetTunableDep;
typedef Hashset<OrderEdge *, uintptr_t, PTRSHIFT, order_edge_hash_function, order_edge_equals> HashsetOrderEdge;
typedef Hashset<OrderElement *, uintptr_t, PTRSHIFT, order_element_hash_function, order_element_equals> HashsetOrderElement;
typedef Hashset<DOREdge *, uintptr_t, PTRSHIFT, doredge_hash_function, doredge_equals> HashsetDOREdge;
typedef SetIterator<TableEntry *, uintptr_t, PTRSHIFT, table_entry_hash_function, table_entry_equals> SetIteratorTableEntry;
typedef SetIterator<OrderEdge *, uintptr_t, PTRSHIFT, order_edge_hash_function, order_edge_equals> SetIteratorOrderEdge;
typedef SetIterator<OrderNodeKey *, uintptr_t, PTRSHIFT, order_node_hash_function, order_node_equals> SetIteratorOrderNode;
+typedef SetIterator<TunableDependent *, uintptr_t, PTRSHIFT, tunable_dependent_hash_function, tunable_dependent_equals> SetIteratorTunableDep;
typedef SetIterator<OrderElement *, uintptr_t, PTRSHIFT, order_element_hash_function, order_element_equals> SetIteratorOrderElement;
typedef SetIterator<DOREdge *, uintptr_t, PTRSHIFT, doredge_hash_function, doredge_equals> SetIteratorDOREdge;
#endif
#include "searchtuner.h"
+#include "tunabledependent.h"
#include <iostream>
#include <fstream>
+#include <valarray>
using namespace std;
+HashsetTunableDep initializeTunableDependencies()
+{
+ HashsetTunableDep dep;
+ dep.add(new TunableDependent(MUSTREACHGLOBAL, DECOMPOSEORDER));
+ dep.add(new TunableDependent(MUSTREACHLOCAL, DECOMPOSEORDER));
+ dep.add(new TunableDependent(MUSTREACHPRUNE, DECOMPOSEORDER));
+ dep.add(new TunableDependent(MUSTEDGEPRUNE, DECOMPOSEORDER));
+ dep.add(new TunableDependent(NODEENCODING, ENCODINGGRAPHOPT));
+ dep.add(new TunableDependent(EDGEENCODING, ENCODINGGRAPHOPT));
+ dep.add(new TunableDependent(ELEMENTOPTSETS, ELEMENTOPT));
+ return dep;
+}
+
+
+HashsetTunableDep SearchTuner::tunableDependency = initializeTunableDependencies();
+
TunableSetting::TunableSetting(VarType _type, TunableParam _param) :
hasVar(true),
type1(_type),
return result->selectedValue;
}
+bool SearchTuner::validTunableSetting(TunableSetting* setting){
+ TunableDependent tuneDep((Tunables)setting->param);
+ bool result = true;
+ while(tunableDependency.contains(&tuneDep)){
+ TunableDependent *dependent = tunableDependency.get(&tuneDep);
+ TunableSetting p(dependent->parent);
+ if(!settings.contains(&p)){
+ SetIteratorTunableSetting *iter = settings.iterator();
+ while(iter->hasNext()){
+ model_print("*******************\n");
+ iter->next()->print();
+ }
+ delete iter;
+ }
+ ASSERT(settings.contains(&p));
+ TunableSetting *parent = settings.get(&p);
+ if(!(bool)parent->selectedValue){ //Check parent config is already off
+ return false;
+ }
+ tuneDep.dependent = dependent->parent;
+ }
+ return result;
+}
+
void SearchTuner::randomMutate() {
- TunableSetting *randomSetting = settings.getRandomElement();
+ TunableSetting *randomSetting;
+ do{
+ randomSetting= settings.getRandomElement();
+ }while(!validTunableSetting(randomSetting));
int range = randomSetting->highValue - randomSetting->lowValue;
int randomchoice = (random() % range) + randomSetting->lowValue;
if (randomchoice < randomSetting->selectedValue)
CMEMALLOC;
private:
+ bool validTunableSetting(TunableSetting* setting);
+ static HashsetTunableDep tunableDependency;
/** Used Settings keeps track of settings that were actually used by
the example. Mutating settings may cause the Constraint Compiler
not to query other settings.*/
--- /dev/null
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * File: TunableDependent.cc
+ * Author: hamed
+ *
+ * Created on October 5, 2018, 11:26 AM
+ */
+
+#include "tunabledependent.h"
+
+TunableDependent::TunableDependent(Tunables dependent, Tunables parent):
+ dependent(dependent),
+ parent(parent)
+{
+}
+
+TunableDependent::TunableDependent(TunableDependent &setting)
+{
+ dependent = setting.dependent;
+ parent = setting.parent;
+}
+
+TunableDependent::~TunableDependent() {
+}
+
--- /dev/null
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * File: TunableDependent.h
+ * Author: hamed
+ *
+ * Created on October 5, 2018, 11:26 AM
+ */
+
+#ifndef TUNABLEDEPENDENT_H
+#define TUNABLEDEPENDENT_H
+
+#include "tunable.h"
+
+class TunableDependent {
+public:
+ TunableDependent(Tunables dependent, Tunables parent = (Tunables) -1);
+ TunableDependent(TunableDependent &setting);
+ virtual ~TunableDependent();
+ Tunables dependent;
+ Tunables parent;
+};
+
+#endif /* TUNABLEDEPENDENT_H */
+
class TunableSetting;
class TunableDesc;
+class TunableDependent;
class OrderResolver;
class DecomposeOrderResolver;