From 143e0f128a44d6a3b0681a161985631c59c57a26 Mon Sep 17 00:00:00 2001 From: Alexander Krimm Date: Fri, 6 Oct 2023 15:19:34 +0200 Subject: [PATCH] wio --- CMakeLists.txt | 2 + README.md | 2 +- algorithm/CMakeLists.txt | 7 ++ algorithm/README.md | 6 ++ .../gnuradio-4.0/algorithm/fourier}/fft.hpp | 2 - .../algorithm/fourier}/fft_common.hpp | 2 + .../algorithm/fourier}/fft_types.hpp | 3 +- .../gnuradio-4.0/algorithm/fourier}/fftw.hpp | 6 -- .../algorithm/fourier}/window.hpp | 4 +- algorithm/test/CMakeLists.txt | 2 + algorithm/test/qa_algorithm_fourier.cpp | 100 ++++++++++++++++++ blocks/CMakeLists.txt | 2 - blocks/README.md | 15 +++ .../include/gnuradio-4.0/basic/selector.hpp | 3 +- blocks/basic/test/qa_selector.cpp | 3 +- blocks/demo/CMakeLists.txt | 3 - blocks/filter/test/CMakeLists.txt | 1 + blocks/fourier/CMakeLists.txt | 2 +- .../include/gnuradio-4.0/fourier/fft.hpp | 10 +- blocks/fourier/test/CMakeLists.txt | 1 + blocks/fourier/test/qa_fourier.cpp | 80 +------------- blocks/math/CMakeLists.txt | 3 - core/CMakeLists.txt | 2 +- core/include/gnuradio-4.0/annotated.hpp | 2 +- core/include/gnuradio-4.0/claim_strategy.hpp | 3 +- core/include/gnuradio-4.0/graph.hpp | 3 +- core/include/gnuradio-4.0/node.hpp | 5 +- core/include/gnuradio-4.0/node_registry.hpp | 3 +- core/include/gnuradio-4.0/node_traits.hpp | 3 +- core/include/gnuradio-4.0/port.hpp | 3 +- core/include/gnuradio-4.0/port_traits.hpp | 3 +- .../gnuradio-4.0/reader_writer_lock.hpp | 2 +- core/include/gnuradio-4.0/tag.hpp | 3 +- core/include/gnuradio-4.0/transactions.hpp | 4 +- core/test/CMakeLists.txt | 5 +- core/test/app_plugins_test.cpp | 3 +- core/test/qa_dynamic_port.cpp | 3 +- meta/CMakeLists.txt | 7 ++ meta/README.md | 3 + .../include/gnuradio-4.0/meta}/typelist.hpp | 0 .../include/gnuradio-4.0/meta}/utils.hpp | 0 meta/test/CMakeLists.txt | 2 + {core => meta}/test/qa_traits.cpp | 2 +- 43 files changed, 196 insertions(+), 124 deletions(-) create mode 100644 algorithm/CMakeLists.txt create mode 100644 algorithm/README.md rename {core/include/gnuradio-4.0/algorithm/fft => algorithm/include/gnuradio-4.0/algorithm/fourier}/fft.hpp (99%) rename {core/include/gnuradio-4.0/algorithm/fft => algorithm/include/gnuradio-4.0/algorithm/fourier}/fft_common.hpp (98%) rename {core/include/gnuradio-4.0/algorithm/fft => algorithm/include/gnuradio-4.0/algorithm/fourier}/fft_types.hpp (94%) rename {core/include/gnuradio-4.0/algorithm/fft => algorithm/include/gnuradio-4.0/algorithm/fourier}/fftw.hpp (98%) rename {core/include/gnuradio-4.0/algorithm/fft => algorithm/include/gnuradio-4.0/algorithm/fourier}/window.hpp (99%) create mode 100644 algorithm/test/CMakeLists.txt create mode 100644 algorithm/test/qa_algorithm_fourier.cpp create mode 100644 blocks/README.md delete mode 100644 blocks/demo/CMakeLists.txt delete mode 100644 blocks/math/CMakeLists.txt create mode 100644 meta/CMakeLists.txt create mode 100644 meta/README.md rename {core/include/gnuradio-4.0 => meta/include/gnuradio-4.0/meta}/typelist.hpp (100%) rename {core/include/gnuradio-4.0 => meta/include/gnuradio-4.0/meta}/utils.hpp (100%) create mode 100644 meta/test/CMakeLists.txt rename {core => meta}/test/qa_traits.cpp (96%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 405ae685b..e1e80ccdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,4 +166,6 @@ endif () add_subdirectory(bench) # custom ut addon for microbenchmarking add_subdirectory(core) +add_subdirectory(meta) +add_subdirectory(algorithm) add_subdirectory(blocks) diff --git a/README.md b/README.md index dece633e6..0b665731a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![License](https://img.shields.io/badge/License-LGPL%203.0-blue.svg)](https://opensource.org/licenses/LGPL-3.0) ![CMake](https://github.com/fair-acc/graph-prototype/workflows/CMake/badge.svg) -# Graph Prototype +# GNURadio 4.0 prototype A small proof-of-concept for evaluating efficient [directed graph](https://en.wikipedia.org/wiki/Directed_graph)-based algorithms, notably required node structures, scheduling interfaces, and partial compile-time merging of [directed acyclic](https://en.wikipedia.org/wiki/Directed_acyclic_graph) as well as diff --git a/algorithm/CMakeLists.txt b/algorithm/CMakeLists.txt new file mode 100644 index 000000000..f40756e2c --- /dev/null +++ b/algorithm/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(gnuradio-algorithm INTERFACE) +target_include_directories(gnuradio-algorithm INTERFACE $ $) +target_link_libraries(gnuradio-algorithm INTERFACE gnuradio-options gnuradio-meta vir fftw) + +if (ENABLE_TESTING) + add_subdirectory(test) +endif () \ No newline at end of file diff --git a/algorithm/README.md b/algorithm/README.md new file mode 100644 index 000000000..1dcf0f2ce --- /dev/null +++ b/algorithm/README.md @@ -0,0 +1,6 @@ +# gnuradio-algorithm + +A math support library with math primitives to be used by different block types. + +Included algorithms: + - Fast Fourier Transform \ No newline at end of file diff --git a/core/include/gnuradio-4.0/algorithm/fft/fft.hpp b/algorithm/include/gnuradio-4.0/algorithm/fourier/fft.hpp similarity index 99% rename from core/include/gnuradio-4.0/algorithm/fft/fft.hpp rename to algorithm/include/gnuradio-4.0/algorithm/fourier/fft.hpp index 7955d67ba..42695e0bf 100644 --- a/core/include/gnuradio-4.0/algorithm/fft/fft.hpp +++ b/algorithm/include/gnuradio-4.0/algorithm/fourier/fft.hpp @@ -3,8 +3,6 @@ #include -#include - #include "fft_types.hpp" #include "window.hpp" diff --git a/core/include/gnuradio-4.0/algorithm/fft/fft_common.hpp b/algorithm/include/gnuradio-4.0/algorithm/fourier/fft_common.hpp similarity index 98% rename from core/include/gnuradio-4.0/algorithm/fft/fft_common.hpp rename to algorithm/include/gnuradio-4.0/algorithm/fourier/fft_common.hpp index bd312156b..908b13305 100644 --- a/core/include/gnuradio-4.0/algorithm/fft/fft_common.hpp +++ b/algorithm/include/gnuradio-4.0/algorithm/fourier/fft_common.hpp @@ -5,6 +5,8 @@ #include #include +#include + #include "fft_types.hpp" namespace gr::algorithm { diff --git a/core/include/gnuradio-4.0/algorithm/fft/fft_types.hpp b/algorithm/include/gnuradio-4.0/algorithm/fourier/fft_types.hpp similarity index 94% rename from core/include/gnuradio-4.0/algorithm/fft/fft_types.hpp rename to algorithm/include/gnuradio-4.0/algorithm/fourier/fft_types.hpp index 8d24d715e..7eb4f54ea 100644 --- a/core/include/gnuradio-4.0/algorithm/fft/fft_types.hpp +++ b/algorithm/include/gnuradio-4.0/algorithm/fourier/fft_types.hpp @@ -1,7 +1,8 @@ #ifndef GRAPH_PROTOTYPE_ALGORITHM_FFT_TYPES_HPP #define GRAPH_PROTOTYPE_ALGORITHM_FFT_TYPES_HPP -#include +#include +#include namespace gr::algorithm { template diff --git a/core/include/gnuradio-4.0/algorithm/fft/fftw.hpp b/algorithm/include/gnuradio-4.0/algorithm/fourier/fftw.hpp similarity index 98% rename from core/include/gnuradio-4.0/algorithm/fft/fftw.hpp rename to algorithm/include/gnuradio-4.0/algorithm/fourier/fftw.hpp index 3086df9a4..2bcba9a8b 100644 --- a/core/include/gnuradio-4.0/algorithm/fft/fftw.hpp +++ b/algorithm/include/gnuradio-4.0/algorithm/fourier/fftw.hpp @@ -3,17 +3,11 @@ #include -#include -#include -#include - #include "fft_types.hpp" #include "window.hpp" namespace gr::algorithm { -using namespace fair::graph; - template concept FFTwDoubleType = std::is_same_v> || std::is_same_v; diff --git a/core/include/gnuradio-4.0/algorithm/fft/window.hpp b/algorithm/include/gnuradio-4.0/algorithm/fourier/window.hpp similarity index 99% rename from core/include/gnuradio-4.0/algorithm/fft/window.hpp rename to algorithm/include/gnuradio-4.0/algorithm/fourier/window.hpp index 05ce63eaf..5ba1f6949 100644 --- a/core/include/gnuradio-4.0/algorithm/fft/window.hpp +++ b/algorithm/include/gnuradio-4.0/algorithm/fourier/window.hpp @@ -10,10 +10,10 @@ #include #include -#include - #include +#include + namespace gr::algorithm::window { /** diff --git a/algorithm/test/CMakeLists.txt b/algorithm/test/CMakeLists.txt new file mode 100644 index 000000000..f1253aa45 --- /dev/null +++ b/algorithm/test/CMakeLists.txt @@ -0,0 +1,2 @@ +add_ut_test(qa_algorithm_fourier) +target_link_libraries(qa_algorithm_fourier PRIVATE gnuradio-algorithm) \ No newline at end of file diff --git a/algorithm/test/qa_algorithm_fourier.cpp b/algorithm/test/qa_algorithm_fourier.cpp new file mode 100644 index 000000000..84ddb2b31 --- /dev/null +++ b/algorithm/test/qa_algorithm_fourier.cpp @@ -0,0 +1,100 @@ +#include + +#include + +#include + +#include +#include + +template +bool +equalVectors(const std::vector &v1, const std::vector &v2, double tolerance = std::is_same_v ? 1.e-5 : 1e-4) { + if (v1.size() != v2.size()) { + return false; + } + if constexpr (gr::algorithm::ComplexType) { + return std::equal(v1.begin(), v1.end(), v2.begin(), [&tolerance](const auto &l, const auto &r) { + return std::abs(l.real() - r.real()) < static_cast(tolerance) && std::abs(l.imag() - r.imag()) < static_cast(tolerance); + }); + } else { + return std::equal(v1.begin(), v1.end(), v2.begin(), [&tolerance](const auto &l, const auto &r) { return std::abs(static_cast(l) - static_cast(r)) < tolerance; }); + } +} + +const boost::ut::suite<"window functions"> windowTests = [] { + using namespace boost::ut; + using namespace boost::ut::reflection; + using gr::algorithm::window::create; + + "window pre-computed array tests"_test = []() { // this tests regression w.r.t. changed implementations + // Expected value for size 8 + std::vector Rectangular8{ 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f }; + std::vector Hamming8{ 0.07672f, 0.2119312255f, 0.53836f, 0.8647887745f, 1.0f, 0.8647887745f, 0.53836f, 0.2119312255f }; + std::vector Hann8{ 0.f, 0.1882550991f, 0.611260467f, 0.950484434f, 0.950484434f, 0.611260467f, 0.1882550991f, 0.f }; + std::vector Blackman8{ 0.f, 0.09045342435f, 0.4591829575f, 0.9203636181f, 0.9203636181f, 0.4591829575f, 0.09045342435f, 0.f }; + std::vector BlackmanHarris8{ 0.00006f, 0.03339172348f, 0.3328335043f, 0.8893697722f, 0.8893697722f, 0.3328335043f, 0.03339172348f, 0.00006f }; + std::vector BlackmanNuttall8{ 0.0003628f, 0.03777576895f, 0.34272762f, 0.8918518611f, 0.8918518611f, 0.34272762f, 0.03777576895f, 0.0003628f }; + std::vector Exponential8{ 1.f, 1.042546905f, 1.08690405f, 1.133148453f, 1.181360413f, 1.231623642f, 1.284025417f, 1.338656724f }; + std::vector FlatTop8{ 0.004f, -0.1696424054f, 0.04525319348f, 3.622389212f, 3.622389212f, 0.04525319348f, -0.1696424054f, 0.004f }; + std::vector HannExp8{ 0.f, 0.611260467f, 0.950484434f, 0.1882550991f, 0.1882550991f, 0.950484434f, 0.611260467f, 0.f }; + std::vector Nuttall8{ 0.f, 0.0311427368f, 0.3264168059f, 0.8876284573f, 0.8876284573f, 0.3264168059f, 0.0311427368f, 0.f }; + std::vector Kaiser8{ 0.5714348848f, 0.7650986027f, 0.9113132365f, 0.9899091685f, 0.9899091685f, 0.9113132365f, 0.7650986027f, 0.5714348848f }; + + // check all windows for unwanted changes + using enum gr::algorithm::window::Type; + expect(equalVectors(create(None, 8), Rectangular8)) << fmt::format("<{}> equal Rectangular8[8] vector {} vs. ref: {}", type_name(), create(None, 8), Rectangular8); + expect(equalVectors(create(Rectangular, 8), Rectangular8)) << fmt::format("<{}> equal Rectangular[8]vector {} vs. ref: {}", type_name(), create(Rectangular, 8), Rectangular8); + expect(equalVectors(create(Hamming, 8), Hamming8)) << fmt::format("<{}> equal Hamming[8] vector {} vs. ref: {}", type_name(), create(Hamming, 8), Hamming8); + expect(equalVectors(create(Hann, 8), Hann8)) << fmt::format("<{}> equal Hann[8] vector {} vs. ref: {}", type_name(), create(Hann, 8), Hann8); + expect(equalVectors(create(Blackman, 8), Blackman8)) << fmt::format("<{}> equal Blackman[8] vvector {} vs. ref: {}", type_name(), create(Blackman, 8), Blackman8); + expect(equalVectors(create(BlackmanHarris, 8), BlackmanHarris8)) + << fmt::format("<{}> equal BlackmanHarris[8] vector {} vs. ref: {}", type_name(), create(BlackmanHarris, 8), BlackmanHarris8); + expect(equalVectors(create(BlackmanNuttall, 8), BlackmanNuttall8)) + << fmt::format("<{}> equal BlackmanNuttall[8] vector {} vs. ref: {}", type_name(), create(BlackmanNuttall, 8), BlackmanNuttall8); + expect(equalVectors(create(Exponential, 8), Exponential8)) << fmt::format("<{}> equal Exponential[8] vector {} vs. ref: {}", type_name(), create(Exponential, 8), Exponential8); + expect(equalVectors(create(FlatTop, 8), FlatTop8)) << fmt::format("<{}> equal FlatTop[8] vector {} vs. ref: {}", type_name(), create(FlatTop, 8), FlatTop8); + expect(equalVectors(create(HannExp, 8), HannExp8)) << fmt::format("<{}> equal HannExp[8] vector {} vs. ref: {}", type_name(), create(HannExp, 8), HannExp8); + expect(equalVectors(create(Nuttall, 8), Nuttall8)) << fmt::format("<{}> equal Nuttall[8] vector {} vs. ref: {}", type_name(), create(Nuttall, 8), Nuttall8); + expect(equalVectors(create(Kaiser, 8), Kaiser8)) << fmt::format("<{}> equal Kaiser[8] vector {} vs. ref: {}", type_name(), create(Kaiser, 8), Kaiser8); + + // test zero length + expect(eq(create(None, 0).size(), 0u)) << fmt::format("<{}> zero size None[8] vectors", type_name()); + expect(eq(create(Rectangular, 0).size(), 0u)) << fmt::format("<{}> zero size Rectangular[8] vectors", type_name()); + expect(eq(create(Hamming, 0).size(), 0u)) << fmt::format("<{}> zero size Hamming[8] vectors", type_name()); + expect(eq(create(Hann, 0).size(), 0u)) << fmt::format("<{}> zero size Hann[8] vectors", type_name()); + expect(eq(create(Blackman, 0).size(), 0u)) << fmt::format("<{}> zero size Blackman[8] vectors", type_name()); + expect(eq(create(BlackmanHarris, 0).size(), 0u)) << fmt::format("<{}> zero size BlackmanHarris[8] vectors", type_name()); + expect(eq(create(BlackmanNuttall, 0).size(), 0u)) << fmt::format("<{}> zero size BlackmanNuttall[8] vectors", type_name()); + expect(eq(create(Exponential, 0).size(), 0u)) << fmt::format("<{}> zero size Exponential[8] vectors", type_name()); + expect(eq(create(FlatTop, 0).size(), 0u)) << fmt::format("<{}> zero size FlatTop[8] vectors", type_name()); + expect(eq(create(HannExp, 0).size(), 0u)) << fmt::format("<{}> zero size HannExp[8] vectors", type_name()); + expect(eq(create(Nuttall, 0).size(), 0u)) << fmt::format("<{}> zero size Nuttall[8] vectors", type_name()); + expect(eq(create(Kaiser, 0).size(), 0u)) << fmt::format("<{}> zero size Kaiser[8] vectors", type_name()); + } | std::tuple(); + + "basic window tests"_test = [](gr::algorithm::window::Type window) { + using enum gr::algorithm::window::Type; + expect(gr::algorithm::window::parse(gr::algorithm::window::to_string(window)) == window) << fmt::format("window {} parse(to_string) identity\n", gr::algorithm::window::to_string(window)); + + const auto w = create(window, 1024U); + expect(eq(w.size(), 1024U)); + + if (window == Exponential || window == FlatTop || window == Blackman || window == Nuttall) { + return; // min max out of [0, 1] by design and/or numerical corner cases + } + const auto [min, max] = std::ranges::minmax_element(w); + expect(ge(*min, 0.f)) << fmt::format("window {} min value\n", gr::algorithm::window::to_string(window)); + expect(le(*max, 1.f)) << fmt::format("window {} max value\n", gr::algorithm::window::to_string(window)); + } | gr::algorithm::window::TypeList; + + "window corner cases"_test = []() { + expect(throws([] { std::ignore = gr::algorithm::window::parse("UnknownWindow"); })) << "invalid window name"; + expect(throws([] { std::ignore = create(gr::algorithm::window::Type::Kaiser, 1); })) << "invalid Kaiser window size"; + expect(throws([] { std::ignore = create(gr::algorithm::window::Type::Kaiser, 2, -1.f); })) << "invalid Kaiser window beta"; + } | std::tuple(); +}; + +int +main() { /* not needed for UT */ +} diff --git a/blocks/CMakeLists.txt b/blocks/CMakeLists.txt index 591814431..b41d21c0d 100644 --- a/blocks/CMakeLists.txt +++ b/blocks/CMakeLists.txt @@ -1,9 +1,7 @@ add_subdirectory(basic) add_subdirectory(filter) add_subdirectory(fourier) -add_subdirectory(math) if (ENABLE_TESTING) add_subdirectory(testing) - add_subdirectory(demo) endif () diff --git a/blocks/README.md b/blocks/README.md new file mode 100644 index 000000000..1925c3ee4 --- /dev/null +++ b/blocks/README.md @@ -0,0 +1,15 @@ +# gnuradio blocks + +This directory contains collections of blocks by topic. + +Structure of a block, entries in square brackets are optional: + +- + - include/gnuradio-4.0// + - one or more headers which each can contain one or more block definitions + - test + - qa_ - tests for a block + - CMakeLists.txt + - README.md - a short description of the block library + - [src] - containing optional samples + - [assets] - additional block documentation \ No newline at end of file diff --git a/blocks/basic/include/gnuradio-4.0/basic/selector.hpp b/blocks/basic/include/gnuradio-4.0/basic/selector.hpp index d6ba85f4a..e3bc341dd 100644 --- a/blocks/basic/include/gnuradio-4.0/basic/selector.hpp +++ b/blocks/basic/include/gnuradio-4.0/basic/selector.hpp @@ -2,7 +2,8 @@ #define GRAPH_PROTOTYPE_SELECTOR_HPP #include -#include + +#include namespace gr::blocks::basic { using namespace fair::graph; diff --git a/blocks/basic/test/qa_selector.cpp b/blocks/basic/test/qa_selector.cpp index 555ac48fc..717b64e9c 100644 --- a/blocks/basic/test/qa_selector.cpp +++ b/blocks/basic/test/qa_selector.cpp @@ -3,9 +3,10 @@ #include +#include + #include #include -#include #include diff --git a/blocks/demo/CMakeLists.txt b/blocks/demo/CMakeLists.txt deleted file mode 100644 index 68e60e3d9..000000000 --- a/blocks/demo/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_library(gr-demo INTERFACE) -target_link_libraries(gr-demo INTERFACE gnuradio-core) -target_include_directories(gr-demo INTERFACE $ $) diff --git a/blocks/filter/test/CMakeLists.txt b/blocks/filter/test/CMakeLists.txt index e1365a931..922b60770 100644 --- a/blocks/filter/test/CMakeLists.txt +++ b/blocks/filter/test/CMakeLists.txt @@ -1 +1,2 @@ add_ut_test(qa_filter) +target_link_libraries(qa_filter PRIVATE gr-filter) diff --git a/blocks/fourier/CMakeLists.txt b/blocks/fourier/CMakeLists.txt index 57325e816..7d56e3917 100644 --- a/blocks/fourier/CMakeLists.txt +++ b/blocks/fourier/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(gr-fourier INTERFACE) -target_link_libraries(gr-fourier INTERFACE gnuradio-core) +target_link_libraries(gr-fourier INTERFACE gnuradio-core gnuradio-algorithm) target_include_directories(gr-fourier INTERFACE $ $) if (ENABLE_TESTING) diff --git a/blocks/fourier/include/gnuradio-4.0/fourier/fft.hpp b/blocks/fourier/include/gnuradio-4.0/fourier/fft.hpp index ec1484a95..4085daff7 100644 --- a/blocks/fourier/include/gnuradio-4.0/fourier/fft.hpp +++ b/blocks/fourier/include/gnuradio-4.0/fourier/fft.hpp @@ -7,11 +7,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace gr::blocks::fft { diff --git a/blocks/fourier/test/CMakeLists.txt b/blocks/fourier/test/CMakeLists.txt index db92022ce..9c432411a 100644 --- a/blocks/fourier/test/CMakeLists.txt +++ b/blocks/fourier/test/CMakeLists.txt @@ -1 +1,2 @@ add_ut_test(qa_fourier) +target_link_libraries(qa_fourier PRIVATE gr-fourier) \ No newline at end of file diff --git a/blocks/fourier/test/qa_fourier.cpp b/blocks/fourier/test/qa_fourier.cpp index 76447f1a3..0ca52933a 100644 --- a/blocks/fourier/test/qa_fourier.cpp +++ b/blocks/fourier/test/qa_fourier.cpp @@ -7,8 +7,10 @@ #include #include #include -#include -#include + +#include +#include + #include #if defined(__clang__) && __clang_major__ >= 16 @@ -359,80 +361,6 @@ const boost::ut::suite<"Fourier Transforms"> fftTests = [] { } | typesWithAlgoToTest; }; -const boost::ut::suite<"window functions"> windowTests = [] { - using namespace boost::ut; - using namespace gr::blocks::fft; - using namespace boost::ut::reflection; - using gr::algorithm::window::create; - - "window pre-computed array tests"_test = []() { // this tests regression w.r.t. changed implementations - // Expected value for size 8 - std::vector Rectangular8{ 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f }; - std::vector Hamming8{ 0.07672f, 0.2119312255f, 0.53836f, 0.8647887745f, 1.0f, 0.8647887745f, 0.53836f, 0.2119312255f }; - std::vector Hann8{ 0.f, 0.1882550991f, 0.611260467f, 0.950484434f, 0.950484434f, 0.611260467f, 0.1882550991f, 0.f }; - std::vector Blackman8{ 0.f, 0.09045342435f, 0.4591829575f, 0.9203636181f, 0.9203636181f, 0.4591829575f, 0.09045342435f, 0.f }; - std::vector BlackmanHarris8{ 0.00006f, 0.03339172348f, 0.3328335043f, 0.8893697722f, 0.8893697722f, 0.3328335043f, 0.03339172348f, 0.00006f }; - std::vector BlackmanNuttall8{ 0.0003628f, 0.03777576895f, 0.34272762f, 0.8918518611f, 0.8918518611f, 0.34272762f, 0.03777576895f, 0.0003628f }; - std::vector Exponential8{ 1.f, 1.042546905f, 1.08690405f, 1.133148453f, 1.181360413f, 1.231623642f, 1.284025417f, 1.338656724f }; - std::vector FlatTop8{ 0.004f, -0.1696424054f, 0.04525319348f, 3.622389212f, 3.622389212f, 0.04525319348f, -0.1696424054f, 0.004f }; - std::vector HannExp8{ 0.f, 0.611260467f, 0.950484434f, 0.1882550991f, 0.1882550991f, 0.950484434f, 0.611260467f, 0.f }; - std::vector Nuttall8{ 0.f, 0.0311427368f, 0.3264168059f, 0.8876284573f, 0.8876284573f, 0.3264168059f, 0.0311427368f, 0.f }; - std::vector Kaiser8{ 0.5714348848f, 0.7650986027f, 0.9113132365f, 0.9899091685f, 0.9899091685f, 0.9113132365f, 0.7650986027f, 0.5714348848f }; - - // check all windows for unwanted changes - using enum gr::algorithm::window::Type; - expect(equalVectors(create(None, 8), Rectangular8)) << fmt::format("<{}> equal Rectangular8[8] vector {} vs. ref: {}", type_name(), create(None, 8), Rectangular8); - expect(equalVectors(create(Rectangular, 8), Rectangular8)) << fmt::format("<{}> equal Rectangular[8]vector {} vs. ref: {}", type_name(), create(Rectangular, 8), Rectangular8); - expect(equalVectors(create(Hamming, 8), Hamming8)) << fmt::format("<{}> equal Hamming[8] vector {} vs. ref: {}", type_name(), create(Hamming, 8), Hamming8); - expect(equalVectors(create(Hann, 8), Hann8)) << fmt::format("<{}> equal Hann[8] vector {} vs. ref: {}", type_name(), create(Hann, 8), Hann8); - expect(equalVectors(create(Blackman, 8), Blackman8)) << fmt::format("<{}> equal Blackman[8] vvector {} vs. ref: {}", type_name(), create(Blackman, 8), Blackman8); - expect(equalVectors(create(BlackmanHarris, 8), BlackmanHarris8)) - << fmt::format("<{}> equal BlackmanHarris[8] vector {} vs. ref: {}", type_name(), create(BlackmanHarris, 8), BlackmanHarris8); - expect(equalVectors(create(BlackmanNuttall, 8), BlackmanNuttall8)) - << fmt::format("<{}> equal BlackmanNuttall[8] vector {} vs. ref: {}", type_name(), create(BlackmanNuttall, 8), BlackmanNuttall8); - expect(equalVectors(create(Exponential, 8), Exponential8)) << fmt::format("<{}> equal Exponential[8] vector {} vs. ref: {}", type_name(), create(Exponential, 8), Exponential8); - expect(equalVectors(create(FlatTop, 8), FlatTop8)) << fmt::format("<{}> equal FlatTop[8] vector {} vs. ref: {}", type_name(), create(FlatTop, 8), FlatTop8); - expect(equalVectors(create(HannExp, 8), HannExp8)) << fmt::format("<{}> equal HannExp[8] vector {} vs. ref: {}", type_name(), create(HannExp, 8), HannExp8); - expect(equalVectors(create(Nuttall, 8), Nuttall8)) << fmt::format("<{}> equal Nuttall[8] vector {} vs. ref: {}", type_name(), create(Nuttall, 8), Nuttall8); - expect(equalVectors(create(Kaiser, 8), Kaiser8)) << fmt::format("<{}> equal Kaiser[8] vector {} vs. ref: {}", type_name(), create(Kaiser, 8), Kaiser8); - - // test zero length - expect(eq(create(None, 0).size(), 0u)) << fmt::format("<{}> zero size None[8] vectors", type_name()); - expect(eq(create(Rectangular, 0).size(), 0u)) << fmt::format("<{}> zero size Rectangular[8] vectors", type_name()); - expect(eq(create(Hamming, 0).size(), 0u)) << fmt::format("<{}> zero size Hamming[8] vectors", type_name()); - expect(eq(create(Hann, 0).size(), 0u)) << fmt::format("<{}> zero size Hann[8] vectors", type_name()); - expect(eq(create(Blackman, 0).size(), 0u)) << fmt::format("<{}> zero size Blackman[8] vectors", type_name()); - expect(eq(create(BlackmanHarris, 0).size(), 0u)) << fmt::format("<{}> zero size BlackmanHarris[8] vectors", type_name()); - expect(eq(create(BlackmanNuttall, 0).size(), 0u)) << fmt::format("<{}> zero size BlackmanNuttall[8] vectors", type_name()); - expect(eq(create(Exponential, 0).size(), 0u)) << fmt::format("<{}> zero size Exponential[8] vectors", type_name()); - expect(eq(create(FlatTop, 0).size(), 0u)) << fmt::format("<{}> zero size FlatTop[8] vectors", type_name()); - expect(eq(create(HannExp, 0).size(), 0u)) << fmt::format("<{}> zero size HannExp[8] vectors", type_name()); - expect(eq(create(Nuttall, 0).size(), 0u)) << fmt::format("<{}> zero size Nuttall[8] vectors", type_name()); - expect(eq(create(Kaiser, 0).size(), 0u)) << fmt::format("<{}> zero size Kaiser[8] vectors", type_name()); - } | std::tuple(); - - "basic window tests"_test = [](gr::algorithm::window::Type window) { - using enum gr::algorithm::window::Type; - expect(gr::algorithm::window::parse(gr::algorithm::window::to_string(window)) == window) << fmt::format("window {} parse(to_string) identity\n", gr::algorithm::window::to_string(window)); - - const auto w = create(window, 1024U); - expect(eq(w.size(), 1024U)); - - if (window == Exponential || window == FlatTop || window == Blackman || window == Nuttall) { - return; // min max out of [0, 1] by design and/or numerical corner cases - } - const auto [min, max] = std::ranges::minmax_element(w); - expect(ge(*min, 0.f)) << fmt::format("window {} min value\n", gr::algorithm::window::to_string(window)); - expect(le(*max, 1.f)) << fmt::format("window {} max value\n", gr::algorithm::window::to_string(window)); - } | gr::algorithm::window::TypeList; - - "window corner cases"_test = []() { - expect(throws([] { std::ignore = gr::algorithm::window::parse("UnknownWindow"); })) << "invalid window name"; - expect(throws([] { std::ignore = create(gr::algorithm::window::Type::Kaiser, 1); })) << "invalid Kaiser window size"; - expect(throws([] { std::ignore = create(gr::algorithm::window::Type::Kaiser, 2, -1.f); })) << "invalid Kaiser window beta"; - } | std::tuple(); -}; - int main() { /* not needed for UT */ } diff --git a/blocks/math/CMakeLists.txt b/blocks/math/CMakeLists.txt deleted file mode 100644 index 928e16991..000000000 --- a/blocks/math/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_library(gr-math INTERFACE) -target_link_libraries(gr-math INTERFACE gnuradio-core) -target_include_directories(gr-math INTERFACE $ $) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 136d876e6..f1e396a5a 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,6 +1,6 @@ add_library(gnuradio-core INTERFACE) target_include_directories(gnuradio-core INTERFACE $ $ $) -target_link_libraries(gnuradio-core INTERFACE gnuradio-options refl-cpp::refl-cpp pmtv vir) +target_link_libraries(gnuradio-core INTERFACE gnuradio-options gnuradio-meta refl-cpp::refl-cpp pmtv vir) # configure a header file to pass the CMake settings to the source code configure_file("${PROJECT_SOURCE_DIR}/cmake/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/include/gnuradio-4.0/config.h" @ONLY) diff --git a/core/include/gnuradio-4.0/annotated.hpp b/core/include/gnuradio-4.0/annotated.hpp index d677fec91..e877f639a 100644 --- a/core/include/gnuradio-4.0/annotated.hpp +++ b/core/include/gnuradio-4.0/annotated.hpp @@ -5,7 +5,7 @@ #include #include -#include "utils.hpp" +#include namespace fair::graph { diff --git a/core/include/gnuradio-4.0/claim_strategy.hpp b/core/include/gnuradio-4.0/claim_strategy.hpp index 9a0fcd704..8c65aadff 100644 --- a/core/include/gnuradio-4.0/claim_strategy.hpp +++ b/core/include/gnuradio-4.0/claim_strategy.hpp @@ -9,8 +9,9 @@ #include #include +#include + #include "sequence.hpp" -#include "utils.hpp" #include "wait_strategy.hpp" namespace gr { diff --git a/core/include/gnuradio-4.0/graph.hpp b/core/include/gnuradio-4.0/graph.hpp index 68fa9988d..6e7a8b020 100644 --- a/core/include/gnuradio-4.0/graph.hpp +++ b/core/include/gnuradio-4.0/graph.hpp @@ -1,12 +1,13 @@ #ifndef GNURADIO_GRAPH_HPP #define GNURADIO_GRAPH_HPP +#include + #include "buffer.hpp" #include "circular_buffer.hpp" #include "node.hpp" #include "port.hpp" #include "sequence.hpp" -#include "typelist.hpp" #include "thread/thread_pool.hpp" #include diff --git a/core/include/gnuradio-4.0/node.hpp b/core/include/gnuradio-4.0/node.hpp index e0fcdbdc1..423a23d4a 100644 --- a/core/include/gnuradio-4.0/node.hpp +++ b/core/include/gnuradio-4.0/node.hpp @@ -4,13 +4,14 @@ #include #include +#include +#include + #include "node_traits.hpp" #include "port.hpp" #include "sequence.hpp" #include "tag.hpp" #include "thread/thread_pool.hpp" -#include "typelist.hpp" -#include "utils.hpp" #include "annotated.hpp" // This needs to be included after fmt/format.h, as it defines formatters only if FMT_FORMAT_H_ is defined #include "reflection.hpp" diff --git a/core/include/gnuradio-4.0/node_registry.hpp b/core/include/gnuradio-4.0/node_registry.hpp index 2b4d10e40..a31a50785 100644 --- a/core/include/gnuradio-4.0/node_registry.hpp +++ b/core/include/gnuradio-4.0/node_registry.hpp @@ -5,8 +5,9 @@ #include #include +#include + #include "graph.hpp" -#include "utils.hpp" namespace fair::graph { diff --git a/core/include/gnuradio-4.0/node_traits.hpp b/core/include/gnuradio-4.0/node_traits.hpp index 5f1c0750d..38b01792d 100644 --- a/core/include/gnuradio-4.0/node_traits.hpp +++ b/core/include/gnuradio-4.0/node_traits.hpp @@ -1,10 +1,11 @@ #ifndef GNURADIO_NODE_NODE_TRAITS_HPP #define GNURADIO_NODE_NODE_TRAITS_HPP +#include + #include "reflection.hpp" #include "port.hpp" #include "port_traits.hpp" -#include "utils.hpp" #include diff --git a/core/include/gnuradio-4.0/port.hpp b/core/include/gnuradio-4.0/port.hpp index 375d4e868..e77ef44fc 100644 --- a/core/include/gnuradio-4.0/port.hpp +++ b/core/include/gnuradio-4.0/port.hpp @@ -5,12 +5,13 @@ #include #include +#include + #include "dataset.hpp" #include "node.hpp" #include "annotated.hpp" #include "circular_buffer.hpp" #include "tag.hpp" -#include "utils.hpp" namespace fair::graph { diff --git a/core/include/gnuradio-4.0/port_traits.hpp b/core/include/gnuradio-4.0/port_traits.hpp index f98b221f9..aeb05972b 100644 --- a/core/include/gnuradio-4.0/port_traits.hpp +++ b/core/include/gnuradio-4.0/port_traits.hpp @@ -1,8 +1,9 @@ #ifndef GNURADIO_NODE_PORT_TRAITS_HPP #define GNURADIO_NODE_PORT_TRAITS_HPP +#include + #include "port.hpp" -#include "utils.hpp" namespace fair::graph::traits::port { diff --git a/core/include/gnuradio-4.0/reader_writer_lock.hpp b/core/include/gnuradio-4.0/reader_writer_lock.hpp index 25d0127a0..31df24504 100644 --- a/core/include/gnuradio-4.0/reader_writer_lock.hpp +++ b/core/include/gnuradio-4.0/reader_writer_lock.hpp @@ -4,7 +4,7 @@ #include #include -#include "utils.hpp" +#include namespace fair::graph { diff --git a/core/include/gnuradio-4.0/tag.hpp b/core/include/gnuradio-4.0/tag.hpp index 0d067b949..ed4763a05 100644 --- a/core/include/gnuradio-4.0/tag.hpp +++ b/core/include/gnuradio-4.0/tag.hpp @@ -5,8 +5,9 @@ #include +#include + #include "reflection.hpp" -#include "utils.hpp" #ifdef __cpp_lib_hardware_interference_size using std::hardware_constructive_interference_size; diff --git a/core/include/gnuradio-4.0/transactions.hpp b/core/include/gnuradio-4.0/transactions.hpp index 75c4a3913..e66b130c5 100644 --- a/core/include/gnuradio-4.0/transactions.hpp +++ b/core/include/gnuradio-4.0/transactions.hpp @@ -14,6 +14,8 @@ #include +#include + #include "tag.hpp" #include "settings.hpp" @@ -22,8 +24,6 @@ #include #pragma GCC diagnostic pop -#include "utils.hpp" - namespace fair::graph { static auto nullMatchPred = [](auto, auto, auto) { return std::nullopt; }; diff --git a/core/test/CMakeLists.txt b/core/test/CMakeLists.txt index 230e74b67..067a901a2 100644 --- a/core/test/CMakeLists.txt +++ b/core/test/CMakeLists.txt @@ -5,7 +5,7 @@ configure_file(build_configure.hpp.in build_configure.hpp @ONLY) function(setup_test_no_asan TARGET_NAME) target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_BINARY_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(${TARGET_NAME} PRIVATE gnuradio-options gnuradio-core fmt refl-cpp ut fftw gr-basic gr-demo gr-filter gr-fourier gr-math gr-testing) + target_link_libraries(${TARGET_NAME} PRIVATE gnuradio-options gnuradio-core fmt refl-cpp ut fftw gr-basic gr-testing) add_test(NAME ${TARGET_NAME} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}) endfunction() @@ -41,7 +41,6 @@ add_ut_test(qa_settings) add_ut_test(qa_tags) add_ut_test(qa_thread_affinity) add_ut_test(qa_thread_pool) -add_ut_test(qa_traits) if (NOT (EMSCRIPTEN OR (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang"))) add_subdirectory(plugins) @@ -54,5 +53,5 @@ if (NOT (EMSCRIPTEN OR (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang"))) add_app_test(app_plugins_test app_plugins_test.cpp) add_app_test(app_grc) - target_link_libraries(app_grc PRIVATE yaml-cpp::yaml-cpp gr-basic gr-demo gr-filter gr-fourier gr-math gr-testing) + target_link_libraries(app_grc PRIVATE yaml-cpp::yaml-cpp gr-basic gr-testing) endif () diff --git a/core/test/app_plugins_test.cpp b/core/test/app_plugins_test.cpp index 0574ee54d..3b65fa62b 100644 --- a/core/test/app_plugins_test.cpp +++ b/core/test/app_plugins_test.cpp @@ -6,7 +6,8 @@ #include #include -#include + +#include #include diff --git a/core/test/qa_dynamic_port.cpp b/core/test/qa_dynamic_port.cpp index 4869f4397..1d987dbd4 100644 --- a/core/test/qa_dynamic_port.cpp +++ b/core/test/qa_dynamic_port.cpp @@ -7,7 +7,8 @@ #include #include #include -#include + +#include #if defined(__clang__) && __clang_major__ >= 16 // clang 16 does not like ut's default reporter_junit due to some issues with stream buffers and output redirection diff --git a/meta/CMakeLists.txt b/meta/CMakeLists.txt new file mode 100644 index 000000000..2eaaebc72 --- /dev/null +++ b/meta/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(gnuradio-meta INTERFACE) +target_include_directories(gnuradio-meta INTERFACE $ $) +target_link_libraries(gnuradio-meta INTERFACE gnuradio-options vir ) + +if (ENABLE_TESTING) + add_subdirectory(test) +endif () \ No newline at end of file diff --git a/meta/README.md b/meta/README.md new file mode 100644 index 000000000..41cecc401 --- /dev/null +++ b/meta/README.md @@ -0,0 +1,3 @@ +# gnuradio-meta + +A small metaprogramming and utility library for use by different parts of GNURadio. \ No newline at end of file diff --git a/core/include/gnuradio-4.0/typelist.hpp b/meta/include/gnuradio-4.0/meta/typelist.hpp similarity index 100% rename from core/include/gnuradio-4.0/typelist.hpp rename to meta/include/gnuradio-4.0/meta/typelist.hpp diff --git a/core/include/gnuradio-4.0/utils.hpp b/meta/include/gnuradio-4.0/meta/utils.hpp similarity index 100% rename from core/include/gnuradio-4.0/utils.hpp rename to meta/include/gnuradio-4.0/meta/utils.hpp diff --git a/meta/test/CMakeLists.txt b/meta/test/CMakeLists.txt new file mode 100644 index 000000000..d392159fe --- /dev/null +++ b/meta/test/CMakeLists.txt @@ -0,0 +1,2 @@ +add_ut_test(qa_traits) +target_link_libraries(qa_traits PRIVATE gnuradio-meta) diff --git a/core/test/qa_traits.cpp b/meta/test/qa_traits.cpp similarity index 96% rename from core/test/qa_traits.cpp rename to meta/test/qa_traits.cpp index 29e318d6e..3795e692c 100644 --- a/core/test/qa_traits.cpp +++ b/meta/test/qa_traits.cpp @@ -1,6 +1,6 @@ #include -#include +#include namespace fair::meta {