Prep for removing sfzInterpolationCast
This commit is contained in:
parent
cebf9060e1
commit
8d2ac8ebd5
4 changed files with 3 additions and 110 deletions
|
|
@ -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 <benchmark/benchmark.h>
|
||||
#include <vector>
|
||||
#include <random>
|
||||
#include <numeric>
|
||||
#include <absl/algorithm/container.h>
|
||||
|
||||
// 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<float> dist { 0, maxJump };
|
||||
jumps = std::vector<int>(state.range(0));
|
||||
coeffs = std::vector<float>(state.range(0));
|
||||
floatJumps = std::vector<float>(state.range(0));
|
||||
absl::c_generate(floatJumps, [&]() { return dist(gen); });
|
||||
}
|
||||
|
||||
void TearDown(const ::benchmark::State& /* state */) {
|
||||
|
||||
}
|
||||
|
||||
std::vector<int> jumps;
|
||||
std::vector<float> coeffs;
|
||||
std::vector<float> floatJumps;
|
||||
};
|
||||
|
||||
|
||||
BENCHMARK_DEFINE_F(InterpolationCast, Scalar)(benchmark::State& state) {
|
||||
for (auto _ : state)
|
||||
{
|
||||
sfz::sfzInterpolationCast<float, false>(floatJumps, absl::MakeSpan(jumps), absl::MakeSpan(coeffs));
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(InterpolationCast, SIMD)(benchmark::State& state) {
|
||||
for (auto _ : state)
|
||||
{
|
||||
sfz::sfzInterpolationCast<float, true>(floatJumps, absl::MakeSpan(jumps), absl::MakeSpan(coeffs));
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(InterpolationCast, Scalar_Unaligned)(benchmark::State& state) {
|
||||
for (auto _ : state)
|
||||
{
|
||||
sfz::sfzInterpolationCast<float, false>(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<float, true>(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();
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -616,6 +616,8 @@ void cumsum(absl::Span<const T> input, absl::Span<T> output) noexcept
|
|||
template <>
|
||||
void cumsum<float, true>(absl::Span<const float> input, absl::Span<float> output) noexcept;
|
||||
|
||||
// FIXME: This should go away once the changes from the resampler are in
|
||||
|
||||
namespace _internals {
|
||||
template <class T>
|
||||
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 <class T, bool SIMD = SIMDConfig::sfzInterpolationCast>
|
||||
template <class T>
|
||||
void sfzInterpolationCast(absl::Span<const T> floatJumps, absl::Span<int> jumps, absl::Span<T> coeffs) noexcept
|
||||
{
|
||||
CHECK(jumps.size() >= floatJumps.size());
|
||||
|
|
@ -652,9 +653,6 @@ void sfzInterpolationCast(absl::Span<const T> floatJumps, absl::Span<int> jumps,
|
|||
_internals::snippetSFZInterpolationCast(floatJump, jump, coeff);
|
||||
}
|
||||
|
||||
template <>
|
||||
void sfzInterpolationCast<float, true>(absl::Span<const float> floatJumps, absl::Span<int> jumps, absl::Span<float> coeffs) noexcept;
|
||||
|
||||
namespace _internals {
|
||||
template <class T>
|
||||
inline void snippetDiff(const T*& input, T*& output)
|
||||
|
|
|
|||
|
|
@ -116,36 +116,6 @@ void sfz::cumsum<float, true>(absl::Span<const float> input, absl::Span<float> o
|
|||
_internals::snippetCumsum(in, out);
|
||||
}
|
||||
|
||||
template <>
|
||||
void sfz::sfzInterpolationCast<float, true>(absl::Span<const float> floatJumps, absl::Span<int> jumps, absl::Span<float> coeffs) noexcept
|
||||
{
|
||||
sfz::sfzInterpolationCast<float, false>(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<float*>(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<TypeAlignment>(floatJump, jump, coeff);
|
||||
// }
|
||||
|
||||
// while(floatJump < sentinel)
|
||||
// _internals::snippetSFZInterpolationCast(floatJump, jump, coeff);
|
||||
}
|
||||
|
||||
template <>
|
||||
void sfz::diff<float, true>(absl::Span<const float> input, absl::Span<float> output) noexcept
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue