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
0c6f196e
Commit
0c6f196e
authored
Jun 19, 2014
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experiments with MUX profiling.
parent
9842a666
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
189 additions
and
18 deletions
+189
-18
src/aig/gia/giaMuxes.c
+141
-16
src/misc/vec/vecPtr.h
+25
-0
src/misc/vec/vecStr.h
+23
-2
No files found.
src/aig/gia/giaMuxes.c
View file @
0c6f196e
...
@@ -297,18 +297,30 @@ int Gia_MuxMffcSize( Gia_Man_t * p, int iObj )
...
@@ -297,18 +297,30 @@ int Gia_MuxMffcSize( Gia_Man_t * p, int iObj )
void
Gia_MuxStructPrint_rec
(
Gia_Man_t
*
p
,
int
iObj
,
int
fFirst
)
void
Gia_MuxStructPrint_rec
(
Gia_Man_t
*
p
,
int
iObj
,
int
fFirst
)
{
{
Gia_Obj_t
*
pObj
=
Gia_ManObj
(
p
,
iObj
);
Gia_Obj_t
*
pObj
=
Gia_ManObj
(
p
,
iObj
);
int
iCtrl
;
if
(
!
fFirst
&&
(
!
Gia_ObjIsMuxId
(
p
,
iObj
)
||
Gia_ObjRefNumId
(
p
,
iObj
)
>
0
)
)
if
(
!
fFirst
&&
(
!
Gia_ObjIsMuxId
(
p
,
iObj
)
||
Gia_ObjRefNumId
(
p
,
iObj
)
>
0
)
)
return
;
return
;
printf
(
" [(%s"
,
Gia_ObjFaninC2
(
p
,
pObj
)
?
"!"
:
""
);
iCtrl
=
Gia_ObjFaninId2p
(
p
,
pObj
);
if
(
!
Gia_ObjIsMuxId
(
p
,
Gia_ObjFaninId2p
(
p
,
pObj
))
)
printf
(
" [("
);
printf
(
"%d"
,
Gia_ObjFaninId2p
(
p
,
pObj
)
);
if
(
Gia_ObjIsMuxId
(
p
,
iCtrl
)
&&
Gia_ObjRefNumId
(
p
,
iCtrl
)
==
0
)
Gia_MuxStructPrint_rec
(
p
,
iCtrl
,
0
);
else
else
Gia_MuxStructPrint_rec
(
p
,
Gia_ObjFaninId2p
(
p
,
pObj
),
0
);
printf
(
"%d"
,
iCtrl
);
printf
(
")"
);
printf
(
")"
);
Gia_MuxStructPrint_rec
(
p
,
Gia_ObjFaninId0p
(
p
,
pObj
),
0
);
if
(
Gia_ObjFaninC2
(
p
,
pObj
)
)
printf
(
"|"
);
{
Gia_MuxStructPrint_rec
(
p
,
Gia_ObjFaninId1p
(
p
,
pObj
),
0
);
Gia_MuxStructPrint_rec
(
p
,
Gia_ObjFaninId0p
(
p
,
pObj
),
0
);
printf
(
"] "
);
printf
(
"|"
);
Gia_MuxStructPrint_rec
(
p
,
Gia_ObjFaninId1p
(
p
,
pObj
),
0
);
printf
(
"] "
);
}
else
{
Gia_MuxStructPrint_rec
(
p
,
Gia_ObjFaninId1p
(
p
,
pObj
),
0
);
printf
(
"|"
);
Gia_MuxStructPrint_rec
(
p
,
Gia_ObjFaninId0p
(
p
,
pObj
),
0
);
printf
(
"] "
);
}
}
}
void
Gia_MuxStructPrint
(
Gia_Man_t
*
p
,
int
iObj
)
void
Gia_MuxStructPrint
(
Gia_Man_t
*
p
,
int
iObj
)
{
{
...
@@ -332,21 +344,106 @@ void Gia_MuxStructPrint( Gia_Man_t * p, int iObj )
...
@@ -332,21 +344,106 @@ void Gia_MuxStructPrint( Gia_Man_t * p, int iObj )
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
void
Gia_MuxStructDump_rec
(
Gia_Man_t
*
p
,
int
iObj
,
int
fFirst
,
Vec_Str_t
*
vStr
,
int
nDigitsId
)
{
Gia_Obj_t
*
pObj
=
Gia_ManObj
(
p
,
iObj
);
int
iCtrl
;
if
(
!
fFirst
&&
(
!
Gia_ObjIsMuxId
(
p
,
iObj
)
||
Gia_ObjRefNumId
(
p
,
iObj
)
>
0
)
)
return
;
iCtrl
=
Gia_ObjFaninId2p
(
p
,
pObj
);
Vec_StrPush
(
vStr
,
'['
);
Vec_StrPush
(
vStr
,
'('
);
if
(
Gia_ObjIsMuxId
(
p
,
iCtrl
)
&&
Gia_ObjRefNumId
(
p
,
iCtrl
)
==
0
)
Gia_MuxStructDump_rec
(
p
,
iCtrl
,
0
,
vStr
,
nDigitsId
);
else
Vec_StrPrintNumStar
(
vStr
,
iCtrl
,
nDigitsId
);
Vec_StrPush
(
vStr
,
')'
);
if
(
Gia_ObjFaninC2
(
p
,
pObj
)
)
{
Gia_MuxStructDump_rec
(
p
,
Gia_ObjFaninId0p
(
p
,
pObj
),
0
,
vStr
,
nDigitsId
);
Vec_StrPush
(
vStr
,
'|'
);
Gia_MuxStructDump_rec
(
p
,
Gia_ObjFaninId1p
(
p
,
pObj
),
0
,
vStr
,
nDigitsId
);
Vec_StrPush
(
vStr
,
']'
);
}
else
{
Gia_MuxStructDump_rec
(
p
,
Gia_ObjFaninId1p
(
p
,
pObj
),
0
,
vStr
,
nDigitsId
);
Vec_StrPush
(
vStr
,
'|'
);
Gia_MuxStructDump_rec
(
p
,
Gia_ObjFaninId0p
(
p
,
pObj
),
0
,
vStr
,
nDigitsId
);
Vec_StrPush
(
vStr
,
']'
);
}
}
void
Gia_MuxStructDump
(
Gia_Man_t
*
p
,
int
iObj
,
Vec_Str_t
*
vStr
,
int
Num
,
int
nDigitsNum
,
int
nDigitsId
)
{
int
Count1
,
Count2
;
assert
(
Gia_ObjIsMuxId
(
p
,
iObj
)
);
Count1
=
Gia_MuxDeref
(
p
,
iObj
);
Vec_StrClear
(
vStr
);
Vec_StrPrintNumStar
(
vStr
,
Num
,
nDigitsNum
);
Gia_MuxStructDump_rec
(
p
,
iObj
,
1
,
vStr
,
nDigitsId
);
Vec_StrPush
(
vStr
,
'\0'
);
Count2
=
Gia_MuxRef
(
p
,
iObj
);
assert
(
Count1
==
Count2
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Gia_ManMuxCompare
(
char
**
pp1
,
char
**
pp2
)
{
int
Diff
=
strcmp
(
*
pp1
,
*
pp2
);
if
(
Diff
<
0
)
return
1
;
if
(
Diff
>
0
)
return
-
1
;
return
0
;
}
int
Gia_ManMuxCountOne
(
char
*
p
)
{
int
Count
=
0
;
for
(
;
*
p
;
p
++
)
Count
+=
(
*
p
==
'['
);
return
Count
;
}
void
Gia_ManMuxProfile
(
Vec_Ptr_t
*
p
,
Vec_Int_t
*
vCounts
)
{
int
i
;
char
*
pTemp
;
Vec_IntFill
(
vCounts
,
1000
,
0
);
Vec_PtrForEachEntry
(
char
*
,
p
,
pTemp
,
i
)
Vec_IntAddToEntry
(
vCounts
,
Abc_MinInt
(
Gia_ManMuxCountOne
(
pTemp
),
999
),
1
);
}
void
Gia_ManMuxProfiling
(
Gia_Man_t
*
p
)
void
Gia_ManMuxProfiling
(
Gia_Man_t
*
p
)
{
{
Gia_Man_t
*
pNew
;
Gia_Man_t
*
pNew
;
Gia_Obj_t
*
pObj
;
Gia_Obj_t
*
pObj
;
Vec_Int_t
*
vFans
;
Vec_Int_t
*
vFans
;
Vec_Int_t
*
vCounts
;
Vec_Int_t
*
vCounts
=
Vec_IntAlloc
(
100
);
Vec_Ptr_t
*
vTrees
=
Vec_PtrAlloc
(
1000
);
Vec_Str_t
*
vStr
=
Vec_StrAlloc
(
1000
);
Vec_Int_t
*
vDegree
=
Vec_IntAlloc
(
1000
);
int
i
,
nRefs
,
Size
,
Count
,
Total
=
0
,
Roots
=
0
;
int
i
,
nRefs
,
Size
,
Count
,
Total
=
0
,
Roots
=
0
;
int
nDigitsId
,
nMemory
=
0
;
char
*
pTemp
;
abctime
clk
=
Abc_Clock
();
pNew
=
Gia_ManDupMuxes
(
p
,
2
);
pNew
=
Gia_ManDupMuxes
(
p
,
2
);
nDigitsId
=
Abc_Base10Log
(
Gia_ManObjNum
(
pNew
)
);
Gia_ManCreateRefs
(
pNew
);
Gia_ManCreateRefs
(
pNew
);
Gia_ManForEachCo
(
pNew
,
pObj
,
i
)
Gia_ManForEachCo
(
pNew
,
pObj
,
i
)
Gia_ObjRefFanin0Inc
(
pNew
,
pObj
);
Gia_ObjRefFanin0Inc
(
pNew
,
pObj
);
Vec_IntFill
(
vCounts
,
1000
,
0
);
vFans
=
Gia_ManFirstFanouts
(
pNew
);
vFans
=
Gia_ManFirstFanouts
(
pNew
);
vCounts
=
Vec_IntStart
(
100
);
Gia_ManForEachMux
(
pNew
,
pObj
,
i
)
Gia_ManForEachMux
(
pNew
,
pObj
,
i
)
{
{
Total
++
;
Total
++
;
...
@@ -356,22 +453,50 @@ void Gia_ManMuxProfiling( Gia_Man_t * p )
...
@@ -356,22 +453,50 @@ void Gia_ManMuxProfiling( Gia_Man_t * p )
{
{
Roots
++
;
Roots
++
;
Size
=
Gia_MuxMffcSize
(
pNew
,
i
);
Size
=
Gia_MuxMffcSize
(
pNew
,
i
);
Vec_IntAddToEntry
(
vCounts
,
Abc_MinInt
(
Size
,
99
),
1
);
Vec_IntAddToEntry
(
vCounts
,
Abc_MinInt
(
Size
,
999
),
1
);
if
(
Size
>=
2
)
if
(
Size
>
3
)
{
{
printf
(
"%d "
,
Size
);
Gia_MuxStructDump
(
pNew
,
i
,
vStr
,
Size
,
3
,
nDigitsId
);
Gia_MuxStructPrint
(
pNew
,
i
);
Vec_PtrPush
(
vTrees
,
Abc_UtilStrsav
(
Vec_StrArray
(
vStr
))
);
nMemory
+=
Vec_StrSize
(
vStr
);
}
}
}
}
}
}
printf
(
"MUXes: Total = %d. Roots = %d.
\n
"
,
Total
,
Roots
);
printf
(
"MUXes: Total = %d. Roots = %d. Trees = %d. Memory = %.2f MB
\n
"
,
Total
,
Roots
,
Vec_PtrSize
(
vTrees
),
1
.
0
*
nMemory
/
(
1
<<
20
)
);
Vec_IntForEachEntry
(
vCounts
,
Count
,
i
)
if
(
Count
)
printf
(
"%d=%d "
,
i
,
Count
);
printf
(
"
\n
"
);
// Vec_PtrForEachEntryStop( char *, vTrees, pTemp, i, Abc_MinInt(Vec_PtrSize(vTrees), 40) )
// printf( "%6d : %3d %3d %s\n", i, -1, Gia_ManMuxCountOne(pTemp), pTemp );
// uniqify
Vec_PtrUniqify2
(
vTrees
,
(
int
(
*
)(
void
))
Gia_ManMuxCompare
,
(
void
(
*
)(
void
))
free
,
vDegree
);
Gia_ManMuxProfile
(
vTrees
,
vCounts
);
nMemory
=
0
;
Vec_PtrForEachEntry
(
char
*
,
vTrees
,
pTemp
,
i
)
nMemory
+=
strlen
(
pTemp
);
printf
(
"MUXes: Trees = %d. Memory = %.2f MB
\n
"
,
Vec_PtrSize
(
vTrees
),
1
.
0
*
nMemory
/
(
1
<<
20
)
);
Vec_IntForEachEntry
(
vCounts
,
Count
,
i
)
Vec_IntForEachEntry
(
vCounts
,
Count
,
i
)
if
(
Count
)
if
(
Count
)
printf
(
"%d=%d "
,
i
,
Count
);
printf
(
"%d=%d "
,
i
,
Count
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
// Vec_PtrForEachEntryStop( char *, vTrees, pTemp, i, Abc_MinInt(Vec_PtrSize(vTrees), 40) )
// printf( "%6d : %3d %3d %s\n", i, Vec_IntEntry(vDegree, i), Gia_ManMuxCountOne(pTemp), pTemp );
Vec_PtrForEachEntryStop
(
char
*
,
vTrees
,
pTemp
,
i
,
Abc_MinInt
(
Vec_PtrSize
(
vTrees
),
5000
)
)
if
(
Vec_IntEntry
(
vDegree
,
i
)
>
10
)
printf
(
"%6d : %3d %3d %s
\n
"
,
i
,
Vec_IntEntry
(
vDegree
,
i
),
Gia_ManMuxCountOne
(
pTemp
),
pTemp
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
Vec_PtrFreeFree
(
vTrees
);
Vec_StrFree
(
vStr
);
Vec_IntFree
(
vDegree
);
Vec_IntFree
(
vCounts
);
Vec_IntFree
(
vCounts
);
Vec_IntFree
(
vFans
);
Vec_IntFree
(
vFans
);
Gia_ManStop
(
pNew
);
Gia_ManStop
(
pNew
);
...
...
src/misc/vec/vecPtr.h
View file @
0c6f196e
...
@@ -883,6 +883,31 @@ static void Vec_PtrUniqify( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)() )
...
@@ -883,6 +883,31 @@ static void Vec_PtrUniqify( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)() )
p
->
pArray
[
k
++
]
=
p
->
pArray
[
i
];
p
->
pArray
[
k
++
]
=
p
->
pArray
[
i
];
p
->
nSize
=
k
;
p
->
nSize
=
k
;
}
}
static
void
Vec_PtrUniqify2
(
Vec_Ptr_t
*
p
,
int
(
*
Vec_PtrSortCompare
)(),
void
(
*
Vec_PtrObjFree
)(),
Vec_Int_t
*
vCounts
)
{
int
i
,
k
;
if
(
vCounts
)
Vec_IntFill
(
vCounts
,
1
,
1
);
if
(
p
->
nSize
<
2
)
return
;
Vec_PtrSort
(
p
,
Vec_PtrSortCompare
);
for
(
i
=
k
=
1
;
i
<
p
->
nSize
;
i
++
)
if
(
Vec_PtrSortCompare
(
p
->
pArray
+
i
,
p
->
pArray
+
k
-
1
)
!=
0
)
{
p
->
pArray
[
k
++
]
=
p
->
pArray
[
i
];
if
(
vCounts
)
Vec_IntPush
(
vCounts
,
1
);
}
else
{
if
(
Vec_PtrObjFree
)
Vec_PtrObjFree
(
p
->
pArray
[
i
]
);
if
(
vCounts
)
Vec_IntAddToEntry
(
vCounts
,
Vec_IntSize
(
vCounts
)
-
1
,
1
);
}
p
->
nSize
=
k
;
assert
(
vCounts
==
NULL
||
Vec_IntSize
(
vCounts
)
==
Vec_PtrSize
(
p
)
);
}
...
...
src/misc/vec/vecStr.h
View file @
0c6f196e
...
@@ -575,9 +575,30 @@ static inline void Vec_StrPrintNum( Vec_Str_t * p, int Num )
...
@@ -575,9 +575,30 @@ static inline void Vec_StrPrintNum( Vec_Str_t * p, int Num )
Num
=
-
Num
;
Num
=
-
Num
;
}
}
for
(
i
=
0
;
Num
;
Num
/=
10
,
i
++
)
for
(
i
=
0
;
Num
;
Num
/=
10
,
i
++
)
Digits
[
i
]
=
(
char
)(
'0'
+
Num
%
10
)
;
Digits
[
i
]
=
Num
%
10
;
for
(
i
--
;
i
>=
0
;
i
--
)
for
(
i
--
;
i
>=
0
;
i
--
)
Vec_StrPush
(
p
,
Digits
[
i
]
);
Vec_StrPush
(
p
,
(
char
)(
'0'
+
Digits
[
i
])
);
}
static
inline
void
Vec_StrPrintNumStar
(
Vec_Str_t
*
p
,
int
Num
,
int
nDigits
)
{
int
i
;
char
Digits
[
16
]
=
{
0
};
if
(
Num
==
0
)
{
for
(
i
=
0
;
i
<
nDigits
;
i
++
)
Vec_StrPush
(
p
,
'0'
);
return
;
}
if
(
Num
<
0
)
{
Vec_StrPush
(
p
,
'-'
);
Num
=
-
Num
;
nDigits
--
;
}
for
(
i
=
0
;
Num
;
Num
/=
10
,
i
++
)
Digits
[
i
]
=
Num
%
10
;
for
(
i
=
Abc_MaxInt
(
i
,
nDigits
)
-
1
;
i
>=
0
;
i
--
)
Vec_StrPush
(
p
,
(
char
)(
'0'
+
Digits
[
i
])
);
}
}
/**Function*************************************************************
/**Function*************************************************************
...
...
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