Skip to content

Commit

Permalink
OpenMp support removed for the time being
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumgizmos committed Nov 26, 2023
1 parent 4e90918 commit 17078c6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 37 deletions.
8 changes: 4 additions & 4 deletions cpp_test/TestBPDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ldpc::bp::BpEntry>(3);
auto bpd = ldpc::bp::BpDecoder(pcm, vector<double>{0.1,0.2,0.3,0.4}, 100, ldpc::bp::MINIMUM_SUM, ldpc::bp::SERIAL, 0.625, 1, vector<int>{2,3,1}, 1234);
auto expected_order = vector<int>{2,3,1};
ASSERT_EQ(bpd.random_schedule_seed,-1);
Expand All @@ -356,7 +356,7 @@ TEST(BpDecoder, random_schedule_seed){
}

{
auto pcm = ldpc::gf2codes::rep_code(3);
auto pcm = ldpc::gf2codes::rep_code<ldpc::bp::BpEntry>(3);
auto bpd = ldpc::bp::BpDecoder(pcm, vector<double>{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<int>{0,1,2};
ASSERT_EQ(bpd.random_schedule_seed,0);
Expand All @@ -365,7 +365,7 @@ TEST(BpDecoder, random_schedule_seed){
}

{
auto pcm = ldpc::gf2codes::rep_code(3);
auto pcm = ldpc::gf2codes::rep_code<ldpc::bp::BpEntry>(3);
auto bpd = ldpc::bp::BpDecoder(pcm, vector<double>{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<int>{0,1,2};
ASSERT_EQ(bpd.random_schedule_seed,4);
Expand All @@ -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<ldpc::bp::BpEntry>(n);
int maximum_iterations = pcm.n;
auto channel_probabilities = vector<double>(pcm.n, 0.1);

Expand Down
12 changes: 9 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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++",
)
)
Expand Down
3 changes: 0 additions & 3 deletions src_cpp/bp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <iterator>
#include <cmath>
#include <limits>
// #include <omp.h>
#include <random>
#include <chrono>
#include <stdexcept> // required for std::runtime_error
Expand Down Expand Up @@ -269,7 +268,6 @@ typedef ldpc::gf2sparse::GF2Sparse<BpEntry> 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)) {
Expand Down Expand Up @@ -514,7 +512,6 @@ typedef ldpc::gf2sparse::GF2Sparse<BpEntry> BpSparse;
}

check_indices_updated.clear();
#pragma omp for
for (auto bit_index: serial_schedule_order) {
double temp;
log_prob_ratios[bit_index] = std::log(
Expand Down
53 changes: 26 additions & 27 deletions src_cpp/gf2sparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <vector>
#include <iterator>
#include <omp.h>
#include "sparse_matrix_base.hpp"

namespace ldpc{
Expand Down Expand Up @@ -78,13 +77,13 @@ class GF2Sparse: public ldpc::sparse_matrix_base::SparseMatrixBase<ENTRY_OBJ>{
*/
std::vector<uint8_t> mulvec(std::vector<uint8_t>& 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<uint8_t>& mulvec_parallel(std::vector<uint8_t>& input_vector, std::vector<uint8_t>& 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<uint8_t>& mulvec_parallel(std::vector<uint8_t>& input_vector, std::vector<uint8_t>& output_vector);

/**
* @brief Multiplies the matrix by another matrix and returns the result as a new matrix
Expand Down Expand Up @@ -192,25 +191,25 @@ std::vector<uint8_t> GF2Sparse<ENTRY_OBJ>::mulvec(std::vector<uint8_t>& input_ve
}


template<class ENTRY_OBJ>
std::vector<uint8_t>& GF2Sparse<ENTRY_OBJ>::mulvec_parallel(std::vector<uint8_t>& input_vector, std::vector<uint8_t>& output_vector){
// Initialize the output vector to all zeros
#pragma omp for
for(int i = 0; i<this->m; 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<class ENTRY_OBJ>
// std::vector<uint8_t>& GF2Sparse<ENTRY_OBJ>::mulvec_parallel(std::vector<uint8_t>& input_vector, std::vector<uint8_t>& output_vector){
// // Initialize the output vector to all zeros
// #pragma omp for
// for(int i = 0; i<this->m; 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<typename ENTRY_OBJ>
Expand Down

0 comments on commit 17078c6

Please sign in to comment.