From 17078c6806cac841b34f7ce0ae97c8617528d762 Mon Sep 17 00:00:00 2001 From: Joschka Roffe Date: Sun, 26 Nov 2023 09:49:21 +0000 Subject: [PATCH] OpenMp support removed for the time being --- cpp_test/TestBPDecoder.cpp | 8 +++--- setup.py | 12 ++++++--- src_cpp/bp.hpp | 3 --- src_cpp/gf2sparse.hpp | 53 +++++++++++++++++++------------------- 4 files changed, 39 insertions(+), 37 deletions(-) diff --git a/cpp_test/TestBPDecoder.cpp b/cpp_test/TestBPDecoder.cpp index 57abe6e..8524605 100644 --- a/cpp_test/TestBPDecoder.cpp +++ b/cpp_test/TestBPDecoder.cpp @@ -347,7 +347,7 @@ TEST(BpDecoder, min_sum_single_scan){ TEST(BpDecoder, random_schedule_seed){ { - auto pcm = ldpc::gf2codes::rep_code(3); + auto pcm = ldpc::gf2codes::rep_code(3); auto bpd = ldpc::bp::BpDecoder(pcm, vector{0.1,0.2,0.3,0.4}, 100, ldpc::bp::MINIMUM_SUM, ldpc::bp::SERIAL, 0.625, 1, vector{2,3,1}, 1234); auto expected_order = vector{2,3,1}; ASSERT_EQ(bpd.random_schedule_seed,-1); @@ -356,7 +356,7 @@ TEST(BpDecoder, random_schedule_seed){ } { - auto pcm = ldpc::gf2codes::rep_code(3); + auto pcm = ldpc::gf2codes::rep_code(3); auto bpd = ldpc::bp::BpDecoder(pcm, vector{0.1,0.2,0.3,0.4}, 100, ldpc::bp::MINIMUM_SUM, ldpc::bp::SERIAL, 0.625, 1, ldpc::bp::NULL_INT_VECTOR, 0); auto expected_order = vector{0,1,2}; ASSERT_EQ(bpd.random_schedule_seed,0); @@ -365,7 +365,7 @@ TEST(BpDecoder, random_schedule_seed){ } { - auto pcm = ldpc::gf2codes::rep_code(3); + auto pcm = ldpc::gf2codes::rep_code(3); auto bpd = ldpc::bp::BpDecoder(pcm, vector{0.1,0.2,0.3,0.4}, 100, ldpc::bp::MINIMUM_SUM, ldpc::bp::SERIAL, 0.625, 1, ldpc::bp::NULL_INT_VECTOR, 4); auto expected_order = vector{0,1,2}; ASSERT_EQ(bpd.random_schedule_seed,4); @@ -378,7 +378,7 @@ TEST(BpDecoder, random_schedule_seed){ //received vector decoding TEST(BpDecoder, ProdSumSerial_RepCode5) { int n = 5; - auto pcm = ldpc::gf2codes::rep_code(n); + auto pcm = ldpc::gf2codes::rep_code(n); int maximum_iterations = pcm.n; auto channel_probabilities = vector(pcm.n, 0.1); diff --git a/setup.py b/setup.py index 8a07efc..ddb043f 100755 --- a/setup.py +++ b/setup.py @@ -102,9 +102,15 @@ def generate_cython_stub_file(pyx_filepath: str, output_filepath: str) -> None: if sys.platform == "win32": - compile_flags = ["/Ox", "/std:c++20",'-fopenmp'] + compile_flags = ["/Ox", "/std:c++20"] + extra_link_args =[] + # compile_flags = ["/Ox", "/std:c++20",'-fopenmp'] + # extra_link_args =['-lgomp','-fopenmp'], else: - compile_flags = ["-std=c++2a", "-O3",'-fopenmp'] + compile_flags = ["-std=c++2a", "-O3"] + extra_link_args =[] + # compile_flags = ["-std=c++2a", "-O3", "-fopenmp"] + # extra_link_args =['-lgomp','-fopenmp'], this_directory = Path(__file__).parent @@ -123,7 +129,7 @@ def generate_cython_stub_file(pyx_filepath: str, output_filepath: str) -> None: library_dirs=[], include_dirs=[np.get_include(),'src_cpp', 'include/robin_map','include/ldpc/src_cpp'], extra_compile_args=compile_flags, - extra_link_args=[], + extra_link_args=extra_link_args, language="c++", ) ) diff --git a/src_cpp/bp.hpp b/src_cpp/bp.hpp index 6a0cd6f..54cba61 100644 --- a/src_cpp/bp.hpp +++ b/src_cpp/bp.hpp @@ -6,7 +6,6 @@ #include #include #include -// #include #include #include #include // required for std::runtime_error @@ -269,7 +268,6 @@ typedef ldpc::gf2sparse::GF2Sparse BpSparse; //compute bit to check update -#pragma omp for for (int i = 0; i < bit_count; i++) { double temp = 0; for (auto &e: this->pcm.reverse_iterate_column(i)) { @@ -514,7 +512,6 @@ typedef ldpc::gf2sparse::GF2Sparse BpSparse; } check_indices_updated.clear(); -#pragma omp for for (auto bit_index: serial_schedule_order) { double temp; log_prob_ratios[bit_index] = std::log( diff --git a/src_cpp/gf2sparse.hpp b/src_cpp/gf2sparse.hpp index a10a67a..a8e7013 100755 --- a/src_cpp/gf2sparse.hpp +++ b/src_cpp/gf2sparse.hpp @@ -8,7 +8,6 @@ #include #include -#include #include "sparse_matrix_base.hpp" namespace ldpc{ @@ -78,13 +77,13 @@ class GF2Sparse: public ldpc::sparse_matrix_base::SparseMatrixBase{ */ std::vector mulvec(std::vector& input_vector); - /** - * @brief Multiplies the matrix by a vector with parallel execution using OpenMP and stores the result in another vector - * @param input_vector The vector to multiply the matrix with - * @param output_vector The vector to store the result in - * @return A reference to the output vector - */ - std::vector& mulvec_parallel(std::vector& input_vector, std::vector& output_vector); + // /** + // * @brief Multiplies the matrix by a vector with parallel execution using OpenMP and stores the result in another vector + // * @param input_vector The vector to multiply the matrix with + // * @param output_vector The vector to store the result in + // * @return A reference to the output vector + // */ + // std::vector& mulvec_parallel(std::vector& input_vector, std::vector& output_vector); /** * @brief Multiplies the matrix by another matrix and returns the result as a new matrix @@ -192,25 +191,25 @@ std::vector GF2Sparse::mulvec(std::vector& input_ve } -template -std::vector& GF2Sparse::mulvec_parallel(std::vector& input_vector, std::vector& output_vector){ - // Initialize the output vector to all zeros - #pragma omp for - for(int i = 0; im; i++) output_vector[i] = 0; - - // Iterate through each row of the matrix - #pragma omp for - for(int i = 0; i < this->m; i++){ - // Iterate through each non-zero entry in the row - for(auto& e: this->iterate_row(i)){ - // Compute the XOR of the current output value with the value in the input vector at the entry's column index - output_vector[i] ^= input_vector[e.col_index]; - } - } - - // Return the output vector - return output_vector; -} +// template +// std::vector& GF2Sparse::mulvec_parallel(std::vector& input_vector, std::vector& output_vector){ +// // Initialize the output vector to all zeros +// #pragma omp for +// for(int i = 0; im; i++) output_vector[i] = 0; + +// // Iterate through each row of the matrix +// #pragma omp for +// for(int i = 0; i < this->m; i++){ +// // Iterate through each non-zero entry in the row +// for(auto& e: this->iterate_row(i)){ +// // Compute the XOR of the current output value with the value in the input vector at the entry's column index +// output_vector[i] ^= input_vector[e.col_index]; +// } +// } + +// // Return the output vector +// return output_vector; +// } template