Commit 481c29c8 by Alan Mishchenko

Improvements to technology mapping.

parent ffea3a2c
...@@ -240,6 +240,11 @@ struct If_Man_t_ ...@@ -240,6 +240,11 @@ struct If_Man_t_
Hash_IntMan_t * vPairHash; // hashing pairs of truth tables Hash_IntMan_t * vPairHash; // hashing pairs of truth tables
Vec_Int_t * vPairRes; // resulting truth table Vec_Int_t * vPairRes; // resulting truth table
Vec_Str_t * vPairPerms; // resulting permutation Vec_Str_t * vPairPerms; // resulting permutation
char pCanonPerm[IF_MAX_LUTSIZE];
unsigned uCanonPhase;
int nCacheHits;
int nCacheMisses;
abctime timeCache[6];
int nBestCutSmall[2]; int nBestCutSmall[2];
int nCountNonDec[2]; int nCountNonDec[2];
Vec_Int_t * vCutData; // cut data storage Vec_Int_t * vCutData; // cut data storage
......
...@@ -168,6 +168,14 @@ void If_ManStop( If_Man_t * p ) ...@@ -168,6 +168,14 @@ void If_ManStop( If_Man_t * p )
for ( i = 6; i <= p->pPars->nLutSize; i++ ) for ( i = 6; i <= p->pPars->nLutSize; i++ )
nMemTotal += (int)Vec_MemMemory(p->vTtMem[i]); nMemTotal += (int)Vec_MemMemory(p->vTtMem[i]);
printf( "Unique truth tables = %d. Memory = %.2f MB\n", nUnique, 1.0 * nMemTotal / (1<<20) ); printf( "Unique truth tables = %d. Memory = %.2f MB\n", nUnique, 1.0 * nMemTotal / (1<<20) );
if ( p->nCacheMisses )
{
printf( "Cache hits = %d. Cache misses = %d (%.2f %%)\n", p->nCacheHits, p->nCacheMisses, 100.0 * p->nCacheMisses / (p->nCacheHits + p->nCacheMisses) );
Abc_PrintTime( 1, "Non-DSD ", p->timeCache[0] );
Abc_PrintTime( 1, "DSD hits ", p->timeCache[1] );
Abc_PrintTime( 1, "DSD misses", p->timeCache[2] );
Abc_PrintTime( 1, "Canon ", p->timeCache[3] );
}
} }
if ( p->pPars->fVerbose && p->nCutsUselessAll ) if ( p->pPars->fVerbose && p->nCutsUselessAll )
{ {
......
...@@ -149,9 +149,9 @@ int If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_ ...@@ -149,9 +149,9 @@ int If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_
int If_CutComputeTruthPerm_int( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int iCutFunc0, int iCutFunc1 ) int If_CutComputeTruthPerm_int( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int iCutFunc0, int iCutFunc1 )
{ {
int fVerbose = 0; int fVerbose = 0;
abctime clk;
int pPerm[IF_MAX_LUTSIZE]; int pPerm[IF_MAX_LUTSIZE];
char pCanonPerm[IF_MAX_LUTSIZE]; int v, Place, fCompl, truthId, nLeavesNew, RetValue = 0;
int v, Place, fCompl, truthId, nLeavesNew, uCanonPhase, RetValue = 0;
int nWords = Abc_TtWordNum( pCut->nLeaves ); int nWords = Abc_TtWordNum( pCut->nLeaves );
word * pTruth0s = Vec_MemReadEntry( p->vTtMem[pCut0->nLeaves], Abc_Lit2Var(iCutFunc0) ); word * pTruth0s = Vec_MemReadEntry( p->vTtMem[pCut0->nLeaves], Abc_Lit2Var(iCutFunc0) );
word * pTruth1s = Vec_MemReadEntry( p->vTtMem[pCut1->nLeaves], Abc_Lit2Var(iCutFunc1) ); word * pTruth1s = Vec_MemReadEntry( p->vTtMem[pCut1->nLeaves], Abc_Lit2Var(iCutFunc1) );
...@@ -201,7 +201,7 @@ if ( fVerbose ) ...@@ -201,7 +201,7 @@ if ( fVerbose )
// perform operation // perform operation
Abc_TtAnd( pTruth, pTruth0, pTruth1, nWords, 0 ); Abc_TtAnd( pTruth, pTruth0, pTruth1, nWords, 0 );
// minimize support // minimize support
if ( p->pPars->fCutMin ) if ( p->pPars->fCutMin && (pCut0->nLeaves + pCut1->nLeaves > pCut->nLeaves || pCut0->nLeaves == 0 || pCut1->nLeaves == 0) )
{ {
nLeavesNew = Abc_TtMinBase( pTruth, pCut->pLeaves, pCut->nLeaves, pCut->nLeaves ); nLeavesNew = Abc_TtMinBase( pTruth, pCut->pLeaves, pCut->nLeaves, pCut->nLeaves );
if ( nLeavesNew < If_CutLeaveNum(pCut) ) if ( nLeavesNew < If_CutLeaveNum(pCut) )
...@@ -211,9 +211,11 @@ if ( fVerbose ) ...@@ -211,9 +211,11 @@ if ( fVerbose )
} }
} }
// compute canonical form // compute canonical form
uCanonPhase = Abc_TtCanonicize( pTruth, pCut->nLeaves, pCanonPerm ); clk = Abc_Clock();
p->uCanonPhase = Abc_TtCanonicize( pTruth, pCut->nLeaves, p->pCanonPerm );
p->timeCache[3] += Abc_Clock() - clk;
for ( v = 0; v < (int)pCut->nLeaves; v++ ) for ( v = 0; v < (int)pCut->nLeaves; v++ )
pPerm[v] = Abc_LitNotCond( pCut->pLeaves[(int)pCanonPerm[v]], ((uCanonPhase>>v)&1) ); pPerm[v] = Abc_LitNotCond( pCut->pLeaves[(int)p->pCanonPerm[v]], ((p->uCanonPhase>>v)&1) );
pCut->iCutDsd = 0; pCut->iCutDsd = 0;
for ( v = 0; v < (int)pCut->nLeaves; v++ ) for ( v = 0; v < (int)pCut->nLeaves; v++ )
{ {
...@@ -228,7 +230,7 @@ if ( fVerbose ) ...@@ -228,7 +230,7 @@ if ( fVerbose )
assert( pCut->uSign == If_ObjCutSignCompute( pCut ) ); assert( pCut->uSign == If_ObjCutSignCompute( pCut ) );
// hash function // hash function
fCompl = ((uCanonPhase >> pCut->nLeaves) & 1); fCompl = ((p->uCanonPhase >> pCut->nLeaves) & 1);
truthId = Vec_MemHashInsert( p->vTtMem[pCut->nLeaves], pTruth ); truthId = Vec_MemHashInsert( p->vTtMem[pCut->nLeaves], pTruth );
pCut->iCutFunc = Abc_Var2Lit( truthId, fCompl ); pCut->iCutFunc = Abc_Var2Lit( truthId, fCompl );
...@@ -245,36 +247,33 @@ if ( fVerbose ) ...@@ -245,36 +247,33 @@ if ( fVerbose )
} }
int If_CutComputeTruthPerm( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int iCutFunc0, int iCutFunc1 ) int If_CutComputeTruthPerm( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int iCutFunc0, int iCutFunc1 )
{ {
int i, k, Num, nEntriesOld, RetValue; abctime clk = Abc_Clock();
// if ( pCut0->nLeaves + pCut1->nLeaves > pCut->nLeaves || iCutFunc0 < 2 || iCutFunc1 < 2 ) int i, Num, nEntriesOld, RetValue;
return If_CutComputeTruthPerm_int( p, pCut, pCut0, pCut1, iCutFunc0, iCutFunc1 ); if ( pCut0->nLeaves + pCut1->nLeaves > pCut->nLeaves || iCutFunc0 < 2 || iCutFunc1 < 2 )
{
RetValue = If_CutComputeTruthPerm_int( p, pCut, pCut0, pCut1, iCutFunc0, iCutFunc1 );
p->timeCache[0] += Abc_Clock() - clk;
return RetValue;
}
assert( pCut0->nLeaves + pCut1->nLeaves == pCut->nLeaves ); assert( pCut0->nLeaves + pCut1->nLeaves == pCut->nLeaves );
nEntriesOld = Hash_IntManEntryNum(p->vPairHash); nEntriesOld = Hash_IntManEntryNum(p->vPairHash);
Num = Hash_Int2ManInsert( p->vPairHash, (iCutFunc0 << 5)|pCut0->nLeaves, (iCutFunc1 << 5)|pCut1->nLeaves, -1 ); Num = Hash_Int2ManInsert( p->vPairHash, (iCutFunc0 << 5)|pCut0->nLeaves, (iCutFunc1 << 5)|pCut1->nLeaves, -1 );
assert( Num > 0 ); assert( Num > 0 );
if ( nEntriesOld == Hash_IntManEntryNum(p->vPairHash) ) if ( nEntriesOld == Hash_IntManEntryNum(p->vPairHash) )
{ {
char * pCanonPerm;
int v, pPerm[IF_MAX_LUTSIZE]; int v, pPerm[IF_MAX_LUTSIZE];
char * pCanonPerm = Vec_StrEntryP( p->vPairPerms, Num * pCut->nLimit );
pCut->iCutFunc = Vec_IntEntry( p->vPairRes, Num ); pCut->iCutFunc = Vec_IntEntry( p->vPairRes, Num );
// move complements from the fanin cuts // move complements from the fanin cuts
for ( v = 0; v < (int)pCut->nLeaves; v++ ) for ( v = 0; v < (int)pCut->nLeaves; v++ )
if ( v < (int)pCut0->nLeaves ) if ( v < (int)pCut0->nLeaves )
{
assert( pCut->pLeaves[v] == pCut0->pLeaves[v] );
pCut->pLeaves[v] = Abc_Var2Lit( pCut->pLeaves[v], If_CutLeafBit(pCut0, v) ); pCut->pLeaves[v] = Abc_Var2Lit( pCut->pLeaves[v], If_CutLeafBit(pCut0, v) );
}
else else
{
assert( pCut->pLeaves[v] == pCut1->pLeaves[v-(int)pCut0->nLeaves] );
pCut->pLeaves[v] = Abc_Var2Lit( pCut->pLeaves[v], If_CutLeafBit(pCut1, v-(int)pCut0->nLeaves) ); pCut->pLeaves[v] = Abc_Var2Lit( pCut->pLeaves[v], If_CutLeafBit(pCut1, v-(int)pCut0->nLeaves) );
}
// reorder the cut // reorder the cut
pCanonPerm = Vec_StrEntryP( p->vPairPerms, Num * pCut->nLimit );
for ( v = 0; v < (int)pCut->nLeaves; v++ ) for ( v = 0; v < (int)pCut->nLeaves; v++ )
{
assert( pCanonPerm[v] >= 0 );
pPerm[v] = Abc_LitNotCond( pCut->pLeaves[Abc_Lit2Var((int)pCanonPerm[v])], Abc_LitIsCompl((int)pCanonPerm[v]) ); pPerm[v] = Abc_LitNotCond( pCut->pLeaves[Abc_Lit2Var((int)pCanonPerm[v])], Abc_LitIsCompl((int)pCanonPerm[v]) );
}
// generate the result // generate the result
pCut->iCutDsd = 0; pCut->iCutDsd = 0;
for ( v = 0; v < (int)pCut->nLeaves; v++ ) for ( v = 0; v < (int)pCut->nLeaves; v++ )
...@@ -284,8 +283,11 @@ int If_CutComputeTruthPerm( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_ ...@@ -284,8 +283,11 @@ int If_CutComputeTruthPerm( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_
pCut->iCutDsd |= (1 << v); pCut->iCutDsd |= (1 << v);
} }
// printf( "Found: %d(%d) %d(%d) -> %d(%d)\n", iCutFunc0, pCut0->nLeaves, iCutFunc1, pCut0->nLeaves, pCut->iCutFunc, pCut->nLeaves ); // printf( "Found: %d(%d) %d(%d) -> %d(%d)\n", iCutFunc0, pCut0->nLeaves, iCutFunc1, pCut0->nLeaves, pCut->iCutFunc, pCut->nLeaves );
p->nCacheHits++;
p->timeCache[1] += Abc_Clock() - clk;
return 0; return 0;
} }
p->nCacheMisses++;
RetValue = If_CutComputeTruthPerm_int( p, pCut, pCut0, pCut1, iCutFunc0, iCutFunc1 ); RetValue = If_CutComputeTruthPerm_int( p, pCut, pCut0, pCut1, iCutFunc0, iCutFunc1 );
assert( RetValue == 0 ); assert( RetValue == 0 );
// printf( "Added: %d(%d) %d(%d) -> %d(%d)\n", iCutFunc0, pCut0->nLeaves, iCutFunc1, pCut0->nLeaves, pCut->iCutFunc, pCut->nLeaves ); // printf( "Added: %d(%d) %d(%d) -> %d(%d)\n", iCutFunc0, pCut0->nLeaves, iCutFunc1, pCut0->nLeaves, pCut->iCutFunc, pCut->nLeaves );
...@@ -294,16 +296,11 @@ int If_CutComputeTruthPerm( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_ ...@@ -294,16 +296,11 @@ int If_CutComputeTruthPerm( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_
Vec_IntPush( p->vPairRes, pCut->iCutFunc ); Vec_IntPush( p->vPairRes, pCut->iCutFunc );
// save the permutation // save the permutation
assert( Num * (int)pCut->nLimit == Vec_StrSize(p->vPairPerms) ); assert( Num * (int)pCut->nLimit == Vec_StrSize(p->vPairPerms) );
for ( i = 0; i < (int)pCut0->nLeaves; i++ ) for ( i = 0; i < (int)pCut->nLeaves; i++ )
for ( k = 0; k < (int)pCut->nLeaves; k++ ) Vec_StrPush( p->vPairPerms, (char)Abc_Var2Lit((int)p->pCanonPerm[i], ((p->uCanonPhase>>i)&1)) );
if ( pCut0->pLeaves[i] == pCut->pLeaves[k] )
{ Vec_StrPush( p->vPairPerms, (char)Abc_Var2Lit(k, If_CutLeafBit(pCut0, i) != If_CutLeafBit(pCut, k)) ); break; }
for ( i = 0; i < (int)pCut1->nLeaves; i++ )
for ( k = 0; k < (int)pCut->nLeaves; k++ )
if ( pCut1->pLeaves[i] == pCut->pLeaves[k] )
{ Vec_StrPush( p->vPairPerms, (char)Abc_Var2Lit(k, If_CutLeafBit(pCut1, i) != If_CutLeafBit(pCut, k)) ); break; }
for ( i = (int)pCut0->nLeaves + (int)pCut1->nLeaves; i < (int)pCut->nLimit; i++ ) for ( i = (int)pCut0->nLeaves + (int)pCut1->nLeaves; i < (int)pCut->nLimit; i++ )
Vec_StrPush( p->vPairPerms, (char)-1 ); Vec_StrPush( p->vPairPerms, (char)-1 );
p->timeCache[2] += Abc_Clock() - clk;
return 0; return 0;
} }
......
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