summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-12-06 19:34:05 -0800
committerOri Bernstein <ori@eigenstate.org>2016-12-06 19:34:05 -0800
commit822da329297079d473f20a6fe14c7c2d712cdc83 (patch)
treee508b662c8a3702a1e41c63eed84c4ae6a9c7481 /6
parentd495c764a13dbc06ff3fbdd5254123b5125f4dd1 (diff)
downloadmc-822da329297079d473f20a6fe14c7c2d712cdc83.tar.gz
Grow the adjacency lists incrementally.
We don't need to waste *THAT* much RAM on them.
Diffstat (limited to '6')
-rw-r--r--6/asm.h1
-rw-r--r--6/ra.c7
2 files changed, 6 insertions, 2 deletions
diff --git a/6/asm.h b/6/asm.h
index 83b3a98..f5edae7 100644
--- a/6/asm.h
+++ b/6/asm.h
@@ -190,6 +190,7 @@ struct Isel {
size_t *gbits; /* igraph matrix repr */
regid **gadj; /* igraph adj set repr */
size_t *ngadj;
+ size_t *gadjsz;
size_t nreg; /* maxregid at time of alloc */
int *degree; /* degree of nodes */
int *nuses; /* number of uses of nodes */
diff --git a/6/ra.c b/6/ra.c
index 71c3a19..b80e0fc 100644
--- a/6/ra.c
+++ b/6/ra.c
@@ -371,8 +371,10 @@ static int degreechange(Isel *s, regid u, regid v)
static void alputedge(Isel *s, regid u, regid v)
{
- if (!s->gadj[u])
- s->gadj[u] = xalloc(maxregid*sizeof(regid));
+ if (s->ngadj[u] == s->gadjsz[u]) {
+ s->gadjsz[u] = s->gadjsz[u]*2 + 1;
+ s->gadj[u] = xrealloc(s->gadj[u], s->gadjsz[u]*sizeof(regid));
+ }
s->gadj[u][s->ngadj[u]] = v;
s->ngadj[u]++;
}
@@ -444,6 +446,7 @@ static void setup(Isel *s)
/* fresh adj list repr. */
s->gadj = zalloc(s->nreg * sizeof(regid*));
s->ngadj = zalloc(s->nreg * sizeof(size_t));
+ s->gadjsz = zalloc(s->nreg * sizeof(size_t));
s->mactiveset = bsclear(s->mactiveset);
s->wlmoveset = bsclear(s->wlmoveset);