Commit 8638b13e by Alan Mishchenko

Expriments with functions (bug fixes).

parent 197c65be
...@@ -23027,6 +23027,17 @@ int Abc_CommandFunEnum( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -23027,6 +23027,17 @@ int Abc_CommandFunEnum( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage; goto usage;
} }
} }
if ( nVars < 2 || nVars > 6 )
{
Abc_Print( -1, "The number of inputs should be 2 <= N <= 6.\n" );
goto usage;
}
if ( nInputs < nVars || nInputs > 6 )
{
Abc_Print( -1, "The intermediate support size should be N <= S <= 6.\n" );
goto usage;
}
Dau_FunctionEnum( nInputs, nVars, fVerbose ); Dau_FunctionEnum( nInputs, nVars, fVerbose );
return 0; return 0;
...@@ -370,7 +370,7 @@ int Gem_Enumerate( int nVars, int fDump, int fVerbose ) ...@@ -370,7 +370,7 @@ int Gem_Enumerate( int nVars, int fDump, int fVerbose )
if ( Gem_FuncReduce( p, f, i, j ) ) if ( Gem_FuncReduce( p, f, i, j ) )
return Gem_ManFree( p ); return Gem_ManFree( p );
} }
printf( "Finished (functions = %10d) ", v, p->nObjs ); printf( "Finished (functions = %10d) ", p->nObjs );
Abc_PrintTime( 0, "Time", Abc_Clock() - clk ); Abc_PrintTime( 0, "Time", Abc_Clock() - clk );
if ( fDump ) Vec_MemDumpTruthTables( p->vTtMem, "enum", nVars ); if ( fDump ) Vec_MemDumpTruthTables( p->vTtMem, "enum", nVars );
Gem_ManFree( p ); Gem_ManFree( p );
......
...@@ -1230,6 +1230,13 @@ unsigned Abc_TtCanonicizeHie( Abc_TtHieMan_t * p, word * pTruthInit, int nVars, ...@@ -1230,6 +1230,13 @@ unsigned Abc_TtCanonicizeHie( Abc_TtHieMan_t * p, word * pTruthInit, int nVars,
int i, k; int i, k;
assert( nVars <= 16 ); assert( nVars <= 16 );
// handle constant
if ( nVars == 0 )
{
Abc_TtClear( pTruthInit, nWords );
return 0;
}
Abc_TtCopy( pTruth, pTruthInit, nWords, 0 ); Abc_TtCopy( pTruth, pTruthInit, nWords, 0 );
for ( i = 0; i < nVars; i++ ) for ( i = 0; i < nVars; i++ )
......
...@@ -467,15 +467,16 @@ int Dau_CountFuncs( Vec_Int_t * vNodSup, int iStart, int iStop, int nVars ) ...@@ -467,15 +467,16 @@ int Dau_CountFuncs( Vec_Int_t * vNodSup, int iStart, int iStop, int nVars )
Count += ((Entry & 0xF) <= nVars); Count += ((Entry & 0xF) <= nVars);
return Count; return Count;
} }
int Dau_PrintStats( int nNodes, int nInputs, int nVars, Vec_Int_t * vNodSup, int iStart, int iStop, abctime clk ) int Dau_PrintStats( int nNodes, int nInputs, int nVars, Vec_Int_t * vNodSup, int iStart, int iStop, word nSteps, abctime clk )
{ {
int nNew; int nNew;
printf("Nodes = %2d. ", nNodes ); printf("N =%2d | ", nNodes );
printf("New%d = %10d. ", nInputs, iStop-iStart ); printf("C =%12.0f ", (double)(iword)nSteps );
printf("Total%d = %10d. ", nInputs, iStop ); printf("New%d =%10d ", nInputs, iStop-iStart );
printf("New%d = %10d. ", nVars, nNew = Dau_CountFuncs(vNodSup, iStart, iStop, nVars) ); printf("All%d =%10d | ", nInputs, iStop );
printf("Total%d = %10d. ", nVars, Dau_CountFuncs(vNodSup, 0, iStop, nVars) ); printf("New%d =%8d ", nVars, nNew = Dau_CountFuncs(vNodSup, iStart, iStop, nVars) );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); printf("All%d =%8d ", nVars, Dau_CountFuncs(vNodSup, 0, iStop, nVars) );
Abc_PrintTime( 1, "T", Abc_Clock() - clk );
fflush(stdout); fflush(stdout);
return nNew; return nNew;
} }
...@@ -483,13 +484,13 @@ int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInp ...@@ -483,13 +484,13 @@ int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInp
{ {
char Perm[16] = {0}; char Perm[16] = {0};
int nVarsNew = Abc_TtMinBase( pCur, NULL, nVars, nInputs ); int nVarsNew = Abc_TtMinBase( pCur, NULL, nVars, nInputs );
unsigned Phase = nVarsNew ? Abc_TtCanonicizeHie( pMan, pCur, nVarsNew, Perm, 1 ) : 0; unsigned Phase = Abc_TtCanonicizeHie( pMan, pCur, nVarsNew, Perm, 1 );
int nEntries = Vec_MemEntryNum(vTtMem); int nEntries = Vec_MemEntryNum(vTtMem);
int Entry = Vec_MemHashInsert( vTtMem, pCur ); int Entry = Vec_MemHashInsert( vTtMem, pCur );
if ( nEntries == Vec_MemEntryNum(vTtMem) ) // found in the table - not new if ( nEntries == Vec_MemEntryNum(vTtMem) ) // found in the table - not new
return 0; return 0;
Phase = 0; Phase = 0;
nEntries = 0; Entry = 0;
// this is a new class // this is a new class
Vec_IntPush( vNodSup, (nNodes << 16) | nVarsNew ); Vec_IntPush( vNodSup, (nNodes << 16) | nVarsNew );
assert( Vec_MemEntryNum(vTtMem) == Vec_IntSize(vNodSup) ); assert( Vec_MemEntryNum(vTtMem) == Vec_IntSize(vNodSup) );
...@@ -498,7 +499,7 @@ int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInp ...@@ -498,7 +499,7 @@ int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInp
void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose ) void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose )
{ {
abctime clk = Abc_Clock(); abctime clk = Abc_Clock();
int nWords = Abc_TtWordNum(nInputs); int nWords = Abc_TtWordNum(nInputs); word nSteps = 0;
Abc_TtHieMan_t * pMan = Abc_TtHieManStart( nInputs, 5 ); Abc_TtHieMan_t * pMan = Abc_TtHieManStart( nInputs, 5 );
Vec_Mem_t * vTtMem = Vec_MemAlloc( nWords, 16 ); Vec_Mem_t * vTtMem = Vec_MemAlloc( nWords, 16 );
Vec_Int_t * vNodSup = Vec_IntAlloc( 1 << 16 ); Vec_Int_t * vNodSup = Vec_IntAlloc( 1 << 16 );
...@@ -514,7 +515,7 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose ) ...@@ -514,7 +515,7 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose )
Abc_TtNot( Truth, nWords ); Abc_TtNot( Truth, nWords );
Vec_MemHashInsert( vTtMem, Truth ); Vec_MemHashInsert( vTtMem, Truth );
Vec_IntPush( vNodSup, 1 ); // nodes=0, supp=1 Vec_IntPush( vNodSup, 1 ); // nodes=0, supp=1
Dau_PrintStats( 0, nInputs, nVars, vNodSup, 0, 2, clk ); Dau_PrintStats( 0, nInputs, nVars, vNodSup, 0, 2, nSteps, clk );
// numerate other functions based on how many nodes they have // numerate other functions based on how many nodes they have
for ( n = 1; n < 32; n++ ) for ( n = 1; n < 32; n++ )
{ {
...@@ -554,6 +555,7 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose ) ...@@ -554,6 +555,7 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose )
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp+1, vTtMem, vNodSup ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp+1, vTtMem, vNodSup );
} }
} }
nSteps += 3;
} }
for ( g = 0; g < 2; g++ ) for ( g = 0; g < 2; g++ )
{ {
...@@ -582,6 +584,7 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose ) ...@@ -582,6 +584,7 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose )
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vNodSup ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vNodSup );
} }
nSteps += 5;
} }
} }
for ( g = 0; g < 2; g++ ) for ( g = 0; g < 2; g++ )
...@@ -626,13 +629,14 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose ) ...@@ -626,13 +629,14 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose )
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vNodSup ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vNodSup );
} }
nSteps += 9;
} }
} }
} }
} }
iStart = iStop; iStart = iStop;
iStop = Vec_IntSize(vNodSup); iStop = Vec_IntSize(vNodSup);
nNew = Dau_PrintStats( n, nInputs, nVars, vNodSup, iStart, iStop, clk ); nNew = Dau_PrintStats( n, nInputs, nVars, vNodSup, iStart, iStop, nSteps, clk );
if ( nNew == 0 ) if ( nNew == 0 )
break; break;
} }
......
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