Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BSD
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
SunMaple
BSD
Commits
879d8b82
Commit
879d8b82
authored
Mar 27, 2025
by
chengshuyao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
variable ordering
parent
345c3457
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
62 deletions
+62
-62
src/BSD.cpp
+29
-44
src/BSD.h
+10
-5
src/next_layer_bit.h
+22
-12
src/zstart.sh
+1
-1
No files found.
src/BSD.cpp
View file @
879d8b82
...
@@ -33,12 +33,20 @@ extern const int parameter_max_samples = 40000; //BSD每一个节点最多进
...
@@ -33,12 +33,20 @@ extern const int parameter_max_samples = 40000; //BSD每一个节点最多进
extern
const
int
parameter_max_BDD_width
=
10000
;
//BSD每一层最多多少个节点
extern
const
int
parameter_max_BDD_width
=
10000
;
//BSD每一层最多多少个节点
//全局变量
//全局变量
int
GLOBAL_which_demo_function
;
int
GLOBAL_BDD_id_number
;
int
GLOBAL_BDD_id_number
;
int
GLOBAL_BDD_nodes
;
int
GLOBAL_BDD_nodes
;
int
GLOBAL_BDD_split_nodes
;
int
GLOBAL_BDD_split_nodes
;
int
GLOBAL_train_time
;
int
GLOBAL_train_time
;
int
GLOBAL_program_time
;
int
GLOBAL_program_time
;
//待优化变量
int
variable_order
[
parameter_input_bit_width
];
int
variable_order_number
;
int
BSD_execute
(
int
variable_order_number
,
int
*
variable_order
);
#include"cvt.h"
#include"cvt.h"
#include"io_generator_function.h"
#include"io_generator_function.h"
#include"BSD.h"
#include"BSD.h"
...
@@ -46,63 +54,41 @@ int GLOBAL_program_time;
...
@@ -46,63 +54,41 @@ int GLOBAL_program_time;
#include"tool_function.h"
#include"tool_function.h"
#include"print_circuit.h"
#include"print_circuit.h"
int
main
(
int
argc
,
char
*
argv
[]){
int
main
(
int
argc
,
char
*
argv
[]){
omp_set_num_threads
(
parameter_num_threads
);
omp_set_num_threads
(
parameter_num_threads
);
GLOBAL_BDD_id_number
=
0
;
GLOBAL_BDD_id_number
=
0
;
GLOBAL_BDD_nodes
=
0
;
GLOBAL_BDD_nodes
=
0
;
GLOBAL_BDD_split_nodes
=
0
;
GLOBAL_BDD_split_nodes
=
0
;
int
i
,
j
;
int
which_demo_function
;
if
(
argc
>=
2
){
if
(
argc
>=
2
){
circuit_index
=
atoi
(
argv
[
1
]);
GLOBAL_which_demo_function
=
atoi
(
argv
[
1
]);
}
if
(
argc
>=
3
){
which_demo_function
=
atoi
(
argv
[
2
]);
}
else
{
which_demo_function
=
22
;
}
DIR
*
output_dir
;
output_dir
=
opendir
(
"rtl/"
);
dirent
*
ptr
;
vector
<
string
>
files
;
while
((
ptr
=
readdir
(
output_dir
))
!=
NULL
){
files
.
push_back
(
ptr
->
d_name
);
}
bool
this_bit_finished
=
0
;
for
(
i
=
0
;
i
<
files
.
size
();
i
++
){
if
(
files
[
i
].
substr
(
0
,
8
)
==
"function"
){
int
this_output_bit
=
0
;
for
(
j
=
0
;
j
<
10
;
j
++
){
//cout<<files[i].substr(18+j,1);
if
(
files
[
i
].
substr
(
18
+
j
+
1
,
1
)
==
"."
){
break
;
}
}
}
//cout<<atoi(files[i].substr(9,9+j).c_str());
/// if(argc>=3){
if
(
atoi
(
files
[
i
].
substr
(
9
,
9
+
j
).
c_str
())
==
circuit_index
){
/// which_demo_function = atoi(argv[2]);
this_bit_finished
=
1
;
/// }else{
cout
<<
"this bit finished: "
<<
circuit_index
<<
endl
;
/// which_demo_function = 22;
return
0
;
/// }
break
;
}
}
int
area
=
BSD_execute
(
0
,
variable_order
);
}
cout
<<
endl
;
closedir
(
output_dir
);
cout
<<
"Design Area = "
<<
area
<<
endl
;
};
int
BSD_execute
(
int
variable_order_number
,
int
*
variable_order
){
BDD_class
BDD_class_main
;
BDD_class
BDD_class_main
;
BDD_class_main
.
which_demo_function
=
GLOBAL_which_demo_function
;
BDD_class_main
.
BSD_variable_order_number
=
variable_order_number
;
for
(
int
i
=
0
;
i
<
variable_order_number
;
i
++
){
BDD_class_main
.
BSD_variable_order
[
i
]
=
variable_order
[
i
];
}
BDD_class_main
.
start_depth
=
0
;
BDD_class_main
.
start_depth
=
0
;
BDD_class_main
.
BDD_id
=
0
;
BDD_class_main
.
BDD_id
=
0
;
GLOBAL_BDD_id_number
+=
1
;
GLOBAL_BDD_id_number
+=
1
;
BDD_class_main
.
which_demo_function
=
which_demo_function
;
BDD_class_main
.
which_demo_function
=
22
;
BDD_class_main
.
how_many_start_nodes
=
parameter_output_bit_width
;
BDD_class_main
.
how_many_start_nodes
=
parameter_output_bit_width
;
BDD_class_main
.
start_nodes
=
new
BDD_node
[
BDD_class_main
.
how_many_start_nodes
];
BDD_class_main
.
start_nodes
=
new
BDD_node
[
BDD_class_main
.
how_many_start_nodes
];
for
(
int
zi
=
0
;
zi
<
BDD_class_main
.
how_many_start_nodes
;
zi
++
){
for
(
int
zi
=
0
;
zi
<
BDD_class_main
.
how_many_start_nodes
;
zi
++
){
...
@@ -116,7 +102,6 @@ int main(int argc,char* argv[]){
...
@@ -116,7 +102,6 @@ int main(int argc,char* argv[]){
BDD_class_main
.
BDD_width_each_layer
[
zi
]
=
0
;
BDD_class_main
.
BDD_width_each_layer
[
zi
]
=
0
;
}
}
BDD_class_main
.
BDD_FULL_PROCESS
();
BDD_class_main
.
BDD_FULL_PROCESS
();
return
BDD_class_main
.
total_split_nodes
;
};
};
src/BSD.h
View file @
879d8b82
...
@@ -75,9 +75,11 @@ public:
...
@@ -75,9 +75,11 @@ public:
bool
io_generator_single
(
bool
input_data
[
parameter_input_bit_width
],
int
which_bit_output
);
bool
io_generator_single
(
bool
input_data
[
parameter_input_bit_width
],
int
which_bit_output
);
int
set_random_input_data
(
bool
**
mask_input_data
);
int
set_random_input_data
(
bool
**
mask_input_data
);
int
mask_random_input_data
(
int
depth
,
bool
mask
[
parameter_input_bit_width
],
int
amount
,
int
*
most_influence
,
bool
**
mask_input_data
);
int
mask_random_input_data
(
int
depth
,
bool
mask
[
parameter_input_bit_width
],
int
amount
,
int
*
most_influence
,
bool
**
mask_input_data
);
int
next_bit_layer
(
int
depth
,
BDD_node
**
BDD
,
int
*
most_influence
);
int
next_bit_layer
(
int
depth
);
int
next_bit_layer_old
(
int
depth
,
BDD_node
**
BDD
,
int
*
most_influence
);
int
next_bit_layer_0
(
int
depth
);
int
next_bit_layer_single
(
int
depth
,
BDD_node
**
BDD
,
int
*
most_influence
,
int
which_node_this_layer
);
int
next_bit_layer_1
(
int
depth
);
int
next_bit_layer_old
(
int
depth
);
int
next_bit_layer_single
(
int
depth
,
int
which_node_this_layer
);
int
compare_simplify_list
(
int
list_line_amount
,
bool
*
this_line
,
bool
**
simplify_list
);
int
compare_simplify_list
(
int
list_line_amount
,
bool
*
this_line
,
bool
**
simplify_list
);
int
compare_simplify_list_neg
(
int
list_line_amount
,
bool
*
this_line
,
bool
**
simplify_list
);
int
compare_simplify_list_neg
(
int
list_line_amount
,
bool
*
this_line
,
bool
**
simplify_list
);
...
@@ -130,6 +132,9 @@ public:
...
@@ -130,6 +132,9 @@ public:
int
BSD_samples_train_each_layer
();
int
BSD_samples_train_each_layer
();
int
BSD_samples_sort_each_layer
();
int
BSD_samples_sort_each_layer
();
int
BSD_variable_order
[
parameter_input_bit_width
];
int
BSD_variable_order_number
;
BDD_class
(){
BDD_class
(){
most_influence
=
new
int
[
parameter_input_bit_width
];
most_influence
=
new
int
[
parameter_input_bit_width
];
BDD_width_each_layer
=
new
int
[
parameter_input_bit_width
+
1
];
BDD_width_each_layer
=
new
int
[
parameter_input_bit_width
+
1
];
...
@@ -176,7 +181,7 @@ int BDD_class::BSD_samples_sort_each_layer(){
...
@@ -176,7 +181,7 @@ int BDD_class::BSD_samples_sort_each_layer(){
bool
*
BDD_class
::
io_generator
(
bool
input_data
[
parameter_input_bit_width
],
bool
*
output_bits
){
bool
*
BDD_class
::
io_generator
(
bool
input_data
[
parameter_input_bit_width
],
bool
*
output_bits
){
//bool* output_bits = new bool [parameter_output_bit_width];
//bool* output_bits = new bool [parameter_output_bit_width];
output_bits
=
io_generator_function
(
input_data
,
1
,
output_bits
);
output_bits
=
io_generator_function
(
input_data
,
which_demo_function
,
output_bits
);
//io_read_times += 1;
//io_read_times += 1;
return
output_bits
;
return
output_bits
;
};
};
...
@@ -391,7 +396,7 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
...
@@ -391,7 +396,7 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
BDD
[
i
+
1
][
zi
].
non_equal_number
=
0
;
BDD
[
i
+
1
][
zi
].
non_equal_number
=
0
;
}
}
BSD_samples
=
BSD_samples_sort
;
BSD_samples
=
BSD_samples_sort
;
most_influence
[
i
]
=
next_bit_layer
(
i
,
BDD
,
most_influence
);
most_influence
[
i
]
=
next_bit_layer
(
i
);
BSD_samples
=
BSD_samples_train
;
BSD_samples
=
BSD_samples_train
;
cout
<<
BSD_samples
<<
endl
;
cout
<<
BSD_samples
<<
endl
;
...
...
src/next_layer_bit.h
View file @
879d8b82
int
BDD_class
::
next_bit_layer_single
(
int
depth
,
BDD_node
**
BDD
,
int
*
most_influence
,
int
which_node_this_layer
){
int
BDD_class
::
next_bit_layer_single
(
int
depth
,
int
which_node_this_layer
){
int
most_influence_next
=
0
;
int
most_influence_next
=
0
;
int
i
,
j
,
k
;
int
i
,
j
,
k
;
...
@@ -113,7 +113,17 @@ int BDD_class::next_bit_layer_single(int depth,BDD_node** BDD,int* most_influenc
...
@@ -113,7 +113,17 @@ int BDD_class::next_bit_layer_single(int depth,BDD_node** BDD,int* most_influenc
return
most_influence_next
;
return
most_influence_next
;
};
};
int
BDD_class
::
next_bit_layer
(
int
depth
,
BDD_node
**
BDD
,
int
*
most_influence
){
int
BDD_class
::
next_bit_layer
(
int
depth
){
if
(
depth
<
BSD_variable_order_number
)
return
BSD_variable_order
[
depth
];
else
return
next_bit_layer_0
(
depth
);
}
int
BDD_class
::
next_bit_layer_1
(
int
depth
){
random_device
rd
;
random_device
rd
;
mt19937
gen
(
rd
());
mt19937
gen
(
rd
());
//int most_influence_all[64] ={0,32,1,33,2,34,3,35,4,36,5,37,6,38,7,39,8,40,9,41,10,42,11,43,12,44,13,45,14,46,15,47,16,48,17,49,18,50,19,51,20,52,21,53,22,54,23,55,24,56,25,57,26,58,27,59,28,60,29,61,30,62,31,63};
//int most_influence_all[64] ={0,32,1,33,2,34,3,35,4,36,5,37,6,38,7,39,8,40,9,41,10,42,11,43,12,44,13,45,14,46,15,47,16,48,17,49,18,50,19,51,20,52,21,53,22,54,23,55,24,56,25,57,26,58,27,59,28,60,29,61,30,62,31,63};
...
@@ -124,10 +134,10 @@ int BDD_class::next_bit_layer(int depth,BDD_node** BDD,int* most_influence){
...
@@ -124,10 +134,10 @@ int BDD_class::next_bit_layer(int depth,BDD_node** BDD,int* most_influence){
int
most_influence_next
=
999999
;
int
most_influence_next
=
999999
;
int
most_influence_single
=
0
;
int
most_influence_single
=
0
;
if
(
depth
<
2000
){
if
(
depth
<
2000
){
most_influence_next
=
next_bit_layer_
old
(
depth
,
BDD
,
most_influence
);
most_influence_next
=
next_bit_layer_
0
(
depth
);
}
}
else
if
(
depth
==
parameter_input_bit_width
-
1
){
else
if
(
depth
==
parameter_input_bit_width
-
1
){
most_influence_next
=
next_bit_layer_
old
(
depth
,
BDD
,
most_influence
);
most_influence_next
=
next_bit_layer_
0
(
depth
);
return
most_influence_next
;
return
most_influence_next
;
}
}
//return most_influence_next;
//return most_influence_next;
...
@@ -148,7 +158,7 @@ int BDD_class::next_bit_layer(int depth,BDD_node** BDD,int* most_influence){
...
@@ -148,7 +158,7 @@ int BDD_class::next_bit_layer(int depth,BDD_node** BDD,int* most_influence){
else
{
else
{
which_node_this_layer
=
rand
()
%
BDD_width_each_layer
[
depth
];
which_node_this_layer
=
rand
()
%
BDD_width_each_layer
[
depth
];
}
}
most_influence_single
=
next_bit_layer_single
(
depth
,
BDD
,
most_influence
,
which_node_this_layer
);
most_influence_single
=
next_bit_layer_single
(
depth
,
which_node_this_layer
);
this_bit_most_influence
[
most_influence_single
]
=
1
;
this_bit_most_influence
[
most_influence_single
]
=
1
;
}
}
int
i
=
depth
;
int
i
=
depth
;
...
@@ -322,7 +332,7 @@ int BDD_class::next_bit_layer(int depth,BDD_node** BDD,int* most_influence){
...
@@ -322,7 +332,7 @@ int BDD_class::next_bit_layer(int depth,BDD_node** BDD,int* most_influence){
return
most_influence_next
;
return
most_influence_next
;
};
};
int
BDD_class
::
next_bit_layer_
old
(
int
depth
,
BDD_node
**
BDD
,
int
*
most_influence
){
int
BDD_class
::
next_bit_layer_
0
(
int
depth
){
int
most_influence_next
=
0
;
int
most_influence_next
=
0
;
int
i
,
j
,
k
;
int
i
,
j
,
k
;
...
@@ -447,12 +457,12 @@ int BDD_class::next_bit_layer_old(int depth,BDD_node** BDD,int* most_influence){
...
@@ -447,12 +457,12 @@ int BDD_class::next_bit_layer_old(int depth,BDD_node** BDD,int* most_influence){
double
amount_turn_max_divide_average
=
amount_turn_static
[
most_influence_next
]
/
amount_turn_average
;
double
amount_turn_max_divide_average
=
amount_turn_static
[
most_influence_next
]
/
amount_turn_average
;
double
amount_turn_max_ratio
=
amount_turn
[
most_influence_next
]
/
(
zz
+
1
);
double
amount_turn_max_ratio
=
amount_turn
[
most_influence_next
]
/
(
zz
+
1
);
//USE_THIS:BEST
//USE_THIS:BEST
if
((
depth
<
parameter_input_bit_width
-
2
)
){
//
if((depth<parameter_input_bit_width-2) ){
if
((
amount_turn_max_divide_average
<
4
)
||
(
amount_turn_max_ratio
<
0
.
3
)
||
((
amount_turn_max_ratio
>
0
.
8
)
&&
((
amount_turn_max_ratio
<
0
.
999
)))){
//
if((amount_turn_max_divide_average < 4) || (amount_turn_max_ratio < 0.3) || ((amount_turn_max_ratio>0.8)&&((amount_turn_max_ratio<0.999)))){
has_been_unfold
[
most_influence_next
]
=
0
;
//
has_been_unfold[most_influence_next] = 0;
most_influence_next
=
999999
;
//
most_influence_next = 999999;
}
//
}
}
//
}
//delete[]amount_turn;
//delete[]amount_turn;
return
most_influence_next
;
return
most_influence_next
;
};
};
src/zstart.sh
View file @
879d8b82
...
@@ -3,4 +3,4 @@ export LIBRARY_PATH=/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/lus
...
@@ -3,4 +3,4 @@ export LIBRARY_PATH=/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/lus
export
LD_LIBRARY_PATH
=
/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/lib
export
LD_LIBRARY_PATH
=
/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/lib
rm rtl/
*
rm rtl/
*
g++ BSD.cpp
-O3
-std
=
c++11
-fopenmp
-pg
g++ BSD.cpp
-O3
-std
=
c++11
-fopenmp
-pg
./a.out
./a.out
2
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