21#ifndef ABC__aig__mem__mem2_h
22#define ABC__aig__mem__mem2_h
83static inline Mmr_Flex_t * Mmr_FlexStart(
int nPageBase )
87 p->nPageBase = nPageBase;
88 p->PageMask = (1 << nPageBase) - 1;
89 p->iNext = (1 << nPageBase);
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) );
107 assert( h > 0 && h < p->iNext );
108 return (
word *)Vec_PtrEntry(&
p->vPages, (h >>
p->nPageBase)) + (h &
p->PageMask);
114 if (
p->iNext +
nWords >=
p->PageMask )
119 hEntry = ((Vec_PtrSize(&
p->vPages) - 1) <<
p->nPageBase) |
p->iNext;
122 p->nEntriesMax = Abc_MaxInt(
p->nEntriesMax,
p->nEntries );
125static inline void Mmr_FlexRelease(
Mmr_Flex_t *
p,
int h )
127 assert( h > 0 && h < p->iNext );
128 if ( (h >>
p->nPageBase) && Vec_PtrEntry(&
p->vPages, (h >>
p->nPageBase) - 1) )
130 word * pPage = (
word *)Vec_PtrEntry(&
p->vPages, (h >>
p->nPageBase) - 1);
131 Vec_PtrWriteEntry( &
p->vPages, (h >>
p->nPageBase) - 1, NULL );
148static inline void Mmr_FixedCreate(
Mmr_Fixed_t *
p,
int nPageBase,
int nEntryWords )
150 assert( nEntryWords > 0 && nEntryWords < (1 << nPageBase) );
151 p->nPageBase = nPageBase;
152 p->PageMask = (1 << nPageBase) - 1;
153 p->nEntryWords = nEntryWords;
155static inline Mmr_Fixed_t * Mmr_FixedStart(
int nPageBase,
int nEntryWords )
158 Mmr_FixedCreate(
p, nPageBase, nEntryWords );
161static inline void Mmr_FixedStop(
Mmr_Fixed_t *
p,
int fFreeLast )
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) );
178 assert( h > 0 && h < (Vec_PtrSize(&
p->vPages) <<
p->nPageBase) );
179 return (
word *)Vec_PtrEntry(&
p->vPages, (h >>
p->nPageBase)) + (h &
p->PageMask);
183 if ( Vec_IntSize(&
p->vFrees) == 0 )
185 int i, hEntry = Vec_PtrSize(&
p->vPages) <<
p->nPageBase;
187 for ( i = 1; i +
p->nEntryWords <=
p->PageMask; i +=
p->nEntryWords )
188 Vec_IntPush( &
p->vFrees, hEntry | i );
189 Vec_IntReverseOrder( &
p->vFrees );
192 p->nEntriesMax = Abc_MaxInt(
p->nEntriesMax,
p->nEntries );
193 return Vec_IntPop( &
p->vFrees );
195static inline void Mmr_FixedRecycle(
Mmr_Fixed_t *
p,
int h )
198 memset( Mmr_FixedEntry(
p, h), 0xFF,
sizeof(
word) *
p->nEntryWords );
199 Vec_IntPush( &
p->vFrees, h );
203 return Vec_PtrSize(&
p->vPages) * (
p->PageMask + 1);
218static inline Mmr_Step_t * Mmr_StepStart(
int nPageBase,
int nWordBase )
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 );
232 for ( i = 0; i <=
p->uMask; i++ )
233 Mmr_FixedStop(
p->pMems + i, 0 );
239 return Mmr_FixedEntry(
p->pMems + (h &
p->uMask), (h >>
p->nBits) );
246 p->nEntriesMax = Abc_MaxInt(
p->nEntriesMax,
p->nEntries );
249static inline void Mmr_StepRecycle(
Mmr_Step_t *
p,
int h )
252 Mmr_FixedRecycle(
p->pMems + (h &
p->uMask), (h >>
p->nBits) );
257 for ( i = 1; i <=
p->uMask; i++ )
258 Mem += Mmr_FixedMemory(
p->pMems + i );
#define ABC_FALLOC(type, num)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
unsigned __int64 word
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Mmr_Flex_t_ Mmr_Flex_t
DECLARATIONS ///.
struct Mmr_Step_t_ Mmr_Step_t
struct Mmr_Fixed_t_ Mmr_Fixed_t
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.