Commit bd7b5511 by Alan Mishchenko

Improvements to LMS code.

parent a20e32f9
...@@ -806,6 +806,7 @@ extern ABC_DLL void Abc_NtkRecPs3(int fPrintLib); ...@@ -806,6 +806,7 @@ extern ABC_DLL void Abc_NtkRecPs3(int fPrintLib);
extern ABC_DLL Gia_Man_t * Abc_NtkRecGetGia3(); extern ABC_DLL Gia_Man_t * Abc_NtkRecGetGia3();
extern ABC_DLL int Abc_NtkRecIsRunning3(); extern ABC_DLL int Abc_NtkRecIsRunning3();
extern ABC_DLL void Abc_NtkRecLibMerge3(Gia_Man_t * pGia); extern ABC_DLL void Abc_NtkRecLibMerge3(Gia_Man_t * pGia);
extern ABC_DLL int Abc_NtkRecInputNum3();
//extern ABC_DLL void Abc_NtkRecFilter3(int nLimit); //extern ABC_DLL void Abc_NtkRecFilter3(int nLimit);
/*=== abcReconv.c ==========================================================*/ /*=== abcReconv.c ==========================================================*/
extern ABC_DLL Abc_ManCut_t * Abc_NtkManCutStart( int nNodeSizeMax, int nConeSizeMax, int nNodeFanStop, int nConeFanStop ); extern ABC_DLL Abc_ManCut_t * Abc_NtkManCutStart( int nNodeSizeMax, int nConeSizeMax, int nNodeFanStop, int nConeFanStop );
......
...@@ -876,6 +876,12 @@ void Abc_End( Abc_Frame_t * pAbc ) ...@@ -876,6 +876,12 @@ void Abc_End( Abc_Frame_t * pAbc )
Gia_ManStop( Abc_FrameGetGlobalFrame()->pGia ); Gia_ManStop( Abc_FrameGetGlobalFrame()->pGia );
if ( Abc_FrameGetGlobalFrame()->pGia2 ) if ( Abc_FrameGetGlobalFrame()->pGia2 )
Gia_ManStop( Abc_FrameGetGlobalFrame()->pGia2 ); Gia_ManStop( Abc_FrameGetGlobalFrame()->pGia2 );
if ( Abc_NtkRecIsRunning() )
Abc_NtkRecStop();
if ( Abc_NtkRecIsRunning2() )
Abc_NtkRecStop2();
if ( Abc_NtkRecIsRunning3() )
Abc_NtkRecStop3();
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -14837,6 +14843,20 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -14837,6 +14843,20 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->nLutSize = pPars->nGateSize; pPars->nLutSize = pPars->nGateSize;
} }
if ( pPars->fUserRecLib )
{
if ( Abc_NtkRecIsRunning() + Abc_NtkRecIsRunning2() + Abc_NtkRecIsRunning3() != 1 )
{
printf( "Exactly one LMS manager should be running.\n" );
return 0;
}
if ( Abc_NtkRecIsRunning3() && Abc_NtkRecInputNum3() != pPars->nLutSize )
{
printf( "The number of library inputs (%d) different from the K parameters (%d).\n", Abc_NtkRecInputNum3(), pPars->nLutSize );
return 0;
}
}
/* /*
// modify for LUT structures // modify for LUT structures
if ( pPars->pLutStruct ) if ( pPars->pLutStruct )
......
...@@ -80,7 +80,7 @@ struct Lms_Man_t_ ...@@ -80,7 +80,7 @@ struct Lms_Man_t_
int nAddedFuncs; int nAddedFuncs;
int nHoleInTheWall; int nHoleInTheWall;
// runtime // runtime
clock_t timeCollect; clock_t timeTruth;
clock_t timeCanon; clock_t timeCanon;
clock_t timeBuild; clock_t timeBuild;
clock_t timeCheck; clock_t timeCheck;
...@@ -109,6 +109,7 @@ static Lms_Man_t * s_pMan3 = NULL; ...@@ -109,6 +109,7 @@ static Lms_Man_t * s_pMan3 = NULL;
Lms_Man_t * Lms_ManStart( Gia_Man_t * pGia, int nVars, int nCuts, int fFuncOnly, int fVerbose ) Lms_Man_t * Lms_ManStart( Gia_Man_t * pGia, int nVars, int nCuts, int fFuncOnly, int fVerbose )
{ {
Lms_Man_t * p; Lms_Man_t * p;
clock_t clk, clk2 = clock();
// if GIA is given, use the number of variables from GIA // if GIA is given, use the number of variables from GIA
nVars = pGia ? Gia_ManCiNum(pGia) : nVars; nVars = pGia ? Gia_ManCiNum(pGia) : nVars;
assert( nVars >= 6 && nVars <= 16 ); assert( nVars >= 6 && nVars <= 16 );
...@@ -141,8 +142,12 @@ Lms_Man_t * Lms_ManStart( Gia_Man_t * pGia, int nVars, int nCuts, int fFuncOnly, ...@@ -141,8 +142,12 @@ Lms_Man_t * Lms_ManStart( Gia_Man_t * pGia, int nVars, int nCuts, int fFuncOnly,
p->nAdded = Gia_ManCoNum( p->pGia ); p->nAdded = Gia_ManCoNum( p->pGia );
Gia_ManForEachCo( p->pGia, pObj, i ) Gia_ManForEachCo( p->pGia, pObj, i )
{ {
clk = clock();
pTruth = Gia_ObjComputeTruthTable( p->pGia, pObj ); pTruth = Gia_ObjComputeTruthTable( p->pGia, pObj );
p->timeTruth += clock() - clk;
clk = clock();
Index = Vec_MemHashInsert( p->vTtMem, (word *)pTruth ); Index = Vec_MemHashInsert( p->vTtMem, (word *)pTruth );
p->timeInsert += clock() - clk;
assert( Index == Prev || Index == Prev + 1 ); // GIA subgraphs should be ordered assert( Index == Prev || Index == Prev + 1 ); // GIA subgraphs should be ordered
Vec_IntPush( p->vTruthIds, Index ); Vec_IntPush( p->vTruthIds, Index );
Prev = Index; Prev = Index;
...@@ -152,6 +157,7 @@ Lms_Man_t * Lms_ManStart( Gia_Man_t * pGia, int nVars, int nCuts, int fFuncOnly, ...@@ -152,6 +157,7 @@ Lms_Man_t * Lms_ManStart( Gia_Man_t * pGia, int nVars, int nCuts, int fFuncOnly,
p->vNodes = Vec_PtrAlloc( 1000 ); p->vNodes = Vec_PtrAlloc( 1000 );
p->vLabelsP = Vec_PtrAlloc( 1000 ); p->vLabelsP = Vec_PtrAlloc( 1000 );
p->vLabels = Vec_IntAlloc( 1000 ); p->vLabels = Vec_IntAlloc( 1000 );
p->timeTotal += clock() - clk2;
return p; return p;
} }
void Lms_ManStop( Lms_Man_t * p ) void Lms_ManStop( Lms_Man_t * p )
...@@ -191,14 +197,14 @@ void Lms_ManPrint( Lms_Man_t * p ) ...@@ -191,14 +197,14 @@ void Lms_ManPrint( Lms_Man_t * p )
if ( p->nHoleInTheWall ) if ( p->nHoleInTheWall )
printf( "Cuts whose logic structure has a hole = %10d. (%6.2f %%)\n", p->nHoleInTheWall, !p->nTried? 0 : 100.0*p->nHoleInTheWall/p->nTried ); printf( "Cuts whose logic structure has a hole = %10d. (%6.2f %%)\n", p->nHoleInTheWall, !p->nTried? 0 : 100.0*p->nHoleInTheWall/p->nTried );
p->timeOther = p->timeTotal - p->timeCollect - p->timeCanon - p->timeBuild - p->timeCheck - p->timeInsert; p->timeOther = p->timeTotal - p->timeTruth - p->timeCanon - p->timeBuild - p->timeCheck - p->timeInsert;
ABC_PRTP( "Runtime: Collect", p->timeCollect, p->timeTotal ); ABC_PRTP( "Runtime: Truth ", p->timeTruth, p->timeTotal );
ABC_PRTP( "Runtime: Canon ", p->timeCanon, p->timeTotal ); ABC_PRTP( "Runtime: Canon ", p->timeCanon, p->timeTotal );
ABC_PRTP( "Runtime: Build ", p->timeBuild, p->timeTotal ); ABC_PRTP( "Runtime: Build ", p->timeBuild, p->timeTotal );
ABC_PRTP( "Runtime: Check ", p->timeCheck, p->timeTotal ); ABC_PRTP( "Runtime: Check ", p->timeCheck, p->timeTotal );
ABC_PRTP( "Runtime: Insert ", p->timeInsert, p->timeTotal ); ABC_PRTP( "Runtime: Insert", p->timeInsert, p->timeTotal );
ABC_PRTP( "Runtime: Other ", p->timeOther, p->timeTotal ); ABC_PRTP( "Runtime: Other ", p->timeOther, p->timeTotal );
ABC_PRTP( "Runtime: TOTAL ", p->timeTotal, p->timeTotal ); ABC_PRTP( "Runtime: TOTAL ", p->timeTotal, p->timeTotal );
} }
...@@ -470,6 +476,11 @@ void Abc_NtkRecLibMerge3( Gia_Man_t * pLib ) ...@@ -470,6 +476,11 @@ void Abc_NtkRecLibMerge3( Gia_Man_t * pLib )
Gia_Obj_t * pObjPo, * pDriver, * pTemp = NULL; Gia_Obj_t * pObjPo, * pDriver, * pTemp = NULL;
clock_t clk, clk2 = clock(); clock_t clk, clk2 = clock();
if ( Gia_ManCiNum(pLib) != Gia_ManCiNum(pGia) )
{
printf( "The number of Library inputs (%d) differs from the number of Gia inputs (%d).\n", Gia_ManCiNum(pLib), Gia_ManCiNum(pGia) );
return;
}
assert( Gia_ManCiNum(pLib) == Gia_ManCiNum(pGia) ); assert( Gia_ManCiNum(pLib) == Gia_ManCiNum(pGia) );
// create hash table if not available // create hash table if not available
...@@ -486,7 +497,7 @@ void Abc_NtkRecLibMerge3( Gia_Man_t * pLib ) ...@@ -486,7 +497,7 @@ void Abc_NtkRecLibMerge3( Gia_Man_t * pLib )
// compute the truth table // compute the truth table
clk = clock(); clk = clock();
pTruth = Gia_ObjComputeTruthTable( pLib, Gia_ObjFanin0(pObjPo) ); pTruth = Gia_ObjComputeTruthTable( pLib, Gia_ObjFanin0(pObjPo) );
p->timeCollect += clock() - clk; p->timeTruth += clock() - clk;
// semi-canonicize // semi-canonicize
clk = clock(); clk = clock();
memcpy( p->pTemp1, pTruth, p->nWords * sizeof(word) ); memcpy( p->pTemp1, pTruth, p->nWords * sizeof(word) );
...@@ -599,7 +610,7 @@ int Abc_NtkRecAddCut3( If_Man_t * pIfMan, If_Obj_t * pRoot, If_Cut_t * pCut ) ...@@ -599,7 +610,7 @@ int Abc_NtkRecAddCut3( If_Man_t * pIfMan, If_Obj_t * pRoot, If_Cut_t * pCut )
// collect internal nodes and skip redundant cuts // collect internal nodes and skip redundant cuts
clk = clock(); clk = clock();
If_CutTraverse( pIfMan, pRoot, pCut, vNodes ); If_CutTraverse( pIfMan, pRoot, pCut, vNodes );
p->timeCollect += clock() - clk; p->timeTruth += clock() - clk;
// semi-canonicize truth table // semi-canonicize truth table
clk = clock(); clk = clock();
...@@ -1132,13 +1143,17 @@ Gia_Man_t * Abc_NtkRecGetGia3() ...@@ -1132,13 +1143,17 @@ Gia_Man_t * Abc_NtkRecGetGia3()
{ {
clock_t clk = clock(); clock_t clk = clock();
printf( "Before normalizing: Library has %d classes and %d AIG subgraphs with %d AND nodes.\n", printf( "Before normalizing: Library has %d classes and %d AIG subgraphs with %d AND nodes.\n",
Vec_MemEntryNum(s_pMan3->vTtMem), s_pMan3->nAdded, Gia_ManAndNum(s_pMan3->pGia) ); Vec_MemEntryNum(s_pMan3->vTtMem), Gia_ManPoNum(s_pMan3->pGia), Gia_ManAndNum(s_pMan3->pGia) );
Lms_GiaNormalize( s_pMan3 ); Lms_GiaNormalize( s_pMan3 );
printf( "After normalizing: Library has %d classes and %d AIG subgraphs with %d AND nodes.\n", printf( "After normalizing: Library has %d classes and %d AIG subgraphs with %d AND nodes.\n",
Vec_MemEntryNum(s_pMan3->vTtMem), s_pMan3->nAdded, Gia_ManAndNum(s_pMan3->pGia) ); Vec_MemEntryNum(s_pMan3->vTtMem), Gia_ManPoNum(s_pMan3->pGia), Gia_ManAndNum(s_pMan3->pGia) );
Abc_PrintTime( 1, "Normalization runtime", clock() - clk ); Abc_PrintTime( 1, "Normalization runtime", clock() - clk );
return s_pMan3->pGia; return s_pMan3->pGia;
} }
int Abc_NtkRecInputNum3()
{
return Gia_ManCiNum(s_pMan3->pGia);
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
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