summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2012-07-29 12:34:32 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2012-07-29 12:34:32 -0700
commit8a2d237f788d7650694efa5dead2cb09a75010ee (patch)
tree00cdf97aba108cda41a5fec10cd0275042356ac2
parente8d690f2a4c9abde54bb248a97c0c619b187f238 (diff)
downloadabc-8a2d237f788d7650694efa5dead2cb09a75010ee.tar.gz
abc-8a2d237f788d7650694efa5dead2cb09a75010ee.tar.bz2
abc-8a2d237f788d7650694efa5dead2cb09a75010ee.zip
Adding memory reporting to vectors.
-rw-r--r--src/misc/vec/vecBit.h16
-rw-r--r--src/misc/vec/vecFlt.h16
-rw-r--r--src/misc/vec/vecInt.h16
-rw-r--r--src/misc/vec/vecPtr.h16
-rw-r--r--src/misc/vec/vecStr.h16
-rw-r--r--src/misc/vec/vecVec.h142
-rw-r--r--src/misc/vec/vecWrd.h16
7 files changed, 120 insertions, 118 deletions
diff --git a/src/misc/vec/vecBit.h b/src/misc/vec/vecBit.h
index 4024d0ee..2c0c65e5 100644
--- a/src/misc/vec/vecBit.h
+++ b/src/misc/vec/vecBit.h
@@ -268,6 +268,22 @@ static inline int Vec_BitCap( Vec_Bit_t * p )
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 []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
static inline int Vec_BitEntry( Vec_Bit_t * p, int i )
{
assert( i >= 0 && i < p->nSize );
diff --git a/src/misc/vec/vecFlt.h b/src/misc/vec/vecFlt.h
index 19423ae0..873139f7 100644
--- a/src/misc/vec/vecFlt.h
+++ b/src/misc/vec/vecFlt.h
@@ -311,6 +311,22 @@ static inline int Vec_FltCap( Vec_Flt_t * p )
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 []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
static inline float Vec_FltEntry( Vec_Flt_t * p, int i )
{
assert( i >= 0 && i < p->nSize );
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h
index a9d7e92d..84d53e46 100644
--- a/src/misc/vec/vecInt.h
+++ b/src/misc/vec/vecInt.h
@@ -383,6 +383,22 @@ static inline int Vec_IntCap( Vec_Int_t * p )
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 []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
static inline int Vec_IntEntry( Vec_Int_t * p, int i )
{
assert( i >= 0 && i < p->nSize );
diff --git a/src/misc/vec/vecPtr.h b/src/misc/vec/vecPtr.h
index 1d60ec50..8285ef58 100644
--- a/src/misc/vec/vecPtr.h
+++ b/src/misc/vec/vecPtr.h
@@ -314,6 +314,22 @@ static inline int Vec_PtrCap( Vec_Ptr_t * p )
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 []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
static inline int Vec_PtrCountZero( Vec_Ptr_t * p )
{
int i, Counter = 0;
diff --git a/src/misc/vec/vecStr.h b/src/misc/vec/vecStr.h
index cc57b2de..d795a89f 100644
--- a/src/misc/vec/vecStr.h
+++ b/src/misc/vec/vecStr.h
@@ -305,6 +305,22 @@ static inline int Vec_StrCap( Vec_Str_t * p )
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 []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
static inline char Vec_StrEntry( Vec_Str_t * p, int i )
{
assert( i >= 0 && i < p->nSize );
diff --git a/src/misc/vec/vecVec.h b/src/misc/vec/vecVec.h
index 6d309dc4..d935be0f 100644
--- a/src/misc/vec/vecVec.h
+++ b/src/misc/vec/vecVec.h
@@ -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
diff --git a/src/misc/vec/vecWrd.h b/src/misc/vec/vecWrd.h
index 97296401..86985266 100644
--- a/src/misc/vec/vecWrd.h
+++ b/src/misc/vec/vecWrd.h
@@ -361,6 +361,22 @@ static inline int Vec_WrdCap( Vec_Wrd_t * p )
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 []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
static inline word Vec_WrdEntry( Vec_Wrd_t * p, int i )
{
assert( i >= 0 && i < p->nSize );