From 1c0944be606f154cf11934bcc5a585ba9d75886e Mon Sep 17 00:00:00 2001 From: WeileiZeng <240155787@qq.com> Date: Sat, 11 Apr 2020 13:28:27 -0700 Subject: [PATCH] add my_bp4 --- ...p4-feedback5-num-data-1000-flexible.gnudat | 16 + gnuplot/toric_rate.gnu | 2 +- makefile | 2 + my_bp4.c | 254 +++++++++++++++ my_bp4.c~ | 298 ++++++++++++++++++ my_bp4.out | Bin 0 -> 250152 bytes 6 files changed, 571 insertions(+), 1 deletion(-) create mode 100644 gnuplot/result/my-bp4-feedback5-num-data-1000-flexible.gnudat create mode 100644 my_bp4.c create mode 100644 my_bp4.c~ create mode 100755 my_bp4.out diff --git a/gnuplot/result/my-bp4-feedback5-num-data-1000-flexible.gnudat b/gnuplot/result/my-bp4-feedback5-num-data-1000-flexible.gnudat new file mode 100644 index 0000000..83e0f17 --- /dev/null +++ b/gnuplot/result/my-bp4-feedback5-num-data-1000-flexible.gnudat @@ -0,0 +1,16 @@ +#header +sizes: 13, 11, 9, 7, 5, + p, P_c converge rate, zero error vectors, weight one error, weight 2 error +0.199526 0.037736 53.000000 0.000000 0.000000 0.199526 0.163934 61.000000 0.000000 0.000000 0.199526 0.250000 68.000000 0.000000 0.000000 0.199526 0.439560 91.000000 0.000000 0.000000 0.199526 0.630435 138.000000 0.000000 0.000000 +0.158489 0.055556 54.000000 0.000000 0.000000 0.158489 0.105263 57.000000 0.000000 0.000000 0.158489 0.250000 68.000000 0.000000 0.000000 0.158489 0.439560 91.000000 0.000000 0.000000 0.158489 0.786611 239.000000 0.000000 0.000000 +0.125893 0.072727 55.000000 0.000000 0.000000 0.125893 0.238806 67.000000 0.000000 0.000000 0.125893 0.238806 67.000000 0.000000 0.000000 0.125893 0.625000 136.000000 0.000000 0.000000 0.125893 0.796000 250.000000 0.000000 0.000000 +0.100000 0.260870 69.000000 0.000000 0.000000 0.100000 0.215385 65.000000 0.000000 0.000000 0.100000 0.560345 116.000000 0.000000 0.000000 0.100000 0.737113 194.000000 0.000000 0.000000 0.100000 0.873762 404.000000 0.000000 0.000000 +0.079433 0.445652 92.000000 0.000000 0.000000 0.079433 0.575000 120.000000 0.000000 0.000000 0.079433 0.737113 194.000000 0.000000 0.000000 0.079433 0.827703 296.000000 0.000000 0.000000 0.079433 0.900391 512.000000 0.000000 0.000000 +0.063096 0.648276 145.000000 0.000000 0.000000 0.063096 0.799213 254.000000 0.000000 0.000000 0.063096 0.864721 377.000000 0.000000 0.000000 0.063096 0.905904 542.000000 0.000000 0.000000 0.063096 0.947314 968.000000 0.000000 0.000000 +0.050119 0.845921 331.000000 0.000000 0.000000 0.050119 0.914141 594.000000 0.000000 0.000000 0.050119 0.926724 696.000000 0.000000 0.000000 0.050119 0.945860 942.000000 0.000000 0.000000 0.050119 0.971445 1786.000000 0.000000 0.000000 +0.039811 0.955224 1139.000000 0.000000 0.000000 0.039811 0.958671 1234.000000 0.000000 0.000000 0.039811 0.960949 1306.000000 0.000000 0.000000 0.039811 0.966732 1533.000000 0.000000 0.000000 0.039811 0.987531 4090.000000 0.000000 0.000000 +0.031623 0.983628 3115.000000 0.000000 0.000000 0.031623 0.985722 3572.000000 0.000000 0.000000 0.031623 0.983789 3146.000000 0.000000 0.000000 0.031623 0.990916 5614.000000 0.000000 0.000000 0.031623 0.993903 8365.000000 0.000000 0.000000 +0.025119 0.992677 6964.000000 0.000000 0.000000 0.025119 0.993458 7796.000000 0.000000 0.000000 0.025119 0.994167 8744.000000 0.000000 0.000000 0.025119 0.994458 9202.000000 0.000000 0.000000 0.025119 0.996748 15685.000000 0.000000 0.000000 +0.019953 0.996103 13087.000000 0.000000 0.000000 0.019953 0.997688 22060.000000 0.000000 0.000000 0.019953 0.996726 15575.000000 0.000000 0.000000 0.019953 0.997832 23519.000000 0.000000 0.000000 0.019953 0.998046 26101.000000 0.000000 0.000000 +0.015849 0.998520 34448.000000 0.000000 0.000000 0.015849 0.998550 35178.000000 0.000000 0.000000 0.015849 0.998645 37644.000000 0.000000 0.000000 0.015849 0.999056 54025.000000 0.000000 0.000000 0.015849 0.999134 58923.000000 0.000000 0.000000 +0.012589 0.999372 81203.000000 0.000000 0.000000 0.012589 0.999414 86983.000000 0.000000 0.000000 0.012589 0.999415 87206.000000 0.000000 0.000000 0.012589 0.999494 100757.000000 0.000000 0.000000 0.012589 0.999616 132694.000000 0.000000 0.000000 diff --git a/gnuplot/toric_rate.gnu b/gnuplot/toric_rate.gnu index 564e431..83a0f52 100755 --- a/gnuplot/toric_rate.gnu +++ b/gnuplot/toric_rate.gnu @@ -22,7 +22,7 @@ data_title='iteration0-cycle1000-Dint2-50' #data_title='my-bp3-feedback5-num-data-1000-schedule' data_title='my-bp3-feedback5-num-data-1000-schedule-p' -data_title='my-bp3-feedback5-num-data-1000-flexible' +data_title='my-bp4-feedback5-num-data-1000-flexible' diff --git a/makefile b/makefile index 3f2ad55..73dafa0 100644 --- a/makefile +++ b/makefile @@ -36,6 +36,8 @@ my_bp2.out:my_bp2.c $(files) $(command) my_bp3.out:my_bp3.c $(files) $(command) +my_bp4.out:my_bp4.c $(files) + $(command) #bp_decoding3.out:bp_decoding3.c mm_read.c mm_read.h mmio.c mmio.h mm_write.c mm_write.h lib.cpp lib.h my_lib.h makefile bp_decoding3.out:bp_decoding3.c $(files) $(command) diff --git a/my_bp4.c b/my_bp4.c new file mode 100644 index 0000000..2391dc8 --- /dev/null +++ b/my_bp4.c @@ -0,0 +1,254 @@ +//Weilei Apr 6, 2020 +// copied from my_bp1.c +#include +#include +#include +#include +#include +#include +#include +#include "my_lib.h" +#include +#include "bp_decoder.h" +using namespace std; +using namespace itpp; + + + +// Read the code from files and do BP decoding +//input:source file for stabilzier matrix; error propability p ; + +int decode( BP_Decoder, GF2mat G, GF2mat H, double p, mat * data, int col_index, int row_index, int cycles, int feedback, double time_out, int num_data_points); + +int main(int argc, char **argv){ + Parser parser; + parser.init(argc,argv); + //p.set_silentmode(true); + string filename_G, filename_H, filename_result; + //parser.get(filename_G,"filename_G"); + + vector> pool; + vector>::size_type pool_size=15; //max number of threads, 15 with decreasing size for best performace + std::chrono::milliseconds span (100); + std::chrono::milliseconds final_thread_time (10000);//10 secs before prelimilary result print + string filename_data; + filename_data="gnuplot/result/my-bp4-feedback5-num-data-1000-flexible.gnudat"; + int feedback=5; + int cycles = 1000000;//70 sec for 2,000,000 + double time_out=50;//time out in seconds for each data points (p and size) + int num_data_points = 50;//data entry for each data points + + //change parameter p, code size + double p; + //parser.get(p,"p"); + int sizes[]= {13,11,9,7,5}; + string stabilizer_folder="data/toric/stabilizer"; + double ip_begin=-0.7; + double ip_end=-2.0; + int data_rows = (ip_begin-ip_end)/0.1; + mat data(data_rows,5*5); //return result in a mat, 5 columns for each size. format defines in header + data.zeros(); + + int col_index=-5; + for ( int size : sizes){ + // cout<<"size = "< ip_end;ip-=0.1){ + //cout<<"ip = "<= pool_size ){ + //wait until some of them finish + //break; + for(vector > :: iterator it = pool.begin(); it != pool.end(); ++it){ + //printf("%d", *it); + if ( it->wait_for(span) == future_status::ready){ + // cout<<"."<> :: iterator it = pool.begin(); it != pool.end(); ++it){ + it->get(); + } + + //print final result + mat2gnudata(data,filename_data,header); + cout<<"save final data to "<time_out){ + break; + }else if (counts_nonconverge > num_data_points){ + break; + } + + } + } + //cout<<"counts_converge="< +#include "bp_decoder.h" +using namespace std; +using namespace itpp; + + + +// Read the code from files and do BP decoding +//input:source file for stabilzier matrix; error propability p ; + +int decode( GF2mat G, GF2mat H, double p, mat * data, int col_index, int row_index, int cycles, int feedback, double time_out, int num_data_points); + +int main(int argc, char **argv){ + Parser parser; + parser.init(argc,argv); + //p.set_silentmode(true); + string filename_G, filename_H, filename_result; + //parser.get(filename_G,"filename_G"); + //parser.get(filename_H,"filename_H"); + //parser.get(filename_result,"filename_result"); + + vector> pool; + vector>::size_type pool_size=15; //max number of threads, 15 with decreasing size for best performace + std::chrono::milliseconds span (100); + std::chrono::milliseconds final_thread_time (10000);//10 secs before prelimilary result print + string filename_data="gnuplot/result/my-bp3-iteration0-cycle100-min-sum.gnudat"; + // filename_data="gnuplot/result/my-bp3-feedback5-cycle0-10000-schedule.gnudat"; + filename_data="gnuplot/result/my-bp3-feedback5-num-data-1000-schedule-p.gnudat"; + filename_data="gnuplot/result/my-bp3-feedback5-num-data-1000-flexible.gnudat"; + int feedback=5; + // int cycle0=10000; //number of cycles for the first data points + int cycles = 1000000;//70 sec for 2,000,000 + double time_out=500;//time out in seconds for each data points (p and size) + int num_data_points = 50;//data entry for each data points + + //change parameter p, code size + //char * filename_result=argv[3];//prefix for the file + double p; + //parser.get(p,"p"); + int sizes[]= {13,11,9,7,5}; + string stabilizer_folder="data/toric/stabilizer"; + //string error_folder="data/toric/bp_decoding4"; + double ip_begin=-0.7; + double ip_end=-2.0; + int data_rows = (ip_begin-ip_end)/0.1; + mat data(data_rows,5*5); //return result in a mat, 5 columns for each size. format defines in header + data.zeros(); + + int col_index=-5; + for ( int size : sizes){ + // cout<<"size = "< ip_end;ip-=0.1){ + //cout<<"ip = "<= pool_size ){ + //wait until some of them finish + //break; + for(vector > :: iterator it = pool.begin(); it != pool.end(); ++it){ + //printf("%d", *it); + if ( it->wait_for(span) == future_status::ready){ + // cout<<"."<> :: iterator it = pool.begin(); it != pool.end(); ++it){ + it->get(); + } + + //print final result + mat2gnudata(data,filename_data,header); + cout<<"save final data to "<0){ + break; + } + // usleep(100000); + + LLRin = LLRout; + LLRout.zeros(); + ans = bp_decoder.bp_syndrome_llr(syndrome,LLRin, LLRout); + // ans = bp_syndrome_llr(H,syndrome,LLRin, LLRout, exit_iteration, decode_mode); + bitsout = LLRout < bound; + + } + + bitsout=bitsout+rec_bits+rec_bits0;//cancel input vector + //bitsout=reduce_weight( bitsout, G);//remove trivial cycles + rec_bits=rec_bits0;//replace for compatibility for saving data + + if(ans>=0){ + if ( current_iteration < 0 ){ + //cout<<"-------------------------------make it converge after iteration."<time_out){ + break; + }else if (counts_nonconverge > num_data_points){ + break; + } + + } + } + //cout<<"counts_converge="<