abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mem2.h File Reference
#include "misc/vec/vec.h"

Go to the source code of this file.

Data Structures

struct  Mmr_Flex_t_
 
struct  Mmr_Fixed_t_
 
struct  Mmr_Step_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Mmr_Flex_t_ 
Mmr_Flex_t
 DECLARATIONS ///. More...
 
typedef struct Mmr_Fixed_t_ Mmr_Fixed_t
 
typedef struct Mmr_Step_t_ Mmr_Step_t
 

Functions

static Mmr_Flex_tMmr_FlexStart (int nPageBase)
 FUNCTION DEFINITIONS ///. More...
 
static void Mmr_FlexStop (Mmr_Flex_t *p)
 
static wordMmr_FlexEntry (Mmr_Flex_t *p, int h)
 
static int Mmr_FlexFetch (Mmr_Flex_t *p, int nWords)
 
static void Mmr_FlexRelease (Mmr_Flex_t *p, int h)
 
static void Mmr_FixedCreate (Mmr_Fixed_t *p, int nPageBase, int nEntryWords)
 
static Mmr_Fixed_tMmr_FixedStart (int nPageBase, int nEntryWords)
 
static void Mmr_FixedStop (Mmr_Fixed_t *p, int fFreeLast)
 
static wordMmr_FixedEntry (Mmr_Fixed_t *p, int h)
 
static int Mmr_FixedFetch (Mmr_Fixed_t *p)
 
static void Mmr_FixedRecycle (Mmr_Fixed_t *p, int h)
 
static int Mmr_FixedMemory (Mmr_Fixed_t *p)
 
static Mmr_Step_tMmr_StepStart (int nPageBase, int nWordBase)
 
static void Mmr_StepStop (Mmr_Step_t *p)
 
static wordMmr_StepEntry (Mmr_Step_t *p, int h)
 
static int Mmr_StepFetch (Mmr_Step_t *p, int nWords)
 
static void Mmr_StepRecycle (Mmr_Step_t *p, int h)
 
static int Mmr_StepMemory (Mmr_Step_t *p)
 

Typedef Documentation

typedef struct Mmr_Fixed_t_ Mmr_Fixed_t

Definition at line 34 of file mem2.h.

typedef typedefABC_NAMESPACE_HEADER_START struct Mmr_Flex_t_ Mmr_Flex_t

DECLARATIONS ///.

CFile****************************************************************

