ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
rwr.h File Reference
#include "base/abc/abc.h"
#include "opt/cut/cut.h"
Include dependency graph for rwr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Rwr_Man_t_
 
struct  Rwr_Node_t_
 

Macros

#define RWR_LIMIT   1048576/4
 INCLUDES ///.
 

Typedefs

typedef struct Rwr_Man_t_ Rwr_Man_t
 
typedef struct Rwr_Node_t_ Rwr_Node_t
 

Functions

void Rwr_ManPreprocess (Rwr_Man_t *p)
 MACRO DEFINITIONS ///.
 
int Rwr_NodeRewrite (Rwr_Man_t *p, Cut_Man_t *pManCut, Abc_Obj_t *pNode, int fUpdateLevel, int fUseZeros, int fPlaceEnable)
 FUNCTION DEFINITIONS ///.
 
void Rwr_ScoresClean (Rwr_Man_t *p)
 
void Rwr_ScoresReport (Rwr_Man_t *p)
 
void Rwr_ManPrecompute (Rwr_Man_t *p)
 FUNCTION DEFINITIONS ///.
 
Rwr_Node_tRwr_ManAddVar (Rwr_Man_t *p, unsigned uTruth, int fPrecompute)
 
Rwr_Node_tRwr_ManAddNode (Rwr_Man_t *p, Rwr_Node_t *p0, Rwr_Node_t *p1, int fExor, int Level, int Volume)
 
int Rwr_ManNodeVolume (Rwr_Man_t *p, Rwr_Node_t *p0, Rwr_Node_t *p1)
 
void Rwr_ManIncTravId (Rwr_Man_t *p)
 
Rwr_Man_tRwr_ManStart (int fPrecompute)
 DECLARATIONS ///.
 
void Rwr_ManStop (Rwr_Man_t *p)
 
void Rwr_ManPrintStats (Rwr_Man_t *p)
 
void Rwr_ManPrintStatsFile (Rwr_Man_t *p)
 
void * Rwr_ManReadDecs (Rwr_Man_t *p)
 
Vec_Ptr_tRwr_ManReadLeaves (Rwr_Man_t *p)
 
int Rwr_ManReadCompl (Rwr_Man_t *p)
 
void Rwr_ManAddTimeCuts (Rwr_Man_t *p, abctime Time)
 
void Rwr_ManAddTimeUpdate (Rwr_Man_t *p, abctime Time)
 
void Rwr_ManAddTimeTotal (Rwr_Man_t *p, abctime Time)
 
void Rwr_ManPrint (Rwr_Man_t *p)
 
void Rwr_ManWriteToArray (Rwr_Man_t *p)
 FUNCTION DEFINITIONS ///.
 
void Rwr_ManLoadFromArray (Rwr_Man_t *p, int fVerbose)
 
void Rwr_ManWriteToFile (Rwr_Man_t *p, char *pFileName)
 
void Rwr_ManLoadFromFile (Rwr_Man_t *p, char *pFileName)
 
void Rwr_ListAddToTail (Rwr_Node_t **ppList, Rwr_Node_t *pNode)
 
char * Rwr_ManGetPractical (Rwr_Man_t *p)
 

Macro Definition Documentation

◆ RWR_LIMIT

#define RWR_LIMIT   1048576/4

INCLUDES ///.

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

FileName [rwr.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [DAG-aware AIG rewriting package.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
rwr.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

] PARAMETERS /// BASIC TYPES ///

Definition at line 45 of file rwr.h.

Typedef Documentation

◆ Rwr_Man_t

typedef struct Rwr_Man_t_ Rwr_Man_t

Definition at line 47 of file rwr.h.

◆ Rwr_Node_t

typedef struct Rwr_Node_t_ Rwr_Node_t

Definition at line 48 of file rwr.h.

Function Documentation

◆ Rwr_ListAddToTail()

void Rwr_ListAddToTail ( Rwr_Node_t ** ppList,
Rwr_Node_t * pNode )
extern

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

Synopsis [Adds the node to the end of the list.]

Description []

SideEffects []

SeeAlso []

Definition at line 619 of file rwrUtil.c.

620{
621 Rwr_Node_t * pTemp;
622 // find the last one
623 for ( pTemp = *ppList; pTemp; pTemp = pTemp->pNext )
624 ppList = &pTemp->pNext;
625 // attach at the end
626 *ppList = pNode;
627}
struct Rwr_Node_t_ Rwr_Node_t
Definition rwr.h:48
Rwr_Node_t * pNext
Definition rwr.h:112
Here is the caller graph for this function:

◆ Rwr_ManAddNode()

Rwr_Node_t * Rwr_ManAddNode ( Rwr_Man_t * p,
Rwr_Node_t * p0,
Rwr_Node_t * p1,
int fExor,
int Level,
int Volume )
extern

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 206 of file rwrLib.c.

207{
208 Rwr_Node_t * pNew;
209 unsigned uTruth;
210 // compute truth table, leve, volume
211 p->nConsidered++;
212 if ( fExor )
213 uTruth = (p0->uTruth ^ p1->uTruth);
214 else
215 uTruth = (Rwr_IsComplement(p0)? ~Rwr_Regular(p0)->uTruth : Rwr_Regular(p0)->uTruth) &
216 (Rwr_IsComplement(p1)? ~Rwr_Regular(p1)->uTruth : Rwr_Regular(p1)->uTruth) & 0xFFFF;
217 // create the new node
218 pNew = (Rwr_Node_t *)Extra_MmFixedEntryFetch( p->pMmNode );
219 pNew->Id = p->vForest->nSize;
220 pNew->TravId = 0;
221 pNew->uTruth = uTruth;
222 pNew->Level = Level;
223 pNew->Volume = Volume;
224 pNew->fUsed = 0;
225 pNew->fExor = fExor;
226 pNew->p0 = p0;
227 pNew->p1 = p1;
228 pNew->pNext = NULL;
229 Vec_PtrPush( p->vForest, pNew );
230 // do not add if the node is not essential
231 if ( uTruth != p->puCanons[uTruth] )
232 return pNew;
233
234 // add to the list
235 p->nAdded++;
236 if ( p->pTable[uTruth] == NULL )
237 p->nClasses++;
238 Rwr_ListAddToTail( p->pTable + uTruth, pNew );
239 return pNew;
240}
Cube * p
Definition exorList.c:222
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
void Rwr_ListAddToTail(Rwr_Node_t **ppList, Rwr_Node_t *pNode)
Definition rwrUtil.c:619
Rwr_Node_t * p1
Definition rwr.h:111
int Id
Definition rwr.h:100
unsigned fUsed
Definition rwr.h:108
unsigned Volume
Definition rwr.h:106
Rwr_Node_t * p0
Definition rwr.h:110
unsigned fExor
Definition rwr.h:109
unsigned Level
Definition rwr.h:107
int TravId
Definition rwr.h:101
unsigned uTruth
Definition rwr.h:105
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManAddTimeCuts()

void Rwr_ManAddTimeCuts ( Rwr_Man_t * p,
abctime Time )
extern

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

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 261 of file rwrMan.c.

262{
263 p->timeCut += Time;
264}
Here is the caller graph for this function:

◆ Rwr_ManAddTimeTotal()

void Rwr_ManAddTimeTotal ( Rwr_Man_t * p,
abctime Time )
extern

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

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 293 of file rwrMan.c.

294{
295 p->timeTotal += Time;
296}
Here is the caller graph for this function:

◆ Rwr_ManAddTimeUpdate()

void Rwr_ManAddTimeUpdate ( Rwr_Man_t * p,
abctime Time )
extern

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

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 277 of file rwrMan.c.

278{
279 p->timeUpdate += Time;
280}
Here is the caller graph for this function:

◆ Rwr_ManAddVar()

Rwr_Node_t * Rwr_ManAddVar ( Rwr_Man_t * p,
unsigned uTruth,
int fPrecompute )
extern

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 253 of file rwrLib.c.

254{
255 Rwr_Node_t * pNew;
256 pNew = (Rwr_Node_t *)Extra_MmFixedEntryFetch( p->pMmNode );
257 pNew->Id = p->vForest->nSize;
258 pNew->TravId = 0;
259 pNew->uTruth = uTruth;
260 pNew->Level = 0;
261 pNew->Volume = 0;
262 pNew->fUsed = 1;
263 pNew->fExor = 0;
264 pNew->p0 = NULL;
265 pNew->p1 = NULL;
266 pNew->pNext = NULL;
267 Vec_PtrPush( p->vForest, pNew );
268 if ( fPrecompute )
269 Rwr_ListAddToTail( p->pTable + uTruth, pNew );
270 return pNew;
271}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManGetPractical()

char * Rwr_ManGetPractical ( Rwr_Man_t * p)
extern

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

Synopsis [Create practical classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 640 of file rwrUtil.c.

641{
642 char * pPractical;
643 int i;
644 pPractical = ABC_ALLOC( char, p->nFuncs );
645 memset( pPractical, 0, sizeof(char) * p->nFuncs );
646 pPractical[0] = 1;
647 for ( i = 1; ; i++ )
648 {
649 if ( s_RwrPracticalClasses[i] == 0 )
650 break;
651 pPractical[ s_RwrPracticalClasses[i] ] = 1;
652 }
653 return pPractical;
654}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManIncTravId()

void Rwr_ManIncTravId ( Rwr_Man_t * p)
extern

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 350 of file rwrLib.c.

351{
352 Rwr_Node_t * pNode;
353 int i;
354 if ( p->nTravIds++ < 0x8FFFFFFF )
355 return;
356 Vec_PtrForEachEntry( Rwr_Node_t *, p->vForest, pNode, i )
357 pNode->TravId = 0;
358 p->nTravIds = 1;
359}
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the caller graph for this function:

◆ Rwr_ManLoadFromArray()

void Rwr_ManLoadFromArray ( Rwr_Man_t * p,
int fVerbose )
extern

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

Synopsis [Loads data.]

Description []

SideEffects []

SeeAlso []

Definition at line 472 of file rwrUtil.c.

473{
474 unsigned short * pArray = s_RwtAigSubgraphs;
475 Rwr_Node_t * p0, * p1;
476 unsigned Entry0, Entry1;
477 int Level, Volume, nEntries, fExor;
478 int i;
479 abctime clk = Abc_Clock();
480
481 // reconstruct the forest
482 for ( i = 0; ; i++ )
483 {
484 Entry0 = pArray[2*i + 0];
485 Entry1 = pArray[2*i + 1];
486 if ( Entry0 == 0 && Entry1 == 0 )
487 break;
488 // get EXOR flag
489 fExor = (Entry0 & 1);
490 Entry0 >>= 1;
491 // get the nodes
492 p0 = (Rwr_Node_t *)p->vForest->pArray[Entry0 >> 1];
493 p1 = (Rwr_Node_t *)p->vForest->pArray[Entry1 >> 1];
494 // compute the level and volume of the new nodes
495 Level = 1 + Abc_MaxInt( p0->Level, p1->Level );
496 Volume = 1 + Rwr_ManNodeVolume( p, p0, p1 );
497 // set the complemented attributes
498 p0 = Rwr_NotCond( p0, (Entry0 & 1) );
499 p1 = Rwr_NotCond( p1, (Entry1 & 1) );
500 // add the node
501// Rwr_ManTryNode( p, p0, p1, Level, Volume );
502 Rwr_ManAddNode( p, p0, p1, fExor, Level, Volume + fExor );
503 }
504 nEntries = i - 1;
505 if ( fVerbose )
506 {
507 printf( "The number of classes = %d. Canonical nodes = %d.\n", p->nClasses, p->nAdded );
508 printf( "The number of nodes loaded = %d. ", nEntries ); ABC_PRT( "Loading", Abc_Clock() - clk );
509 }
510}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
Rwr_Node_t * Rwr_ManAddNode(Rwr_Man_t *p, Rwr_Node_t *p0, Rwr_Node_t *p1, int fExor, int Level, int Volume)
Definition rwrLib.c:206
int Rwr_ManNodeVolume(Rwr_Man_t *p, Rwr_Node_t *p0, Rwr_Node_t *p1)
Definition rwrLib.c:330
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManLoadFromFile()

void Rwr_ManLoadFromFile ( Rwr_Man_t * p,
char * pFileName )
extern

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

Synopsis [Loads data.]

Description []

SideEffects []

SeeAlso []

Definition at line 562 of file rwrUtil.c.

563{
564 FILE * pFile;
565 Rwr_Node_t * p0, * p1;
566 unsigned * pBuffer;
567 int Level, Volume, nEntries, fExor;
568 int i;
569 abctime clk = Abc_Clock();
570 int RetValue;
571
572 // load the data
573 pFile = fopen( pFileName, "rb" );
574 if ( pFile == NULL )
575 {
576 printf( "Rwr_ManLoadFromFile: Cannot open file \"%s\".\n", pFileName );
577 return;
578 }
579 RetValue = fread( &nEntries, sizeof(int), 1, pFile );
580 pBuffer = ABC_ALLOC( unsigned, nEntries * 2 );
581 RetValue = fread( pBuffer, sizeof(unsigned), nEntries * 2, pFile );
582 fclose( pFile );
583 // reconstruct the forest
584 for ( i = 0; i < nEntries; i++ )
585 {
586 // get EXOR flag
587 fExor = (pBuffer[2*i + 0] & 1);
588 pBuffer[2*i + 0] = (pBuffer[2*i + 0] >> 1);
589 // get the nodes
590 p0 = (Rwr_Node_t *)p->vForest->pArray[pBuffer[2*i + 0] >> 1];
591 p1 = (Rwr_Node_t *)p->vForest->pArray[pBuffer[2*i + 1] >> 1];
592 // compute the level and volume of the new nodes
593 Level = 1 + Abc_MaxInt( p0->Level, p1->Level );
594 Volume = 1 + Rwr_ManNodeVolume( p, p0, p1 );
595 // set the complemented attributes
596 p0 = Rwr_NotCond( p0, (pBuffer[2*i + 0] & 1) );
597 p1 = Rwr_NotCond( p1, (pBuffer[2*i + 1] & 1) );
598 // add the node
599// Rwr_ManTryNode( p, p0, p1, Level, Volume );
600 Rwr_ManAddNode( p, p0, p1, fExor, Level, Volume + fExor );
601 }
602 ABC_FREE( pBuffer );
603 printf( "The number of classes = %d. Canonical nodes = %d.\n", p->nClasses, p->nAdded );
604 printf( "The number of nodes loaded = %d. ", nEntries ); ABC_PRT( "Loading", Abc_Clock() - clk );
605}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the call graph for this function:

◆ Rwr_ManNodeVolume()

int Rwr_ManNodeVolume ( Rwr_Man_t * p,
Rwr_Node_t * p0,
Rwr_Node_t * p1 )
extern

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

Synopsis [Adds one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 330 of file rwrLib.c.

331{
332 int Volume = 0;
334 Rwr_Trav_rec( p, p0, &Volume );
335 Rwr_Trav_rec( p, p1, &Volume );
336 return Volume;
337}
void Rwr_Trav_rec(Rwr_Man_t *p, Rwr_Node_t *pNode, int *pVolume)
Definition rwrLib.c:307
void Rwr_ManIncTravId(Rwr_Man_t *p)
Definition rwrLib.c:350
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManPrecompute()

void Rwr_ManPrecompute ( Rwr_Man_t * p)
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Precomputes the forest in the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file rwrLib.c.

49{
50 Rwr_Node_t * p0, * p1;
51 int i, k, Level, Volume;
52 int LevelOld = -1;
53 int nNodes;
54
55 Vec_PtrForEachEntryStart( Rwr_Node_t *, p->vForest, p0, i, 1 )
56 Vec_PtrForEachEntryStart( Rwr_Node_t *, p->vForest, p1, k, 1 )
57 {
58 if ( LevelOld < (int)p0->Level )
59 {
60 LevelOld = p0->Level;
61 printf( "Starting level %d (at %d nodes).\n", LevelOld+1, i );
62 printf( "Considered = %5d M. Found = %8d. Classes = %6d. Trying %7d.\n",
63 p->nConsidered/1000000, p->vForest->nSize, p->nClasses, i );
64 }
65
66 if ( k == i )
67 break;
68// if ( p0->Level + p1->Level > 6 ) // hard
69// break;
70
71 if ( p0->Level + p1->Level > 5 ) // easy
72 break;
73
74// if ( p0->Level + p1->Level > 6 || (p0->Level == 3 && p1->Level == 3) )
75// break;
76
77 // compute the level and volume of the new nodes
78 Level = 1 + Abc_MaxInt( p0->Level, p1->Level );
79 Volume = 1 + Rwr_ManNodeVolume( p, p0, p1 );
80 // try four different AND nodes
81 Rwr_ManTryNode( p, p0 , p1 , 0, Level, Volume );
82 Rwr_ManTryNode( p, Rwr_Not(p0), p1 , 0, Level, Volume );
83 Rwr_ManTryNode( p, p0 , Rwr_Not(p1), 0, Level, Volume );
84 Rwr_ManTryNode( p, Rwr_Not(p0), Rwr_Not(p1), 0, Level, Volume );
85 // try EXOR
86 Rwr_ManTryNode( p, p0 , p1 , 1, Level, Volume + 1 );
87 // report the progress
88 if ( p->nConsidered % 50000000 == 0 )
89 printf( "Considered = %5d M. Found = %8d. Classes = %6d. Trying %7d.\n",
90 p->nConsidered/1000000, p->vForest->nSize, p->nClasses, i );
91 // quit after some time
92 if ( p->vForest->nSize == RWR_LIMIT + 5 )
93 {
94 printf( "Considered = %5d M. Found = %8d. Classes = %6d. Trying %7d.\n",
95 p->nConsidered/1000000, p->vForest->nSize, p->nClasses, i );
96 goto save;
97 }
98 }
99save :
100
101 // mark the relevant ones
103 k = 5;
104 nNodes = 0;
105 Vec_PtrForEachEntryStart( Rwr_Node_t *, p->vForest, p0, i, 5 )
106 if ( p0->uTruth == p->puCanons[p0->uTruth] )
107 {
108 Rwr_MarkUsed_rec( p, p0 );
109 nNodes++;
110 }
111
112 // compact the array by throwing away non-canonical
113 k = 5;
114 Vec_PtrForEachEntryStart( Rwr_Node_t *, p->vForest, p0, i, 5 )
115 if ( p0->fUsed )
116 {
117 p->vForest->pArray[k] = p0;
118 p0->Id = k++;
119 }
120 p->vForest->nSize = k;
121 printf( "Total canonical = %4d. Total used = %5d.\n", nNodes, p->vForest->nSize );
122}
#define RWR_LIMIT
INCLUDES ///.
Definition rwr.h:45
if(last==0)
Definition sparse_int.h:34
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManPreprocess()

void Rwr_ManPreprocess ( Rwr_Man_t * p)
extern

MACRO DEFINITIONS ///.

FUNCTION DECLARATIONS ///

MACRO DEFINITIONS ///.

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

Synopsis [Preprocesses computed library of subgraphs.]

Description []

SideEffects []

SeeAlso []

Definition at line 49 of file rwrDec.c.

50{
51 Dec_Graph_t * pGraph;
52 Rwr_Node_t * pNode;
53 int i, k;
54 // put the nodes into the structure
55 p->pMapInv = ABC_ALLOC( unsigned short, 222 );
56 memset( p->pMapInv, 0, sizeof(unsigned short) * 222 );
57 p->vClasses = Vec_VecStart( 222 );
58 for ( i = 0; i < p->nFuncs; i++ )
59 {
60 if ( p->pTable[i] == NULL )
61 continue;
62 // consider all implementations of this function
63 for ( pNode = p->pTable[i]; pNode; pNode = pNode->pNext )
64 {
65 assert( pNode->uTruth == p->pTable[i]->uTruth );
66 assert( p->pMap[pNode->uTruth] < 222 ); // Guaranteed to be >=0 b/c unsigned
67 Vec_VecPush( p->vClasses, p->pMap[pNode->uTruth], pNode );
68 p->pMapInv[ p->pMap[pNode->uTruth] ] = p->puCanons[pNode->uTruth];
69 }
70 }
71 // compute decomposition forms for each node and verify them
72 Vec_VecForEachEntry( Rwr_Node_t *, p->vClasses, pNode, i, k )
73 {
74 pGraph = Rwr_NodePreprocess( p, pNode );
75 pNode->pNext = (Rwr_Node_t *)pGraph;
76 assert( pNode->uTruth == (Dec_GraphDeriveTruth(pGraph) & 0xFFFF) );
77 }
78}
unsigned Dec_GraphDeriveTruth(Dec_Graph_t *pGraph)
DECLARATIONS ///.
Definition decUtil.c:102
struct Dec_Graph_t_ Dec_Graph_t
Definition dec.h:68
#define assert(ex)
Definition util_old.h:213
#define Vec_VecForEachEntry(Type, vGlob, pEntry, i, k)
Definition vecVec.h:87
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManPrint()

void Rwr_ManPrint ( Rwr_Man_t * p)
extern

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

Synopsis [Prints one rwr node.]

Description []

SideEffects []

SeeAlso []

Definition at line 237 of file rwrPrint.c.

238{
239 FILE * pFile;
240 Rwr_Node_t * pNode;
241 unsigned uTruth;
242 int Limit, Counter, Volume, nFuncs, i;
243 pFile = fopen( "graph_lib.txt", "w" );
244 Counter = 0;
245 Limit = (1 << 16);
246 for ( i = 0; i < Limit; i++ )
247 {
248 if ( p->pTable[i] == NULL )
249 continue;
250 if ( i != p->puCanons[i] )
251 continue;
252 fprintf( pFile, "\nClass %3d. Func %6d. ", p->pMap[i], Counter++ );
253 Rwr_GetBushVolume( p, i, &Volume, &nFuncs );
254 fprintf( pFile, "Roots = %3d. Vol = %3d. Sum = %3d. ", nFuncs, Volume, Rwr_GetBushSumOfVolumes(p, i) );
255 uTruth = i;
256 Extra_PrintBinary( pFile, &uTruth, 16 );
257 fprintf( pFile, "\n" );
258 for ( pNode = p->pTable[i]; pNode; pNode = pNode->pNext )
259 if ( pNode->uTruth == p->puCanons[pNode->uTruth] )
260 Rwr_NodePrint( pFile, p, pNode );
261 }
262 fclose( pFile );
263}
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
void Rwr_NodePrint(FILE *pFile, Rwr_Man_t *p, Rwr_Node_t *pNode)
Definition rwrPrint.c:208
int Rwr_GetBushSumOfVolumes(Rwr_Man_t *p, int Entry)
Definition rwrPrint.c:94
void Rwr_GetBushVolume(Rwr_Man_t *p, int Entry, int *pVolume, int *pnFuncs)
Definition rwrPrint.c:66
Here is the call graph for this function:

◆ Rwr_ManPrintStats()

void Rwr_ManPrintStats ( Rwr_Man_t * p)
extern

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

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 143 of file rwrMan.c.

144{
145 int i, Counter = 0;
146 for ( i = 0; i < 222; i++ )
147 Counter += (p->nScores[i] > 0);
148
149 printf( "Rewriting statistics:\n" );
150 printf( "Total cuts tries = %8d.\n", p->nCutsGood );
151 printf( "Bad cuts found = %8d.\n", p->nCutsBad );
152 printf( "Total subgraphs = %8d.\n", p->nSubgraphs );
153 printf( "Used NPN classes = %8d.\n", Counter );
154 printf( "Nodes considered = %8d.\n", p->nNodesConsidered );
155 printf( "Nodes rewritten = %8d.\n", p->nNodesRewritten );
156 printf( "Gain = %8d. (%6.2f %%).\n", p->nNodesBeg-p->nNodesEnd, 100.0*(p->nNodesBeg-p->nNodesEnd)/p->nNodesBeg );
157 ABC_PRT( "Start ", p->timeStart );
158 ABC_PRT( "Cuts ", p->timeCut );
159 ABC_PRT( "Resynthesis ", p->timeRes );
160 ABC_PRT( " Mffc ", p->timeMffc );
161 ABC_PRT( " Eval ", p->timeEval );
162 ABC_PRT( "Update ", p->timeUpdate );
163 ABC_PRT( "TOTAL ", p->timeTotal );
164
165/*
166 printf( "The scores are:\n" );
167 for ( i = 0; i < 222; i++ )
168 if ( p->nScores[i] > 0 )
169 {
170 extern void Ivy_TruthDsdComputePrint( unsigned uTruth );
171 printf( "%3d = %8d canon = %5d ", i, p->nScores[i], p->pMapInv[i] );
172 Ivy_TruthDsdComputePrint( (unsigned)p->pMapInv[i] | ((unsigned)p->pMapInv[i] << 16) );
173 }
174*/
175 printf( "\n" );
176
177}
Here is the caller graph for this function:

◆ Rwr_ManPrintStatsFile()

void Rwr_ManPrintStatsFile ( Rwr_Man_t * p)
extern

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

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 190 of file rwrMan.c.

191{
192 FILE * pTable;
193 pTable = fopen( "stats.txt", "a+" );
194 fprintf( pTable, "%d ", p->nCutsGood );
195 fprintf( pTable, "%d ", p->nSubgraphs );
196 fprintf( pTable, "%d ", p->nNodesRewritten );
197 fprintf( pTable, "%d", p->nNodesGained );
198 fprintf( pTable, "\n" );
199 fclose( pTable );
200}

◆ Rwr_ManReadCompl()

int Rwr_ManReadCompl ( Rwr_Man_t * p)
extern

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

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file rwrMan.c.

246{
247 return p->fCompl;
248}
Here is the caller graph for this function:

◆ Rwr_ManReadDecs()

void * Rwr_ManReadDecs ( Rwr_Man_t * p)
extern

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

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 213 of file rwrMan.c.

214{
215 return p->pGraph;
216}
Here is the caller graph for this function:

◆ Rwr_ManReadLeaves()

Vec_Ptr_t * Rwr_ManReadLeaves ( Rwr_Man_t * p)
extern

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

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 229 of file rwrMan.c.

230{
231 return p->vFanins;
232}

◆ Rwr_ManStart()

Rwr_Man_t * Rwr_ManStart ( int fPrecompute)
extern

DECLARATIONS ///.

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

FileName [rwrMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [DAG-aware AIG rewriting package.]

Synopsis [Rewriting manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
rwrMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

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

Synopsis [Starts rewriting manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file rwrMan.c.

48{
49 Dec_Man_t * pManDec;
50 Rwr_Man_t * p;
51 abctime clk = Abc_Clock();
52clk = Abc_Clock();
53 p = ABC_ALLOC( Rwr_Man_t, 1 );
54 memset( p, 0, sizeof(Rwr_Man_t) );
55 p->nFuncs = (1<<16);
56 pManDec = (Dec_Man_t *)Abc_FrameReadManDec();
57 p->puCanons = pManDec->puCanons;
58 p->pPhases = pManDec->pPhases;
59 p->pPerms = pManDec->pPerms;
60 p->pMap = pManDec->pMap;
61 // initialize practical NPN classes
62 p->pPractical = Rwr_ManGetPractical( p );
63 // create the table
64 p->pTable = ABC_ALLOC( Rwr_Node_t *, p->nFuncs );
65 memset( p->pTable, 0, sizeof(Rwr_Node_t *) * p->nFuncs );
66 // create the elementary nodes
67 p->pMmNode = Extra_MmFixedStart( sizeof(Rwr_Node_t) );
68 p->vForest = Vec_PtrAlloc( 100 );
69 Rwr_ManAddVar( p, 0x0000, fPrecompute ); // constant 0
70 Rwr_ManAddVar( p, 0xAAAA, fPrecompute ); // var A
71 Rwr_ManAddVar( p, 0xCCCC, fPrecompute ); // var B
72 Rwr_ManAddVar( p, 0xF0F0, fPrecompute ); // var C
73 Rwr_ManAddVar( p, 0xFF00, fPrecompute ); // var D
74 p->nClasses = 5;
75 // other stuff
76 p->nTravIds = 1;
77 p->pPerms4 = Extra_Permutations( 4 );
78 p->vLevNums = Vec_IntAlloc( 50 );
79 p->vFanins = Vec_PtrAlloc( 50 );
80 p->vFaninsCur = Vec_PtrAlloc( 50 );
81 p->vNodesTemp = Vec_PtrAlloc( 50 );
82 if ( fPrecompute )
83 { // precompute subgraphs
85// Rwr_ManPrint( p );
87 }
88 else
89 { // load saved subgraphs
91// Rwr_ManPrint( p );
93 }
94p->timeStart = Abc_Clock() - clk;
95 return p;
96}
ABC_DLL void * Abc_FrameReadManDec()
Definition mainFrame.c:66
struct Dec_Man_t_ Dec_Man_t
Definition dec.h:79
char ** Extra_Permutations(int n)
Extra_MmFixed_t * Extra_MmFixedStart(int nEntrySize)
Rwr_Node_t * Rwr_ManAddVar(Rwr_Man_t *p, unsigned uTruth, int fPrecompute)
Definition rwrLib.c:253
char * Rwr_ManGetPractical(Rwr_Man_t *p)
Definition rwrUtil.c:640
void Rwr_ManPreprocess(Rwr_Man_t *p)
MACRO DEFINITIONS ///.
Definition rwrDec.c:49
struct Rwr_Man_t_ Rwr_Man_t
Definition rwr.h:47
void Rwr_ManWriteToArray(Rwr_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition rwrUtil.c:426
void Rwr_ManPrecompute(Rwr_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition rwrLib.c:48
void Rwr_ManLoadFromArray(Rwr_Man_t *p, int fVerbose)
Definition rwrUtil.c:472
char * pPerms
Definition dec.h:88
char * pPhases
Definition dec.h:87
unsigned char * pMap
Definition dec.h:89
unsigned short * puCanons
Definition dec.h:86
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManStop()

void Rwr_ManStop ( Rwr_Man_t * p)
extern

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

Synopsis [Stops rewriting manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 109 of file rwrMan.c.

110{
111 if ( p->vClasses )
112 {
113 Rwr_Node_t * pNode;
114 int i, k;
115 Vec_VecForEachEntry( Rwr_Node_t *, p->vClasses, pNode, i, k )
116 Dec_GraphFree( (Dec_Graph_t *)pNode->pNext );
117 }
118 if ( p->vClasses ) Vec_VecFree( p->vClasses );
119 Vec_PtrFree( p->vNodesTemp );
120 Vec_PtrFree( p->vForest );
121 Vec_IntFree( p->vLevNums );
122 Vec_PtrFree( p->vFanins );
123 Vec_PtrFree( p->vFaninsCur );
124 Extra_MmFixedStop( p->pMmNode );
125 ABC_FREE( p->pMapInv );
126 ABC_FREE( p->pTable );
127 ABC_FREE( p->pPractical );
128 ABC_FREE( p->pPerms4 );
129 ABC_FREE( p );
130}
void Extra_MmFixedStop(Extra_MmFixed_t *p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManWriteToArray()

void Rwr_ManWriteToArray ( Rwr_Man_t * p)
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Writes data.]

Description []

SideEffects []

SeeAlso []

Definition at line 426 of file rwrUtil.c.

427{
428 FILE * pFile;
429 Rwr_Node_t * pNode;
430 unsigned Entry0, Entry1;
431 int i, nEntries;
432 abctime clk = Abc_Clock();
433 // prepare the buffer
434 nEntries = p->vForest->nSize - 5;
435 pFile = fopen( "npn4_aig_array.txt", "w" );
436 fprintf( pFile, "static unsigned short s_RwtAigSubgraphs[] = \n{" );
437 for ( i = 0; i < nEntries; i++ )
438 {
439 if ( i % 5 == 0 )
440 fprintf( pFile, "\n " );
441 pNode = (Rwr_Node_t *)p->vForest->pArray[i+5];
442 Entry0 = (Rwr_Regular(pNode->p0)->Id << 1) | Rwr_IsComplement(pNode->p0);
443 Entry1 = (Rwr_Regular(pNode->p1)->Id << 1) | Rwr_IsComplement(pNode->p1);
444 Entry0 = (Entry0 << 1) | pNode->fExor;
445 Extra_PrintHex( pFile, &Entry0, 4 );
446 fprintf( pFile, "," );
447 Extra_PrintHex( pFile, &Entry1, 4 );
448 fprintf( pFile, ", " );
449 }
450 if ( i % 5 == 0 )
451 fprintf( pFile, "\n " );
452 Entry0 = 0;
453 Extra_PrintHex( pFile, &Entry0, 4 );
454 fprintf( pFile, "," );
455 Extra_PrintHex( pFile, &Entry0, 4 );
456 fprintf( pFile, " \n};\n" );
457 fclose( pFile );
458 printf( "The number of nodes saved = %d. ", nEntries ); ABC_PRT( "Saving", Abc_Clock() - clk );
459}
void Extra_PrintHex(FILE *pFile, unsigned *pTruth, int nVars)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ManWriteToFile()

void Rwr_ManWriteToFile ( Rwr_Man_t * p,
char * pFileName )
extern

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

Synopsis [Writes.]

Description []

SideEffects []

SeeAlso []

Definition at line 524 of file rwrUtil.c.

525{
526 FILE * pFile;
527 Rwr_Node_t * pNode;
528 unsigned * pBuffer;
529 int i, nEntries;
530 abctime clk = Abc_Clock();
531 // prepare the buffer
532 nEntries = p->vForest->nSize - 5;
533 pBuffer = ABC_ALLOC( unsigned, nEntries * 2 );
534 for ( i = 0; i < nEntries; i++ )
535 {
536 pNode = (Rwr_Node_t *)p->vForest->pArray[i+5];
537 pBuffer[2*i + 0] = (Rwr_Regular(pNode->p0)->Id << 1) | Rwr_IsComplement(pNode->p0);
538 pBuffer[2*i + 1] = (Rwr_Regular(pNode->p1)->Id << 1) | Rwr_IsComplement(pNode->p1);
539 // save EXOR flag
540 pBuffer[2*i + 0] = (pBuffer[2*i + 0] << 1) | pNode->fExor;
541
542 }
543 pFile = fopen( pFileName, "wb" );
544 fwrite( &nEntries, sizeof(int), 1, pFile );
545 fwrite( pBuffer, sizeof(unsigned), nEntries * 2, pFile );
546 ABC_FREE( pBuffer );
547 fclose( pFile );
548 printf( "The number of nodes saved = %d. ", nEntries ); ABC_PRT( "Saving", Abc_Clock() - clk );
549}

◆ Rwr_NodeRewrite()

int Rwr_NodeRewrite ( Rwr_Man_t * p,
Cut_Man_t * pManCut,
Abc_Obj_t * pNode,
int fUpdateLevel,
int fUseZeros,
int fPlaceEnable )
extern

FUNCTION DEFINITIONS ///.

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

Synopsis [Performs rewriting for one node.]

Description [This procedure considers all the cuts computed for the node and tries to rewrite each of them using the "forest" of different AIG structures precomputed and stored in the RWR manager. Determines the best rewriting and computes the gain in the number of AIG nodes in the final network. In the end, p->vFanins contains information about the best cut that can be used for rewriting, while p->pGraph gives the decomposition dag (represented using decomposition graph data structure). Returns gain in the number of nodes or -1 if node cannot be rewritten.]

SideEffects []

SeeAlso []

Definition at line 59 of file rwrEva.c.

60{
61 int fVeryVerbose = 0;
62 Dec_Graph_t * pGraph;
63 Cut_Cut_t * pCut;//, * pTemp;
64 Abc_Obj_t * pFanin;
65 unsigned uPhase;
66 unsigned uTruthBest = 0; // Suppress "might be used uninitialized"
67 unsigned uTruth;
68 char * pPerm;
69 int Required, nNodesSaved;
70 int nNodesSaveCur = -1; // Suppress "might be used uninitialized"
71 int i, GainCur = -1, GainBest = -1;
72 abctime clk, clk2;//, Counter;
73
74 p->nNodesConsidered++;
75 // get the required times
76 Required = fUpdateLevel? Abc_ObjRequiredLevel(pNode) : ABC_INFINITY;
77
78 // get the node's cuts
79clk = Abc_Clock();
80 pCut = (Cut_Cut_t *)Abc_NodeGetCutsRecursive( pManCut, pNode, 0, 0 );
81 assert( pCut != NULL );
82p->timeCut += Abc_Clock() - clk;
83
84//printf( " %d", Rwr_CutCountNumNodes(pNode, pCut) );
85/*
86 Counter = 0;
87 for ( pTemp = pCut->pNext; pTemp; pTemp = pTemp->pNext )
88 Counter++;
89 printf( "%d ", Counter );
90*/
91 // go through the cuts
92clk = Abc_Clock();
93 for ( pCut = pCut->pNext; pCut; pCut = pCut->pNext )
94 {
95 // consider only 4-input cuts
96 if ( pCut->nLeaves < 4 )
97 continue;
98// Cut_CutPrint( pCut, 0 ), printf( "\n" );
99
100 // get the fanin permutation
101 uTruth = 0xFFFF & *Cut_CutReadTruth(pCut);
102 pPerm = p->pPerms4[ (int)p->pPerms[uTruth] ];
103 uPhase = p->pPhases[uTruth];
104 // collect fanins with the corresponding permutation/phase
105 Vec_PtrClear( p->vFaninsCur );
106 Vec_PtrFill( p->vFaninsCur, (int)pCut->nLeaves, 0 );
107 for ( i = 0; i < (int)pCut->nLeaves; i++ )
108 {
109 pFanin = Abc_NtkObj( pNode->pNtk, pCut->pLeaves[(int)pPerm[i]] );
110 if ( pFanin == NULL )
111 break;
112 pFanin = Abc_ObjNotCond(pFanin, ((uPhase & (1<<i)) > 0) );
113 Vec_PtrWriteEntry( p->vFaninsCur, i, pFanin );
114 }
115 if ( i != (int)pCut->nLeaves )
116 {
117 p->nCutsBad++;
118 continue;
119 }
120 p->nCutsGood++;
121
122 {
123 int Counter = 0;
124 Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninsCur, pFanin, i )
125 if ( Abc_ObjFanoutNum(Abc_ObjRegular(pFanin)) == 1 )
126 Counter++;
127 if ( Counter > 2 )
128 continue;
129 }
130
131clk2 = Abc_Clock();
132/*
133 printf( "Considering: (" );
134 Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninsCur, pFanin, i )
135 printf( "%d ", Abc_ObjFanoutNum(Abc_ObjRegular(pFanin)) );
136 printf( ")\n" );
137*/
138 // mark the fanin boundary
139 Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninsCur, pFanin, i )
140 Abc_ObjRegular(pFanin)->vFanouts.nSize++;
141
142 // label MFFC with current ID
143 Abc_NtkIncrementTravId( pNode->pNtk );
144 nNodesSaved = Abc_NodeMffcLabelAig( pNode );
145 // unmark the fanin boundary
146 Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninsCur, pFanin, i )
147 Abc_ObjRegular(pFanin)->vFanouts.nSize--;
148p->timeMffc += Abc_Clock() - clk2;
149
150 // evaluate the cut
151clk2 = Abc_Clock();
152 pGraph = Rwr_CutEvaluate( p, pNode, pCut, p->vFaninsCur, nNodesSaved, Required, &GainCur, fPlaceEnable );
153p->timeEval += Abc_Clock() - clk2;
154
155 // check if the cut is better than the current best one
156 if ( pGraph != NULL && GainBest < GainCur )
157 {
158 // save this form
159 nNodesSaveCur = nNodesSaved;
160 GainBest = GainCur;
161 p->pGraph = pGraph;
162 p->fCompl = ((uPhase & (1<<4)) > 0);
163 uTruthBest = 0xFFFF & *Cut_CutReadTruth(pCut);
164 // collect fanins in the
165 Vec_PtrClear( p->vFanins );
166 Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninsCur, pFanin, i )
167 Vec_PtrPush( p->vFanins, pFanin );
168 }
169 }
170p->timeRes += Abc_Clock() - clk;
171
172 if ( GainBest == -1 )
173 return -1;
174/*
175 if ( GainBest > 0 )
176 {
177 printf( "Class %d ", p->pMap[uTruthBest] );
178 printf( "Gain = %d. Node %d : ", GainBest, pNode->Id );
179 Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanins, pFanin, i )
180 printf( "%d ", Abc_ObjRegular(pFanin)->Id );
181 Dec_GraphPrint( stdout, p->pGraph, NULL, NULL );
182 printf( "\n" );
183 }
184*/
185
186// printf( "%d", nNodesSaveCur - GainBest );
187/*
188 if ( GainBest > 0 )
189 {
190 if ( Rwr_CutIsBoolean( pNode, p->vFanins ) )
191 printf( "b" );
192 else
193 {
194 printf( "Node %d : ", pNode->Id );
195 Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanins, pFanin, i )
196 printf( "%d ", Abc_ObjRegular(pFanin)->Id );
197 printf( "a" );
198 }
199 }
200*/
201/*
202 if ( GainBest > 0 )
203 if ( p->fCompl )
204 printf( "c" );
205 else
206 printf( "." );
207*/
208
209 // copy the leaves
210 Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanins, pFanin, i )
211 Dec_GraphNode((Dec_Graph_t *)p->pGraph, i)->pFunc = pFanin;
212/*
213 printf( "(" );
214 Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanins, pFanin, i )
215 printf( " %d", Abc_ObjRegular(pFanin)->vFanouts.nSize - 1 );
216 printf( " ) " );
217*/
218// printf( "%d ", Rwr_NodeGetDepth_rec( pNode, p->vFanins ) );
219
220 p->nScores[p->pMap[uTruthBest]]++;
221 p->nNodesGained += GainBest;
222 if ( fUseZeros || GainBest > 0 )
223 {
224 p->nNodesRewritten++;
225 }
226
227 // report the progress
228 if ( fVeryVerbose && GainBest > 0 )
229 {
230 printf( "Node %6s : ", Abc_ObjName(pNode) );
231 printf( "Fanins = %d. ", p->vFanins->nSize );
232 printf( "Save = %d. ", nNodesSaveCur );
233 printf( "Add = %d. ", nNodesSaveCur-GainBest );
234 printf( "GAIN = %d. ", GainBest );
235 printf( "Cone = %d. ", p->pGraph? Dec_GraphNodeNum((Dec_Graph_t *)p->pGraph) : 0 );
236 printf( "Class = %d. ", p->pMap[uTruthBest] );
237 printf( "\n" );
238 }
239 return GainBest;
240}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL int Abc_ObjRequiredLevel(Abc_Obj_t *pObj)
Definition abcTiming.c:1214
ABC_DLL int Abc_NodeMffcLabelAig(Abc_Obj_t *pNode)
Definition abcRefs.c:100
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
ABC_DLL void * Abc_NodeGetCutsRecursive(void *p, Abc_Obj_t *pObj, int fDag, int fTree)
Definition abcCut.c:412
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
struct Cut_CutStruct_t_ Cut_Cut_t
Definition cut.h:50
Abc_Ntk_t * pNtk
Definition abc.h:130
int pLeaves[0]
Definition cut.h:89
unsigned nLeaves
Definition cut.h:84
Cut_Cut_t * pNext
Definition cut.h:88
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rwr_ScoresClean()

void Rwr_ScoresClean ( Rwr_Man_t * p)
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 504 of file rwrEva.c.

505{
506 Vec_Ptr_t * vSubgraphs;
507 Rwr_Node_t * pNode;
508 int i, k;
509 for ( i = 0; i < p->vClasses->nSize; i++ )
510 {
511 vSubgraphs = Vec_VecEntry( p->vClasses, i );
512 Vec_PtrForEachEntry( Rwr_Node_t *, vSubgraphs, pNode, k )
513 pNode->nScore = pNode->nGain = pNode->nAdded = 0;
514 }
515}
short nGain
Definition rwr.h:103
short nAdded
Definition rwr.h:104
short nScore
Definition rwr.h:102
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the caller graph for this function:

◆ Rwr_ScoresReport()

void Rwr_ScoresReport ( Rwr_Man_t * p)
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 550 of file rwrEva.c.

551{
552 extern void Ivy_TruthDsdComputePrint( unsigned uTruth );
553 int Perm[222];
554 Vec_Ptr_t * vSubgraphs;
555 Rwr_Node_t * pNode;
556 int i, iNew, k;
557 unsigned uTruth;
558 // collect total gains
559 assert( p->vClasses->nSize == 222 );
560 for ( i = 0; i < p->vClasses->nSize; i++ )
561 {
562 Perm[i] = i;
563 Gains[i] = 0;
564 vSubgraphs = Vec_VecEntry( p->vClasses, i );
565 Vec_PtrForEachEntry( Rwr_Node_t *, vSubgraphs, pNode, k )
566 Gains[i] += pNode->nGain;
567 }
568 // sort the gains
569 qsort( Perm, (size_t)222, sizeof(int), (int (*)(const void *, const void *))Rwr_ScoresCompare );
570
571 // print classes
572 for ( i = 0; i < p->vClasses->nSize; i++ )
573 {
574 iNew = Perm[i];
575 if ( Gains[iNew] == 0 )
576 break;
577 vSubgraphs = Vec_VecEntry( p->vClasses, iNew );
578 printf( "CLASS %3d: Subgr = %3d. Total gain = %6d. ", iNew, Vec_PtrSize(vSubgraphs), Gains[iNew] );
579 uTruth = (unsigned)p->pMapInv[iNew];
580 Extra_PrintBinary( stdout, &uTruth, 16 );
581 printf( " " );
582 Ivy_TruthDsdComputePrint( (unsigned)p->pMapInv[iNew] | ((unsigned)p->pMapInv[iNew] << 16) );
583 Vec_PtrForEachEntry( Rwr_Node_t *, vSubgraphs, pNode, k )
584 {
585 if ( pNode->nScore == 0 )
586 continue;
587 printf( " %2d: S=%5d. A=%5d. G=%6d. ", k, pNode->nScore, pNode->nAdded, pNode->nGain );
588 Dec_GraphPrint( stdout, (Dec_Graph_t *)pNode->pNext, NULL, NULL );
589 }
590 }
591}
void Dec_GraphPrint(FILE *pFile, Dec_Graph_t *pGraph, char *pNamesIn[], char *pNameOut)
FUNCTION DEFINITIONS ///.
Definition decPrint.c:49
void Ivy_TruthDsdComputePrint(unsigned uTruth)
Definition ivyDsd.c:678
int Rwr_ScoresCompare(int *pNum1, int *pNum2)
Definition rwrEva.c:530
Here is the call graph for this function:
Here is the caller graph for this function: