Commit b5df218d by Alan Mishchenko

Experiments with mapping.

parent ace34099
...@@ -258,6 +258,7 @@ struct Jf_Par_t_ ...@@ -258,6 +258,7 @@ struct Jf_Par_t_
int fCnfObjIds; int fCnfObjIds;
int fAddOrCla; int fAddOrCla;
int fPureAig; int fPureAig;
int fCutHashing;
int fVerbose; int fVerbose;
int fVeryVerbose; int fVeryVerbose;
int nLutSizeMax; int nLutSizeMax;
......
...@@ -144,8 +144,8 @@ static inline void Kf_SetPrepare( Kf_Set_t * p, int * pCuts0, int * pCuts1 ) ...@@ -144,8 +144,8 @@ static inline void Kf_SetPrepare( Kf_Set_t * p, int * pCuts0, int * pCuts1 )
{ {
int i; int i;
// prepare hash table // prepare hash table
for ( i = 0; i <= p->TableMask; i++ ) // for ( i = 0; i <= p->TableMask; i++ )
assert( p->pTable[i] == 0 ); // assert( p->pTable[i] == 0 );
// prepare cut storage // prepare cut storage
for ( i = 0; i <= p->nLutSize; i++ ) for ( i = 0; i <= p->nLutSize; i++ )
p->pList[i] = -1; p->pList[i] = -1;
...@@ -333,7 +333,7 @@ static inline void Kf_HashCleanup( Kf_Set_t * p, int iStart ) ...@@ -333,7 +333,7 @@ static inline void Kf_HashCleanup( Kf_Set_t * p, int iStart )
{ {
int i; int i;
for ( i = iStart; i < p->nTEntries; i++ ) for ( i = iStart; i < p->nTEntries; i++ )
p->pPlace[i] = 0; p->pTable[p->pPlace[i]] = 0;
p->nTEntries = iStart; p->nTEntries = iStart;
} }
...@@ -398,6 +398,7 @@ static inline void Kf_SetMergePairs( Kf_Set_t * p, Kf_Cut_t * pCut0, Kf_Cut_t * ...@@ -398,6 +398,7 @@ static inline void Kf_SetMergePairs( Kf_Set_t * p, Kf_Cut_t * pCut0, Kf_Cut_t *
break; break;
if ( i < pCut1->nLeaves ) if ( i < pCut1->nLeaves )
continue; continue;
p->CutCount[1]++;
if ( Kf_SetRemoveDuplicates(p, p->nTEntries, pCut0->Sign | pCut1->Sign) ) if ( Kf_SetRemoveDuplicates(p, p->nTEntries, pCut0->Sign | pCut1->Sign) )
continue; continue;
// create new cut // create new cut
...@@ -417,6 +418,7 @@ static inline Kf_Cut_t * Kf_SetMerge( Kf_Set_t * p, int * pCuts0, int * pCuts1, ...@@ -417,6 +418,7 @@ static inline Kf_Cut_t * Kf_SetMerge( Kf_Set_t * p, int * pCuts0, int * pCuts1,
{ {
int c0, c1; int c0, c1;
Kf_SetPrepare( p, pCuts0, pCuts1 ); Kf_SetPrepare( p, pCuts0, pCuts1 );
p->CutCount[0] += p->nCuts0 * p->nCuts1;
for ( c0 = c1 = 0; c0 < p->nCuts0 && c1 < p->nCuts1; ) for ( c0 = c1 = 0; c0 < p->nCuts0 && c1 < p->nCuts1; )
{ {
if ( p->pCuts0[c0].nLeaves >= p->pCuts1[c1].nLeaves ) if ( p->pCuts0[c0].nLeaves >= p->pCuts1[c1].nLeaves )
...@@ -424,8 +426,9 @@ static inline Kf_Cut_t * Kf_SetMerge( Kf_Set_t * p, int * pCuts0, int * pCuts1, ...@@ -424,8 +426,9 @@ static inline Kf_Cut_t * Kf_SetMerge( Kf_Set_t * p, int * pCuts0, int * pCuts1,
else else
Kf_SetMergePairs( p, p->pCuts1 + c1++, p->pCuts0 + c0, p->nCuts0 - c0, fArea ); Kf_SetMergePairs( p, p->pCuts1 + c1++, p->pCuts0 + c0, p->nCuts0 - c0, fArea );
} }
p->CutCount[2] += p->nCuts;
Kf_SetFilter( p ); Kf_SetFilter( p );
p->CutCount[3] += Abc_MinInt( p->nCuts, p->nCutNum ); p->CutCount[3] += Abc_MinInt( p->nCuts, p->nCutNum-1 );
return Kf_SetSelectBest( p, fArea, 1 ); return Kf_SetSelectBest( p, fArea, 1 );
} }
...@@ -619,7 +622,7 @@ static inline Kf_Cut_t * Kf_SetMerge2( Kf_Set_t * p, int * pCuts0, int * pCuts1, ...@@ -619,7 +622,7 @@ static inline Kf_Cut_t * Kf_SetMerge2( Kf_Set_t * p, int * pCuts0, int * pCuts1,
} }
Kf_SetFilter2( p ); Kf_SetFilter2( p );
p->CutCount[3] += Abc_MinInt( p->nCuts, p->nCutNum-1 ); p->CutCount[3] += Abc_MinInt( p->nCuts, p->nCutNum-1 );
return Kf_SetSelectBest( p, fArea, 0 ); return Kf_SetSelectBest( p, fArea, 1 );
} }
...@@ -766,7 +769,7 @@ void Kf_ManComputeMapping( Kf_Man_t * p ) ...@@ -766,7 +769,7 @@ void Kf_ManComputeMapping( Kf_Man_t * p )
if ( p->pPars->fVerbose ) if ( p->pPars->fVerbose )
{ {
printf( "Aig: CI = %d CO = %d AND = %d ", Gia_ManCiNum(p->pGia), Gia_ManCoNum(p->pGia), Gia_ManAndNum(p->pGia) ); printf( "Aig: CI = %d CO = %d AND = %d ", Gia_ManCiNum(p->pGia), Gia_ManCoNum(p->pGia), Gia_ManAndNum(p->pGia) );
printf( "LutSize = %d CutMax = %d Rounds = %d\n", p->pPars->nLutSize, p->pPars->nCutNum, p->pPars->nRounds ); printf( "LutSize = %d CutMax = %d Hash = %d\n", p->pPars->nLutSize, p->pPars->nCutNum, p->pPars->fCutHashing );
printf( "Computing cuts...\r" ); printf( "Computing cuts...\r" );
fflush( stdout ); fflush( stdout );
} }
...@@ -781,8 +784,10 @@ void Kf_ManComputeMapping( Kf_Man_t * p ) ...@@ -781,8 +784,10 @@ void Kf_ManComputeMapping( Kf_Man_t * p )
} }
else if ( Gia_ObjIsAnd(pObj) ) else if ( Gia_ObjIsAnd(pObj) )
{ {
if ( p->pPars->fCutHashing )
pCutBest = Kf_SetMerge( p->pSett, Kf_ObjCuts0(p, i), Kf_ObjCuts1(p, i), p->pPars->fAreaOnly, p->pPars->fCutMin );
else
pCutBest = Kf_SetMerge2( p->pSett, Kf_ObjCuts0(p, i), Kf_ObjCuts1(p, i), p->pPars->fAreaOnly, p->pPars->fCutMin ); pCutBest = Kf_SetMerge2( p->pSett, Kf_ObjCuts0(p, i), Kf_ObjCuts1(p, i), p->pPars->fAreaOnly, p->pPars->fCutMin );
// pCutBest = Kf_SetMerge( p->pSett, Kf_ObjCuts0(p, i), Kf_ObjCuts1(p, i), p->pPars->fAreaOnly, p->pPars->fCutMin );
Kf_ManSaveResults( p->pSett->ppCuts, p->pSett->nCuts, pCutBest, p->vTemp ); Kf_ManSaveResults( p->pSett->ppCuts, p->pSett->nCuts, pCutBest, p->vTemp );
Vec_IntWriteEntry( &p->vTime, i, pCutBest->Delay + 1 ); Vec_IntWriteEntry( &p->vTime, i, pCutBest->Delay + 1 );
Vec_FltWriteEntry( &p->vArea, i, (pCutBest->Area + 1)/Kf_ObjRefs(p, i) ); Vec_FltWriteEntry( &p->vArea, i, (pCutBest->Area + 1)/Kf_ObjRefs(p, i) );
...@@ -926,13 +931,14 @@ void Kf_ManSetDefaultPars( Jf_Par_t * pPars ) ...@@ -926,13 +931,14 @@ void Kf_ManSetDefaultPars( Jf_Par_t * pPars )
pPars->nRounds = 1; pPars->nRounds = 1;
pPars->nVerbLimit = 5; pPars->nVerbLimit = 5;
pPars->DelayTarget = -1; pPars->DelayTarget = -1;
pPars->fAreaOnly = 1; pPars->fAreaOnly = 0;
pPars->fOptEdge = 1; pPars->fOptEdge = 1;
pPars->fCoarsen = 0; pPars->fCoarsen = 0;
pPars->fCutMin = 0; pPars->fCutMin = 0;
pPars->fFuncDsd = 0; pPars->fFuncDsd = 0;
pPars->fGenCnf = 0; pPars->fGenCnf = 0;
pPars->fPureAig = 0; pPars->fPureAig = 0;
pPars->fCutHashing = 0;
pPars->fVerbose = 0; pPars->fVerbose = 0;
pPars->fVeryVerbose = 0; pPars->fVeryVerbose = 0;
pPars->nLutSizeMax = KF_LEAF_MAX; pPars->nLutSizeMax = KF_LEAF_MAX;
......
...@@ -30369,7 +30369,7 @@ int Abc_CommandAbc9Kf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -30369,7 +30369,7 @@ int Abc_CommandAbc9Kf( Abc_Frame_t * pAbc, int argc, char ** argv )
Gia_Man_t * pNew; int c; Gia_Man_t * pNew; int c;
Kf_ManSetDefaultPars( pPars ); Kf_ManSetDefaultPars( pPars );
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "KCRDWPaekmdcgvwh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "KCRDWPaekmdcgtvwh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -30466,6 +30466,9 @@ int Abc_CommandAbc9Kf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -30466,6 +30466,9 @@ int Abc_CommandAbc9Kf( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'g': case 'g':
pPars->fPureAig ^= 1; pPars->fPureAig ^= 1;
break; break;
case 't':
pPars->fCutHashing ^= 1;
break;
case 'v': case 'v':
pPars->fVerbose ^= 1; pPars->fVerbose ^= 1;
break; break;
...@@ -30498,7 +30501,7 @@ usage: ...@@ -30498,7 +30501,7 @@ usage:
sprintf(Buffer, "best possible" ); sprintf(Buffer, "best possible" );
else else
sprintf(Buffer, "%d", pPars->DelayTarget ); sprintf(Buffer, "%d", pPars->DelayTarget );
Abc_Print( -2, "usage: &kf [-KCRDWP num] [-akmdcgvwh]\n" ); Abc_Print( -2, "usage: &kf [-KCRDWP num] [-akmdcgtvwh]\n" );
Abc_Print( -2, "\t performs technology mapping of the network\n" ); Abc_Print( -2, "\t performs technology mapping of the network\n" );
Abc_Print( -2, "\t-K num : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize ); Abc_Print( -2, "\t-K num : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
Abc_Print( -2, "\t-C num : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum ); Abc_Print( -2, "\t-C num : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
...@@ -30513,6 +30516,7 @@ usage: ...@@ -30513,6 +30516,7 @@ usage:
Abc_Print( -2, "\t-d : toggles using DSD to represent cut functions [default = %s]\n", pPars->fFuncDsd? "yes": "no" ); Abc_Print( -2, "\t-d : toggles using DSD to represent cut functions [default = %s]\n", pPars->fFuncDsd? "yes": "no" );
Abc_Print( -2, "\t-c : toggles mapping for CNF generation [default = %s]\n", pPars->fGenCnf? "yes": "no" ); Abc_Print( -2, "\t-c : toggles mapping for CNF generation [default = %s]\n", pPars->fGenCnf? "yes": "no" );
Abc_Print( -2, "\t-g : toggles generating AIG without mapping [default = %s]\n", pPars->fPureAig? "yes": "no" ); Abc_Print( -2, "\t-g : toggles generating AIG without mapping [default = %s]\n", pPars->fPureAig? "yes": "no" );
Abc_Print( -2, "\t-t : toggles cut computation using hash table [default = %s]\n", pPars->fCutHashing? "yes": "no" );
Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" ); Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
Abc_Print( -2, "\t-w : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" ); Abc_Print( -2, "\t-w : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : prints the command usage\n"); Abc_Print( -2, "\t-h : prints the command usage\n");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment