Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
6df122bd
Commit
6df122bd
authored
Jul 20, 2012
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated code for lazy man's synthesis (memory optimization).
parent
6c9b59bf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
300 additions
and
6 deletions
+300
-6
abclib.dsp
+4
-0
src/aig/gia/giaHash.c
+1
-1
src/aig/gia/giaMan.c
+5
-5
src/base/abci/abcRec2.c
+0
-0
src/misc/vec/vecMem.h
+290
-0
No files found.
abclib.dsp
View file @
6df122bd
...
...
@@ -2539,6 +2539,10 @@ SOURCE=.\src\misc\vec\vecInt.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\vec\vecMem.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\vec\vecPtr.h
# End Source File
# Begin Source File
...
...
src/aig/gia/giaHash.c
View file @
6df122bd
...
...
@@ -109,7 +109,7 @@ int Gia_ManHashLookup( Gia_Man_t * p, Gia_Obj_t * p0, Gia_Obj_t * p1 )
void
Gia_ManHashAlloc
(
Gia_Man_t
*
p
)
{
assert
(
p
->
pHTable
==
NULL
);
p
->
nHTable
=
Abc_PrimeCudd
(
p
->
nObjsAlloc
);
p
->
nHTable
=
Abc_PrimeCudd
(
Gia_ManAndNum
(
p
)
?
Gia_ManAndNum
(
p
)
+
1000
:
p
->
nObjsAlloc
);
p
->
pHTable
=
ABC_CALLOC
(
int
,
p
->
nHTable
);
}
...
...
src/aig/gia/giaMan.c
View file @
6df122bd
...
...
@@ -52,8 +52,8 @@ Gia_Man_t * Gia_ManStart( int nObjsMax )
p
->
pObjs
=
ABC_CALLOC
(
Gia_Obj_t
,
nObjsMax
);
p
->
pObjs
->
iDiff0
=
p
->
pObjs
->
iDiff1
=
GIA_NONE
;
p
->
nObjs
=
1
;
p
->
vCis
=
Vec_IntAlloc
(
nObjsMax
/
1
0
);
p
->
vCos
=
Vec_IntAlloc
(
nObjsMax
/
1
0
);
p
->
vCis
=
Vec_IntAlloc
(
nObjsMax
/
2
0
);
p
->
vCos
=
Vec_IntAlloc
(
nObjsMax
/
2
0
);
return
p
;
}
...
...
@@ -414,10 +414,10 @@ void Gia_ManPrintStats( Gia_Man_t * p, int fTents, int fSwitch )
if
(
Gia_ManRegNum
(
p
)
)
printf
(
" ff =%7d"
,
Gia_ManRegNum
(
p
)
);
printf
(
" and =%8d"
,
Gia_ManAndNum
(
p
)
);
printf
(
" lev =%5d"
,
Gia_ManLevelNum
(
p
)
);
printf
(
" lev =%5d"
,
Gia_ManLevelNum
(
p
)
);
Vec_IntFreeP
(
&
p
->
vLevels
);
printf
(
" cut =%5d"
,
Gia_ManCrossCut
(
p
)
);
printf
(
" mem =%5.2f MB"
,
1
.
0
*
(
sizeof
(
Gia_Obj_t
)
*
p
->
nObjs
+
sizeof
(
int
)
*
(
Vec_IntSize
(
p
->
vCis
)
+
Vec_IntSize
(
p
->
vCos
)))
/
(
1
<<
20
)
);
//
printf( " mem =%5.2f MB", 1.0*(sizeof(Gia_Obj_t)*p->nObjsAlloc + sizeof(int)*(Vec_IntCap(p->vCis) + Vec_IntCap(p->vCos)))/(1<<20) );
//
printf( " mem =%5.2f MB", 1.0*(sizeof(Gia_Obj_t)*p->nObjs + sizeof(int)*(Vec_IntSize(p->vCis) + Vec_IntSize(p->vCos)))/(1<<20) );
printf
(
" mem =%5.2f MB"
,
1
.
0
*
(
sizeof
(
Gia_Obj_t
)
*
p
->
nObjsAlloc
+
sizeof
(
int
)
*
(
Vec_IntCap
(
p
->
vCis
)
+
Vec_IntCap
(
p
->
vCos
)))
/
(
1
<<
20
)
);
if
(
Gia_ManHasDangling
(
p
)
)
printf
(
" ch =%5d"
,
Gia_ManEquivCountClasses
(
p
)
);
if
(
fSwitch
)
...
...
src/base/abci/abcRec2.c
View file @
6df122bd
This diff is collapsed.
Click to expand it.
src/misc/vec/vecMem.h
0 → 100644
View file @
6df122bd
/**CFile****************************************************************
FileName [vecMem.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Resizable arrays.]
Synopsis [Resizable array of memory pieces.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - July 20, 2012.]
Revision [$Id: vecMem.h,v 1.00 2012/07/20 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef ABC__misc__vec__vecMem_h
#define ABC__misc__vec__vecMem_h
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
ABC_NAMESPACE_HEADER_START
/*
This vector stores pieces of memory of the given size.
It is useful for representing truth tables and any other objects
of the fixed size. It is better that Extra_MmFixed because the
entry IDs can be used as handles to retrieve memory pieces without
the need for an array of pointers from entry IDs into memory pieces
(this can save 8(4) bytes per object on a 64(32)-bit platform).
*/
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
typedef
struct
Vec_Mem_t_
Vec_Mem_t
;
struct
Vec_Mem_t_
{
int
nEntrySize
;
// entry size (in terms of 8-byte words)
int
nEntries
;
// number of entries currently used
int
LogPageSze
;
// log2 of page size (in terms of entries)
int
PageMask
;
// page mask
int
nPageAlloc
;
// number of pages currently allocated
int
iPage
;
// the number of a page currently used
word
**
ppPages
;
// memory pages
};
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
#define Vec_MemForEachEntry( vVec, pEntry, i ) \
for ( i = 0; (i < Vec_MemEntryNum(vVec)) && ((pEntry) = Vec_MemReadEntry(vVec, i)); i++ )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Allocates a memory vector.]
Description [Entry size is in terms of 8-byte words. Page size is log2
of the number of entries on one page.]
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
Vec_Mem_t
*
Vec_MemAlloc
(
int
nEntrySize
,
int
LogPageSze
)
{
Vec_Mem_t
*
p
;
p
=
ABC_CALLOC
(
Vec_Mem_t
,
1
);
p
->
nEntrySize
=
nEntrySize
;
p
->
LogPageSze
=
LogPageSze
;
p
->
PageMask
=
(
1
<<
p
->
LogPageSze
)
-
1
;
p
->
iPage
=
-
1
;
return
p
;
}
static
inline
void
Vec_MemFree
(
Vec_Mem_t
*
p
)
{
int
i
;
for
(
i
=
0
;
i
<=
p
->
iPage
;
i
++
)
ABC_FREE
(
p
->
ppPages
[
i
]
);
ABC_FREE
(
p
->
ppPages
);
ABC_FREE
(
p
);
}
static
inline
void
Vec_MemFreeP
(
Vec_Mem_t
**
p
)
{
if
(
*
p
==
NULL
)
return
;
Vec_MemFree
(
*
p
);
*
p
=
NULL
;
}
static
inline
Vec_Mem_t
*
Vec_MemDup
(
Vec_Mem_t
*
pVec
)
{
Vec_Mem_t
*
p
=
NULL
;
return
p
;
}
/**Function*************************************************************
Synopsis [Duplicates the integer array.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
void
Vec_MemFill
(
Vec_Mem_t
*
pVec
,
int
nEntries
)
{
}
static
inline
void
Vec_MemClean
(
Vec_Mem_t
*
pVec
,
int
nEntries
)
{
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
int
Vec_MemEntrySize
(
Vec_Mem_t
*
p
)
{
return
p
->
nEntrySize
;
}
static
inline
int
Vec_MemEntryNum
(
Vec_Mem_t
*
p
)
{
return
p
->
nEntries
;
}
static
inline
int
Vec_MemPageSize
(
Vec_Mem_t
*
p
)
{
return
p
->
LogPageSze
;
}
static
inline
int
Vec_MemPageNum
(
Vec_Mem_t
*
p
)
{
return
p
->
iPage
+
1
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
double
Vec_MemMemory
(
Vec_Mem_t
*
p
)
{
return
(
double
)
sizeof
(
word
)
*
p
->
nEntrySize
*
(
1
<<
p
->
LogPageSze
)
*
(
p
->
iPage
+
1
)
+
(
double
)
sizeof
(
word
*
)
*
p
->
nPageAlloc
+
(
double
)
sizeof
(
Vec_Mem_t
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
word
*
Vec_MemReadEntry
(
Vec_Mem_t
*
p
,
int
i
)
{
assert
(
i
>=
0
&&
i
<
p
->
nEntries
);
return
p
->
ppPages
[
i
>>
p
->
LogPageSze
]
+
p
->
nEntrySize
*
(
i
&
p
->
PageMask
);
}
static
inline
word
*
Vec_MemReadEntryLast
(
Vec_Mem_t
*
p
)
{
assert
(
p
->
nEntries
>
0
);
return
Vec_MemReadEntry
(
p
,
p
->
nEntries
-
1
);
}
static
inline
void
Vec_MemWriteEntry
(
Vec_Mem_t
*
p
,
int
i
,
word
*
pEntry
)
{
word
*
pPlace
=
Vec_MemReadEntry
(
p
,
i
);
memmove
(
pPlace
,
pEntry
,
sizeof
(
word
)
*
p
->
nEntrySize
);
}
static
inline
word
*
Vec_MemGetEntry
(
Vec_Mem_t
*
p
,
int
i
)
{
assert
(
i
>=
0
);
if
(
i
>=
p
->
nEntries
)
{
int
k
,
iPageNew
=
(
i
>>
p
->
LogPageSze
);
if
(
p
->
iPage
<
iPageNew
)
{
// realloc page pointers if needed
if
(
iPageNew
>=
p
->
nPageAlloc
)
p
->
ppPages
=
ABC_REALLOC
(
word
*
,
p
->
ppPages
,
(
p
->
nPageAlloc
=
p
->
nPageAlloc
?
2
*
p
->
nPageAlloc
:
iPageNew
+
32
)
);
// allocate new pages if needed
for
(
k
=
p
->
iPage
+
1
;
k
<=
iPageNew
;
k
++
)
p
->
ppPages
[
k
]
=
ABC_ALLOC
(
word
,
p
->
nEntrySize
*
(
1
<<
p
->
LogPageSze
)
);
// update page counter
p
->
iPage
=
iPageNew
;
}
// update entry counter
p
->
nEntries
=
i
+
1
;
}
return
Vec_MemReadEntry
(
p
,
i
);
}
static
inline
void
Vec_MemSetEntry
(
Vec_Mem_t
*
p
,
int
i
,
word
*
pEntry
)
{
word
*
pPlace
=
Vec_MemGetEntry
(
p
,
i
);
memmove
(
pPlace
,
pEntry
,
sizeof
(
word
)
*
p
->
nEntrySize
);
}
static
inline
void
Vec_MemPush
(
Vec_Mem_t
*
p
,
word
*
pEntry
)
{
word
*
pPlace
=
Vec_MemGetEntry
(
p
,
p
->
nEntries
);
memmove
(
pPlace
,
pEntry
,
sizeof
(
word
)
*
p
->
nEntrySize
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
void
Vec_MemShrink
(
Vec_Mem_t
*
p
,
int
nEntriesNew
)
{
int
i
,
iPageOld
=
p
->
iPage
;
assert
(
nEntriesNew
<=
p
->
nEntries
);
p
->
nEntries
=
nEntriesNew
;
p
->
iPage
=
(
nEntriesNew
>>
p
->
LogPageSze
);
for
(
i
=
p
->
iPage
+
1
;
i
<=
iPageOld
;
i
++
)
ABC_FREE
(
p
->
ppPages
[
i
]
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
void
Vec_MemPrint
(
Vec_Mem_t
*
vVec
)
{
word
*
pEntry
;
int
i
;
printf
(
"Memory vector has %d entries: "
,
Vec_MemEntryNum
(
vVec
)
);
Vec_MemForEachEntry
(
vVec
,
pEntry
,
i
)
{
printf
(
"%3d : "
,
i
);
// add printout here
printf
(
"
\n
"
);
}
}
ABC_NAMESPACE_HEADER_END
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment