mirror of https://github.com/YosysHQ/abc.git
Adding memory reporting to vectors.
This commit is contained in:
parent
e8d690f2a4
commit
8a2d237f78
|
|
@ -257,6 +257,22 @@ static inline int Vec_BitCap( Vec_Bit_t * p )
|
|||
return p->nCap;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline double Vec_BitMemory( Vec_Bit_t * p )
|
||||
{
|
||||
return !p ? 0.0 : 1.0 * sizeof(int) * p->nCap + sizeof(Vec_Bit_t);
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
|
|||
|
|
@ -300,6 +300,22 @@ static inline int Vec_FltCap( Vec_Flt_t * p )
|
|||
return p->nCap;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline double Vec_FltMemory( Vec_Flt_t * p )
|
||||
{
|
||||
return !p ? 0.0 : 1.0 * sizeof(float) * p->nCap + sizeof(Vec_Flt_t);
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
|
|||
|
|
@ -372,6 +372,22 @@ static inline int Vec_IntCap( Vec_Int_t * p )
|
|||
return p->nCap;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline double Vec_IntMemory( Vec_Int_t * p )
|
||||
{
|
||||
return !p ? 0.0 : 1.0 * sizeof(int) * p->nCap + sizeof(Vec_Int_t) ;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
|
|||
|
|
@ -303,6 +303,22 @@ static inline int Vec_PtrCap( Vec_Ptr_t * p )
|
|||
return p->nCap;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline double Vec_PtrMemory( Vec_Ptr_t * p )
|
||||
{
|
||||
return !p ? 0.0 : 1.0 * sizeof(void *) * p->nCap + sizeof(Vec_Ptr_t);
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
|
|||
|
|
@ -294,6 +294,22 @@ static inline int Vec_StrCap( Vec_Str_t * p )
|
|||
return p->nCap;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline double Vec_StrMemory( Vec_Str_t * p )
|
||||
{
|
||||
return !p ? 0.0 : 1.0 * sizeof(char) * p->nCap + sizeof(Vec_Str_t);
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
|
|||
|
|
@ -197,18 +197,6 @@ static inline void Vec_VecExpand( Vec_Vec_t * p, int Level )
|
|||
p->pArray[i] = Vec_PtrAlloc( 0 );
|
||||
p->nSize = Level + 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Allocates a vector with the given capacity.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline void Vec_VecExpandInt( Vec_Vec_t * p, int Level )
|
||||
{
|
||||
int i;
|
||||
|
|
@ -284,18 +272,6 @@ static inline Vec_Ptr_t * Vec_VecEntry( Vec_Vec_t * p, int i )
|
|||
assert( i >= 0 && i < p->nSize );
|
||||
return (Vec_Ptr_t *)p->pArray[i];
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline Vec_Int_t * Vec_VecEntryInt( Vec_Vec_t * p, int i )
|
||||
{
|
||||
assert( i >= 0 && i < p->nSize );
|
||||
|
|
@ -313,9 +289,27 @@ static inline Vec_Int_t * Vec_VecEntryInt( Vec_Vec_t * p, int i )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline void * Vec_VecEntryEntry( Vec_Vec_t * p, int i, int k )
|
||||
static inline double Vec_VecMemory( Vec_Vec_t * p )
|
||||
{
|
||||
return Vec_PtrEntry( Vec_VecEntry(p, i), k );
|
||||
int i;
|
||||
double Mem;
|
||||
if ( p == NULL ) return 0.0;
|
||||
Mem = Vec_PtrMemory( (Vec_Ptr_t *)p );
|
||||
for ( i = 0; i < p->nSize; i++ )
|
||||
if ( Vec_VecEntry(p, i) )
|
||||
Mem += Vec_PtrMemory( Vec_VecEntry(p, i) );
|
||||
return Mem;
|
||||
}
|
||||
static inline double Vec_VecMemoryInt( Vec_Vec_t * p )
|
||||
{
|
||||
int i;
|
||||
double Mem;
|
||||
if ( p == NULL ) return 0.0;
|
||||
Mem = Vec_PtrMemory( (Vec_Ptr_t *)p );
|
||||
for ( i = 0; i < p->nSize; i++ )
|
||||
if ( Vec_VecEntry(p, i) )
|
||||
Mem += Vec_IntMemory( Vec_VecEntryInt(p, i) );
|
||||
return Mem;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
|
@ -329,6 +323,10 @@ static inline void * Vec_VecEntryEntry( Vec_Vec_t * p, int i, int k )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline void * Vec_VecEntryEntry( Vec_Vec_t * p, int i, int k )
|
||||
{
|
||||
return Vec_PtrEntry( Vec_VecEntry(p, i), k );
|
||||
}
|
||||
static inline int Vec_VecEntryEntryInt( Vec_Vec_t * p, int i, int k )
|
||||
{
|
||||
return Vec_IntEntry( Vec_VecEntryInt(p, i), k );
|
||||
|
|
@ -393,18 +391,6 @@ static inline Vec_Vec_t * Vec_VecDup( Vec_Vec_t * p )
|
|||
Vec_PtrPush( vNew, Vec_PtrDup(vVec) );
|
||||
return (Vec_Vec_t *)vNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Frees the vector.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline Vec_Vec_t * Vec_VecDupInt( Vec_Vec_t * p )
|
||||
{
|
||||
Vec_Ptr_t * vNew;
|
||||
|
|
@ -478,18 +464,6 @@ static inline void Vec_VecPush( Vec_Vec_t * p, int Level, void * Entry )
|
|||
}
|
||||
Vec_PtrPush( Vec_VecEntry(p, Level), Entry );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline void Vec_VecPushInt( Vec_Vec_t * p, int Level, int Entry )
|
||||
{
|
||||
if ( p->nSize < Level + 1 )
|
||||
|
|
@ -521,18 +495,6 @@ static inline void Vec_VecPushUnique( Vec_Vec_t * p, int Level, void * Entry )
|
|||
else
|
||||
Vec_PtrPushUnique( Vec_VecEntry(p, Level), Entry );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline void Vec_VecPushUniqueInt( Vec_Vec_t * p, int Level, int Entry )
|
||||
{
|
||||
if ( p->nSize < Level + 1 )
|
||||
|
|
@ -560,18 +522,6 @@ static int Vec_VecSortCompare1( Vec_Ptr_t ** pp1, Vec_Ptr_t ** pp2 )
|
|||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Comparison procedure for two integers.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static int Vec_VecSortCompare2( Vec_Ptr_t ** pp1, Vec_Ptr_t ** pp2 )
|
||||
{
|
||||
if ( Vec_PtrSize(*pp1) > Vec_PtrSize(*pp2) )
|
||||
|
|
@ -621,18 +571,6 @@ static int Vec_VecSortCompare3( Vec_Int_t ** pp1, Vec_Int_t ** pp2 )
|
|||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Comparison procedure for two integers.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static int Vec_VecSortCompare4( Vec_Int_t ** pp1, Vec_Int_t ** pp2 )
|
||||
{
|
||||
if ( Vec_IntEntry(*pp1,0) > Vec_IntEntry(*pp2,0) )
|
||||
|
|
@ -689,38 +627,6 @@ static inline void Vec_VecPrintInt( Vec_Vec_t * p, int fSkipSingles )
|
|||
}
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Returns memory, in bytes, used by the vector.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline double Vec_VecMemory( Vec_Vec_t * p )
|
||||
{
|
||||
int i;
|
||||
Vec_Ptr_t * vVec;
|
||||
double Mem = sizeof(Vec_Vec_t);
|
||||
Mem += Vec_VecCap(p) * sizeof(void *);
|
||||
Vec_VecForEachLevel( p, vVec, i )
|
||||
Mem += sizeof(Vec_Ptr_t) + Vec_PtrCap(vVec) * sizeof(void *);
|
||||
return Mem;
|
||||
}
|
||||
static inline double Vec_VecMemoryInt( Vec_Vec_t * p )
|
||||
{
|
||||
int i;
|
||||
Vec_Int_t * vVec;
|
||||
double Mem = sizeof(Vec_Vec_t);
|
||||
Mem += Vec_VecCap(p) * sizeof(void *);
|
||||
Vec_VecForEachLevelInt( p, vVec, i )
|
||||
Mem += sizeof(Vec_Int_t) + Vec_IntCap(vVec) * sizeof(int);
|
||||
return Mem;
|
||||
}
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -350,6 +350,22 @@ static inline int Vec_WrdCap( Vec_Wrd_t * p )
|
|||
return p->nCap;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline double Vec_WrdMemory( Vec_Wrd_t * p )
|
||||
{
|
||||
return !p ? 0.0 : 1.0 * sizeof(word) * p->nCap + sizeof(Vec_Wrd_t);
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
|
|||
Loading…
Reference in New Issue