From 3dc77bbe1c72763ba82b8c3e13ecc607081a7c92 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 9 Mar 2025 23:52:03 -0700 Subject: [PATCH] Bug fix in "stochmap". --- src/base/abci/abcPart.c | 40 +++++++++++++++++++++++++++++++++------- src/map/mio/mio.c | 2 +- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/base/abci/abcPart.c b/src/base/abci/abcPart.c index 214709b3c..0b8f01c1a 100644 --- a/src/base/abci/abcPart.c +++ b/src/base/abci/abcPart.c @@ -1287,10 +1287,23 @@ typedef struct StochSynData_t_ Abc_Ntk_t * Abc_NtkStochProcessOne( Abc_Ntk_t * p, char * pScript, int Rand, int TimeSecs ) { Abc_Ntk_t * pNew, * pTemp; - char FileName[100], Command[1000]; + char * pSpot, FileName[100], Command[1000]; sprintf( FileName, "%06x.blif", Rand ); - Io_WriteBlif( p, FileName, 0, 0, 0 ); - sprintf( Command, "./abc -q \"read %s; %s; write %s\"", FileName, pScript, FileName ); + Abc_Ntk_t * pNetlist = Abc_NtkToNetlist(p); + if ( pNetlist == NULL ) { + printf( "Cannot produce an intermediate network.\n" ); + return NULL; + } + Io_WriteBlif( pNetlist, FileName, 1, 0, 0 ); + Abc_NtkDelete( pNetlist ); + if ( (pSpot = strstr(pScript, ".genlib")) ) { + char Spot = pSpot[strlen(".genlib")]; + pSpot[strlen(".genlib")] = 0; + sprintf( Command, "./abc -q \"%s; read %s%c%s; write %s\"", pScript, FileName, Spot, pSpot+strlen(".genlib")+1, FileName ); + pSpot[strlen(".genlib")] = Spot; + } + else + sprintf( Command, "./abc -q \"read %s; %s; write %s\"", FileName, pScript, FileName ); #if defined(__wasm) if ( 1 ) #else @@ -1455,6 +1468,11 @@ void Abc_NtkInsertPartitions_rec( Abc_Ntk_t * pNew, Abc_Obj_t * pObj, Vec_Int_t } Abc_Ntk_t * Abc_NtkInsertPartitions( Abc_Ntk_t * p, Vec_Ptr_t * vvIns, Vec_Ptr_t * vvOuts, Vec_Ptr_t * vWins ) { + if ( vvIns == NULL ) { + assert( vvOuts == NULL ); + assert( Vec_PtrSize(vWins) == 1 ); + return Abc_NtkDupDfs( (Abc_Ntk_t *)Vec_PtrEntry(vWins, 0) ); + } // check consistency of input data Abc_Ntk_t * pNew, * pTemp; Abc_Obj_t * pObj; int i, k, iNode; Vec_PtrForEachEntry( Abc_Ntk_t *, vWins, pTemp, i ) { @@ -1675,6 +1693,8 @@ Vec_Wec_t * Abc_NtkCollectObjectsWithSuppLimit( Abc_Ntk_t * pNtk, int Level, int Abc_NtkForEachNode( pNtk, pObj, i ) if ( Abc_ObjLevel(pObj) > Level && Vec_IntEntry(vSuppIds, i) >= 0 && !Abc_NodeIsTravIdCurrent(pObj) ) { Vec_Int_t * vSupp = Vec_WecEntry( vSupps, Vec_IntEntry(vSuppIds, i) ); + if ( Vec_IntSize(vSupp) < 4 ) + continue; Vec_Int_t * vThis = Vec_WecPushLevel( vResSupps ); Vec_IntGrow( vThis, Vec_IntSize(vSupp) + 1 ); Vec_IntAppend( vThis, vSupp ); @@ -1790,9 +1810,15 @@ Vec_Ptr_t * Abc_NtkDupWindows( Abc_Ntk_t * pNtk, Vec_Ptr_t * vvIns, Vec_Ptr_t * } Vec_Ptr_t * Abc_NtkExtractPartitions( Abc_Ntk_t * pNtk, int Iter, int nSuppMax, Vec_Ptr_t ** pvIns, Vec_Ptr_t ** pvOuts, Vec_Ptr_t ** pvNodes ) { + if ( Abc_NtkCiNum(pNtk) <= nSuppMax ) { + Vec_Ptr_t * vWins = Vec_PtrAlloc( 1 ); + Vec_PtrPush( vWins, Abc_NtkDupDfs(pNtk) ); + *pvIns = *pvOuts = *pvNodes = NULL; + return vWins; + } int iUseRevL = Abc_Random(0) & 1; int LevelMax = iUseRevL ? Abc_NtkLevelR(pNtk) : Abc_NtkLevel(pNtk); - int LevelCut = LevelMax > 8 ? (Abc_Random(0) % (LevelMax - 4)) : 0; + int LevelCut = Iter % 3 == 0 ? 0 : LevelMax > 8 ? 2 + (Abc_Random(0) % (LevelMax - 4)) : 0; //printf( "Using %s cut level %d (out of %d)\n", iUseRevL ? "reverse": "direct", LevelCut, LevelMax ); //Abc_NtkPermuteLevel( pNtk ); Vec_Wec_t * vStore = Vec_WecStart( LevelMax+1 ); @@ -1850,9 +1876,9 @@ void Abc_NtkStochMap( int nSuppMax, int nIters, int TimeOut, int Seed, int fVerb Vec_PtrFreeFunc( vWins, (void (*)(void *)) Abc_NtkDelete ); //Vec_PtrFreeFunc( vOpts, (void (*)(void *)) Abc_NtkDelete ); vOpts = NULL; - Vec_PtrFreeFunc( vIns, (void (*)(void *)) Vec_IntFree ); - Vec_PtrFreeFunc( vOuts, (void (*)(void *)) Vec_IntFree ); - Vec_PtrFreeFunc( vNodes, (void (*)(void *)) Vec_IntFree ); + if ( vIns ) Vec_PtrFreeFunc( vIns, (void (*)(void *)) Vec_IntFree ); + if ( vOuts ) Vec_PtrFreeFunc( vOuts, (void (*)(void *)) Vec_IntFree ); + if ( vNodes ) Vec_PtrFreeFunc( vNodes, (void (*)(void *)) Vec_IntFree ); if ( nTimeToStop && Abc_Clock() > nTimeToStop ) { printf( "Runtime limit (%d sec) is reached after %d iterations.\n", TimeOut, i ); diff --git a/src/map/mio/mio.c b/src/map/mio/mio.c index 4915845e1..a2c956356 100644 --- a/src/map/mio/mio.c +++ b/src/map/mio/mio.c @@ -336,7 +336,7 @@ int Mio_CommandReadGenlib( Abc_Frame_t * pAbc, int argc, char **argv ) double WireDelay = 0.0; int fShortNames = 0; int nFaninLimit = 0; - int c, fVerbose = 1; + int c, fVerbose = 0; pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc);