From 735a831e13684334d55b422993a80d94d356f180 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 22 Jun 2012 10:30:22 -0700 Subject: Added memory reporting to &vta. --- src/misc/util/abc_global.h | 14 ++++++++------ src/misc/vec/vecBit.h | 16 ++++++++++++++++ src/misc/vec/vecFlt.h | 16 ++++++++++++++++ src/misc/vec/vecPtr.h | 16 ++++++++++++++++ src/misc/vec/vecSet.h | 4 ++-- src/misc/vec/vecStr.h | 16 ++++++++++++++++ src/misc/vec/vecVec.h | 47 ++++++++++++++++++++++++++++++++++++++++++++++ src/misc/vec/vecWrd.h | 16 ++++++++++++++++ 8 files changed, 137 insertions(+), 8 deletions(-) (limited to 'src/misc') diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h index 5f0e1232..9524c505 100644 --- a/src/misc/util/abc_global.h +++ b/src/misc/util/abc_global.h @@ -205,12 +205,14 @@ typedef ABC_UINT64_T word; #define ABC_SWAP(Type, a, b) { Type t = a; a = b; b = t; } -#define ABC_PRT(a,t) (Abc_Print(1, "%s = ", (a)), Abc_Print(1, "%7.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))) -#define ABC_PRTr(a,t) (Abc_Print(1, "%s = ", (a)), Abc_Print(1, "%7.2f sec\r", (float)(t)/(float)(CLOCKS_PER_SEC))) -#define ABC_PRTn(a,t) (Abc_Print(1, "%s = ", (a)), Abc_Print(1, "%6.2f sec ", (float)(t)/(float)(CLOCKS_PER_SEC))) -#define ABC_PRTP(a,t,T) (Abc_Print(1, "%s = ", (a)), Abc_Print(1, "%7.2f sec (%6.2f %%)\n", (float)(t)/(float)(CLOCKS_PER_SEC), (T)? 100.0*(t)/(T) : 0.0)) -#define ABC_PRM(a,f) (Abc_Print(1, "%s = ", (a)), Abc_Print(1, "%7.3f Mb ", 1.0*(f)/(1<<20))) -#define ABC_PRMP(a,f,F) (Abc_Print(1, "%s = ", (a)), Abc_Print(1, "%7.3f Mb (%6.2f %%) ", (1.0*(f)/(1<<20)), ((F)? 100.0*(f)/(F) : 0.0) ) ) +#define ABC_PRT(a,t) (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%9.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))) +#define ABC_PRTr(a,t) (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%9.2f sec\r", (float)(t)/(float)(CLOCKS_PER_SEC))) +#define ABC_PRTn(a,t) (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%9.2f sec ", (float)(t)/(float)(CLOCKS_PER_SEC))) +#define ABC_PRTP(a,t,T) (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%9.2f sec (%6.2f %%)\n", (float)(t)/(float)(CLOCKS_PER_SEC), (T)? 100.0*(t)/(T) : 0.0)) +#define ABC_PRM(a,f) (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%10.3f Mb\n", 1.0*(f)/(1<<20))) +#define ABC_PRMr(a,f) (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%10.3f Mb\r", 1.0*(f)/(1<<20))) +#define ABC_PRMn(a,f) (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%10.3f Mb ", 1.0*(f)/(1<<20))) +#define ABC_PRMP(a,f,F) (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%10.3f Mb (%6.2f %%)\n", (1.0*(f)/(1<<20)), ((F)? 100.0*(f)/(F) : 0.0) ) ) #define ABC_ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) #define ABC_CALLOC(type, num) ((type *) calloc((num), sizeof(type))) diff --git a/src/misc/vec/vecBit.h b/src/misc/vec/vecBit.h index 7f0d7409..4024d0ee 100644 --- a/src/misc/vec/vecBit.h +++ b/src/misc/vec/vecBit.h @@ -241,6 +241,22 @@ static inline int Vec_BitSize( Vec_Bit_t * p ) return p->nSize; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_BitCap( Vec_Bit_t * p ) +{ + return p->nCap; +} + /**Function************************************************************* Synopsis [] diff --git a/src/misc/vec/vecFlt.h b/src/misc/vec/vecFlt.h index 0ad6da27..19423ae0 100644 --- a/src/misc/vec/vecFlt.h +++ b/src/misc/vec/vecFlt.h @@ -284,6 +284,22 @@ static inline int Vec_FltSize( Vec_Flt_t * p ) return p->nSize; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_FltCap( Vec_Flt_t * p ) +{ + return p->nCap; +} + /**Function************************************************************* Synopsis [] diff --git a/src/misc/vec/vecPtr.h b/src/misc/vec/vecPtr.h index afad09d1..1d60ec50 100644 --- a/src/misc/vec/vecPtr.h +++ b/src/misc/vec/vecPtr.h @@ -287,6 +287,22 @@ static inline int Vec_PtrSize( Vec_Ptr_t * p ) return p->nSize; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_PtrCap( Vec_Ptr_t * p ) +{ + return p->nCap; +} + /**Function************************************************************* Synopsis [] diff --git a/src/misc/vec/vecSet.h b/src/misc/vec/vecSet.h index df2a9a68..72358ea1 100644 --- a/src/misc/vec/vecSet.h +++ b/src/misc/vec/vecSet.h @@ -189,9 +189,9 @@ static inline void Vec_SetFree( Vec_Set_t * p ) SeeAlso [] ***********************************************************************/ -static inline int Vec_ReportMemory( Vec_Set_t * p ) +static inline double Vec_ReportMemory( Vec_Set_t * p ) { - int Mem = sizeof(Vec_Set_t); + double Mem = sizeof(Vec_Set_t); Mem += p->nPagesAlloc * sizeof(void *); Mem += sizeof(word) * (1 << p->nPageSize) * (1 + p->iPage); return Mem; diff --git a/src/misc/vec/vecStr.h b/src/misc/vec/vecStr.h index c794dc2f..cefa0ea9 100644 --- a/src/misc/vec/vecStr.h +++ b/src/misc/vec/vecStr.h @@ -278,6 +278,22 @@ static inline int Vec_StrSize( Vec_Str_t * p ) return p->nSize; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_StrCap( Vec_Str_t * p ) +{ + return p->nCap; +} + /**Function************************************************************* Synopsis [] diff --git a/src/misc/vec/vecVec.h b/src/misc/vec/vecVec.h index 8bed4574..6d309dc4 100644 --- a/src/misc/vec/vecVec.h +++ b/src/misc/vec/vecVec.h @@ -236,6 +236,22 @@ static inline int Vec_VecSize( Vec_Vec_t * p ) return p->nSize; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_VecCap( Vec_Vec_t * p ) +{ + return p->nCap; +} + /**Function************************************************************* Synopsis [] @@ -673,6 +689,37 @@ 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 diff --git a/src/misc/vec/vecWrd.h b/src/misc/vec/vecWrd.h index 11414ff7..97296401 100644 --- a/src/misc/vec/vecWrd.h +++ b/src/misc/vec/vecWrd.h @@ -334,6 +334,22 @@ static inline int Vec_WrdSize( Vec_Wrd_t * p ) return p->nSize; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_WrdCap( Vec_Wrd_t * p ) +{ + return p->nCap; +} + /**Function************************************************************* Synopsis [] -- cgit v1.2.3