summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2014-03-08 22:57:33 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2014-03-08 22:57:33 -0800
commit76e35126e7fc11e8d964246cfcbe9c18de86633f (patch)
tree77ded8b20c107c58694238d799cb6ab4652bd2ad
parent12c68e7e8e1602b3ba55bbcb54cfdd0e00f8fe3d (diff)
downloadabc-76e35126e7fc11e8d964246cfcbe9c18de86633f.tar.gz
abc-76e35126e7fc11e8d964246cfcbe9c18de86633f.tar.bz2
abc-76e35126e7fc11e8d964246cfcbe9c18de86633f.zip
Changes to LUT mappers.
-rw-r--r--src/base/abci/abc.c73
-rw-r--r--src/map/if/if.h1
-rw-r--r--src/map/if/ifDsd.c47
3 files changed, 114 insertions, 7 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index d1d1a9ec..e2913543 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -237,6 +237,7 @@ static int Abc_CommandDsdLoad ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandDsdFree ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDsdPs ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDsdTune ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDsdMerge ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandScut ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandInit ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -797,6 +798,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "DSD manager", "dsd_free", Abc_CommandDsdFree, 0 );
Cmd_CommandAdd( pAbc, "DSD manager", "dsd_ps", Abc_CommandDsdPs, 0 );
Cmd_CommandAdd( pAbc, "DSD manager", "dsd_tune", Abc_CommandDsdTune, 0 );
+ Cmd_CommandAdd( pAbc, "DSD manager", "dsd_merge", Abc_CommandDsdMerge, 0 );
// Cmd_CommandAdd( pAbc, "Sequential", "scut", Abc_CommandScut, 0 );
Cmd_CommandAdd( pAbc, "Sequential", "init", Abc_CommandInit, 1 );
@@ -15648,6 +15650,77 @@ usage:
return 1;
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandDsdMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ char * FileName, * pTemp;
+ char ** pArgvNew;
+ int c, nArgcNew;
+ FILE * pFile;
+ If_DsdMan_t * pDsdMan;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( !Abc_FrameReadManDsd() )
+ {
+ Abc_Print( 1, "The DSD manager is not started.\n" );
+ return 0;
+ }
+ pArgvNew = argv + globalUtilOptind;
+ nArgcNew = argc - globalUtilOptind;
+ if ( nArgcNew != 1 )
+ {
+ Abc_Print( -1, "File name is not given on the command line.\n" );
+ return 1;
+ }
+ // get the input file name
+ FileName = pArgvNew[0];
+ // fix the wrong symbol
+ for ( pTemp = FileName; *pTemp; pTemp++ )
+ if ( *pTemp == '>' )
+ *pTemp = '\\';
+ if ( (pFile = fopen( FileName, "r" )) == NULL )
+ {
+ Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+ if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
+ Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+ Abc_Print( 1, "\n" );
+ return 1;
+ }
+ fclose( pFile );
+ pDsdMan = If_DsdManLoad(FileName);
+ if ( pDsdMan == NULL )
+ return 1;
+ If_DsdManMerge( Abc_FrameReadManDsd(), pDsdMan );
+ If_DsdManFree( pDsdMan, 0 );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: dsd_merge [-h] <file>\n" );
+ Abc_Print( -2, "\t mermges DSD manager from file with the current one\n");
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file> : file name to read\n");
+ return 1;
+}
+
/**Function*************************************************************
diff --git a/src/map/if/if.h b/src/map/if/if.h
index d31a023e..c422505b 100644
--- a/src/map/if/if.h
+++ b/src/map/if/if.h
@@ -524,6 +524,7 @@ extern void If_DsdManTune( If_DsdMan_t * p, int LutSize, int fFast, i
extern void If_DsdManFree( If_DsdMan_t * p, int fVerbose );
extern void If_DsdManSave( If_DsdMan_t * p, char * pFileName );
extern If_DsdMan_t * If_DsdManLoad( char * pFileName );
+extern void If_DsdManMerge( If_DsdMan_t * p, If_DsdMan_t * pNew );
extern int If_DsdManCompute( If_DsdMan_t * p, word * pTruth, int nLeaves, unsigned char * pPerm, char * pLutStruct );
extern char * If_DsdManFileName( If_DsdMan_t * p );
extern int If_DsdManVarNum( If_DsdMan_t * p );
diff --git a/src/map/if/ifDsd.c b/src/map/if/ifDsd.c
index def088c7..e50a3743 100644
--- a/src/map/if/ifDsd.c
+++ b/src/map/if/ifDsd.c
@@ -445,13 +445,13 @@ void If_DsdManPrintDistrib( If_DsdMan_t * p )
{
printf( "%3d : ", i );
printf( "All = %8d ", CountAll[i] );
- printf( "Non = %8d ", CountNon[i] );
+ printf( "Non = %8d ", CountNon[i] );
printf( "(%6.2f %%)", 100.0 * CountNon[i] / CountAll[i] );
printf( "\n" );
}
printf( "All : " );
printf( "All = %8d ", Vec_PtrSize(p->vObjs) );
- printf( "Non = %8d ", CountNonTotal );
+ printf( "Non = %8d ", CountNonTotal );
printf( "(%6.2f %%)", 100.0 * CountNonTotal / Vec_PtrSize(p->vObjs) );
printf( "\n" );
}
@@ -482,7 +482,8 @@ void If_DsdManPrint( If_DsdMan_t * p, char * pFileName, int Number, int fOccurs,
fprintf( pFile, "Unique table hits = %8d\n", p->nUniqueHits );
fprintf( pFile, "Unique table misses = %8d\n", p->nUniqueMisses );
fprintf( pFile, "Memory used for objects = %8.2f MB.\n", 1.0*Mem_FlexReadMemUsage(p->pMem)/(1<<20) );
- fprintf( pFile, "Memory used for hash table = %8.2f MB.\n", 1.0*sizeof(int)*p->nBins/(1<<20) );
+ fprintf( pFile, "Memory used for functions = %8.2f MB.\n", 8.0*(Vec_MemEntrySize(p->vTtMem)+1)*Vec_MemEntryNum(p->vTtMem)/(1<<20) );
+ fprintf( pFile, "Memory used for hash table = %8.2f MB.\n", 1.0*sizeof(int)*(p->nBins+Vec_IntCap(p->vNexts))/(1<<20) );
fprintf( pFile, "Memory used for array = %8.2f MB.\n", 1.0*sizeof(void *)*Vec_PtrCap(p->vObjs)/(1<<20) );
If_DsdManPrintDistrib( p );
if ( fOccurs )
@@ -820,6 +821,35 @@ If_DsdMan_t * If_DsdManLoad( char * pFileName )
fclose( pFile );
return p;
}
+void If_DsdManMerge( If_DsdMan_t * p, If_DsdMan_t * pNew )
+{
+ If_DsdObj_t * pObj;
+ Vec_Int_t * vMap;
+ int pFanins[DAU_MAX_VAR];
+ int i, k, iFanin, Id;
+ if ( p->nVars < pNew->nVars )
+ {
+ printf( "The number of variables should be the same or smaller.\n" );
+ return;
+ }
+ if ( p->LutSize != pNew->LutSize )
+ {
+ printf( "LUT size should be the same.\n" );
+ return;
+ }
+ vMap = Vec_IntAlloc( Vec_PtrSize(pNew->vObjs) );
+ Vec_IntPush( vMap, 0 );
+ Vec_IntPush( vMap, 1 );
+ If_DsdVecForEachNode( pNew->vObjs, pObj, i )
+ {
+ If_DsdObjForEachFaninLit( pNew->vObjs, pObj, iFanin, k )
+ pFanins[k] = Abc_Lit2LitV( Vec_IntArray(vMap), iFanin );
+ Id = If_DsdObjFindOrAdd( p, pObj->Type, pFanins, pObj->nFans, pObj->Type == IF_DSD_PRIME ? If_DsdObjTruth(pNew, pObj) : NULL );
+ Vec_IntPush( vMap, Id );
+ }
+ assert( Vec_IntSize(vMap) == Vec_PtrSize(pNew->vObjs) );
+ Vec_IntFree( vMap );
+}
/**Function*************************************************************
@@ -1636,15 +1666,18 @@ void If_DsdManTest()
void If_DsdManTune( If_DsdMan_t * p, int LutSize, int fFast, int fAdd, int fSpec, int fVerbose )
{
ProgressBar * pProgress = NULL;
- If_DsdObj_t * pObj;
sat_solver * pSat = NULL;
- Vec_Int_t * vLits = Vec_IntAlloc( 1000 );
+ If_DsdObj_t * pObj;
+ Vec_Int_t * vLits;
int i, Value, nVars;
word * pTruth;
- pSat = (sat_solver *)If_ManSatBuildXY( LutSize );
- if ( !fAdd )
+ if ( !fAdd || !LutSize )
If_DsdVecForEachObj( p->vObjs, pObj, i )
pObj->fMark = 0;
+ if ( LutSize == 0 )
+ return;
+ vLits = Vec_IntAlloc( 1000 );
+ pSat = (sat_solver *)If_ManSatBuildXY( LutSize );
pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(p->vObjs) );
If_DsdVecForEachObj( p->vObjs, pObj, i )
{