I have a hypergraph data structure with two arrays, one for edges, and one for vertices (similar to bipartite graph). I have a problem with resizing the arrays, so I tried the simplified example:
ar dom = {0..0};
var arr: [dom] int;
writeln(arr);
dom = {0..#2};
writeln(arr);
dom = {0..#1};
writeln(arr);
record Vertex {}
record Edge {}
record Wrapper {
type nodeType;
type idType;
var id: idType;
}
record NodeData {
type nodeIdType;
var ndom = {0..-1};
var neighborList: [ndom] nodeIdType;
proc numNeighbors() return ndom.numIndices;
var lock$: sync bool = true;
// This method is not parallel-safe
proc addNodes(vals) {
lock$; // acquire lock
neighborList.push_back(vals);
lock$ = true; // release the lock
}
proc readWriteThis(f) {
f <~> new ioLiteral("{ ndom = ") <~> ndom <~> new ioLiteral(", neighborlist = ") <~> neighborList <~> new ioLiteral(", lock$ = ") <~> lock$.readFF() <~> new ioLiteral(" }");
}
}
type vType = Wrapper(Vertex, int);
type eType = Wrapper(Edge, int);
var dom1 = {0..0};
var arr1: [dom1] NodeData(eType);
writeln(arr1);
dom1 = {0..#2};
writeln(arr1);
dom1 = {0..#1};
writeln(arr1);
When I try to run this code, it hangs with the following output:
$ ./resize -nl 1
salloc: Granted job allocation 15015
0
0 0
0
{ ndom = {0..-1}, neighborlist = , lock$ = true }
So the resizing on an array of integers works perfectly fine, but I can't resize my array of records. What am I doing wrong?
As a side note, when I try to do resize domains in my complete code, I see the domains changing, but my arrays that use the domains do not change at all. At least the code does not hang though.
EDIT
I tried another example that actually illuminates my original problem better:
class Test {
var dom;
var ints: [dom] int;
proc resize(size) {
dom = {dom.low..size};
}
}
var test = new Test(dom = {0..-1});
writeln(test);
test.resize(1);
writeln(test);
Here is the output that I see:
$ ./resize -nl 1
salloc: Granted job allocation 15038
{dom = {0..-1}, ints = }
{dom = {0..1}, ints = }
salloc: Relinquishing job allocation 15038
So my problem is that the resize
method is useless. It does change the domain, but it does not change the member array.