[buddy] get rid of many recursive algorithms
This patch addresses the BuDDy part of #396, reported by Florian Renkin and Reed Oei. * src/kernel.c, src/kernel.h: Declare a bddrecstack and associated macros. Resize it when new variable are declared. * src/cache.h: Add a BddCache_index macro. * src/bddop.c (not_rec, apply_rec, quant_rec, appquant_rec, support_rec, ite_rec, compose_rec, restrict_rec, satone_rec, satoneset_rec): Rewrite using this stack to get rid of the recursion.
This commit is contained in:
parent
d7b3d05e57
commit
6f76121b89
4 changed files with 856 additions and 520 deletions
|
|
@ -45,7 +45,6 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include "kernel.h"
|
||||
#include "cache.h"
|
||||
#include "prime.h"
|
||||
|
||||
/*************************************************************************
|
||||
|
|
@ -103,6 +102,8 @@ jmp_buf bddexception; /* Long-jump point for interrupting calc. */
|
|||
int bddresized; /* Flag indicating a resize of the nodetable */
|
||||
int bddcachesize; /* Size of the operator caches */
|
||||
int bddhashsize; /* Size of the BDD node hash */
|
||||
int* bddrecstack; /* Internal recursion stack */
|
||||
int* bddrecstacktop; /* Internal recursion stack top */
|
||||
|
||||
bddCacheStat bddcachestats;
|
||||
|
||||
|
|
@ -273,6 +274,7 @@ void bdd_done(void)
|
|||
|
||||
free(bddnodes);
|
||||
free(bddrefstack);
|
||||
free(bddrecstack);
|
||||
free(bddvarset);
|
||||
free(bddvar2level);
|
||||
free(bddlevel2var);
|
||||
|
|
@ -280,6 +282,7 @@ void bdd_done(void)
|
|||
|
||||
bddnodes = NULL;
|
||||
bddrefstack = NULL;
|
||||
bddrecstack = NULL;
|
||||
bddvarset = NULL;
|
||||
|
||||
bdd_operator_done();
|
||||
|
|
@ -374,7 +377,11 @@ int bdd_setvarnum(int num)
|
|||
|
||||
if (__likely(bddrefstack != NULL))
|
||||
free(bddrefstack);
|
||||
bddrefstack = bddrefstacktop = (int*)malloc(sizeof(int)*(num*2+4));
|
||||
bddrefstack = bddrefstacktop = (int*)malloc(sizeof(int)*((num+2)*2));
|
||||
|
||||
if (__likely(bddrecstack != NULL))
|
||||
free(bddrecstack);
|
||||
bddrecstack = bddrecstacktop = (int*)malloc(sizeof(int)*((num+1)*9));
|
||||
|
||||
for(bdv=bddvarnum ; bddvarnum < num; bddvarnum++)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue