abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fraMan.c File Reference
#include "fra.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Fra_ParamsDefault (Fra_Par_t *pPars)
 DECLARATIONS ///. More...
 
void Fra_ParamsDefaultSeq (Fra_Par_t *pPars)
 
Fra_Man_tFra_ManStart (Aig_Man_t *pManAig, Fra_Par_t *pPars)
 
void Fra_ManClean (Fra_Man_t *p, int nNodesMax)
 
Aig_Man_tFra_ManPrepareComb (Fra_Man_t *p)
 
void Fra_ManFinalizeComb (Fra_Man_t *p)
 
void Fra_ManStop (Fra_Man_t *p)
 
void Fra_ManPrint (Fra_Man_t *p)
 

Function Documentation

void Fra_ManClean ( Fra_Man_t p,
int  nNodesMax 
)

Function*************************************************************

Synopsis [Starts the fraiging manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 145 of file fraMan.c.

146 {
147  int i;
148  // remove old arrays
149  for ( i = 0; i < p->nMemAlloc; i++ )
150  if ( p->pMemFanins[i] && p->pMemFanins[i] != (void *)1 )
151  Vec_PtrFree( p->pMemFanins[i] );
152  // realloc for the new size
153  if ( p->nMemAlloc < nNodesMax )
154  {
155  int nMemAllocNew = nNodesMax + 5000;
156  p->pMemFanins = ABC_REALLOC( Vec_Ptr_t *, p->pMemFanins, nMemAllocNew );
157  p->pMemSatNums = ABC_REALLOC( int, p->pMemSatNums, nMemAllocNew );
158  p->nMemAlloc = nMemAllocNew;
159  }
160  // prepare for the new run
161  memset( p->pMemFanins, 0, sizeof(Vec_Ptr_t *) * p->nMemAlloc );
162  memset( p->pMemSatNums, 0, sizeof(int) * p->nMemAlloc );
163 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int * pMemSatNums
Definition: fra.h:216
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
Vec_Ptr_t ** pMemFanins
Definition: fra.h:215
int nMemAlloc
Definition: fra.h:217
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Fra_ManFinalizeComb ( Fra_Man_t p)

Function*************************************************************

Synopsis [Finalizes the combinational miter after fraiging.]

Description []

SideEffects []

SeeAlso []

Definition at line 217 of file fraMan.c.

218 {
219  Aig_Obj_t * pObj;
220  int i;
221  // add the POs
222  Aig_ManForEachCo( p->pManAig, pObj, i )
223  Aig_ObjCreateCo( p->pManFraig, Fra_ObjChild0Fra(pObj,0) );
224  // postprocess
225  Aig_ManCleanMarkB( p->pManFraig );
226 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
Aig_Man_t * pManAig
Definition: fra.h:191
void Aig_ManCleanMarkB(Aig_Man_t *p)
Definition: aigUtil.c:167
static Aig_Obj_t * Fra_ObjChild0Fra(Aig_Obj_t *pObj, int i)
Definition: fra.h:272
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
Definition: aig.h:69
Aig_Man_t* Fra_ManPrepareComb ( Fra_Man_t p)

Function*************************************************************

Synopsis [Prepares the new manager to begin fraiging.]

Description []

SideEffects []

SeeAlso []

Definition at line 176 of file fraMan.c.

177 {
178  Aig_Man_t * pManFraig;
179  Aig_Obj_t * pObj;
180  int i;
181  assert( p->pManFraig == NULL );
182  // start the fraig package
183  pManFraig = Aig_ManStart( Aig_ManObjNumMax(p->pManAig) );
184  pManFraig->pName = Abc_UtilStrsav( p->pManAig->pName );
185  pManFraig->pSpec = Abc_UtilStrsav( p->pManAig->pSpec );
186  pManFraig->nRegs = p->pManAig->nRegs;
187  pManFraig->nAsserts = p->pManAig->nAsserts;
188  // set the pointers to the available fraig nodes
189  Fra_ObjSetFraig( Aig_ManConst1(p->pManAig), 0, Aig_ManConst1(pManFraig) );
190  Aig_ManForEachCi( p->pManAig, pObj, i )
191  Fra_ObjSetFraig( pObj, 0, Aig_ObjCreateCi(pManFraig) );
192  // set the pointers to the manager
193  Aig_ManForEachObj( pManFraig, pObj, i )
194  pObj->pData = p;
195  // allocate memory for mapping FRAIG nodes into SAT numbers and fanins
196  p->nMemAlloc = p->nSizeAlloc;
197  p->pMemFanins = ABC_ALLOC( Vec_Ptr_t *, p->nMemAlloc );
198  memset( p->pMemFanins, 0, sizeof(Vec_Ptr_t *) * p->nMemAlloc );
199  p->pMemSatNums = ABC_ALLOC( int, p->nMemAlloc );
200  memset( p->pMemSatNums, 0, sizeof(int) * p->nMemAlloc );
201  // make sure the satisfying assignment is node assigned
202  assert( pManFraig->pData == NULL );
203  return pManFraig;
204 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Aig_Man_t * pManAig
Definition: fra.h:191
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void Fra_ObjSetFraig(Aig_Obj_t *pObj, int i, Aig_Obj_t *pNode)
Definition: fra.h:261
Aig_Man_t * pManFraig
Definition: fra.h:192
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define assert(ex)
Definition: util_old.h:213
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
void Fra_ManPrint ( Fra_Man_t p)

Function*************************************************************

Synopsis [Prints stats for the fraiging manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 278 of file fraMan.c.

279 {
280  double nMemory = 1.0*Aig_ManObjNumMax(p->pManAig)*(p->pSml->nWordsTotal*sizeof(unsigned)+6*sizeof(void*))/(1<<20);
281  printf( "SimWord = %d. Round = %d. Mem = %0.2f MB. LitBeg = %d. LitEnd = %d. (%6.2f %%).\n",
282  p->pPars->nSimWords, p->pSml->nSimRounds, nMemory, p->nLitsBeg, p->nLitsEnd, 100.0*p->nLitsEnd/(p->nLitsBeg?p->nLitsBeg:1) );
283  printf( "Proof = %d. Cex = %d. Fail = %d. FailReal = %d. C-lim = %d. ImpRatio = %6.2f %%\n",
284  p->nSatProof, p->nSatCallsSat, p->nSatFails, p->nSatFailsReal, p->pPars->nBTLimitNode, Fra_ImpComputeStateSpaceRatio(p) );
285  printf( "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n",
286  p->nNodesBeg, p->nNodesEnd, 100.0*(p->nNodesBeg-p->nNodesEnd)/(p->nNodesBeg?p->nNodesBeg:1),
287  p->nRegsBeg, p->nRegsEnd, 100.0*(p->nRegsBeg-p->nRegsEnd)/(p->nRegsBeg?p->nRegsBeg:1) );
288  if ( p->pSat ) Sat_SolverPrintStats( stdout, p->pSat );
289  if ( p->pPars->fUse1Hot ) Fra_OneHotEstimateCoverage( p, p->vOneHots );
290  ABC_PRT( "AIG simulation ", p->pSml->timeSim );
291  ABC_PRT( "AIG traversal ", p->timeTrav );
292  if ( p->timeRwr )
293  {
294  ABC_PRT( "AIG rewriting ", p->timeRwr );
295  }
296  ABC_PRT( "SAT solving ", p->timeSat );
297  ABC_PRT( " Unsat ", p->timeSatUnsat );
298  ABC_PRT( " Sat ", p->timeSatSat );
299  ABC_PRT( " Fail ", p->timeSatFail );
300  ABC_PRT( "Class refining ", p->timeRef );
301  ABC_PRT( "TOTAL RUNTIME ", p->timeTotal );
302  if ( p->time1 ) { ABC_PRT( "time1 ", p->time1 ); }
303  if ( p->nSpeculs )
304  printf( "Speculations = %d.\n", p->nSpeculs );
305  fflush( stdout );
306 }
int nSatProof
Definition: fra.h:231
Aig_Man_t * pManAig
Definition: fra.h:191
abctime timeSatSat
Definition: fra.h:245
void Fra_OneHotEstimateCoverage(Fra_Man_t *p, Vec_Int_t *vOneHots)
Definition: fraHot.c:328
int timeSim
Definition: fra.h:181
int nRegsBeg
Definition: fra.h:226
Fra_Par_t * pPars
Definition: fra.h:189
sat_solver * pSat
Definition: fra.h:210
abctime time1
Definition: fra.h:249
Fra_Sml_t * pSml
Definition: fra.h:200
Vec_Int_t * vOneHots
Definition: fra.h:208
abctime timeRwr
Definition: fra.h:242
abctime timeTrav
Definition: fra.h:241
int nLitsEnd
Definition: fra.h:223
abctime timeSat
Definition: fra.h:243
int nRegsEnd
Definition: fra.h:227
int nSpeculs
Definition: fra.h:234
int nNodesBeg
Definition: fra.h:224
int nWordsTotal
Definition: fra.h:177
abctime timeTotal
Definition: fra.h:248
abctime timeSatFail
Definition: fra.h:246
int nSatFails
Definition: fra.h:232
abctime timeSatUnsat
Definition: fra.h:244
int nSatFailsReal
Definition: fra.h:233
double Fra_ImpComputeStateSpaceRatio(Fra_Man_t *p)
Definition: fraImp.c:628
abctime timeRef
Definition: fra.h:247
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
int nNodesEnd
Definition: fra.h:225
int nSimRounds
Definition: fra.h:180
#define ABC_PRT(a, t)
Definition: abc_global.h:220
void Sat_SolverPrintStats(FILE *pFile, sat_solver *p)
Definition: satUtil.c:188
int nSatCallsSat
Definition: fra.h:229
int nLitsBeg
Definition: fra.h:222
Fra_Man_t* Fra_ManStart ( Aig_Man_t pManAig,
Fra_Par_t pPars 
)

Function*************************************************************

Synopsis [Starts the fraiging manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 104 of file fraMan.c.

105 {
106  Fra_Man_t * p;
107  Aig_Obj_t * pObj;
108  int i;
109  // allocate the fraiging manager
110  p = ABC_ALLOC( Fra_Man_t, 1 );
111  memset( p, 0, sizeof(Fra_Man_t) );
112  p->pPars = pPars;
113  p->pManAig = pManAig;
114  p->nSizeAlloc = Aig_ManObjNumMax( pManAig );
115  p->nFramesAll = pPars->nFramesK + 1;
116  // allocate storage for sim pattern
117  p->nPatWords = Abc_BitWordNum( (Aig_ManCiNum(pManAig) - Aig_ManRegNum(pManAig)) * p->nFramesAll + Aig_ManRegNum(pManAig) );
118  p->pPatWords = ABC_ALLOC( unsigned, p->nPatWords );
119  p->vPiVars = Vec_PtrAlloc( 100 );
120  // equivalence classes
121  p->pCla = Fra_ClassesStart( pManAig );
122  // allocate other members
124  memset( p->pMemFraig, 0, sizeof(Aig_Obj_t *) * p->nSizeAlloc * p->nFramesAll );
125  // set random number generator
126 // srand( 0xABCABC );
127  Aig_ManRandom(1);
128  // set the pointer to the manager
129  Aig_ManForEachObj( p->pManAig, pObj, i )
130  pObj->pData = p;
131  return p;
132 }
char * memset()
Aig_Man_t * pManAig
Definition: fra.h:191
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Fra_Cla_t * Fra_ClassesStart(Aig_Man_t *pAig)
FUNCTION DEFINITIONS ///.
Definition: fraClass.c:60
Fra_Cla_t * pCla
Definition: fra.h:198
Fra_Par_t * pPars
Definition: fra.h:189
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
unsigned Aig_ManRandom(int fReset)
Definition: aigUtil.c:1157
int nFramesAll
Definition: fra.h:194
unsigned * pPatWords
Definition: fra.h:205
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
int nSizeAlloc
Definition: fra.h:196
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Aig_Obj_t ** pMemFraig
Definition: fra.h:195
int nPatWords
Definition: fra.h:204
static int Abc_BitWordNum(int nBits)
Definition: abc_global.h:255
Vec_Ptr_t * vPiVars
Definition: fra.h:212
void Fra_ManStop ( Fra_Man_t p)

Function*************************************************************

Synopsis [Stops the fraiging manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 240 of file fraMan.c.

241 {
242  if ( p->pPars->fVerbose )
243  Fra_ManPrint( p );
244  // save mapping from original nodes into FRAIG nodes
245  if ( p->pManAig )
246  {
247  if ( p->pManAig->pObjCopies )
248  ABC_FREE( p->pManAig->pObjCopies );
249  p->pManAig->pObjCopies = p->pMemFraig;
250  p->pMemFraig = NULL;
251  }
252  Fra_ManClean( p, 0 );
253  if ( p->vTimeouts ) Vec_PtrFree( p->vTimeouts );
254  if ( p->vPiVars ) Vec_PtrFree( p->vPiVars );
255  if ( p->pSat ) sat_solver_delete( p->pSat );
256  if ( p->pCla ) Fra_ClassesStop( p->pCla );
257  if ( p->pSml ) Fra_SmlStop( p->pSml );
258  if ( p->vCex ) Vec_IntFree( p->vCex );
259  if ( p->vOneHots ) Vec_IntFree( p->vOneHots );
260  ABC_FREE( p->pMemFraig );
261  ABC_FREE( p->pMemFanins );
262  ABC_FREE( p->pMemSatNums );
263  ABC_FREE( p->pPatWords );
264  ABC_FREE( p );
265 }
void Fra_ManPrint(Fra_Man_t *p)
Definition: fraMan.c:278
int * pMemSatNums
Definition: fra.h:216
Aig_Man_t * pManAig
Definition: fra.h:191
Fra_Cla_t * pCla
Definition: fra.h:198
Fra_Par_t * pPars
Definition: fra.h:189
sat_solver * pSat
Definition: fra.h:210
Fra_Sml_t * pSml
Definition: fra.h:200
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
Vec_Int_t * vOneHots
Definition: fra.h:208
Vec_Ptr_t ** pMemFanins
Definition: fra.h:215
unsigned * pPatWords
Definition: fra.h:205
Vec_Ptr_t * vTimeouts
Definition: fra.h:218
void Fra_ManClean(Fra_Man_t *p, int nNodesMax)
Definition: fraMan.c:145
Vec_Int_t * vCex
Definition: fra.h:206
void Fra_ClassesStop(Fra_Cla_t *p)
Definition: fraClass.c:90
#define ABC_FREE(obj)
Definition: abc_global.h:232
Aig_Obj_t ** pMemFraig
Definition: fra.h:195
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Vec_Ptr_t * vPiVars
Definition: fra.h:212
void Fra_SmlStop(Fra_Sml_t *p)
Definition: fraSim.c:839
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
ABC_NAMESPACE_IMPL_START void Fra_ParamsDefault ( Fra_Par_t pPars)

DECLARATIONS ///.

CFile****************************************************************

FileName [fraMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [New FRAIG package.]

Synopsis [Starts the FRAIG manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 30, 2007.]

Revision [

Id:
fraMan.c,v 1.00 2007/06/30 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Sets the default solving parameters.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file fraMan.c.

46 {
47  memset( pPars, 0, sizeof(Fra_Par_t) );
48  pPars->nSimWords = 32; // the number of words in the simulation info
49  pPars->dSimSatur = 0.005; // the ratio of refined classes when saturation is reached
50  pPars->fPatScores = 0; // enables simulation pattern scoring
51  pPars->MaxScore = 25; // max score after which resimulation is used
52  pPars->fDoSparse = 1; // skips sparse functions
53 // pPars->dActConeRatio = 0.05; // the ratio of cone to be bumped
54 // pPars->dActConeBumpMax = 5.0; // the largest bump of activity
55  pPars->dActConeRatio = 0.3; // the ratio of cone to be bumped
56  pPars->dActConeBumpMax = 10.0; // the largest bump of activity
57  pPars->nBTLimitNode = 100; // conflict limit at a node
58  pPars->nBTLimitMiter = 500000; // conflict limit at an output
59  pPars->nFramesK = 0; // the number of timeframes to unroll
60  pPars->fConeBias = 1;
61  pPars->fRewrite = 0;
62 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Fra_Par_t_ Fra_Par_t
INCLUDES ///.
Definition: fra.h:53
void Fra_ParamsDefaultSeq ( Fra_Par_t pPars)

Function*************************************************************

Synopsis [Sets the default solving parameters.]

Description []

SideEffects []

SeeAlso []

Definition at line 75 of file fraMan.c.

76 {
77  memset( pPars, 0, sizeof(Fra_Par_t) );
78  pPars->nSimWords = 1; // the number of words in the simulation info
79  pPars->dSimSatur = 0.005; // the ratio of refined classes when saturation is reached
80  pPars->fPatScores = 0; // enables simulation pattern scoring
81  pPars->MaxScore = 25; // max score after which resimulation is used
82  pPars->fDoSparse = 1; // skips sparse functions
83  pPars->dActConeRatio = 0.3; // the ratio of cone to be bumped
84  pPars->dActConeBumpMax = 10.0; // the largest bump of activity
85  pPars->nBTLimitNode = 10000000; // conflict limit at a node
86  pPars->nBTLimitMiter = 500000; // conflict limit at an output
87  pPars->nFramesK = 1; // the number of timeframes to unroll
88  pPars->fConeBias = 0;
89  pPars->fRewrite = 0;
90  pPars->fLatchCorr = 0;
91 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Fra_Par_t_ Fra_Par_t
INCLUDES ///.
Definition: fra.h:53