diff --git a/benchmarks/BM_interpolationCast.cpp b/benchmarks/BM_interpolationCast.cpp deleted file mode 100644 index b3743530..00000000 --- a/benchmarks/BM_interpolationCast.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause - -// This code is part of the sfizz library and is licensed under a BSD 2-clause -// license. You should have receive a LICENSE.md file along with the code. -// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz - -#include "SIMDHelpers.h" -#include -#include -#include -#include -#include - -// In this one we have an array of jumps - -constexpr float maxJump { 4 }; - -class InterpolationCast : public benchmark::Fixture { -public: - void SetUp(const ::benchmark::State& state) { - std::random_device rd { }; - std::mt19937 gen { rd() }; - std::uniform_real_distribution dist { 0, maxJump }; - jumps = std::vector(state.range(0)); - coeffs = std::vector(state.range(0)); - floatJumps = std::vector(state.range(0)); - absl::c_generate(floatJumps, [&]() { return dist(gen); }); - } - - void TearDown(const ::benchmark::State& /* state */) { - - } - - std::vector jumps; - std::vector coeffs; - std::vector floatJumps; -}; - - -BENCHMARK_DEFINE_F(InterpolationCast, Scalar)(benchmark::State& state) { - for (auto _ : state) - { - sfz::sfzInterpolationCast(floatJumps, absl::MakeSpan(jumps), absl::MakeSpan(coeffs)); - } -} - -BENCHMARK_DEFINE_F(InterpolationCast, SIMD)(benchmark::State& state) { - for (auto _ : state) - { - sfz::sfzInterpolationCast(floatJumps, absl::MakeSpan(jumps), absl::MakeSpan(coeffs)); - } -} - -BENCHMARK_DEFINE_F(InterpolationCast, Scalar_Unaligned)(benchmark::State& state) { - for (auto _ : state) - { - sfz::sfzInterpolationCast(absl::MakeSpan(floatJumps).subspan(1), absl::MakeSpan(jumps).subspan(3), absl::MakeSpan(coeffs).subspan(1)); - } -} - -BENCHMARK_DEFINE_F(InterpolationCast, SIMD_Unaligned)(benchmark::State& state) { - for (auto _ : state) - { - sfz::sfzInterpolationCast(absl::MakeSpan(floatJumps).subspan(1), absl::MakeSpan(jumps).subspan(3), absl::MakeSpan(coeffs).subspan(1)); - } -} - - -// Register the function as a benchmark -BENCHMARK_REGISTER_F(InterpolationCast, Scalar)->RangeMultiplier(2)->Range((2<<6), (2<<12)); -BENCHMARK_REGISTER_F(InterpolationCast, SIMD)->RangeMultiplier(2)->Range((2<<6), (2<<12)); -BENCHMARK_REGISTER_F(InterpolationCast, Scalar_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12)); -BENCHMARK_REGISTER_F(InterpolationCast, SIMD_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12)); -BENCHMARK_MAIN(); diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 0e44d964..ffae6f8c 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -54,7 +54,6 @@ sfizz_add_benchmark(bm_mean BM_mean.cpp) sfizz_add_benchmark(bm_meanSquared BM_meanSquared.cpp) sfizz_add_benchmark(bm_cumsum BM_cumsum.cpp) sfizz_add_benchmark(bm_diff BM_diff.cpp) -sfizz_add_benchmark(bm_interpolationCast BM_interpolationCast.cpp) sfizz_add_benchmark(bm_pointerIterationOrOffsets BM_pointerIterationOrOffsets.cpp) sfizz_add_benchmark(bm_maps BM_maps.cpp) target_link_libraries(bm_maps PRIVATE absl::flat_hash_map) diff --git a/src/sfizz/SIMDHelpers.h b/src/sfizz/SIMDHelpers.h index 1f2ab5e3..12accd63 100644 --- a/src/sfizz/SIMDHelpers.h +++ b/src/sfizz/SIMDHelpers.h @@ -616,6 +616,8 @@ void cumsum(absl::Span input, absl::Span output) noexcept template <> void cumsum(absl::Span input, absl::Span output) noexcept; +// FIXME: This should go away once the changes from the resampler are in + namespace _internals { template void snippetSFZInterpolationCast(const T*& floatJump, int*& jump, T*& coeff) @@ -631,13 +633,12 @@ namespace _internals { * and extracts the integer index of the elements to interpolate * * @tparam T the underlying type - * @tparam SIMD use the SIMD version or the scalar version * @param floatJumps the floating point indices * @param jumps the integer indices outputs * @param leftCoeffs the left interpolation coefficients * @param rightCoeffs the right interpolation coefficients */ -template +template void sfzInterpolationCast(absl::Span floatJumps, absl::Span jumps, absl::Span coeffs) noexcept { CHECK(jumps.size() >= floatJumps.size()); @@ -652,9 +653,6 @@ void sfzInterpolationCast(absl::Span floatJumps, absl::Span jumps, _internals::snippetSFZInterpolationCast(floatJump, jump, coeff); } -template <> -void sfzInterpolationCast(absl::Span floatJumps, absl::Span jumps, absl::Span coeffs) noexcept; - namespace _internals { template inline void snippetDiff(const T*& input, T*& output) diff --git a/src/sfizz/SIMDSSE.cpp b/src/sfizz/SIMDSSE.cpp index f20938b7..9cf5ec04 100644 --- a/src/sfizz/SIMDSSE.cpp +++ b/src/sfizz/SIMDSSE.cpp @@ -116,36 +116,6 @@ void sfz::cumsum(absl::Span input, absl::Span o _internals::snippetCumsum(in, out); } -template <> -void sfz::sfzInterpolationCast(absl::Span floatJumps, absl::Span jumps, absl::Span coeffs) noexcept -{ - sfz::sfzInterpolationCast(floatJumps, jumps, coeffs); - // CHECK(jumps.size() >= floatJumps.size()); - // CHECK(jumps.size() == coeffs.size()); - - // auto floatJump = floatJumps.data(); - // auto jump = jumps.data(); - // auto coeff = coeffs.data(); - // const auto sentinel = floatJump + min(floatJumps.size(), jumps.size(), coeffs.size()); - // const auto lastAligned = prevAligned(sentinel); - - // while (unaligned(floatJump, reinterpret_cast(jump), coeff) && floatJump < lastAligned) - // _internals::snippetSFZInterpolationCast(floatJump, jump, coeff); - - // while (floatJump < lastAligned) { - // auto mmFloatJumps = _mm_load_ps(floatJump); - // auto mmIndices = _mm_cvtps_epi32(_mm_sub_ps(mmFloatJumps, _mm_set_ps1(0.4999999552965164184570312f))); - // _mm_store_si128(reinterpret_cast<__m128i*>(jump), mmIndices); - - // auto mmCoeff = _mm_sub_ps(mmFloatJumps, _mm_cvtepi32_ps(mmIndices)); - // _mm_store_ps(coeff, mmCoeff); - // incrementAll(floatJump, jump, coeff); - // } - - // while(floatJump < sentinel) - // _internals::snippetSFZInterpolationCast(floatJump, jump, coeff); -} - template <> void sfz::diff(absl::Span input, absl::Span output) noexcept {