Commit b581e16f by Alan Mishchenko

Experiments with cut caching.

parent d44d9e29
......@@ -2303,6 +2303,10 @@ SOURCE=.\src\map\if\if.h
# End Source File
# Begin Source File
SOURCE=.\src\map\if\ifCache.c
# End Source File
# Begin Source File
SOURCE=.\src\map\if\ifCom.c
# End Source File
# Begin Source File
......
......@@ -237,6 +237,7 @@ struct If_Man_t_
Vec_Str_t * vTtPerms; // mapping of truth table into permutations
int nBestCutSmall[2];
int nCountNonDec[2];
Vec_Int_t * vCutData; // cut data storage
// timing manager
Tim_Man_t * pManTim;
......
/**CFile****************************************************************
FileName [ifCache.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [FPGA mapping based on priority cuts.]
Synopsis []
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - November 21, 2006.]
Revision [$Id: ifCache.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
***********************************************************************/
#include "if.h"
#include "misc/vec/vecHsh.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void If_ManCacheRecord( If_Man_t * p, int iDsd0, int iDsd1, int nShared, int iDsd )
{
if ( p->vCutData == NULL )
p->vCutData = Vec_IntAlloc( 10000 );
if ( iDsd0 > iDsd1 )
ABC_SWAP( int, iDsd0, iDsd1 );
Vec_IntPush( p->vCutData, iDsd0 );
Vec_IntPush( p->vCutData, iDsd1 );
Vec_IntPush( p->vCutData, nShared );
Vec_IntPush( p->vCutData, iDsd );
// printf( "%6d %6d %6d %6d\n", iDsd0, iDsd1, nShared, iDsd );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Vec_IntCountUnique( Vec_Int_t * p )
{
int i, Count = 0, Max = Vec_IntFindMax(p);
unsigned char * pPres = ABC_CALLOC( unsigned char, Max+1 );
for ( i = 0; i < p->nSize; i++ )
if ( pPres[p->pArray[i]] == 0 )
pPres[p->pArray[i]] = 1, Count++;
ABC_FREE( pPres );
return Count;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void If_ManCacheAnalize( If_Man_t * p )
{
Vec_Int_t * vRes, * vTest[32];
int i, Entry, uUnique;
vRes = Hsh_IntManHashArray( p->vCutData, 4 );
for ( i = 0; i <= p->pPars->nLutSize; i++ )
vTest[i] = Vec_IntAlloc( 1000 );
Vec_IntForEachEntry( vRes, Entry, i )
Vec_IntPush( vTest[Vec_IntEntry(p->vCutData, 4*i+2)], Entry );
for ( i = 0; i <= p->pPars->nLutSize; i++ )
{
uUnique = Vec_IntCountUnique(vTest[i]);
printf( "%2d-var entries = %8d. (%6.2f %%) Unique entries = %8d. (%6.2f %%)\n",
i, Vec_IntSize(vTest[i]), 100.0*Vec_IntSize(vTest[i])/Vec_IntSize(vRes),
uUnique, 100.0*uUnique/Vec_IntSize(vTest[i]) );
}
for ( i = 0; i <= p->pPars->nLutSize; i++ )
Vec_IntFree( vTest[i] );
uUnique = Vec_IntCountUnique(vRes);
printf( "Total entries = %8d. (%6.2f %%) Unique entries = %8d. (%6.2f %%)\n",
Vec_IntSize(p->vCutData)/4, 100.0, uUnique, 100.0*uUnique/(Vec_IntSize(p->vCutData)/4) );
Vec_IntFree( vRes );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
......@@ -781,7 +781,7 @@ abctime clk;
if ( *pSpot )
return (int)*pSpot;
clk = Abc_Clock();
if ( truthId >= 0 && truthId == Vec_PtrSize(p->vTtDecs) )
if ( p->LutSize && truthId >= 0 && truthId == Vec_PtrSize(p->vTtDecs) )
{
Vec_Int_t * vSets = Dau_DecFindSets_int( pTruth, nLits, p->pSched );
// printf( "%d ", Vec_IntSize(vSets) );
......
......@@ -141,6 +141,9 @@ void If_ManRestart( If_Man_t * p )
***********************************************************************/
void If_ManStop( If_Man_t * p )
{
extern void If_ManCacheAnalize( If_Man_t * p );
if ( p->pPars->fVerbose && p->vCutData )
If_ManCacheAnalize( p );
/*
if ( p->pIfDsdMan )
{
......@@ -190,6 +193,7 @@ void If_ManStop( If_Man_t * p )
Vec_IntFreeP( &p->vLags );
Vec_IntFreeP( &p->vTtDsds );
Vec_StrFreeP( &p->vTtPerms );
Vec_IntFreeP( &p->vCutData );
Vec_MemHashFree( p->vTtMem );
Vec_MemFreeP( &p->vTtMem );
Mem_FixedStop( p->pMemObj, 0 );
......
......@@ -219,6 +219,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
// p->timeTruth += Abc_Clock() - clk;
if ( p->pPars->fUseDsd )
{
extern void If_ManCacheRecord( If_Man_t * p, int iDsd0, int iDsd1, int nShared, int iDsd );
int truthId = Abc_Lit2Var(pCut->iCutFunc);
if ( Vec_IntSize(p->vTtDsds) <= truthId || Vec_IntEntry(p->vTtDsds, truthId) == -1 )
{
......@@ -239,6 +240,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
for ( v = 0; v < (int)pCut->nLeaves; v++ )
pCut->pPerm[v] = (unsigned char)Vec_StrEntry( p->vTtPerms, truthId * p->pPars->nLutSize + v );
}
If_ManCacheRecord( p, pCut0->iCutDsd, pCut1->iCutDsd, p->nShared, pCut->iCutDsd );
}
// run user functions
pCut->fUseless = 0;
......
SRC += src/map/if/ifCom.c \
src/map/if/ifCache.c \
src/map/if/ifCore.c \
src/map/if/ifCut.c \
src/map/if/ifDec07.c \
......
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