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
chengshuyao
BSD
Commits
409122be
Commit
409122be
authored
Dec 23, 2025
by
chengshuyao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debug accuracy first design. Now available
parent
d12d03bc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
30 deletions
+57
-30
src/BSD.h
+18
-15
src/BSD_top.h
+39
-15
src/next_layer_bit.h
+0
-0
No files found.
src/BSD.h
View file @
409122be
...
...
@@ -156,7 +156,7 @@ public:
int
BSD_samples_sort_each_layer
();
int
*
BSD_variable_order
;
int
BSD_variable_order_
number
;
int
BSD_variable_order_
depth
;
int
feature_area
;
int
*
split_nodes_each_layer
;
...
...
@@ -263,13 +263,13 @@ int BDD_class::BSD_samples_sort_each_layer(){
bool
BDD_class
::
io_generator_single
(
bool
*
input_data
,
int
which_bit_output
){
int
origin_which_bit_output
=
this
->
start_node_index
[
which_bit_output
].
root_node_index
;
for
(
int
i
=
0
;
i
<
this
->
start_node_index
[
which_bit_output
].
node_depth
;
i
++
){
input_data
[
this
->
start_node_index
[
which_bit_output
].
expand_input_bit_index
[
i
]]
=
this
->
start_node_index
[
which_bit_output
].
expand_input_bit_data
[
i
];
}
//
int origin_which_bit_output = this->start_node_index[which_bit_output].root_node_index;
//
for (int i=0;i<this->start_node_index[which_bit_output].node_depth;i++){
//
input_data[this->start_node_index[which_bit_output].expand_input_bit_index[i]] = this->start_node_index[which_bit_output].expand_input_bit_data[i];
//
}
#ifdef SINGLE_BITS
//if (output_partition_set[which_bit_output]==1){
bool
output_bit_s
=
io_generator_outer_single
(
input_data
,
origin_
which_bit_output
)
;
bool
output_bit_s
=
io_generator_outer_single
(
input_data
,
which_bit_output
)
;
return
output_bit_s
;
//}else{
// return 0;
...
...
@@ -291,16 +291,16 @@ bool BDD_class::io_generator_single(bool* input_data,int which_bit_output){
uint64_t
BDD_class
::
io_generator_single_vec
(
uint64_t
*
input_data
,
int
which_bit_output
){
int
origin_which_bit_output
=
this
->
start_node_index
[
which_bit_output
].
root_node_index
;
for
(
int
i
=
0
;
i
<
this
->
start_node_index
[
which_bit_output
].
node_depth
;
i
++
){
if
(
this
->
start_node_index
[
which_bit_output
].
expand_input_bit_data
[
i
]
==
0
)
input_data
[
this
->
start_node_index
[
which_bit_output
].
expand_input_bit_index
[
i
]]
=
uint64_t
(
0
);
else
input_data
[
this
->
start_node_index
[
which_bit_output
].
expand_input_bit_index
[
i
]]
=
~
uint64_t
(
0
);
}
///
int origin_which_bit_output = this->start_node_index[which_bit_output].root_node_index;
///
for (int i=0;i<this->start_node_index[which_bit_output].node_depth;i++){
///
if(this->start_node_index[which_bit_output].expand_input_bit_data[i] == 0)
///
input_data[this->start_node_index[which_bit_output].expand_input_bit_index[i]] = uint64_t(0);
///
else
///
input_data[this->start_node_index[which_bit_output].expand_input_bit_index[i]] = ~uint64_t(0);
///
}
#ifdef SINGLE_BITS
//if (output_partition_set[which_bit_output]==1){
uint64_t
output_bit_s
=
io_generator_outer_vec_single
(
input_data
,
origin_
which_bit_output
)
;
uint64_t
output_bit_s
=
io_generator_outer_vec_single
(
input_data
,
which_bit_output
)
;
return
output_bit_s
;
//}else
// return 0;
...
...
@@ -528,13 +528,15 @@ int BDD_class::train_BDD(int start_depth, int how_many_start_nodes, BDD_node* st
//cout<<"New BSD nodes start "<<BDD_width_each_layer[i]<<endl;
BDD
[
i
+
1
]
=
new
BDD_node
[
BDD_width_each_layer
[
i
]
*
2
];
//
cout<<"New BSD nodes finish "<<endl;
cout
<<
"New BSD nodes finish "
<<
endl
;
for
(
zi
=
0
;
zi
<
BDD_width_each_layer
[
i
]
*
2
;
zi
++
){
BDD
[
i
+
1
][
zi
].
has_equal_father
=
0
;
BDD
[
i
+
1
][
zi
].
non_equal_number
=
0
;
}
BSD_samples
=
BSD_samples_sort
;
cout
<<
"next bit layer start "
<<
endl
;
most_influence
[
i
]
=
next_bit_layer
(
i
);
cout
<<
"next bit layer finish "
<<
endl
;
BSD_samples
=
int
(
BSD_samples_train
/
63
)
*
63
;
//一定要是vec_length的整数倍
cout
<<
BSD_samples
<<
endl
;
...
...
@@ -542,6 +544,7 @@ int BDD_class::train_BDD(int start_depth, int how_many_start_nodes, BDD_node* st
cout
<<
"The input bit is: x"
<<
most_influence
[
i
]
<<
endl
;
cout
<<
"BSD width at this layer: "
<<
BDD_width_each_layer
[
i
]
<<
endl
;
set_random_input_data
(
mask_input_data
);
cout
<<
"set random input data finish "
<<
endl
;
#ifdef INPUT_AIG
int
vec_length
=
63
;
#pragma omp parallel for
...
...
src/BSD_top.h
View file @
409122be
...
...
@@ -81,8 +81,8 @@ public:
expand_input_bit_data
=
new
bool
[
parameter_input_bit_width
];
}
~
node_index
(){
arr_delete
(
expand_input_bit_index
);
arr_delete
(
expand_input_bit_data
);
//
arr_delete (expand_input_bit_index);
//
arr_delete (expand_input_bit_data);
}
};
...
...
@@ -256,8 +256,8 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
}
}
cout
<<
endl
;
node_index
*
start_node_index_partition
=
new
node_index
[
max_partition_parts
];
int
zi
=
0
;
node_index
*
start_node_index_partition
=
new
node_index
[
max_partition_parts
];
for
(
int
j
=
0
;
j
<
max_partition_parts
;
j
++
){
if
(
partition_sets
[
i
][
j
]){
start_node_index_partition
[
zi
].
node_depth
=
start_node_index
[
j
].
node_depth
;
...
...
@@ -390,17 +390,24 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
}
}
cout
<<
endl
;
node_index
*
start_node_index_partition
=
new
node_index
[
start_node_partition
];
node_index
*
start_node_index_partition
=
new
node_index
[
max_partition_parts
];
int
zi
=
0
;
for
(
int
j
=
0
;
j
<
partition_parts
;
j
++
){
if
(
partition_sets
[
i
][
j
]){
start_node_index_partition
[
zi
]
=
start_node_index
[
j
];
//start_node_index_partition[zi] = start_node_index[j];
start_node_index_partition
[
zi
].
node_depth
=
start_node_index
[
j
].
node_depth
;
start_node_index_partition
[
zi
].
root_node_index
=
start_node_index
[
j
].
root_node_index
;
for
(
int
zj
=
0
;
zj
<
parameter_input_bit_width
;
zj
++
){
start_node_index_partition
[
zi
].
expand_input_bit_index
[
zj
]
=
start_node_index
[
j
].
expand_input_bit_index
[
zj
];
start_node_index_partition
[
zi
].
expand_input_bit_data
[
zj
]
=
start_node_index
[
j
].
expand_input_bit_data
[
zj
];
}
zi
++
;
}
}
area_parts
[
i
]
=
search_order
(
start_node_partition
,
start_node_depth
,
start_node_index_partition
,
search_order_times
,
start_order
);
area
+=
area_parts
[
i
];
//
arr_delete ( start_node_index_partition);
arr_delete
(
start_node_index_partition
);
}
}
...
...
@@ -502,13 +509,14 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
return
0
;
};
int
BSD_execute
(
int
start_node_number
,
node_index
*
start_node_index
,
int
variable_order_
number
,
int
*
variable_order
){
int
BSD_execute
(
int
start_node_number
,
node_index
*
start_node_index
,
int
variable_order_
depth
,
int
*
variable_order
){
cout
<<
"BSD execute start"
<<
endl
;
BDD_class
BDD_class_main
;
cout
<<
"This variable order: "
<<
variable_order_
number
<<
endl
;
cout
<<
"This variable order: "
<<
variable_order_
depth
<<
endl
;
//BDD_class_main.output_partition_set = output_partition_set;
BDD_class_main
.
which_demo_function
=
GLOBAL_which_demo_function
;
BDD_class_main
.
BSD_variable_order_depth
=
variable_order_depth
;
//for (int vi=0;vi<partition_parts;vi++){
// BDD_class_main.BSD_variable_order_number = variable_order_number;
// for(int i=0;i<variable_order_number;i++){
...
...
@@ -518,7 +526,7 @@ int BSD_execute(int start_node_number, node_index* start_node_index,int variable
// cout<<endl;
//}
//cout<<endl;
for
(
int
i
=
0
;
i
<
variable_order_
number
;
i
++
){
for
(
int
i
=
0
;
i
<
variable_order_
depth
;
i
++
){
BDD_class_main
.
BSD_variable_order
[
i
]
=
variable_order
[
i
];
cout
<<
BDD_class_main
.
BSD_variable_order
[
i
]
<<
" "
;
}
...
...
@@ -531,7 +539,12 @@ int BSD_execute(int start_node_number, node_index* start_node_index,int variable
BDD_class_main
.
how_many_start_nodes
=
start_node_number
;
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
++
){
BDD_class_main
.
start_node_index
[
zi
]
=
start_node_index
[
zi
];
BDD_class_main
.
start_node_index
[
zi
].
node_depth
=
start_node_index
[
zi
].
node_depth
;
BDD_class_main
.
start_node_index
[
zi
].
root_node_index
=
start_node_index
[
zi
].
root_node_index
;
for
(
int
zj
=
0
;
zj
<
parameter_input_bit_width
;
zj
++
){
BDD_class_main
.
start_node_index
[
zi
].
expand_input_bit_index
[
zj
]
=
start_node_index
[
zi
].
expand_input_bit_index
[
zj
];
BDD_class_main
.
start_node_index
[
zi
].
expand_input_bit_data
[
zj
]
=
start_node_index
[
zi
].
expand_input_bit_data
[
zj
];
}
BDD_class_main
.
start_nodes
[
zi
].
which_bit_output
=
start_node_index
[
zi
].
root_node_index
;
BDD_class_main
.
start_nodes
[
zi
].
which_root_node
=
start_node_index
[
zi
].
root_node_index
;
BDD_class_main
.
start_nodes
[
zi
].
which_root_node_all
[
BDD_class_main
.
start_nodes
[
zi
].
which_root_node
]
=
1
;
...
...
@@ -770,9 +783,19 @@ int search_order(int start_node_number = default_start_node_number, int start_no
// feature_variable[variable_order[j]] = 9999999;
//}
node_index
*
start_node_index_copy
=
new
node_index
[
start_node_number
];
for
(
int
zi
=
0
;
zi
<
start_node_number
;
zi
++
){
start_node_index_copy
[
zi
].
node_depth
=
start_node_index
[
zi
].
node_depth
;
start_node_index_copy
[
zi
].
root_node_index
=
start_node_index
[
zi
].
root_node_index
;
for
(
int
zj
=
0
;
zj
<
parameter_input_bit_width
;
zj
++
){
start_node_index_copy
[
zi
].
expand_input_bit_index
[
zj
]
=
start_node_index
[
zi
].
expand_input_bit_index
[
zj
];
start_node_index_copy
[
zi
].
expand_input_bit_data
[
zj
]
=
start_node_index
[
zi
].
expand_input_bit_data
[
zj
];
}
}
if
(
i
<
parameter_max_orders
){
//parameter_max_samples = int(parameter_max_samples/10); //BSD每一个节点最多进行多少次采样
reward
=
BSD_execute
(
start_node_number
,
start_node_index
,
start_node_depth
,
multi_variable_order
[
order_num
]);
reward
=
BSD_execute
(
start_node_number
,
start_node_index
_copy
,
start_node_depth
,
multi_variable_order
[
order_num
]);
//parameter_max_samples *= 10; //BSD每一个节点最多进行多少次采样
}
//else if (i<parameter_max_orders){
...
...
@@ -780,12 +803,13 @@ int search_order(int start_node_number = default_start_node_number, int start_no
//}
else
if
(
i
==
search_iterations
-
1
){
parameter_early_stop_split_nodes
=
9999999
;
reward
=
BSD_execute
(
start_node_number
,
start_node_index
,
best_area_depth
,
best_variable_order
[
order_num
]);
reward
=
BSD_execute
(
start_node_number
,
start_node_index
_copy
,
best_area_depth
,
best_variable_order
[
order_num
]);
break
;
}
else
{
reward
=
BSD_execute
(
start_node_number
,
start_node_index
,
best_area_depth
,
multi_variable_order
[
order_num
]);
reward
=
BSD_execute
(
start_node_number
,
start_node_index
_copy
,
best_area_depth
,
multi_variable_order
[
order_num
]);
}
arr_delete
(
start_node_index_copy
);
#ifdef SEARCH_PARTITION
#else
char
*
start_node_index_string
=
new
char
[
parameter_output_bit_width
+
1
];
...
...
@@ -946,8 +970,8 @@ int search_order(int start_node_number = default_start_node_number, int start_no
}
cout
<<
"Best Order: "
;
for
(
int
vj
=
0
;
vj
<
parameter_input_bit_width
;
vj
++
){
start_order
[
vj
]
=
best_variable_order
[
best_order_num
][
vj
];
cout
<<
start_order
[
vj
]
<<
" "
;
cout
<<
best_variable_order
[
best_order_num
][
vj
];
//
cout<<start_order[vj]<<" ";
}
cout
<<
endl
;
//cout<<"Best Design Area: "<<BSD_features_0.BSD_area<<endl;
...
...
src/next_layer_bit.h
View file @
409122be
This diff is collapsed.
Click to expand it.
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