ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
reoShuffle.c File Reference
#include "reo.h"
Include dependency graph for reoShuffle.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START DdNode * reoShuffle (reo_man *p, DdManager *dd, DdNode *bFunc, int *pPerm, int *pPermInv)
 DECLARATIONS ///.
 
void Extra_ShuffleTest (reo_man *pReo, DdManager *dd, DdNode *Func)
 

Function Documentation

◆ Extra_ShuffleTest()

void Extra_ShuffleTest ( reo_man * pReo,
DdManager * dd,
DdNode * Func )

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

Synopsis [Reorders the DD using REO and CUDD.]

Description [This function can be used to test the performance of the reordering package.]

SideEffects []

SeeAlso []

Definition at line 159 of file reoShuffle.c.

160{
161// extern int runtime1, runtime2;
162
163 DdNode * Temp, * bRemap;
164 int nSuppSize, OffSet, Num, i;
165 abctime clk;
166 int pOrder[1000], pOrderInv[1000];
167 assert( dd->size < 1000 );
168
169 srand( 0x12341234 );
170 nSuppSize = Cudd_SupportSize( dd, Func );
171 if ( nSuppSize < 2 )
172 return;
173
174 for ( i = 0; i < nSuppSize; i++ )
175 pOrder[i] = i;
176 for ( i = 0; i < 120; i++ )
177 {
178 OffSet = rand() % (nSuppSize - 1);
179 Num = pOrder[OffSet];
180 pOrder[OffSet] = pOrder[OffSet+1];
181 pOrder[OffSet+1] = Num;
182 }
183 for ( i = 0; i < nSuppSize; i++ )
184 pOrderInv[pOrder[i]] = i;
185
186/*
187 printf( "Permutation: " );
188 for ( i = 0; i < nSuppSize; i++ )
189 printf( "%d ", pOrder[i] );
190 printf( "\n" );
191 printf( "Inverse permutation: " );
192 for ( i = 0; i < nSuppSize; i++ )
193 printf( "%d ", pOrderInv[i] );
194 printf( "\n" );
195*/
196
197 // create permutation
198// Extra_ReorderSetVerification( pReo, 1 );
199 bRemap = Extra_bddRemapUp( dd, Func ); Cudd_Ref( bRemap );
200
201clk = Abc_Clock();
202 Temp = reoShuffle( pReo, dd, bRemap, pOrder, pOrderInv ); Cudd_Ref( Temp );
203//runtime1 += Abc_Clock() - clk;
204
205//printf( "Initial = %d. Final = %d.\n", Cudd_DagSize(bRemap), Cudd_DagSize(Temp) );
206
207 {
208 DdNode * bFuncPerm;
209clk = Abc_Clock();
210 bFuncPerm = Cudd_bddPermute( dd, bRemap, pOrderInv ); Cudd_Ref( bFuncPerm );
211//runtime2 += Abc_Clock() - clk;
212 if ( bFuncPerm != Temp )
213 {
214 printf( "REO: Internal verification has failed!\n" );
215 fflush( stdout );
216 }
217 Cudd_RecursiveDeref( dd, bFuncPerm );
218 }
219
220 Cudd_RecursiveDeref( dd, Temp );
221 Cudd_RecursiveDeref( dd, bRemap );
222}
ABC_INT64_T abctime
Definition abc_global.h:332
DdNode * Extra_bddRemapUp(DdManager *dd, DdNode *bF)
ABC_NAMESPACE_IMPL_START DdNode * reoShuffle(reo_man *p, DdManager *dd, DdNode *bFunc, int *pPerm, int *pPermInv)
DECLARATIONS ///.
Definition reoShuffle.c:49
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ reoShuffle()

ABC_NAMESPACE_IMPL_START DdNode * reoShuffle ( reo_man * p,
DdManager * dd,
DdNode * bFunc,
int * pPerm,
int * pPermInv )

DECLARATIONS ///.

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

FileName [reoShuffle.c]

PackageName [REO: A specialized DD reordering engine.]

Synopsis [Implementation of the two-variable swap.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - October 15, 2002.]

Revision [

Id
reoShuffle.c,v 1.0 2002/15/10 03:00:00 alanmi Exp

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

Synopsis [This procedure is similar to Cudd_ShuffleHeap() and Cudd_bddPermute().]

Description [The first argument is the REO manager. The 2nd/3d arguments are the function and its CUDD manager. The last argument is the permutation to be implemented. The i-th entry of the permutation array contains the index of the variable that should be brought to the i-th level. The size of the array should be equal or greater to the number of variables currently in use (that is, the size of CUDD manager and the size of REO manager).]

SideEffects [Note that the resulting BDD is not referenced.]

SeeAlso []

Definition at line 49 of file reoShuffle.c.

50{
51 DdNode * bFuncRes = NULL;
52 int i, k, v;
53
54 if ( Cudd_IsConstant(bFunc) )
55 return bFunc;
56
57 // set the initial parameters
58 p->dd = dd;
59 p->nSupp = Cudd_SupportSize( dd, bFunc );
60 p->nTops = 1;
61// p->nNodesBeg = Cudd_DagSize( bFunc );
62
63 // set the starting permutation
64 for ( i = 0; i < p->nSupp; i++ )
65 {
66 p->pOrderInt[i] = i;
67 p->pMapToPlanes[ dd->invperm[i] ] = i;
68 p->pMapToDdVarsFinal[i] = dd->invperm[i];
69 }
70
71 // set the initial parameters
72 p->nUnitsUsed = 0;
73 p->nNodesCur = 0;
74 p->fThisIsAdd = 0;
75 p->Signature++;
76
77 // transfer the function from the CUDD package into REO's internal data structure
78 p->pTops[0] = reoTransferNodesToUnits_rec( p, bFunc );
79// assert( p->nNodesBeg == p->nNodesCur );
80
81 // reorder one variable at a time
82 for ( i = 0; i < p->nSupp; i++ )
83 {
84 if ( p->pOrderInt[i] == pPerm[i] )
85 continue;
86 // find where is variable number pPerm[i]
87 for ( k = i + 1; k < p->nSupp; k++ )
88 if ( pPerm[i] == p->pOrderInt[k] )
89 break;
90 if ( k == p->nSupp )
91 {
92 printf( "reoShuffle() Error: Cannot find a variable.\n" );
93 goto finish;
94 }
95 // move the variable up
96 for ( v = k - 1; v >= i; v-- )
97 {
99 // check if the number of nodes is not too large
100 if ( p->nNodesCur > 10000 )
101 {
102 printf( "reoShuffle() Error: BDD size is too large.\n" );
103 goto finish;
104 }
105 }
106 assert( p->pOrderInt[i] == pPerm[i] );
107 }
108
109 // set the initial parameters
110 p->nRefNodes = 0;
111 p->nNodesCur = 0;
112 p->Signature++;
113 // transfer the BDDs from REO's internal data structure to CUDD
114 bFuncRes = reoTransferUnitsToNodes_rec( p, p->pTops[0] ); Cudd_Ref( bFuncRes );
115 // undo the DDs referenced for storing in the cache
116 for ( i = 0; i < p->nRefNodes; i++ )
117 Cudd_RecursiveDeref( dd, p->pRefNodes[i] );
118
119 // verify zero refs of the terminal nodes
120// assert( reoRecursiveDeref( p->pTops[0] ) );
121// assert( reoCheckZeroRefs( &(p->pPlanes[p->nSupp]) ) );
122
123 // perform verification
124 if ( p->fVerify )
125 {
126 DdNode * bFuncPerm;
127 bFuncPerm = Cudd_bddPermute( dd, bFunc, pPermInv ); Cudd_Ref( bFuncPerm );
128 if ( bFuncPerm != bFuncRes )
129 {
130 printf( "REO: Internal verification has failed!\n" );
131 fflush( stdout );
132 }
133 Cudd_RecursiveDeref( dd, bFuncPerm );
134 }
135
136 // recycle the data structure
137 for ( i = 0; i <= p->nSupp; i++ )
138 reoUnitsRecycleUnitList( p, p->pPlanes + i );
139
140finish :
141 if ( bFuncRes )
142 Cudd_Deref( bFuncRes );
143 return bFuncRes;
144}
Cube * p
Definition exorList.c:222
reo_unit * reoTransferNodesToUnits_rec(reo_man *p, DdNode *F)
DECLARATIONS ///.
Definition reoTransfer.c:43
void reoUnitsRecycleUnitList(reo_man *p, reo_plane *pPlane)
Definition reoUnits.c:87
double reoReorderSwapAdjacentVars(reo_man *p, int Level, int fMovingUp)
FUNCTION DEFINITIONS ///.
Definition reoSwap.c:46
DdNode * reoTransferUnitsToNodes_rec(reo_man *p, reo_unit *pUnit)
Here is the call graph for this function:
Here is the caller graph for this function: