Skip to content

Commit

Permalink
Use LDPC matrices in QC format stored in header.
Browse files Browse the repository at this point in the history
Users don't need to generate the header manually anymore. No longer copying around files with CMake. Moves header files into a separate folder to make include directives nicer. encoder.hpp is now basically obsolete.
  • Loading branch information
Adomas Baliuka authored and Adomas Baliuka committed Jun 14, 2024
1 parent 7577af3 commit cbed3e7
Show file tree
Hide file tree
Showing 22 changed files with 10,826 additions and 100 deletions.
35 changes: 3 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,10 @@ option(LDPC4QKD_HEADER_ONLY
This only creates a CMake target that ONLY points to where the header files are!"
OFF
)
if (LDPC4QKD_HEADER_ONLY)

add_library(LDPC4QKD INTERFACE
src/rate_adaptive_code.hpp # contains decoder and encoder. Does not need any other files to work.
# TODO add `encoder_advanced` and require C++20
# encoder_advanced.hpp # REQUIRES C++20!!! advanced encoder (QC-enabled and constexpr objects). Handles storage.
src/encoder.hpp # contains only minimal encoder that needs static storage of the LDPC matrix
src/read_ldpc_file_formats.hpp # helper methods (not needed to use `rate_adaptive_code.hpp`).
)

target_compile_features(LDPC4QKD INTERFACE cxx_std_17)

target_include_directories(LDPC4QKD
INTERFACE
${CMAKE_CURRENT_LIST_DIR}/src
)

# Create alias with "namespace". This is the target to be used to link to the library in higher level projects.
add_library(LDPC4QKD::LDPC4QKD ALIAS LDPC4QKD)

else (LDPC4QKD_HEADER_ONLY)
add_subdirectory(src) # This contains header only library!

