Off by 1 bug
authorbdemsky <bdemsky@uci.edu>
Fri, 20 Oct 2017 21:41:42 +0000 (14:41 -0700)
committerbdemsky <bdemsky@uci.edu>
Fri, 20 Oct 2017 21:41:42 +0000 (14:41 -0700)
src/ASTAnalyses/Encoding/encodinggraph.cc
src/ASTAnalyses/Encoding/subgraph.h
src/Encoders/elementencoding.cc

index abbaf29..5416ed0 100644 (file)
@@ -73,12 +73,15 @@ void EncodingGraph::encode() {
                                        EncodingSubGraph *subgraph = graphMap.get(n);
                                        if (subgraph == NULL)
                                                continue;
                                        EncodingSubGraph *subgraph = graphMap.get(n);
                                        if (subgraph == NULL)
                                                continue;
-                                       uint encodingSize = subgraph->getEncodingSize(n);
+                                       uint encodingSize = subgraph->getEncodingMaxVal(n)+1;
                                        uint paddedSize = encoding->getSizeEncodingArray(encodingSize);
                                        uint paddedSize = encoding->getSizeEncodingArray(encodingSize);
+                                       model_print("encoding size=%u\n", encodingSize);
+                                       model_print("padded=%u\n", paddedSize);
                                        encoding->allocInUseArrayElement(paddedSize);
                                        encoding->allocEncodingArrayElement(paddedSize);
                                        Set *s = e->getRange();
                                        for (uint i = 0; i < s->getSize(); i++) {
                                        encoding->allocInUseArrayElement(paddedSize);
                                        encoding->allocEncodingArrayElement(paddedSize);
                                        Set *s = e->getRange();
                                        for (uint i = 0; i < s->getSize(); i++) {
+                                               model_print("index=%u\n", i);
                                                uint64_t value = s->getElement(i);
                                                uint encodingIndex = subgraph->getEncoding(n, value);
                                                encoding->setInUseElement(encodingIndex);
                                                uint64_t value = s->getElement(i);
                                                uint encodingIndex = subgraph->getEncoding(n, value);
                                                encoding->setInUseElement(encodingIndex);
index 36f1902..c9aaa0c 100644 (file)
@@ -41,7 +41,7 @@ public:
        SetIteratorEncodingNode *nodeIterator();
        void encode();
        uint getEncoding(EncodingNode *n, uint64_t val);
        SetIteratorEncodingNode *nodeIterator();
        void encode();
        uint getEncoding(EncodingNode *n, uint64_t val);
-       uint getEncodingSize(EncodingNode *n) { return maxEncodingVal;}
+       uint getEncodingMaxVal(EncodingNode *n) { return maxEncodingVal;}
 
        CMEMALLOC;
 private:
 
        CMEMALLOC;
 private:
index da6efd1..19439dc 100644 (file)
@@ -57,7 +57,7 @@ void ElementEncoding::print() {
        if (type == BINARYINDEX) {
                for (uint i = 0; i < encArraySize; i++) {
                        if (i != 0)
        if (type == BINARYINDEX) {
                for (uint i = 0; i < encArraySize; i++) {
                        if (i != 0)
-                               model_print(" ,");
+                               model_print("");
                        if (isinUseElement(i))
                                model_print("%" PRIu64 "", encodingArray[i]);
                        else
                        if (isinUseElement(i))
                                model_print("%" PRIu64 "", encodingArray[i]);
                        else