diff --git a/makefile~ b/makefile~ deleted file mode 100644 index 48fb814..0000000 --- a/makefile~ +++ /dev/null @@ -1,67 +0,0 @@ -#CXX=g++ -g -Wall #for debug mode -CXX=g++ -O3 -Wall -### -O2 -O5 -Os -#g++ `pkg-config --cflags itpp` -o hello.out hello.cpp `pkg-config --libs itpp` - - - -START=`pkg-config --cflags itpp` -END=`pkg-config --libs itpp` -#files=mm_read.c mm_read.h mmio.c mmio.h mm_write.c mm_write.h lib.cpp lib.h my_lib.h makefile -#command=$(CXX) $(START) -o $@ $< $(word 2,$^) $(word 4, $^) $(word 6, $^) $(word 8, $^) $(END) - - -#update: -INC_DIR=~/working/weilei_lib -files=$(INC_DIR)/mm_read.c $(INC_DIR)/mm_read.h $(INC_DIR)/mmio.c $(INC_DIR)/mmio.h $(INC_DIR)/mm_write.c $(INC_DIR)/mm_write.h $(INC_DIR)/lib.cpp $(INC_DIR)/lib.h $(INC_DIR)/dist.c $(INC_DIR)/dist.h $(INC_DIR)/concatenation_lib.c $(INC_DIR)/concatenation_lib.h $(INC_DIR)/my_lib.h makefile -#command=$(CXX) -I../../weilei_lib $(START) -o $@ $< $(word 2,$^) $(word 4, $^) $(word 6, $^) $(word 8, $^) $(word 10, $^) $(word 12, $^) $(END) - -command=$(CXX) -I $(INC_DIR) $(START) -o $@ $< $(word 2,$^) $(word 4, $^) $(word 6, $^) $(word 8, $^) $(word 10, $^) $(word 12, $^) $(END) ; echo finish making - - - -all: parserTest.out ldpcTest.out test.out alist_test.out -###include all headfiles into my_lib.h -#pattern_observer.out:pattern_observer.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 -partial_sum.out:partial_sum.c $(files) - $(command) -pattern_observer.out:pattern_observer.c $(files) - $(command) -bp_decoding4.out:bp_decoding4.c $(files) - $(command) -my_bp1.out:my_bp1.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) -data_collect_perm_check.out:data_collect_perm_check.c $(files) - $(command) -convert_data.out:convert_data.c $(files) - $(command) -test.out:test.c $(files) - $(command) - ./test.out -# $(CXX) $(START) -o $@ $< $(word 2,$^) $(word 4, $^) $(word 6, $^) $(END) -error_analysis.out:error_analysis.c mm_read.c mm_read.h mmio.c mmio.h mm_write.c mm_write.h my_lib.h - $(CXX) $(START) -o $@ $< $(word 2,$^) $(word 4, $^) $(word 6, $^) $(END) -rand_decode_perm_check.out:rand_decode_perm_check.c mm_read.c mm_read.h mmio.c mmio.h mm_write.c mm_write.h lib.cpp lib.h my_lib.h - $(CXX) $(START) -o $@ $< $(word 2,$^) $(word 4, $^) $(word 6, $^) $(word 8, $^) $(END) -rand_decode_perm.out:rand_decode_perm.c mm_read.c mm_read.h mmio.c mmio.h mm_write.c mm_write.h lib.cpp lib.h my_lib.h - $(CXX) $(START) -o $@ $< $(word 2,$^) $(word 4, $^) $(word 6, $^) $(word 8, $^) $(END) -rand_decode3.out:rand_decode3.c mm_read.c mm_read.h mmio.c mmio.h mm_write.c mm_write.h lib.cpp lib.h my_lib.h - $(CXX) $(START) -o $@ $< $(word 2,$^) $(word 4, $^) $(word 6, $^) $(word 8, $^) $(END) -rand_decode.out:rand_decode.c mm_read.c mm_read.h mmio.c mmio.h mm_write.c mm_write.h lib.cpp lib.h my_lib.h - $(CXX) $(START) -o $@ $< $(word 2,$^) $(word 4, $^) $(word 6, $^) $(word 8, $^) $(END) -gauge_to_stabilizer.out:gauge_to_stabilizer.c mm_read.c mm_read.h mmio.c mmio.h mm_write.c mm_write.h my_lib.h - $(CXX) $(START) -o $@ $< $(word 2,$^) $(word 4, $^) $(word 6, $^) $(END) -decoding.out:decoding.c mm_read.c mm_read.h mmio.c mmio.h mm_write.c mm_write.h my_lib.h - $(CXX) $(START) -o $@ $< $(word 2,$^) $(word 4, $^) $(word 6, $^) $(END) -#test.out:test.c mm_read.c mm_read.h mmio.c mmio.h mm_write.c mm_write.h lib.cpp lib.h my_lib.h -# $(CXX) $(START) -o $@ $< $(word 2,$^) $(word 4, $^) $(word 6, $^) $(word 8, $^) $(END) -code_generator.out:code_generator.c mmio.c mmio.h mm_write.c mm_write.h - $(CXX) $(START) -o $@ $< $(word 2, $^) $(word 4, $^) $(END) -clean: - echo this command clean all temperary files in this folder. - rm *~ - rm \#* - diff --git a/my_bp1.c b/my_bp1.c index eb0a62c..2cf26c5 100644 --- a/my_bp1.c +++ b/my_bp1.c @@ -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 #include @@ -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 ="<"< 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 & diff --git a/temp/async_test.c b/temp/async_test.c index e131688..9d82c75 100644 --- a/temp/async_test.c +++ b/temp/async_test.c @@ -4,9 +4,7 @@ // a non-optimized way of checking for prime numbers: - - - + bool is_prime (int x) { std::cout << "wait..."< fut[n]; for ( int i =0;i fut2 = std::async (is_prime,87178291199); std::future fut3 = std::async (std::launch::async,get_prime,871782922); std::future fut4 = std::async (std::launch::async,get_prime,871782920); - std::future fut[10]; - for ( int i =0;i<10;i++){ - fut[i] = std::async (std::launch::async,get_prime,871782918); + int n = 40; + std::future fut[n]; + for ( int i =0;i -#include -using namespace std; - -// A dummy function -void foo(int Z) -{ - for (int i = 0; i < Z; i++) { - cout << "Thread using function" - " pointer as callable\n"; - } -} - -// A callable object -class thread_obj { - public: - void operator()(int x) - { - for (int i = 0; i < x; i++) - cout << "Thread using function" - " object as callable\n"; - } -}; - -int main() -{ - cout << "Threads 1 and 2 and 3 " - "operating independently" << endl; - - // This thread is launched by using - // function pointer as callable - thread th1(foo, 3); - - // This thread is launched by using - // function object as callable - thread th2(thread_obj(), 3); - - // Define a Lambda Expression - auto f = [](int x) { - for (int i = 0; i < x; i++) - cout << "Thread using lambda" - " expression as callable\n"; - }; - - // This thread is launched by using - // lamda expression as callable - thread th3(f, 3); - - // Wait for the threads to finish - // Wait for thread t1 to finish - th1.join(); - - // Wait for thread t2 to finish - th2.join(); - - // Wait for thread t3 to finish - th3.join(); - - return 0; -}