Remove the trig/log/exp functions
We're tabulating these if speed is needed anyway
This commit is contained in:
parent
b10b05078a
commit
04af0b8d80
12 changed files with 32 additions and 383 deletions
|
|
@ -45,96 +45,6 @@ BENCHMARK_DEFINE_F(MyFixture, Dummy)
|
|||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, ScalarExp)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
sfz::exp<float, false>(source, absl::MakeSpan(result));
|
||||
benchmark::DoNotOptimize(result);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, SIMDExp)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
sfz::exp<float, true>(source, absl::MakeSpan(result));
|
||||
benchmark::DoNotOptimize(result);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, ScalarExp_Unaligned)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
sfz::exp<float, false>(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<float, true>(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<float, false>(source, absl::MakeSpan(result));
|
||||
benchmark::DoNotOptimize(result);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, SIMDLog)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
sfz::log<float, true>(source, absl::MakeSpan(result));
|
||||
benchmark::DoNotOptimize(result);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, ScalarSin)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
sfz::sin<float, false>(source, absl::MakeSpan(result));
|
||||
benchmark::DoNotOptimize(result);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, SIMDSin)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
sfz::sin<float, true>(source, absl::MakeSpan(result));
|
||||
benchmark::DoNotOptimize(result);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, ScalarCos)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
sfz::cos<float, false>(source, absl::MakeSpan(result));
|
||||
benchmark::DoNotOptimize(result);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, SIMDCos)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
sfz::cos<float, true>(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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<float>(span1, span2);
|
||||
sfz::applyGain<float>(piFour<float>(), span2);
|
||||
sfz::cos<float>(span2, span1);
|
||||
sfz::sin<float>(span2, span2);
|
||||
sfz::applyGain<float>(span1, absl::MakeSpan(left));
|
||||
sfz::applyGain<float>(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();
|
||||
|
|
|
|||
|
|
@ -116,63 +116,6 @@ static void MulSIMDUnaligned(benchmark::State& state) {
|
|||
}
|
||||
}
|
||||
|
||||
static void LogDomainScalar(benchmark::State& state) {
|
||||
sfz::Buffer<float> output(state.range(0));
|
||||
std::random_device rd { };
|
||||
std::mt19937 gen { rd() };
|
||||
std::uniform_real_distribution<float> dist { 1, 2 };
|
||||
for (auto _ : state)
|
||||
{
|
||||
auto value = dist(gen);
|
||||
sfz::linearRamp<float, false>(absl::MakeSpan(output), 1.0f, value);
|
||||
sfz::applyGain<float, false>(std::log(2.0f), absl::MakeSpan(output));
|
||||
sfz::exp<float, false>(output, absl::MakeSpan(output));
|
||||
}
|
||||
}
|
||||
|
||||
static void LogDomainSIMD(benchmark::State& state) {
|
||||
sfz::Buffer<float> output(state.range(0));
|
||||
std::random_device rd { };
|
||||
std::mt19937 gen { rd() };
|
||||
std::uniform_real_distribution<float> dist { 1, 2 };
|
||||
for (auto _ : state)
|
||||
{
|
||||
auto value = dist(gen);
|
||||
sfz::linearRamp<float, true>(absl::MakeSpan(output), 1.0f, value);
|
||||
sfz::applyGain<float, true>(std::log(2.0f), absl::MakeSpan(output));
|
||||
sfz::exp<float, true>(output, absl::MakeSpan(output));
|
||||
}
|
||||
}
|
||||
static void LogDomainScalarUnaligned(benchmark::State& state) {
|
||||
sfz::Buffer<float> output(state.range(0));
|
||||
std::random_device rd { };
|
||||
std::mt19937 gen { rd() };
|
||||
std::uniform_real_distribution<float> dist { 1, 2 };
|
||||
for (auto _ : state)
|
||||
{
|
||||
auto value = dist(gen);
|
||||
auto outputSpan = absl::MakeSpan(output).subspan(1);
|
||||
sfz::linearRamp<float, false>(outputSpan, 1.0f, value);
|
||||
sfz::applyGain<float, false>(std::log(2.0f), outputSpan);
|
||||
sfz::exp<float, false>(outputSpan, outputSpan);
|
||||
}
|
||||
}
|
||||
|
||||
static void LogDomainSIMDUnaligned(benchmark::State& state) {
|
||||
sfz::Buffer<float> output(state.range(0));
|
||||
std::random_device rd { };
|
||||
std::mt19937 gen { rd() };
|
||||
std::uniform_real_distribution<float> dist { 1, 2 };
|
||||
for (auto _ : state)
|
||||
{
|
||||
auto value = dist(gen);
|
||||
auto outputSpan = absl::MakeSpan(output).subspan(1);
|
||||
sfz::linearRamp<float, true>(outputSpan, 1.0f, value);
|
||||
sfz::applyGain<float, true>(std::log(2.0f), outputSpan);
|
||||
sfz::exp<float, true>(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();
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ BENCHMARK_DEFINE_F(FileFixture, JustRead)(benchmark::State& state) {
|
|||
{
|
||||
sfz::Buffer<float> buffer { numFrames * sndfile.channels() };
|
||||
sndfile.readf(buffer.data(), numFrames);
|
||||
sfz::readInterleaved<float>(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<float> buffer { chunkSize * sndfile.channels() };
|
||||
auto read = sndfile.readf(buffer.data(), chunkSize);
|
||||
sfz::readInterleaved<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
sfz::readInterleaved(
|
||||
absl::MakeSpan(buffer).first(read),
|
||||
output->getSpan(0).subspan(framesRead),
|
||||
output->getSpan(1).subspan(framesRead)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ BENCHMARK_DEFINE_F(FileFixture, SndFileOnce)(benchmark::State& state) {
|
|||
{
|
||||
sfz::Buffer<float> buffer { numFrames * sndfile.channels() };
|
||||
sndfile.readf(buffer.data(), numFrames);
|
||||
sfz::readInterleaved<float>(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<float> buffer { chunkSize * sndfile.channels() };
|
||||
auto read = sndfile.readf(buffer.data(), chunkSize);
|
||||
sfz::readInterleaved<float>(
|
||||
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<float>(
|
||||
sfz::readInterleaved(
|
||||
absl::MakeSpan(buffer).first(read),
|
||||
output->getSpan(0).subspan(framesRead),
|
||||
output->getSpan(1).subspan(framesRead)
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR2X_scalar)(benchmark::State& state)
|
|||
{
|
||||
for (auto _ : state) {
|
||||
auto baseBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames);
|
||||
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
auto outBuffer = upsample2x<float, false>(*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<sfz::AudioBuffer<float>>(numChannels, numFrames);
|
||||
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
auto outBuffer = upsample4x<float, false>(*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<sfz::AudioBuffer<float>>(numChannels, numFrames);
|
||||
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
auto outBuffer = upsample8x<float, false>(*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<sfz::AudioBuffer<float>>(numChannels, numFrames);
|
||||
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
auto outBuffer = upsample2x<float, true>(*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<sfz::AudioBuffer<float>>(numChannels, numFrames);
|
||||
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
auto outBuffer = upsample4x<float, true>(*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<sfz::AudioBuffer<float>>(numChannels, numFrames);
|
||||
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
auto outBuffer = upsample8x<float, true>(*baseBuffer);
|
||||
benchmark::DoNotOptimize(outBuffer);
|
||||
}
|
||||
|
|
@ -300,7 +300,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_BEST)(benchmark::State& state)
|
|||
srcData.output_frames = static_cast<long>(2 * numFrames);
|
||||
src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast<int>(numChannels));
|
||||
auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
|
||||
sfz::readInterleaved<float>(*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<long>(2 * numFrames);
|
||||
src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast<int>(numChannels));
|
||||
auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
|
||||
sfz::readInterleaved<float>(*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<long>(2 * numFrames);
|
||||
src_simple(&srcData, SRC_SINC_FASTEST, static_cast<int>(numChannels));
|
||||
auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
|
||||
sfz::readInterleaved<float>(*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<long>(2 * numFrames);
|
||||
src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast<int>(numChannels));
|
||||
auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
|
||||
sfz::readInterleaved<float>(*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<long>(2 * numFrames);
|
||||
src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast<int>(numChannels));
|
||||
auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
|
||||
sfz::readInterleaved<float>(*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<long>(2 * numFrames);
|
||||
src_simple(&srcData, SRC_SINC_FASTEST, static_cast<int>(numChannels));
|
||||
auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
|
||||
sfz::readInterleaved<float>(*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<long>(2 * numFrames);
|
||||
src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast<int>(numChannels));
|
||||
auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
|
||||
sfz::readInterleaved<float>(*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<long>(2 * numFrames);
|
||||
src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast<int>(numChannels));
|
||||
auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
|
||||
sfz::readInterleaved<float>(*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<long>(2 * numFrames);
|
||||
src_simple(&srcData, SRC_SINC_FASTEST, static_cast<int>(numChannels));
|
||||
auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
|
||||
sfz::readInterleaved<float>(*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<sfz::AudioBuffer<float>>(numChannels, numFrames);
|
||||
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
sfz::readInterleaved(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
|
||||
auto outBuffer = upsample8x<float>(*baseBuffer);
|
||||
benchmark::DoNotOptimize(outBuffer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ BENCHMARK_DEFINE_F(FileFixture, NoResampling)(benchmark::State& state) {
|
|||
{
|
||||
sfz::Buffer<float> buffer { numFrames * sndfile.channels() };
|
||||
sndfile.readf(buffer.data(), sndfile.frames());
|
||||
sfz::readInterleaved<float>(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<float>(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<long>(numFrames));
|
||||
upsampler4x.process_block(output->channelWriter(0), temp.data(), static_cast<long>(numFrames * 2));
|
||||
|
|
@ -171,7 +171,7 @@ BENCHMARK_DEFINE_F(FileFixture, ResampleInChunks)(benchmark::State& state) {
|
|||
thisChunkSize * sndfile.channels()
|
||||
);
|
||||
|
||||
sfz::readInterleaved<float>(bufferChunk, leftSpan, rightSpan);
|
||||
sfz::readInterleaved(bufferChunk, leftSpan, rightSpan);
|
||||
|
||||
upsampler2xLeft.process_block(chunkSpan.data(), leftSpan.data(), static_cast<long>(thisChunkSize));
|
||||
upsampler4xLeft.process_block(output->channelWriter(0) + outputFrameCounter, chunkSpan.data(), static_cast<long>(thisChunkSize * 2));
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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<const float> input, absl::Span<float> 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<const float> inputLeft, absl::Span<const
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Fill a buffer with a value; comparable to std::fill in essence.
|
||||
* @brief Fill a buffer with a value
|
||||
*
|
||||
* @tparam T the underlying type
|
||||
* @tparam SIMD use the SIMD version or the scalar version
|
||||
* @param output
|
||||
* @param value
|
||||
*/
|
||||
|
|
@ -157,92 +152,6 @@ void fill(absl::Span<T> 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 <class Type, bool SIMD = SIMDConfig::mathfuns>
|
||||
void exp(absl::Span<const Type> input, absl::Span<Type> 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<float, true>(absl::Span<const float> input, absl::Span<float> 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 <class Type, bool SIMD = SIMDConfig::mathfuns>
|
||||
void log(absl::Span<const Type> input, absl::Span<Type> 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<float, true>(absl::Span<const float> input, absl::Span<float> 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 <class Type, bool SIMD = SIMDConfig::mathfuns>
|
||||
void sin(absl::Span<const Type> input, absl::Span<Type> 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<float, true>(absl::Span<const float> input, absl::Span<float> 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 <class Type, bool SIMD = SIMDConfig::mathfuns>
|
||||
void cos(absl::Span<const Type> input, absl::Span<Type> 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<float, true>(absl::Span<const float> input, absl::Span<float> output) noexcept;
|
||||
|
||||
namespace _internals {
|
||||
template <class T>
|
||||
inline void snippetSaturatingIndex(const T*& jump, T*& leftCoeff, T*& rightCoeff, int*& index, T& floatIndex, T loopEnd)
|
||||
|
|
|
|||
|
|
@ -16,90 +16,6 @@
|
|||
|
||||
constexpr uintptr_t TypeAlignment = 4;
|
||||
|
||||
template <>
|
||||
void sfz::exp<float, true>(absl::Span<const float> input, absl::Span<float> 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<TypeAlignment>(out, in);
|
||||
}
|
||||
|
||||
while (in < sentinel)
|
||||
*out++ = std::exp(*in++);
|
||||
}
|
||||
|
||||
template <>
|
||||
void sfz::cos<float, true>(absl::Span<const float> input, absl::Span<float> 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<TypeAlignment>(out, in);
|
||||
}
|
||||
|
||||
while (in < sentinel)
|
||||
*out++ = std::exp(*in++);
|
||||
}
|
||||
|
||||
template <>
|
||||
void sfz::log<float, true>(absl::Span<const float> input, absl::Span<float> 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<TypeAlignment>(out, in);
|
||||
}
|
||||
|
||||
while (in < sentinel)
|
||||
*out++ = std::exp(*in++);
|
||||
}
|
||||
|
||||
template <>
|
||||
void sfz::sin<float, true>(absl::Span<const float> input, absl::Span<float> 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<TypeAlignment>(out, in);
|
||||
}
|
||||
|
||||
while (in < sentinel)
|
||||
*out++ = std::exp(*in++);
|
||||
}
|
||||
|
||||
template <>
|
||||
void sfz::applyGain<float, true>(float gain, absl::Span<const float> input, absl::Span<float> output) noexcept
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ int main(int argc, char** argv)
|
|||
sfz::Buffer<float> buffer { numFrames * 2 };
|
||||
sfz::Buffer<float> right { numFrames };
|
||||
sndfile.readf(buffer.data(), numFrames * 2 );
|
||||
sfz::readInterleaved<float>(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 {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ int main(int argc, char** argv)
|
|||
sfz::Buffer<float> buffer { numFrames * 2 };
|
||||
sfz::Buffer<float> right { numFrames };
|
||||
sndfile.readf(buffer.data(), numFrames * 2 );
|
||||
sfz::readInterleaved<float>(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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue