Commit 4937fb09 by Bruno Schmitt

Minimizing memory usage. The implementation was using twice as much memory as necessary.

parent 1d26d58a
...@@ -96,7 +96,7 @@ Fxch_SCHashTable_t* Fxch_SCHashTableCreate( Fxch_Man_t* pFxchMan, ...@@ -96,7 +96,7 @@ Fxch_SCHashTable_t* Fxch_SCHashTableCreate( Fxch_Man_t* pFxchMan,
int nEntries ) int nEntries )
{ {
Fxch_SCHashTable_t* pSCHashTable = ABC_CALLOC( Fxch_SCHashTable_t, 1 ); Fxch_SCHashTable_t* pSCHashTable = ABC_CALLOC( Fxch_SCHashTable_t, 1 );
int nBits = Abc_Base2Log( nEntries + 1 ) + 1; int nBits = Abc_Base2Log( nEntries + 1 );
pSCHashTable->pFxchMan = pFxchMan; pSCHashTable->pFxchMan = pFxchMan;
...@@ -221,10 +221,10 @@ static inline int Fxch_SCHashTableEntryCompare( Fxch_SCHashTable_t* pSCHashTable ...@@ -221,10 +221,10 @@ static inline int Fxch_SCHashTableEntryCompare( Fxch_SCHashTable_t* pSCHashTable
int Fxch_SCHashTableInsert( Fxch_SCHashTable_t* pSCHashTable, int Fxch_SCHashTableInsert( Fxch_SCHashTable_t* pSCHashTable,
Vec_Wec_t* vCubes, Vec_Wec_t* vCubes,
unsigned int SubCubeID, unsigned int SubCubeID,
unsigned int iSubCube, unsigned int iSubCube,
unsigned int iCube, unsigned int iCube,
unsigned int iLit0, unsigned int iLit0,
unsigned int iLit1, unsigned int iLit1,
char fUpdate ) char fUpdate )
{ {
...@@ -238,7 +238,7 @@ int Fxch_SCHashTableInsert( Fxch_SCHashTable_t* pSCHashTable, ...@@ -238,7 +238,7 @@ int Fxch_SCHashTableInsert( Fxch_SCHashTable_t* pSCHashTable,
fStart = 1; fStart = 1;
MurmurHash3_x86_32( ( void* ) &SubCubeID, sizeof( int ), 0x9747b28c, &BinID); MurmurHash3_x86_32( ( void* ) &SubCubeID, sizeof( int ), 0x9747b28c, &BinID);
iNewEntry = ( unsigned int )( Vec_IntEntry( pSCHashTable->vCubeLinks, iCube ) ) + iSubCube; iNewEntry = ( unsigned int )( Vec_IntEntry( pSCHashTable->vCubeLinks, iCube ) ) + iSubCube;
pBin = Fxch_SCHashTableBin( pSCHashTable, BinID ); pBin = Fxch_SCHashTableBin( pSCHashTable, BinID );
pNewEntry = Fxch_SCHashTableEntry( pSCHashTable, iNewEntry ); pNewEntry = Fxch_SCHashTableEntry( pSCHashTable, iNewEntry );
...@@ -286,15 +286,15 @@ int Fxch_SCHashTableInsert( Fxch_SCHashTable_t* pSCHashTable, ...@@ -286,15 +286,15 @@ int Fxch_SCHashTableInsert( Fxch_SCHashTable_t* pSCHashTable,
else else
Base = Fxch_DivCreate( pSCHashTable->pFxchMan, &( pNewEntry->SCData ), &( pEntry->SCData ) ); Base = Fxch_DivCreate( pSCHashTable->pFxchMan, &( pNewEntry->SCData ), &( pEntry->SCData ) );
if ( Base < 0 ) if ( Base < 0 )
continue; continue;
iNewDiv = Fxch_DivAdd( pSCHashTable->pFxchMan, fUpdate, 0, Base ); iNewDiv = Fxch_DivAdd( pSCHashTable->pFxchMan, fUpdate, 0, Base );
if ( pSCHashTable->pFxchMan->SMode == 0 ) if ( pSCHashTable->pFxchMan->SMode == 0 )
{ {
Vec_WecPush( pSCHashTable->pFxchMan->vDivCubePairs, iNewDiv, pEntry->SCData.iCube ); Vec_WecPush( pSCHashTable->pFxchMan->vDivCubePairs, iNewDiv, pEntry->SCData.iCube );
Vec_WecPush( pSCHashTable->pFxchMan->vDivCubePairs, iNewDiv, pNewEntry->SCData.iCube ); Vec_WecPush( pSCHashTable->pFxchMan->vDivCubePairs, iNewDiv, pNewEntry->SCData.iCube );
} }
Pairs++; Pairs++;
...@@ -309,10 +309,10 @@ int Fxch_SCHashTableInsert( Fxch_SCHashTable_t* pSCHashTable, ...@@ -309,10 +309,10 @@ int Fxch_SCHashTableInsert( Fxch_SCHashTable_t* pSCHashTable,
int Fxch_SCHashTableRemove( Fxch_SCHashTable_t* pSCHashTable, int Fxch_SCHashTableRemove( Fxch_SCHashTable_t* pSCHashTable,
Vec_Wec_t* vCubes, Vec_Wec_t* vCubes,
unsigned int SubCubeID, unsigned int SubCubeID,
unsigned int iSubCube, unsigned int iSubCube,
unsigned int iCube, unsigned int iCube,
unsigned int iLit0, unsigned int iLit0,
unsigned int iLit1, unsigned int iLit1,
char fUpdate ) char fUpdate )
{ {
...@@ -325,11 +325,11 @@ int Fxch_SCHashTableRemove( Fxch_SCHashTable_t* pSCHashTable, ...@@ -325,11 +325,11 @@ int Fxch_SCHashTableRemove( Fxch_SCHashTable_t* pSCHashTable,
fStart = 1; fStart = 1;
MurmurHash3_x86_32( ( void* ) &SubCubeID, sizeof( int ), 0x9747b28c, &BinID); MurmurHash3_x86_32( ( void* ) &SubCubeID, sizeof( int ), 0x9747b28c, &BinID);
iEntry = ( unsigned int )( Vec_IntEntry( pSCHashTable->vCubeLinks, iCube ) ) + iSubCube; iEntry = ( unsigned int )( Vec_IntEntry( pSCHashTable->vCubeLinks, iCube ) ) + iSubCube;
pBin = Fxch_SCHashTableBin( pSCHashTable, BinID ); pBin = Fxch_SCHashTableBin( pSCHashTable, BinID );
pEntry = Fxch_SCHashTableEntry( pSCHashTable, iEntry ); pEntry = Fxch_SCHashTableEntry( pSCHashTable, iEntry );
assert( pEntry->Used == 1 ); assert( pEntry->Used == 1 );
assert( pEntry->SCData.iCube == iCube ); assert( pEntry->SCData.iCube == iCube );
...@@ -345,12 +345,12 @@ int Fxch_SCHashTableRemove( Fxch_SCHashTable_t* pSCHashTable, ...@@ -345,12 +345,12 @@ int Fxch_SCHashTableRemove( Fxch_SCHashTable_t* pSCHashTable,
for ( iNextEntry = (int)pEntry->iNext; iNextEntry != (int)iEntry; iNextEntry = pNextEntry->iNext, fStart = 0 ) for ( iNextEntry = (int)pEntry->iNext; iNextEntry != (int)iEntry; iNextEntry = pNextEntry->iNext, fStart = 0 )
{ {
int Base, int Base,
iDiv; iDiv;
pNextEntry = Fxch_SCHashTableBin( pSCHashTable, iNextEntry ); pNextEntry = Fxch_SCHashTableBin( pSCHashTable, iNextEntry );
if ( !Fxch_SCHashTableEntryCompare( pSCHashTable, vCubes, &( pEntry->SCData ), &( pNextEntry->SCData ) ) if ( !Fxch_SCHashTableEntryCompare( pSCHashTable, vCubes, &( pEntry->SCData ), &( pNextEntry->SCData ) )
|| pEntry->SCData.iLit0 == 0 || pEntry->SCData.iLit0 == 0
|| pNextEntry->SCData.iLit0 == 0 ) || pNextEntry->SCData.iLit0 == 0 )
continue; continue;
...@@ -360,27 +360,27 @@ int Fxch_SCHashTableRemove( Fxch_SCHashTable_t* pSCHashTable, ...@@ -360,27 +360,27 @@ int Fxch_SCHashTableRemove( Fxch_SCHashTable_t* pSCHashTable,
else else
Base = Fxch_DivCreate( pSCHashTable->pFxchMan, &( pEntry->SCData ), &( pNextEntry->SCData ) ); Base = Fxch_DivCreate( pSCHashTable->pFxchMan, &( pEntry->SCData ), &( pNextEntry->SCData ) );
if ( Base < 0 ) if ( Base < 0 )
continue; continue;
iDiv = Fxch_DivRemove( pSCHashTable->pFxchMan, fUpdate, 0, Base ); iDiv = Fxch_DivRemove( pSCHashTable->pFxchMan, fUpdate, 0, Base );
if ( pSCHashTable->pFxchMan->SMode == 0 ) if ( pSCHashTable->pFxchMan->SMode == 0 )
{ {
int i, int i,
iCube0, iCube0,
iCube1; iCube1;
Vec_Int_t* vDivCubePairs = Vec_WecEntry( pSCHashTable->pFxchMan->vDivCubePairs, iDiv ); Vec_Int_t* vDivCubePairs = Vec_WecEntry( pSCHashTable->pFxchMan->vDivCubePairs, iDiv );
Vec_IntForEachEntryDouble( vDivCubePairs, iCube0, iCube1, i ) Vec_IntForEachEntryDouble( vDivCubePairs, iCube0, iCube1, i )
if ( ( iCube0 == (int)pNextEntry->SCData.iCube && iCube1 == (int)pEntry->SCData.iCube ) || if ( ( iCube0 == (int)pNextEntry->SCData.iCube && iCube1 == (int)pEntry->SCData.iCube ) ||
( iCube0 == (int)pEntry->SCData.iCube && iCube1 == (int)pNextEntry->SCData.iCube ) ) ( iCube0 == (int)pEntry->SCData.iCube && iCube1 == (int)pNextEntry->SCData.iCube ) )
{ {
Vec_IntDrop( vDivCubePairs, i+1 ); Vec_IntDrop( vDivCubePairs, i+1 );
Vec_IntDrop( vDivCubePairs, i ); Vec_IntDrop( vDivCubePairs, i );
} }
if ( Vec_IntSize( vDivCubePairs ) == 0 ) if ( Vec_IntSize( vDivCubePairs ) == 0 )
Vec_IntErase( vDivCubePairs ); Vec_IntErase( vDivCubePairs );
} }
Pairs++; Pairs++;
......
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