Commit 36f33bc7 by Alan Mishchenko

Expriments with functions (bug fixes).

parent fff82d4d
...@@ -499,7 +499,7 @@ void Dau_ExactNpnPrint( Vec_Mem_t * vTtMem, Vec_Int_t * vNodSup, int nVars, int ...@@ -499,7 +499,7 @@ void Dau_ExactNpnPrint( Vec_Mem_t * vTtMem, Vec_Int_t * vNodSup, int nVars, int
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Dau_TablesSave( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTtMemA, Vec_Int_t * vNodSup, Vec_Int_t * vMapping ) void Dau_TablesSave( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTtMemA, Vec_Int_t * vNodSup, Vec_Int_t * vMapping, int nFronts )
{ {
FILE * pFile; FILE * pFile;
char FileName[100]; char FileName[100];
...@@ -518,7 +518,8 @@ void Dau_TablesSave( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTt ...@@ -518,7 +518,8 @@ void Dau_TablesSave( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTt
fwrite( Vec_MemReadEntry(vTtMem, i), 8, nWords, pFile ); fwrite( Vec_MemReadEntry(vTtMem, i), 8, nWords, pFile );
fwrite( Vec_IntArray(vNodSup), 4, Vec_IntSize(vNodSup), pFile ); fwrite( Vec_IntArray(vNodSup), 4, Vec_IntSize(vNodSup), pFile );
fclose( pFile ); fclose( pFile );
printf( "Dumped files with %10d functions and %10d classes.\n", Vec_IntSize(vMapping), Vec_IntSize(vNodSup) ); printf( "Dumped files with %10d functions and %10d classes after exploring %10d frontiers.\n",
Vec_IntSize(vMapping), Vec_IntSize(vNodSup), nFronts );
fflush(stdout); fflush(stdout);
} }
void Dau_TablesLoad( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTtMemA, Vec_Int_t * vNodSup, Vec_Int_t * vMapping ) void Dau_TablesLoad( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTtMemA, Vec_Int_t * vNodSup, Vec_Int_t * vMapping )
...@@ -597,26 +598,29 @@ int Dau_PrintStats( int nNodes, int nInputs, int nVars, Vec_Int_t * vNodSup, int ...@@ -597,26 +598,29 @@ int Dau_PrintStats( int nNodes, int nInputs, int nVars, Vec_Int_t * vNodSup, int
fflush(stdout); fflush(stdout);
return nNew; return nNew;
} }
int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTtMemA, Vec_Int_t * vNodSup, Vec_Int_t * vMapping ) int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInputs, int nVars0, int nVars,
Vec_Mem_t * vTtMem, Vec_Mem_t * vTtMemA, Vec_Int_t * vNodSup, Vec_Int_t * vMapping, int nFronts )
{ {
int DumpDelta = 100000000; int DumpDelta = 1000000;
int nEntries = Vec_MemEntryNum(vTtMemA); // int DumpDelta = 125000000;
Vec_MemHashInsert( vTtMemA, pCur ); // int nEntries = Vec_MemEntryNum(vTtMemA);
if ( nEntries == Vec_MemEntryNum(vTtMemA) ) // found in the table - not new // Vec_MemHashInsert( vTtMemA, pCur );
return 0; // if ( nEntries == Vec_MemEntryNum(vTtMemA) ) // found in the table - not new
else // this is a new function // return 0;
// else // this is a new function
{ {
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 = Abc_TtCanonicizeHie( pMan, pCur, nVarsNew, Perm, 1 ); 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 );
Vec_IntPush( vMapping, Entry ); //Vec_IntPush( vMapping, Entry );
assert( Vec_MemEntryNum(vTtMemA) == Vec_IntSize(vMapping) ); //assert( Vec_MemEntryNum(vTtMemA) == Vec_IntSize(vMapping) );
if ( nEntries == Vec_MemEntryNum(vTtMem) ) // found in the table - not new if ( nEntries == Vec_MemEntryNum(vTtMem) ) // found in the table - not new
{ {
if ( Vec_IntSize(vMapping) % DumpDelta == 0 ) //if ( Vec_IntSize(vMapping) % DumpDelta == 0 )
Dau_TablesSave( nInputs, nVars, vTtMem, vTtMemA, vNodSup, vMapping ); //if ( Vec_IntSize(vNodSup) % DumpDelta == 0 )
// Dau_TablesSave( nInputs, nVars0, vTtMem, vTtMemA, vNodSup, vMapping, nFronts );
return 0; return 0;
} }
Phase = 0; Phase = 0;
...@@ -624,8 +628,9 @@ int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInp ...@@ -624,8 +628,9 @@ int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInp
// 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) );
if ( Vec_IntSize(vMapping) % DumpDelta == 0 ) //if ( Vec_IntSize(vMapping) % DumpDelta == 0 )
Dau_TablesSave( nInputs, nVars, vTtMem, vTtMemA, vNodSup, vMapping ); if ( Vec_IntSize(vNodSup) % DumpDelta == 0 )
Dau_TablesSave( nInputs, nVars0, vTtMem, vTtMemA, vNodSup, vMapping, nFronts );
return 1; return 1;
} }
} }
...@@ -688,16 +693,16 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose ) ...@@ -688,16 +693,16 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose )
{ {
tGate = s_Truths6[v] & s_Truths6[nSupp]; tGate = s_Truths6[v] & s_Truths6[nSupp];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp+1, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp+1, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp+1, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp+1, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
} }
else else
{ {
tGate = s_Truths6[v] ^ s_Truths6[nSupp]; tGate = s_Truths6[v] ^ s_Truths6[nSupp];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp+1, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp+1, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
} }
} }
nSteps += 3; nSteps += 3;
...@@ -711,23 +716,23 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose ) ...@@ -711,23 +716,23 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose )
{ {
tGate = s_Truths6[v] & s_Truths6[k]; tGate = s_Truths6[v] & s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
tGate = s_Truths6[v] & ~s_Truths6[k]; tGate = s_Truths6[v] & ~s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
} }
else else
{ {
tGate = s_Truths6[v] ^ s_Truths6[k]; tGate = s_Truths6[v] ^ s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
} }
nSteps += 5; nSteps += 5;
} }
...@@ -742,37 +747,37 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose ) ...@@ -742,37 +747,37 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose )
{ {
tGate = s_Truths6[m] & s_Truths6[k]; tGate = s_Truths6[m] & s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
tGate = s_Truths6[m] & ~s_Truths6[k]; tGate = s_Truths6[m] & ~s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
tGate = ~s_Truths6[m] & s_Truths6[k]; tGate = ~s_Truths6[m] & s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
tGate = ~s_Truths6[m] & ~s_Truths6[k]; tGate = ~s_Truths6[m] & ~s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
} }
else else
{ {
tGate = s_Truths6[m] ^ s_Truths6[k]; tGate = s_Truths6[m] ^ s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nSupp, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry );
} }
nSteps += 9; nSteps += 9;
} }
...@@ -785,7 +790,7 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose ) ...@@ -785,7 +790,7 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose )
if ( nNew == 0 ) if ( nNew == 0 )
break; break;
} }
Dau_TablesSave( nInputs, nVars, vTtMem, vTtMemA, vNodSup, vMapping ); Dau_TablesSave( nInputs, nVars, vTtMem, vTtMemA, vNodSup, vMapping, Vec_IntSize(vNodSup) );
Abc_PrintTime( 1, "Total time", Abc_Clock() - clk ); Abc_PrintTime( 1, "Total time", Abc_Clock() - clk );
//Dau_ExactNpnPrint( vTtMem, vTtMemA, vNodSup, nVars, nInputs, n ); //Dau_ExactNpnPrint( vTtMem, vTtMemA, vNodSup, nVars, nInputs, n );
Abc_TtHieManStop( pMan ); Abc_TtHieManStop( pMan );
......
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