FileName [mem2.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Memory management.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
mem2.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 33 of file mem2.h.

typedef struct Mmr_Step_t_ Mmr_Step_t

Definition at line 35 of file mem2.h.

Function Documentation

static void Mmr_FixedCreate ( Mmr_Fixed_t p,
int  nPageBase,
int  nEntryWords 
)
inlinestatic

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 148 of file mem2.h.

149 {
150  assert( nEntryWords > 0 && nEntryWords < (1 << nPageBase) );
151  p->nPageBase = nPageBase;
152  p->PageMask = (1 << nPageBase) - 1;
153  p->nEntryWords = nEntryWords;
154 }
int nPageBase
Definition: mem2.h:49
int nEntryWords
Definition: mem2.h:51
#define assert(ex)
Definition: util_old.h:213
int PageMask
Definition: mem2.h:50
static word* Mmr_FixedEntry ( Mmr_Fixed_t p,
int  h 
)
inlinestatic

Definition at line 176 of file mem2.h.

177 {
178  assert( h > 0 && h < (Vec_PtrSize(&p->vPages) << p->nPageBase) );
179  return (word *)Vec_PtrEntry(&p->vPages, (h >> p->nPageBase)) + (h & p->PageMask);
180 }
int nPageBase
Definition: mem2.h:49
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define assert(ex)
Definition: util_old.h:213
Vec_Ptr_t vPages
Definition: mem2.h:54
int PageMask
Definition: mem2.h:50
static int Mmr_FixedFetch ( Mmr_Fixed_t p)
inlinestatic

Definition at line 181 of file mem2.h.

182 {
183  if ( Vec_IntSize(&p->vFrees) == 0 )
184  {
185  int i, hEntry = Vec_PtrSize(&p->vPages) << p->nPageBase;
186  Vec_PtrPush( &p->vPages, ABC_FALLOC( word, p->PageMask + 1 ) );
187  for ( i = 1; i + p->nEntryWords <= p->PageMask; i += p->nEntryWords )
188  Vec_IntPush( &p->vFrees, hEntry | i );
190  }
191  p->nEntries++;
193  return Vec_IntPop( &p->vFrees );
194 }
int nPageBase
Definition: mem2.h:49
int nEntriesMax
Definition: mem2.h:53
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_IntReverseOrder(Vec_Int_t *p)
Definition: vecInt.h:1042
Vec_Int_t vFrees
Definition: mem2.h:55
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static int Vec_IntPop(Vec_Int_t *p)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int nEntryWords
Definition: mem2.h:51
Vec_Ptr_t vPages
Definition: mem2.h:54
int PageMask
Definition: mem2.h:50
int nEntries
Definition: mem2.h:52
#define ABC_FALLOC(type, num)
Definition: abc_global.h:231
static int Mmr_FixedMemory ( Mmr_Fixed_t p)
inlinestatic

Definition at line 201 of file mem2.h.

202 {
203  return Vec_PtrSize(&p->vPages) * (p->PageMask + 1);
204 }
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Vec_Ptr_t vPages
Definition: mem2.h:54
int PageMask
Definition: mem2.h:50
static void Mmr_FixedRecycle ( Mmr_Fixed_t p,
int  h 
)
inlinestatic

Definition at line 195 of file mem2.h.

196 {
197  p->nEntries--;
198  memset( Mmr_FixedEntry(p, h), 0xFF, sizeof(word) * p->nEntryWords );
199  Vec_IntPush( &p->vFrees, h );
200 }
char * memset()
static word * Mmr_FixedEntry(Mmr_Fixed_t *p, int h)
Definition: mem2.h:176
Vec_Int_t vFrees
Definition: mem2.h:55
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
int nEntryWords
Definition: mem2.h:51
int nEntries
Definition: mem2.h:52
static Mmr_Fixed_t* Mmr_FixedStart ( int  nPageBase,
int  nEntryWords 
)
inlinestatic

Definition at line 155 of file mem2.h.

156 {
158  Mmr_FixedCreate( p, nPageBase, nEntryWords );
159  return p;
160 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Mmr_FixedCreate(Mmr_Fixed_t *p, int nPageBase, int nEntryWords)
Definition: mem2.h:148
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static void Mmr_FixedStop ( Mmr_Fixed_t p,
int  fFreeLast 
)
inlinestatic

Definition at line 161 of file mem2.h.

162 {
163  word * pPage;
164  int i;
165  if ( 0 && Vec_PtrSize(&p->vPages) )
166  printf( "Using %3d pages of %6d words each with %6d entries (max = %6d) of size %d. Total memory = %5.2f MB.\n",
167  Vec_PtrSize(&p->vPages), p->nPageBase ? 1 << p->nPageBase : 0, p->nEntries, p->nEntriesMax, p->nEntryWords,
168  1.0 * Vec_PtrSize(&p->vPages) * (1 << p->nPageBase) * 8 / (1 << 20) );
169  Vec_PtrForEachEntry( word *, &p->vPages, pPage, i )
170  ABC_FREE( pPage );
171  ABC_FREE( p->vPages.pArray );
172  ABC_FREE( p->vFrees.pArray );
173  if ( fFreeLast )
174  ABC_FREE( p );
175 }
int nPageBase
Definition: mem2.h:49
int nEntriesMax
Definition: mem2.h:53
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
if(last==0)
Definition: sparse_int.h:34
#define ABC_FREE(obj)
Definition: abc_global.h:232
int nEntryWords
Definition: mem2.h:51
Vec_Ptr_t vPages
Definition: mem2.h:54
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int nEntries
Definition: mem2.h:52
static word* Mmr_FlexEntry ( Mmr_Flex_t p,
int  h 
)
inlinestatic

Definition at line 105 of file mem2.h.

106 {
107  assert( h > 0 && h < p->iNext );
108  return (word *)Vec_PtrEntry(&p->vPages, (h >> p->nPageBase)) + (h & p->PageMask);
109 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define assert(ex)
Definition: util_old.h:213
static int Mmr_FlexFetch ( Mmr_Flex_t p,
int  nWords 
)
inlinestatic

Definition at line 110 of file mem2.h.

111 {
112  int hEntry;
113  assert( nWords > 0 && nWords < p->PageMask );
114  if ( p->iNext + nWords >= p->PageMask )
115  {
116  Vec_PtrPush( &p->vPages, ABC_FALLOC( word, p->PageMask + 1 ) );
117  p->iNext = 1;
118  }
119  hEntry = ((Vec_PtrSize(&p->vPages) - 1) << p->nPageBase) | p->iNext;
120  p->iNext += nWords;
121  p->nEntries++;
122  p->nEntriesMax = Abc_MaxInt( p->nEntriesMax, p->nEntries );
123  return hEntry;
124 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int nWords
Definition: abcNpn.c:127
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define assert(ex)
Definition: util_old.h:213
#define ABC_FALLOC(type, num)
Definition: abc_global.h:231
static void Mmr_FlexRelease ( Mmr_Flex_t p,
int  h 
)
inlinestatic

Definition at line 125 of file mem2.h.

126 {
127  assert( h > 0 && h < p->iNext );
128  if ( (h >> p->nPageBase) && Vec_PtrEntry(&p->vPages, (h >> p->nPageBase) - 1) )
129  {
130  word * pPage = (word *)Vec_PtrEntry(&p->vPages, (h >> p->nPageBase) - 1);
131  Vec_PtrWriteEntry( &p->vPages, (h >> p->nPageBase) - 1, NULL );
132  ABC_FREE( pPage );
133  }
134 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
static Mmr_Flex_t* Mmr_FlexStart ( int  nPageBase)
inlinestatic

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file mem2.h.

84 {
85  Mmr_Flex_t * p;
86  p = ABC_CALLOC( Mmr_Flex_t, 1 );
87  p->nPageBase = nPageBase;
88  p->PageMask = (1 << nPageBase) - 1;
89  p->iNext = (1 << nPageBase);
90  return p;
91 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_HEADER_START struct Mmr_Flex_t_ Mmr_Flex_t
DECLARATIONS ///.
Definition: mem2.h:33
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static void Mmr_FlexStop ( Mmr_Flex_t p)
inlinestatic

Definition at line 92 of file mem2.h.

93 {
94  word * pPage;
95  int i;
96  if ( 0 && Vec_PtrSize(&p->vPages) )
97  printf( "Using %3d pages of %6d words each with %6d entries (max = %6d). Total memory = %5.2f MB.\n",
98  Vec_PtrSize(&p->vPages), p->nPageBase ? 1 << p->nPageBase : 0, p->nEntries, p->nEntriesMax,
99  1.0 * Vec_PtrSize(&p->vPages) * (1 << p->nPageBase) * 8 / (1 << 20) );
100  Vec_PtrForEachEntry( word *, &p->vPages, pPage, i )
101  ABC_FREE( pPage );
102  ABC_FREE( p->vPages.pArray );
103  ABC_FREE( p );
104 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static word* Mmr_StepEntry ( Mmr_Step_t p,
int  h 
)
inlinestatic

Definition at line 236 of file mem2.h.

237 {
238  assert( (h & p->uMask) > 0 );
239  return Mmr_FixedEntry( p->pMems + (h & p->uMask), (h >> p->nBits) );
240 }
static word * Mmr_FixedEntry(Mmr_Fixed_t *p, int h)
Definition: mem2.h:176
Mmr_Fixed_t pMems[0]
Definition: mem2.h:65
int nBits
Definition: mem2.h:60
#define assert(ex)
Definition: util_old.h:213
int uMask
Definition: mem2.h:61
static int Mmr_StepFetch ( Mmr_Step_t p,
int  nWords 
)
inlinestatic

Definition at line 241 of file mem2.h.

242 {
243  assert( nWords > 0 && nWords <= p->uMask );
244  p->nEntries++;
245  p->nEntriesAll++;
247  return (Mmr_FixedFetch(p->pMems + nWords) << p->nBits) | nWords;
248 }
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
int nWords
Definition: abcNpn.c:127
int nEntries
Definition: mem2.h:62
Mmr_Fixed_t pMems[0]
Definition: mem2.h:65
static int Mmr_FixedFetch(Mmr_Fixed_t *p)
Definition: mem2.h:181
int nBits
Definition: mem2.h:60
#define assert(ex)
Definition: util_old.h:213
int nEntriesAll
Definition: mem2.h:64
int nEntriesMax
Definition: mem2.h:63
static int Mmr_StepMemory ( Mmr_Step_t p)
inlinestatic

Definition at line 254 of file mem2.h.

255 {
256  int i, Mem = 0;
257  for ( i = 1; i <= p->uMask; i++ )
258  Mem += Mmr_FixedMemory( p->pMems + i );
259  return Mem;
260 }
Mmr_Fixed_t pMems[0]
Definition: mem2.h:65
static int Mmr_FixedMemory(Mmr_Fixed_t *p)
Definition: mem2.h:201
int uMask
Definition: mem2.h:61
static void Mmr_StepRecycle ( Mmr_Step_t p,
int  h 
)
inlinestatic

Definition at line 249 of file mem2.h.

250 {
251  p->nEntries--;
252  Mmr_FixedRecycle( p->pMems + (h & p->uMask), (h >> p->nBits) );
253 }
int nEntries
Definition: mem2.h:62
Mmr_Fixed_t pMems[0]
Definition: mem2.h:65
int nBits
Definition: mem2.h:60
static void Mmr_FixedRecycle(Mmr_Fixed_t *p, int h)
Definition: mem2.h:195
int uMask
Definition: mem2.h:61
static Mmr_Step_t* Mmr_StepStart ( int  nPageBase,
int  nWordBase 
)
inlinestatic

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 218 of file mem2.h.

219 {
220  char * pMemory = ABC_CALLOC( char, sizeof(Mmr_Step_t) + sizeof(Mmr_Fixed_t) * (1 << nWordBase) );
221  Mmr_Step_t * p = (Mmr_Step_t *)pMemory;
222  int i;
223  p->nBits = nWordBase;
224  p->uMask = (1 << nWordBase) - 1;
225  for ( i = 1; i <= p->uMask; i++ )
226  Mmr_FixedCreate( p->pMems + i, nPageBase, i );
227  return p;
228 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Mmr_FixedCreate(Mmr_Fixed_t *p, int nPageBase, int nEntryWords)
Definition: mem2.h:148
Mmr_Fixed_t pMems[0]
Definition: mem2.h:65
int nBits
Definition: mem2.h:60
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
int uMask
Definition: mem2.h:61
static void Mmr_StepStop ( Mmr_Step_t p)
inlinestatic

Definition at line 229 of file mem2.h.

230 {
231  int i;
232  for ( i = 0; i <= p->uMask; i++ )
233  Mmr_FixedStop( p->pMems + i, 0 );
234  ABC_FREE( p );
235 }
static void Mmr_FixedStop(Mmr_Fixed_t *p, int fFreeLast)
Definition: mem2.h:161
Mmr_Fixed_t pMems[0]
Definition: mem2.h:65
#define ABC_FREE(obj)
Definition: abc_global.h:232
int uMask
Definition: mem2.h:61