Skip to content

Commit

Permalink
clean files
Browse files Browse the repository at this point in the history
  • Loading branch information
WeileiZeng committed Mar 31, 2020
1 parent 32148f1 commit 2a6d056
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 178 deletions.
67 changes: 0 additions & 67 deletions makefile~

This file was deleted.

38 changes: 2 additions & 36 deletions my_bp1.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
//updated on Dec 9.
//using optimizations (compared with bp_decoding3.c)
// bits_out = llr_output < bound,
// repeat decoding
//the input become syndrome, not the error vector. (this should not be the difference or produce any differenc ein the result. If I have time, I will implement it in bp_decoding3.c
//exit at 200 ant repeat 5 times

//In order to change to z error only, there is no change needed for this code. Just use the new generating matrix. 2/10/2018
//Compared to bp_decoding2.c, in this file,I save all data for errors that converge or not converge in bp decoding.
//In this file, for toric code, we use stabilizer S=(S_x,S_z).
//errors are in the format e=(e_z,e_x). (bistin, recbits, bitsout) //not checked excatly, based on the assumption that the BP decoding in itpp doesnot know the difference between X and Z errors and operators.
//hello world
//Weilei March 26, 2020. yse c++ async to manage multi threads
// copied from bp_decoding4.c

#include <itpp/itbase.h>
#include <itpp/itcomm.h>
Expand All @@ -30,8 +20,6 @@ int main(int argc, char **argv){
char * filename_result=argv[3];//prefix for the file
double p=atof(argv[4]);
p=p/100000.0;//previous use 1000 division. Now use 100,000 division cause the thershold for toric codes seems to be around 0.1%.
// cout<<"prob p ="<<p<<endl;
//cout<<"input file -->"<<filename_G<<endl;

//parameter setup
int cycles=3000;//10000;//number of cycles: fro toric code, 10000 give reletively clear result
Expand All @@ -51,9 +39,6 @@ int main(int argc, char **argv){
// LDPC_Code C=MM_to_LDPC_Code(filename_G); //convert GF2mat saved in .mm file to LDPC_Code
//LDPC_Code C = get_test_LDPC_Code();

//LDPC_Code C(filename_G);//load code if saved in .it file with LDPC_Code format
//vec pvals = "0.01:0.01:0.1"; p.get(pvals,"pvals");// start:increment:end=inclusive

//bp decoding set up
C.set_exit_conditions(exit_at_iteration,true,true);//high perperformance. This number of iteration would not affect small errors which converges and stop very fast. Only affect those doesn't converge soon or not converge at all.
// C.set_exit_conditions(50,true,true); // 50 iterations,check syndrome always
Expand Down Expand Up @@ -234,26 +219,7 @@ cout<<"rec_bits"<<endl;
cout<<", Converge rate ="<<rate_converge<<endl;
// save_result(p,rate_converge,filename_result_p);//no need to save this. can get it by counting the size of the matrix when doing gnuplot

//save errors to files
char filename_result_ic[255];
sprintf( filename_result_ic,"%s%.5f_input_converge",filename_result,p);//append p to the file name
//cout<<E_input_converge.rows()<<endl;
GF2mat_to_MM(E_input_converge,filename_result_ic);

char filename_result_in[255];
sprintf( filename_result_in,"%s%.5f_input_nonconverge",filename_result,p);//append p to the file name
GF2mat_to_MM(E_input_nonconverge,filename_result_in);

char filename_result_oc[255];
sprintf( filename_result_oc,"%s%.5f_output_converge",filename_result,p);//append p to the file name
GF2mat_to_MM(E_output_converge,filename_result_oc);

char filename_result_on[255];
sprintf( filename_result_on,"%s%.5f_output_nonconverge",filename_result,p);//append p to the file name
GF2mat_to_MM(E_output_nonconverge,filename_result_on);

// cout<<E_input_nonconverge<<endl;
// cout<<E_input_converge<<endl;
timer.toc_print();
return 0;
}
Expand Down
51 changes: 51 additions & 0 deletions run_save_bp4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#runs bp_decoding3.out and save all the input and output errors

#try bp decoding for toric code with different size, 5,9,25,35
#added size 7,11,13
#p=0.1% to 5%
#100,000 division, 2000 means 2%

#time estimation
#size 9: 65 sec
#size 11: 100 sec
#size 13: 160 sec

make bp_decoding4.out

stabilizer_folder=data/toric/stabilizer
error_folder=data/toric/bp_decoding4
#error_folder=data/toric/temp
#test fold

#size=13
#for size in {5,7,9,11,13}
for size in {13,11,9,7,5}
#for size in 5
do

echo start run_save_bp.sh for size ${size}
date
for i in {100..5000..100}
#for i in {2000..2000..100}
do
#add G matrix on Dec 14
./bp_decoding4.out ${stabilizer_folder}/toric_S_x_size_${size}.mm ${stabilizer_folder}/toric_S_z_size_${size}.mm ${error_folder}/toric_S_size_${size}.mm_rate $i &
echo $i
num_process=`pgrep -c decoding`
while (( num_process > 15 ))
do
sleep 1
num_process=`pgrep -c decoding`
done
done

#wait
echo start \(finish\) bp_decoding 10000 cycle for size ${size} x ${size} when p is \in 100,000 division. All error saved
date
done
wait

date
echo done
#echo finish bp_decoding 10000 cycle for size ${size} x ${size} when p is \in 100,000 division. All error saved>> data/toric/bp_converge3/bp_decoding.log &
#date >> data/toric/bp_converge3/bp_decoding.log &
6 changes: 2 additions & 4 deletions temp/async_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

// a non-optimized way of checking for prime numbers:





bool is_prime (int x) {
std::cout << "wait..."<<x<<"\n";
for ( int i = 0; i<x; i++) double a=100*15-1/4.1+133.1/2.77/3.88*i+1.3*i;
Expand All @@ -32,7 +30,7 @@ int main ()
int n = 40;
std::future<int> fut[n];
for ( int i =0;i<n;i++){
fut[i] = std::async (std::launch::async,get_prime,871782918);
fut[i] = std::async (std::launch::async,get_prime,71782918);
}

int num = fut3.get();
Expand Down
Binary file modified temp/async_test.out
Binary file not shown.
2 changes: 0 additions & 2 deletions temp/makefile~

This file was deleted.

11 changes: 5 additions & 6 deletions temp/async_test.c~ → temp/prime_calculator.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

// a non-optimized way of checking for prime numbers:





bool is_prime (int x) {
std::cout << "wait..."<<x<<"\n";
for ( int i = 0; i<x; i++) double a=100*15-1/4.1+133.1/2.77/3.88*i+1.3*i;
Expand All @@ -29,9 +27,10 @@ int main ()
//std::future<bool> fut2 = std::async (is_prime,87178291199);
std::future<int> fut3 = std::async (std::launch::async,get_prime,871782922);
std::future<int> fut4 = std::async (std::launch::async,get_prime,871782920);
std::future<int> fut[10];
for ( int i =0;i<10;i++){
fut[i] = std::async (std::launch::async,get_prime,871782918);
int n = 40;
std::future<int> fut[n];
for ( int i =0;i<n;i++){
fut[i] = std::async (std::launch::async,get_prime,71782918);
}

int num = fut3.get();
Expand Down
63 changes: 0 additions & 63 deletions test.c~

This file was deleted.

0 comments on commit 2a6d056

Please sign in to comment.