commit b2566e9ac34108cbf989261b1b5d52fe4f13e935
parent c71d3680deef40bd1a7f0b104a86821d6af38740
Author: [email protected] <[email protected]>
Date: Tue, 17 Mar 2020 09:22:27 +0000
Multiple architectures for DFT
Diffstat:
8 files changed, 222 insertions(+), 141 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -14,10 +14,11 @@
# You should have received a copy of the GNU General Public License
# along with KFR.
-
cmake_minimum_required(VERSION 3.1)
-set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS}" CACHE STRING "compile flags" FORCE)
+set(CMAKE_CXX_FLAGS
+ " ${CMAKE_CXX_FLAGS}"
+ CACHE STRING "compile flags" FORCE)
project(kfr CXX)
@@ -25,13 +26,16 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
-message(STATUS "C++ compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} ${CMAKE_CXX_COMPILER} ")
+message(
+ STATUS
+ "C++ compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} ${CMAKE_CXX_COMPILER} "
+)
message(STATUS CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR})
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
- set (X86 TRUE)
+ set(X86 TRUE)
else ()
- set (X86 FALSE)
+ set(X86 FALSE)
endif ()
if (X86)
@@ -40,13 +44,14 @@ endif ()
if (MSVC)
message(STATUS MSVC)
-endif()
+endif ()
-if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL
+ "AppleClang")
set(CLANG 1)
-else()
+else ()
set(CLANG 0)
-endif()
+endif ()
# Include autogenerated list of source files
include(sources.cmake)
@@ -56,12 +61,15 @@ if (CLANG)
option(ENABLE_DFT "Enable DFT and related algorithms." ON)
option(ENABLE_DFT_NP "Enable Non-power of 2 DFT" ON)
if (X86)
- option(ENABLE_DFT_MULTIARCH "Build DFT static libraries for various architectures. Requires Clang" OFF)
+ option(
+ ENABLE_DFT_MULTIARCH
+ "Build DFT static libraries for various architectures. Requires Clang"
+ OFF)
endif ()
else ()
option(ENABLE_DFT "Enable DFT and related algorithms." OFF)
option(ENABLE_DFT_NP "Enable Non-power of 2 DFT" OFF)
-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)
@@ -78,18 +86,20 @@ endif ()
if (CPU_ARCH STREQUAL "detect" AND X86)
message(STATUS "Detecting native cpu...")
try_run(
- RUN_RESULT COMPILE_RESULT
- "${CMAKE_CURRENT_BINARY_DIR}/tmpdir"
- ${CMAKE_CURRENT_SOURCE_DIR}/cmake/detect_cpu.cpp
- CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CMAKE_CURRENT_SOURCE_DIR}/include" -DCMAKE_CXX_STANDARD=17
- -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_CXX_EXTENSIONS=ON
- COMPILE_OUTPUT_VARIABLE COMPILE_OUT
- RUN_OUTPUT_VARIABLE RUN_OUT
- )
+ RUN_RESULT COMPILE_RESULT "${CMAKE_CURRENT_BINARY_DIR}/tmpdir"
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/detect_cpu.cpp
+ CMAKE_FLAGS
+ "-DINCLUDE_DIRECTORIES=${CMAKE_CURRENT_SOURCE_DIR}/include"
+ -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON
+ -DCMAKE_CXX_EXTENSIONS=ON
+ COMPILE_OUTPUT_VARIABLE COMPILE_OUT
+ RUN_OUTPUT_VARIABLE RUN_OUT)
if (COMPILE_RESULT AND RUN_RESULT EQUAL 0)
message(STATUS DETECTED_CPU = ${RUN_OUT})
- set(CPU_ARCH ${RUN_OUT} CACHE STRING "Detected CPU" FORCE)
- else()
+ set(CPU_ARCH
+ ${RUN_OUT}
+ CACHE STRING "Detected CPU" FORCE)
+ else ()
message(STATUS COMPILE_RESULT = ${COMPILE_RESULT})
message(STATUS RUN_RESULT = ${RUN_RESULT})
message(STATUS COMPILE_OUT = ${COMPILE_OUT})
@@ -106,7 +116,7 @@ if (WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
-endif()
+endif ()
if (IOS)
set(STD_LIB)
@@ -155,7 +165,7 @@ if (NOT ENABLE_DFT)
endif ()
if (KFR_EXTENDED_TESTS)
target_compile_definitions(kfr INTERFACE -DKFR_EXTENDED_TESTS)
-endif()
+endif ()
message(STATUS CPU_ARCH=${CPU_ARCH})
@@ -165,25 +175,58 @@ if (X86)
target_set_arch(detect_cpu PRIVATE generic)
endif ()
+function (add_arch_library NAME ARCH SRCS DEFS)
+ add_library(${NAME}_${ARCH} STATIC ${SRCS})
+ target_link_libraries(${NAME}_${ARCH} kfr)
+ target_set_arch(${NAME}_${ARCH} PRIVATE ${ARCH})
+ target_compile_options(${NAME}_${ARCH} PRIVATE ${DEFS})
+ target_link_libraries(${NAME}_all INTERFACE ${NAME}_${ARCH})
+endfunction ()
+
if (ENABLE_DFT)
- add_library(kfr_dft ${KFR_DFT_SRC})
- target_link_libraries(kfr_dft kfr use_arch)
+
if (MSVC)
- target_compile_options(kfr_dft PRIVATE -fp:fast)
- else()
- target_compile_options(kfr_dft PRIVATE -ffast-math)
- endif()
+ set(KFR_DFT_DEFS -fp:fast)
+ else ()
+ set(KFR_DFT_DEFS -ffast-math)
+ endif ()
+
+ if (ENABLE_DFT_MULTIARCH)
+ add_library(kfr_dft INTERFACE)
+ add_library(kft_multidft_all INTERFACE)
+ target_link_libraries(kfr_dft INTERFACE kfr kft_multidft_all)
+ target_compile_definitions(
+ kfr_dft
+ INTERFACE -DKFR_DFT_MULTI=1
+ -DCMT_MULTI=1
+ -DCMT_MULTI_ENABLED_SSE2=1
+ -DCMT_MULTI_ENABLED_SSE41=1
+ -DCMT_MULTI_ENABLED_AVX=1
+ -DCMT_MULTI_ENABLED_AVX2=1
+ -DCMT_MULTI_ENABLED_AVX512=1)
+
+ add_arch_library(kft_multidft sse2 "${KFR_DFT_SRC}" "${KFR_DFT_DEFS}")
+ add_arch_library(kft_multidft sse41 "${KFR_DFT_SRC}" "${KFR_DFT_DEFS}")
+ add_arch_library(kft_multidft avx "${KFR_DFT_SRC}" "${KFR_DFT_DEFS}")
+ add_arch_library(kft_multidft avx2 "${KFR_DFT_SRC}" "${KFR_DFT_DEFS}")
+ add_arch_library(kft_multidft avx512 "${KFR_DFT_SRC}" "${KFR_DFT_DEFS}")
- if (ENABLE_DFT_NP)
- target_compile_definitions(kfr_dft PUBLIC -DKFR_DFT_NPo2)
else ()
- target_compile_definitions(kfr_dft PUBLIC -DKFR_DFT_NO_NPo2)
- endif ()
+ add_library(kfr_dft ${KFR_DFT_SRC})
+ target_link_libraries(kfr_dft kfr use_arch)
+ target_compile_options(kfr_dft PRIVATE "${KFR_DFT_DEFS}")
+ if (ENABLE_DFT_NP)
+ target_compile_definitions(kfr_dft PUBLIC -DKFR_DFT_NPo2)
+ else ()
+ target_compile_definitions(kfr_dft PUBLIC -DKFR_DFT_NO_NPo2)
+ endif ()
+
+ endif ()
if (ENABLE_CAPI_BUILD)
add_subdirectory(capi)
endif ()
-endif()
+endif ()
if (ENABLE_TESTS)
add_subdirectory(examples)
@@ -194,21 +237,29 @@ endif ()
add_library(kfr_io ${KFR_IO_SRC})
target_link_libraries(kfr_io kfr)
-install(TARGETS kfr kfr_io ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
+install(
+ TARGETS kfr kfr_io
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib)
if (ENABLE_DFT)
- install(TARGETS kfr_dft ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
+ install(
+ TARGETS kfr_dft
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib)
endif ()
install(DIRECTORY include/kfr DESTINATION include)
# uninstall target
-if(NOT TARGET uninstall)
+if (NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
- IMMEDIATE @ONLY)
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" IMMEDIATE
+ @ONLY)
- add_custom_target(uninstall
- COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake)
-endif()
+ add_custom_target(
+ uninstall
+ COMMAND ${CMAKE_COMMAND} -P
+ ${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake)
+endif ()
diff --git a/capi/CMakeLists.txt b/capi/CMakeLists.txt
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with KFR.
-
cmake_minimum_required(VERSION 3.1)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
@@ -26,9 +25,9 @@ if (MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif ()
-if(APPLE)
+if (APPLE)
add_compile_options(-mmacosx-version-min=10.9)
-endif()
+endif ()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/bin)
@@ -44,33 +43,32 @@ if (NOT WIN32)
target_link_libraries(kfr_capi_all_pic INTERFACE kfr)
endif ()
-function(add_c_library ARCH)
- add_library(kfr_capi_${ARCH} STATIC
- ${KFR_DFT_SRC}
- ${CMAKE_CURRENT_SOURCE_DIR}/../include/kfr/dsp/impl/dsp-impl.cpp
- )
+function (add_c_library ARCH)
+ add_library(
+ kfr_capi_${ARCH} STATIC
+ ${KFR_DFT_SRC}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../include/kfr/dsp/impl/dsp-impl.cpp)
target_link_libraries(kfr_capi_${ARCH} kfr)
target_set_arch(kfr_capi_${ARCH} PRIVATE ${ARCH})
target_compile_options(kfr_capi_${ARCH} PRIVATE -Xclang -ffast-math)
target_link_libraries(kfr_capi_all INTERFACE kfr_capi_${ARCH})
if (NOT WIN32)
- add_library(kfr_capi_${ARCH}_pic STATIC
+ add_library(
+ kfr_capi_${ARCH}_pic STATIC
${KFR_DFT_SRC}
- ${CMAKE_CURRENT_SOURCE_DIR}/../include/kfr/dsp/impl/dsp-impl.cpp
- )
- set_property(TARGET kfr_capi_${ARCH}_pic PROPERTY POSITION_INDEPENDENT_CODE 1)
+ ${CMAKE_CURRENT_SOURCE_DIR}/../include/kfr/dsp/impl/dsp-impl.cpp)
+ set_property(TARGET kfr_capi_${ARCH}_pic
+ PROPERTY POSITION_INDEPENDENT_CODE 1)
target_link_libraries(kfr_capi_${ARCH}_pic kfr)
target_set_arch(kfr_capi_${ARCH}_pic PRIVATE ${ARCH})
target_compile_options(kfr_capi_${ARCH}_pic PRIVATE -Xclang -ffast-math)
target_link_libraries(kfr_capi_all_pic INTERFACE kfr_capi_${ARCH}_pic)
- endif()
-endfunction()
-
+ endif ()
+endfunction ()
-add_library(kfr_capi SHARED
- ${PROJECT_SOURCE_DIR}/capi/capi.cpp)
+add_library(kfr_capi SHARED ${PROJECT_SOURCE_DIR}/capi/capi.cpp)
add_c_library(sse2)
add_c_library(sse41)
@@ -78,15 +76,16 @@ add_c_library(avx)
add_c_library(avx2)
add_c_library(avx512)
-target_compile_definitions(kfr_capi PRIVATE
- -DKFR_DFT_MULTI=1
- -DCMT_MULTI=1
- -DCMT_MULTI_ENABLED_SSE2=1
- -DCMT_MULTI_ENABLED_SSE41=1
- -DCMT_MULTI_ENABLED_AVX=1
- -DCMT_MULTI_ENABLED_AVX2=1
- -DCMT_MULTI_ENABLED_AVX512=1
- -DKFR_BUILDING_DLL=1)
+target_compile_definitions(
+ kfr_capi
+ PRIVATE -DKFR_DFT_MULTI=1
+ -DCMT_MULTI=1
+ -DCMT_MULTI_ENABLED_SSE2=1
+ -DCMT_MULTI_ENABLED_SSE41=1
+ -DCMT_MULTI_ENABLED_AVX=1
+ -DCMT_MULTI_ENABLED_AVX2=1
+ -DCMT_MULTI_ENABLED_AVX512=1
+ -DKFR_BUILDING_DLL=1)
target_set_arch(kfr_capi PRIVATE sse2)
@@ -96,9 +95,22 @@ else ()
target_link_libraries(kfr_capi PRIVATE kfr kfr_capi_all_pic)
if (APPLE)
- message (STATUS "Minimum macOS version is set to ${CMAKE_OSX_DEPLOYMENT_TARGET}")
- message (STATUS "Set CMAKE_OSX_DEPLOYMENT_TARGET variable to change")
+ message(
+ STATUS
+ "Minimum macOS version is set to ${CMAKE_OSX_DEPLOYMENT_TARGET}"
+ )
+ message(STATUS "Set CMAKE_OSX_DEPLOYMENT_TARGET variable to change")
else ()
- set_property(TARGET kfr_capi APPEND PROPERTY LINK_LIBRARIES -nodefaultlibs -Wl,-Bdynamic -lm -lc -Wl,-Bstatic -lstdc++ -lgcc -s)
+ set_property(
+ TARGET kfr_capi APPEND
+ PROPERTY LINK_LIBRARIES
+ -nodefaultlibs
+ -Wl,-Bdynamic
+ -lm
+ -lc
+ -Wl,-Bstatic
+ -lstdc++
+ -lgcc
+ -s)
endif ()
-endif()
+endif ()
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with KFR.
-
cmake_minimum_required(VERSION 3.1)
# Binary output directories
@@ -46,10 +45,6 @@ target_link_libraries(sample_rate_conversion kfr kfr_io use_arch)
if (ENABLE_DFT)
add_executable(dft dft.cpp)
target_link_libraries(dft kfr kfr_dft use_arch)
- if (ENABLE_DFT_MULTIARCH)
- target_link_libraries(dft kfr_multidft)
- target_compile_definitions(dft PRIVATE -DKFR_DFT_MULTI=1)
- endif ()
add_executable(ccv ccv.cpp)
target_link_libraries(ccv kfr kfr_dft use_arch)
endif ()
diff --git a/examples/dft.cpp b/examples/dft.cpp
@@ -23,11 +23,7 @@ int main()
univector<complex<fbase>, size> out = scalar(qnan);
// initialize fft
- const dft_plan<fbase> dft(
-#ifdef KFR_DFT_MULTI
- cpu_t::runtime,
-#endif
- size);
+ const dft_plan<fbase> dft(size);
dft.dump();
diff --git a/include/kfr/base/filter.hpp b/include/kfr/base/filter.hpp
@@ -64,7 +64,7 @@ public:
process_buffer(buffer.data(), buffer.data(), buffer.size());
}
- /// @brief Applies filter to a univector and write the result to another univector
+ /// @brief Applies filter to a univector and writes the result to another univector
template <univector_tag Tag1, univector_tag Tag2>
void apply(univector<T, Tag1>& dest, const univector<T, Tag2>& src)
{
@@ -109,10 +109,7 @@ template <typename T>
class expression_filter : public filter<T>
{
public:
- template <typename... Args>
- explicit expression_filter(expression_pointer<T>&& filter_expr) : filter_expr(std::move(filter_expr))
- {
- }
+ explicit expression_filter(expression_pointer<T>&& filter_expr) : filter_expr(std::move(filter_expr)) {}
protected:
void process_buffer(T* dest, const T* src, size_t size) override
diff --git a/include/kfr/dft/fft.hpp b/include/kfr/dft/fft.hpp
@@ -162,13 +162,18 @@ struct dft_plan
CMT_IF_ENABLED_SSE2(sse2::dft_initialize(*this); break;);
}
}
-#endif
-
+ explicit dft_plan(size_t size, dft_order order = dft_order::normal)
+ :dft_plan(cpu_t::runtime, size, order)
+ {
+ }
+#else
explicit dft_plan(size_t size, dft_order order = dft_order::normal)
: size(size), temp_size(0), data_size(0)
{
dft_initialize(*this);
}
+#endif
+
void dump() const
{
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with KFR.
-
cmake_minimum_required(VERSION 3.1)
add_definitions(-DKFR_TESTING=1)
@@ -54,7 +53,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/tests/cmake/")
if (ENABLE_CAPI_BUILD)
add_executable(capi_test capi_test.cpp)
- target_include_directories(capi_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include)
+ target_include_directories(capi_test
+ PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include)
target_link_libraries(capi_test PUBLIC kfr_capi)
endif ()
@@ -72,33 +72,40 @@ if (ENABLE_ASMTEST)
target_compile_options(asm_test PRIVATE -Gs16384)
endif ()
- add_custom_command(TARGET asm_test POST_BUILD COMMAND objconv -fyasm $<TARGET_FILE:asm_test>)
-endif()
+ add_custom_command(
+ TARGET asm_test
+ POST_BUILD
+ COMMAND objconv -fyasm $<TARGET_FILE:asm_test>)
+endif ()
if (X86)
- if(MSVC AND NOT CLANG)
- add_executable(multiarch multiarch.cpp multiarch_fir_sse2.cpp multiarch_fir_avx.cpp)
- set_source_files_properties(multiarch_fir_sse2.cpp PROPERTIES COMPILE_FLAGS /arch:SSE2)
- set_source_files_properties(multiarch_fir_avx.cpp PROPERTIES COMPILE_FLAGS /arch:AVX)
- else()
- add_executable(multiarch multiarch.cpp multiarch_fir_sse2.cpp multiarch_fir_avx.cpp)
- set_source_files_properties(multiarch_fir_sse2.cpp PROPERTIES COMPILE_FLAGS "-mno-avx -mno-sse3 -msse2")
- set_source_files_properties(multiarch_fir_avx.cpp PROPERTIES COMPILE_FLAGS "-mavx -mno-avx2")
- endif()
+ if (MSVC AND NOT CLANG)
+ add_executable(multiarch multiarch.cpp multiarch_fir_sse2.cpp
+ multiarch_fir_avx.cpp)
+ set_source_files_properties(multiarch_fir_sse2.cpp
+ PROPERTIES COMPILE_FLAGS /arch:SSE2)
+ set_source_files_properties(multiarch_fir_avx.cpp
+ PROPERTIES COMPILE_FLAGS /arch:AVX)
+ else ()
+ add_executable(multiarch multiarch.cpp multiarch_fir_sse2.cpp
+ multiarch_fir_avx.cpp)
+ set_source_files_properties(
+ multiarch_fir_sse2.cpp PROPERTIES COMPILE_FLAGS
+ "-mno-avx -mno-sse3 -msse2")
+ set_source_files_properties(multiarch_fir_avx.cpp
+ PROPERTIES COMPILE_FLAGS "-mavx -mno-avx2")
+ endif ()
target_link_libraries(multiarch kfr)
endif ()
set(ALL_TESTS_CPP
- base_test.cpp
- complex_test.cpp
- dsp_test.cpp
- expression_test.cpp
- intrinsic_test.cpp
- io_test.cpp
- ${KFR_UNITTEST_SRC}
- )
-
-# set(ALL_TESTS_MERGED_CPP all_tests_merged.cpp)
+ base_test.cpp
+ complex_test.cpp
+ dsp_test.cpp
+ expression_test.cpp
+ intrinsic_test.cpp
+ io_test.cpp
+ ${KFR_UNITTEST_SRC})
if (ENABLE_DFT)
list(APPEND ALL_TESTS_CPP dft_test.cpp)
@@ -111,13 +118,16 @@ if (MPFR_FOUND AND GMP_FOUND)
message(STATUS "MPFR is found")
add_executable(generate_data generate_data.cpp)
target_link_libraries(generate_data kfr)
- target_include_directories(generate_data PRIVATE ${MPFR_INCLUDE_DIR} ${GMP_INCLUDE_DIR})
+ target_include_directories(generate_data PRIVATE ${MPFR_INCLUDE_DIR}
+ ${GMP_INCLUDE_DIR})
target_link_libraries(generate_data ${MPFR_LIBRARIES} ${GMP_LIBRARIES})
if (REGENERATE_TESTS)
- add_custom_command(TARGET generate_data POST_BUILD
- COMMENT "Generating tests..."
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/data
- COMMAND generate_data)
+ add_custom_command(
+ TARGET generate_data
+ POST_BUILD
+ COMMENT "Generating tests..."
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/data
+ COMMAND generate_data)
endif ()
endif ()
@@ -129,10 +139,11 @@ if (ENABLE_DFT)
endif ()
target_link_libraries(all_tests kfr_io)
-function(add_x86_test ARCH)
+function (add_x86_test ARCH)
set(NAME ${ARCH})
- add_executable(all_tests_${NAME} all_tests.cpp ${ALL_TESTS_CPP} ${KFR_IO_SRC})
+ add_executable(all_tests_${NAME} all_tests.cpp ${ALL_TESTS_CPP}
+ ${KFR_IO_SRC})
if (ENABLE_DFT)
target_sources(all_tests_${NAME} PRIVATE ${KFR_DFT_SRC})
endif ()
@@ -142,24 +153,34 @@ function(add_x86_test ARCH)
target_compile_definitions(all_tests_${NAME} PUBLIC KFR_ENABLE_FLAC=1)
if (ARCH_TESTS_MULTI)
- add_library(all_tests_multiarch_${NAME} STATIC ${ALL_TESTS_MERGED_CPP} ${KFR_IO_SRC})
+ add_library(all_tests_multiarch_${NAME} STATIC ${ALL_TESTS_MERGED_CPP}
+ ${KFR_IO_SRC})
if (ENABLE_DFT)
target_sources(all_tests_multiarch_${NAME} PRIVATE ${KFR_DFT_SRC})
endif ()
target_link_libraries(all_tests_multiarch_${NAME} kfr)
target_set_arch(all_tests_multiarch_${NAME} PRIVATE ${ARCH})
- target_compile_definitions(all_tests_multiarch_${NAME} PRIVATE KFR_NO_MAIN)
- target_compile_definitions(all_tests_multiarch_${NAME} PUBLIC KFR_ENABLE_FLAC=1)
+ target_compile_definitions(all_tests_multiarch_${NAME}
+ PRIVATE KFR_NO_MAIN)
+ target_compile_definitions(all_tests_multiarch_${NAME}
+ PUBLIC KFR_ENABLE_FLAC=1)
endif ()
-endfunction()
+endfunction ()
message(STATUS "ARCH_TESTS = ${ARCH_TESTS}")
if (ARCH_TESTS AND ARCH_TESTS STREQUAL "ON")
- set (ARCH_LIST generic sse2 ssse3 sse42 avx avx2 avx512)
+ set(ARCH_LIST
+ generic
+ sse2
+ ssse3
+ sse42
+ avx
+ avx2
+ avx512)
else ()
- string (REPLACE "," ";" ARCH_LIST "${ARCH_TESTS}")
+ string(REPLACE "," ";" ARCH_LIST "${ARCH_TESTS}")
endif ()
if (MSVC AND NOT CLANG)
@@ -170,20 +191,20 @@ message(STATUS "Testing for ${ARCH_LIST}")
if (ARCH_TESTS)
- foreach(A IN LISTS ARCH_LIST)
+ foreach (A IN LISTS ARCH_LIST)
add_x86_test(${A})
- endforeach()
+ endforeach ()
if (ARCH_TESTS_MULTI)
add_executable(all_tests_multiarch all_tests.cpp)
target_compile_definitions(all_tests_multiarch PRIVATE KFR_MULTI_ARCH)
- foreach(A IN LISTS ARCH_LIST)
+ foreach (A IN LISTS ARCH_LIST)
target_link_libraries(all_tests_multiarch all_tests_multiarch_${A})
- endforeach()
+ endforeach ()
endif ()
-endif()
+endif ()
-if(USE_SDE)
+if (USE_SDE)
find_program(SDE "sde")
find_program(EMULATOR "sde")
list(APPEND EMULATOR "-skx")
@@ -207,24 +228,29 @@ if (NOT SKIP_TESTS)
enable_testing()
if (X86)
- add_test(NAME multiarch
- COMMAND ${EMULATOR} ${PROJECT_BINARY_DIR}/bin/multiarch)
+ add_test(NAME multiarch COMMAND ${EMULATOR}
+ ${PROJECT_BINARY_DIR}/bin/multiarch)
if (ENABLE_CAPI_BUILD)
- add_test(NAME capi_test COMMAND ${EMULATOR} ${PROJECT_BINARY_DIR}/bin/capi_test)
+ add_test(NAME capi_test COMMAND ${EMULATOR}
+ ${PROJECT_BINARY_DIR}/bin/capi_test)
endif ()
endif ()
if (ARCH_TESTS)
- foreach(A IN LISTS ARCH_LIST)
+ foreach (A IN LISTS ARCH_LIST)
if (USE_SDE)
- add_test(NAME all_tests_${A} COMMAND ${SDE} ${SDE_ARCH_${A}} -- ${PROJECT_BINARY_DIR}/bin/all_tests_${A})
+ add_test(NAME all_tests_${A}
+ COMMAND ${SDE} ${SDE_ARCH_${A}} --
+ ${PROJECT_BINARY_DIR}/bin/all_tests_${A})
else ()
- add_test(NAME all_tests_${A} COMMAND ${EMULATOR} ${PROJECT_BINARY_DIR}/bin/all_tests_${A})
+ add_test(NAME all_tests_${A}
+ COMMAND ${EMULATOR}
+ ${PROJECT_BINARY_DIR}/bin/all_tests_${A})
endif ()
- endforeach()
+ endforeach ()
else ()
- add_test(NAME all_tests
- COMMAND ${EMULATOR} ${PROJECT_BINARY_DIR}/bin/all_tests)
+ add_test(NAME all_tests COMMAND ${EMULATOR}
+ ${PROJECT_BINARY_DIR}/bin/all_tests)
endif ()
endif ()
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
@@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with KFR.
-
cmake_minimum_required(VERSION 3.1)
# Binary output directories