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
d350b1a8
Commit
d350b1a8
authored
Nov 16, 2020
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experiments with MFFC computation.
parent
ecafca53
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
42 deletions
+108
-42
src/aig/gia/giaMf.c
+108
-42
No files found.
src/aig/gia/giaMf.c
View file @
d350b1a8
...
...
@@ -1548,68 +1548,97 @@ void Mf_ManComputeCuts( Mf_Man_t * p )
SeeAlso []
***********************************************************************/
int
Mf_CutRef
2_rec
(
Mf_Man_t
*
p
,
int
*
pCut
,
Vec_Int_t
*
vTemp
,
int
Limi
t
)
int
Mf_CutRef
_rec
(
Mf_Man_t
*
p
,
int
*
pCu
t
)
{
int
i
,
Count
=
Mf_CutArea
(
p
,
Mf_CutSize
(
pCut
),
Mf_CutFunc
(
pCut
));
if
(
Limit
==
0
)
return
Count
;
for
(
i
=
1
;
i
<=
Mf_CutSize
(
pCut
);
i
++
)
{
Vec_IntPush
(
vTemp
,
pCut
[
i
]
);
if
(
!
Mf_ObjMapRefInc
(
p
,
pCut
[
i
])
&&
Mf_ManObj
(
p
,
pCut
[
i
])
->
iCutSet
)
Count
+=
Mf_CutRef2_rec
(
p
,
Mf_ObjCutBest
(
p
,
pCut
[
i
]),
vTemp
,
Limit
-
1
);
}
Count
+=
Mf_CutRef_rec
(
p
,
Mf_ObjCutBest
(
p
,
pCut
[
i
])
);
return
Count
;
}
static
inline
int
Mf_CutAreaDerefed2
(
Mf_Man_t
*
p
,
int
*
pCut
)
int
Mf_CutDeref_rec
(
Mf_Man_t
*
p
,
int
*
pCut
)
{
int
Ela1
,
iObj
,
i
;
Vec_IntClear
(
&
p
->
vTemp
);
Ela1
=
Mf_CutRef2_rec
(
p
,
pCut
,
&
p
->
vTemp
,
8
);
Vec_IntForEachEntry
(
&
p
->
vTemp
,
iObj
,
i
)
Mf_ObjMapRefDec
(
p
,
iObj
);
int
i
,
Count
=
Mf_CutArea
(
p
,
Mf_CutSize
(
pCut
),
Mf_CutFunc
(
pCut
));
for
(
i
=
1
;
i
<=
Mf_CutSize
(
pCut
);
i
++
)
if
(
!
Mf_ObjMapRefDec
(
p
,
pCut
[
i
])
&&
Mf_ManObj
(
p
,
pCut
[
i
])
->
iCutSet
)
Count
+=
Mf_CutDeref_rec
(
p
,
Mf_ObjCutBest
(
p
,
pCut
[
i
])
);
return
Count
;
}
static
inline
int
Mf_CutAreaRefed
(
Mf_Man_t
*
p
,
int
*
pCut
)
{
int
Ela1
=
Mf_CutDeref_rec
(
p
,
pCut
);
int
Ela2
=
Mf_CutRef_rec
(
p
,
pCut
);
assert
(
Ela1
==
Ela2
);
return
Ela1
;
}
static
inline
int
Mf_CutAreaDerefed
2Multi
(
Mf_Man_t
*
p
,
int
**
ppCuts
,
int
nCuts
)
static
inline
int
Mf_CutAreaDerefed
(
Mf_Man_t
*
p
,
int
*
pCut
)
{
int
Ela1
=
0
,
iObj
,
i
;
Vec_IntClear
(
&
p
->
vTemp
);
for
(
i
=
0
;
i
<
nCuts
;
i
++
)
Ela1
+=
Mf_CutRef2_rec
(
p
,
ppCuts
[
i
],
&
p
->
vTemp
,
ABC_INFINITY
);
Vec_IntForEachEntry
(
&
p
->
vTemp
,
iObj
,
i
)
Mf_ObjMapRefDec
(
p
,
iObj
);
int
Ela1
=
Mf_CutRef_rec
(
p
,
pCut
);
int
Ela2
=
Mf_CutDeref_rec
(
p
,
pCut
);
assert
(
Ela1
==
Ela2
);
return
Ela1
;
}
static
inline
int
Mf_CutAreaMffc
(
Mf_Man_t
*
p
,
int
iObj
)
{
return
Mf_ObjMapRefNum
(
p
,
iObj
)
?
Mf_CutAreaRefed
(
p
,
Mf_ObjCutBest
(
p
,
iObj
))
:
Mf_CutAreaDerefed
(
p
,
Mf_ObjCutBest
(
p
,
iObj
));
}
int
Mf_CutRef
_rec
(
Mf_Man_t
*
p
,
int
*
pCu
t
)
int
Mf_CutRef
2_rec
(
Mf_Man_t
*
p
,
int
*
pCut
,
Vec_Int_t
*
vTemp
,
int
Limi
t
)
{
int
i
,
Count
=
Mf_CutArea
(
p
,
Mf_CutSize
(
pCut
),
Mf_CutFunc
(
pCut
));
if
(
Limit
==
0
)
return
Count
;
for
(
i
=
1
;
i
<=
Mf_CutSize
(
pCut
);
i
++
)
{
Vec_IntPush
(
vTemp
,
pCut
[
i
]
);
if
(
!
Mf_ObjMapRefInc
(
p
,
pCut
[
i
])
&&
Mf_ManObj
(
p
,
pCut
[
i
])
->
iCutSet
)
Count
+=
Mf_CutRef_rec
(
p
,
Mf_ObjCutBest
(
p
,
pCut
[
i
])
);
Count
+=
Mf_CutRef2_rec
(
p
,
Mf_ObjCutBest
(
p
,
pCut
[
i
]),
vTemp
,
Limit
-
1
);
}
return
Count
;
}
int
Mf_CutDeref
_rec
(
Mf_Man_t
*
p
,
int
*
pCu
t
)
int
Mf_CutDeref
2_rec
(
Mf_Man_t
*
p
,
int
*
pCut
,
Vec_Int_t
*
vTemp
,
int
Limi
t
)
{
int
i
,
Count
=
Mf_CutArea
(
p
,
Mf_CutSize
(
pCut
),
Mf_CutFunc
(
pCut
));
if
(
Limit
==
0
)
return
Count
;
for
(
i
=
1
;
i
<=
Mf_CutSize
(
pCut
);
i
++
)
{
Vec_IntPush
(
vTemp
,
pCut
[
i
]
);
if
(
!
Mf_ObjMapRefDec
(
p
,
pCut
[
i
])
&&
Mf_ManObj
(
p
,
pCut
[
i
])
->
iCutSet
)
Count
+=
Mf_CutDeref_rec
(
p
,
Mf_ObjCutBest
(
p
,
pCut
[
i
])
);
Count
+=
Mf_CutDeref2_rec
(
p
,
Mf_ObjCutBest
(
p
,
pCut
[
i
]),
vTemp
,
Limit
-
1
);
}
return
Count
;
}
static
inline
int
Mf_CutAreaRefed
(
Mf_Man_t
*
p
,
int
*
pCut
)
static
inline
int
Mf_CutAreaRefed
2
(
Mf_Man_t
*
p
,
int
*
pCut
)
{
int
Ela1
=
Mf_CutDeref_rec
(
p
,
pCut
);
int
Ela2
=
Mf_CutRef_rec
(
p
,
pCut
);
assert
(
Ela1
==
Ela2
);
int
Ela1
,
iObj
,
i
;
Vec_IntClear
(
&
p
->
vTemp
);
Ela1
=
Mf_CutDeref2_rec
(
p
,
pCut
,
&
p
->
vTemp
,
8
);
Vec_IntForEachEntry
(
&
p
->
vTemp
,
iObj
,
i
)
Mf_ObjMapRefInc
(
p
,
iObj
);
return
Ela1
;
}
static
inline
int
Mf_CutAreaDerefed
(
Mf_Man_t
*
p
,
int
*
pCut
)
static
inline
int
Mf_CutAreaDerefed
2
(
Mf_Man_t
*
p
,
int
*
pCut
)
{
int
Ela1
=
Mf_CutRef_rec
(
p
,
pCut
);
int
Ela2
=
Mf_CutDeref_rec
(
p
,
pCut
);
assert
(
Ela1
==
Ela2
);
int
Ela1
,
iObj
,
i
;
Vec_IntClear
(
&
p
->
vTemp
);
Ela1
=
Mf_CutRef2_rec
(
p
,
pCut
,
&
p
->
vTemp
,
8
);
Vec_IntForEachEntry
(
&
p
->
vTemp
,
iObj
,
i
)
Mf_ObjMapRefDec
(
p
,
iObj
);
return
Ela1
;
}
static
inline
int
Mf_CutAreaRefed2Multi
(
Mf_Man_t
*
p
,
int
iObj
,
int
**
ppCuts
,
int
nCuts
)
{
int
Ela1
=
0
,
iTemp
,
i
;
Vec_IntClear
(
&
p
->
vTemp
);
for
(
i
=
0
;
i
<
nCuts
;
i
++
)
Ela1
+=
Mf_CutDeref2_rec
(
p
,
ppCuts
[
i
],
&
p
->
vTemp
,
ABC_INFINITY
);
assert
(
Mf_ObjMapRefNum
(
p
,
iObj
)
==
0
);
Vec_IntForEachEntry
(
&
p
->
vTemp
,
iTemp
,
i
)
Mf_ObjMapRefInc
(
p
,
iTemp
);
return
Ela1
;
}
static
inline
float
Mf_CutFlow
(
Mf_Man_t
*
p
,
int
*
pCut
,
int
*
pTime
)
{
Mf_Obj_t
*
pObj
;
...
...
@@ -1668,6 +1697,41 @@ static inline void Mf_ObjComputeBestCut( Mf_Man_t * p, int iObj )
SeeAlso []
***********************************************************************/
int
Mf_ManMappingFromMapping
(
Mf_Man_t
*
p
)
{
Gia_Man_t
*
pGia
=
p
->
pGia0
;
Gia_Obj_t
*
pObj
;
int
i
,
iObj
,
Count
=
0
;
Vec_Int_t
*
vMapping
=
Vec_IntAlloc
(
3
*
Gia_ManObjNum
(
pGia
)
);
Vec_IntFill
(
vMapping
,
Gia_ManObjNum
(
pGia
),
0
);
Gia_ManForEachAnd
(
pGia
,
pObj
,
iObj
)
if
(
Mf_ObjMapRefNum
(
p
,
iObj
)
)
{
int
*
pCut
=
Mf_ObjCutBest
(
p
,
iObj
);
Vec_IntWriteEntry
(
vMapping
,
iObj
,
Vec_IntSize
(
vMapping
)
);
Vec_IntPush
(
vMapping
,
Mf_CutSize
(
pCut
)
);
for
(
i
=
1
;
i
<=
Mf_CutSize
(
pCut
);
i
++
)
Vec_IntPush
(
vMapping
,
pCut
[
i
]
);
Vec_IntPush
(
vMapping
,
iObj
);
Count
++
;
}
assert
(
pGia
->
vMapping
==
NULL
);
pGia
->
vMapping
=
vMapping
;
printf
(
"Mapping is %.2fx larger than AIG manager.
\n
"
,
1
.
0
*
Vec_IntSize
(
vMapping
)
/
Gia_ManObjNum
(
pGia
)
);
return
Count
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void
Mf_ManPrintFanoutProfile
(
Mf_Man_t
*
p
,
Vec_Int_t
*
vFanCounts
)
{
Gia_Man_t
*
pGia
=
p
->
pGia0
;
...
...
@@ -1685,11 +1749,9 @@ void Mf_ManPrintFanoutProfile( Mf_Man_t * p, Vec_Int_t * vFanCounts )
int
Mf_ManPrintMfccStats
(
Mf_Man_t
*
p
,
int
iObj
)
{
Gia_Man_t
*
pGia
=
p
->
pGia0
;
int
Area
=
Mf_ObjMapRefNum
(
p
,
iObj
)
>
0
?
Mf_CutAreaRefed
(
p
,
Mf_ObjCutBest
(
p
,
iObj
))
:
Mf_CutAreaDerefed
(
p
,
Mf_ObjCutBest
(
p
,
iObj
));
int
Area
;
printf
(
"%5d : Level = %5d Refs = %5d Mffc = %5d
\n
"
,
iObj
,
Gia_ObjLevelId
(
pGia
,
iObj
),
Mf_ObjMapRefNum
(
p
,
iObj
),
Area
);
iObj
,
Gia_ObjLevelId
(
pGia
,
iObj
),
Mf_ObjMapRefNum
(
p
,
iObj
),
(
Area
=
Mf_CutAreaMffc
(
p
,
iObj
))
);
return
Area
;
}
void
Mf_ManOptimizationOne
(
Mf_Man_t
*
p
,
int
iObj
)
...
...
@@ -1697,10 +1759,14 @@ void Mf_ManOptimizationOne( Mf_Man_t * p, int iObj )
Gia_Man_t
*
pGia
=
p
->
pGia0
;
int
*
ppCuts
[
32
],
nCuts
=
0
;
int
iFanout
,
i
,
nAreaSum
=
0
,
nAreaBest
=
0
;
// skip pivots whose MFFC fanouts are
not used in the mapping or
pointed to by COs
// skip pivots whose MFFC fanouts are pointed to by COs
Gia_ObjForEachFanoutStaticId
(
pGia
,
iObj
,
iFanout
,
i
)
if
(
Mf_ObjMapRefNum
(
p
,
iFanout
)
==
0
||
Gia_ObjIsCo
(
Gia_ManObj
(
pGia
,
iFanout
))
)
if
(
Gia_ObjIsCo
(
Gia_ManObj
(
pGia
,
iFanout
))
)
return
;
// the pivot is used in the mapping as well as all of its fanouts
assert
(
Mf_ObjMapRefNum
(
p
,
iObj
)
>
1
);
Gia_ObjForEachFanoutStaticId
(
pGia
,
iObj
,
iFanout
,
i
)
assert
(
Mf_ObjMapRefNum
(
p
,
iFanout
)
>
0
);
// print this pivot and its fanouts
printf
(
"
\n
Pivot node = %d
\n
"
,
iObj
);
printf
(
"Pivot "
),
Mf_ManPrintMfccStats
(
p
,
iObj
);
...
...
@@ -1711,21 +1777,21 @@ void Mf_ManOptimizationOne( Mf_Man_t * p, int iObj )
Mf_ObjMapRefInc
(
p
,
iFanout
);
Gia_ObjForEachFanoutStaticId
(
pGia
,
iObj
,
iFanout
,
i
)
ppCuts
[
nCuts
++
]
=
Mf_ObjCutBest
(
p
,
iFanout
);
nAreaBest
=
Mf_CutArea
Derefed2Multi
(
p
,
ppCuts
,
nCuts
);
nAreaBest
=
Mf_CutArea
Refed2Multi
(
p
,
iObj
,
ppCuts
,
nCuts
);
Gia_ObjForEachFanoutStaticId
(
pGia
,
iObj
,
iFanout
,
i
)
Mf_ObjMapRefDec
(
p
,
iFanout
);
printf
(
"Sum of MFFC size = %d
\n
"
,
nAreaSum
);
printf
(
"Shared MFFC size = %d
\n
"
,
nAreaBest
);
printf
(
"Sum of MFFC size
s
= %d
\n
"
,
nAreaSum
);
printf
(
"Shared MFFC size
= %d
\n
"
,
nAreaBest
);
}
void
Mf_ManOptimization
(
Mf_Man_t
*
p
)
{
int
nOutMax
=
3
;
Gia_Man_t
*
pGia
=
p
->
pGia0
;
int
i
,
Count
,
nNodes
=
Gia_NodeMffcMapping
(
pGia
);
int
i
,
Count
,
nNodes
=
Mf_ManMappingFromMapping
(
p
);
Gia_ManLevelNum
(
pGia
);
Gia_ManStaticMappingFanoutStart
(
pGia
);
Mf_ManPrintFanoutProfile
(
p
,
pGia
->
vFanoutNums
);
printf
(
"
\n
Individual logic cones
:
\n
"
);
printf
(
"
\n
Individual logic cones
for mapping with %d nodes:
\n
"
,
nNodes
);
Vec_IntForEachEntry
(
pGia
->
vFanoutNums
,
Count
,
i
)
if
(
Count
>=
2
&&
Count
<=
nOutMax
&&
Gia_ObjIsAnd
(
Gia_ManObj
(
pGia
,
i
))
)
Mf_ManOptimizationOne
(
p
,
i
);
...
...
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