v1.4: 初步解决了效率问题
This commit is contained in:
parent
c112a34dd6
commit
2dc85e3e88
2
crun
2
crun
@ -9,6 +9,6 @@ if [ $? -ne 0 ]; then
|
||||
else
|
||||
clear
|
||||
echo "========================"
|
||||
time ./atpg -i $1 --lut=8 --seed=19260817
|
||||
time ./atpg -i $1 --lut=16 --seed=19260817
|
||||
fi
|
||||
|
||||
|
@ -2,17 +2,17 @@
|
||||
|
||||
#include "circuit.h"
|
||||
|
||||
int LUTCircuit::check() {
|
||||
double LUTCircuit::check() {
|
||||
|
||||
// static bool init = 0;
|
||||
// static std::unordered_set<Gate*> dt;
|
||||
|
||||
printf("checking circuit ...\n");
|
||||
|
||||
int score_value_unsatisfied_cost = 0;
|
||||
int score_fault_detected_weight = 0;
|
||||
int score_fault_propagated_weight = 0;
|
||||
int score_fault_update_cost = 0;
|
||||
double score_value_unsatisfied_cost = 0;
|
||||
double score_fault_detected_weight = 0;
|
||||
double score_fault_propagated_weight = 0;
|
||||
double score_fault_update_cost = 0;
|
||||
int unsatisfied_lut = 0;
|
||||
|
||||
for(LUT* lut : luts) {
|
||||
@ -55,19 +55,21 @@ int LUTCircuit::check() {
|
||||
score_fault_detected_weight += t_fd[0] * g->fault_detected_weight[0];
|
||||
score_fault_detected_weight += t_fd[1] * g->fault_detected_weight[1];
|
||||
|
||||
score_fault_propagated_weight += t_fpl[0] * g->fault_propagated_weight[0];
|
||||
score_fault_propagated_weight += t_fpl[1] * g->fault_propagated_weight[1];
|
||||
if(!g->isPO) {
|
||||
score_fault_propagated_weight += (double)t_fpl[0] / g->avg_dist * g->fault_detected_weight[0];
|
||||
score_fault_propagated_weight += (double)t_fpl[1] / g->avg_dist * g->fault_detected_weight[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("=====================================\n");
|
||||
printf("unsat_lut: %d\n", unsatisfied_lut);
|
||||
printf("score_value_unsatisfied_cost: %d\n", score_value_unsatisfied_cost);
|
||||
printf("score_fault_detected_weight: %d\n", score_fault_detected_weight);
|
||||
printf("score_fault_propagated_weight: %d\n", score_fault_propagated_weight);
|
||||
printf("score_fault_update_cost: %d\n", score_fault_update_cost);
|
||||
printf("score_value_unsatisfied_cost: %.2f\n", score_value_unsatisfied_cost);
|
||||
printf("score_fault_detected_weight: %.2f\n", score_fault_detected_weight);
|
||||
printf("score_fault_propagated_weight: %.2f\n", score_fault_propagated_weight);
|
||||
printf("score_fault_update_cost: %.2f\n", score_fault_update_cost);
|
||||
|
||||
int score = - score_value_unsatisfied_cost + score_fault_detected_weight + score_fault_propagated_weight - score_fault_update_cost;
|
||||
double score = - score_value_unsatisfied_cost + score_fault_detected_weight + score_fault_propagated_weight - score_fault_update_cost;
|
||||
|
||||
printf("score: %d\n", score);
|
||||
|
||||
|
@ -29,7 +29,7 @@ void ls_random_sol();
|
||||
void ls_gen_sol();
|
||||
|
||||
// checker
|
||||
int check();
|
||||
double check();
|
||||
|
||||
Simulator *simulator;
|
||||
Circuit *C;
|
||||
|
49
src/ls.cpp
49
src/ls.cpp
@ -79,13 +79,13 @@ void LUTCircuit::ls_update(std::vector<LUT*> &unsat) {
|
||||
}
|
||||
// printf("cost: %d add: %d\n", lut->vunat_cost, OPT(vsat_inc));
|
||||
|
||||
for(LUT* out : lut->fanouts) {
|
||||
if(out->vunat_cost -= OPT(vsat_inc) > 1) {
|
||||
out->vunat_cost -= OPT(vsat_inc);
|
||||
} else {
|
||||
out->vunat_cost = 1;
|
||||
}
|
||||
}
|
||||
// for(LUT* out : lut->fanouts) {
|
||||
// if(out->vunat_cost -= OPT(vsat_inc) > 1) {
|
||||
// out->vunat_cost -= OPT(vsat_inc);
|
||||
// } else {
|
||||
// out->vunat_cost = 1;
|
||||
// }
|
||||
// }
|
||||
|
||||
unsat.push_back(lut);
|
||||
}
|
||||
@ -201,32 +201,34 @@ void LUTCircuit::ls_gen_sol() {
|
||||
break;
|
||||
}
|
||||
|
||||
pick->cal_score();
|
||||
// pick->cal_score();
|
||||
|
||||
// int t1 = check();
|
||||
// double t1 = check();
|
||||
|
||||
// printf(">>>>>>>>>>>>>\n");
|
||||
// printf("dert_score: %d\n", pick->score);
|
||||
// printf("dert_fault_detected_weight: %d\n", pick->score_fault_detected_weight);
|
||||
// printf("dert_fault_propagated_weight: %d\n", pick->score_fault_propagated_weight);
|
||||
// printf("dert_up_cost: %d\n", pick->score_fault_update_cost);
|
||||
// printf("dert_unsat_cost: %d\n", pick->score_value_unsatisfied_cost);
|
||||
// printf("dert_score: %.2f\n", pick->score);
|
||||
// printf("dert_unsat_cost: %.2f\n", pick->score_value_unsatisfied_cost);
|
||||
// printf("dert_fault_detected_weight: %.2f\n", pick->score_fault_detected_weight);
|
||||
// printf("dert_fault_propagated_weight: %.2f\n", pick->score_fault_propagated_weight);
|
||||
// printf("dert_up_cost: %.2f\n", pick->score_fault_update_cost);
|
||||
|
||||
ls_flip(pick);
|
||||
|
||||
// int t2 = check();
|
||||
// assert((t2 - t1) == pick->score);
|
||||
// double t2 = check();
|
||||
// assert(((t2 - t1) - pick->score) < 1e-6);
|
||||
|
||||
if(pick->isPI) {
|
||||
int score;
|
||||
simulator->simulate(PIs, score, fault_detected);
|
||||
// printf("step: %d fd: %d\n", step, score);
|
||||
printf("step: %d fd: %d\n", step, score);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LUTCircuit::ls_init() {
|
||||
for(LUT* lut : luts) {
|
||||
static int cnt = 0;
|
||||
printf("[%d/%d]\n", ++cnt, luts.size());
|
||||
lut->init_lookup_table();
|
||||
}
|
||||
|
||||
@ -280,6 +282,8 @@ void LUTCircuit::ls_random_sol() {
|
||||
|
||||
step = 0;
|
||||
|
||||
std::vector<int*> t_focus;
|
||||
|
||||
for(LUT* lut : luts) {
|
||||
lut->up_cost = 1;
|
||||
|
||||
@ -295,11 +299,22 @@ void LUTCircuit::ls_random_sol() {
|
||||
g->fault_detected_weight[0] = !fault_detected[g->id-1][0];
|
||||
g->fault_detected_weight[1] = !fault_detected[g->id-1][1];
|
||||
|
||||
if(g->fault_detected_weight[0]) {
|
||||
t_focus.push_back(&g->fault_detected_weight[0]);
|
||||
}
|
||||
|
||||
if(g->fault_detected_weight[1]) {
|
||||
t_focus.push_back(&g->fault_detected_weight[1]);
|
||||
}
|
||||
|
||||
g->fault_propagated_weight[0] = !fault_detected[g->id-1][0];
|
||||
g->fault_propagated_weight[1] = !fault_detected[g->id-1][1];
|
||||
}
|
||||
}
|
||||
|
||||
int *tw = t_focus[rand()%t_focus.size()];
|
||||
*tw = 100000;
|
||||
|
||||
for(LUT* lut : luts) {
|
||||
lut->uptag = 0;
|
||||
lut->value = rand() % 2;
|
||||
|
10
src/lut.h
10
src/lut.h
@ -62,11 +62,11 @@ public:
|
||||
void get_fault_info(Gate *gate, int *t_fd, int *t_fpl);
|
||||
|
||||
// score
|
||||
int score;
|
||||
int score_value_unsatisfied_cost;
|
||||
int score_fault_detected_weight;
|
||||
int score_fault_propagated_weight;
|
||||
int score_fault_update_cost;
|
||||
double score;
|
||||
double score_value_unsatisfied_cost;
|
||||
double score_fault_detected_weight;
|
||||
double score_fault_propagated_weight;
|
||||
double score_fault_update_cost;
|
||||
|
||||
void cal_score();
|
||||
void cal_update();
|
||||
|
@ -29,10 +29,10 @@ int main(int argc, char *argv[]) {
|
||||
printf("PO:\t%ld\n", circuit->POs.size());
|
||||
printf("Gate:\t%ld\n", circuit->gates.size());
|
||||
printf("LUT:\t%ld\n", C->luts.size());
|
||||
// printf("================================ \n");
|
||||
printf("================================ \n");
|
||||
|
||||
|
||||
C->print();
|
||||
// C->print();
|
||||
C->ls_main();
|
||||
|
||||
return 0;
|
||||
|
@ -8,7 +8,7 @@
|
||||
// name, type, short-name,must-need, default ,low, high, comments
|
||||
#define PARAS \
|
||||
PARA( seed , int , '\0' , false , 17 , 0 , 100000000 , "max input numbers of LUT") \
|
||||
PARA( lut , int , '\0' , false , 8 , 0 , 16 , "max input numbers of LUT") \
|
||||
PARA( lut , int , '\0' , false , 8 , 0 , 30 , "max input numbers of LUT") \
|
||||
PARA( sp , double , '\0' , false , 0.01 , 0 , 1 , "max input numbers of LUT") \
|
||||
PARA( brk_sp , double , '\0' , false , 0.05 , 0 , 1 , "max input numbers of LUT") \
|
||||
PARA( t , int , '\0' , false , 20 , 0 , 1000 , "max input numbers of LUT") \
|
||||
|
@ -75,8 +75,10 @@ void LUT::cal_score() {
|
||||
score_fault_detected_weight += (t_fd2[0] - t_fd1[0]) * g->fault_detected_weight[0];
|
||||
score_fault_detected_weight += (t_fd2[1] - t_fd1[1]) * g->fault_detected_weight[1];
|
||||
|
||||
score_fault_propagated_weight += (t_fpl2[0] - t_fpl1[0]) * g->fault_propagated_weight[0];
|
||||
score_fault_propagated_weight += (t_fpl2[1] - t_fpl1[1]) * g->fault_propagated_weight[1];
|
||||
if(!g->isPO) {
|
||||
score_fault_propagated_weight += (double)(t_fpl2[0] - t_fpl1[0]) / g->avg_dist * g->fault_detected_weight[0];
|
||||
score_fault_propagated_weight += (double)(t_fpl2[1] - t_fpl1[1]) / g->avg_dist * g->fault_detected_weight[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,8 +107,10 @@ void LUT::cal_score() {
|
||||
score_fault_detected_weight += (t_fd2[0] - t_fd1[0]) * g->fault_detected_weight[0];
|
||||
score_fault_detected_weight += (t_fd2[1] - t_fd1[1]) * g->fault_detected_weight[1];
|
||||
|
||||
score_fault_propagated_weight += (t_fpl2[0] - t_fpl1[0]) * g->fault_propagated_weight[0];
|
||||
score_fault_propagated_weight += (t_fpl2[1] - t_fpl1[1]) * g->fault_propagated_weight[1];
|
||||
if(!g->isPO) {
|
||||
score_fault_propagated_weight += (double)(t_fpl2[0] - t_fpl1[0]) / g->avg_dist * g->fault_detected_weight[0];
|
||||
score_fault_propagated_weight += (double)(t_fpl2[1] - t_fpl1[1]) / g->avg_dist * g->fault_detected_weight[1];
|
||||
}
|
||||
}
|
||||
|
||||
// update cost score
|
||||
@ -131,7 +135,5 @@ void LUT::cal_score() {
|
||||
out->vsat = ( out->cal_value() == out->value );
|
||||
}
|
||||
|
||||
|
||||
|
||||
score = - score_value_unsatisfied_cost + score_fault_detected_weight + score_fault_propagated_weight - score_fault_update_cost;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user