diff --git a/CMakeLists.txt b/CMakeLists.txt index cff21517..a3b9f457 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,13 +71,17 @@ target_include_directories(readerwriterqueue INTERFACE "external/readerwriterque add_subdirectory(sfizz) add_subdirectory(clients) +if (SFIZZ_TESTS) # Tests add_subdirectory(external/Catch2 EXCLUDE_FROM_ALL) add_subdirectory(external/cnpy EXCLUDE_FROM_ALL) add_subdirectory(tests) +endif() +if (SFIZZ_BENCHMARKS) # Benchmarks set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable Google Benchmark tests") set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Disable Google Benchmark install") add_subdirectory(external/benchmark EXCLUDE_FROM_ALL) -add_subdirectory(benchmarks) \ No newline at end of file +add_subdirectory(benchmarks) +endif() \ No newline at end of file diff --git a/benchmarks/BM_ADSR.cpp b/benchmarks/BM_ADSR.cpp index b21fa07c..b54dd720 100644 --- a/benchmarks/BM_ADSR.cpp +++ b/benchmarks/BM_ADSR.cpp @@ -22,7 +22,7 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "../sources/ADSREnvelope.h" +#include "../sfizz/ADSREnvelope.h" #include #include #include @@ -35,7 +35,7 @@ constexpr int release = attack; constexpr int releaseTime = envelopeSize - static_cast(envelopeSize / 4); // Explicitely instantiate class -#include "../sources/ADSREnvelope.cpp" +#include "../sfizz/ADSREnvelope.cpp" template class sfz::ADSREnvelope; static void Point(benchmark::State& state) { diff --git a/benchmarks/BM_add.cpp b/benchmarks/BM_add.cpp index a37dd021..20ab8386 100644 --- a/benchmarks/BM_add.cpp +++ b/benchmarks/BM_add.cpp @@ -27,7 +27,7 @@ #include #include #include -#include "../sources/SIMDHelpers.h" +#include "../sfizz/SIMDHelpers.h" class AddArray : public benchmark::Fixture { public: diff --git a/benchmarks/BM_fill.cpp b/benchmarks/BM_fill.cpp index a8973122..41f5c87a 100644 --- a/benchmarks/BM_fill.cpp +++ b/benchmarks/BM_fill.cpp @@ -22,8 +22,8 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "../sources/SIMDHelpers.h" -#include "../sources/Buffer.h" +#include "../sfizz/SIMDHelpers.h" +#include "../sfizz/Buffer.h" #include #include #include diff --git a/benchmarks/BM_gain.cpp b/benchmarks/BM_gain.cpp index 04843fa9..e59c7cef 100644 --- a/benchmarks/BM_gain.cpp +++ b/benchmarks/BM_gain.cpp @@ -27,7 +27,7 @@ #include #include #include -#include "../sources/SIMDHelpers.h" +#include "../sfizz/SIMDHelpers.h" class GainSingle : public benchmark::Fixture { public: diff --git a/benchmarks/BM_looping.cpp b/benchmarks/BM_looping.cpp index 3d982dfb..3a281833 100644 --- a/benchmarks/BM_looping.cpp +++ b/benchmarks/BM_looping.cpp @@ -26,7 +26,7 @@ #include #include #include -#include "../sources/SIMDHelpers.h" +#include "../sfizz/SIMDHelpers.h" // In this one we have an array of indices diff --git a/benchmarks/BM_mathfuns.cpp b/benchmarks/BM_mathfuns.cpp index 513868b7..df533384 100644 --- a/benchmarks/BM_mathfuns.cpp +++ b/benchmarks/BM_mathfuns.cpp @@ -21,7 +21,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "../sources/SIMDHelpers.h" +#include "../sfizz/SIMDHelpers.h" #include "absl/types/span.h" #include #include diff --git a/benchmarks/BM_ramp.cpp b/benchmarks/BM_ramp.cpp index ffeea816..cb8ffdb5 100644 --- a/benchmarks/BM_ramp.cpp +++ b/benchmarks/BM_ramp.cpp @@ -23,8 +23,8 @@ #include #include -#include "../sources/SIMDHelpers.h" -#include "../sources/Buffer.h" +#include "../sfizz/SIMDHelpers.h" +#include "../sfizz/Buffer.h" static void Dummy(benchmark::State& state) { diff --git a/benchmarks/BM_readInterleaved.cpp b/benchmarks/BM_readInterleaved.cpp index d3bafa31..4d30a949 100644 --- a/benchmarks/BM_readInterleaved.cpp +++ b/benchmarks/BM_readInterleaved.cpp @@ -22,8 +22,8 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "../sources/SIMDHelpers.h" -#include "../sources/Buffer.h" +#include "../sfizz/SIMDHelpers.h" +#include "../sfizz/Buffer.h" #include #include #include diff --git a/benchmarks/BM_saturating.cpp b/benchmarks/BM_saturating.cpp index d9357bbd..a26ab73d 100644 --- a/benchmarks/BM_saturating.cpp +++ b/benchmarks/BM_saturating.cpp @@ -26,7 +26,7 @@ #include #include #include -#include "../sources/SIMDHelpers.h" +#include "../sfizz/SIMDHelpers.h" // In this one we have an array of indices diff --git a/benchmarks/BM_writeInterleaved.cpp b/benchmarks/BM_writeInterleaved.cpp index bcfc413c..d2921706 100644 --- a/benchmarks/BM_writeInterleaved.cpp +++ b/benchmarks/BM_writeInterleaved.cpp @@ -22,8 +22,8 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "../sources/SIMDHelpers.h" -#include "../sources/Buffer.h" +#include "../sfizz/SIMDHelpers.h" +#include "../sfizz/Buffer.h" #include #include #include diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 71da6bea..7b5a929c 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -1,5 +1,29 @@ project(sfizz) +# Check SIMD +include(CheckIncludeFiles) +CHECK_INCLUDE_FILES(x86intrin.h HAVE_X86INTRIN_H) +CHECK_INCLUDE_FILES(intrin.h HAVE_INTRIN_H) +CHECK_INCLUDE_FILES(arm_neon.h HAVE_ARM_NEON_H) + +# SIMD checks +if (HAVE_X86INTRIN_H AND UNIX) + add_compile_options(-DHAVE_X86INTRIN_H) + set(SFIZZ_SIMD_SOURCES ../sfizz/SIMDSSE.cpp) +elseif (HAVE_INTRIN_H AND WIN32) + add_compile_options(/DHAVE_INTRIN_H) + set(SFIZZ_SIMD_SOURCES ../sfizz/SIMDSSE.cpp) +elseif (HAVE_ARM_NEON_H AND UNIX) + add_compile_options(-DHAVE_ARM_NEON_H) + add_compile_options(-mfpu=neon-fp-armv8) + add_compile_options(-march=native) + add_compile_options(-mtune=cortex-a53) + add_compile_options(-funsafe-math-optimizations) + set(SFIZZ_SIMD_SOURCES ../sfizz/SIMDNEON.cpp) +else() + set(SFIZZ_SIMD_SOURCES ../sfizz/SIMDDummy.cpp) +endif() + add_executable(bm_opf_high_vs_low BM_OPF_high_vs_low.cpp) target_link_libraries(bm_opf_high_vs_low benchmark absl::span) @@ -31,4 +55,19 @@ add_executable(bm_ADSR BM_ADSR.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_ADSR benchmark absl::span absl::algorithm) add_executable(bm_add BM_add.cpp ${SFIZZ_SIMD_SOURCES}) -target_link_libraries(bm_add benchmark absl::span absl::algorithm) \ No newline at end of file +target_link_libraries(bm_add benchmark absl::span absl::algorithm) + +add_custom_target(sfizz_benchmarks) +add_dependencies(sfizz_benchmarks + bm_opf_high_vs_low + bm_write + bm_read + bm_fill + bm_mathfuns + bm_gain + bm_looping + bm_saturating + bm_ramp + bm_ADSR + bm_add +) \ No newline at end of file diff --git a/scripts/asan_clang.sh b/scripts/asan_clang.sh index 7f7737f6..4a560431 100755 --- a/scripts/asan_clang.sh +++ b/scripts/asan_clang.sh @@ -1,3 +1,3 @@ #!/bin/sh script_dir="$(dirname "$0")" -cmake -D CMAKE_C_COMPILER=clang-9 -D CMAKE_CXX_COMPILER=clang++-9 -D CMAKE_CXX_FLAGS="-fsanitize=address" -D CMAKE_BUILD_TYPE=Release -S "$script_dir/.." -B . \ No newline at end of file +cmake -D CMAKE_C_COMPILER=clang-9 -D CMAKE_CXX_COMPILER=clang++-9 -D CMAKE_CXX_FLAGS="-fsanitize=address" -D CMAKE_BUILD_TYPE=Release -D SFIZZ_TESTS=ON -D SFIZZ_BENCHMARKS=ON -S "$script_dir/.." -B . \ No newline at end of file diff --git a/scripts/debug_clang.sh b/scripts/debug_clang.sh index faff568f..04bf0172 100755 --- a/scripts/debug_clang.sh +++ b/scripts/debug_clang.sh @@ -1,3 +1,3 @@ #!/bin/sh script_dir="$(dirname "$0")" -cmake -D CMAKE_C_COMPILER=clang-9 -D CMAKE_CXX_COMPILER=clang++-9 -D CMAKE_BUILD_TYPE=Debug -S "$script_dir/.." -B . \ No newline at end of file +cmake -D CMAKE_C_COMPILER=clang-9 -D CMAKE_CXX_COMPILER=clang++-9 -D CMAKE_BUILD_TYPE=Debug -D SFIZZ_TESTS=ON -D SFIZZ_BENCHMARKS=ON -S "$script_dir/.." -B . \ No newline at end of file diff --git a/scripts/debug_gcc.sh b/scripts/debug_gcc.sh index e4e55e07..57ccb016 100755 --- a/scripts/debug_gcc.sh +++ b/scripts/debug_gcc.sh @@ -1,3 +1,3 @@ #!/bin/sh script_dir="$(dirname "$0")" -cmake -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++ -D CMAKE_BUILD_TYPE=Debug -S "$script_dir/.." -B . \ No newline at end of file +cmake -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++ -D CMAKE_BUILD_TYPE=Debug -D SFIZZ_TESTS=ON -D SFIZZ_BENCHMARKS=ON -S "$script_dir/.." -B . \ No newline at end of file diff --git a/scripts/release_clang.sh b/scripts/release_clang.sh index 70a007d8..da9c34c7 100755 --- a/scripts/release_clang.sh +++ b/scripts/release_clang.sh @@ -1,3 +1,3 @@ #!/bin/sh script_dir="$(dirname "$0")" -cmake -D CMAKE_C_COMPILER=clang-9 -D CMAKE_CXX_COMPILER=clang++-9 -D CMAKE_BUILD_TYPE=Release -S "$script_dir/.." -B . \ No newline at end of file +cmake -D CMAKE_C_COMPILER=clang-9 -D CMAKE_CXX_COMPILER=clang++-9 -D CMAKE_BUILD_TYPE=Release -D SFIZZ_TESTS=ON -D SFIZZ_BENCHMARKS=ON -S "$script_dir/.." -B . \ No newline at end of file diff --git a/scripts/release_gcc.sh b/scripts/release_gcc.sh index 25c091c3..d8d01b78 100755 --- a/scripts/release_gcc.sh +++ b/scripts/release_gcc.sh @@ -1,3 +1,3 @@ #!/bin/sh script_dir="$(dirname "$0")" -cmake -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++ -D CMAKE_BUILD_TYPE=Release -S "$script_dir/.." -B . +cmake -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++ -D CMAKE_BUILD_TYPE=Release -D SFIZZ_TESTS=ON -D SFIZZ_BENCHMARKS=ON -S "$script_dir/.." -B . diff --git a/sfizz/CMakeLists.txt b/sfizz/CMakeLists.txt index e30e6c2b..1ebb85ec 100644 --- a/sfizz/CMakeLists.txt +++ b/sfizz/CMakeLists.txt @@ -33,6 +33,7 @@ elseif (HAVE_ARM_NEON_H AND UNIX) else() set(SFIZZ_SIMD_SOURCES SIMDDummy.cpp) endif() + set(SFIZZ_SOURCES ${SFIZZ_SOURCES} ${SFIZZ_SIMD_SOURCES}) add_library(sfizz_parser STATIC)