diff --git a/benchmarks/BM_mathfuns.cpp b/benchmarks/BM_mathfuns.cpp index aa11b966..6cf78e9a 100644 --- a/benchmarks/BM_mathfuns.cpp +++ b/benchmarks/BM_mathfuns.cpp @@ -45,96 +45,6 @@ BENCHMARK_DEFINE_F(MyFixture, Dummy) } } -BENCHMARK_DEFINE_F(MyFixture, ScalarExp) -(benchmark::State& state) -{ - for (auto _ : state) { - sfz::exp(source, absl::MakeSpan(result)); - benchmark::DoNotOptimize(result); - } -} - -BENCHMARK_DEFINE_F(MyFixture, SIMDExp) -(benchmark::State& state) -{ - for (auto _ : state) { - sfz::exp(source, absl::MakeSpan(result)); - benchmark::DoNotOptimize(result); - } -} - -BENCHMARK_DEFINE_F(MyFixture, ScalarExp_Unaligned) -(benchmark::State& state) -{ - for (auto _ : state) { - sfz::exp(absl::MakeSpan(source).subspan(1), absl::MakeSpan(result).subspan(1)); - benchmark::DoNotOptimize(result); - } -} - -BENCHMARK_DEFINE_F(MyFixture, SIMDExp_Unaligned) -(benchmark::State& state) -{ - for (auto _ : state) { - sfz::exp(absl::MakeSpan(source).subspan(1), absl::MakeSpan(result).subspan(1)); - benchmark::DoNotOptimize(result); - } -} - -BENCHMARK_DEFINE_F(MyFixture, ScalarLog) -(benchmark::State& state) -{ - for (auto _ : state) { - sfz::log(source, absl::MakeSpan(result)); - benchmark::DoNotOptimize(result); - } -} - -BENCHMARK_DEFINE_F(MyFixture, SIMDLog) -(benchmark::State& state) -{ - for (auto _ : state) { - sfz::log(source, absl::MakeSpan(result)); - benchmark::DoNotOptimize(result); - } -} - -BENCHMARK_DEFINE_F(MyFixture, ScalarSin) -(benchmark::State& state) -{ - for (auto _ : state) { - sfz::sin(source, absl::MakeSpan(result)); - benchmark::DoNotOptimize(result); - } -} - -BENCHMARK_DEFINE_F(MyFixture, SIMDSin) -(benchmark::State& state) -{ - for (auto _ : state) { - sfz::sin(source, absl::MakeSpan(result)); - benchmark::DoNotOptimize(result); - } -} - -BENCHMARK_DEFINE_F(MyFixture, ScalarCos) -(benchmark::State& state) -{ - for (auto _ : state) { - sfz::cos(source, absl::MakeSpan(result)); - benchmark::DoNotOptimize(result); - } -} - -BENCHMARK_DEFINE_F(MyFixture, SIMDCos) -(benchmark::State& state) -{ - for (auto _ : state) { - sfz::cos(source, absl::MakeSpan(result)); - benchmark::DoNotOptimize(result); - } -} - BENCHMARK_DEFINE_F(MyFixture, ScalarLibmFloorLog2) (benchmark::State& state) { @@ -159,16 +69,6 @@ BENCHMARK_DEFINE_F(MyFixture, ScalarFastFloorLog2) } BENCHMARK_REGISTER_F(MyFixture, Dummy)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); -BENCHMARK_REGISTER_F(MyFixture, ScalarExp)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); -BENCHMARK_REGISTER_F(MyFixture, SIMDExp)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); -BENCHMARK_REGISTER_F(MyFixture, ScalarExp_Unaligned)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); -BENCHMARK_REGISTER_F(MyFixture, SIMDExp_Unaligned)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); -BENCHMARK_REGISTER_F(MyFixture, ScalarLog)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); -BENCHMARK_REGISTER_F(MyFixture, SIMDLog)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); -BENCHMARK_REGISTER_F(MyFixture, ScalarSin)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); -BENCHMARK_REGISTER_F(MyFixture, SIMDSin)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); -BENCHMARK_REGISTER_F(MyFixture, ScalarCos)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); -BENCHMARK_REGISTER_F(MyFixture, SIMDCos)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); BENCHMARK_REGISTER_F(MyFixture, ScalarLibmFloorLog2)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); BENCHMARK_REGISTER_F(MyFixture, ScalarFastFloorLog2)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); diff --git a/benchmarks/BM_pan.cpp b/benchmarks/BM_pan.cpp index 70707ee9..e08b447e 100644 --- a/benchmarks/BM_pan.cpp +++ b/benchmarks/BM_pan.cpp @@ -63,21 +63,6 @@ BENCHMARK_DEFINE_F(PanArray, SIMD)(benchmark::State& state) { } } -BENCHMARK_DEFINE_F(PanArray, BlockOps)(benchmark::State& state) { - ScopedFTZ ftz; - for (auto _ : state) - { - sfz::fill(span2, 1.0f); - sfz::add(span1, span2); - sfz::applyGain(piFour(), span2); - sfz::cos(span2, span1); - sfz::sin(span2, span2); - sfz::applyGain(span1, absl::MakeSpan(left)); - sfz::applyGain(span2, absl::MakeSpan(right)); - } -} - BENCHMARK_REGISTER_F(PanArray, Scalar)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(PanArray, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); -BENCHMARK_REGISTER_F(PanArray, BlockOps)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_MAIN(); diff --git a/benchmarks/BM_ramp.cpp b/benchmarks/BM_ramp.cpp index 3d7ee14e..2a056392 100644 --- a/benchmarks/BM_ramp.cpp +++ b/benchmarks/BM_ramp.cpp @@ -116,63 +116,6 @@ static void MulSIMDUnaligned(benchmark::State& state) { } } -static void LogDomainScalar(benchmark::State& state) { - sfz::Buffer output(state.range(0)); - std::random_device rd { }; - std::mt19937 gen { rd() }; - std::uniform_real_distribution dist { 1, 2 }; - for (auto _ : state) - { - auto value = dist(gen); - sfz::linearRamp(absl::MakeSpan(output), 1.0f, value); - sfz::applyGain(std::log(2.0f), absl::MakeSpan(output)); - sfz::exp(output, absl::MakeSpan(output)); - } -} - -static void LogDomainSIMD(benchmark::State& state) { - sfz::Buffer output(state.range(0)); - std::random_device rd { }; - std::mt19937 gen { rd() }; - std::uniform_real_distribution dist { 1, 2 }; - for (auto _ : state) - { - auto value = dist(gen); - sfz::linearRamp(absl::MakeSpan(output), 1.0f, value); - sfz::applyGain(std::log(2.0f), absl::MakeSpan(output)); - sfz::exp(output, absl::MakeSpan(output)); - } -} -static void LogDomainScalarUnaligned(benchmark::State& state) { - sfz::Buffer output(state.range(0)); - std::random_device rd { }; - std::mt19937 gen { rd() }; - std::uniform_real_distribution dist { 1, 2 }; - for (auto _ : state) - { - auto value = dist(gen); - auto outputSpan = absl::MakeSpan(output).subspan(1); - sfz::linearRamp(outputSpan, 1.0f, value); - sfz::applyGain(std::log(2.0f), outputSpan); - sfz::exp(outputSpan, outputSpan); - } -} - -static void LogDomainSIMDUnaligned(benchmark::State& state) { - sfz::Buffer output(state.range(0)); - std::random_device rd { }; - std::mt19937 gen { rd() }; - std::uniform_real_distribution dist { 1, 2 }; - for (auto _ : state) - { - auto value = dist(gen); - auto outputSpan = absl::MakeSpan(output).subspan(1); - sfz::linearRamp(outputSpan, 1.0f, value); - sfz::applyGain(std::log(2.0f), outputSpan); - sfz::exp(outputSpan, outputSpan); - } -} - // Register the function as a benchmark BENCHMARK(Dummy)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); BENCHMARK(LinearScalar)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); @@ -183,8 +126,4 @@ BENCHMARK(MulScalar)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); BENCHMARK(MulSIMD)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); BENCHMARK(MulScalarUnaligned)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); BENCHMARK(MulSIMDUnaligned)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); -BENCHMARK(LogDomainScalar)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); -BENCHMARK(LogDomainSIMD)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); -BENCHMARK(LogDomainScalarUnaligned)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); -BENCHMARK(LogDomainSIMDUnaligned)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); BENCHMARK_MAIN(); diff --git a/benchmarks/BM_readChunk.cpp b/benchmarks/BM_readChunk.cpp index 4cdc2068..01b93aaa 100644 --- a/benchmarks/BM_readChunk.cpp +++ b/benchmarks/BM_readChunk.cpp @@ -61,7 +61,7 @@ BENCHMARK_DEFINE_F(FileFixture, JustRead)(benchmark::State& state) { { sfz::Buffer buffer { numFrames * sndfile.channels() }; sndfile.readf(buffer.data(), numFrames); - sfz::readInterleaved(buffer, output->getSpan(0), output->getSpan(1)); + sfz::readInterleaved(buffer, output->getSpan(0), output->getSpan(1)); } } @@ -75,7 +75,7 @@ BENCHMARK_DEFINE_F(FileFixture, AllocInside)(benchmark::State& state) { { sfz::Buffer buffer { chunkSize * sndfile.channels() }; auto read = sndfile.readf(buffer.data(), chunkSize); - sfz::readInterleaved( + sfz::readInterleaved( absl::MakeSpan(buffer).first(read), output->getSpan(0).subspan(framesRead), output->getSpan(1).subspan(framesRead) @@ -95,7 +95,7 @@ BENCHMARK_DEFINE_F(FileFixture, AllocOutside)(benchmark::State& state) { while(framesRead < numFrames) { auto read = sndfile.readf(buffer.data(), chunkSize); - sfz::readInterleaved( + sfz::readInterleaved( absl::MakeSpan(buffer).first(read), output->getSpan(0).subspan(framesRead), output->getSpan(1).subspan(framesRead) @@ -124,7 +124,7 @@ BENCHMARK_DEFINE_F(FileFixture, DrWavChunked)(benchmark::State& state) { while(framesRead < numFrames) { auto read = drwav_read_pcm_frames_f32(&wav, chunkSize, buffer.data()); - sfz::readInterleaved( + sfz::readInterleaved( absl::MakeSpan(buffer).first(read), output->getSpan(0).subspan(framesRead), output->getSpan(1).subspan(framesRead) diff --git a/benchmarks/BM_readChunkFlac.cpp b/benchmarks/BM_readChunkFlac.cpp index 048ae23d..df77f637 100644 --- a/benchmarks/BM_readChunkFlac.cpp +++ b/benchmarks/BM_readChunkFlac.cpp @@ -61,7 +61,7 @@ BENCHMARK_DEFINE_F(FileFixture, SndFileOnce)(benchmark::State& state) { { sfz::Buffer buffer { numFrames * sndfile.channels() }; sndfile.readf(buffer.data(), numFrames); - sfz::readInterleaved(buffer, output->getSpan(0), output->getSpan(1)); + sfz::readInterleaved(buffer, output->getSpan(0), output->getSpan(1)); } } @@ -75,7 +75,7 @@ BENCHMARK_DEFINE_F(FileFixture, SndFileChunked)(benchmark::State& state) { { sfz::Buffer buffer { chunkSize * sndfile.channels() }; auto read = sndfile.readf(buffer.data(), chunkSize); - sfz::readInterleaved( + sfz::readInterleaved( absl::MakeSpan(buffer).first(read), output->getSpan(0).subspan(framesRead), output->getSpan(1).subspan(framesRead) @@ -104,7 +104,7 @@ BENCHMARK_DEFINE_F(FileFixture, DrWavChunked)(benchmark::State& state) { while(framesRead < numFrames) { auto read = drflac_read_pcm_frames_f32(flac, chunkSize, buffer.data()); - sfz::readInterleaved( + sfz::readInterleaved( absl::MakeSpan(buffer).first(read), output->getSpan(0).subspan(framesRead), output->getSpan(1).subspan(framesRead) diff --git a/benchmarks/BM_resample.cpp b/benchmarks/BM_resample.cpp index 75101ac3..ffd7f902 100644 --- a/benchmarks/BM_resample.cpp +++ b/benchmarks/BM_resample.cpp @@ -232,7 +232,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR2X_scalar)(benchmark::State& state) { for (auto _ : state) { auto baseBuffer = absl::make_unique>(numChannels, numFrames); - sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); + sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); auto outBuffer = upsample2x(*baseBuffer); benchmark::DoNotOptimize(outBuffer); } @@ -242,7 +242,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR4X_scalar)(benchmark::State& state) { for (auto _ : state) { auto baseBuffer = absl::make_unique>(numChannels, numFrames); - sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); + sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); auto outBuffer = upsample4x(*baseBuffer); benchmark::DoNotOptimize(outBuffer); } @@ -252,7 +252,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR8X_scalar)(benchmark::State& state) { for (auto _ : state) { auto baseBuffer = absl::make_unique>(numChannels, numFrames); - sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); + sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); auto outBuffer = upsample8x(*baseBuffer); benchmark::DoNotOptimize(outBuffer); } @@ -262,7 +262,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR2X_vector)(benchmark::State& state) { for (auto _ : state) { auto baseBuffer = absl::make_unique>(numChannels, numFrames); - sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); + sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); auto outBuffer = upsample2x(*baseBuffer); benchmark::DoNotOptimize(outBuffer); } @@ -272,7 +272,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR4X_vector)(benchmark::State& state) { for (auto _ : state) { auto baseBuffer = absl::make_unique>(numChannels, numFrames); - sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); + sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); auto outBuffer = upsample4x(*baseBuffer); benchmark::DoNotOptimize(outBuffer); } @@ -282,7 +282,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR8X_vector)(benchmark::State& state) { for (auto _ : state) { auto baseBuffer = absl::make_unique>(numChannels, numFrames); - sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); + sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); auto outBuffer = upsample8x(*baseBuffer); benchmark::DoNotOptimize(outBuffer); } @@ -300,7 +300,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_BEST)(benchmark::State& state) srcData.output_frames = static_cast(2 * numFrames); src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast(numChannels)); auto outBuffer = absl::make_unique>(numChannels, 2 * numFrames); - sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); + sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); } } @@ -317,7 +317,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_MEDIUM)(benchmark::State& state) srcData.output_frames = static_cast(2 * numFrames); src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast(numChannels)); auto outBuffer = absl::make_unique>(numChannels, 2 * numFrames); - sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); + sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); } } @@ -334,7 +334,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_FASTEST)(benchmark::State& state) srcData.output_frames = static_cast(2 * numFrames); src_simple(&srcData, SRC_SINC_FASTEST, static_cast(numChannels)); auto outBuffer = absl::make_unique>(numChannels, 2 * numFrames); - sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); + sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); } } @@ -352,7 +352,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_BEST)(benchmark::State& state) srcData.output_frames = static_cast(2 * numFrames); src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast(numChannels)); auto outBuffer = absl::make_unique>(numChannels, 2 * numFrames); - sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); + sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); } } @@ -369,7 +369,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_MEDIUM)(benchmark::State& state) srcData.output_frames = static_cast(2 * numFrames); src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast(numChannels)); auto outBuffer = absl::make_unique>(numChannels, 2 * numFrames); - sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); + sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); } } @@ -386,7 +386,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_FASTEST)(benchmark::State& state) srcData.output_frames = static_cast(2 * numFrames); src_simple(&srcData, SRC_SINC_FASTEST, static_cast(numChannels)); auto outBuffer = absl::make_unique>(numChannels, 2 * numFrames); - sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); + sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); } } @@ -403,7 +403,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_BEST)(benchmark::State& state) srcData.output_frames = static_cast(2 * numFrames); src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast(numChannels)); auto outBuffer = absl::make_unique>(numChannels, 2 * numFrames); - sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); + sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); } } @@ -420,7 +420,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_MEDIUM)(benchmark::State& state) srcData.output_frames = static_cast(2 * numFrames); src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast(numChannels)); auto outBuffer = absl::make_unique>(numChannels, 2 * numFrames); - sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); + sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); } } @@ -437,7 +437,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_FASTEST)(benchmark::State& state) srcData.output_frames = static_cast(2 * numFrames); src_simple(&srcData, SRC_SINC_FASTEST, static_cast(numChannels)); auto outBuffer = absl::make_unique>(numChannels, 2 * numFrames); - sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); + sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); } } @@ -446,7 +446,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR8X_default)(benchmark::State& state) { for (auto _ : state) { auto baseBuffer = absl::make_unique>(numChannels, numFrames); - sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); + sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); auto outBuffer = upsample8x(*baseBuffer); benchmark::DoNotOptimize(outBuffer); } diff --git a/benchmarks/BM_resampleChunk.cpp b/benchmarks/BM_resampleChunk.cpp index a75c06c5..59ba3434 100644 --- a/benchmarks/BM_resampleChunk.cpp +++ b/benchmarks/BM_resampleChunk.cpp @@ -105,7 +105,7 @@ BENCHMARK_DEFINE_F(FileFixture, NoResampling)(benchmark::State& state) { { sfz::Buffer buffer { numFrames * sndfile.channels() }; sndfile.readf(buffer.data(), sndfile.frames()); - sfz::readInterleaved(buffer, output->getSpan(0), output->getSpan(1)); + sfz::readInterleaved(buffer, output->getSpan(0), output->getSpan(1)); } } @@ -121,7 +121,7 @@ BENCHMARK_DEFINE_F(FileFixture, ResampleAtOnce)(benchmark::State& state) { upsampler4x.set_coefs(coeffsStage4x.data()); sndfile.readf(buffer.data(), numFrames); - sfz::readInterleaved(buffer, output->getSpan(0), output->getSpan(1)); + sfz::readInterleaved(buffer, output->getSpan(0), output->getSpan(1)); upsampler2x.process_block(temp.data(), output->channelReader(0), static_cast(numFrames)); upsampler4x.process_block(output->channelWriter(0), temp.data(), static_cast(numFrames * 2)); @@ -171,7 +171,7 @@ BENCHMARK_DEFINE_F(FileFixture, ResampleInChunks)(benchmark::State& state) { thisChunkSize * sndfile.channels() ); - sfz::readInterleaved(bufferChunk, leftSpan, rightSpan); + sfz::readInterleaved(bufferChunk, leftSpan, rightSpan); upsampler2xLeft.process_block(chunkSpan.data(), leftSpan.data(), static_cast(thisChunkSize)); upsampler4xLeft.process_block(output->channelWriter(0) + outputFrameCounter, chunkSpan.data(), static_cast(thisChunkSize * 2)); diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 3f3ca5b2..b2fa4195 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -70,7 +70,7 @@ target_link_libraries(bm_logger PRIVATE sfizz::sfizz) if (TARGET sfizz-samplerate) sfizz_add_benchmark(bm_resample BM_resample.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_resample PRIVATE sfizz-samplerate sfizz-sndfile) +target_link_libraries(bm_resample PRIVATE sfizz-samplerate sfizz-sndfile sfizz-cpuid) endif() sfizz_add_benchmark(bm_envelopes BM_envelopes.cpp) diff --git a/src/sfizz/SIMDHelpers.h b/src/sfizz/SIMDHelpers.h index d22ef484..840853a3 100644 --- a/src/sfizz/SIMDHelpers.h +++ b/src/sfizz/SIMDHelpers.h @@ -103,12 +103,10 @@ bool unaligned(const T* ptr1, Args... rest) /** * @brief Read interleaved stereo data from a buffer and separate it in a left/right pair of buffers. * - * The output size will be the minimum of the input span and output spans size. - * - * @tparam T the underlying type * @param input * @param outputLeft * @param outputRight + * @param inputSize */ void readInterleaved(const float* input, float* outputLeft, float* outputRight, unsigned inputSize) noexcept; @@ -125,12 +123,10 @@ inline void readInterleaved(absl::Span input, absl::Span out /** * @brief Write a pair of left and right stereo input into a single buffer interleaved. * - * The output size will be the minimum of the input spans and output span size. - * - * @tparam T the underlying type * @param inputLeft * @param inputRight * @param output + * @param outputSize */ void writeInterleaved(const float* inputLeft, const float* inputRight, float* output, unsigned outputSize) noexcept; @@ -144,10 +140,9 @@ inline void writeInterleaved(absl::Span inputLeft, absl::Span output, T value) noexcept absl::c_fill(output, value); } -/** - * @brief Exp math function - * - * @tparam T the underlying type - * @tparam SIMD use the SIMD version or the scalar version - * @param input - * @param output - */ -template -void exp(absl::Span input, absl::Span output) noexcept -{ - CHECK(output.size() >= input.size()); - auto sentinel = std::min(input.size(), output.size()); - for (decltype(sentinel) i = 0; i < sentinel; ++i) - output[i] = std::exp(input[i]); -} - -template <> -void exp(absl::Span input, absl::Span output) noexcept; - -/** - * @brief Log math function - * - * The output size will be the minimum of the input span and output span size. - * - * @tparam T the underlying type - * @tparam SIMD use the SIMD version or the scalar version - * @param input - * @param output - */ -template -void log(absl::Span input, absl::Span output) noexcept -{ - CHECK(output.size() >= input.size()); - auto sentinel = std::min(input.size(), output.size()); - for (decltype(sentinel) i = 0; i < sentinel; ++i) - output[i] = std::log(input[i]); -} - -template <> -void log(absl::Span input, absl::Span output) noexcept; - -/** - * @brief sin math function - * - * The output size will be the minimum of the input span and output span size. - * - * @tparam T the underlying type - * @tparam SIMD use the SIMD version or the scalar version - * @param input - * @param output - */ -template -void sin(absl::Span input, absl::Span output) noexcept -{ - CHECK(output.size() >= input.size()); - auto sentinel = std::min(input.size(), output.size()); - for (decltype(sentinel) i = 0; i < sentinel; ++i) - output[i] = std::sin(input[i]); -} - -template <> -void sin(absl::Span input, absl::Span output) noexcept; - -/** - * @brief cos math function - * - * The output size will be the minimum of the input span and output span size. - * - * @tparam T the underlying type - * @tparam SIMD use the SIMD version or the scalar version - * @param input - * @param output - */ -template -void cos(absl::Span input, absl::Span output) noexcept -{ - CHECK(output.size() >= input.size()); - auto sentinel = std::min(input.size(), output.size()); - for (decltype(sentinel) i = 0; i < sentinel; ++i) - output[i] = std::cos(input[i]); -} - -template <> -void cos(absl::Span input, absl::Span output) noexcept; - namespace _internals { template inline void snippetSaturatingIndex(const T*& jump, T*& leftCoeff, T*& rightCoeff, int*& index, T& floatIndex, T loopEnd) diff --git a/src/sfizz/SIMDSSE.cpp b/src/sfizz/SIMDSSE.cpp index 3c9fdb8f..607ae2e7 100644 --- a/src/sfizz/SIMDSSE.cpp +++ b/src/sfizz/SIMDSSE.cpp @@ -16,90 +16,6 @@ constexpr uintptr_t TypeAlignment = 4; -template <> -void sfz::exp(absl::Span input, absl::Span output) noexcept -{ - CHECK(output.size() >= input.size()); - auto* in = input.begin(); - auto* out = output.begin(); - auto* sentinel = in + std::min(input.size(), output.size()); - const auto* lastAligned = prevAligned(sentinel); - - while (unaligned(in, out) && in < lastAligned) - *out++ = std::exp(*in++); - - while (in < lastAligned) { - _mm_store_ps(out, exp_ps(_mm_load_ps(in))); - incrementAll(out, in); - } - - while (in < sentinel) - *out++ = std::exp(*in++); -} - -template <> -void sfz::cos(absl::Span input, absl::Span output) noexcept -{ - CHECK(output.size() >= input.size()); - auto* in = input.begin(); - auto* out = output.begin(); - auto* sentinel = in + std::min(input.size(), output.size()); - const auto* lastAligned = prevAligned(sentinel); - - while (unaligned(in, out) && in < lastAligned) - *out++ = std::exp(*in++); - - while (in < lastAligned) { - _mm_store_ps(out, cos_ps(_mm_load_ps(in))); - incrementAll(out, in); - } - - while (in < sentinel) - *out++ = std::exp(*in++); -} - -template <> -void sfz::log(absl::Span input, absl::Span output) noexcept -{ - CHECK(output.size() >= input.size()); - auto* in = input.begin(); - auto* out = output.begin(); - auto* sentinel = in + std::min(input.size(), output.size()); - const auto* lastAligned = prevAligned(sentinel); - - while (unaligned(in, out) && in < lastAligned) - *out++ = std::exp(*in++); - - while (in < lastAligned) { - _mm_store_ps(out, log_ps(_mm_load_ps(in))); - incrementAll(out, in); - } - - while (in < sentinel) - *out++ = std::exp(*in++); -} - -template <> -void sfz::sin(absl::Span input, absl::Span output) noexcept -{ - CHECK(output.size() >= input.size()); - auto* in = input.begin(); - auto* out = output.begin(); - auto* sentinel = in + std::min(input.size(), output.size()); - const auto* lastAligned = prevAligned(sentinel); - - while (unaligned(in, out) && in < lastAligned) - *out++ = std::exp(*in++); - - while (in < lastAligned) { - _mm_store_ps(out, sin_ps(_mm_load_ps(in))); - incrementAll(out, in); - } - - while (in < sentinel) - *out++ = std::exp(*in++); -} - template <> void sfz::applyGain(float gain, absl::Span input, absl::Span output) noexcept { diff --git a/tests/EQ.cpp b/tests/EQ.cpp index a75eea55..23082efe 100644 --- a/tests/EQ.cpp +++ b/tests/EQ.cpp @@ -68,7 +68,7 @@ int main(int argc, char** argv) sfz::Buffer buffer { numFrames * 2 }; sfz::Buffer right { numFrames }; sndfile.readf(buffer.data(), numFrames * 2 ); - sfz::readInterleaved(buffer, absl::MakeSpan(left), absl::MakeSpan(right)); + sfz::readInterleaved(buffer, absl::MakeSpan(left), absl::MakeSpan(right)); } else if (sndfile.channels() == 1) { sndfile.readf(left.data(), numFrames); } else { diff --git a/tests/Filter.cpp b/tests/Filter.cpp index 32c7bd2a..8104aa0b 100644 --- a/tests/Filter.cpp +++ b/tests/Filter.cpp @@ -71,7 +71,7 @@ int main(int argc, char** argv) sfz::Buffer buffer { numFrames * 2 }; sfz::Buffer right { numFrames }; sndfile.readf(buffer.data(), numFrames * 2 ); - sfz::readInterleaved(buffer, absl::MakeSpan(left), absl::MakeSpan(right)); + sfz::readInterleaved(buffer, absl::MakeSpan(left), absl::MakeSpan(right)); } else if (sndfile.channels() == 1) { sndfile.readf(left.data(), numFrames); } else {