Commit c03f9b51 by Alan Mishchenko

Version abc90220

parent 28d4f869
...@@ -3663,10 +3663,6 @@ SOURCE=.\src\aig\gia\giaSim.c ...@@ -3663,10 +3663,6 @@ SOURCE=.\src\aig\gia\giaSim.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\aig\gia\giaSolver.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\gia\giaSort.c SOURCE=.\src\aig\gia\giaSort.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -1084,6 +1084,8 @@ char * Aig_FileNameGenericAppend( char * pBase, char * pSuffix ) ...@@ -1084,6 +1084,8 @@ char * Aig_FileNameGenericAppend( char * pBase, char * pSuffix )
if ( (pDot = strrchr( Buffer, '.' )) ) if ( (pDot = strrchr( Buffer, '.' )) )
*pDot = 0; *pDot = 0;
strcat( Buffer, pSuffix ); strcat( Buffer, pSuffix );
if ( (pDot = strrchr( Buffer, '\\' )) || (pDot = strrchr( Buffer, '/' )) )
return pDot+1;
return Buffer; return Buffer;
} }
......
...@@ -444,7 +444,8 @@ p->timeSatUnsat += clock() - clk; ...@@ -444,7 +444,8 @@ p->timeSatUnsat += clock() - clk;
RetValue = sat_solver_addclause( p->pSat, &Lit, &Lit + 1 ); RetValue = sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
assert( RetValue ); assert( RetValue );
p->nSatUnsat++; p->nSatUnsat++;
p->nConfUnsat += p->pSat->stats.conflicts - nConflicts; p->nConfUnsat += p->pSat->stats.conflicts - nConflicts;
//printf( "UNSAT after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
return 1; return 1;
} }
else if ( RetValue == l_True ) else if ( RetValue == l_True )
...@@ -452,6 +453,7 @@ p->timeSatUnsat += clock() - clk; ...@@ -452,6 +453,7 @@ p->timeSatUnsat += clock() - clk;
p->timeSatSat += clock() - clk; p->timeSatSat += clock() - clk;
p->nSatSat++; p->nSatSat++;
p->nConfSat += p->pSat->stats.conflicts - nConflicts; p->nConfSat += p->pSat->stats.conflicts - nConflicts;
//printf( "SAT after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
return 0; return 0;
} }
else // if ( RetValue == l_Undef ) else // if ( RetValue == l_Undef )
...@@ -459,6 +461,7 @@ p->timeSatSat += clock() - clk; ...@@ -459,6 +461,7 @@ p->timeSatSat += clock() - clk;
p->timeSatUndec += clock() - clk; p->timeSatUndec += clock() - clk;
p->nSatUndec++; p->nSatUndec++;
p->nConfUndec += p->pSat->stats.conflicts - nConflicts; p->nConfUndec += p->pSat->stats.conflicts - nConflicts;
//printf( "UNDEC after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
return -1; return -1;
} }
} }
...@@ -477,10 +480,18 @@ p->timeSatUndec += clock() - clk; ...@@ -477,10 +480,18 @@ p->timeSatUndec += clock() - clk;
***********************************************************************/ ***********************************************************************/
void Cec_ManSatSolve( Cec_ManPat_t * pPat, Gia_Man_t * pAig, Cec_ParSat_t * pPars ) void Cec_ManSatSolve( Cec_ManPat_t * pPat, Gia_Man_t * pAig, Cec_ParSat_t * pPars )
{ {
static int Counter;
// char Buffer[1000];
Bar_Progress_t * pProgress = NULL; Bar_Progress_t * pProgress = NULL;
Cec_ManSat_t * p; Cec_ManSat_t * p;
Gia_Obj_t * pObj; Gia_Obj_t * pObj;
int i, status, clk = clock(); int i, status, clk = clock();
// sprintf( Buffer, "gia%03d.aig", Counter++ );
//Gia_WriteAiger( pAig, Buffer, 0, 0 );
//printf( "Dumpted slice into file \"%s\".\n", Buffer );
// reset the manager // reset the manager
if ( pPat ) if ( pPat )
{ {
...@@ -501,6 +512,8 @@ void Cec_ManSatSolve( Cec_ManPat_t * pPat, Gia_Man_t * pAig, Cec_ParSat_t * pPar ...@@ -501,6 +512,8 @@ void Cec_ManSatSolve( Cec_ManPat_t * pPat, Gia_Man_t * pAig, Cec_ParSat_t * pPar
pObj->fMark1 = 1; pObj->fMark1 = 1;
continue; continue;
} }
//printf( "Output %6d : ", i );
Bar_ProgressUpdate( pProgress, i, "SAT..." ); Bar_ProgressUpdate( pProgress, i, "SAT..." );
status = Cec_ManSatCheckNode( p, pObj ); status = Cec_ManSatCheckNode( p, pObj );
pObj->fMark0 = (status == 0); pObj->fMark0 = (status == 0);
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// INCLUDES /// /// INCLUDES ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
#include "aig.h" #include "aig.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -303,6 +303,8 @@ static inline int Gia_XsimAndCond( int Value0, int fCompl0, int Value1, int fCom ...@@ -303,6 +303,8 @@ static inline int Gia_XsimAndCond( int Value0, int fCompl0, int Value1, int fCom
for ( i = 1; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ ) for ( i = 1; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ )
#define Gia_ManForEachObjVec( vVec, p, pObj, i ) \ #define Gia_ManForEachObjVec( vVec, p, pObj, i ) \
for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Gia_ManObj(p, Vec_IntEntry(vVec,i))); i++ ) for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Gia_ManObj(p, Vec_IntEntry(vVec,i))); i++ )
#define Gia_ManForEachObjVecLit( vVec, p, pObj, fCompl, i ) \
for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Gia_ManObj(p, Gia_Lit2Var(Vec_IntEntry(vVec,i)))) && (((fCompl) = Gia_LitIsCompl(Vec_IntEntry(vVec,i))),1); i++ )
#define Gia_ManForEachAnd( p, pObj, i ) \ #define Gia_ManForEachAnd( p, pObj, i ) \
for ( i = 0; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ ) if ( !Gia_ObjIsAnd(pObj) ) {} else for ( i = 0; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ ) if ( !Gia_ObjIsAnd(pObj) ) {} else
#define Gia_ManForEachCi( p, pObj, i ) \ #define Gia_ManForEachCi( p, pObj, i ) \
...@@ -373,11 +375,12 @@ extern void Gia_ManHashStart( Gia_Man_t * p ); ...@@ -373,11 +375,12 @@ extern void Gia_ManHashStart( Gia_Man_t * p );
extern void Gia_ManHashStop( Gia_Man_t * p ); extern void Gia_ManHashStop( Gia_Man_t * p );
extern int Gia_ManHashAnd( Gia_Man_t * p, int iLit0, int iLit1 ); extern int Gia_ManHashAnd( Gia_Man_t * p, int iLit0, int iLit1 );
extern int Gia_ManHashXor( Gia_Man_t * p, int iLit0, int iLit1 ); extern int Gia_ManHashXor( Gia_Man_t * p, int iLit0, int iLit1 );
extern int Gia_ManHashMux( Gia_Man_t * p, int iCtrl, int iData1, int iData0 );
extern int Gia_ManHashAndTry( Gia_Man_t * p, int iLit0, int iLit1 ); extern int Gia_ManHashAndTry( Gia_Man_t * p, int iLit0, int iLit1 );
extern Gia_Man_t * Gia_ManRehash( Gia_Man_t * p ); extern Gia_Man_t * Gia_ManRehash( Gia_Man_t * p );
/*=== giaLogic.c ===========================================================*/ /*=== giaLogic.c ===========================================================*/
extern void Gia_ManTestDistance( Gia_Man_t * p ); extern void Gia_ManTestDistance( Gia_Man_t * p );
extern void Gia_ManSolveProblem( Gia_Man_t * pGia, int nDims, int nSols ); extern void Gia_ManSolveProblem( Gia_Man_t * pGia, int nDims, int nSols, int fCluster, int fDump, int fVerbose );
/*=== giaMan.c ===========================================================*/ /*=== giaMan.c ===========================================================*/
extern Gia_Man_t * Gia_ManStart( int nObjsMax ); extern Gia_Man_t * Gia_ManStart( int nObjsMax );
extern void Gia_ManStop( Gia_Man_t * p ); extern void Gia_ManStop( Gia_Man_t * p );
......
...@@ -417,39 +417,67 @@ Gia_Man_t * Gia_ManDupCofactored( Gia_Man_t * p, int iVar ) ...@@ -417,39 +417,67 @@ Gia_Man_t * Gia_ManDupCofactored( Gia_Man_t * p, int iVar )
{ {
Gia_Man_t * pNew, * pTemp; Gia_Man_t * pNew, * pTemp;
Gia_Obj_t * pObj, * pPivot; Gia_Obj_t * pObj, * pPivot;
int i; int i, iCofVar = -1;
assert( Gia_ManRegNum(p) == 0 ); if ( !(iVar > 0 && iVar < Gia_ManObjNum(p)) )
assert( iVar < Gia_ManObjNum(p) ); {
printf( "Gia_ManDupCofactored(): Variable %d is out of range (%d; %d).\n", iVar, 0, Gia_ManObjNum(p) );
return NULL;
}
// find the cofactoring variable
pPivot = Gia_ManObj( p, iVar );
if ( !(Gia_ObjIsCi(pPivot) || Gia_ObjIsAnd(pPivot)) )
{
printf( "Gia_ManDupCofactored(): Variable %d should be a CI or an AND node.\n", iVar );
return NULL;
}
// assert( Gia_ManRegNum(p) == 0 );
pNew = Gia_ManStart( Gia_ManObjNum(p) ); pNew = Gia_ManStart( Gia_ManObjNum(p) );
pNew->pName = Aig_UtilStrsav( p->pName ); pNew->pName = Aig_UtilStrsav( p->pName );
Gia_ManHashAlloc( pNew ); Gia_ManHashAlloc( pNew );
Gia_ManConst0(p)->Value = 0; Gia_ManConst0(p)->Value = 0;
// compute negative cofactor
Gia_ManForEachCi( p, pObj, i ) Gia_ManForEachCi( p, pObj, i )
{
pObj->Value = Gia_ManAppendCi(pNew); pObj->Value = Gia_ManAppendCi(pNew);
// find the cofactoring variable if ( pObj == pPivot )
pPivot = Gia_ManObj(p, iVar); {
// compute the negative cofactor iCofVar = pObj->Value;
if ( Gia_ObjIsCi(pPivot) ) pObj->Value = Gia_Var2Lit( 0, 0 );
pPivot->Value = Gia_Var2Lit( 0, 0 ); }
}
Gia_ManForEachAnd( p, pObj, i ) Gia_ManForEachAnd( p, pObj, i )
{ {
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
if ( pObj == pPivot ) if ( pObj == pPivot )
pPivot->Value = Gia_Var2Lit( 0, 0 ); {
iCofVar = pObj->Value;
pObj->Value = Gia_Var2Lit( 0, 0 );
}
} }
Gia_ManForEachCo( p, pObj, i ) Gia_ManForEachCo( p, pObj, i )
pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); pObj->Value = Gia_ObjFanin0Copy(pObj);
// compute the positive cofactor // compute the positive cofactor
if ( Gia_ObjIsCi(pPivot) ) Gia_ManForEachCi( p, pObj, i )
pPivot->Value = Gia_Var2Lit( 0, 1 ); {
pObj->Value = Gia_Var2Lit( Gia_ObjId(pNew, Gia_ManCi(pNew, i)), 0 );
if ( pObj == pPivot )
pObj->Value = Gia_Var2Lit( 0, 1 );
}
Gia_ManForEachAnd( p, pObj, i ) Gia_ManForEachAnd( p, pObj, i )
{ {
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
if ( pObj == pPivot ) if ( pObj == pPivot )
pPivot->Value = Gia_Var2Lit( 0, 1 ); pObj->Value = Gia_Var2Lit( 0, 1 );
} }
// create MUXes
assert( iCofVar > 0 );
Gia_ManForEachCo( p, pObj, i ) Gia_ManForEachCo( p, pObj, i )
pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); {
if ( pObj->Value == (unsigned)Gia_ObjFanin0Copy(pObj) )
pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
else
pObj->Value = Gia_ManAppendCo( pNew, Gia_ManHashMux(pNew, iCofVar, Gia_ObjFanin0Copy(pObj), pObj->Value) );
}
Gia_ManHashStop( pNew ); Gia_ManHashStop( pNew );
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
// rehash the result // rehash the result
......
...@@ -42,7 +42,7 @@ struct For_Man_t_ ...@@ -42,7 +42,7 @@ struct For_Man_t_
Gia_Man_t * pGia; // the original AIG manager Gia_Man_t * pGia; // the original AIG manager
int nObjs; // the number of objects int nObjs; // the number of objects
int iObj; // the last added object int iObj; // the last added object
int * pPlace; // Placeing of objects int * pPlace; // coordinates of objects
int * piNext; // array of next pointers int * piNext; // array of next pointers
int * piRoot; // array of root pointers int * piRoot; // array of root pointers
float * plEdge; // edge coordinates float * plEdge; // edge coordinates
...@@ -413,7 +413,7 @@ void For_ManSortObjects( For_Man_t * p ) ...@@ -413,7 +413,7 @@ void For_ManSortObjects( For_Man_t * p )
p->piNext[i] = p->piRoot[iPlace]; p->piNext[i] = p->piRoot[iPlace];
p->piRoot[iPlace] = i; p->piRoot[iPlace] = i;
} }
// recostruct the order // reconstruct the order
p->iObj = 0; p->iObj = 0;
pPrev = NULL; pPrev = NULL;
vArray = Vec_PtrAlloc( 100 ); vArray = Vec_PtrAlloc( 100 );
......
...@@ -630,23 +630,38 @@ static inline unsigned Gli_ManUpdateRandomInput( unsigned uInfo, float PiTransPr ...@@ -630,23 +630,38 @@ static inline unsigned Gli_ManUpdateRandomInput( unsigned uInfo, float PiTransPr
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline void Gli_ManSimulateSeqOne( Gli_Man_t * p, float PiTransProb ) void Gli_ManSimulateSeqPref( Gli_Man_t * p, int nPref )
{ {
Gli_Obj_t * pObj, * pObjRi, * pObjRo; Gli_Obj_t * pObj, * pObjRi, * pObjRo;
int i; int i, f;
// initialize simulation data
Gli_ManForEachPi( p, pObj, i ) Gli_ManForEachPi( p, pObj, i )
pObj->uSimInfo = Gli_ManUpdateRandomInput( pObj->uSimInfo, PiTransProb ); pObj->uSimInfo = Gli_ManUpdateRandomInput( pObj->uSimInfo, 0.5 );
Gli_ManForEachNode( p, pObj, i ) Gli_ManForEachRo( p, pObj, i )
pObj->uSimInfo = Gli_ManSimulateSeqNode( p, pObj ); pObj->uSimInfo = 0;
Gli_ManForEachRi( p, pObj, i ) for ( f = 0; f < nPref; f++ )
pObj->uSimInfo = Gli_ObjFanin(pObj, 0)->uSimInfo; {
Gli_ManForEachRiRo( p, pObjRi, pObjRo, i ) // simulate one frame
pObjRo->uSimInfo = pObjRi->uSimInfo; Gli_ManForEachNode( p, pObj, i )
pObj->uSimInfo = Gli_ManSimulateSeqNode( p, pObj );
Gli_ManForEachRi( p, pObj, i )
pObj->uSimInfo = Gli_ObjFanin(pObj, 0)->uSimInfo;
// initialize the next frame
Gli_ManForEachPi( p, pObj, i )
pObj->uSimInfo = Gli_ManUpdateRandomInput( pObj->uSimInfo, 0.5 );
Gli_ManForEachRiRo( p, pObjRi, pObjRo, i )
pObjRo->uSimInfo = pObjRi->uSimInfo;
}
// save simulation data after nPref timeframes
if ( p->pSimInfoPrev == NULL )
p->pSimInfoPrev = ABC_ALLOC( unsigned, Gli_ManCiNum(p) );
Gli_ManForEachCi( p, pObj, i )
p->pSimInfoPrev[i] = pObj->uSimInfo;
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Simulates sequential network randomly for the given number of frames.] Synopsis [Initialized object values to be one pattern in the saved data.]
Description [] Description []
...@@ -655,19 +670,19 @@ static inline void Gli_ManSimulateSeqOne( Gli_Man_t * p, float PiTransProb ) ...@@ -655,19 +670,19 @@ static inline void Gli_ManSimulateSeqOne( Gli_Man_t * p, float PiTransProb )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline void Gli_ManSaveCiInfo( Gli_Man_t * p ) void Gli_ManSetDataSaved( Gli_Man_t * p, int iBit )
{ {
Gli_Obj_t * pObj; Gli_Obj_t * pObj;
int i; int i;
if ( p->pSimInfoPrev == NULL )
p->pSimInfoPrev = ABC_ALLOC( unsigned, Gli_ManCiNum(p) );
Gli_ManForEachCi( p, pObj, i ) Gli_ManForEachCi( p, pObj, i )
p->pSimInfoPrev[i] = pObj->uSimInfo; pObj->fPhase = pObj->fPhase2 = ((p->pSimInfoPrev[i] >> iBit) & 1);
Gli_ManForEachNode( p, pObj, i )
pObj->fPhase = pObj->fPhase2 = Gli_NodeComputeValue( pObj );
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Simulates sequential network randomly for the given number of frames.] Synopsis [Sets random info at the PIs and collects changed PIs.]
Description [] Description []
...@@ -676,14 +691,37 @@ static inline void Gli_ManSaveCiInfo( Gli_Man_t * p ) ...@@ -676,14 +691,37 @@ static inline void Gli_ManSaveCiInfo( Gli_Man_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Gli_ManSimulateSeqPref( Gli_Man_t * p, int nPref ) void Gli_ManSetPiRandomSeq( Gli_Man_t * p, float PiTransProb )
{ {
Gli_Obj_t * pObj; Gli_Obj_t * pObj, * pObjRi;
int i, f; float Multi = 1.0 / (1 << 16);
Gli_ManForEachRo( p, pObj, i ) int i;
pObj->uSimInfo = 0; assert( 0.0 < PiTransProb && PiTransProb < 1.0 );
for ( f = 0; f < nPref; f++ ) // transfer data to the COs
Gli_ManSimulateSeqOne( p, 0.5 ); Gli_ManForEachCo( p, pObj, i )
pObj->fPhase = pObj->fPhase2 = Gli_ObjFanin(pObj, 0)->fPhase;
// set changed PIs
Vec_IntClear( p->vCisChanged );
Gli_ManForEachPi( p, pObj, i )
if ( Multi * (Aig_ManRandom(0) & 0xffff) < PiTransProb )
{
Vec_IntPush( p->vCisChanged, pObj->Handle );
pObj->fPhase ^= 1;
pObj->fPhase2 ^= 1;
pObj->nSwitches++;
pObj->nGlitches++;
}
// set changed ROs
Gli_ManForEachRiRo( p, pObjRi, pObj, i )
if ( pObjRi->fPhase != pObj->fPhase )
{
Vec_IntPush( p->vCisChanged, pObj->Handle );
pObj->fPhase ^= 1;
pObj->fPhase2 ^= 1;
pObj->nSwitches++;
pObj->nGlitches++;
}
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -714,14 +752,14 @@ void Gli_ManSwitchesAndGlitches( Gli_Man_t * p, int nPatterns, float PiTransProb ...@@ -714,14 +752,14 @@ void Gli_ManSwitchesAndGlitches( Gli_Man_t * p, int nPatterns, float PiTransProb
} }
else else
{ {
int nIters = Aig_BitWordNum(nPatterns);
Gli_ManSimulateSeqPref( p, 16 ); Gli_ManSimulateSeqPref( p, 16 );
for ( k = Aig_BitWordNum(nPatterns) - 1; k >= 0; k-- ) for ( i = 0; i < 32; i++ )
{ {
Gli_ManSaveCiInfo( p ); Gli_ManSetDataSaved( p, i );
Gli_ManSimulateSeqOne( p, PiTransProb ); for ( k = 0; k < nIters; k++ )
for ( i = 0; i < 32; i++ )
{ {
Gli_ManSetPiFromSaved( p, i ); Gli_ManSetPiRandomSeq( p, PiTransProb );
Gli_ManSwitching( p ); Gli_ManSwitching( p );
Gli_ManGlitching( p ); Gli_ManGlitching( p );
// Gli_ManVerify( p ); // Gli_ManVerify( p );
......
...@@ -509,6 +509,24 @@ int Gia_ManHashXor( Gia_Man_t * p, int iLit0, int iLit1 ) ...@@ -509,6 +509,24 @@ int Gia_ManHashXor( Gia_Man_t * p, int iLit0, int iLit1 )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Gia_ManHashMux( Gia_Man_t * p, int iCtrl, int iData1, int iData0 )
{
int iTemp0 = Gia_ManHashAnd( p, Gia_LitNot(iCtrl), iData0 );
int iTemp1 = Gia_ManHashAnd( p, iCtrl, iData1 );
return Gia_LitNotCond( Gia_ManHashAnd( p, Gia_LitNot(iTemp0), Gia_LitNot(iTemp1) ), 1 );
}
/**Function*************************************************************
Synopsis [Rehashes AIG with mapping.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t * Gia_ManRehash( Gia_Man_t * p ) Gia_Man_t * Gia_ManRehash( Gia_Man_t * p )
{ {
Gia_Man_t * pNew; Gia_Man_t * pNew;
......
...@@ -59,13 +59,13 @@ static void sort_rec(int* array, int size, int(*comp)(const void *, const void * ...@@ -59,13 +59,13 @@ static void sort_rec(int* array, int size, int(*comp)(const void *, const void *
if (size <= 15) if (size <= 15)
selectionsort(array, size, comp); selectionsort(array, size, comp);
else{ else{
int * pivot = array + size/2; int pivot = array[size/2];
int tmp; int tmp;
int i = -1; int i = -1;
int j = size; int j = size;
for(;;){ for(;;){
do i++; while(comp(array + i, pivot)); do i++; while(comp(array + i, &pivot));
do j--; while(comp(pivot, array + j)); do j--; while(comp(&pivot, array + j));
if (i >= j) break; if (i >= j) break;
tmp = array[i]; array[i] = array[j]; array[j] = tmp; tmp = array[i]; array[i] = array[j]; array[j] = tmp;
} }
...@@ -79,6 +79,65 @@ void minisat_sort(int* array, int size, int(*comp)(const void *, const void *)) ...@@ -79,6 +79,65 @@ void minisat_sort(int* array, int size, int(*comp)(const void *, const void *))
} }
/**Function*************************************************************
Synopsis [This is implementation of qsort in MiniSat.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void selectionsort2(int* array, int size)
{
int i, j, best_i;
int tmp;
for (i = 0; i < size-1; i++){
best_i = i;
for (j = i+1; j < size; j++){
if (array[j] < array[best_i])
best_i = j;
}
tmp = array[i]; array[i] = array[best_i]; array[best_i] = tmp;
}
}
static void sort_rec2(int* array, int size)
{
if (size <= 15)
selectionsort2(array, size);
else{
int pivot = array[size/2];
int tmp;
int i = -1;
int j = size;
for(;;){
do i++; while(array[i] < pivot);
do j--; while(pivot < array[j]);
if (i >= j) break;
tmp = array[i]; array[i] = array[j]; array[j] = tmp;
}
sort_rec2(array , i );
sort_rec2(&array[i], size-i);
}
}
void minisat_sort2(int* array, int size)
{
sort_rec2(array,size);
}
/**Function*************************************************************
Synopsis [This is implementation of qsort in MiniSat.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int * Gia_SortGetTest( int nSize ) int * Gia_SortGetTest( int nSize )
{ {
int i, * pArray; int i, * pArray;
...@@ -96,10 +155,11 @@ void Gia_SortVerifySorted( int * pArray, int nSize ) ...@@ -96,10 +155,11 @@ void Gia_SortVerifySorted( int * pArray, int nSize )
} }
void Gia_SortTest() void Gia_SortTest()
{ {
int nSize = 1000000; int nSize = 100000000;
int * pArray; int * pArray;
int clk = clock(); int clk = clock();
printf( "Sorting %d integers\n", nSize );
pArray = Gia_SortGetTest( nSize ); pArray = Gia_SortGetTest( nSize );
clk = clock(); clk = clock();
qsort( pArray, nSize, 4, (int (*)(const void *, const void *)) num_cmp1 ); qsort( pArray, nSize, 4, (int (*)(const void *, const void *)) num_cmp1 );
...@@ -113,8 +173,91 @@ clk = clock(); ...@@ -113,8 +173,91 @@ clk = clock();
ABC_PRT( "minisat", clock() - clk ); ABC_PRT( "minisat", clock() - clk );
Gia_SortVerifySorted( pArray, nSize ); Gia_SortVerifySorted( pArray, nSize );
ABC_FREE( pArray ); ABC_FREE( pArray );
pArray = Gia_SortGetTest( nSize );
clk = clock();
minisat_sort2( pArray, nSize );
ABC_PRT( "minisat with inlined comparison", clock() - clk );
Gia_SortVerifySorted( pArray, nSize );
ABC_FREE( pArray );
}
/**Function*************************************************************
Synopsis [This is implementation of qsort in MiniSat.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void selectionsort3(float* array, int* perm, int size)
{
float tmpf;
int tmpi;
int i, j, best_i;
for (i = 0; i < size-1; i++){
best_i = i;
for (j = i+1; j < size; j++){
if (array[j] < array[best_i])
best_i = j;
}
tmpf = array[i]; array[i] = array[best_i]; array[best_i] = tmpf;
tmpi = perm[i]; perm[i] = perm[best_i]; perm[best_i] = tmpi;
}
}
static void sort_rec3(float* array, int* perm, int size)
{
if (size <= 15)
selectionsort3(array, perm, size);
else{
float pivot = array[size/2];
float tmpf;
int tmpi;
int i = -1;
int j = size;
for(;;){
do i++; while(array[i] < pivot);
do j--; while(pivot < array[j]);
if (i >= j) break;
tmpf = array[i]; array[i] = array[j]; array[j] = tmpf;
tmpi = perm[i]; perm[i] = perm[j]; perm[j] = tmpi;
}
sort_rec3(array , perm, i );
sort_rec3(&array[i], &perm[i], size-i);
}
}
void minisat_sort3(float* array, int* perm, int size)
{
sort_rec3(array, perm, size);
} }
/**Function*************************************************************
Synopsis [Sorts the array of floating point numbers.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int * Gia_SortFloats( float * pArray, int nSize )
{
int i, * pPerm;
pPerm = ABC_ALLOC( int, nSize );
for ( i = 0; i < nSize; i++ )
pPerm[i] = i;
minisat_sort3( pArray, pPerm, nSize );
// for ( i = 1; i < nSize; i++ )
// assert( pArray[i-1] <= pArray[i] );
return pPerm;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -14,6 +14,7 @@ SRC += src/aig/gia/gia.c \ ...@@ -14,6 +14,7 @@ SRC += src/aig/gia/gia.c \
src/aig/gia/giaMan.c \ src/aig/gia/giaMan.c \
src/aig/gia/giaScl.c \ src/aig/gia/giaScl.c \
src/aig/gia/giaSim.c \ src/aig/gia/giaSim.c \
src/aig/gia/giaSort.c \
src/aig/gia/giaSwitch.c \ src/aig/gia/giaSwitch.c \
src/aig/gia/giaTsim.c \ src/aig/gia/giaTsim.c \
src/aig/gia/giaUtil.c src/aig/gia/giaUtil.c
...@@ -50,7 +50,7 @@ void Ssw_ManSetDefaultParams( Ssw_Pars_t * p ) ...@@ -50,7 +50,7 @@ void Ssw_ManSetDefaultParams( Ssw_Pars_t * p )
p->nBTLimit = 1000; // conflict limit at a node p->nBTLimit = 1000; // conflict limit at a node
p->nBTLimitGlobal = 5000000; // conflict limit for all runs p->nBTLimitGlobal = 5000000; // conflict limit for all runs
p->nMinDomSize = 100; // min clock domain considered for optimization p->nMinDomSize = 100; // min clock domain considered for optimization
p->nItersStop = 0; // stop after the given number of iterations p->nItersStop = -1; // stop after the given number of iterations
p->nResimDelta = 1000; // the internal of nodes to resimulate p->nResimDelta = 1000; // the internal of nodes to resimulate
p->fPolarFlip = 0; // uses polarity adjustment p->fPolarFlip = 0; // uses polarity adjustment
p->fLatchCorr = 0; // performs register correspondence p->fLatchCorr = 0; // performs register correspondence
...@@ -199,7 +199,7 @@ clk = clock(); ...@@ -199,7 +199,7 @@ clk = clock();
if ( !RetValue ) if ( !RetValue )
break; break;
if ( p->pPars->nItersStop && p->pPars->nItersStop == nIter ) if ( p->pPars->nItersStop >= 0 && p->pPars->nItersStop == nIter )
{ {
Aig_Man_t * pSRed = Ssw_SpeculativeReduction( p ); Aig_Man_t * pSRed = Ssw_SpeculativeReduction( p );
Aig_ManDumpBlif( pSRed, "srm.blif", NULL, NULL ); Aig_ManDumpBlif( pSRed, "srm.blif", NULL, NULL );
......
...@@ -14501,7 +14501,7 @@ usage: ...@@ -14501,7 +14501,7 @@ usage:
fprintf( pErr, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs ); fprintf( pErr, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
fprintf( pErr, "\t-N num : number of last POs treated as constraints (0=none) [default = %d]\n", pPars->nConstrs ); fprintf( pErr, "\t-N num : number of last POs treated as constraints (0=none) [default = %d]\n", pPars->nConstrs );
fprintf( pErr, "\t-S num : additional simulation frames for c-examples (0=none) [default = %d]\n", pPars->nFramesAddSim ); fprintf( pErr, "\t-S num : additional simulation frames for c-examples (0=none) [default = %d]\n", pPars->nFramesAddSim );
fprintf( pErr, "\t-I num : iteration number to stop and output SR-model (0=none) [default = %d]\n", pPars->nItersStop ); fprintf( pErr, "\t-I num : iteration number to stop and output SR-model (-1=none) [default = %d]\n", pPars->nItersStop );
fprintf( pErr, "\t-V num : min var num needed to recycle the SAT solver [default = %d]\n", pPars->nSatVarMax2 ); fprintf( pErr, "\t-V num : min var num needed to recycle the SAT solver [default = %d]\n", pPars->nSatVarMax2 );
fprintf( pErr, "\t-M num : min call num needed to recycle the SAT solver [default = %d]\n", pPars->nRecycleCalls2 ); fprintf( pErr, "\t-M num : min call num needed to recycle the SAT solver [default = %d]\n", pPars->nRecycleCalls2 );
fprintf( pErr, "\t-p : toggle alighning polarity of SAT variables [default = %s]\n", pPars->fPolarFlip? "yes": "no" ); fprintf( pErr, "\t-p : toggle alighning polarity of SAT variables [default = %s]\n", pPars->fPolarFlip? "yes": "no" );
...@@ -22365,6 +22365,12 @@ int Abc_CommandAbc9Cof( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -22365,6 +22365,12 @@ int Abc_CommandAbc9Cof( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1; return 1;
} }
pAbc->pAig = Gia_ManDupCofactored( pTemp = pAbc->pAig, iVar ); pAbc->pAig = Gia_ManDupCofactored( pTemp = pAbc->pAig, iVar );
if ( pAbc->pAig == NULL )
{
pAbc->pAig = pTemp;
printf( "Abc_CommandAbc9Cof(): Transformation has failed.\n" );
return 1;
}
Gia_ManStop( pTemp ); Gia_ManStop( pTemp );
return 0; return 0;
...@@ -23017,12 +23023,36 @@ usage: ...@@ -23017,12 +23023,36 @@ usage:
***********************************************************************/ ***********************************************************************/
int Abc_CommandAbc9Embed( Abc_Frame_t * pAbc, int argc, char ** argv ) int Abc_CommandAbc9Embed( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
int nDims = 30;
int fCluster = 0;
int fDump = 0;
int fVerbose = 0;
int c; int c;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "Ddcvh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
case 'D':
if ( globalUtilOptind >= argc )
{
fprintf( stdout, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
nDims = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nDims < 0 )
goto usage;
break;
case 'c':
fCluster ^= 1;
break;
case 'd':
fDump ^= 1;
break;
case 'v':
fVerbose ^= 1;
break;
case 'h': case 'h':
goto usage; goto usage;
default: default:
...@@ -23034,15 +23064,19 @@ int Abc_CommandAbc9Embed( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -23034,15 +23064,19 @@ int Abc_CommandAbc9Embed( Abc_Frame_t * pAbc, int argc, char ** argv )
printf( "Abc_CommandAbc9Test(): There is no AIG.\n" ); printf( "Abc_CommandAbc9Test(): There is no AIG.\n" );
return 1; return 1;
} }
Gia_ManSolveProblem( pAbc->pAig, 30, 2 ); Gia_ManSolveProblem( pAbc->pAig, nDims, 2, fCluster, fDump, fVerbose );
return 0; return 0;
usage: usage:
fprintf( stdout, "usage: &embed [-h]\n" ); fprintf( stdout, "usage: &embed [-D num] [-dcvh]\n" );
fprintf( stdout, "\t fast placement based on the technique introduced by\n" ); fprintf( stdout, "\t fast placement based on high-dimensional embedding from\n" );
fprintf( stdout, "\t D. Harel and Y. Koren, \"Graph drawing by high-dimensional\n" ); fprintf( stdout, "\t D. Harel and Y. Koren, \"Graph drawing by high-dimensional\n" );
fprintf( stdout, "\t embedding\", J. Graph Algs & Apps, Vol 8(2), pp. 195-217 (2004)\n" ); fprintf( stdout, "\t embedding\", J. Graph Algs & Apps, 2004, Vol 8(2), pp. 195-217\n" );
fprintf( stdout, "\t-h : print the command usage\n"); fprintf( stdout, "\t-D num : the number of dimensions for embedding [default = %d]\n", nDims );
fprintf( stdout, "\t-d : toggle dumping placement into a Gnuplot file [default = %s]\n", fDump? "yes":"no");
fprintf( stdout, "\t-c : toggle clustered representation [default = %s]\n", fCluster? "yes":"no");
fprintf( stdout, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes":"no");
fprintf( stdout, "\t-h : print the command usage\n");
return 1; return 1;
} }
...@@ -23060,6 +23094,8 @@ usage: ...@@ -23060,6 +23094,8 @@ usage:
int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
int c; int c;
extern void Gia_SatSolveTest( Gia_Man_t * p );
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{ {
...@@ -23081,7 +23117,8 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -23081,7 +23117,8 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv )
// Sat_ManTest( pAbc->pAig, Gia_ManCo(pAbc->pAig, 0), 0 ); // Sat_ManTest( pAbc->pAig, Gia_ManCo(pAbc->pAig, 0), 0 );
// Gia_ManTestDistance( pAbc->pAig ); // Gia_ManTestDistance( pAbc->pAig );
// For_ManExperiment( pAbc->pAig ); // For_ManExperiment( pAbc->pAig );
Gia_ManSolveProblem( pAbc->pAig, 30, 2 ); Gia_ManSolveProblem( pAbc->pAig, 30, 2, 1, 0, 1 );
// Gia_SatSolveTest( pAbc->pAig );
return 0; return 0;
usage: usage:
......
...@@ -192,7 +192,7 @@ void Abc_NtkFxuFreeInfo( Fxu_Data_t * p ) ...@@ -192,7 +192,7 @@ void Abc_NtkFxuFreeInfo( Fxu_Data_t * p )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Recostructs the network after FX.] Synopsis [Reconstructs the network after FX.]
Description [] Description []
......
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