Fixing the performance bug
authorHamed Gorjiara <hgorjiar@uci.edu>
Wed, 22 Nov 2017 19:28:14 +0000 (11:28 -0800)
committerHamed Gorjiara <hgorjiar@uci.edu>
Wed, 22 Nov 2017 19:28:14 +0000 (11:28 -0800)
src/ASTAnalyses/Order/orderanalysis.cc
src/ASTAnalyses/Order/ordergraph.cc
src/ASTAnalyses/Order/ordernode.cc
src/ASTAnalyses/Order/ordernode.h
src/ASTTransform/decomposeordertransform.cc
src/Backend/constraint.cc
src/Collections/structs.cc
src/Collections/structs.h
src/classlist.h

index 7e3e030..8a991a4 100644 (file)
@@ -50,7 +50,7 @@ void DFSClearContradictions(CSolver *solver, OrderGraph *graph, HashtableNodeToN
                        //Compute full transitive closure for nodes
                        SetIteratorOrderNode *srciterator = sources->iterator();
                        while (srciterator->hasNext()) {
-                               OrderNode *srcnode = srciterator->next();
+                               OrderNode *srcnode = (OrderNode*)srciterator->next();
                                OrderEdge *newedge = graph->getOrderEdgeFromOrderGraph(srcnode, node);
                                newedge->mustPos = true;
                                newedge->polPos = true;
index 85a0207..9f50949 100644 (file)
@@ -117,7 +117,7 @@ void OrderGraph::addMustOrderEdge(OrderNode *node1, OrderNode *node2, BooleanOrd
 
 OrderNode *OrderGraph::getOrderNodeFromOrderGraph(uint64_t id) {
        OrderNode *node = new OrderNode(id);
-       OrderNode *tmp = nodes.get(node);
+       OrderNode *tmp = (OrderNode*)nodes.get(node);
        if ( tmp != NULL) {
                delete node;
                node = tmp;
@@ -128,8 +128,8 @@ OrderNode *OrderGraph::getOrderNodeFromOrderGraph(uint64_t id) {
 }
 
 OrderNode *OrderGraph::lookupOrderNodeFromOrderGraph(uint64_t id) {
-       OrderNode node(id);
-       OrderNode *tmp = nodes.get(&node);
+       OrderNodeKey node(id);
+       OrderNode *tmp = (OrderNode*)nodes.get(&node);
        return tmp;
 }
 
@@ -225,7 +225,7 @@ bool OrderGraph::isTherePathVisit(HashsetOrderNode &visited, OrderNode *current,
 void OrderGraph::DFS(Vector<OrderNode *> *finishNodes) {
        SetIteratorOrderNode *iterator = getNodes();
        while (iterator->hasNext()) {
-               OrderNode *node = iterator->next();
+               OrderNode *node = (OrderNode*)iterator->next();
                if (node->status == NOTVISITED && !node->removed) {
                        node->status = VISITED;
                        DFSNodeVisit(node, finishNodes, false, false, 0);
@@ -239,7 +239,7 @@ void OrderGraph::DFS(Vector<OrderNode *> *finishNodes) {
 void OrderGraph::DFSMust(Vector<OrderNode *> *finishNodes) {
        SetIteratorOrderNode *iterator = getNodes();
        while (iterator->hasNext()) {
-               OrderNode *node = iterator->next();
+               OrderNode *node = (OrderNode*)iterator->next();
                if (node->status == NOTVISITED && !node->removed) {
                        node->status = VISITED;
                        DFSNodeVisit(node, finishNodes, false, true, 0);
@@ -294,7 +294,7 @@ void OrderGraph::DFSNodeVisit(OrderNode *node, Vector<OrderNode *> *finishNodes,
 void OrderGraph::resetNodeInfoStatusSCC() {
        SetIteratorOrderNode *iterator = getNodes();
        while (iterator->hasNext()) {
-               iterator->next()->status = NOTVISITED;
+               ((OrderNode*)iterator->next())->status = NOTVISITED;
        }
        delete iterator;
 }
index 41b11a5..9382f32 100644 (file)
@@ -2,7 +2,7 @@
 #include "orderedge.h"
 
 OrderNode::OrderNode(uint64_t _id) :
-       id(_id),
+       OrderNodeKey(_id),
        status(NOTVISITED),
        removed(false),
        sccNum(0),
index a9bc1d3..4a40466 100644 (file)
 enum NodeStatus {NOTVISITED, VISITED, FINISHED, ADDEDTOSET};
 typedef enum NodeStatus NodeStatus;
 
-class OrderNode {
+class OrderNodeKey{
+public:
+    OrderNodeKey(uint64_t id) : id(id){}
+    virtual ~OrderNodeKey(){}
+    uint64_t getID() {return id;}
+    uint64_t id;
+};
+
+class OrderNode : public OrderNodeKey {
 public:
        OrderNode(uint64_t id);
+        virtual ~OrderNode(){}
        void addNewIncomingEdge(OrderEdge *edge);
        void addNewOutgoingEdge(OrderEdge *edge);
-       uint64_t getID() {return id;}
 
-       uint64_t id;
        NodeStatus status;
        bool removed;
        uint sccNum;
index f629a76..525a03c 100644 (file)
@@ -244,7 +244,7 @@ void DecomposeOrderTransform::bypassMustBeTrueNode(OrderGraph *graph, OrderNode
 void DecomposeOrderTransform::removeMustBeTrueNodes(OrderGraph *graph, DecomposeOrderResolver *dor) {
        SetIteratorOrderNode *iterator = graph->getNodes();
        while (iterator->hasNext()) {
-               OrderNode *node = iterator->next();
+               OrderNode *node = (OrderNode*)iterator->next();
                if (node->removed)
                        continue;
                if (isMustBeTrueNode(node)) {
@@ -257,7 +257,7 @@ void DecomposeOrderTransform::removeMustBeTrueNodes(OrderGraph *graph, Decompose
 void DecomposeOrderTransform::mustEdgePrune(OrderGraph *graph, DecomposeOrderResolver *dor) {
        SetIteratorOrderNode *iterator = graph->getNodes();
        while (iterator->hasNext()) {
-               OrderNode *node = iterator->next();
+               OrderNode *node = (OrderNode*)iterator->next();
                if (node->removed)
                        continue;
                attemptNodeMerge(graph, node, dor);
index 0fe3d45..356b415 100644 (file)
@@ -351,8 +351,9 @@ int solveCNF(CNF *cnf) {
        int result = solve(cnf->solver);
        long long finishTime = getTimeNano();
        cnf->encodeTime = startSolve - startTime;
+        model_print("CNF Encode time: %f\n", cnf->encodeTime/1000000000.0);
        cnf->solveTime = finishTime - startSolve;
-       model_print("CNF Encode time: %f\n Solve time: %f\n", cnf->encodeTime/1000000000.0, cnf->solveTime/ 1000000000.0);
+       model_print("Solve time: %f\n", cnf->solveTime/ 1000000000.0);
        return result;
 }
 
index 4e2827c..ac69f9d 100644 (file)
@@ -29,11 +29,11 @@ bool table_entry_equals(TableEntry *key1, TableEntry *key2) {
        return true;
 }
 
-unsigned int order_node_hash_function(OrderNode *This) {
+unsigned int order_node_hash_function(OrderNodeKey *This) {
        return (uint) This->id;
 }
 
-bool order_node_equals(OrderNode *key1, OrderNode *key2) {
+bool order_node_equals(OrderNodeKey *key1, OrderNodeKey *key2) {
        return key1->id == key2->id;
 }
 
index 2515f8f..9fa23bc 100644 (file)
@@ -10,8 +10,8 @@
 
 unsigned int table_entry_hash_function(TableEntry *This);
 bool table_entry_equals(TableEntry *key1, TableEntry *key2);
-unsigned int order_node_hash_function(OrderNode *This);
-bool order_node_equals(OrderNode *key1, OrderNode *key2);
+unsigned int order_node_hash_function(OrderNodeKey *This);
+bool order_node_equals(OrderNodeKey *key1, OrderNodeKey *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);
@@ -24,7 +24,7 @@ bool doredge_equals(DOREdge *key1, DOREdge *key2);
 
 
 typedef Hashset<TableEntry *, uintptr_t, PTRSHIFT, table_entry_hash_function, table_entry_equals> HashsetTableEntry;
-typedef Hashset<OrderNode *, uintptr_t, PTRSHIFT, order_node_hash_function, order_node_equals> HashsetOrderNode;
+typedef Hashset<OrderNodeKey *, uintptr_t, PTRSHIFT, order_node_hash_function, order_node_equals> HashsetOrderNode;
 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;
@@ -35,7 +35,7 @@ typedef Hashset<uint64_t, uint64_t, 0> Hashset64Int;
 typedef SetIterator<uint64_t, uint64_t, 0> SetIterator64Int;
 
 
-typedef Hashtable<OrderNode *, HashsetOrderNode *, uintptr_t, PTRSHIFT> HashtableNodeToNodeSet;
+typedef Hashtable<OrderNodeKey *, HashsetOrderNode *, uintptr_t, PTRSHIFT> HashtableNodeToNodeSet;
 typedef Hashtable<OrderPair *, OrderPair *, uintptr_t, PTRSHIFT, order_pair_hash_function, order_pair_equals> HashtableOrderPair;
 typedef Hashtable<void *, void *, uintptr_t, PTRSHIFT> CloneMap;
 
@@ -45,7 +45,7 @@ typedef Hashtable<Set *, EncodingNode *, uintptr_t, PTRSHIFT> HashtableEncoding;
 
 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<OrderNode *, uintptr_t, PTRSHIFT, order_node_hash_function, order_node_equals> SetIteratorOrderNode;
+typedef SetIterator<OrderNodeKey *, uintptr_t, PTRSHIFT, order_node_hash_function, order_node_equals> SetIteratorOrderNode;
 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
index bb102ad..fee6d9b 100644 (file)
@@ -51,6 +51,7 @@ class FunctionEncoding;
 class OrderEncoding;
 
 class OrderGraph;
+class OrderNodeKey;
 class OrderNode;
 class OrderEdge;
 class DOREdge;