Unverified Commit 0fa51fd6 by Philippe Sauter Committed by GitHub

Merge branch 'berkeley-abc:master' into fix-retime-segfault

parents 0f7d05d5 e387ddf8
...@@ -6,6 +6,7 @@ ReleaseLib/ ...@@ -6,6 +6,7 @@ ReleaseLib/
ReleaseExe/ ReleaseExe/
ReleaseExt/ ReleaseExt/
_/
_TEST/ _TEST/
lib/abc* lib/abc*
lib/m114* lib/m114*
......
...@@ -120,6 +120,7 @@ Gia_Man_t * Gia_ManDeepSynOne( int nNoImpr, int TimeOut, int nAnds, int Seed, in ...@@ -120,6 +120,7 @@ Gia_Man_t * Gia_ManDeepSynOne( int nNoImpr, int TimeOut, int nAnds, int Seed, in
} }
if ( nTimeToStop && Abc_Clock() > nTimeToStop ) if ( nTimeToStop && Abc_Clock() > nTimeToStop )
{ {
if ( !Abc_FrameIsBatchMode() )
printf( "Runtime limit (%d sec) is reached after %d iterations.\n", TimeOut, i ); printf( "Runtime limit (%d sec) is reached after %d iterations.\n", TimeOut, i );
break; break;
} }
......
...@@ -3689,6 +3689,58 @@ Vec_Str_t * Gia_ManComputeRange( Gia_Man_t * p ) ...@@ -3689,6 +3689,58 @@ Vec_Str_t * Gia_ManComputeRange( Gia_Man_t * p )
return vOut; return vOut;
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_ManComparePrint( Gia_Man_t * p, Gia_Man_t * q )
{
Vec_Wrd_t * vSimsPi = Vec_WrdStartTruthTables( Gia_ManCiNum(p) );
Vec_Wrd_t * vSimsP = Gia_ManSimPatSimOut( p, vSimsPi, 0 );
Vec_Wrd_t * vSimsQ = Gia_ManSimPatSimOut( q, vSimsPi, 0 );
int i, k, nWords = Vec_WrdSize(vSimsPi) / Gia_ManCiNum(p), Count = 0;
Gia_Obj_t * pObjP, * pObjQ;
Gia_ManSetPhase( p );
Gia_ManSetPhase( q );
Gia_ManForEachObj( p, pObjP, i ) {
word * pSim = Vec_WrdEntryP( vSimsP, i * nWords );
if ( pSim[0] & 1 ) Abc_TtNot( pSim, nWords );
}
Gia_ManForEachObj( q, pObjQ, i ) {
word * pSim = Vec_WrdEntryP( vSimsQ, i * nWords );
if ( pSim[0] & 1 ) Abc_TtNot( pSim, nWords );
}
Gia_ManForEachAnd( q, pObjQ, i ) {
word * pSimQ = Vec_WrdEntryP( vSimsQ, i * nWords );
int fFirst = 1;
Gia_ManForEachObj( p, pObjP, k ) {
word * pSimP = Vec_WrdEntryP( vSimsP, k * nWords );
if ( !Abc_TtEqual(pSimQ, pSimP, nWords) )
continue;
if ( fFirst ) {
printf( "%5d :", i );
fFirst = 0;
Count++;
}
printf( " %5d(%d)", k, pObjQ->fPhase ^ pObjP->fPhase );
}
if ( !fFirst )
printf( "\n");
}
printf( "Found %d equivalent nodes.\n", Count );
Vec_WrdFree( vSimsP );
Vec_WrdFree( vSimsQ );
Vec_WrdFree( vSimsPi );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -22,6 +22,19 @@ ...@@ -22,6 +22,19 @@
#include "base/main/main.h" #include "base/main/main.h"
#include "base/cmd/cmd.h" #include "base/cmd/cmd.h"
#ifdef ABC_USE_PTHREADS
#ifdef _WIN32
#include "../lib/pthread.h"
#else
#include <pthread.h>
#include <unistd.h>
#endif
#endif
ABC_NAMESPACE_IMPL_START ABC_NAMESPACE_IMPL_START
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -34,6 +47,169 @@ ABC_NAMESPACE_IMPL_START ...@@ -34,6 +47,169 @@ ABC_NAMESPACE_IMPL_START
/**Function************************************************************* /**Function*************************************************************
Synopsis [Processing on a single core.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t * Gia_StochProcessOne( Gia_Man_t * p, char * pScript, int Rand, int TimeSecs )
{
Gia_Man_t * pNew;
char FileName[100], Command[1000];
sprintf( FileName, "%06x.aig", Rand );
Gia_AigerWrite( p, FileName, 0, 0, 0 );
sprintf( Command, "./abc -q \"&read %s; %s; &write %s\"", FileName, pScript, FileName );
if ( system( (char *)Command ) )
{
fprintf( stderr, "The following command has returned non-zero exit status:\n" );
fprintf( stderr, "\"%s\"\n", (char *)Command );
fprintf( stderr, "Sorry for the inconvenience.\n" );
fflush( stdout );
unlink( FileName );
return Gia_ManDup(p);
}
pNew = Gia_AigerRead( FileName, 0, 0, 0 );
unlink( FileName );
if ( pNew && Gia_ManAndNum(pNew) < Gia_ManAndNum(p) )
return pNew;
Gia_ManStopP( &pNew );
return Gia_ManDup(p);
}
void Gia_StochProcessArray( Vec_Ptr_t * vGias, char * pScript, int TimeSecs, int fVerbose )
{
Gia_Man_t * pGia, * pNew; int i;
Vec_Int_t * vRands = Vec_IntAlloc( Vec_PtrSize(vGias) );
Abc_Random(1);
for ( i = 0; i < Vec_PtrSize(vGias); i++ )
Vec_IntPush( vRands, Abc_Random(0) % 0x1000000 );
Vec_PtrForEachEntry( Gia_Man_t *, vGias, pGia, i )
{
pNew = Gia_StochProcessOne( pGia, pScript, Vec_IntEntry(vRands, i), TimeSecs );
Gia_ManStop( pGia );
Vec_PtrWriteEntry( vGias, i, pNew );
}
Vec_IntFree( vRands );
}
/**Function*************************************************************
Synopsis [Processing on a many cores.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
#ifndef ABC_USE_PTHREADS
void Gia_StochProcess( Vec_Ptr_t * vGias, char * pScript, int nProcs, int TimeSecs, int fVerbose )
{
Gia_StochProcessArray( vGias, pScript, TimeSecs, fVerbose );
}
#else // pthreads are used
#define PAR_THR_MAX 100
typedef struct Gia_StochThData_t_
{
Vec_Ptr_t * vGias;
char * pScript;
int Index;
int Rand;
int nTimeOut;
int fWorking;
} Gia_StochThData_t;
void * Gia_StochWorkerThread( void * pArg )
{
Gia_StochThData_t * pThData = (Gia_StochThData_t *)pArg;
volatile int * pPlace = &pThData->fWorking;
Gia_Man_t * pGia, * pNew;
while ( 1 )
{
while ( *pPlace == 0 );
assert( pThData->fWorking );
if ( pThData->Index == -1 )
{
pthread_exit( NULL );
assert( 0 );
return NULL;
}
pGia = (Gia_Man_t *)Vec_PtrEntry( pThData->vGias, pThData->Index );
pNew = Gia_StochProcessOne( pGia, pThData->pScript, pThData->Rand, pThData->nTimeOut );
Gia_ManStop( pGia );
Vec_PtrWriteEntry( pThData->vGias, pThData->Index, pNew );
pThData->fWorking = 0;
}
assert( 0 );
return NULL;
}
void Gia_StochProcess( Vec_Ptr_t * vGias, char * pScript, int nProcs, int TimeSecs, int fVerbose )
{
Gia_StochThData_t ThData[PAR_THR_MAX];
pthread_t WorkerThread[PAR_THR_MAX];
int i, k, status;
if ( fVerbose )
printf( "Running concurrent synthesis with %d processes.\n", nProcs );
fflush( stdout );
if ( nProcs < 2 )
return Gia_StochProcessArray( vGias, pScript, TimeSecs, fVerbose );
// subtract manager thread
nProcs--;
assert( nProcs >= 1 && nProcs <= PAR_THR_MAX );
// start threads
Abc_Random(1);
for ( i = 0; i < nProcs; i++ )
{
ThData[i].vGias = vGias;
ThData[i].pScript = pScript;
ThData[i].Index = -1;
ThData[i].Rand = Abc_Random(0) % 0x1000000;
ThData[i].nTimeOut = TimeSecs;
ThData[i].fWorking = 0;
status = pthread_create( WorkerThread + i, NULL, Gia_StochWorkerThread, (void *)(ThData + i) ); assert( status == 0 );
}
// look at the threads
for ( k = 0; k < Vec_PtrSize(vGias); k++ )
{
for ( i = 0; i < nProcs; i++ )
{
if ( ThData[i].fWorking )
continue;
ThData[i].Index = k;
ThData[i].fWorking = 1;
break;
}
if ( i == nProcs )
k--;
}
// wait till threads finish
for ( i = 0; i < nProcs; i++ )
if ( ThData[i].fWorking )
i = -1;
// stop threads
for ( i = 0; i < nProcs; i++ )
{
assert( !ThData[i].fWorking );
// stop
ThData[i].Index = -1;
ThData[i].fWorking = 1;
}
}
#endif // pthreads are used
/**Function*************************************************************
Synopsis [] Synopsis []
Description [] Description []
...@@ -184,7 +360,7 @@ Gia_Man_t * Gia_ManDupDivideOne( Gia_Man_t * p, Vec_Int_t * vCis, Vec_Int_t * vA ...@@ -184,7 +360,7 @@ Gia_Man_t * Gia_ManDupDivideOne( Gia_Man_t * p, Vec_Int_t * vCis, Vec_Int_t * vA
pNew->vMapping = vMapping; pNew->vMapping = vMapping;
return pNew; return pNew;
} }
Vec_Ptr_t * Gia_ManDupDivide( Gia_Man_t * p, Vec_Wec_t * vCis, Vec_Wec_t * vAnds, Vec_Wec_t * vCos, char * pScript ) Vec_Ptr_t * Gia_ManDupDivide( Gia_Man_t * p, Vec_Wec_t * vCis, Vec_Wec_t * vAnds, Vec_Wec_t * vCos, char * pScript, int nProcs, int TimeOut )
{ {
Vec_Ptr_t * vAigs = Vec_PtrAlloc( Vec_WecSize(vCis) ); int i; Vec_Ptr_t * vAigs = Vec_PtrAlloc( Vec_WecSize(vCis) ); int i;
for ( i = 0; i < Vec_WecSize(vCis); i++ ) for ( i = 0; i < Vec_WecSize(vCis); i++ )
...@@ -192,7 +368,8 @@ Vec_Ptr_t * Gia_ManDupDivide( Gia_Man_t * p, Vec_Wec_t * vCis, Vec_Wec_t * vAnds ...@@ -192,7 +368,8 @@ Vec_Ptr_t * Gia_ManDupDivide( Gia_Man_t * p, Vec_Wec_t * vCis, Vec_Wec_t * vAnds
Gia_ManCollectNodes( p, Vec_WecEntry(vCis, i), Vec_WecEntry(vAnds, i), Vec_WecEntry(vCos, i) ); Gia_ManCollectNodes( p, Vec_WecEntry(vCis, i), Vec_WecEntry(vAnds, i), Vec_WecEntry(vCos, i) );
Vec_PtrPush( vAigs, Gia_ManDupDivideOne(p, Vec_WecEntry(vCis, i), Vec_WecEntry(vAnds, i), Vec_WecEntry(vCos, i)) ); Vec_PtrPush( vAigs, Gia_ManDupDivideOne(p, Vec_WecEntry(vCis, i), Vec_WecEntry(vAnds, i), Vec_WecEntry(vCos, i)) );
} }
Gia_ManStochSynthesis( vAigs, pScript ); //Gia_ManStochSynthesis( vAigs, pScript );
Gia_StochProcess( vAigs, pScript, nProcs, TimeOut, 0 );
return vAigs; return vAigs;
} }
Gia_Man_t * Gia_ManDupStitch( Gia_Man_t * p, Vec_Wec_t * vCis, Vec_Wec_t * vAnds, Vec_Wec_t * vCos, Vec_Ptr_t * vAigs, int fHash ) Gia_Man_t * Gia_ManDupStitch( Gia_Man_t * p, Vec_Wec_t * vCis, Vec_Wec_t * vAnds, Vec_Wec_t * vCos, Vec_Ptr_t * vAigs, int fHash )
...@@ -388,7 +565,7 @@ Vec_Wec_t * Gia_ManStochOutputs( Gia_Man_t * p, Vec_Wec_t * vAnds ) ...@@ -388,7 +565,7 @@ Vec_Wec_t * Gia_ManStochOutputs( Gia_Man_t * p, Vec_Wec_t * vAnds )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Gia_ManStochSyn( int nMaxSize, int nIters, int TimeOut, int Seed, int fVerbose, char * pScript ) void Gia_ManStochSyn( int nMaxSize, int nIters, int TimeOut, int Seed, int fVerbose, char * pScript, int nProcs )
{ {
abctime nTimeToStop = TimeOut ? Abc_Clock() + TimeOut * CLOCKS_PER_SEC : 0; abctime nTimeToStop = TimeOut ? Abc_Clock() + TimeOut * CLOCKS_PER_SEC : 0;
abctime clkStart = Abc_Clock(); abctime clkStart = Abc_Clock();
...@@ -407,7 +584,7 @@ void Gia_ManStochSyn( int nMaxSize, int nIters, int TimeOut, int Seed, int fVerb ...@@ -407,7 +584,7 @@ void Gia_ManStochSyn( int nMaxSize, int nIters, int TimeOut, int Seed, int fVerb
Vec_Wec_t * vAnds = Gia_ManStochNodes( pGia, nMaxSize, Abc_Random(0) & 0x7FFFFFFF ); Vec_Wec_t * vAnds = Gia_ManStochNodes( pGia, nMaxSize, Abc_Random(0) & 0x7FFFFFFF );
Vec_Wec_t * vIns = Gia_ManStochInputs( pGia, vAnds ); Vec_Wec_t * vIns = Gia_ManStochInputs( pGia, vAnds );
Vec_Wec_t * vOuts = Gia_ManStochOutputs( pGia, vAnds ); Vec_Wec_t * vOuts = Gia_ManStochOutputs( pGia, vAnds );
Vec_Ptr_t * vAigs = Gia_ManDupDivide( pGia, vIns, vAnds, vOuts, pScript ); Vec_Ptr_t * vAigs = Gia_ManDupDivide( pGia, vIns, vAnds, vOuts, pScript, nProcs, TimeOut );
Gia_Man_t * pNew = Gia_ManDupStitchMap( pGia, vIns, vAnds, vOuts, vAigs ); Gia_Man_t * pNew = Gia_ManDupStitchMap( pGia, vIns, vAnds, vOuts, vAigs );
int fMapped = Gia_ManHasMapping(pGia) && Gia_ManHasMapping(pNew); int fMapped = Gia_ManHasMapping(pGia) && Gia_ManHasMapping(pNew);
Abc_FrameUpdateGia( Abc_FrameGetGlobalFrame(), pNew ); Abc_FrameUpdateGia( Abc_FrameGetGlobalFrame(), pNew );
......
...@@ -897,6 +897,16 @@ void Abc_AigReplace_int( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, i ...@@ -897,6 +897,16 @@ void Abc_AigReplace_int( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, i
{ {
if ( Abc_ObjIsCo(pFanout) ) if ( Abc_ObjIsCo(pFanout) )
{ {
pFanin1 = Abc_ObjRegular( pNew );
if ( pFanin1->fMarkB )
Abc_AigRemoveFromLevelStructureR( pMan->vLevelsR, pFanin1 );
if ( fUpdateLevel && pMan->pNtkAig->vLevelsR )
{
Abc_ObjSetReverseLevel( pFanin1, Abc_ObjReverseLevel(pOld) );
assert( pFanin1->fMarkB == 0 );
pFanin1->fMarkB = 1;
Vec_VecPush( pMan->vLevelsR, Abc_ObjReverseLevel(pFanin1), pFanin1 );
}
Abc_ObjPatchFanin( pFanout, pOld, pNew ); Abc_ObjPatchFanin( pFanout, pOld, pNew );
continue; continue;
} }
......
...@@ -1265,6 +1265,42 @@ int Abc_NtkToAig( Abc_Ntk_t * pNtk ) ...@@ -1265,6 +1265,42 @@ int Abc_NtkToAig( Abc_Ntk_t * pNtk )
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_ObjFaninSort( Abc_Obj_t * pObj )
{
Vec_Int_t * vFanins = Abc_ObjFaninVec( pObj );
char * pCube, * pSop = (char*)pObj->pData;
int i, j, nVars = Abc_SopGetVarNum( pSop );
assert( nVars == Vec_IntSize(vFanins) );
for ( i = 0; i < Vec_IntSize(vFanins); i++ )
for ( j = i+1; j < Vec_IntSize(vFanins); j++ )
{
if ( Vec_IntEntry(vFanins, i) < Vec_IntEntry(vFanins, j) )
continue;
ABC_SWAP( int, Vec_IntArray(vFanins)[i], Vec_IntArray(vFanins)[j] );
for ( pCube = pSop; *pCube; pCube += nVars + 3 ) {
ABC_SWAP( char, pCube[i], pCube[j] );
}
}
}
void Abc_NtkFaninSort( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj; int i;
assert( Abc_NtkIsSopLogic(pNtk) );
Abc_NtkForEachNode( pNtk, pObj, i )
Abc_ObjFaninSort( pObj );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -175,11 +175,11 @@ void Abc_NtkDsdConstruct( Dsd_Manager_t * pManDsd, Abc_Ntk_t * pNtk, Abc_Ntk_t * ...@@ -175,11 +175,11 @@ void Abc_NtkDsdConstruct( Dsd_Manager_t * pManDsd, Abc_Ntk_t * pNtk, Abc_Ntk_t *
// save the CI nodes in the DSD nodes // save the CI nodes in the DSD nodes
Abc_AigConst1(pNtk)->pCopy = pNodeNew = Abc_NtkCreateNodeConst1(pNtkNew); Abc_AigConst1(pNtk)->pCopy = pNodeNew = Abc_NtkCreateNodeConst1(pNtkNew);
Dsd_NodeSetMark( Dsd_ManagerReadConst1(pManDsd), (int)(ABC_PTRINT_T)pNodeNew ); Dsd_NodeSetMark( Dsd_ManagerReadConst1(pManDsd), (word)(ABC_PTRINT_T)pNodeNew );
Abc_NtkForEachCi( pNtk, pNode, i ) Abc_NtkForEachCi( pNtk, pNode, i )
{ {
pNodeDsd = Dsd_ManagerReadInput( pManDsd, i ); pNodeDsd = Dsd_ManagerReadInput( pManDsd, i );
Dsd_NodeSetMark( pNodeDsd, (int)(ABC_PTRINT_T)pNode->pCopy ); Dsd_NodeSetMark( pNodeDsd, (word)(ABC_PTRINT_T)pNode->pCopy );
} }
// collect DSD nodes in DFS order (leaves and const1 are not collected) // collect DSD nodes in DFS order (leaves and const1 are not collected)
...@@ -298,7 +298,7 @@ printf( "\n" ); ...@@ -298,7 +298,7 @@ printf( "\n" );
} }
} }
pNodeNew->pData = bLocal; pNodeNew->pData = bLocal;
Dsd_NodeSetMark( pNodeDsd, (int)(ABC_PTRINT_T)pNodeNew ); Dsd_NodeSetMark( pNodeDsd, (word)(ABC_PTRINT_T)pNodeNew );
return pNodeNew; return pNodeNew;
} }
...@@ -417,7 +417,7 @@ void Abc_NodeDecompDsdAndMux( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes, Dsd_Manager ...@@ -417,7 +417,7 @@ void Abc_NodeDecompDsdAndMux( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes, Dsd_Manager
Abc_ObjForEachFanin( pNode, pFanin, i ) Abc_ObjForEachFanin( pNode, pFanin, i )
{ {
pFaninDsd = Dsd_ManagerReadInput( pManDsd, i ); pFaninDsd = Dsd_ManagerReadInput( pManDsd, i );
Dsd_NodeSetMark( pFaninDsd, (int)(ABC_PTRINT_T)pFanin ); Dsd_NodeSetMark( pFaninDsd, (word)(ABC_PTRINT_T)pFanin );
} }
// construct the intermediate nodes // construct the intermediate nodes
......
...@@ -1140,6 +1140,70 @@ void Abc_GenBooth( char * pFileName, int nVars ) ...@@ -1140,6 +1140,70 @@ void Abc_GenBooth( char * pFileName, int nVars )
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_GenGraph( char * pFileName, int nPis )
{
FILE * pFile;
int i, a, b, w, nDigitsIn, nWords = Abc_TruthWordNum( nPis*(nPis-1)/2 );
unsigned * pTruth = ABC_CALLOC( unsigned, nWords );
unsigned char M[10][10] = {{0}}, C[100][2] = {{0}}, nVars = 0;
assert( nPis <= 8 );
for ( a = 0; a < nPis; a++ )
for ( b = a+1; b < nPis; b++ )
C[nVars][0] = a, C[nVars][1] = b, nVars++;
for ( i = 0; i < (1<<nVars); i++ )
{
int fChanges = 1;
for ( w = 0; w < nVars; w++ )
M[C[w][0]][C[w][1]] = M[C[w][1]][C[w][0]] = (i >> w) & 1;
while ( fChanges && !M[0][1] ) {
fChanges = 0;
for ( a = 0; a < nPis; a++ )
for ( b = 0; b < nPis; b++ )
if ( M[a][b] )
for ( w = 0; w < nPis; w++ )
if ( M[b][w] && !M[a][w] )
M[a][w] = 1, fChanges = 1;
}
if ( M[0][1] )
Abc_InfoSetBit(pTruth, i);
}
pFile = fopen( pFileName, "w" );
fprintf( pFile, "# Function with %d inputs generated by ABC on %s\n", nVars, Extra_TimeStamp() );
fprintf( pFile, ".model fun%d\n", nVars );
fprintf( pFile, ".inputs" );
nDigitsIn = Abc_Base10Log( nVars );
for ( i = 0; i < nVars; i++ )
fprintf( pFile, " i%0*d", nDigitsIn, i );
fprintf( pFile, "\n" );
fprintf( pFile, ".outputs f\n" );
fprintf( pFile, ".names" );
nDigitsIn = Abc_Base10Log( nVars );
for ( b = nVars-1; b >= 0; b-- )
fprintf( pFile, " i%0*d", nDigitsIn, b );
fprintf( pFile, " f\n" );
for ( i = 0; i < (1<<nVars); i++ )
if ( Abc_InfoHasBit(pTruth, i) )
{
for ( b = nVars-1; b >= 0; b-- )
fprintf( pFile, "%d", (i>>b)&1 );
fprintf( pFile, " 1\n" );
}
fprintf( pFile, ".end\n" );
fprintf( pFile, "\n" );
fclose( pFile );
ABC_FREE( pTruth );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -92,8 +92,8 @@ extern DdNode * Dsd_NodeReadSupp( Dsd_Node_t * p ); ...@@ -92,8 +92,8 @@ extern DdNode * Dsd_NodeReadSupp( Dsd_Node_t * p );
extern Dsd_Node_t ** Dsd_NodeReadDecs( Dsd_Node_t * p ); extern Dsd_Node_t ** Dsd_NodeReadDecs( Dsd_Node_t * p );
extern Dsd_Node_t * Dsd_NodeReadDec ( Dsd_Node_t * p, int i ); extern Dsd_Node_t * Dsd_NodeReadDec ( Dsd_Node_t * p, int i );
extern int Dsd_NodeReadDecsNum( Dsd_Node_t * p ); extern int Dsd_NodeReadDecsNum( Dsd_Node_t * p );
extern int Dsd_NodeReadMark( Dsd_Node_t * p ); extern word Dsd_NodeReadMark( Dsd_Node_t * p );
extern void Dsd_NodeSetMark( Dsd_Node_t * p, int Mark ); extern void Dsd_NodeSetMark( Dsd_Node_t * p, word Mark );
extern DdManager * Dsd_ManagerReadDd( Dsd_Manager_t * pMan ); extern DdManager * Dsd_ManagerReadDd( Dsd_Manager_t * pMan );
extern Dsd_Node_t * Dsd_ManagerReadRoot( Dsd_Manager_t * pMan, int i ); extern Dsd_Node_t * Dsd_ManagerReadRoot( Dsd_Manager_t * pMan, int i );
extern Dsd_Node_t * Dsd_ManagerReadInput( Dsd_Manager_t * pMan, int i ); extern Dsd_Node_t * Dsd_ManagerReadInput( Dsd_Manager_t * pMan, int i );
......
...@@ -56,7 +56,7 @@ DdNode * Dsd_NodeReadSupp( Dsd_Node_t * p ) { return p->S; } ...@@ -56,7 +56,7 @@ DdNode * Dsd_NodeReadSupp( Dsd_Node_t * p ) { return p->S; }
Dsd_Node_t ** Dsd_NodeReadDecs( Dsd_Node_t * p ) { return p->pDecs; } Dsd_Node_t ** Dsd_NodeReadDecs( Dsd_Node_t * p ) { return p->pDecs; }
Dsd_Node_t * Dsd_NodeReadDec ( Dsd_Node_t * p, int i ) { return p->pDecs[i]; } Dsd_Node_t * Dsd_NodeReadDec ( Dsd_Node_t * p, int i ) { return p->pDecs[i]; }
int Dsd_NodeReadDecsNum( Dsd_Node_t * p ) { return p->nDecs; } int Dsd_NodeReadDecsNum( Dsd_Node_t * p ) { return p->nDecs; }
int Dsd_NodeReadMark( Dsd_Node_t * p ) { return p->Mark; } word Dsd_NodeReadMark( Dsd_Node_t * p ) { return p->Mark; }
/**Function************************************************************* /**Function*************************************************************
...@@ -74,7 +74,7 @@ int Dsd_NodeReadMark( Dsd_Node_t * p ) { return p->Mark; } ...@@ -74,7 +74,7 @@ int Dsd_NodeReadMark( Dsd_Node_t * p ) { return p->Mark; }
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Dsd_NodeSetMark( Dsd_Node_t * p, int Mark ){ p->Mark = Mark; } void Dsd_NodeSetMark( Dsd_Node_t * p, word Mark ){ p->Mark = Mark; }
/**Function************************************************************* /**Function*************************************************************
......
...@@ -57,7 +57,7 @@ struct Dsd_Node_t_ ...@@ -57,7 +57,7 @@ struct Dsd_Node_t_
DdNode * G; // function of the node DdNode * G; // function of the node
DdNode * S; // support of this function DdNode * S; // support of this function
Dsd_Node_t ** pDecs; // pointer to structures for formal inputs Dsd_Node_t ** pDecs; // pointer to structures for formal inputs
int Mark; // the mark used by CASE 4 of disjoint decomposition word Mark; // the mark used by CASE 4 of disjoint decomposition
short nDecs; // the number of formal inputs short nDecs; // the number of formal inputs
short nVisits; // the counter of visits short nVisits; // the counter of visits
}; };
......
...@@ -325,8 +325,8 @@ static inline int Abc_Var2Lit4( int Var, int Att ) { assert(!(Att >> ...@@ -325,8 +325,8 @@ static inline int Abc_Var2Lit4( int Var, int Att ) { assert(!(Att >>
static inline int Abc_Lit2Var4( int Lit ) { assert(Lit >= 0); return Lit >> 4; } static inline int Abc_Lit2Var4( int Lit ) { assert(Lit >= 0); return Lit >> 4; }
static inline int Abc_Lit2Att4( int Lit ) { assert(Lit >= 0); return Lit & 15; } static inline int Abc_Lit2Att4( int Lit ) { assert(Lit >= 0); return Lit & 15; }
// time counting
typedef ABC_INT64_T abctime; typedef ABC_INT64_T abctime;
// counting wall time
static inline abctime Abc_Clock() static inline abctime Abc_Clock()
{ {
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
...@@ -336,6 +336,25 @@ static inline abctime Abc_Clock() ...@@ -336,6 +336,25 @@ static inline abctime Abc_Clock()
#endif #endif
#if (defined(LIN) || defined(LIN64)) && !APPLE_MACH && !defined(__MINGW32__) #if (defined(LIN) || defined(LIN64)) && !APPLE_MACH && !defined(__MINGW32__)
struct timespec ts; struct timespec ts;
if ( clock_gettime(CLOCK_MONOTONIC, &ts) < 0 )
return (abctime)-1;
abctime res = ((abctime) ts.tv_sec) * CLOCKS_PER_SEC;
res += (((abctime) ts.tv_nsec) * CLOCKS_PER_SEC) / 1000000000;
return res;
#else
return (abctime) clock();
#endif
}
// counting thread time
static inline abctime Abc_ThreadClock()
{
#if defined(__APPLE__) && defined(__MACH__)
#define APPLE_MACH (__APPLE__ & __MACH__)
#else
#define APPLE_MACH 0
#endif
#if (defined(LIN) || defined(LIN64)) && !APPLE_MACH && !defined(__MINGW32__)
struct timespec ts;
if ( clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) < 0 ) if ( clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) < 0 )
return (abctime)-1; return (abctime)-1;
abctime res = ((abctime) ts.tv_sec) * CLOCKS_PER_SEC; abctime res = ((abctime) ts.tv_sec) * CLOCKS_PER_SEC;
...@@ -346,7 +365,6 @@ static inline abctime Abc_Clock() ...@@ -346,7 +365,6 @@ static inline abctime Abc_Clock()
#endif #endif
} }
// misc printing procedures // misc printing procedures
enum Abc_VerbLevel enum Abc_VerbLevel
{ {
......
...@@ -705,7 +705,7 @@ finish: ...@@ -705,7 +705,7 @@ finish:
// wait till threads finish // wait till threads finish
for ( i = 0; i < nProcs; i++ ) for ( i = 0; i < nProcs; i++ )
if ( ThData[i].fWorking ) if ( ThData[i].fWorking )
i = 0; i = -1;
// stop threads // stop threads
for ( i = 0; i < nProcs; i++ ) for ( i = 0; i < nProcs; i++ )
{ {
......
...@@ -1637,22 +1637,6 @@ Vec_Int_t * Exa4_ManSolve( char * pFileNameIn, char * pFileNameOut, int TimeOut, ...@@ -1637,22 +1637,6 @@ Vec_Int_t * Exa4_ManSolve( char * pFileNameIn, char * pFileNameOut, int TimeOut,
char * pKissat = "kissat"; char * pKissat = "kissat";
#endif #endif
char Command[1000], * pCommand = (char *)&Command; char Command[1000], * pCommand = (char *)&Command;
{
FILE * pFile = fopen( pKissat, "rb" );
if ( pFile == NULL )
{
printf( "Cannot find the Kissat binary \"%s\".\n", pKissat );
pKissat = "./kissat";
pFile = fopen( pKissat, "rb" );
if ( pFile == NULL )
{
printf( "Cannot find the Kissat binary \"%s\".\n", pKissat );
return NULL;
}
fclose( pFile );
}
fclose( pFile );
}
if ( TimeOut ) if ( TimeOut )
sprintf( pCommand, "%s --time=%d %s %s > %s", pKissat, TimeOut, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut ); sprintf( pCommand, "%s --time=%d %s %s > %s", pKissat, TimeOut, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
else else
......
...@@ -154,6 +154,8 @@ extern void Cnf_ManStop( Cnf_Man_t * p ); ...@@ -154,6 +154,8 @@ extern void Cnf_ManStop( Cnf_Man_t * p );
extern Vec_Int_t * Cnf_DataCollectPiSatNums( Cnf_Dat_t * pCnf, Aig_Man_t * p ); extern Vec_Int_t * Cnf_DataCollectPiSatNums( Cnf_Dat_t * pCnf, Aig_Man_t * p );
extern Cnf_Dat_t * Cnf_DataAlloc( Aig_Man_t * pAig, int nVars, int nClauses, int nLiterals ); extern Cnf_Dat_t * Cnf_DataAlloc( Aig_Man_t * pAig, int nVars, int nClauses, int nLiterals );
extern Cnf_Dat_t * Cnf_DataDup( Cnf_Dat_t * p ); extern Cnf_Dat_t * Cnf_DataDup( Cnf_Dat_t * p );
extern Cnf_Dat_t * Cnf_DataDupCof( Cnf_Dat_t * p, int Lit );
extern Cnf_Dat_t * Cnf_DataDupCofArray( Cnf_Dat_t * p, Vec_Int_t * vLits );
extern void Cnf_DataFree( Cnf_Dat_t * p ); extern void Cnf_DataFree( Cnf_Dat_t * p );
extern void Cnf_DataLift( Cnf_Dat_t * p, int nVarsPlus ); extern void Cnf_DataLift( Cnf_Dat_t * p, int nVarsPlus );
extern void Cnf_DataCollectFlipLits( Cnf_Dat_t * p, int iFlipVar, Vec_Int_t * vFlips ); extern void Cnf_DataCollectFlipLits( Cnf_Dat_t * p, int iFlipVar, Vec_Int_t * vFlips );
......
...@@ -103,10 +103,8 @@ void Cnf_ManStop( Cnf_Man_t * p ) ...@@ -103,10 +103,8 @@ void Cnf_ManStop( Cnf_Man_t * p )
***********************************************************************/ ***********************************************************************/
Vec_Int_t * Cnf_DataCollectPiSatNums( Cnf_Dat_t * pCnf, Aig_Man_t * p ) Vec_Int_t * Cnf_DataCollectPiSatNums( Cnf_Dat_t * pCnf, Aig_Man_t * p )
{ {
Vec_Int_t * vCiIds; Aig_Obj_t * pObj; int i;
Aig_Obj_t * pObj; Vec_Int_t * vCiIds = Vec_IntAlloc( Aig_ManCiNum(p) );
int i;
vCiIds = Vec_IntAlloc( Aig_ManCiNum(p) );
Aig_ManForEachCi( p, pObj, i ) Aig_ManForEachCi( p, pObj, i )
Vec_IntPush( vCiIds, pCnf->pVarNums[pObj->Id] ); Vec_IntPush( vCiIds, pCnf->pVarNums[pObj->Id] );
return vCiIds; return vCiIds;
...@@ -126,9 +124,7 @@ Vec_Int_t * Cnf_DataCollectPiSatNums( Cnf_Dat_t * pCnf, Aig_Man_t * p ) ...@@ -126,9 +124,7 @@ Vec_Int_t * Cnf_DataCollectPiSatNums( Cnf_Dat_t * pCnf, Aig_Man_t * p )
Cnf_Dat_t * Cnf_DataAlloc( Aig_Man_t * pAig, int nVars, int nClauses, int nLiterals ) Cnf_Dat_t * Cnf_DataAlloc( Aig_Man_t * pAig, int nVars, int nClauses, int nLiterals )
{ {
Cnf_Dat_t * pCnf; Cnf_Dat_t * pCnf;
int i; pCnf = ABC_CALLOC( Cnf_Dat_t, 1 );
pCnf = ABC_ALLOC( Cnf_Dat_t, 1 );
memset( pCnf, 0, sizeof(Cnf_Dat_t) );
pCnf->pMan = pAig; pCnf->pMan = pAig;
pCnf->nVars = nVars; pCnf->nVars = nVars;
pCnf->nClauses = nClauses; pCnf->nClauses = nClauses;
...@@ -136,10 +132,8 @@ Cnf_Dat_t * Cnf_DataAlloc( Aig_Man_t * pAig, int nVars, int nClauses, int nLiter ...@@ -136,10 +132,8 @@ Cnf_Dat_t * Cnf_DataAlloc( Aig_Man_t * pAig, int nVars, int nClauses, int nLiter
pCnf->pClauses = ABC_ALLOC( int *, nClauses + 1 ); pCnf->pClauses = ABC_ALLOC( int *, nClauses + 1 );
pCnf->pClauses[0] = ABC_ALLOC( int, nLiterals ); pCnf->pClauses[0] = ABC_ALLOC( int, nLiterals );
pCnf->pClauses[nClauses] = pCnf->pClauses[0] + nLiterals; pCnf->pClauses[nClauses] = pCnf->pClauses[0] + nLiterals;
pCnf->pVarNums = ABC_ALLOC( int, Aig_ManObjNumMax(pAig) ); if ( pCnf->pVarNums )
// memset( pCnf->pVarNums, 0xff, sizeof(int) * Aig_ManObjNumMax(pAig) ); pCnf->pVarNums = ABC_FALLOC( int, Aig_ManObjNumMax(pAig) );
for ( i = 0; i < Aig_ManObjNumMax(pAig); i++ )
pCnf->pVarNums[i] = -1;
return pCnf; return pCnf;
} }
...@@ -160,9 +154,42 @@ Cnf_Dat_t * Cnf_DataDup( Cnf_Dat_t * p ) ...@@ -160,9 +154,42 @@ Cnf_Dat_t * Cnf_DataDup( Cnf_Dat_t * p )
int i; int i;
pCnf = Cnf_DataAlloc( p->pMan, p->nVars, p->nClauses, p->nLiterals ); pCnf = Cnf_DataAlloc( p->pMan, p->nVars, p->nClauses, p->nLiterals );
memcpy( pCnf->pClauses[0], p->pClauses[0], sizeof(int) * p->nLiterals ); memcpy( pCnf->pClauses[0], p->pClauses[0], sizeof(int) * p->nLiterals );
if ( p->pVarNums )
memcpy( pCnf->pVarNums, p->pVarNums, sizeof(int) * Aig_ManObjNumMax(p->pMan) );
for ( i = 1; i < p->nClauses; i++ )
pCnf->pClauses[i] = pCnf->pClauses[0] + (p->pClauses[i] - p->pClauses[0]);
return pCnf;
}
Cnf_Dat_t * Cnf_DataDupCof( Cnf_Dat_t * p, int Lit )
{
Cnf_Dat_t * pCnf;
int i;
pCnf = Cnf_DataAlloc( p->pMan, p->nVars, p->nClauses+1, p->nLiterals+1 );
memcpy( pCnf->pClauses[0], p->pClauses[0], sizeof(int) * p->nLiterals );
if ( pCnf->pVarNums )
memcpy( pCnf->pVarNums, p->pVarNums, sizeof(int) * Aig_ManObjNumMax(p->pMan) ); memcpy( pCnf->pVarNums, p->pVarNums, sizeof(int) * Aig_ManObjNumMax(p->pMan) );
for ( i = 1; i < p->nClauses; i++ ) for ( i = 1; i < p->nClauses; i++ )
pCnf->pClauses[i] = pCnf->pClauses[0] + (p->pClauses[i] - p->pClauses[0]); pCnf->pClauses[i] = pCnf->pClauses[0] + (p->pClauses[i] - p->pClauses[0]);
pCnf->pClauses[p->nClauses] = pCnf->pClauses[0] + p->nLiterals;
pCnf->pClauses[p->nClauses][0] = Lit;
assert( pCnf->pClauses[p->nClauses+1] == pCnf->pClauses[0] + p->nLiterals+1 );
return pCnf;
}
Cnf_Dat_t * Cnf_DataDupCofArray( Cnf_Dat_t * p, Vec_Int_t * vLits )
{
Cnf_Dat_t * pCnf;
int i, iLit;
pCnf = Cnf_DataAlloc( p->pMan, p->nVars, p->nClauses+Vec_IntSize(vLits), p->nLiterals+Vec_IntSize(vLits) );
memcpy( pCnf->pClauses[0], p->pClauses[0], sizeof(int) * p->nLiterals );
if ( pCnf->pVarNums )
memcpy( pCnf->pVarNums, p->pVarNums, sizeof(int) * Aig_ManObjNumMax(p->pMan) );
for ( i = 1; i < p->nClauses; i++ )
pCnf->pClauses[i] = pCnf->pClauses[0] + (p->pClauses[i] - p->pClauses[0]);
Vec_IntForEachEntry( vLits, iLit, i ) {
pCnf->pClauses[p->nClauses+i] = pCnf->pClauses[0] + p->nLiterals+i;
pCnf->pClauses[p->nClauses+i][0] = iLit;
}
assert( pCnf->pClauses[p->nClauses+Vec_IntSize(vLits)] == pCnf->pClauses[0] + p->nLiterals+Vec_IntSize(vLits) );
return pCnf; return pCnf;
} }
......
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