pnnl / chgl

Chapel HyperGraph Library (CHGL) - HPC-class Hypergraphs in Chapel
https://pnnl.github.io/chgl/
MIT License
29 stars 8 forks source link

*Fix* Array out of bounds error #47

Closed mandysack closed 5 years ago

mandysack commented 5 years ago

Problem: In the test.chpl file would go to Collapse Vertices, it would be looking for duplicates.

    writeln("Marking and Deleting Vertices...");
            var vertexSetDomain : domain(ArrayWrapper);
            var vertexSet : [vertexSetDomain] int;
            var l$ : sync bool;
            var numUnique : int;
            forall v in _verticesDomain with (+ reduce numUnique, ref vertexSetDomain, ref vertexSet) {
              var tmp = [e in _vertices[v].incident[0..#_vertices[v].degree]] e.id;
              var vertexArr = new ArrayWrapper();
              vertexArr.dom = {0..#_vertices[v].degree};
              **vertexArr.arr = tmp;**

When it would try to set the vertexArr.arr to tmp it would get an error chgl/src/modules/AdjListHyperGraph.chpl:521: error: halt reached - array index out of bounds: (3) To solve this issue, we added a check to see if the a.arr.size was >= than the b.arr.size to remove the error.

   proc ==(a: ArrayWrapper, b: ArrayWrapper) {
   +    if a.arr.size >= b.arr.size {
   +       return || reduce (b.arr == a.arr) ;
   +    }
        return && reduce (a.arr == b.arr);
   }
LouisJenkinsCS commented 5 years ago

Thanks for the patch!