Commit a3559996 by Alan Mishchenko

New technology mapper.

parent 4decece2
...@@ -29555,8 +29555,6 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -29555,8 +29555,6 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "LUT size %d is not supported.\n", nLutSize ); Abc_Print( -1, "LUT size %d is not supported.\n", nLutSize );
goto usage; goto usage;
} }
assert( pPars->pLib == NULL );
pPars->pLib = Mpm_LibLutSetSimple( nLutSize );
break; break;
case 'C': case 'C':
if ( globalUtilOptind >= argc ) if ( globalUtilOptind >= argc )
...@@ -29612,8 +29610,6 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -29612,8 +29610,6 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage; goto usage;
} }
} }
if ( pPars->pLib == NULL )
pPars->pLib = Mpm_LibLutSetSimple( nLutSize );
if ( pPars->fMap4Cnf ) if ( pPars->fMap4Cnf )
pPars->fUseDsd = 1; pPars->fUseDsd = 1;
if ( pPars->fCutMin ) if ( pPars->fCutMin )
...@@ -29631,7 +29627,13 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -29631,7 +29627,13 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
if ( pPars->fUseDsd || pPars->fUseTruth ) if ( pPars->fUseDsd || pPars->fUseTruth )
pPars->fDeriveLuts = 1; pPars->fDeriveLuts = 1;
if ( pPars->fUseDsd && nLutSize != 6 )
{
Abc_Print( -1, "Currently DSD can only be used with 6-input cuts.\n" );
return 1;
}
// perform mapping // perform mapping
assert( pPars->pLib == NULL );
if ( pPars->fMap4Gates ) if ( pPars->fMap4Gates )
{ {
if ( Abc_FrameReadLibGen() == NULL ) if ( Abc_FrameReadLibGen() == NULL )
...@@ -29639,6 +29641,7 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -29639,6 +29641,7 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "There is no GENLIB library available.\n" ); Abc_Print( -1, "There is no GENLIB library available.\n" );
return 1; return 1;
} }
pPars->pLib = Mpm_LibLutSetSimple( nLutSize );
pTemp = Mpm_ManCellMapping( pAbc->pGia, pPars, Abc_FrameReadLibGen() ); pTemp = Mpm_ManCellMapping( pAbc->pGia, pPars, Abc_FrameReadLibGen() );
Mpm_LibLutFree( pPars->pLib ); Mpm_LibLutFree( pPars->pLib );
if ( pTemp == NULL ) if ( pTemp == NULL )
...@@ -29650,6 +29653,7 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -29650,6 +29653,7 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
else else
{ {
pPars->pLib = Mpm_LibLutSetSimple( nLutSize );
pNew = Mpm_ManLutMapping( pAbc->pGia, pPars ); pNew = Mpm_ManLutMapping( pAbc->pGia, pPars );
Mpm_LibLutFree( pPars->pLib ); Mpm_LibLutFree( pPars->pLib );
if ( pNew == NULL ) if ( pNew == NULL )
...@@ -113,9 +113,6 @@ struct Mpm_Man_t_ ...@@ -113,9 +113,6 @@ struct Mpm_Man_t_
Mpm_Uni_t pCutUnits[MPM_CUT_MAX+1]; // cut info units Mpm_Uni_t pCutUnits[MPM_CUT_MAX+1]; // cut info units
Vec_Ptr_t vFreeUnits; // free cut info units Vec_Ptr_t vFreeUnits; // free cut info units
Vec_Ptr_t * vTemp; // storage for cuts Vec_Ptr_t * vTemp; // storage for cuts
// object presence
unsigned char * pObjPres; // object presence
Vec_Int_t vObjPresUsed; // used objects
// cut comparison // cut comparison
int (* pCutCmp) (Mpm_Uni_t *, Mpm_Uni_t *);// procedure to compare cuts int (* pCutCmp) (Mpm_Uni_t *, Mpm_Uni_t *);// procedure to compare cuts
// fanin cuts/signatures // fanin cuts/signatures
......
...@@ -65,8 +65,6 @@ Mpm_Man_t * Mpm_ManStart( Mig_Man_t * pMig, Mpm_Par_t * pPars ) ...@@ -65,8 +65,6 @@ Mpm_Man_t * Mpm_ManStart( Mig_Man_t * pMig, Mpm_Par_t * pPars )
Vec_PtrGrow( &p->vFreeUnits, p->nNumCuts + 1 ); Vec_PtrGrow( &p->vFreeUnits, p->nNumCuts + 1 );
for ( i = p->nNumCuts; i >= 0; i-- ) for ( i = p->nNumCuts; i >= 0; i-- )
Vec_PtrPush( &p->vFreeUnits, p->pCutUnits + i ); Vec_PtrPush( &p->vFreeUnits, p->pCutUnits + i );
p->pObjPres = ABC_FALLOC( unsigned char, Mig_ManObjNum(pMig) );
Vec_IntGrow( &p->vObjPresUsed, p->nLutSize );
p->vTemp = Vec_PtrAlloc( 1000 ); p->vTemp = Vec_PtrAlloc( 1000 );
// mapping attributes // mapping attributes
Vec_IntFill( &p->vCutBests, Mig_ManObjNum(pMig), 0 ); Vec_IntFill( &p->vCutBests, Mig_ManObjNum(pMig), 0 );
...@@ -141,9 +139,7 @@ void Mpm_ManStop( Mpm_Man_t * p ) ...@@ -141,9 +139,7 @@ void Mpm_ManStop( Mpm_Man_t * p )
Vec_IntFreeP( &p->vNpnConfigs ); Vec_IntFreeP( &p->vNpnConfigs );
Vec_PtrFree( p->vTemp ); Vec_PtrFree( p->vTemp );
Mmr_StepStop( p->pManCuts ); Mmr_StepStop( p->pManCuts );
ABC_FREE( p->vObjPresUsed.pArray );
ABC_FREE( p->vFreeUnits.pArray ); ABC_FREE( p->vFreeUnits.pArray );
ABC_FREE( p->pObjPres );
// mapping attributes // mapping attributes
ABC_FREE( p->vCutBests.pArray ); ABC_FREE( p->vCutBests.pArray );
ABC_FREE( p->vCutLists.pArray ); ABC_FREE( p->vCutLists.pArray );
......
...@@ -343,29 +343,14 @@ p->timeCompare += Abc_Clock() - clk; ...@@ -343,29 +343,14 @@ p->timeCompare += Abc_Clock() - clk;
***********************************************************************/ ***********************************************************************/
static inline Mpm_Cut_t * Mpm_ManMergeCuts( Mpm_Man_t * p, Mpm_Cut_t * pCut0, Mpm_Cut_t * pCut1, Mpm_Cut_t * pCut2 ) static inline Mpm_Cut_t * Mpm_ManMergeCuts( Mpm_Man_t * p, Mpm_Cut_t * pCut0, Mpm_Cut_t * pCut1, Mpm_Cut_t * pCut2 )
{ {
int fUsePres = 0;
Mpm_Cut_t * pTemp, * pCut = &((Mpm_Uni_t *)Vec_PtrEntryLast(&p->vFreeUnits))->pCut; Mpm_Cut_t * pTemp, * pCut = &((Mpm_Uni_t *)Vec_PtrEntryLast(&p->vFreeUnits))->pCut;
int i, c, iObj, fDisj = 1; int i, c, iObj, iPlace;
// base cut
if ( fUsePres ) memcpy( pCut->pLeaves, pCut0->pLeaves, sizeof(int) * pCut0->nLeaves );
pCut->nLeaves = pCut0->nLeaves;
// remaining cuts
if ( p->pPars->fUseDsd )
{ {
// clean present objects
for ( i = 0; i < p->vObjPresUsed.nSize; i++ )
p->pObjPres[p->vObjPresUsed.pArray[i]] = (unsigned char)0xFF;
Vec_IntClear(&p->vObjPresUsed);
// check present objects
// for ( i = 0; i < Mig_ManObjNum(p->pMig); i++ )
// assert( p->pObjPres[i] == (unsigned char)0xFF );
// base cut
pCut->nLeaves = 0;
for ( i = 0; i < (int)pCut0->nLeaves; i++ )
{
iObj = Abc_Lit2Var(pCut0->pLeaves[i]);
Vec_IntPush( &p->vObjPresUsed, iObj );
p->pObjPres[iObj] = pCut->nLeaves;
pCut->pLeaves[pCut->nLeaves++] = pCut0->pLeaves[i];
}
// remaining cuts
for ( c = 1; c < 3; c++ ) for ( c = 1; c < 3; c++ )
{ {
pTemp = (c == 1) ? pCut1 : pCut2; pTemp = (c == 1) ? pCut1 : pCut2;
...@@ -376,39 +361,28 @@ static inline Mpm_Cut_t * Mpm_ManMergeCuts( Mpm_Man_t * p, Mpm_Cut_t * pCut0, Mp ...@@ -376,39 +361,28 @@ static inline Mpm_Cut_t * Mpm_ManMergeCuts( Mpm_Man_t * p, Mpm_Cut_t * pCut0, Mp
for ( i = 0; i < (int)pTemp->nLeaves; i++ ) for ( i = 0; i < (int)pTemp->nLeaves; i++ )
{ {
iObj = Abc_Lit2Var(pTemp->pLeaves[i]); iObj = Abc_Lit2Var(pTemp->pLeaves[i]);
if ( p->pObjPres[iObj] == (unsigned char)0xFF ) for ( iPlace = 0; iPlace < (int)pCut->nLeaves; iPlace++ )
if ( iObj == Abc_Lit2Var(pCut->pLeaves[iPlace]) )
break;
if ( iPlace == (int)pCut->nLeaves )
{ {
if ( (int)pCut->nLeaves == p->nLutSize ) if ( (int)pCut->nLeaves == p->nLutSize )
return NULL; return NULL;
Vec_IntPush( &p->vObjPresUsed, iObj );
p->pObjPres[iObj] = pCut->nLeaves;
pCut->pLeaves[pCut->nLeaves++] = pTemp->pLeaves[i]; pCut->pLeaves[pCut->nLeaves++] = pTemp->pLeaves[i];
} }
else p->uPermMask[c] ^= (((i & 7) ^ 7) << (3*iPlace));
fDisj = 0; if ( pTemp->pLeaves[i] != pCut->pLeaves[iPlace] )
p->uPermMask[c] ^= (((i & 7) ^ 7) << (3*p->pObjPres[iObj])); p->uComplMask[c] |= (1 << iPlace);
assert( Abc_Lit2Var(pTemp->pLeaves[i]) == Abc_Lit2Var(pCut->pLeaves[p->pObjPres[iObj]]) );
if ( pTemp->pLeaves[i] != pCut->pLeaves[p->pObjPres[iObj]] )
p->uComplMask[c] |= (1 << p->pObjPres[iObj]);
} }
// Mpm_ManPrintPerm( p->uPermMask[c] ); printf( "\n" );
} }
} }
else else
{ {
int iPlace;
// base cut
pCut->nLeaves = 0;
for ( i = 0; i < (int)pCut0->nLeaves; i++ )
pCut->pLeaves[pCut->nLeaves++] = pCut0->pLeaves[i];
// remaining cuts
for ( c = 1; c < 3; c++ ) for ( c = 1; c < 3; c++ )
{ {
pTemp = (c == 1) ? pCut1 : pCut2; pTemp = (c == 1) ? pCut1 : pCut2;
if ( pTemp == NULL ) if ( pTemp == NULL )
break; break;
p->uPermMask[c] = 0x3FFFF; // 18 bits
p->uComplMask[c] = 0;
for ( i = 0; i < (int)pTemp->nLeaves; i++ ) for ( i = 0; i < (int)pTemp->nLeaves; i++ )
{ {
iObj = Abc_Lit2Var(pTemp->pLeaves[i]); iObj = Abc_Lit2Var(pTemp->pLeaves[i]);
...@@ -421,16 +395,9 @@ static inline Mpm_Cut_t * Mpm_ManMergeCuts( Mpm_Man_t * p, Mpm_Cut_t * pCut0, Mp ...@@ -421,16 +395,9 @@ static inline Mpm_Cut_t * Mpm_ManMergeCuts( Mpm_Man_t * p, Mpm_Cut_t * pCut0, Mp
return NULL; return NULL;
pCut->pLeaves[pCut->nLeaves++] = pTemp->pLeaves[i]; pCut->pLeaves[pCut->nLeaves++] = pTemp->pLeaves[i];
} }
else
fDisj = 0;
p->uPermMask[c] ^= (((i & 7) ^ 7) << (3*iPlace));
assert( Abc_Lit2Var(pTemp->pLeaves[i]) == Abc_Lit2Var(pCut->pLeaves[iPlace]) );
if ( pTemp->pLeaves[i] != pCut->pLeaves[iPlace] )
p->uComplMask[c] |= (1 << iPlace);
} }
} }
} }
// printf( "%d", fDisj );
if ( pCut1 == NULL ) if ( pCut1 == NULL )
{ {
pCut->hNext = 0; pCut->hNext = 0;
...@@ -455,37 +422,50 @@ static inline int Mpm_ManExploreNewCut( Mpm_Man_t * p, Mig_Obj_t * pObj, Mpm_Cut ...@@ -455,37 +422,50 @@ static inline int Mpm_ManExploreNewCut( Mpm_Man_t * p, Mig_Obj_t * pObj, Mpm_Cut
{ {
Mpm_Cut_t * pCut; Mpm_Cut_t * pCut;
int ArrTime; int ArrTime;
#ifdef MIG_RUNTIME #ifdef MIG_RUNTIME
abctime clk = clock(); abctime clk = clock();
#endif #endif
pCut = Mpm_ManMergeCuts( p, pCut0, pCut1, pCut2 );
if ( pCut == NULL ) if ( pCut0->nLeaves >= pCut1->nLeaves )
{ {
pCut = Mpm_ManMergeCuts( p, pCut0, pCut1, pCut2 );
#ifdef MIG_RUNTIME #ifdef MIG_RUNTIME
p->timeMerge += clock() - clk; p->timeMerge += clock() - clk;
#endif #endif
return 1; if ( pCut == NULL )
return 1;
if ( p->pPars->fUseTruth )
Mpm_CutComputeTruth( p, pCut, pCut0, pCut1, pCut2, Mig_ObjFaninC0(pObj), Mig_ObjFaninC1(pObj), Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) );
else if ( p->pPars->fUseDsd )
{
if ( !Mpm_CutComputeDsd6( p, pCut, pCut0, pCut1, pCut2, Mig_ObjFaninC0(pObj), Mig_ObjFaninC1(pObj), Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) ) )
return 1;
}
} }
else
// derive truth table
if ( p->pPars->fUseTruth )
Mpm_CutComputeTruth( p, pCut, pCut0, pCut1, pCut2, Mig_ObjFaninC0(pObj), Mig_ObjFaninC1(pObj), Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) );
else if ( p->pPars->fUseDsd )
{ {
if ( !Mpm_CutComputeDsd6( p, pCut, pCut0, pCut1, pCut2, Mig_ObjFaninC0(pObj), Mig_ObjFaninC1(pObj), Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) ) ) pCut = Mpm_ManMergeCuts( p, pCut1, pCut0, pCut2 );
#ifdef MIG_RUNTIME
p->timeMerge += clock() - clk;
#endif
if ( pCut == NULL )
return 1; return 1;
if ( p->pPars->fUseTruth )
Mpm_CutComputeTruth( p, pCut, pCut1, pCut0, pCut2, Mig_ObjFaninC1(pObj), Mig_ObjFaninC0(pObj), 1 ^ Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) );
else if ( p->pPars->fUseDsd )
{
if ( !Mpm_CutComputeDsd6( p, pCut, pCut1, pCut0, pCut2, Mig_ObjFaninC1(pObj), Mig_ObjFaninC0(pObj), 1 ^ Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) ) )
return 1;
}
} }
#ifdef MIG_RUNTIME #ifdef MIG_RUNTIME
p->timeMerge += clock() - clk;
clk = clock(); clk = clock();
#endif #endif
ArrTime = Mpm_CutGetArrTime( p, pCut ); ArrTime = Mpm_CutGetArrTime( p, pCut );
#ifdef MIG_RUNTIME #ifdef MIG_RUNTIME
p->timeEval += clock() - clk; p->timeEval += clock() - clk;
#endif #endif
if ( p->fMainRun && ArrTime > Required ) if ( p->fMainRun && ArrTime > Required )
return 1; return 1;
...@@ -497,11 +477,11 @@ clk = Abc_Clock(); ...@@ -497,11 +477,11 @@ clk = Abc_Clock();
p->timeStore += Abc_Clock() - clk; p->timeStore += Abc_Clock() - clk;
#endif #endif
// return 0 if const or buffer cut is derived - reset all cuts to contain only one /*
// return 0 if const or buffer cut is derived - reset all cuts to contain only one --- does not work
// if ( pCut->nLeaves < 2 && p->nCutStore == 1 ) // if ( pCut->nLeaves < 2 && p->nCutStore == 1 )
// return 0; // return 0;
/* if ( pCut->nLeaves < 2 )
if ( pCut->nLeaves < 2 )
{ {
int i; int i;
assert( p->nCutStore >= 1 ); assert( p->nCutStore >= 1 );
......
...@@ -91,13 +91,6 @@ static inline int Mpm_CutTruthMinimize6( Mpm_Man_t * p, Mpm_Cut_t * pCut ) ...@@ -91,13 +91,6 @@ static inline int Mpm_CutTruthMinimize6( Mpm_Man_t * p, Mpm_Cut_t * pCut )
} }
k++; k++;
} }
else
{
int iObj = Abc_Lit2Var( pCut->pLeaves[i] );
int Res = Vec_IntRemove( &p->vObjPresUsed, iObj );
assert( Res == 1 );
p->pObjPres[iObj] = (unsigned char)0xFF;
}
} }
assert( k == nSuppSize ); assert( k == nSuppSize );
pCut->nLeaves = nSuppSize; pCut->nLeaves = nSuppSize;
...@@ -129,13 +122,6 @@ static inline int Mpm_CutTruthMinimize7( Mpm_Man_t * p, Mpm_Cut_t * pCut ) ...@@ -129,13 +122,6 @@ static inline int Mpm_CutTruthMinimize7( Mpm_Man_t * p, Mpm_Cut_t * pCut )
} }
k++; k++;
} }
else
{
int iObj = Abc_Lit2Var( pCut->pLeaves[i] );
int Res = Vec_IntRemove( &p->vObjPresUsed, iObj );
assert( Res == 1 );
p->pObjPres[iObj] = (unsigned char)0xFF;
}
} }
assert( k == nSuppSize ); assert( k == nSuppSize );
assert( nSuppSize == Abc_TtSupportSize(p->Truth, Mpm_CutLeafNum(pCut)) ); assert( nSuppSize == Abc_TtSupportSize(p->Truth, Mpm_CutLeafNum(pCut)) );
......
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