kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
Log | Files | Refs | README

commit 20b370ce738238a379e892b36b13d40cdc78bd76
parent 2afeaf05fbc09b99febbc189f6c302a2e2e9a28b
Author: Dan Levin <d.levin256@gmail.com>
Date:   Tue, 12 Nov 2019 17:40:46 +0300

Merge pull request #46 from bmanga/dft-gcc

Make DFT compile with GCC9
Diffstat:
MCMakeLists.txt | 7++-----
Minclude/kfr/cident.h | 4+++-
Minclude/kfr/dft/impl/fft-impl.hpp | 4++--
Minclude/kfr/simd/constants.hpp | 3+++
Minclude/kfr/simd/impl/read_write.hpp | 1+
Minclude/kfr/simd/impl/simd.hpp | 5+++--
Minclude/kfr/simd/vec.hpp | 4++--
7 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -56,12 +56,12 @@ endif() include(sources.cmake) option(ENABLE_TESTS "Enable tests and examples" OFF) +option(ENABLE_DFT "Enable DFT and related algorithms." ON) if (CLANG) - option(ENABLE_DFT "Enable DFT and related algorithms. Requires Clang" ON) if (X86) option(ENABLE_DFT_MULTIARCH "Build DFT static libraries for various architectures. Requires Clang" OFF) endif () -endif () +endif() option(ENABLE_ASMTEST "Enable writing disassembly" OFF) option(REGENERATE_TESTS "Regenerate auto tests" OFF) option(DISABLE_CLANG_EXTENSIONS "Disable Clang vector extensions" OFF) @@ -169,9 +169,6 @@ if (ENABLE_TESTS) endif () if (ENABLE_DFT) - if (NOT CLANG) - message(FATAL_ERROR "Clang compiler is required for DFT in KFR. See README.md for more information") - endif() add_library(kfr_dft ${KFR_DFT_SRC}) target_link_libraries(kfr_dft kfr use_arch) if (MSVC) diff --git a/include/kfr/cident.h b/include/kfr/cident.h @@ -342,7 +342,9 @@ extern char* gets(char* __s); #define CMT_NODEBUG // __attribute__((__nodebug__)) -#ifdef NDEBUG + +// GCC 9 broke attributes on lambdas. +#if defined(NDEBUG) && (!defined(__GNUC__) || __GNUC__ != 9) #define CMT_ALWAYS_INLINE __attribute__((__always_inline__)) #else #define CMT_ALWAYS_INLINE diff --git a/include/kfr/dft/impl/fft-impl.hpp b/include/kfr/dft/impl/fft-impl.hpp @@ -840,7 +840,7 @@ struct fft_specialization<T, 10> : fft_final_stage_impl<T, false, 1024> } // namespace intrinsics template <bool is_even, bool first, typename T> -KFR_INTRINSIC void make_fft(dft_plan<T>* self, size_t stage_size, cbool_t<is_even>, cbool_t<first>) +void make_fft(dft_plan<T>* self, size_t stage_size, cbool_t<is_even>, cbool_t<first>) { constexpr size_t final_size = is_even ? 1024 : 512; @@ -1089,7 +1089,7 @@ public: { using namespace intrinsics; constexpr size_t width = vector_width<T> * 2; - const size_t real_size = this->stage_size; + size_t real_size = this->stage_size; complex<T>* rtwiddle = ptr_cast<complex<T>>(this->data); block_process(real_size / 4, csizes_t<width, 1>(), [=](size_t i, auto w) { constexpr size_t width = val_of(decltype(w)()); diff --git a/include/kfr/simd/constants.hpp b/include/kfr/simd/constants.hpp @@ -88,6 +88,9 @@ public: using Tsub = subtype<T>; }; +template <size_t Value> +constexpr size_t force_compiletime_size_t = Value; + CMT_PRAGMA_GNU(GCC diagnostic pop) /// π (pi) diff --git a/include/kfr/simd/impl/read_write.hpp b/include/kfr/simd/impl/read_write.hpp @@ -28,6 +28,7 @@ #include "../shuffle.hpp" #include "../types.hpp" #include "../vec.hpp" +#include "function.hpp" namespace kfr { diff --git a/include/kfr/simd/impl/simd.hpp b/include/kfr/simd/impl/simd.hpp @@ -23,6 +23,7 @@ #pragma once #include "../platform.hpp" +#include "../constants.hpp" namespace kfr { @@ -67,13 +68,13 @@ constexpr size_t alignment() } template <typename T, size_t N> -struct alignas(alignment<T, N>()) simd_array +struct alignas(force_compiletime_size_t<alignment<T, N>()>) simd_array { T val[next_poweroftwo(N)]; }; template <typename T, size_t N> -struct alignas(alignment<T, N>()) simd_array<bit<T>, N> +struct alignas(force_compiletime_size_t<alignment<T, N>()>) simd_array<bit<T>, N> { bit_value<T> val[next_poweroftwo(N)]; }; diff --git a/include/kfr/simd/vec.hpp b/include/kfr/simd/vec.hpp @@ -162,11 +162,11 @@ struct compoundcast<vec<vec<T, N1>, N2>> } // namespace internal template <typename T, size_t N> -struct alignas(const_max(alignof(intrinsics::simd<typename compound_type_traits<T>::deep_subtype, +struct alignas(force_compiletime_size_t<const_max(alignof(intrinsics::simd<typename compound_type_traits<T>::deep_subtype, N * compound_type_traits<T>::deep_width>), const_min(size_t(platform<>::native_vector_alignment), next_poweroftwo(sizeof(typename compound_type_traits<T>::deep_subtype) * - N * compound_type_traits<T>::deep_width)))) vec + N * compound_type_traits<T>::deep_width)))>) vec { static constexpr vec_shape<T, N> shape() CMT_NOEXCEPT { return {}; }