if (NOT LDPC4QKD_HEADER_ONLY)
option(LDPC4QKD_DEBUG_MESSAGES_ENABLED
"Enables the output debug messages (compile definitions using macros in the C++ code)
"
Expand Down Expand Up @@ -104,12 +86,10 @@ else (LDPC4QKD_HEADER_ONLY)
# https://cmake.org/cmake/help/v3.11/module/FeatureSummary.html
include(FeatureSummary)


# Required to enable testing for link-time optimization.
# https://cmake.org/cmake/help/v3.11/module/CheckIPOSupported.html
include(CheckIPOSupported)


# Use link-time optimization if allowed.
check_ipo_supported(RESULT ipo_supported)
if (ipo_supported)
Expand All @@ -119,7 +99,6 @@ else (LDPC4QKD_HEADER_ONLY)
message(WARNING "Link-time optimization is not supported.")
endif ()


# We attempt to use ccache to speed up the build.
find_program(CCACHE_FOUND "ccache")
if (CCACHE_FOUND)
Expand All @@ -131,30 +110,22 @@ else (LDPC4QKD_HEADER_ONLY)
message(WARNING "Using ccache to speed up the build is not possible.")
endif (CCACHE_FOUND)

# ------------------------------------------------------------------------------------------------------------------
# ----------------------------------------------- INCLUDE SUBDIRECTORIES -------------------------------------------
# ------------------------------------------------------------------------------------------------------------------

add_subdirectory(src)

add_subdirectory(examples)

if (LDPC4QKD_BUILD_ERROR_RATE_BENCHMARKS)
add_subdirectory(benchmarks_error_rate)
endif (LDPC4QKD_BUILD_ERROR_RATE_BENCHMARKS)


if (LDPC4QKD_BUILD_UNIT_TESTS)
add_subdirectory(tests)
else (LDPC4QKD_BUILD_UNIT_TESTS)
message(STATUS "Unit tests are not built, as specified by user.")
endif (LDPC4QKD_BUILD_UNIT_TESTS)


if (BUILD_RUNTIME_BENCHMARKS)
add_subdirectory(benchmarks_runtime)
else (BUILD_RUNTIME_BENCHMARKS)
message(STATUS "Runtime performance benchmarks are not built, as specified by user.")
endif (BUILD_RUNTIME_BENCHMARKS)

endif (LDPC4QKD_HEADER_ONLY)
endif (NOT LDPC4QKD_HEADER_ONLY)
4 changes: 2 additions & 2 deletions benchmarks_error_rate/code_simulation_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include "external/json-6af826d/json.hpp" // external json parser library

#include "read_ldpc_file_formats.hpp"
#include "src/rate_adaptive_code.hpp"
#include "LDPC4QKD/read_ldpc_file_formats.hpp"
#include "LDPC4QKD/rate_adaptive_code.hpp"


namespace LDPC4QKD::CodeSimulationHelpers {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks_error_rate/main_critical_rate_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ constexpr auto help_text =
#include "external/CmdParser-91aaa61e/cmdparser.hpp"

// Project scope
#include "rate_adaptive_code.hpp"
#include "LDPC4QKD/rate_adaptive_code.hpp"

#include "code_simulation_helpers.hpp"

Expand Down
2 changes: 1 addition & 1 deletion benchmarks_error_rate/main_rate_adapted_fer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ constexpr auto help_text =
#include "external/CmdParser-91aaa61e/cmdparser.hpp"

// Project scope
#include "rate_adaptive_code.hpp"
#include "LDPC4QKD/rate_adaptive_code.hpp"
#include "code_simulation_helpers.hpp"

using namespace LDPC4QKD::CodeSimulationHelpers;
Expand Down
2 changes: 1 addition & 1 deletion examples/main_demo_error_correction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// example showing how to use the LDPC belief-propagation decoder.

// Project scope
#include "rate_adaptive_code.hpp"
#include "LDPC4QKD/rate_adaptive_code.hpp"


/// Get a LDPC matrix
Expand Down
47 changes: 6 additions & 41 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,13 @@ cmake_minimum_required(VERSION 3.19)

project(LDPC4QKDLibrary)

get_filename_component(LDPC4QKD_SRC_DIR ${CMAKE_CURRENT_LIST_DIR} DIRECTORY)
get_filename_component(LDPC4QKD_TESTS_DIR "${LDPC4QKD_SRC_DIR}/tests" ABSOLUTE)

if (NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/autogen_ldpc_matrix_csc.hpp")
message(WARNING "C++ code containing the LDPC matrix not found.
Use the Julia scripts to automatically generate it form a .cscmat file! A minimal example will be generated automatically.")

add_custom_command(
OUTPUT autogen_ldpc_matrix_csc.hpp
DEPENDS "${LDPC4QKD_TESTS_DIR}/fortest_autogen_ldpc_matrix_csc.hpp"
COMMAND ${CMAKE_COMMAND} -E copy
"${LDPC4QKD_TESTS_DIR}/fortest_autogen_ldpc_matrix_csc.hpp"
"${CMAKE_CURRENT_LIST_DIR}/autogen_ldpc_matrix_csc.hpp"
VERBATIM
)
endif (NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/autogen_ldpc_matrix_csc.hpp")


if (NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/autogen_rate_adaption.hpp")
message(WARNING "C++ code containing the rate adaption for the LDPC matrix not found.
Use Julia to automatically generate it form an appropriate CSV file! A minimal example will be generated automatically.")

add_custom_command(
OUTPUT autogen_rate_adaption.hpp
DEPENDS "${LDPC4QKD_TESTS_DIR}/fortest_autogen_rate_adaption.hpp"
COMMAND ${CMAKE_COMMAND} -E copy
"${LDPC4QKD_TESTS_DIR}/fortest_autogen_rate_adaption.hpp"
"${CMAKE_CURRENT_LIST_DIR}/autogen_rate_adaption.hpp"
VERBATIM
)
endif (NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/autogen_rate_adaption.hpp")


add_library(LDPC4QKD INTERFACE
rate_adaptive_code.hpp # contains decoder and encoder. Does not need any other files to work.

encoder.hpp # contains only minimal encoder that needs static storage of the LDPC matrix
encoder_advanced.hpp # REQUIRES C++20!!! advanced encoder (QC-enabled and constexpr objects). Handles storage.
autogen_ldpc_matrix_csc.hpp # static storage of the LDPC matrix. Automatically generated by Julia script.
autogen_rate_adaption.hpp # static storage of the rate adaption specification. Automatically generated by Julia script.
read_ldpc_file_formats.hpp # helper methods to generate static storage (not needed to use encoder/decoder class).
)
LDPC4QKD/rate_adaptive_code.hpp # contains decoder and encoder. Does not need any other files to work.
LDPC4QKD/autogen_ldpc_QC.hpp
LDPC4QKD/encoder.hpp # contains only minimal encoder that needs static storage of the LDPC matrix
LDPC4QKD/encoder_advanced.hpp # REQUIRES C++20!!! advanced encoder (QC-enabled and constexpr objects). Handles storage.
LDPC4QKD/read_ldpc_file_formats.hpp # helper methods to generate static storage (not needed to use encoder/decoder class).
)

target_compile_features(LDPC4QKD INTERFACE cxx_std_20)

Expand Down
Loading

0 comments on commit cbed3e7

Please sign in to comment.